{
+ alert(`Value changed to: ${newValue}`)
+ setValue(newValue)
+ }}
+ />
+ )
+}
+
+export const Error = () => {
+ const [value, setValue] = useState(items[0].value)
+
+ return (
+
+ {
+ alert(`Value changed to: ${newValue}`)
+ setValue(newValue)
+ }}
+ />
+ {
+ alert(`Value changed to: ${newValue}`)
+ setValue(newValue)
+ }}
+ />
+
+ )
+}
+
+export const Tooltip = () => {
+ const [value, setValue] = useState(items[0].value)
+
+ return (
+
+ {
+ alert(`Value changed to: ${newValue}`)
+ setValue(newValue)
+ }}
+ />
+ {
+ alert(`Value changed to: ${newValue}`)
+ setValue(newValue)
+ }}
+ />
+ {
+ alert(`Value changed to: ${newValue}`)
+ setValue(newValue)
+ }}
+ />
+
+ )
+}
diff --git a/src/forms/SelectField.tsx b/src/forms/SelectField.tsx
new file mode 100644
index 00000000..84a57eb4
--- /dev/null
+++ b/src/forms/SelectField.tsx
@@ -0,0 +1,147 @@
+import { faCircleExclamation } from '@fortawesome/free-solid-svg-icons'
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
+import React from 'react'
+import { twMerge } from 'tailwind-merge'
+import Select, { Item, SelectClassName } from '../Select'
+import { Tooltip } from '../Tooltip'
+import Label from './Label'
+
+export interface SelectFieldProps {
+ id?: string
+ data?: {
+ cy?: string
+ test?: string
+ }
+ name?: string
+ value: string
+ onChange: (newValue: string) => void
+ onBlur?: () => void
+ label?: string
+ labelType?: 'small' | 'large'
+ placeholder?: string
+ tooltip?: string | React.ReactNode
+ required?: boolean
+ items: Item[]
+ disabled?: boolean
+ error?: string
+ hideError?: boolean
+ contentPosition?: 'item-aligned' | 'popper'
+ className?: {
+ root?: string
+ label?: string
+ error?: string
+ tooltip?: string
+ select?: SelectClassName
+ }
+}
+
+/**
+ * This component returns a select field that works as to be expected in a Formik environment.
+ * State is managed by Formik through the name attribute.
+ *
+ * @param id - The id of the field.
+ * @param data - The object of data attributes that can be used for testing (e.g. data-test or data-cy)
+ * @param name - The name of the field.
+ * @param value - The value of the field (external state management).
+ * @param onChange - The onChange function of the field (external state management).
+ * @param onBlur - The onBlur function of the field (external state management).
+ * @param label - The optional label is shown next to the field in the form.
+ * @param labelType - The optional labelType can be used to change the size and position of the label according to pre-defined standards.
+ * @param placeholder - The optional placeholder is shown when no value is selected / initialization with 'undefined' is chosen.
+ * @param disabled - The optional disabled prop disables the select component.
+ * @param error - The optional error message is shown next to the component.
+ * @param hideError - Hide the error message below this component as is might be more appropriate to show it somewhere else.
+ * @param contentPosition - The position of the content of the select component. Currently only 'item-aligned' and 'popper' are supported.
+ * @param tooltip - The optional tooltip is shown on hover next to the label.
+ * @param items - The array of items that should be available on the select component.
+ * @param required - Indicate whether the field is required or not.
+ * @param className - The optional className object allows you to override the default styling.
+ * @returns Select component with formik state management.
+ */
+export function SelectField({
+ id,
+ data,
+ name,
+ value,
+ onChange,
+ onBlur,
+ label,
+ labelType = 'small',
+ placeholder,
+ tooltip,
+ required = false,
+ items,
+ disabled = false,
+ error,
+ hideError = false,
+ contentPosition = 'item-aligned',
+ className,
+ ...props
+}: SelectFieldProps) {
+ return (
+
+
+ {label && (
+
+ )}
+
+
+
+ {error && !hideError && (
+
+
+
+ )}
+
+
+
+ )
+}
+
+export default SelectField