diff --git a/apps/ui/components/navbar.tsx b/apps/ui/components/navbar.tsx index bba71e5..6e6f40e 100644 --- a/apps/ui/components/navbar.tsx +++ b/apps/ui/components/navbar.tsx @@ -126,7 +126,7 @@ export function Navbar() { intent="outline" className="h-9 items-center" > -
+
Search... diff --git a/apps/ui/components/ui/button.tsx b/apps/ui/components/ui/button.tsx index c52b24b..cf259a7 100644 --- a/apps/ui/components/ui/button.tsx +++ b/apps/ui/components/ui/button.tsx @@ -9,7 +9,7 @@ import { import { tv } from "tailwind-variants" import { focusButtonStyles } from "./primitive" -import { Typography } from "./typography"; +import { Typography } from "./typography" const buttonStyles = tv({ extend: focusButtonStyles, diff --git a/apps/ui/components/ui/calendar.tsx b/apps/ui/components/ui/calendar.tsx index c047a61..a06bfed 100644 --- a/apps/ui/components/ui/calendar.tsx +++ b/apps/ui/components/ui/calendar.tsx @@ -170,8 +170,7 @@ const SelectYear = ({ state }: { state: CalendarState }) => { aria-label="Select year" selectedKey={20} onSelectionChange={(value) => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - state.setFocusedDate(years[Number(value)]?.value) + state.setFocusedDate(years[Number(value)]?.value!) }} > @@ -199,4 +198,4 @@ const CalendarGridHeader = () => { } export type { CalendarProps } -export { Calendar, CalendarHeader, CalendarGridHeader } \ No newline at end of file +export { Calendar, CalendarGridHeader, CalendarHeader } diff --git a/apps/ui/components/ui/date-picker.tsx b/apps/ui/components/ui/date-picker.tsx index 453992d..37e35d9 100644 --- a/apps/ui/components/ui/date-picker.tsx +++ b/apps/ui/components/ui/date-picker.tsx @@ -97,33 +97,33 @@ const DatePicker = ({ {...props} className={composeTailwindRenderProps(className, "group flex w-full flex-col gap-y-1")} > - {label && + {label && ( - } - + )} + - {description && + {description && ( {description} - } - + )} + {(leftDescription || errorMessage || rightDescription) && ( -
+
{errorMessage ? {errorMessage} : leftDescription}
{rightDescription}
)} - + ) } export type { DatePickerProps, DateValue, ValidationResult } -export { DatePicker, DatePickerIcon, DatePickerOverlay } \ No newline at end of file +export { DatePicker, DatePickerIcon, DatePickerOverlay } diff --git a/apps/ui/components/ui/dropdown.tsx b/apps/ui/components/ui/dropdown.tsx index f551d28..a5844d4 100644 --- a/apps/ui/components/ui/dropdown.tsx +++ b/apps/ui/components/ui/dropdown.tsx @@ -85,8 +85,8 @@ const DropdownItem = ({ className, ...props }: DropdownItemProps) => { > {composeRenderProps(props.children, (children, { isSelected }) => ( <> - {isSelected && } {typeof children === "string" ? {children} : children} + {isSelected && } ))} @@ -169,14 +169,14 @@ const DropdownKeyboard = ({ className, ...props }: React.ComponentProps { return ( - fieldGroupStyles({ - ...renderProps, - className, - }), - )} + {...props} + className={composeRenderProps(className, (className, renderProps) => + fieldGroupStyles({ + ...renderProps, + className, + }), + )} /> ) diff --git a/apps/ui/components/ui/keyboard.tsx b/apps/ui/components/ui/keyboard.tsx index ae82764..078e4fc 100644 --- a/apps/ui/components/ui/keyboard.tsx +++ b/apps/ui/components/ui/keyboard.tsx @@ -5,7 +5,7 @@ import { tv } from "tailwind-variants" const keyboardStyles = tv({ slots: { - base: "hidden text-current/70 group-hover:text-fg group-disabled:opacity-50 group-data-focused:text-fg group-data-focused:opacity-90 lg:inline-flex items-center forced-colors:group-data-focused:text-[HighlightText]", + base: "hidden items-center text-current/70 group-hover:text-fg group-disabled:opacity-50 group-data-focused:text-fg group-data-focused:opacity-90 lg:inline-flex forced-colors:group-data-focused:text-[HighlightText]", kbd: "inline-grid min-h-5 min-w-[2ch] place-content-center rounded text-center font-sans text-[.75rem] uppercase", }, }) diff --git a/apps/ui/components/ui/list-box.tsx b/apps/ui/components/ui/list-box.tsx index 56f1a03..92338df 100644 --- a/apps/ui/components/ui/list-box.tsx +++ b/apps/ui/components/ui/list-box.tsx @@ -20,7 +20,7 @@ const ListBox = ({ className, ...props }: ListBoxProps) => {...props} className={composeTailwindRenderProps( className, - "flex grid max-h-96 w-full min-w-56 grid-cols-[auto_1fr] flex-col gap-y-1 overflow-auto overflow-y-auto rounded-xl border p-1 shadow-lg outline-hidden [scrollbar-width:thin] [&::-webkit-scrollbar]:size-0.5 *:[[role='group']+[role=group]]:mt-4 *:[[role='group']+[role=separator]]:mt-1", + "grid max-h-96 w-full min-w-56 grid-cols-[auto_1fr] flex-col gap-y-1 overflow-auto overflow-y-auto rounded-xl border p-1 shadow-lg outline-hidden [scrollbar-width:thin] [&::-webkit-scrollbar]:size-0.5 *:[[role='group']+[role=group]]:mt-4 *:[[role='group']+[role=separator]]:mt-1", )} /> ) diff --git a/apps/ui/components/ui/select.tsx b/apps/ui/components/ui/select.tsx index 115c818..d7c8fc5 100644 --- a/apps/ui/components/ui/select.tsx +++ b/apps/ui/components/ui/select.tsx @@ -68,22 +68,24 @@ const Select = ({ > {(values) => ( <> - {label && + {label && ( - } + )} {typeof props.children === "function" ? props.children(values) : props.children} - {description && + {description && ( {description} - } - + )} + {(leftDescription || errorMessage || rightDescription) && ( -
-
{errorMessage ? {errorMessage} : leftDescription}
+
+
+ {errorMessage ? {errorMessage} : leftDescription} +
{rightDescription}
@@ -169,4 +171,4 @@ Select.Trigger = SelectTrigger Select.List = SelectList export type { SelectProps, SelectTriggerProps } -export { Select } \ No newline at end of file +export { Select } diff --git a/apps/ui/components/ui/text-field.tsx b/apps/ui/components/ui/text-field.tsx index 0e53f08..70c2f57 100644 --- a/apps/ui/components/ui/text-field.tsx +++ b/apps/ui/components/ui/text-field.tsx @@ -10,11 +10,11 @@ import { type TextFieldProps as TextFieldPrimitiveProps, } from "react-aria-components" -import {FieldError, FieldProps} from "./field" +import { FieldError, type FieldProps } from "./field" import { Description, FieldGroup, Input, Label } from "./field" import { Loader } from "./loader" import { composeTailwindRenderProps } from "./primitive" -import {Typography} from "./typography"; +import { Typography } from "./typography" type InputType = Exclude @@ -40,20 +40,20 @@ interface NonRevealableTextFieldProps extends BaseTextFieldProps { type TextFieldProps = RevealableTextFieldProps | NonRevealableTextFieldProps const TextField = ({ - placeholder, - label, - description, - errorMessage, - prefix, - suffix, - isPending, - className, - isRevealable, - type, - leftDescription, - rightDescription, - ...props - }: TextFieldProps) => { + placeholder, + label, + description, + errorMessage, + prefix, + suffix, + isPending, + className, + isRevealable, + type, + leftDescription, + rightDescription, + ...props +}: TextFieldProps) => { const [isPasswordVisible, setIsPasswordVisible] = useState(false) const [autoError, setAutoError] = useState(null) @@ -76,68 +76,70 @@ const TextField = ({ } return ( - - {!props.children ? ( - <> - {label && - - - - } - + {!props.children ? ( + <> + {label && ( + + + + )} + + {prefix && typeof prefix === "string" ? ( + + {prefix} + + ) : ( + {prefix} + )} + + {isRevealable ? ( + - {prefix && typeof prefix === "string" ? ( - {prefix} - ) : ( - {prefix} - )} - - {isRevealable ? ( - - {isPasswordVisible ? : } - - ) : isPending ? ( - - ) : suffix ? ( - typeof suffix === "string" ? ( - {suffix} - ) : ( - suffix - ) - ) : null} - - - {description && {description}} - - {(leftDescription || autoError || rightDescription) && ( - -
-
{autoError ? {autoError} : leftDescription}
-
{rightDescription}
-
-
- )} - - ) : ( - props.children - )} -
+ {isPasswordVisible ? : } + + ) : isPending ? ( + + ) : suffix ? ( + typeof suffix === "string" ? ( + {suffix} + ) : ( + suffix + ) + ) : null} + + + {description && ( + + {description} + + )} + + {(leftDescription || autoError || rightDescription) && ( + +
+
{autoError ? {autoError} : leftDescription}
+
{rightDescription}
+
+
+ )} + + ) : ( + props.children + )} + ) } diff --git a/apps/ui/components/ui/textarea.tsx b/apps/ui/components/ui/textarea.tsx index 00efbf2..e53b942 100644 --- a/apps/ui/components/ui/textarea.tsx +++ b/apps/ui/components/ui/textarea.tsx @@ -1,95 +1,95 @@ "use client" +import { useEffect, useState } from "react" import { - TextArea as TextAreaPrimitive, - TextField as TextFieldPrimitive, - type TextFieldProps as TextFieldPrimitiveProps, - type ValidationResult, - composeRenderProps, + TextArea as TextAreaPrimitive, + TextField as TextFieldPrimitive, + type TextFieldProps as TextFieldPrimitiveProps, + type ValidationResult, + composeRenderProps, } from "react-aria-components" import { tv } from "tailwind-variants" -import { useState, useEffect } from "react" import { Description, FieldError, Label } from "./field" import { composeTailwindRenderProps, focusStyles } from "./primitive" const textareaStyles = tv({ - extend: focusStyles, - base: "field-sizing-content max-h-96 min-h-16 w-full min-w-0 rounded-lg border border-input px-2.5 py-2 pb-6 text-base shadow-xs outline-hidden transition duration-200 disabled:opacity-50 sm:text-sm break-words whitespace-pre-wrap overflow-wrap-anywhere", + extend: focusStyles, + base: "field-sizing-content overflow-wrap-anywhere max-h-96 min-h-16 w-full min-w-0 whitespace-pre-wrap break-words rounded-lg border border-input px-2.5 py-2 pb-6 text-base shadow-xs outline-hidden transition duration-200 disabled:opacity-50 sm:text-sm", }) interface TextareaProps extends TextFieldPrimitiveProps { - autoSize?: boolean - label?: string - placeholder?: string - description?: string - errorMessage?: string | ((validation: ValidationResult) => string) - className?: string - ref?: React.Ref - showCharacterCount?: boolean - maxLength?: number - height?: string | number + autoSize?: boolean + label?: string + placeholder?: string + description?: string + errorMessage?: string | ((validation: ValidationResult) => string) + className?: string + ref?: React.Ref + showCharacterCount?: boolean + maxLength?: number + height?: string | number } const Textarea = ({ - className, - placeholder, - label, - description, - errorMessage, - ref, - showCharacterCount, - maxLength, - height, - ...props - }: TextareaProps) => { - const [currentLength, setCurrentLength] = useState(props.value?.toString().length || 0) + className, + placeholder, + label, + description, + errorMessage, + ref, + showCharacterCount, + maxLength, + height, + ...props +}: TextareaProps) => { + const [currentLength, setCurrentLength] = useState(props.value?.toString().length || 0) - useEffect(() => { - setCurrentLength(props.value?.toString().length || 0) - }, [props.value]) + useEffect(() => { + setCurrentLength(props.value?.toString().length || 0) + }, [props.value]) - const getCountText = () => { - if (maxLength) { - return `${currentLength}/${maxLength}` - } - return `${currentLength}字` + const getCountText = () => { + if (maxLength) { + return `${currentLength}/${maxLength}` } + return `${currentLength}字` + } - return ( - - {label && } -
- - textareaStyles({ - ...renderProps, - className, - }), - )} - style={{ - height: height ?? undefined, - wordWrap: "break-word", - overflowWrap: "break-word", - ...props.style, - }} - /> - {showCharacterCount && currentLength > 0 && ( -
- {getCountText()} -
- )} -
- {description && {description}} - {errorMessage} -
- ) + return ( + + {label && } +
+ + textareaStyles({ + ...renderProps, + className, + }), + )} + style={{ + height: height ?? undefined, + wordWrap: "break-word", + overflowWrap: "break-word", + ...props.style, + }} + /> + {showCharacterCount && currentLength > 0 && ( +
+ {getCountText()} +
+ )} +
+ {description && {description}} + {errorMessage} +
+ ) } export type { TextareaProps } diff --git a/apps/ui/components/ui/typography.tsx b/apps/ui/components/ui/typography.tsx index 2428d6c..52c69bd 100644 --- a/apps/ui/components/ui/typography.tsx +++ b/apps/ui/components/ui/typography.tsx @@ -27,7 +27,13 @@ type TypographyProps = { as?: "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "span" | "div" } -const Typography = ({ className, variant, as: Tag = "div", children, ...props }: TypographyProps) => { +const Typography = ({ + className, + variant, + as: Tag = "div", + children, + ...props +}: TypographyProps) => { return ( {children}