From 2398931cc1e8cc1d3136a11975da3e34a44d9ccf Mon Sep 17 00:00:00 2001
From: miloschwartz
Date: Sat, 12 Apr 2025 19:57:37 -0400
Subject: [PATCH] fix ref type error
---
src/app/[orgId]/settings/sites/SitesTable.tsx | 37 +-
src/components/tags/autocomplete.tsx | 2 +-
src/components/tags/tag-input.tsx | 1362 ++++++++---------
src/components/ui/alert.tsx | 76 +-
src/components/ui/avatar.tsx | 81 +-
src/components/ui/badge.tsx | 2 +-
src/components/ui/breadcrumb.tsx | 105 +-
src/components/ui/button.tsx | 52 +-
src/components/ui/card.tsx | 142 +-
src/components/ui/checkbox.tsx | 51 +-
src/components/ui/command.tsx | 196 ++-
src/components/ui/dialog.tsx | 123 +-
src/components/ui/drawer.tsx | 117 +-
src/components/ui/dropdown-menu.tsx | 270 ++--
src/components/ui/form.tsx | 75 +-
src/components/ui/input-otp.tsx | 79 +-
src/components/ui/input.tsx | 77 +-
src/components/ui/label.tsx | 22 +-
src/components/ui/popover.tsx | 62 +-
src/components/ui/radio-group.tsx | 32 +-
src/components/ui/select.tsx | 256 ++--
src/components/ui/separator.tsx | 42 +-
src/components/ui/sheet.tsx | 118 +-
src/components/ui/switch.tsx | 37 +-
src/components/ui/table.tsx | 86 +-
src/components/ui/tabs.tsx | 87 +-
src/components/ui/textarea.tsx | 32 +-
src/components/ui/toast.tsx | 154 +-
28 files changed, 1764 insertions(+), 2011 deletions(-)
diff --git a/src/app/[orgId]/settings/sites/SitesTable.tsx b/src/app/[orgId]/settings/sites/SitesTable.tsx
index 0a30459c..c0cc5801 100644
--- a/src/app/[orgId]/settings/sites/SitesTable.tsx
+++ b/src/app/[orgId]/settings/sites/SitesTable.tsx
@@ -283,17 +283,46 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
{selectedSite && (
deleteSite(selectedSite.id)}
+ setOpen={(val) => {
+ setIsDeleteModalOpen(val);
+ setSelectedSite(null);
+ }}
+ dialog={
+
+
+ Are you sure you want to remove the site{" "}
+ {selectedSite?.name || selectedSite?.id}{" "}
+ from the organization?
+
+
+
+ Once removed, the site will no longer be
+ accessible.{" "}
+
+ All resources and targets associated with
+ the site will also be removed.
+
+
+
+
+ To confirm, please type the name of the site
+ below.
+
+
+ }
+ buttonText="Confirm Delete Site"
+ onConfirm={async () => deleteSite(selectedSite!.id)}
+ string={selectedSite.name}
title="Delete Site"
- description="Are you sure you want to delete this site? This action cannot be undone."
/>
)}
router.push(`/${orgId}/settings/sites/create`)}
+ createSite={() =>
+ router.push(`/${orgId}/settings/sites/create`)
+ }
/>
>
);
diff --git a/src/components/tags/autocomplete.tsx b/src/components/tags/autocomplete.tsx
index 64efb5ec..db8d76c3 100644
--- a/src/components/tags/autocomplete.tsx
+++ b/src/components/tags/autocomplete.tsx
@@ -306,7 +306,7 @@ export const Autocomplete: React.FC = ({
role="option"
aria-selected={isSelected}
className={cn(
- "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden aria-selected:bg-accent aria-selected:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 hover:bg-accent",
+ "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-accent",
isSelected &&
"bg-accent text-accent-foreground",
classStyleProps?.commandItem
diff --git a/src/components/tags/tag-input.tsx b/src/components/tags/tag-input.tsx
index b50388f2..3510e968 100644
--- a/src/components/tags/tag-input.tsx
+++ b/src/components/tags/tag-input.tsx
@@ -105,93 +105,193 @@ export interface TagInputProps
generateTagId?: () => string;
}
-const TagInput = (
- {
- ref,
- ...props
- }: TagInputProps & {
- ref: React.RefObject;
- }
-) => {
- const {
- id,
- placeholder,
- tags,
- setTags,
- variant,
- size,
- shape,
- enableAutocomplete,
- autocompleteOptions,
- maxTags,
- delimiter = Delimiter.Comma,
- onTagAdd,
- onTagRemove,
- allowDuplicates,
- showCount,
- validateTag,
- placeholderWhenFull = "Max tags reached",
- sortTags,
- delimiterList,
- truncate,
- autocompleteFilter,
- borderStyle,
- textCase,
- interaction,
- animation,
- textStyle,
- minLength,
- maxLength,
- direction = "row",
- onInputChange,
- customTagRenderer,
- onFocus,
- onBlur,
- onTagClick,
- draggable = false,
- inputFieldPosition = "bottom",
- clearAll = false,
- onClearAll,
- usePopoverForTags = false,
- inputProps = {},
- restrictTagsToAutocompleteOptions,
- inlineTags = true,
- addTagsOnBlur = false,
- activeTagIndex,
- setActiveTagIndex,
- styleClasses = {},
- disabled = false,
- usePortal = false,
- addOnPaste = false,
- generateTagId = uuid
- } = props;
+const TagInput = React.forwardRef(
+ (props, ref) => {
+ const {
+ id,
+ placeholder,
+ tags,
+ setTags,
+ variant,
+ size,
+ shape,
+ enableAutocomplete,
+ autocompleteOptions,
+ maxTags,
+ delimiter = Delimiter.Comma,
+ onTagAdd,
+ onTagRemove,
+ allowDuplicates,
+ showCount,
+ validateTag,
+ placeholderWhenFull = "Max tags reached",
+ sortTags,
+ delimiterList,
+ truncate,
+ autocompleteFilter,
+ borderStyle,
+ textCase,
+ interaction,
+ animation,
+ textStyle,
+ minLength,
+ maxLength,
+ direction = "row",
+ onInputChange,
+ customTagRenderer,
+ onFocus,
+ onBlur,
+ onTagClick,
+ draggable = false,
+ inputFieldPosition = "bottom",
+ clearAll = false,
+ onClearAll,
+ usePopoverForTags = false,
+ inputProps = {},
+ restrictTagsToAutocompleteOptions,
+ inlineTags = true,
+ addTagsOnBlur = false,
+ activeTagIndex,
+ setActiveTagIndex,
+ styleClasses = {},
+ disabled = false,
+ usePortal = false,
+ addOnPaste = false,
+ generateTagId = uuid
+ } = props;
- const [inputValue, setInputValue] = React.useState("");
- const [tagCount, setTagCount] = React.useState(
- Math.max(0, tags.length)
- );
- const inputRef = React.useRef(null);
+ const [inputValue, setInputValue] = React.useState("");
+ const [tagCount, setTagCount] = React.useState(
+ Math.max(0, tags.length)
+ );
+ const inputRef = React.useRef(null);
- if (
- (maxTags !== undefined && maxTags < 0) ||
- (props.minTags !== undefined && props.minTags < 0)
- ) {
- console.warn("maxTags and minTags cannot be less than 0");
- // error
- return null;
- }
+ if (
+ (maxTags !== undefined && maxTags < 0) ||
+ (props.minTags !== undefined && props.minTags < 0)
+ ) {
+ console.warn("maxTags and minTags cannot be less than 0");
+ // error
+ return null;
+ }
- const handleInputChange = (e: React.ChangeEvent) => {
- const newValue = e.target.value;
- if (addOnPaste && newValue.includes(delimiter)) {
- const splitValues = newValue
- .split(delimiter)
- .map((v) => v.trim())
- .filter((v) => v);
- splitValues.forEach((value) => {
- if (!value) return; // Skip empty strings from split
+ const handleInputChange = (e: React.ChangeEvent) => {
+ const newValue = e.target.value;
+ if (addOnPaste && newValue.includes(delimiter)) {
+ const splitValues = newValue
+ .split(delimiter)
+ .map((v) => v.trim())
+ .filter((v) => v);
+ splitValues.forEach((value) => {
+ if (!value) return; // Skip empty strings from split
- const newTagText = value.trim();
+ const newTagText = value.trim();
+
+ // Check if the tag is in the autocomplete options if restrictTagsToAutocomplete is true
+ if (
+ restrictTagsToAutocompleteOptions &&
+ !autocompleteOptions?.some(
+ (option) => option.text === newTagText
+ )
+ ) {
+ console.warn(
+ "Tag not allowed as per autocomplete options"
+ );
+ return;
+ }
+
+ if (validateTag && !validateTag(newTagText)) {
+ console.warn("Invalid tag as per validateTag");
+ return;
+ }
+
+ if (minLength && newTagText.length < minLength) {
+ console.warn(`Tag "${newTagText}" is too short`);
+ return;
+ }
+
+ if (maxLength && newTagText.length > maxLength) {
+ console.warn(`Tag "${newTagText}" is too long`);
+ return;
+ }
+
+ const newTagId = generateTagId();
+
+ // Add tag if duplicates are allowed or tag does not already exist
+ if (
+ allowDuplicates ||
+ !tags.some((tag) => tag.text === newTagText)
+ ) {
+ if (maxTags === undefined || tags.length < maxTags) {
+ // Check for maxTags limit
+ const newTag = { id: newTagId, text: newTagText };
+ setTags((prevTags) => [...prevTags, newTag]);
+ onTagAdd?.(newTagText);
+ } else {
+ console.warn(
+ "Reached the maximum number of tags allowed"
+ );
+ }
+ } else {
+ console.warn(`Duplicate tag "${newTagText}" not added`);
+ }
+ });
+ setInputValue("");
+ } else {
+ setInputValue(newValue);
+ }
+ onInputChange?.(newValue);
+ };
+
+ const handleInputFocus = (
+ event: React.FocusEvent
+ ) => {
+ setActiveTagIndex(null); // Reset active tag index when the input field gains focus
+ onFocus?.(event);
+ };
+
+ const handleInputBlur = (event: React.FocusEvent) => {
+ if (addTagsOnBlur && inputValue.trim()) {
+ const newTagText = inputValue.trim();
+
+ if (validateTag && !validateTag(newTagText)) {
+ return;
+ }
+
+ if (minLength && newTagText.length < minLength) {
+ console.warn("Tag is too short");
+ return;
+ }
+
+ if (maxLength && newTagText.length > maxLength) {
+ console.warn("Tag is too long");
+ return;
+ }
+
+ if (
+ (allowDuplicates ||
+ !tags.some((tag) => tag.text === newTagText)) &&
+ (maxTags === undefined || tags.length < maxTags)
+ ) {
+ const newTagId = generateTagId();
+ setTags([...tags, { id: newTagId, text: newTagText }]);
+ onTagAdd?.(newTagText);
+ setTagCount((prevTagCount) => prevTagCount + 1);
+ setInputValue("");
+ }
+ }
+
+ onBlur?.(event);
+ };
+
+ const handleKeyDown = (e: React.KeyboardEvent) => {
+ if (
+ delimiterList
+ ? delimiterList.includes(e.key)
+ : e.key === delimiter || e.key === Delimiter.Enter
+ ) {
+ e.preventDefault();
+ const newTagText = inputValue.trim();
// Check if the tag is in the autocomplete options if restrictTagsToAutocomplete is true
if (
@@ -200,465 +300,203 @@ const TagInput = (
(option) => option.text === newTagText
)
) {
- console.warn(
- "Tag not allowed as per autocomplete options"
- );
+ // error
return;
}
if (validateTag && !validateTag(newTagText)) {
- console.warn("Invalid tag as per validateTag");
return;
}
if (minLength && newTagText.length < minLength) {
- console.warn(`Tag "${newTagText}" is too short`);
+ console.warn("Tag is too short");
+ // error
return;
}
+ // Validate maxLength
if (maxLength && newTagText.length > maxLength) {
- console.warn(`Tag "${newTagText}" is too long`);
+ // error
+ console.warn("Tag is too long");
return;
}
const newTagId = generateTagId();
- // Add tag if duplicates are allowed or tag does not already exist
if (
- allowDuplicates ||
- !tags.some((tag) => tag.text === newTagText)
+ newTagText &&
+ (allowDuplicates ||
+ !tags.some((tag) => tag.text === newTagText)) &&
+ (maxTags === undefined || tags.length < maxTags)
) {
- if (maxTags === undefined || tags.length < maxTags) {
- // Check for maxTags limit
- const newTag = { id: newTagId, text: newTagText };
- setTags((prevTags) => [...prevTags, newTag]);
- onTagAdd?.(newTagText);
- } else {
- console.warn(
- "Reached the maximum number of tags allowed"
- );
- }
- } else {
- console.warn(`Duplicate tag "${newTagText}" not added`);
+ setTags([...tags, { id: newTagId, text: newTagText }]);
+ onTagAdd?.(newTagText);
+ setTagCount((prevTagCount) => prevTagCount + 1);
}
- });
- setInputValue("");
- } else {
- setInputValue(newValue);
- }
- onInputChange?.(newValue);
- };
-
- const handleInputFocus = (
- event: React.FocusEvent
- ) => {
- setActiveTagIndex(null); // Reset active tag index when the input field gains focus
- onFocus?.(event);
- };
-
- const handleInputBlur = (event: React.FocusEvent) => {
- if (addTagsOnBlur && inputValue.trim()) {
- const newTagText = inputValue.trim();
-
- if (validateTag && !validateTag(newTagText)) {
- return;
- }
-
- if (minLength && newTagText.length < minLength) {
- console.warn("Tag is too short");
- return;
- }
-
- if (maxLength && newTagText.length > maxLength) {
- console.warn("Tag is too long");
- return;
- }
-
- if (
- (allowDuplicates ||
- !tags.some((tag) => tag.text === newTagText)) &&
- (maxTags === undefined || tags.length < maxTags)
- ) {
- const newTagId = generateTagId();
- setTags([...tags, { id: newTagId, text: newTagText }]);
- onTagAdd?.(newTagText);
- setTagCount((prevTagCount) => prevTagCount + 1);
setInputValue("");
- }
- }
-
- onBlur?.(event);
- };
-
- const handleKeyDown = (e: React.KeyboardEvent) => {
- if (
- delimiterList
- ? delimiterList.includes(e.key)
- : e.key === delimiter || e.key === Delimiter.Enter
- ) {
- e.preventDefault();
- const newTagText = inputValue.trim();
-
- // Check if the tag is in the autocomplete options if restrictTagsToAutocomplete is true
- if (
- restrictTagsToAutocompleteOptions &&
- !autocompleteOptions?.some(
- (option) => option.text === newTagText
- )
- ) {
- // error
- return;
- }
-
- if (validateTag && !validateTag(newTagText)) {
- return;
- }
-
- if (minLength && newTagText.length < minLength) {
- console.warn("Tag is too short");
- // error
- return;
- }
-
- // Validate maxLength
- if (maxLength && newTagText.length > maxLength) {
- // error
- console.warn("Tag is too long");
- return;
- }
-
- const newTagId = generateTagId();
-
- if (
- newTagText &&
- (allowDuplicates ||
- !tags.some((tag) => tag.text === newTagText)) &&
- (maxTags === undefined || tags.length < maxTags)
- ) {
- setTags([...tags, { id: newTagId, text: newTagText }]);
- onTagAdd?.(newTagText);
- setTagCount((prevTagCount) => prevTagCount + 1);
- }
- setInputValue("");
- } else {
- switch (e.key) {
- case "Delete":
- if (activeTagIndex !== null) {
- e.preventDefault();
- const newTags = [...tags];
- newTags.splice(activeTagIndex, 1);
- setTags(newTags);
- setActiveTagIndex((prev) =>
- newTags.length === 0
- ? null
- : prev! >= newTags.length
- ? newTags.length - 1
- : prev
- );
- setTagCount((prevTagCount) => prevTagCount - 1);
- onTagRemove?.(tags[activeTagIndex].text);
- }
- break;
- case "Backspace":
- if (activeTagIndex !== null) {
- e.preventDefault();
- const newTags = [...tags];
- newTags.splice(activeTagIndex, 1);
- setTags(newTags);
- setActiveTagIndex((prev) =>
- prev! === 0 ? null : prev! - 1
- );
- setTagCount((prevTagCount) => prevTagCount - 1);
- onTagRemove?.(tags[activeTagIndex].text);
- }
- break;
- case "ArrowRight":
- e.preventDefault();
- if (activeTagIndex === null) {
- setActiveTagIndex(0);
- } else {
- setActiveTagIndex((prev) =>
- prev! + 1 >= tags.length ? 0 : prev! + 1
- );
- }
- break;
- case "ArrowLeft":
- e.preventDefault();
- if (activeTagIndex === null) {
- setActiveTagIndex(tags.length - 1);
- } else {
- setActiveTagIndex((prev) =>
- prev! === 0 ? tags.length - 1 : prev! - 1
- );
- }
- break;
- case "Home":
- e.preventDefault();
- setActiveTagIndex(0);
- break;
- case "End":
- e.preventDefault();
- setActiveTagIndex(tags.length - 1);
- break;
- }
- }
- };
-
- const removeTag = (idToRemove: string) => {
- setTags(tags.filter((tag) => tag.id !== idToRemove));
- onTagRemove?.(
- tags.find((tag) => tag.id === idToRemove)?.text || ""
- );
- setTagCount((prevTagCount) => prevTagCount - 1);
- };
-
- const onSortEnd = (oldIndex: number, newIndex: number) => {
- setTags((currentTags) => {
- const newTags = [...currentTags];
- const [removedTag] = newTags.splice(oldIndex, 1);
- newTags.splice(newIndex, 0, removedTag);
-
- return newTags;
- });
- };
-
- const handleClearAll = () => {
- if (!onClearAll) {
- setActiveTagIndex(-1);
- setTags([]);
- return;
- }
- onClearAll?.();
- };
-
- // const filteredAutocompleteOptions = autocompleteFilter
- // ? autocompleteOptions?.filter((option) => autocompleteFilter(option.text))
- // : autocompleteOptions;
- const filteredAutocompleteOptions = useMemo(() => {
- return (autocompleteOptions || []).filter((option) =>
- option.text
- .toLowerCase()
- .includes(inputValue ? inputValue.toLowerCase() : "")
- );
- }, [inputValue, autocompleteOptions]);
-
- const displayedTags = sortTags ? [...tags].sort() : tags;
-
- const truncatedTags = truncate
- ? tags.map((tag) => ({
- id: tag.id,
- text:
- tag.text?.length > truncate
- ? `${tag.text.substring(0, truncate)}...`
- : tag.text
- }))
- : displayedTags;
-
- return (
- ( 0 ? "gap-3" : ""} ${
- inputFieldPosition === "bottom"
- ? "flex-col"
- : inputFieldPosition === "top"
- ? "flex-col-reverse"
- : "flex-row"
- }`}
- >
- {!usePopoverForTags &&
- (!inlineTags ? (
-
- ) : (
- !enableAutocomplete && (
-
-
-
- = maxTags
- ? placeholderWhenFull
- : placeholder
- }
- value={inputValue}
- onChange={handleInputChange}
- onKeyDown={handleKeyDown}
- onFocus={handleInputFocus}
- onBlur={handleInputBlur}
- {...inputProps}
- className={cn(
- "border-0 h-5 bg-transparent focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 flex-1 w-fit",
- // className,
- styleClasses?.input
- )}
- autoComplete={
- enableAutocomplete ? "on" : "off"
- }
- list={
- enableAutocomplete
- ? "autocomplete-options"
- : undefined
- }
- disabled={
- disabled ||
- (maxTags !== undefined &&
- tags.length >= maxTags)
- }
- />
-
-
- )
- ))}
- {enableAutocomplete ? (
-
-
+ newTags.length === 0
+ ? null
+ : prev! >= newTags.length
+ ? newTags.length - 1
+ : prev
+ );
+ setTagCount((prevTagCount) => prevTagCount - 1);
+ onTagRemove?.(tags[activeTagIndex].text);
}
- setTagCount={setTagCount}
- maxTags={maxTags}
- onTagAdd={onTagAdd}
- onTagRemove={onTagRemove}
- allowDuplicates={allowDuplicates ?? false}
- inlineTags={inlineTags}
- usePortal={usePortal}
- classStyleProps={{
- command: styleClasses?.autoComplete?.command,
- popoverTrigger:
- styleClasses?.autoComplete?.popoverTrigger,
- popoverContent:
- styleClasses?.autoComplete?.popoverContent,
- commandList:
- styleClasses?.autoComplete?.commandList,
- commandGroup:
- styleClasses?.autoComplete?.commandGroup,
- commandItem:
- styleClasses?.autoComplete?.commandItem
- }}
- >
- {!usePopoverForTags ? (
- !inlineTags ? (
- // = maxTags ? placeholderWhenFull : placeholder}
- // ref={inputRef}
- // value={inputValue}
- // disabled={disabled || (maxTags !== undefined && tags.length >= maxTags)}
- // onChangeCapture={handleInputChange}
- // onKeyDown={handleKeyDown}
- // onFocus={handleInputFocus}
- // onBlur={handleInputBlur}
- // className={cn(
- // 'w-full',
- // // className,
- // styleClasses?.input,
- // )}
- // />
- (= maxTags
- ? placeholderWhenFull
- : placeholder
- }
- value={inputValue}
- onChange={handleInputChange}
- onKeyDown={handleKeyDown}
- onFocus={handleInputFocus}
- onBlur={handleInputBlur}
- {...inputProps}
- className={cn(
- "border-0 h-5 bg-transparent focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 flex-1 w-fit",
- // className,
- styleClasses?.input
- )}
- autoComplete={
- enableAutocomplete ? "on" : "off"
- }
- list={
- enableAutocomplete
- ? "autocomplete-options"
- : undefined
- }
- disabled={
- disabled ||
- (maxTags !== undefined &&
- tags.length >= maxTags)
- }
- />)
- ) : (
+ break;
+ case "Backspace":
+ if (activeTagIndex !== null) {
+ e.preventDefault();
+ const newTags = [...tags];
+ newTags.splice(activeTagIndex, 1);
+ setTags(newTags);
+ setActiveTagIndex((prev) =>
+ prev! === 0 ? null : prev! - 1
+ );
+ setTagCount((prevTagCount) => prevTagCount - 1);
+ onTagRemove?.(tags[activeTagIndex].text);
+ }
+ break;
+ case "ArrowRight":
+ e.preventDefault();
+ if (activeTagIndex === null) {
+ setActiveTagIndex(0);
+ } else {
+ setActiveTagIndex((prev) =>
+ prev! + 1 >= tags.length ? 0 : prev! + 1
+ );
+ }
+ break;
+ case "ArrowLeft":
+ e.preventDefault();
+ if (activeTagIndex === null) {
+ setActiveTagIndex(tags.length - 1);
+ } else {
+ setActiveTagIndex((prev) =>
+ prev! === 0 ? tags.length - 1 : prev! - 1
+ );
+ }
+ break;
+ case "Home":
+ e.preventDefault();
+ setActiveTagIndex(0);
+ break;
+ case "End":
+ e.preventDefault();
+ setActiveTagIndex(tags.length - 1);
+ break;
+ }
+ }
+ };
+
+ const removeTag = (idToRemove: string) => {
+ setTags(tags.filter((tag) => tag.id !== idToRemove));
+ onTagRemove?.(
+ tags.find((tag) => tag.id === idToRemove)?.text || ""
+ );
+ setTagCount((prevTagCount) => prevTagCount - 1);
+ };
+
+ const onSortEnd = (oldIndex: number, newIndex: number) => {
+ setTags((currentTags) => {
+ const newTags = [...currentTags];
+ const [removedTag] = newTags.splice(oldIndex, 1);
+ newTags.splice(newIndex, 0, removedTag);
+
+ return newTags;
+ });
+ };
+
+ const handleClearAll = () => {
+ if (!onClearAll) {
+ setActiveTagIndex(-1);
+ setTags([]);
+ return;
+ }
+ onClearAll?.();
+ };
+
+ // const filteredAutocompleteOptions = autocompleteFilter
+ // ? autocompleteOptions?.filter((option) => autocompleteFilter(option.text))
+ // : autocompleteOptions;
+ const filteredAutocompleteOptions = useMemo(() => {
+ return (autocompleteOptions || []).filter((option) =>
+ option.text
+ .toLowerCase()
+ .includes(inputValue ? inputValue.toLowerCase() : "")
+ );
+ }, [inputValue, autocompleteOptions]);
+
+ const displayedTags = sortTags ? [...tags].sort() : tags;
+
+ const truncatedTags = truncate
+ ? tags.map((tag) => ({
+ id: tag.id,
+ text:
+ tag.text?.length > truncate
+ ? `${tag.text.substring(0, truncate)}...`
+ : tag.text
+ }))
+ : displayedTags;
+
+ return (
+ 0 ? "gap-3" : ""} ${
+ inputFieldPosition === "bottom"
+ ? "flex-col"
+ : inputFieldPosition === "top"
+ ? "flex-col-reverse"
+ : "flex-row"
+ }`}
+ >
+ {!usePopoverForTags &&
+ (!inlineTags ? (
+
+ ) : (
+ !enableAutocomplete && (
+
+ )
+ ))}
+ {enableAutocomplete ? (
+
+
+ {!usePopoverForTags ? (
+ !inlineTags ? (
+ // = maxTags ? placeholderWhenFull : placeholder}
+ // ref={inputRef}
+ // value={inputValue}
+ // disabled={disabled || (maxTags !== undefined && tags.length >= maxTags)}
+ // onChangeCapture={handleInputChange}
+ // onKeyDown={handleKeyDown}
+ // onFocus={handleInputFocus}
+ // onBlur={handleInputBlur}
+ // className={cn(
+ // 'w-full',
+ // // className,
+ // styleClasses?.input,
+ // )}
+ // />
+ = maxTags
+ ? placeholderWhenFull
+ : placeholder
+ }
+ value={inputValue}
+ onChange={handleInputChange}
+ onKeyDown={handleKeyDown}
+ onFocus={handleInputFocus}
+ onBlur={handleInputBlur}
+ {...inputProps}
+ className={cn(
+ "border-0 h-5 bg-transparent focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 flex-1 w-fit",
+ // className,
+ styleClasses?.input
+ )}
+ autoComplete={
+ enableAutocomplete ? "on" : "off"
+ }
+ list={
+ enableAutocomplete
+ ? "autocomplete-options"
+ : undefined
+ }
+ disabled={
+ disabled ||
+ (maxTags !== undefined &&
+ tags.length >= maxTags)
+ }
+ />
+ ) : (
+
+
+ {/* = maxTags ? placeholderWhenFull : placeholder}
+ ref={inputRef}
+ value={inputValue}
+ disabled={disabled || (maxTags !== undefined && tags.length >= maxTags)}
+ onChangeCapture={handleInputChange}
+ onKeyDown={handleKeyDown}
+ onFocus={handleInputFocus}
+ onBlur={handleInputBlur}
+ inlineTags={inlineTags}
+ className={cn(
+ 'border-0 flex-1 w-fit h-5',
+ // className,
+ styleClasses?.input,
+ )}
+ /> */}
+ = maxTags
+ ? placeholderWhenFull
+ : placeholder
+ }
+ value={inputValue}
+ onChange={handleInputChange}
+ onKeyDown={handleKeyDown}
+ onFocus={handleInputFocus}
+ onBlur={handleInputBlur}
+ {...inputProps}
+ className={cn(
+ "border-0 h-5 bg-transparent focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 flex-1 w-fit",
+ // className,
+ styleClasses?.input
+ )}
+ autoComplete={
+ enableAutocomplete
+ ? "on"
+ : "off"
+ }
+ list={
+ enableAutocomplete
+ ? "autocomplete-options"
+ : undefined
+ }
+ disabled={
+ disabled ||
+ (maxTags !== undefined &&
+ tags.length >= maxTags)
+ }
+ />
+
+ )
+ ) : (
+
+ {/* = maxTags ? placeholderWhenFull : placeholder}
+ ref={inputRef}
+ value={inputValue}
+ disabled={disabled || (maxTags !== undefined && tags.length >= maxTags)}
+ onChangeCapture={handleInputChange}
+ onKeyDown={handleKeyDown}
+ onFocus={handleInputFocus}
+ onBlur={handleInputBlur}
+ className={cn(
+ 'w-full',
+ // className,
+ styleClasses?.input,
+ )}
+ /> */}
+ = maxTags
+ ? placeholderWhenFull
+ : placeholder
+ }
+ value={inputValue}
+ onChange={handleInputChange}
+ onKeyDown={handleKeyDown}
+ onFocus={handleInputFocus}
+ onBlur={handleInputBlur}
+ {...inputProps}
+ className={cn(
+ "border-0 h-5 bg-transparent focus-visible:ring-0 focus-visible:ring-transparent focus-visible:ring-offset-0 flex-1 w-fit",
+ // className,
+ styleClasses?.input
+ )}
+ autoComplete={
+ enableAutocomplete ? "on" : "off"
+ }
+ list={
+ enableAutocomplete
+ ? "autocomplete-options"
+ : undefined
+ }
+ disabled={
+ disabled ||
+ (maxTags !== undefined &&
+ tags.length >= maxTags)
+ }
+ />
+
+ )}
+
+
+ ) : (
+
+ {!usePopoverForTags ? (
+ !inlineTags ? (
+ = maxTags
+ ? placeholderWhenFull
+ : placeholder
+ }
+ value={inputValue}
+ onChange={handleInputChange}
+ onKeyDown={handleKeyDown}
+ onFocus={handleInputFocus}
+ onBlur={handleInputBlur}
+ {...inputProps}
+ className={cn(
+ styleClasses?.input
+ // className
+ )}
+ autoComplete={
+ enableAutocomplete ? "on" : "off"
+ }
+ list={
+ enableAutocomplete
+ ? "autocomplete-options"
+ : undefined
+ }
+ disabled={
+ disabled ||
+ (maxTags !== undefined &&
+ tags.length >= maxTags)
+ }
+ />
+ ) : null
) : (
- {/* = maxTags ? placeholderWhenFull : placeholder}
- ref={inputRef}
- value={inputValue}
- disabled={disabled || (maxTags !== undefined && tags.length >= maxTags)}
- onChangeCapture={handleInputChange}
- onKeyDown={handleKeyDown}
- onFocus={handleInputFocus}
- onBlur={handleInputBlur}
- className={cn(
- 'w-full',
- // className,
- styleClasses?.input,
- )}
- /> */}
= maxTags)
}
+ className={cn(
+ "border-0 w-full",
+ styleClasses?.input
+ // className
+ )}
/>
)}
-
-
- ) : (
-
- {!usePopoverForTags ? (
- !inlineTags ? (
- = maxTags
- ? placeholderWhenFull
- : placeholder
- }
- value={inputValue}
- onChange={handleInputChange}
- onKeyDown={handleKeyDown}
- onFocus={handleInputFocus}
- onBlur={handleInputBlur}
- {...inputProps}
- className={cn(
- styleClasses?.input
- // className
- )}
- autoComplete={
- enableAutocomplete ? "on" : "off"
- }
- list={
- enableAutocomplete
- ? "autocomplete-options"
- : undefined
- }
- disabled={
- disabled ||
- (maxTags !== undefined &&
- tags.length >= maxTags)
- }
- />
- ) : null
- ) : (
-
- = maxTags
- ? placeholderWhenFull
- : placeholder
- }
- value={inputValue}
- onChange={handleInputChange}
- onKeyDown={handleKeyDown}
- onFocus={handleInputFocus}
- onBlur={handleInputBlur}
- {...inputProps}
- autoComplete={
- enableAutocomplete ? "on" : "off"
- }
- list={
- enableAutocomplete
- ? "autocomplete-options"
- : undefined
- }
- disabled={
- disabled ||
- (maxTags !== undefined &&
- tags.length >= maxTags)
- }
- className={cn(
- "border-0 w-full",
- styleClasses?.input
- // className
- )}
- />
-
- )}
-
- )}
- {showCount && maxTags && (
-
-
- {`${tagCount}`}/{`${maxTags}`}
-
-
- )}
- {clearAll && (
-
- )}
-
)
- );
-};
+
+ )}
+
+ {showCount && maxTags && (
+
+
+ {`${tagCount}`}/{`${maxTags}`}
+
+
+ )}
+ {clearAll && (
+
+ )}
+
+ );
+ }
+);
TagInput.displayName = "TagInput";
diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsx
index df3f143b..8f3e489a 100644
--- a/src/components/ui/alert.tsx
+++ b/src/components/ui/alert.tsx
@@ -22,52 +22,44 @@ const alertVariants = cva(
},
);
-const Alert = (
- {
- ref,
- className,
- variant,
- ...props
- }
-) => ();
+const Alert = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes & VariantProps
+>(({ className, variant, ...props }, ref) => (
+
+));
Alert.displayName = "Alert";
-const AlertTitle = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const AlertTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
AlertTitle.displayName = "AlertTitle";
-const AlertDescription = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const AlertDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
AlertDescription.displayName = "AlertDescription";
export { Alert, AlertTitle, AlertDescription };
diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx
index b02832a5..ef6e4355 100644
--- a/src/components/ui/avatar.tsx
+++ b/src/components/ui/avatar.tsx
@@ -5,55 +5,46 @@ import * as AvatarPrimitive from "@radix-ui/react-avatar"
import { cn } from "@app/lib/cn"
-const Avatar = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const Avatar = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
Avatar.displayName = AvatarPrimitive.Root.displayName
-const AvatarImage = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const AvatarImage = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
AvatarImage.displayName = AvatarPrimitive.Image.displayName
-const AvatarFallback = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const AvatarFallback = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
export { Avatar, AvatarImage, AvatarFallback }
diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx
index f4ead817..0c44fda2 100644
--- a/src/components/ui/badge.tsx
+++ b/src/components/ui/badge.tsx
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@app/lib/cn";
const badgeVariants = cva(
- "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",
+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
diff --git a/src/components/ui/breadcrumb.tsx b/src/components/ui/breadcrumb.tsx
index 464475f8..dd40aa55 100644
--- a/src/components/ui/breadcrumb.tsx
+++ b/src/components/ui/breadcrumb.tsx
@@ -4,55 +4,47 @@ import { ChevronRight, MoreHorizontal } from "lucide-react"
import { cn } from "@app/lib/cn"
-const Breadcrumb = (
- {
- ref,
- ...props
+const Breadcrumb = React.forwardRef<
+ HTMLElement,
+ React.ComponentPropsWithoutRef<"nav"> & {
+ separator?: React.ReactNode
}
-) =>
+>(({ ...props }, ref) => )
Breadcrumb.displayName = "Breadcrumb"
-const BreadcrumbList = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef<"ol"> & {
- ref: React.RefObject;
- }
-) => (
)
+const BreadcrumbList = React.forwardRef<
+ HTMLOListElement,
+ React.ComponentPropsWithoutRef<"ol">
+>(({ className, ...props }, ref) => (
+
+))
BreadcrumbList.displayName = "BreadcrumbList"
-const BreadcrumbItem = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef<"li"> & {
- ref: React.RefObject;
- }
-) => ()
+const BreadcrumbItem = React.forwardRef<
+ HTMLLIElement,
+ React.ComponentPropsWithoutRef<"li">
+>(({ className, ...props }, ref) => (
+
+))
BreadcrumbItem.displayName = "BreadcrumbItem"
-const BreadcrumbLink = (
- {
- ref,
- asChild,
- className,
- ...props
+const BreadcrumbLink = React.forwardRef<
+ HTMLAnchorElement,
+ React.ComponentPropsWithoutRef<"a"> & {
+ asChild?: boolean
}
-) => {
+>(({ asChild, className, ...props }, ref) => {
const Comp = asChild ? Slot : "a"
return (
@@ -62,25 +54,22 @@ const BreadcrumbLink = (
{...props}
/>
)
-}
+})
BreadcrumbLink.displayName = "BreadcrumbLink"
-const BreadcrumbPage = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef<"span"> & {
- ref: React.RefObject;
- }
-) => ()
+const BreadcrumbPage = React.forwardRef<
+ HTMLSpanElement,
+ React.ComponentPropsWithoutRef<"span">
+>(({ className, ...props }, ref) => (
+
+))
BreadcrumbPage.displayName = "BreadcrumbPage"
const BreadcrumbSeparator = ({
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
index e9936360..a915c10c 100644
--- a/src/components/ui/button.tsx
+++ b/src/components/ui/button.tsx
@@ -6,7 +6,7 @@ import { cn } from "@app/lib/cn";
import { Loader2 } from "lucide-react";
const buttonVariants = cva(
- "inline-flex items-center justify-center rounded-full whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
+ "inline-flex items-center justify-center rounded-full whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
@@ -51,32 +51,32 @@ export interface ButtonProps
loading?: boolean; // Add loading prop
}
-const Button = (
- {
- ref,
- className,
- variant,
- size,
- asChild = false,
- loading = false,
- ...props
- }: ButtonProps & {
- ref: React.RefObject;
+const Button = React.forwardRef(
+ (
+ {
+ className,
+ variant,
+ size,
+ asChild = false,
+ loading = false,
+ ...props
+ },
+ ref
+ ) => {
+ const Comp = asChild ? Slot : "button";
+ return (
+
+ {loading && }
+ {props.children}
+
+ );
}
-) => {
- const Comp = asChild ? Slot : "button";
- return (
-
- {loading && }
- {props.children}
-
- );
-};
+);
Button.displayName = "Button";
export { Button, buttonVariants };
diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx
index 0ac7d134..e5f16047 100644
--- a/src/components/ui/card.tsx
+++ b/src/components/ui/card.tsx
@@ -2,96 +2,78 @@ import * as React from "react";
import { cn } from "@app/lib/cn";
-const Card = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
Card.displayName = "Card";
-const CardHeader = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
CardHeader.displayName = "CardHeader";
-const CardTitle = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const CardTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
CardTitle.displayName = "CardTitle";
-const CardDescription = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const CardDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
CardDescription.displayName = "CardDescription";
-const CardContent = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
CardContent.displayName = "CardContent";
-const CardFooter = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ();
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+));
CardFooter.displayName = "CardFooter";
export {
diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx
index d4aadcd3..ad22b8fa 100644
--- a/src/components/ui/checkbox.tsx
+++ b/src/components/ui/checkbox.tsx
@@ -9,7 +9,7 @@ import { cva, type VariantProps } from "class-variance-authority";
// Define checkbox variants
const checkboxVariants = cva(
- "peer h-4 w-4 shrink-0 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
+ "peer h-4 w-4 shrink-0 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
{
variants: {
variant: {
@@ -33,24 +33,20 @@ interface CheckboxProps
extends React.ComponentPropsWithoutRef,
VariantProps {}
-const Checkbox = (
- {
- ref,
- className,
- variant,
- ...props
- }: CheckboxProps & {
- ref: React.RefObject>;
- }
-) => (
-
-
-
-);
+const Checkbox = React.forwardRef<
+ React.ElementRef,
+ CheckboxProps
+>(({ className, variant, ...props }, ref) => (
+
+
+
+
+
+));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
interface CheckboxWithLabelProps
@@ -58,17 +54,10 @@ interface CheckboxWithLabelProps
label: string;
}
-const CheckboxWithLabel = (
- {
- ref,
- className,
- label,
- id,
- ...props
- }: CheckboxWithLabelProps & {
- ref: React.RefObject>;
- }
-) => {
+const CheckboxWithLabel = React.forwardRef<
+ React.ElementRef,
+ CheckboxWithLabelProps
+>(({ className, label, id, ...props }, ref) => {
return (
@@ -80,7 +69,7 @@ const CheckboxWithLabel = (
);
-};
+});
CheckboxWithLabel.displayName = "CheckboxWithLabel";
export { Checkbox, CheckboxWithLabel };
diff --git a/src/components/ui/command.tsx b/src/components/ui/command.tsx
index 99c90409..5394dd2c 100644
--- a/src/components/ui/command.tsx
+++ b/src/components/ui/command.tsx
@@ -8,22 +8,19 @@ import { Search } from "lucide-react"
import { cn } from "@app/lib/cn"
import { Dialog, DialogContent } from "@/components/ui/dialog"
-const Command = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const Command = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
Command.displayName = CommandPrimitive.displayName
interface CommandDialogProps extends DialogProps {}
@@ -40,109 +37,92 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
)
}
-const CommandInput = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-
,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+
+
+
+))
+
+CommandInput.displayName = CommandPrimitive.Input.displayName
+
+const CommandList = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+
+CommandList.displayName = CommandPrimitive.List.displayName
+
+const CommandEmpty = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>((props, ref) => (
+
+))
+
+CommandEmpty.displayName = CommandPrimitive.Empty.displayName
+
+const CommandGroup = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
- )
-
-CommandInput.displayName = CommandPrimitive.Input.displayName
-
-const CommandList = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
-
-CommandList.displayName = CommandPrimitive.List.displayName
-
-const CommandEmpty = (
- {
- ref,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
-
-CommandEmpty.displayName = CommandPrimitive.Empty.displayName
-
-const CommandGroup = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+))
CommandGroup.displayName = CommandPrimitive.Group.displayName
-const CommandSeparator = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const CommandSeparator = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
CommandSeparator.displayName = CommandPrimitive.Separator.displayName
-const CommandItem = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const CommandItem = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
CommandItem.displayName = CommandPrimitive.Item.displayName
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx
index 2bfbd320..48e36db4 100644
--- a/src/components/ui/dialog.tsx
+++ b/src/components/ui/dialog.tsx
@@ -14,50 +14,43 @@ const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
-const DialogOverlay = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ();
-DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
-
-const DialogContent = (
- {
- ref,
- className,
- children,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
- ,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
- {children}
-
-
- Close
-
-
-);
+ />
+));
+DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
+
+const DialogContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+
+
+ {children}
+
+
+ Close
+
+
+
+));
DialogContent.displayName = DialogPrimitive.Content.displayName;
const DialogHeader = ({
@@ -88,37 +81,31 @@ const DialogFooter = ({
);
DialogFooter.displayName = "DialogFooter";
-const DialogTitle = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ();
+const DialogTitle = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
DialogTitle.displayName = DialogPrimitive.Title.displayName;
-const DialogDescription = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ();
+const DialogDescription = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
DialogDescription.displayName = DialogPrimitive.Description.displayName;
export {
diff --git a/src/components/ui/drawer.tsx b/src/components/ui/drawer.tsx
index f05d0fb7..d0500060 100644
--- a/src/components/ui/drawer.tsx
+++ b/src/components/ui/drawer.tsx
@@ -22,44 +22,37 @@ const DrawerPortal = DrawerPrimitive.Portal;
const DrawerClose = DrawerPrimitive.Close;
-const DrawerOverlay = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ();
+const DrawerOverlay = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
-const DrawerContent = (
- {
- ref,
- className,
- children,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-
-
- {children}
-
-);
+const DrawerContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+
+
+
+ {children}
+
+
+));
DrawerContent.displayName = "DrawerContent";
const DrawerHeader = ({
@@ -84,37 +77,31 @@ const DrawerFooter = ({
);
DrawerFooter.displayName = "DrawerFooter";
-const DrawerTitle = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ();
+const DrawerTitle = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
-const DrawerDescription = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ();
+const DrawerDescription = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
export {
diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx
index b86efd86..8d2f4c3c 100644
--- a/src/components/ui/dropdown-menu.tsx
+++ b/src/components/ui/dropdown-menu.tsx
@@ -18,174 +18,154 @@ const DropdownMenuSub = DropdownMenuPrimitive.Sub
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
-const DropdownMenuSubTrigger = (
- {
- ref,
- className,
- inset,
- children,
- ...props
+const DropdownMenuSubTrigger = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef & {
+ inset?: boolean
}
-) => (
- {children}
-
-)
+>(({ className, inset, children, ...props }, ref) => (
+
+ {children}
+
+
+))
DropdownMenuSubTrigger.displayName =
DropdownMenuPrimitive.SubTrigger.displayName
-const DropdownMenuSubContent = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
-DropdownMenuSubContent.displayName =
- DropdownMenuPrimitive.SubContent.displayName
-
-const DropdownMenuContent = (
- {
- ref,
- className,
- sideOffset = 4,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
- ,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
-)
+))
+DropdownMenuSubContent.displayName =
+ DropdownMenuPrimitive.SubContent.displayName
+
+const DropdownMenuContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, sideOffset = 4, ...props }, ref) => (
+
+
+
+))
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
-const DropdownMenuItem = (
- {
- ref,
- className,
- inset,
- ...props
+const DropdownMenuItem = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef & {
+ inset?: boolean
}
-) => ()
+>(({ className, inset, ...props }, ref) => (
+
+))
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
-const DropdownMenuCheckboxItem = (
- {
- ref,
- className,
- children,
- checked,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-
-
-
-
- {children}
-)
+const DropdownMenuCheckboxItem = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, checked, ...props }, ref) => (
+
+
+
+
+
+
+ {children}
+
+))
DropdownMenuCheckboxItem.displayName =
DropdownMenuPrimitive.CheckboxItem.displayName
-const DropdownMenuRadioItem = (
- {
- ref,
- className,
- children,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-
-
-
-
- {children}
-)
+const DropdownMenuRadioItem = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+
+
+
+
+
+ {children}
+
+))
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
-const DropdownMenuLabel = (
- {
- ref,
- className,
- inset,
- ...props
+const DropdownMenuLabel = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef & {
+ inset?: boolean
}
-) => ()
+>(({ className, inset, ...props }, ref) => (
+
+))
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
-const DropdownMenuSeparator = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const DropdownMenuSeparator = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
const DropdownMenuShortcut = ({
diff --git a/src/components/ui/form.tsx b/src/components/ui/form.tsx
index ba754e49..61796efd 100644
--- a/src/components/ui/form.tsx
+++ b/src/components/ui/form.tsx
@@ -72,15 +72,10 @@ const FormItemContext = React.createContext(
{} as FormItemContextValue
)
-const FormItem = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => {
+const FormItem = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => {
const id = React.useId()
return (
@@ -88,18 +83,13 @@ const FormItem = (
)
-}
+})
FormItem.displayName = "FormItem"
-const FormLabel = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => {
+const FormLabel = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => {
const { error, formItemId } = useFormField()
return (
@@ -110,17 +100,13 @@ const FormLabel = (
{...props}
/>
)
-}
+})
FormLabel.displayName = "FormLabel"
-const FormControl = (
- {
- ref,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => {
+const FormControl = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ ...props }, ref) => {
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
return (
@@ -136,18 +122,13 @@ const FormControl = (
{...props}
/>
)
-}
+})
FormControl.displayName = "FormControl"
-const FormDescription = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => {
+const FormDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => {
const { formDescriptionId } = useFormField()
return (
@@ -158,19 +139,13 @@ const FormDescription = (
{...props}
/>
)
-}
+})
FormDescription.displayName = "FormDescription"
-const FormMessage = (
- {
- ref,
- className,
- children,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => {
+const FormMessage = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, children, ...props }, ref) => {
const { error, formMessageId } = useFormField()
const body = error ? String(error?.message) : children
@@ -188,7 +163,7 @@ const FormMessage = (
{body}
)
-}
+})
FormMessage.displayName = "FormMessage"
export {
diff --git a/src/components/ui/input-otp.tsx b/src/components/ui/input-otp.tsx
index 6fe57b94..bd0e74c6 100644
--- a/src/components/ui/input-otp.tsx
+++ b/src/components/ui/input-otp.tsx
@@ -6,45 +6,34 @@ import { Dot } from "lucide-react"
import { cn } from "@app/lib/cn"
-const InputOTP = (
- {
- ref,
- className,
- containerClassName,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const InputOTP = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, containerClassName, ...props }, ref) => (
+
+))
InputOTP.displayName = "InputOTP"
-const InputOTPGroup = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef<"div"> & {
- ref: React.RefObject>;
- }
-) => ()
+const InputOTPGroup = React.forwardRef<
+ React.ElementRef<"div">,
+ React.ComponentPropsWithoutRef<"div">
+>(({ className, ...props }, ref) => (
+
+))
InputOTPGroup.displayName = "InputOTPGroup"
-const InputOTPSlot = (
- {
- ref,
- index,
- className,
- ...props
- }
-) => {
+const InputOTPSlot = React.forwardRef<
+ React.ElementRef<"div">,
+ React.ComponentPropsWithoutRef<"div"> & { index: number }
+>(({ index, className, ...props }, ref) => {
const inputOTPContext = React.useContext(OTPInputContext)
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
@@ -66,19 +55,17 @@ const InputOTPSlot = (
)}
)
-}
+})
InputOTPSlot.displayName = "InputOTPSlot"
-const InputOTPSeparator = (
- {
- ref,
- ...props
- }: React.ComponentPropsWithoutRef<"div"> & {
- ref: React.RefObject>;
- }
-) => (
-
-
)
+const InputOTPSeparator = React.forwardRef<
+ React.ElementRef<"div">,
+ React.ComponentPropsWithoutRef<"div">
+>(({ ...props }, ref) => (
+
+
+
+))
InputOTPSeparator.displayName = "InputOTPSeparator"
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx
index b02aa822..9a085cb2 100644
--- a/src/components/ui/input.tsx
+++ b/src/components/ui/input.tsx
@@ -5,56 +5,49 @@ import { EyeOff, Eye } from "lucide-react";
export type InputProps = React.InputHTMLAttributes;
-const Input = (
- {
- ref,
- className,
- type,
- ...props
- }: InputProps & {
- ref: React.RefObject;
- }
-) => {
- const [showPassword, setShowPassword] = React.useState(false);
- const togglePasswordVisibility = () => setShowPassword(!showPassword);
+const Input = React.forwardRef(
+ ({ className, type, ...props }, ref) => {
+ const [showPassword, setShowPassword] = React.useState(false);
+ const togglePasswordVisibility = () => setShowPassword(!showPassword);
- return type === "password" ? (
-
+ return type === "password" ? (
+
+
+
+ {showPassword ? (
+
+ ) : (
+
+ )}
+
+
+ ) : (
-
- {showPassword ? (
-
- ) : (
-
- )}
-
-
- ) : (
-
- );
-};
+ );
+ }
+);
Input.displayName = "Input";
export { Input };
diff --git a/src/components/ui/label.tsx b/src/components/ui/label.tsx
index a306d06c..0c85b64d 100644
--- a/src/components/ui/label.tsx
+++ b/src/components/ui/label.tsx
@@ -10,17 +10,17 @@ const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)
-const Label = (
- {
- ref,
- className,
- ...props
- }
-) => ()
+const Label = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef &
+ VariantProps
+>(({ className, ...props }, ref) => (
+
+))
Label.displayName = LabelPrimitive.Root.displayName
export { Label }
diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx
index d882e5ea..d283903d 100644
--- a/src/components/ui/popover.tsx
+++ b/src/components/ui/popover.tsx
@@ -7,42 +7,34 @@ import { cn } from "@app/lib/cn"
const Popover = PopoverPrimitive.Root
-const PopoverTrigger = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const PopoverTrigger = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
-const PopoverContent = (
- {
- ref,
- className,
- align = "center",
- sideOffset = 4,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-)
+const PopoverContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
+
+
+
+))
PopoverContent.displayName = PopoverPrimitive.Content.displayName
export { Popover, PopoverTrigger, PopoverContent }
diff --git a/src/components/ui/radio-group.tsx b/src/components/ui/radio-group.tsx
index d2930266..f0bf50ac 100644
--- a/src/components/ui/radio-group.tsx
+++ b/src/components/ui/radio-group.tsx
@@ -6,15 +6,10 @@ import { Circle } from "lucide-react"
import { cn } from "@app/lib/cn"
-const RadioGroup = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => {
+const RadioGroup = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => {
return (
)
-}
+})
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
-const RadioGroupItem = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => {
+const RadioGroupItem = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => {
return (
)
-}
+})
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
export { RadioGroup, RadioGroupItem }
diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx
index a8f8a8aa..cd9f6678 100644
--- a/src/components/ui/select.tsx
+++ b/src/components/ui/select.tsx
@@ -12,163 +12,139 @@ const SelectGroup = SelectPrimitive.Group
const SelectValue = SelectPrimitive.Value
-const SelectTrigger = (
- {
- ref,
- className,
- children,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (span]:line-clamp-1",
- "rounded-md",
- className
- )}
- {...props}
->
- {children}
-
-
-
-)
+const SelectTrigger = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+ span]:line-clamp-1",
+ "rounded-md",
+ className
+ )}
+ {...props}
+ >
+ {children}
+
+
+
+
+))
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
-const SelectScrollUpButton = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-)
+const SelectScrollUpButton = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+
+
+))
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
-const SelectScrollDownButton = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-)
+const SelectScrollDownButton = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+
+
+))
SelectScrollDownButton.displayName =
SelectPrimitive.ScrollDownButton.displayName
-const SelectContent = (
- {
- ref,
- className,
- children,
- position = "popper",
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-
- ,
+ React.ComponentPropsWithoutRef
+>(({ className, children, position = "popper", ...props }, ref) => (
+
+
- {children}
-
-
-
-)
+
+
+ {children}
+
+
+
+
+))
SelectContent.displayName = SelectPrimitive.Content.displayName
-const SelectLabel = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const SelectLabel = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
SelectLabel.displayName = SelectPrimitive.Label.displayName
-const SelectItem = (
- {
- ref,
- className,
- children,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-
-
-
-
- {children}
-)
+const SelectItem = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+
+
+
+
+
+
+ {children}
+
+))
SelectItem.displayName = SelectPrimitive.Item.displayName
-const SelectSeparator = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const SelectSeparator = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
export {
diff --git a/src/components/ui/separator.tsx b/src/components/ui/separator.tsx
index bd8183ee..c59cac0d 100644
--- a/src/components/ui/separator.tsx
+++ b/src/components/ui/separator.tsx
@@ -5,27 +5,27 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator"
import { cn } from "@app/lib/cn"
-const Separator = (
- {
- ref,
- className,
- orientation = "horizontal",
- decorative = true,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const Separator = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(
+ (
+ { className, orientation = "horizontal", decorative = true, ...props },
+ ref
+ ) => (
+
+ )
+)
Separator.displayName = SeparatorPrimitive.Root.displayName
export { Separator }
diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx
index b87baec6..44cdf853 100644
--- a/src/components/ui/sheet.tsx
+++ b/src/components/ui/sheet.tsx
@@ -15,22 +15,19 @@ const SheetClose = SheetPrimitive.Close
const SheetPortal = SheetPrimitive.Portal
-const SheetOverlay = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const SheetOverlay = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
const sheetVariants = cva(
@@ -56,30 +53,25 @@ interface SheetContentProps
extends React.ComponentPropsWithoutRef,
VariantProps {}
-const SheetContent = (
- {
- ref,
- side = "right",
- className,
- children,
- ...props
- }: SheetContentProps & {
- ref: React.RefObject>;
- }
-) => (
-
-
- {children}
- {/* */}
- {/* */}
- {/* Close */}
- {/* */}
-
-)
+const SheetContent = React.forwardRef<
+ React.ElementRef,
+ SheetContentProps
+>(({ side = "right", className, children, ...props }, ref) => (
+
+
+
+ {children}
+ {/* */}
+ {/* */}
+ {/* Close */}
+ {/* */}
+
+
+))
SheetContent.displayName = SheetPrimitive.Content.displayName
const SheetHeader = ({
@@ -110,34 +102,28 @@ const SheetFooter = ({
)
SheetFooter.displayName = "SheetFooter"
-const SheetTitle = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const SheetTitle = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
SheetTitle.displayName = SheetPrimitive.Title.displayName
-const SheetDescription = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const SheetDescription = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
SheetDescription.displayName = SheetPrimitive.Description.displayName
export {
diff --git a/src/components/ui/switch.tsx b/src/components/ui/switch.tsx
index fda8d28d..3158b6a1 100644
--- a/src/components/ui/switch.tsx
+++ b/src/components/ui/switch.tsx
@@ -5,28 +5,25 @@ import * as SwitchPrimitives from "@radix-ui/react-switch"
import { cn } from "@app/lib/cn"
-const Switch = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
- ,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
-)
+ {...props}
+ ref={ref}
+ >
+
+
+))
Switch.displayName = SwitchPrimitives.Root.displayName
export { Switch }
diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx
index 156caa8e..7bfec308 100644
--- a/src/components/ui/table.tsx
+++ b/src/components/ui/table.tsx
@@ -6,21 +6,18 @@ export function TableContainer({ children }: { children: React.ReactNode }) {
return {children}
}
-const Table = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ()
+const Table = React.forwardRef<
+ HTMLTableElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
Table.displayName = "Table"
const TableHeader = React.forwardRef<
@@ -43,22 +40,19 @@ const TableBody = React.forwardRef<
))
TableBody.displayName = "TableBody"
-const TableFooter = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => (tr]:border-b-0",
- className
- )}
- {...props}
-/>)
+const TableFooter = React.forwardRef<
+ HTMLTableSectionElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+ tr]:last:border-b-0",
+ className
+ )}
+ {...props}
+ />
+))
TableFooter.displayName = "TableFooter"
const TableRow = React.forwardRef<
@@ -83,7 +77,7 @@ const TableHead = React.forwardRef<
[role=checkbox]]:translate-y-[2px]",
+ "h-10 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
className
)}
{...props}
@@ -97,28 +91,22 @@ const TableCell = React.forwardRef<
>(({ className, ...props }, ref) => (
| [role=checkbox]]:translate-y-[2px]",
- className
- )}
+ className={cn("p-3 align-middle [&:has([role=checkbox])]:pr-0", className)}
{...props}
/>
))
TableCell.displayName = "TableCell"
-const TableCaption = (
- {
- ref,
- className,
- ...props
- }: React.HTMLAttributes & {
- ref: React.RefObject;
- }
-) => ()
+const TableCaption = React.forwardRef<
+ HTMLTableCaptionElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
TableCaption.displayName = "TableCaption"
export {
diff --git a/src/components/ui/tabs.tsx b/src/components/ui/tabs.tsx
index 891e10f6..aa76c090 100644
--- a/src/components/ui/tabs.tsx
+++ b/src/components/ui/tabs.tsx
@@ -7,58 +7,49 @@ import { cn } from "@app/lib/cn"
const Tabs = TabsPrimitive.Root
-const TabsList = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const TabsList = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
TabsList.displayName = TabsPrimitive.List.displayName
-const TabsTrigger = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const TabsTrigger = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
-const TabsContent = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const TabsContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
TabsContent.displayName = TabsPrimitive.Content.displayName
export { Tabs, TabsList, TabsTrigger, TabsContent }
diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsx
index de57ad87..625d181d 100644
--- a/src/components/ui/textarea.tsx
+++ b/src/components/ui/textarea.tsx
@@ -5,26 +5,20 @@ import { cn } from "@app/lib/cn"
export interface TextareaProps
extends React.TextareaHTMLAttributes {}
-const Textarea = (
- {
- ref,
- className,
- ...props
- }: TextareaProps & {
- ref: React.RefObject;
+const Textarea = React.forwardRef(
+ ({ className, ...props }, ref) => {
+ return (
+
+ )
}
-) => {
- return (
-
- )
-}
+)
Textarea.displayName = "Textarea"
export { Textarea }
diff --git a/src/components/ui/toast.tsx b/src/components/ui/toast.tsx
index d9f9afc9..f045c7ff 100644
--- a/src/components/ui/toast.tsx
+++ b/src/components/ui/toast.tsx
@@ -9,22 +9,19 @@ import { cn } from "@app/lib/cn"
const ToastProvider = ToastPrimitives.Provider
-const ToastViewport = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const ToastViewport = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
ToastViewport.displayName = ToastPrimitives.Viewport.displayName
const toastVariants = cva(
@@ -43,14 +40,11 @@ const toastVariants = cva(
}
)
-const Toast = (
- {
- ref,
- className,
- variant,
- ...props
- }
-) => {
+const Toast = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef &
+ VariantProps
+>(({ className, variant, ...props }, ref) => {
return (
)
-}
+})
Toast.displayName = ToastPrimitives.Root.displayName
-const ToastAction = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const ToastAction = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
ToastAction.displayName = ToastPrimitives.Action.displayName
-const ToastClose = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => (
-
-)
+const ToastClose = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+
+
+))
ToastClose.displayName = ToastPrimitives.Close.displayName
-const ToastTitle = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const ToastTitle = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
ToastTitle.displayName = ToastPrimitives.Title.displayName
-const ToastDescription = (
- {
- ref,
- className,
- ...props
- }: React.ComponentPropsWithoutRef & {
- ref: React.RefObject>;
- }
-) => ()
+const ToastDescription = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
ToastDescription.displayName = ToastPrimitives.Description.displayName
type ToastProps = React.ComponentPropsWithoutRef
|