diff --git a/app/components/Input.tsx b/app/components/Input.tsx deleted file mode 100644 index bbb608a..0000000 --- a/app/components/Input.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { Asterisk } from "lucide-react"; -import { useRef } from "react"; -import { type AriaTextFieldProps, useId, useTextField } from "react-aria"; - -import cn from "~/utils/cn"; - -export interface InputProps extends AriaTextFieldProps { - label: string; - labelHidden?: boolean; - isRequired?: boolean; - className?: string; - isInvalid?: boolean; - errorMessage?: string; -} - -export default function Input(props: InputProps) { - const { label, labelHidden, className, isInvalid: customIsInvalid, errorMessage } = props; - const ref = useRef(null); - const id = useId(props.id); - - const { - labelProps, - inputProps, - descriptionProps, - errorMessageProps, - isInvalid: ariaIsInvalid, - validationErrors, - } = useTextField( - { - ...props, - label, - "aria-label": label, - }, - ref, - ); - - const isInvalid = customIsInvalid ?? ariaIsInvalid; - - return ( -
- - - {props.description && ( -
- {props.description} -
- )} - {isInvalid ? ( -
- {errorMessage ?? validationErrors.join(" ")} -
- ) : null} -
- ); -} diff --git a/app/components/Notice.tsx b/app/components/Notice.tsx deleted file mode 100644 index 9200019..0000000 --- a/app/components/Notice.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - CircleAlert, - CircleSlash2, - LucideProps, - TriangleAlert, -} from 'lucide-react'; -import React from 'react'; -import Card from '~/components/Card'; - -export interface NoticeProps { - children: React.ReactNode; - title?: string; - variant?: 'default' | 'error' | 'warning'; - icon?: React.ReactElement; -} - -export default function Notice({ - children, - title, - variant, - icon, -}: NoticeProps) { - return ( - -
- {title ? ( - {title} - ) : undefined} - {!variant && icon ? icon : iconForVariant(variant)} -
- {children} -
- ); -} - -function iconForVariant(variant?: 'default' | 'error' | 'warning') { - switch (variant) { - case 'error': - return ; - case 'warning': - return ; - default: - return ; - } -} diff --git a/app/components/NumberInput.tsx b/app/components/NumberInput.tsx deleted file mode 100644 index f520afd..0000000 --- a/app/components/NumberInput.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { Minus, Plus } from "lucide-react"; -import { useRef } from "react"; -import { type AriaNumberFieldProps, useButton, useId, useLocale, useNumberField } from "react-aria"; -import { useNumberFieldState } from "react-stately"; - -import cn from "~/utils/cn"; - -export interface InputProps extends AriaNumberFieldProps { - isRequired?: boolean; - name?: string; -} - -export default function NumberInput(props: InputProps) { - const { label, name } = props; - const { locale } = useLocale(); - const state = useNumberFieldState({ ...props, locale }); - const ref = useRef(null); - const id = useId(props.id); - - const { - labelProps, - inputProps, - groupProps, - incrementButtonProps, - decrementButtonProps, - descriptionProps, - errorMessageProps, - isInvalid, - validationErrors, - } = useNumberField(props, state, ref); - - const decrRef = useRef(null); - const incrRef = useRef(null); - const { buttonProps: decrProps } = useButton(decrementButtonProps, decrRef); - const { buttonProps: incrProps } = useButton(incrementButtonProps, incrRef); - - return ( -
- -
- - - - -
- {props.description && ( -
- {props.description} -
- )} - {isInvalid && ( -
- {validationErrors.join(" ")} -
- )} -
- ); -} diff --git a/app/components/Popover.tsx b/app/components/Popover.tsx deleted file mode 100644 index 9a808f9..0000000 --- a/app/components/Popover.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React, { useRef } from "react"; -import { type AriaPopoverProps, DismissButton, Overlay, usePopover } from "react-aria"; -import type { OverlayTriggerState } from "react-stately"; - -import cn from "~/utils/cn"; - -export interface PopoverProps extends Omit { - children: React.ReactNode; - state: OverlayTriggerState; - popoverRef?: React.RefObject; - className?: string; -} - -export default function Popover(props: PopoverProps) { - const ref = props.popoverRef ?? useRef(null); - const { state, children, className } = props; - const { popoverProps, underlayProps } = usePopover( - { - ...props, - popoverRef: ref, - offset: 8, - }, - state, - ); - - return ( - -
-
- - {children} - -
- - ); -} diff --git a/app/components/RadioGroup.tsx b/app/components/RadioGroup.tsx deleted file mode 100644 index 67d2643..0000000 --- a/app/components/RadioGroup.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import React, { createContext, useContext, useRef } from "react"; -import { AriaRadioGroupProps, AriaRadioProps, VisuallyHidden, useFocusRing } from "react-aria"; -import { useRadio, useRadioGroup } from "react-aria"; -import { RadioGroupState } from "react-stately"; -import { useRadioGroupState } from "react-stately"; - -import cn from "~/utils/cn"; - -interface RadioGroupProps extends AriaRadioGroupProps { - children: React.ReactElement[]; - label: string; - className?: string; -} - -const RadioContext = createContext(null); - -function RadioGroup({ children, label, className, ...props }: RadioGroupProps) { - const state = useRadioGroupState(props); - const { radioGroupProps, labelProps } = useRadioGroup( - { - ...props, - "aria-label": label, - }, - state, - ); - - return ( -
- - {label} - - {children} -
- ); -} - -interface RadioProps extends AriaRadioProps { - label: string; - className?: string; -} - -function Radio({ children, label, className, ...props }: RadioProps) { - const state = useContext(RadioContext); - const ref = useRef(null); - const { inputProps, isSelected, isDisabled } = useRadio( - { - ...props, - "aria-label": label, - }, - state!, - ref, - ); - const { isFocusVisible, focusProps } = useFocusRing(); - - return ( -