diff --git a/app/components/generic/Label.tsx b/app/components/generic/Label.tsx new file mode 100644 index 000000000..31097283b --- /dev/null +++ b/app/components/generic/Label.tsx @@ -0,0 +1,26 @@ +'use client'; + +import classNames from 'classnames'; +import React from 'react'; + +export default function Label({ + children, + htmlFor, + className = '', + required = false, +}: { + children: React.ReactNode; + htmlFor: string; + className?: string; + required?: boolean; +}) { + return ( + + ); +} diff --git a/app/components/generic/select/FormMultiSelect.tsx b/app/components/generic/select/FormMultiSelect.tsx new file mode 100644 index 000000000..ffe6faf3a --- /dev/null +++ b/app/components/generic/select/FormMultiSelect.tsx @@ -0,0 +1,58 @@ +'use client'; + +import { MultiSelect, ComboboxData } from '@mantine/core'; +import classnames from 'classnames'; +import _kebabCase from 'lodash-es/kebabCase'; +import { FocusEventHandler } from 'react'; +import Label from '../Label'; + +export interface FormMultiSelectProps { + id?: string; + name: string; + label?: string; + data: ComboboxData; + onChange: (value: string[]) => void; + onBlur?: FocusEventHandler | undefined; + value: string[]; + disabled?: boolean; + classNames?: { + wrapper?: string; + label?: string; + input?: string; + }; +} + +export default function FormMultiSelect({ + id, + name, + label, + classNames, + data, + onChange, + onBlur, + value, + disabled = false, +}: FormMultiSelectProps) { + if (!id) id = _kebabCase(name); + + return ( +
+ {label && ( + + )} + + +
+ ); +} diff --git a/app/components/generic/select/FormSingleSelect.tsx b/app/components/generic/select/FormSingleSelect.tsx new file mode 100644 index 000000000..861a374c0 --- /dev/null +++ b/app/components/generic/select/FormSingleSelect.tsx @@ -0,0 +1,60 @@ +'use client'; + +import { Select, ComboboxData, ComboboxItem } from '@mantine/core'; +import classnames from 'classnames'; +import _kebabCase from 'lodash-es/kebabCase'; +import { FocusEventHandler } from 'react'; +import Label from '../Label'; + +export interface FormSingleSelectProps { + id?: string; + name: string; + label?: string; + data: ComboboxData; + onChange: (value: string, option: ComboboxItem) => void; + onBlur?: FocusEventHandler | undefined; + value: string; + disabled?: boolean; + classNames?: { + wrapper?: string; + label?: string; + input?: string; + }; +} + +export default function FormSingleSelect({ + id, + name, + label, + classNames, + data, + onChange, + onBlur, + value, + disabled = false, +}: FormSingleSelectProps) { + if (!id) id = _kebabCase(name); + + return ( +
+ {label && ( + + )} + +