@helpwave/hightide 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coloring/shading.cjs +15 -6
- package/dist/coloring/shading.cjs.map +1 -1
- package/dist/coloring/shading.js +15 -6
- package/dist/coloring/shading.js.map +1 -1
- package/dist/components/date/DatePicker.cjs +15 -6
- package/dist/components/date/DatePicker.cjs.map +1 -1
- package/dist/components/date/DatePicker.js +15 -6
- package/dist/components/date/DatePicker.js.map +1 -1
- package/dist/components/date/YearMonthPicker.cjs +15 -6
- package/dist/components/date/YearMonthPicker.cjs.map +1 -1
- package/dist/components/date/YearMonthPicker.js +15 -6
- package/dist/components/date/YearMonthPicker.js.map +1 -1
- package/dist/components/layout-and-navigation/Expandable.cjs +15 -6
- package/dist/components/layout-and-navigation/Expandable.cjs.map +1 -1
- package/dist/components/layout-and-navigation/Expandable.d.cts +2 -0
- package/dist/components/layout-and-navigation/Expandable.d.ts +2 -0
- package/dist/components/layout-and-navigation/Expandable.js +15 -6
- package/dist/components/layout-and-navigation/Expandable.js.map +1 -1
- package/dist/components/layout-and-navigation/FAQSection.cjs +16 -8
- package/dist/components/layout-and-navigation/FAQSection.cjs.map +1 -1
- package/dist/components/layout-and-navigation/FAQSection.js +16 -8
- package/dist/components/layout-and-navigation/FAQSection.js.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.cjs +15 -6
- package/dist/components/user-action/DateAndTimePicker.cjs.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.js +15 -6
- package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
- package/dist/css/globals.css +3 -6
- package/dist/index.cjs +16 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/coloring/shading.ts","../../src/coloring/types.ts","../../src/components/branding/HelpwaveBadge.tsx","../../src/components/layout-and-navigation/Tile.tsx","../../src/components/icons-and-geometry/Helpwave.tsx","../../src/components/date/DatePicker.tsx","../../src/localization/LanguageProvider.tsx","../../src/hooks/useLocalStorage.ts","../../src/localization/util.ts","../../src/util/noop.ts","../../src/components/user-action/Button.tsx","../../src/components/date/YearMonthPicker.tsx","../../src/components/layout-and-navigation/Expandable.tsx","../../src/components/date/DayPicker.tsx","../../src/components/date/TimeDisplay.tsx","../../src/components/date/TimePicker.tsx","../../src/components/dialogs/ConfirmDialog.tsx","../../src/components/layout-and-navigation/Overlay.tsx","../../src/hooks/useHoverState.ts","../../src/components/user-action/Tooltip.tsx","../../src/components/icons-and-geometry/Avatar.tsx","../../src/components/icons-and-geometry/Circle.tsx","../../src/components/icons-and-geometry/Ring.tsx","../../src/components/icons-and-geometry/Tag.tsx","../../src/components/layout-and-navigation/BreadCrumb.tsx","../../src/components/layout-and-navigation/Carousel.tsx","../../src/components/layout-and-navigation/Chip.tsx","../../src/components/layout-and-navigation/DividerInserter.tsx","../../src/components/layout-and-navigation/FAQSection.tsx","../../src/components/layout-and-navigation/MarkdownInterpreter.tsx","../../src/components/layout-and-navigation/Pagination.tsx","../../src/components/layout-and-navigation/SearchableList.tsx","../../src/components/user-action/Input.tsx","../../src/hooks/useSaveDelay.ts","../../src/components/user-action/Label.tsx","../../src/components/layout-and-navigation/StepperBar.tsx","../../src/components/layout-and-navigation/Table.tsx","../../src/components/user-action/Checkbox.tsx","../../src/components/layout-and-navigation/TextImage.tsx","../../src/components/layout-and-navigation/VerticalDivider.tsx","../../src/components/loading-states/ErrorComponent.tsx","../../src/components/loading-states/LoadingAndErrorComponent.tsx","../../src/components/loading-states/LoadingAnimation.tsx","../../src/components/loading-states/LoadingButton.tsx","../../src/components/loading-states/ProgressIndicator.tsx","../../src/components/modals/ConfirmModal.tsx","../../src/components/modals/DiscardChangesModal.tsx","../../src/components/modals/InputModal.tsx","../../src/components/user-action/Select.tsx","../../src/components/modals/LanguageModal.tsx","../../src/theming/useTheme.tsx","../../src/components/modals/ThemeModal.tsx","../../src/components/properties/CheckboxProperty.tsx","../../src/components/properties/PropertyBase.tsx","../../src/components/properties/DateProperty.tsx","../../src/components/properties/MultiSelectProperty.tsx","../../src/components/user-action/MultiSelect.tsx","../../src/components/user-action/Menu.tsx","../../src/hooks/useOutsideClick.ts","../../src/components/properties/NumberProperty.tsx","../../src/components/properties/SelectProperty.tsx","../../src/components/properties/TextProperty.tsx","../../src/components/user-action/Textarea.tsx","../../src/components/user-action/DateAndTimePicker.tsx","../../src/components/user-action/ScrollPicker.tsx","../../src/components/user-action/ToggleableInput.tsx","../../src/util/news.ts"],"sourcesContent":["import tinycolor from 'tinycolor2'\nimport type { ShadedColors } from '@/index'\nimport { shadingColorValues } from '@/index'\n\n// Function to generate a full shading of several colors\nexport const generateShadingColors = (partialShading: Omit<Partial<ShadedColors>, '0' | '1000'>): ShadedColors => {\n const shading: ShadedColors = {\n 0: '#FFFFFF',\n 1000: '#000000'\n } as ShadedColors\n\n let index = 1\n while (index < shadingColorValues.length - 1) {\n const previous = shadingColorValues[index - 1]!\n const current = shadingColorValues[index]!\n\n if (partialShading[current] !== undefined) {\n shading[current] = partialShading[current]\n index++\n continue\n }\n\n let j: number = index + 1\n while (j < shadingColorValues.length) {\n if (partialShading[shadingColorValues[j]!] !== undefined) {\n break\n }\n j++\n }\n if (j === shadingColorValues.length) {\n j = shadingColorValues.length - 1\n }\n\n const nextFound = shadingColorValues[j]!\n const interval = nextFound - previous\n for (let k = index; k < j; k++) {\n const current = shadingColorValues[k]!\n const previousValue = partialShading[previous] ?? shading[previous]\n const nextValue = partialShading[nextFound] ?? shading[nextFound]\n shading[current] = tinycolor.mix(tinycolor(previousValue), tinycolor(nextValue), (current - previous) / interval * 100).toHexString()\n }\n index = j\n }\n\n return shading\n}\n","export const shadingColorValues = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000] as const\nexport type ColorShadingValue = typeof shadingColorValues[number]\nexport type ShadedColors = Record<ColorShadingValue, string>\n\nexport type ColoringStyle = 'background' | 'tonal' | 'tonal-opaque' | 'text' | 'text-border'\nexport type ColorMode = 'light' | 'dark'\n\nexport type Coloring = {\n color: '',\n style?: ColoringStyle,\n mode?: ColorMode,\n hover?: boolean,\n}\n","import clsx from 'clsx'\nimport { Tile } from '@/components/layout-and-navigation/Tile'\nimport { Helpwave } from '@/components/icons-and-geometry/Helpwave'\n\ntype Size = 'small' | 'large'\n\nexport type HelpwaveBadgeProps = {\n size?: Size,\n title?: string,\n className?: string,\n}\n\n/**\n * A Badge with the helpwave logo and the helpwave name\n */\nexport const HelpwaveBadge = ({\n size = 'small',\n title = 'helpwave',\n className = ''\n }: HelpwaveBadgeProps) => {\n const iconSize: number = size === 'small' ? 24 : 64\n\n return (\n <Tile\n prefix={(<Helpwave size={iconSize}/>)}\n title={{ value: title, className: size === 'small' ? 'textstyle-title-lg text-base' : 'textstyle-title-xl' }}\n className={clsx(\n {\n 'px-2 py-1 rounded-md': size === 'small',\n 'px-4 py-1 rounded-md': size === 'large',\n }, className\n )}\n />\n )\n}\n","import type { ReactNode } from 'react'\nimport Image from 'next/image'\nimport clsx from 'clsx'\n\nexport type TileProps = {\n title: { value: string, className?: string },\n description?: { value: string, className?: string },\n prefix?: ReactNode,\n suffix?: ReactNode,\n className?: string,\n}\n\n/**\n * A component for creating a tile similar to the flutter ListTile\n */\nexport const Tile = ({\n title,\n description,\n prefix,\n suffix,\n className\n }: TileProps) => {\n return (\n <div className={clsx('row gap-x-4 w-full items-center', className)}>\n {prefix}\n <div className=\"col w-full\">\n <span className={clsx(title.className)}>{title.value}</span>\n {!!description &&\n <span className={clsx(description.className ?? 'textstyle-description')}>{description.value}</span>}\n </div>\n {suffix}\n </div>\n )\n}\n\ntype ImageLocation = 'prefix' | 'suffix'\ntype ImageSize = {\n width: number,\n height: number,\n}\n\nexport type TileWithImageProps = Omit<TileProps, 'suffix' | 'prefix'> & {\n url: string,\n imageLocation?: ImageLocation,\n imageSize?: ImageSize,\n imageClassName?: string,\n}\n\n/**\n * A Tile with an image as prefix or suffix\n */\nexport const TileWithImage = ({\n url,\n imageLocation = 'prefix',\n imageSize = { width: 24, height: 24 },\n imageClassName = '',\n ...tileProps\n }: TileWithImageProps) => {\n const image = <Image src={url} alt=\"\" {...imageSize} className={clsx(imageClassName)}/>\n return (\n <Tile\n {...tileProps}\n prefix={imageLocation === 'prefix' ? image : undefined}\n suffix={imageLocation === 'suffix' ? image : undefined}\n />\n )\n}\n","import type { SVGProps } from 'react'\nimport { clsx } from 'clsx'\n\nexport type HelpwaveProps = SVGProps<SVGSVGElement> & {\n color?: string,\n animate?: 'none' | 'loading' | 'pulse' | 'bounce',\n size?: number,\n}\n\n/**\n * The helpwave loading spinner based on the svg logo.\n */\nexport const Helpwave = ({\n color = 'currentColor',\n animate = 'none',\n size = 64,\n ...props\n }: HelpwaveProps) => {\n const isLoadingAnimation = animate === 'loading'\n let svgAnimationKey = ''\n\n if (animate === 'pulse') {\n svgAnimationKey = 'animate-pulse'\n } else if (animate === 'bounce') {\n svgAnimationKey = 'animate-bounce'\n }\n\n if (size < 0) {\n console.error('size cannot be less than 0')\n size = 64\n }\n\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 888 888\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={48}\n {...props}\n >\n <g className={clsx(svgAnimationKey)}>\n <path className={clsx({ 'animate-wave-big-left-up': isLoadingAnimation })}\n d=\"M144 543.235C144 423.259 232.164 326 340.92 326\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-big-right-down': isLoadingAnimation })}\n d=\"M537.84 544.104C429.084 544.104 340.92 446.844 340.92 326.869\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-left-up': isLoadingAnimation })}\n d=\"M462.223 518.035C462.223 432.133 525.348 362.495 603.217 362.495\" stroke={color}\n strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-right-down': isLoadingAnimation })}\n d=\"M745.001 519.773C666.696 519.773 603.218 450.136 603.218 364.233\" stroke={color}\n strokeDasharray=\"1000\"/>\n </g>\n </svg>\n )\n}\n","import { useEffect, useState } from 'react'\nimport { ArrowDown, ArrowUp, ChevronDown } from 'lucide-react'\nimport type { Language } from '@/localization/util'\nimport { useLocale } from '@/localization/LanguageProvider'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { noop } from '@/util/noop'\nimport { addDuration, isInTimeSpan, subtractDuration } from '@/util/date'\nimport clsx from 'clsx'\nimport { SolidButton, TextButton } from '../user-action/Button'\nimport type { YearMonthPickerProps } from './YearMonthPicker'\nimport { YearMonthPicker } from './YearMonthPicker'\nimport type { DayPickerProps } from './DayPicker'\nimport { DayPicker } from './DayPicker'\n\ntype DatePickerTranslation = {\n today: string,\n}\n\nconst defaultDatePickerTranslation: Record<Language, DatePickerTranslation> = {\n en: {\n today: 'Today',\n },\n de: {\n today: 'Heute',\n }\n}\n\ntype DisplayMode = 'yearMonth' | 'day'\n\nexport type DatePickerProps = {\n value?: Date,\n start?: Date,\n end?: Date,\n initialDisplay?: DisplayMode,\n onChange?: (date: Date) => void,\n dayPickerProps?: Omit<DayPickerProps, 'displayedMonth' | 'onChange' | 'selected'>,\n yearMonthPickerProps?: Omit<YearMonthPickerProps, 'displayedYearMonth' | 'onChange' | 'start' | 'end'>,\n className?: string,\n}\n\n/**\n * A Component for picking a date\n */\nexport const DatePicker = ({\n overwriteTranslation,\n value = new Date(),\n start = subtractDuration(new Date(), { years: 50 }),\n end = addDuration(new Date(), { years: 50 }),\n initialDisplay = 'day',\n onChange = noop,\n yearMonthPickerProps,\n dayPickerProps,\n className = ''\n }: PropsForTranslation<DatePickerTranslation, DatePickerProps>) => {\n const locale = useLocale()\n const translation = useTranslation(defaultDatePickerTranslation, overwriteTranslation)\n const [displayedMonth, setDisplayedMonth] = useState<Date>(value)\n const [displayMode, setDisplayMode] = useState<DisplayMode>(initialDisplay)\n\n useEffect(() => {\n setDisplayedMonth(value)\n }, [value])\n\n return (\n <div className={clsx('col gap-y-4', className)}>\n <div className=\"row items-center justify-between h-7\">\n <TextButton\n className={clsx('row gap-x-1 items-center cursor-pointer select-none', {\n 'text-disabled-text': displayMode !== 'day',\n })}\n onClick={() => setDisplayMode(displayMode === 'day' ? 'yearMonth' : 'day')}\n >\n {`${new Intl.DateTimeFormat(locale, { month: 'long' }).format(displayedMonth)} ${displayedMonth.getFullYear()}`}\n <ChevronDown size={16}/>\n </TextButton>\n {displayMode === 'day' && (\n <div className=\"row justify-end\">\n <SolidButton\n size=\"small\"\n color=\"primary\"\n disabled={!isInTimeSpan(subtractDuration(displayedMonth, { months: 1 }), start, end)}\n onClick={() => {\n setDisplayedMonth(subtractDuration(displayedMonth, { months: 1 }))\n }}\n >\n <ArrowUp size={20}/>\n </SolidButton>\n <SolidButton\n size=\"small\"\n color=\"primary\"\n disabled={!isInTimeSpan(addDuration(displayedMonth, { months: 1 }), start, end)}\n onClick={() => {\n setDisplayedMonth(addDuration(displayedMonth, { months: 1 }))\n }}\n >\n <ArrowDown size={20}/>\n </SolidButton>\n </div>\n )}\n </div>\n {displayMode === 'yearMonth' ? (\n <YearMonthPicker\n {...yearMonthPickerProps}\n displayedYearMonth={value}\n start={start}\n end={end}\n onChange={newDate => {\n setDisplayedMonth(newDate)\n setDisplayMode('day')\n }}\n />\n ) : (\n <div>\n <DayPicker\n {...dayPickerProps}\n displayedMonth={displayedMonth}\n start={start}\n end={end}\n selected={value}\n onChange={date => {\n onChange(date)\n }}\n />\n <div className=\"mt-2\">\n <TextButton\n onClick={() => {\n const newDate = new Date()\n newDate.setHours(value.getHours(), value.getMinutes())\n onChange(newDate)\n }}\n >\n {translation.today}\n </TextButton>\n </div>\n </div>\n )}\n </div>\n )\n}\n\n/**\n * Example for the Date Picker\n */\nexport const DatePickerUncontrolled = ({\n value = new Date(),\n onChange = noop,\n ...props\n }: DatePickerProps) => {\n const [date, setDate] = useState<Date>(value)\n\n useEffect(() => setDate(value), [value])\n\n return (\n <DatePicker\n {...props}\n value={date}\n onChange={date1 => {\n setDate(date1)\n onChange(date1)\n }}\n />\n )\n}\n","import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport { useLocalStorage } from '@/hooks/useLocalStorage'\nimport type { Language } from './util'\nimport { LanguageUtil } from './util'\n\nexport type LanguageContextValue = {\n language: Language,\n setLanguage: Dispatch<SetStateAction<Language>>,\n}\n\nexport const LanguageContext = createContext<LanguageContextValue>({\n language: LanguageUtil.DEFAULT_LANGUAGE,\n setLanguage: (v) => v\n})\n\nexport const useLanguage = () => useContext(LanguageContext)\n\nexport const useLocale = (overWriteLanguage?: Language) => {\n const { language } = useLanguage()\n const mapping: Record<Language, string> = {\n en: 'en-US',\n de: 'de-DE'\n }\n return mapping[overWriteLanguage ?? language]\n}\n\ntype LanguageProviderProps = {\n initialLanguage?: Language,\n}\n\nexport const LanguageProvider = ({ initialLanguage, children }: PropsWithChildren<LanguageProviderProps>) => {\n const [language, setLanguage] = useState<Language>(initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n const [storedLanguage, setStoredLanguage] = useLocalStorage<Language>('language', initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n\n useEffect(() => {\n if (language !== initialLanguage && initialLanguage) {\n console.warn('LanguageProvider initial state changed: Prefer using languageProvider\\'s setLanguage instead')\n setLanguage(initialLanguage)\n }\n }, [initialLanguage]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n // TODO set locale of html tag here as well\n setStoredLanguage(language)\n }, [language, setStoredLanguage])\n\n useEffect(() => {\n if (storedLanguage !== null) {\n setLanguage(storedLanguage)\n return\n }\n\n const LanguageToTestAgainst = Object.values(LanguageUtil.languages)\n\n const matchingBrowserLanguage = window.navigator.languages\n .map(language => LanguageToTestAgainst.find((test) => language === test || language.split('-')[0] === test))\n .filter(entry => entry !== undefined)\n\n if (matchingBrowserLanguage.length === 0) return\n\n const firstMatch = matchingBrowserLanguage[0] as Language\n setLanguage(firstMatch)\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <LanguageContext.Provider value={{\n language,\n setLanguage\n }}>\n {children}\n </LanguageContext.Provider>\n )\n}","import type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { LocalStorageService } from '../util/storage'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(value => {\n const newValue = value instanceof Function ? value(storedValue) : value\n const storageService = new LocalStorageService()\n storageService.set(key, value)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n useEffect(() => {\n setStoredValue(get())\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return [storedValue, setValue]\n}","/**\n * The supported languages\n */\nconst languages = ['en', 'de'] as const\n\n/**\n * The supported languages\n */\nexport type Language = typeof languages[number]\n\n/**\n * The supported languages' names in their respective language\n */\nconst languagesLocalNames: Record<Language, string> = {\n en: 'English',\n de: 'Deutsch',\n}\n\n/**\n * The default language\n */\nconst DEFAULT_LANGUAGE: Language = 'en'\n\n/**\n * A constant definition for holding data regarding languages\n */\nexport const LanguageUtil = {\n languages,\n DEFAULT_LANGUAGE,\n languagesLocalNames,\n}","export const noop = () => undefined\n","import type { ButtonHTMLAttributes, PropsWithChildren, ReactNode } from 'react'\nimport clsx from 'clsx'\n\n\nexport const ButtonColorUtil = {\n solid: ['primary', 'secondary', 'tertiary', 'positive', 'warning', 'negative', 'neutral'] as const,\n text: ['primary', 'negative', 'neutral'] as const,\n outline: ['primary'] as const,\n}\n\n\n/**\n * The allowed colors for the SolidButton and IconButton\n */\nexport type SolidButtonColor = typeof ButtonColorUtil.solid[number]\n/**\n * The allowed colors for the OutlineButton\n */\nexport type OutlineButtonColor = typeof ButtonColorUtil.outline[number]\n/**\n * The allowed colors for the TextButton\n */\nexport type TextButtonColor = typeof ButtonColorUtil.text[number]\n\n/**\n * The different sizes for a button\n */\ntype ButtonSizes = 'small' | 'medium' | 'large'\n\n/**\n * The shard properties between all button types\n */\nexport type ButtonProps = PropsWithChildren<{\n /**\n * @default 'medium'\n */\n size?: ButtonSizes,\n}> & ButtonHTMLAttributes<Element>\n\nconst paddingMapping: Record<ButtonSizes, string> = {\n small: 'btn-sm',\n medium: 'btn-md',\n large: 'btn-lg'\n}\n\nconst iconPaddingMapping: Record<ButtonSizes, string> = {\n small: 'icon-btn-sm',\n medium: 'icon-btn-md',\n large: 'icon-btn-lg'\n}\n\nexport const ButtonUtil = {\n paddingMapping,\n iconPaddingMapping\n}\n\ntype ButtonWithIconsProps = ButtonProps & {\n startIcon?: ReactNode,\n endIcon?: ReactNode,\n}\n\nexport type SolidButtonProps = ButtonWithIconsProps & {\n color?: SolidButtonColor,\n}\n\nexport type OutlineButtonProps = ButtonWithIconsProps & {\n color?: OutlineButtonColor,\n}\n\nexport type TextButtonProps = ButtonWithIconsProps & {\n color?: TextButtonColor,\n}\n\nexport type IconButtonProps = ButtonProps & {\n color?: SolidButtonColor,\n}\n\n/**\n * A button with a solid background and different sizes\n */\nconst SolidButton = ({\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n startIcon,\n endIcon,\n onClick,\n className,\n ...restProps\n }: SolidButtonProps) => {\n const colorClasses = {\n primary: 'bg-button-solid-primary-background text-button-solid-primary-text',\n secondary: 'bg-button-solid-secondary-background text-button-solid-secondary-text',\n tertiary: 'bg-button-solid-tertiary-background text-button-solid-tertiary-text',\n positive: 'bg-button-solid-positive-background text-button-solid-positive-text',\n warning: 'bg-button-solid-warning-background text-button-solid-warning-text',\n negative: 'bg-button-solid-negative-background text-button-solid-negative-text',\n neutral: 'bg-button-solid-neutral-background text-button-solid-neutral-text',\n }[color]\n\n const iconColorClasses = {\n primary: 'text-button-solid-primary-icon',\n secondary: 'text-button-solid-secondary-icon',\n tertiary: 'text-button-solid-tertiary-icon',\n positive: 'text-button-solid-positive-icon',\n warning: 'text-button-solid-warning-icon',\n negative: 'text-button-solid-negative-icon',\n neutral: 'text-button-solid-neutral-icon',\n }[color]\n\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className,\n {\n 'text-disabled-text bg-disabled-background': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.paddingMapping[size]\n )}\n {...restProps}\n >\n {startIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {startIcon}\n </span>\n )}\n {children}\n {endIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {endIcon}\n </span>\n )}\n </button>\n )\n}\n\n/**\n * A button with an outline border and different sizes\n */\nconst OutlineButton = ({\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n startIcon,\n endIcon,\n onClick,\n className,\n ...restProps\n }: OutlineButtonProps) => {\n const colorClasses = {\n primary: 'bg-transparent border-2 border-button-outline-primary-text text-button-outline-primary-text',\n }[color]\n\n const iconColorClasses = {\n primary: 'text-button-outline-primary-icon',\n }[color]\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className, {\n 'text-disabled-text border-disabled-outline': disabled,\n [clsx(colorClasses, 'hover:brightness-80')]: !disabled,\n },\n ButtonUtil.paddingMapping[size]\n )}\n {...restProps}\n >\n {startIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {startIcon}\n </span>\n )}\n {children}\n {endIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {endIcon}\n </span>\n )}\n </button>\n )\n}\n\n/**\n * A text that is a button that can have different sizes\n */\nconst TextButton = ({\n children,\n disabled = false,\n color = 'neutral',\n size = 'medium',\n startIcon,\n endIcon,\n onClick,\n className,\n ...restProps\n }: TextButtonProps) => {\n const colorClasses = {\n primary: 'bg-transparent text-button-text-primary-text',\n negative: 'bg-transparent text-button-text-negative-text',\n neutral: 'bg-transparent text-button-text-neutral-text',\n }[color]\n\n const iconColorClasses = {\n primary: 'text-button-text-primary-icon',\n negative: 'text-button-text-negative-icon',\n neutral: 'text-button-text-neutral-icon',\n }[color]\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className, {\n 'text-disabled-text': disabled,\n [clsx(colorClasses, 'hover:bg-button-text-hover-background rounded-full')]: !disabled,\n },\n ButtonUtil.paddingMapping[size]\n )}\n {...restProps}\n >\n {startIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {startIcon}\n </span>\n )}\n {children}\n {endIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {endIcon}\n </span>\n )}\n </button>\n )\n}\n\n\n/**\n * A button for icons with a solid background and different sizes\n */\nconst IconButton = ({\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n onClick,\n className,\n ...restProps\n }: IconButtonProps) => {\n const colorClasses = {\n primary: 'bg-button-solid-primary-background text-button-solid-primary-text',\n secondary: 'bg-button-solid-secondary-background text-button-solid-secondary-text',\n tertiary: 'bg-button-solid-tertiary-background text-button-solid-tertiary-text',\n positive: 'bg-button-solid-positive-background text-button-solid-positive-text',\n warning: 'bg-button-solid-warning-background text-button-solid-warning-text',\n negative: 'bg-button-solid-negative-background text-button-solid-negative-text',\n neutral: 'bg-button-solid-neutral-background text-button-solid-neutral-text',\n }[color]\n\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className,\n {\n 'text-disabled-text bg-disabled-background': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.iconPaddingMapping[size]\n )}\n {...restProps}\n >\n {children}\n </button>\n )\n}\n\nexport { SolidButton, OutlineButton, TextButton, IconButton }\n","import { useEffect, useRef, useState } from 'react'\nimport { Scrollbars } from 'react-custom-scrollbars-2'\nimport { noop } from '@/util/noop'\nimport { equalSizeGroups, range } from '@/util/array'\nimport clsx from 'clsx'\nimport { Expandable } from '@/components/layout-and-navigation/Expandable'\nimport { addDuration, monthsList, subtractDuration } from '@/util/date'\nimport { useLocale } from '@/localization/LanguageProvider'\n\nexport type YearMonthPickerProps = {\n displayedYearMonth?: Date,\n start?: Date,\n end?: Date,\n onChange?: (date: Date) => void,\n className?: string,\n maxHeight?: number,\n showValueOpen?: boolean,\n}\n\n// TODO use a dynamically loading infinite list here\nexport const YearMonthPicker = ({\n displayedYearMonth = new Date(),\n start = subtractDuration(new Date(), { years: 50 }),\n end = addDuration(new Date(), { years: 50 }),\n onChange = noop,\n className = '',\n maxHeight = 300,\n showValueOpen = true\n }: YearMonthPickerProps) => {\n const locale = useLocale()\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n const scrollToItem = () => {\n if (ref.current) {\n ref.current.scrollIntoView({\n behavior: 'instant',\n block: 'center',\n })\n }\n }\n\n scrollToItem()\n }, [ref])\n\n if (end < start) {\n console.error(`startYear: (${start}) less than endYear: (${end})`)\n return null\n }\n\n const years = range(start.getFullYear(), end.getFullYear())\n\n return (\n <div className={clsx('col select-none', className)}>\n <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>\n <div className=\"col gap-y-1 mr-3\">\n {years.map(year => {\n const selectedYear = displayedYearMonth.getFullYear() === year\n return (\n <Expandable\n key={year}\n ref={(displayedYearMonth.getFullYear() ?? new Date().getFullYear()) === year ? ref : undefined}\n label={<span className={clsx({ 'text-primary font-bold': selectedYear })}>{year}</span>}\n initialExpansion={showValueOpen && selectedYear}\n >\n <div className=\"col gap-y-1 px-2 pb-2\">\n {equalSizeGroups([...monthsList], 3).map((monthList, index) => (\n <div key={index} className=\"row\">\n {monthList.map(month => {\n const monthIndex = monthsList.indexOf(month)\n const newDate = new Date(year, monthIndex)\n\n const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth()\n const firstOfMonth = new Date(year, monthIndex, 1)\n const lastOfMonth = new Date(year, monthIndex, 1)\n const isAfterStart = start === undefined || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 })\n const isBeforeEnd = end === undefined || firstOfMonth <= end\n const isValid = isAfterStart && isBeforeEnd\n return (\n <button\n key={month}\n disabled={!isValid}\n className={clsx(\n 'chip hover:brightness-95 flex-1',\n {\n 'bg-gray-50 text-black': !selectedMonth && isValid,\n 'bg-primary text-on-primary': selectedMonth && isValid,\n 'bg-disabled-background text-disabled-text': !isValid\n }\n )}\n onClick={() => {\n onChange(newDate)\n }}\n >\n {new Intl.DateTimeFormat(locale, { month: 'short' }).format(newDate)}\n </button>\n )\n })}\n </div>\n ))}\n </div>\n </Expandable>\n )\n })}\n </div>\n </Scrollbars>\n </div>\n )\n}\n\nexport const YearMonthPickerUncontrolled = ({\n displayedYearMonth = new Date(),\n onChange = noop,\n ...props\n }: YearMonthPickerProps) => {\n const [yearMonth, setYearMonth] = useState<Date>(displayedYearMonth)\n\n useEffect(() => setYearMonth(displayedYearMonth), [displayedYearMonth])\n\n return (\n <YearMonthPicker\n displayedYearMonth={yearMonth}\n onChange={date => {\n setYearMonth(date)\n onChange(date)\n }}\n {...props}\n />\n )\n}\n","import type { PropsWithChildren, ReactNode } from 'react'\nimport { forwardRef, useState } from 'react'\nimport { ChevronDown, ChevronUp } from 'lucide-react'\nimport clsx from 'clsx'\n\ntype IconBuilder = (expanded: boolean) => ReactNode\n\nexport type ExpandableProps = PropsWithChildren<{\n label: ReactNode,\n icon?: IconBuilder,\n initialExpansion?: boolean,\n /**\n * Whether the expansion should only happen when the header is clicked or on the entire component\n */\n clickOnlyOnHeader?: boolean,\n className?: string,\n headerClassName?: string,\n}>\n\nconst DefaultIcon: IconBuilder = (expanded) => expanded ?\n (<ChevronUp size={16} className=\"min-w-[16px]\"/>)\n : (<ChevronDown size={16} className=\"min-w-[16px]\"/>)\n\n/**\n * A Component for showing and hiding content\n */\nexport const Expandable = forwardRef<HTMLDivElement, ExpandableProps>(({\n children,\n label,\n icon,\n initialExpansion = false,\n clickOnlyOnHeader = true,\n className = '',\n headerClassName = ''\n }, ref) => {\n const [isExpanded, setIsExpanded] = useState(initialExpansion)\n icon ??= DefaultIcon\n\n return (\n <div\n ref={ref}\n className={clsx('col bg-surface text-on-surface group rounded-lg shadow-sm', { 'cursor-pointer': !clickOnlyOnHeader }, className)}\n onClick={() => !clickOnlyOnHeader && setIsExpanded(!isExpanded)}\n >\n <button\n className={clsx('btn-md rounded-lg justify-between items-center bg-surface text-on-surface', { 'group-hover:brightness-95': !isExpanded }, headerClassName)}\n onClick={() => clickOnlyOnHeader && setIsExpanded(!isExpanded)}\n >\n {label}\n {icon(isExpanded)}\n </button>\n {isExpanded && (\n <div className=\"col\">\n {children}\n </div>\n )}\n </div>\n )\n})\n\nExpandable.displayName = 'Expandable'\n","import type { WeekDay } from '@/util/date'\nimport { equalDate, getWeeksForCalenderMonth, isInTimeSpan } from '@/util/date'\nimport { noop } from '@/util/noop'\nimport clsx from 'clsx'\nimport { useLocale } from '@/localization/LanguageProvider'\nimport { useEffect, useState } from 'react'\n\nexport type DayPickerProps = {\n displayedMonth: Date,\n selected?: Date,\n start?: Date,\n end?: Date,\n onChange?: (date: Date) => void,\n weekStart?: WeekDay,\n markToday?: boolean,\n className?: string,\n}\n\n/**\n * A component for selecting a day of a month\n */\nexport const DayPicker = ({\n displayedMonth,\n selected,\n start,\n end,\n onChange = noop,\n weekStart = 'monday',\n markToday = true,\n className = ''\n }: DayPickerProps) => {\n const locale = useLocale()\n const month = displayedMonth.getMonth()\n const weeks = getWeeksForCalenderMonth(displayedMonth, weekStart)\n\n return (\n <div className={clsx('col gap-y-1 min-w-[220px] select-none', className)}>\n <div className=\"row text-center\">\n {weeks[0]!.map((weekDay, index) => (\n <div key={index} className=\"flex-1 font-semibold\">\n {new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(weekDay).substring(0, 2)}\n </div>\n ))}\n </div>\n {weeks.map((week, index) => (\n <div key={index} className=\"row text-center\">\n {week.map((date) => {\n const isSelected = !!selected && equalDate(selected, date)\n const isToday = equalDate(new Date(), date)\n const isSameMonth = date.getMonth() === month\n const isDayValid = isInTimeSpan(date, start, end)\n return (\n <button\n disabled={!isDayValid}\n key={date.getDate()}\n className={clsx(\n 'flex-1 rounded-full border-2 border-transparent shadow-sm',\n {\n 'text-gray-700 bg-gray-100': !isSameMonth && isDayValid,\n 'text-black bg-white': !isSelected && isSameMonth && isDayValid,\n 'text-on-primary bg-primary': isSelected,\n 'border-black': isToday && markToday,\n 'hover:brightness-90 hover:bg-primary hover:text-on-primary': isDayValid,\n 'text-disabled-text bg-disabled-background': !isDayValid\n }\n )}\n onClick={() => onChange(date)}\n >\n {date.getDate()}\n </button>\n )\n })}\n </div>\n ))}\n </div>\n )\n}\n\nexport const DayPickerUncontrolled = ({ displayedMonth, onChange = noop, ...restProps }: DayPickerProps) => {\n const [date, setDate] = useState(displayedMonth)\n\n useEffect(() => setDate(displayedMonth), [displayedMonth])\n\n return (\n <DayPicker\n displayedMonth={date}\n onChange={newDate => {\n setDate(newDate)\n onChange(newDate)\n }}\n {...restProps}\n />\n )\n}\n","import type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\n\ntype TimeDisplayTranslation = {\n today: string,\n yesterday: string,\n tomorrow: string,\n inDays: (days: number) => string,\n agoDays: (days: number) => string,\n january: string,\n february: string,\n march: string,\n april: string,\n may: string,\n june: string,\n july: string,\n august: string,\n september: string,\n october: string,\n november: string,\n december: string,\n}\n\nconst defaultTimeDisplayTranslations: Record<Language, TimeDisplayTranslation> = {\n en: {\n today: 'today',\n yesterday: 'yesterday',\n tomorrow: 'tomorrow',\n inDays: (days: number) => `in ${days} days`,\n agoDays: (days: number) => `${days} days ago`,\n january: 'January',\n february: 'February',\n march: 'March',\n april: 'April',\n may: 'May',\n june: 'June',\n july: 'July',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December'\n },\n de: {\n today: 'heute',\n yesterday: 'gestern',\n tomorrow: 'morgen',\n inDays: (days: number) => `in ${days} Tagen`,\n agoDays: (days: number) => `vor ${days} Tagen`,\n january: 'Januar',\n february: 'Februar',\n march: 'März',\n april: 'April',\n may: 'Mai',\n june: 'Juni',\n july: 'Juli',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December'\n }\n}\n\ntype TimeDisplayMode = 'daysFromToday' | 'date'\n\ntype TimeDisplayProps = {\n date: Date,\n mode?: TimeDisplayMode,\n}\n\n/**\n * A Component for displaying time and dates in a unified fashion\n */\nexport const TimeDisplay = ({\n overwriteTranslation,\n date,\n mode = 'daysFromToday'\n }: PropsForTranslation<TimeDisplayTranslation, TimeDisplayProps>) => {\n const translation = useTranslation(defaultTimeDisplayTranslations, overwriteTranslation)\n const difference = new Date().setHours(0, 0, 0, 0).valueOf() - new Date(date).setHours(0, 0, 0, 0).valueOf()\n const isBefore = difference > 0\n const differenceInDays = Math.floor(Math.abs(difference) / (1000 * 3600 * 24))\n\n let displayString\n if (differenceInDays === 0) {\n displayString = translation.today\n } else if (differenceInDays === 1) {\n displayString = isBefore ? translation.yesterday : translation.tomorrow\n } else {\n displayString = isBefore ? translation.agoDays(differenceInDays) : translation.inDays(differenceInDays)\n }\n const monthToTranslation: { [key: number]: string } = {\n 0: translation.january,\n 1: translation.february,\n 2: translation.march,\n 3: translation.april,\n 4: translation.may,\n 5: translation.june,\n 6: translation.july,\n 7: translation.august,\n 8: translation.september,\n 9: translation.october,\n 10: translation.november,\n 11: translation.december\n } as const\n\n let fullString\n if (mode === 'daysFromToday') {\n fullString = `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')} - ${displayString}`\n } else {\n fullString = `${date.getDate()}. ${monthToTranslation[date.getMonth()]} ${date.getFullYear()}`\n }\n\n return (\n <span>\n {fullString}\n </span>\n )\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { Scrollbars } from 'react-custom-scrollbars-2'\nimport { noop } from '@/util/noop'\nimport { closestMatch, range } from '@/util/array'\nimport clsx from 'clsx'\n\ntype MinuteIncrement = '1min' | '5min' | '10min' | '15min' | '30min'\n\nexport type TimePickerProps = {\n time?: Date,\n onChange?: (time: Date) => void,\n is24HourFormat?: boolean,\n minuteIncrement?: MinuteIncrement,\n maxHeight?: number,\n className?: string,\n}\n\nexport const TimePicker = ({\n time = new Date(),\n onChange = noop,\n is24HourFormat = true,\n minuteIncrement = '5min',\n maxHeight = 300,\n className = ''\n }: TimePickerProps) => {\n const minuteRef = useRef<HTMLButtonElement>(null)\n const hourRef = useRef<HTMLButtonElement>(null)\n\n const isPM = time.getHours() >= 11\n const hours = is24HourFormat ? range(0, 23) : range(1, 12)\n let minutes = range(0, 59)\n\n useEffect(() => {\n const scrollToItem = () => {\n if (minuteRef.current) {\n const container = minuteRef.current.parentElement!\n\n const hasOverflow = container.scrollHeight > maxHeight\n if (hasOverflow) {\n minuteRef.current.scrollIntoView({\n behavior: 'instant',\n block: 'nearest',\n })\n }\n }\n }\n scrollToItem()\n }, [minuteRef, minuteRef.current]) // eslint-disable-line\n\n useEffect(() => {\n const scrollToItem = () => {\n if (hourRef.current) {\n const container = hourRef.current.parentElement!\n\n const hasOverflow = container.scrollHeight > maxHeight\n if (hasOverflow) {\n hourRef.current.scrollIntoView({\n behavior: 'instant',\n block: 'nearest',\n })\n }\n }\n }\n scrollToItem()\n }, [hourRef, hourRef.current]) // eslint-disable-line\n\n switch (minuteIncrement) {\n case '5min':\n minutes = minutes.filter(value => value % 5 === 0)\n break\n case '10min':\n minutes = minutes.filter(value => value % 10 === 0)\n break\n case '15min':\n minutes = minutes.filter(value => value % 15 === 0)\n break\n case '30min':\n minutes = minutes.filter(value => value % 30 === 0)\n break\n }\n\n const closestMinute = closestMatch(minutes, (item1, item2) => Math.abs(item1 - time.getMinutes()) < Math.abs(item2 - time.getMinutes()))\n\n const style = (selected: boolean) => clsx('chip-full hover:brightness-90 hover:bg-primary hover:text-on-primary rounded-md mr-3',\n { 'bg-primary text-on-primary': selected, 'bg-white text-black': !selected })\n\n const onChangeWrapper = (transformer: (newDate: Date) => void) => {\n const newDate = new Date(time)\n transformer(newDate)\n onChange(newDate)\n }\n\n return (\n <div className={clsx('row gap-x-2 w-fit min-w-[150px] select-none', className)}>\n <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>\n <div className=\"col gap-y-1 h-full\">\n {hours.map(hour => {\n const currentHour = hour === time.getHours() - (!is24HourFormat && isPM ? 12 : 0)\n return (\n <button\n key={hour}\n ref={currentHour ? hourRef : undefined}\n className={style(currentHour)}\n onClick={() => onChangeWrapper(newDate => newDate.setHours(hour + (!is24HourFormat && isPM ? 12 : 0)))}\n >\n {hour.toString().padStart(2, '0')}\n </button>\n )\n })}\n </div>\n </Scrollbars>\n <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>\n <div className=\"col gap-y-1 h-full\">\n {minutes.map(minute => {\n const currentMinute = minute === closestMinute\n return (\n <button\n key={minute + minuteIncrement} // minute increment so that scroll works\n ref={currentMinute ? minuteRef : undefined}\n className={style(currentMinute)}\n onClick={() => onChangeWrapper(newDate => newDate.setMinutes(minute))}\n >\n {minute.toString().padStart(2, '0')}\n </button>\n )\n })}\n </div>\n </Scrollbars>\n {!is24HourFormat && (\n <div className=\"col gap-y-1\">\n <button\n className={style(!isPM)}\n onClick={() => onChangeWrapper(newDate => isPM && newDate.setHours(newDate.getHours() - 12))}\n >\n AM\n </button>\n <button\n className={style(isPM)}\n onClick={() => onChangeWrapper(newDate => !isPM && newDate.setHours(newDate.getHours() + 12))}\n >\n PM\n </button>\n </div>\n )}\n </div>\n )\n}\n\nexport const TimePickerUncontrolled = ({\n time,\n onChange = noop,\n ...props\n }: TimePickerProps) => {\n const [value, setValue] = useState(time)\n useEffect(() => setValue(time), [time])\n\n return (\n <TimePicker\n {...props}\n time={value}\n onChange={time1 => {\n setValue(time1)\n onChange(time1)\n }}\n />\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport type { SolidButtonColor } from '../user-action/Button'\nimport { SolidButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport clsx from 'clsx'\nimport type { DialogProps } from '@/components/layout-and-navigation/Overlay'\nimport { Dialog } from '@/components/layout-and-navigation/Overlay'\n\ntype ConfirmDialogTranslation = {\n confirm: string,\n cancel: string,\n decline: string,\n}\n\nexport type ConfirmDialogType = 'positive' | 'negative' | 'neutral' | 'primary'\n\nconst defaultConfirmDialogTranslation = {\n en: {\n confirm: 'Confirm',\n decline: 'Decline'\n },\n de: {\n confirm: 'Bestätigen',\n decline: 'Ablehnen'\n }\n}\n\ntype ButtonOverwriteType = {\n text?: string,\n color?: SolidButtonColor,\n disabled?: boolean,\n}\n\nexport type ConfirmDialogProps = DialogProps & {\n isShowingDecline?: boolean,\n requireAnswer?: boolean,\n onConfirm: () => void,\n onDecline?: () => void,\n confirmType?: ConfirmDialogType,\n /**\n * Order: Decline, Confirm\n */\n buttonOverwrites?: [ButtonOverwriteType, ButtonOverwriteType],\n}\n\n/**\n * A Dialog for demanding the user for confirmation\n *\n * To allow for background closing, prefer using a ConfirmModal\n */\nexport const ConfirmDialog = ({\n overwriteTranslation,\n children,\n onConfirm,\n onDecline,\n confirmType = 'positive',\n buttonOverwrites,\n className,\n ...restProps\n }: PropsForTranslation<ConfirmDialogTranslation, PropsWithChildren<ConfirmDialogProps>>) => {\n const translation = useTranslation(defaultConfirmDialogTranslation, overwriteTranslation)\n\n const mapping: Record<ConfirmDialogType, SolidButtonColor> = {\n neutral: 'primary',\n negative: 'negative',\n positive: 'positive',\n primary: 'primary',\n }\n\n return (\n <Dialog {...restProps} className={clsx('justify-between', className)}>\n <div className=\"col grow\">\n {children}\n </div>\n <div className=\"row mt-3 gap-x-4 justify-end\">\n {onDecline && (\n <SolidButton\n color={buttonOverwrites?.[0].color ?? 'negative'}\n onClick={onDecline}\n\n disabled={buttonOverwrites?.[0].disabled ?? false}\n >\n {buttonOverwrites?.[0].text ?? translation.decline}\n </SolidButton>\n )}\n <SolidButton\n autoFocus\n color={buttonOverwrites?.[1].color ?? mapping[confirmType]}\n onClick={onConfirm}\n disabled={buttonOverwrites?.[1].disabled ?? false}\n >\n {buttonOverwrites?.[1].text ?? translation.confirm}\n </SolidButton>\n </div>\n </Dialog>\n )\n}\n","import type { PropsWithChildren, ReactNode } from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport ReactDOM from 'react-dom'\nimport clsx from 'clsx'\nimport { Tooltip } from '@/components/user-action/Tooltip'\nimport { X } from 'lucide-react'\nimport { IconButton } from '@/components/user-action/Button'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { Language } from '@/localization/util'\n\nexport type OverlayProps = PropsWithChildren<{\n /**\n * Whether the overlay should be currently displayed\n */\n isOpen: boolean,\n /**\n * Callback when the background is clicked\n */\n onBackgroundClick?: () => void,\n /**\n * Styling for the background\n *\n * To remove the darkening, set bg-transparent\n */\n backgroundClassName?: string,\n}>\n\n/**\n * A generic overlay window which is managed by its parent\n */\nexport const Overlay = ({\n children,\n isOpen,\n onBackgroundClick,\n backgroundClassName,\n }: PropsWithChildren<OverlayProps>) => {\n // The element to which the overlay will be attached to\n const [root, setRoot] = useState<HTMLElement>()\n\n useEffect(() => {\n setRoot(document.body)\n }, [])\n\n if (!root || !isOpen) return null\n\n\n return ReactDOM.createPortal(\n <div className={clsx('fixed inset-0 z-[9999]')}>\n <div\n className={clsx('fixed inset-0 h-screen w-screen bg-black/30', backgroundClassName)}\n onClick={onBackgroundClick}\n />\n {children}\n </div>,\n root\n )\n}\n\n\nlet overlayStack: HTMLDivElement[] = []\n\n\n// --- Modal ---\n\ntype ModalHeaderTranslation = {\n close: string,\n}\n\nconst defaultModalHeaderTranslation: Record<Language, ModalHeaderTranslation> = {\n en: {\n close: 'Close'\n },\n de: {\n close: 'Schließen'\n }\n}\n\nexport type OverlayHeaderProps = {\n /**\n * Callback when the close button is clicked. If omitted or undefined, the button is hidden\n */\n onClose?: () => void,\n /** The title of the Modal. If you want to only set the text use `titleText` instead */\n title?: ReactNode,\n /** The title text of the Modal. If you want to set a custom title use `title` instead */\n titleText?: string,\n /** The description of the Modal. If you want to only set the text use `descriptionText` instead */\n description?: ReactNode,\n /** The description text of the Modal. If you want to set a custom description use `description` instead */\n descriptionText?: string,\n}\n\n/**\n * A header that should be in an Overlay\n */\nexport const OverlayHeader = ({\n overwriteTranslation,\n onClose,\n title,\n titleText = '',\n description,\n descriptionText = ''\n }: PropsForTranslation<ModalHeaderTranslation, OverlayHeaderProps>) => {\n const translation = useTranslation(defaultModalHeaderTranslation, overwriteTranslation)\n const hasTitleRow = !!title || !!titleText || !!onClose\n const titleRow = (\n <div className=\"row justify-between items-start gap-x-8\">\n {title ?? (\n <h2\n className={clsx('textstyle-title-lg', {\n 'mb-1': description || descriptionText,\n })}\n >\n {titleText}\n </h2>\n )}\n {!!onClose && (\n <Tooltip tooltip={translation.close}>\n <IconButton color=\"neutral\" size=\"small\" onClick={onClose}>\n <X className=\"w-full h-full\"/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n )\n\n return (\n <div className=\"col\">\n {hasTitleRow && (titleRow)}\n {description ?? (descriptionText && (<span className=\"textstyle-description\">{descriptionText}</span>))}\n </div>\n )\n}\n\nexport type ModalProps = {\n isOpen: boolean,\n onClose: () => void,\n className?: string,\n backgroundClassName?: string,\n headerProps?: Omit<OverlayHeaderProps, 'onClose'>,\n}\n\n/**\n * A Generic Modal Window\n */\nexport const Modal = ({\n children,\n isOpen,\n onClose,\n className,\n backgroundClassName,\n headerProps,\n }: PropsWithChildren<ModalProps>) => {\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!isOpen) return\n\n const modal = ref.current\n\n if (!modal) {\n console.error('modal open, but no ref found')\n return\n }\n\n overlayStack.push(modal)\n\n const focusable = modal?.querySelectorAll(\n 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex=\"-1\"])'\n )\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n\n const handleKeyDown = (e: KeyboardEvent) => {\n const isTopmost = overlayStack[overlayStack.length - 1] === modal\n if (!isTopmost) return\n\n if (e.key === 'Escape') {\n e.stopPropagation()\n onClose()\n } else if (e.key === 'Tab') {\n if (focusable.length === 0) return\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n (last as HTMLElement).focus()\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n (first as HTMLElement).focus()\n }\n }\n }\n\n modal.focus()\n document.addEventListener('keydown', handleKeyDown)\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n overlayStack = overlayStack.filter(m => m !== modal)\n }\n }, [isOpen, onClose])\n\n return (\n <Overlay\n isOpen={isOpen}\n onBackgroundClick={onClose}\n backgroundClassName={backgroundClassName}\n >\n <div\n ref={ref}\n tabIndex={-1}\n className={clsx(\n 'fixed left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 col p-4 bg-overlay-background text-overlay-text rounded-xl shadow-xl',\n className\n )}\n role=\"dialog\"\n aria-modal={true}\n >\n <OverlayHeader {...headerProps} onClose={onClose}/>\n {children}\n </div>\n </Overlay>\n )\n}\n\n// --- Dialog ---\n\nexport type DialogProps = Omit<OverlayProps, 'onBackgroundClick'> & {\n headerProps?: Omit<OverlayHeaderProps, 'onClose'>,\n className?: string,\n}\n\n/**\n * A Generic Dialog Window\n */\nexport const Dialog = ({\n children,\n isOpen,\n className,\n backgroundClassName,\n headerProps,\n }: PropsWithChildren<DialogProps>) => {\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!isOpen) return\n\n const dialog = ref.current\n\n if (!dialog) {\n console.error('dialog open, but no ref found')\n return\n }\n\n overlayStack.push(dialog)\n\n const focusable = dialog?.querySelectorAll(\n 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex=\"-1\"])'\n )\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n\n const handleKeyDown = (e: KeyboardEvent) => {\n const isTopmost = overlayStack[overlayStack.length - 1] === dialog\n if (!isTopmost) return\n\n if (e.key === 'Escape') {\n e.stopPropagation()\n } else if (e.key === 'Tab') {\n if (focusable.length === 0) return\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n (last as HTMLElement).focus()\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n (first as HTMLElement).focus()\n }\n }\n }\n\n dialog.focus()\n document.addEventListener('keydown', handleKeyDown)\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n overlayStack = overlayStack.filter(m => m !== dialog)\n }\n }, [isOpen])\n\n return (\n <Overlay\n isOpen={isOpen}\n backgroundClassName={backgroundClassName}\n >\n <div\n ref={ref}\n tabIndex={-1}\n className={clsx(\n 'fixed left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 col p-4 bg-overlay-background text-overlay-text rounded-xl shadow-xl',\n className\n )}\n role=\"dialog\"\n aria-modal={true}\n >\n {!!headerProps && (<OverlayHeader {...headerProps}/>)}\n {children}\n </div>\n </Overlay>\n )\n}","import type { Dispatch, SetStateAction } from 'react'\nimport { useEffect, useState } from 'react'\n\ntype UseHoverStateProps = {\n /**\n * The delay after which the menu is closed in milliseconds\n *\n * default: 200ms\n */\n closingDelay: number,\n /**\n * Whether the hover state management should be disabled\n *\n * default: false\n */\n isDisabled: boolean,\n}\n\ntype UseHoverStateReturnType = {\n /**\n * Whether the element is hovered\n */\n isHovered: boolean,\n /**\n * Function to change the current hover status\n */\n setIsHovered: Dispatch<SetStateAction<boolean>>,\n /**\n * Handlers to pass on to the component that should be hovered\n */\n handlers: {\n onMouseEnter: () => void,\n onMouseLeave: () => void,\n },\n}\n\nconst defaultUseHoverStateProps: UseHoverStateProps = {\n closingDelay: 200,\n isDisabled: false,\n}\n\n/**\n * @param props See UseHoverStateProps\n *\n * A react hook for managing the hover state of a component. The handlers provided should be\n * forwarded to the component which should be hovered over\n */\nexport const useHoverState = (props: Partial<UseHoverStateProps> | undefined = undefined): UseHoverStateReturnType => {\n const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props }\n\n const [isHovered, setIsHovered] = useState(false)\n const [timer, setTimer] = useState<NodeJS.Timeout>()\n\n const onMouseEnter = () => {\n if (isDisabled) {\n return\n }\n clearTimeout(timer)\n setIsHovered(true)\n }\n\n const onMouseLeave = () => {\n if (isDisabled) {\n return\n }\n setTimer(setTimeout(() => {\n setIsHovered(false)\n }, closingDelay))\n }\n\n useEffect(() => {\n if (timer) {\n return () => {\n clearTimeout(timer)\n }\n }\n })\n\n useEffect(() => {\n if (timer) {\n clearTimeout(timer)\n }\n }, [isDisabled]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n isHovered, setIsHovered, handlers: { onMouseEnter, onMouseLeave }\n }\n}\n","import type { CSSProperties, PropsWithChildren, ReactNode } from 'react'\nimport { useHoverState } from '@/hooks/useHoverState'\nimport { clsx } from 'clsx'\n\ntype Position = 'top' | 'bottom' | 'left' | 'right'\n\nexport type TooltipProps = PropsWithChildren<{\n tooltip: string | ReactNode,\n /**\n * Number of milliseconds until the tooltip appears\n *\n * defaults to 1000ms\n */\n animationDelay?: number,\n /**\n * Class names of additional styling properties for the tooltip\n */\n tooltipClassName?: string,\n /**\n * Class names of additional styling properties for the container from which the tooltip will be created\n */\n containerClassName?: string,\n position?: Position,\n zIndex?: number,\n}>\n\n/**\n * A Component for showing a tooltip when hovering over Content\n * @param tooltip The tooltip to show can be a text or any ReactNode\n * @param children The Content for which the tooltip should be created\n * @param animationDelay The delay before the tooltip appears\n * @param tooltipClassName Additional ClassNames for the Container of the tooltip\n * @param containerClassName Additional ClassNames for the Container holding the content\n * @param position The direction of the tooltip relative to the Container\n * @param zIndex The z Index of the tooltip (you may require this when stacking modal)\n * @constructor\n */\nexport const Tooltip = ({\n tooltip,\n children,\n animationDelay = 650,\n tooltipClassName = '',\n containerClassName = '',\n position = 'bottom',\n zIndex = 10,\n }: TooltipProps) => {\n const { isHovered, handlers } = useHoverState()\n\n const positionClasses = {\n top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,\n bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,\n left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,\n right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`\n }\n\n const triangleSize = 6\n const triangleClasses = {\n top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,\n bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,\n left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,\n right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`\n }\n\n const triangleStyle: Record<Position, CSSProperties> = {\n top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },\n bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },\n left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },\n right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }\n }\n\n return (\n <div\n className={clsx('relative inline-block', containerClassName)}\n {...handlers}\n >\n {children}\n {isHovered && (\n <div\n className={clsx(\n `opacity-0 absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap\n animate-tooltip-fade-in shadow-lg bg-tooltip-background`,\n positionClasses[position], tooltipClassName\n )}\n style={{ zIndex, animationDelay: animationDelay + 'ms' }}\n >\n {tooltip}\n <div\n className={clsx(`absolute w-0 h-0`, triangleClasses[position])}\n style={{ ...triangleStyle[position], zIndex }}\n />\n </div>\n )}\n </div>\n )\n}\n","import Image from 'next/image'\nimport clsx from 'clsx'\n\nexport const avtarSizeList = ['tiny', 'small', 'medium', 'large'] as const\nexport type AvatarSize = typeof avtarSizeList[number]\nexport const avatarSizeMapping: Record<AvatarSize, number> = {\n tiny: 24,\n small: 32,\n medium: 48,\n large: 64\n}\n\nexport type AvatarProps = {\n avatarUrl: string,\n alt: string,\n size?: AvatarSize,\n className?: string,\n}\n\n/**\n * A component for showing a profile picture\n */\nexport const Avatar = ({ avatarUrl, alt, size = 'medium', className = '' }: AvatarProps) => {\n // TODO remove later\n avatarUrl = 'https://cdn.helpwave.de/boringavatar.svg'\n\n const avtarSize = {\n tiny: 24,\n small: 32,\n medium: 48,\n large: 64,\n }[size]\n\n const style = {\n width: avtarSize + 'px',\n height: avtarSize + 'px',\n maxWidth: avtarSize + 'px',\n maxHeight: avtarSize + 'px',\n minWidth: avtarSize + 'px',\n minHeight: avtarSize + 'px',\n }\n\n return (\n // TODO transparent or white background later\n <div className={clsx(`rounded-full bg-primary`, className)} style={style}>\n <Image\n className=\"rounded-full border border-gray-200\"\n style={style}\n src={avatarUrl}\n alt={alt}\n width={avtarSize}\n height={avtarSize}\n />\n </div>\n )\n}\n\nexport type AvatarGroupProps = {\n avatars: Omit<AvatarProps, 'size'>[],\n maxShownProfiles?: number,\n size?: AvatarSize,\n}\n\n/**\n * A component for showing a group of Avatar's\n */\nexport const AvatarGroup = ({\n avatars,\n maxShownProfiles = 5,\n size = 'tiny'\n }: AvatarGroupProps) => {\n const displayedProfiles = avatars.length < maxShownProfiles ? avatars : avatars.slice(0, maxShownProfiles)\n const diameter = avatarSizeMapping[size]\n const stackingOverlap = 0.5 // given as a percentage\n const notDisplayedProfiles = avatars.length - maxShownProfiles\n const avatarGroupWidth = diameter * (stackingOverlap * (displayedProfiles.length - 1) + 1)\n return (\n <div className=\"row relative\" style={{ height: diameter + 'px' }}>\n <div style={{ width: avatarGroupWidth + 'px' }}>\n {displayedProfiles.map((avatar, index) => (\n <div\n key={index}\n className=\"absolute\"\n style={{ left: (index * diameter * stackingOverlap) + 'px', zIndex: maxShownProfiles - index }}\n >\n <Avatar avatarUrl={avatar.avatarUrl} alt={avatar.alt} size={size}/>\n </div>\n ))}\n </div>\n {\n notDisplayedProfiles > 0 && (\n <div\n className=\"truncate row items-center\"\n style={{ fontSize: (diameter / 2) + 'px', marginLeft: (1 + diameter / 16) + 'px' }}\n >\n <span>+ {notDisplayedProfiles}</span>\n </div>\n )\n }\n </div>\n )\n}\n\nexport default { Avatar, AvatarGroup }\n","import type { HTMLAttributes } from 'react'\nimport clsx from 'clsx'\n\nexport type CircleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'color'> & {\n radius: number,\n className?: string,\n}\n\nexport const Circle = ({\n radius = 20,\n className = 'bg-primary',\n style,\n ...restProps\n }: CircleProps) => {\n const size = radius * 2\n return (\n <div\n className={clsx(`rounded-full`, className)}\n style={{\n width: `${size}px`,\n height: `${size}px`,\n ...style,\n }}\n {...restProps}\n />\n )\n}\n","import type { CSSProperties } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { noop } from '../../util/noop'\nimport { Circle } from './Circle'\nimport clsx from 'clsx'\n\nexport type RingProps = {\n innerSize: number, // the size of the entire circle including the circleWidth\n width: number,\n className?: string,\n};\n\nexport const Ring = ({\n innerSize = 20,\n width = 7,\n className = 'outline-primary',\n }: RingProps) => {\n return (\n <div\n className={clsx(`bg-transparent rounded-full outline`, className)}\n style={{\n width: `${innerSize}px`,\n height: `${innerSize}px`,\n outlineWidth: `${width}px`,\n }}\n />\n )\n}\n\nexport type AnimatedRingProps = RingProps & {\n fillAnimationDuration?: number, // in seconds, 0 means no animation\n repeating?: boolean,\n onAnimationFinished?: () => void,\n style?: CSSProperties,\n};\n\nexport const AnimatedRing = ({\n innerSize,\n width,\n className,\n fillAnimationDuration = 3,\n repeating = false,\n onAnimationFinished = noop,\n style,\n }: AnimatedRingProps) => {\n const [currentWidth, setCurrentWidth] = useState(0)\n const milliseconds = 1000 * fillAnimationDuration\n\n const animate = useCallback((timestamp: number, startTime: number) => {\n const progress = Math.min((timestamp - startTime) / milliseconds, 1)\n const newWidth = Math.min(width * progress, width)\n\n setCurrentWidth(newWidth)\n\n if (progress < 1) {\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, startTime))\n } else {\n onAnimationFinished()\n if (repeating) {\n setCurrentWidth(0)\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, newTimestamp))\n }\n }\n }, [milliseconds, onAnimationFinished, repeating, width])\n\n useEffect(() => {\n if (currentWidth < width) {\n requestAnimationFrame((timestamp) => animate(timestamp, timestamp))\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div\n className=\"row items-center justify-center\"\n style={{\n width: `${innerSize + 2 * width}px`,\n height: `${innerSize + 2 * width}px`,\n ...style,\n }}\n >\n <Ring\n innerSize={innerSize}\n width={currentWidth}\n className={className}\n />\n </div>\n )\n}\n\nexport type RingWaveProps = Omit<AnimatedRingProps, 'innerSize'> & {\n startInnerSize: number,\n endInnerSize: number,\n style?: CSSProperties,\n};\n\nexport const RingWave = ({\n startInnerSize = 20,\n endInnerSize = 30,\n width,\n className,\n fillAnimationDuration = 3,\n repeating = false,\n onAnimationFinished = noop,\n style\n }: RingWaveProps) => {\n const [currentInnerSize, setCurrentInnerSize] = useState(startInnerSize)\n const distance = endInnerSize - startInnerSize\n const milliseconds = 1000 * fillAnimationDuration\n\n const animate = useCallback((timestamp: number, startTime: number) => {\n const progress = Math.min((timestamp - startTime) / milliseconds, 1)\n const newInnerSize = Math.min(\n startInnerSize + distance * progress,\n endInnerSize\n )\n\n setCurrentInnerSize(newInnerSize)\n\n if (progress < 1) {\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, startTime))\n } else {\n onAnimationFinished()\n if (repeating) {\n setCurrentInnerSize(startInnerSize)\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, newTimestamp))\n }\n }\n }, [distance, endInnerSize, milliseconds, onAnimationFinished, repeating, startInnerSize])\n\n useEffect(() => {\n if (currentInnerSize < endInnerSize) {\n requestAnimationFrame((timestamp) => animate(timestamp, timestamp))\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div\n className=\"row items-center justify-center\"\n style={{\n width: `${endInnerSize + 2 * width}px`,\n height: `${endInnerSize + 2 * width}px`,\n ...style\n }}\n >\n <Ring\n innerSize={currentInnerSize}\n width={width}\n className={className}\n />\n </div>\n )\n}\n\nexport type RadialRingsProps = {\n circle1ClassName?: string,\n circle2ClassName?: string,\n circle3ClassName?: string,\n waveWidth?: number,\n waveBaseColor?: string,\n sizeCircle1?: number,\n sizeCircle2?: number,\n sizeCircle3?: number,\n};\n\n// TODO use fixed colors here to avoid artifacts\nexport const RadialRings = ({\n circle1ClassName = 'bg-primary/90 outline-primary/90',\n circle2ClassName = 'bg-primary/60 outline-primary/60',\n circle3ClassName = 'bg-primary/40 outline-primary/40',\n waveWidth = 10,\n waveBaseColor = 'outline-white/20',\n sizeCircle1 = 100,\n sizeCircle2 = 200,\n sizeCircle3 = 300\n }: RadialRingsProps) => {\n const [currentRing, setCurrentRing] = useState(0)\n const size = sizeCircle3\n\n return (\n <div\n className=\"relative\"\n style={{\n width: `${sizeCircle3}px`,\n height: `${sizeCircle3}px`,\n }}\n >\n <Circle\n radius={sizeCircle1 / 2}\n className={clsx(circle1ClassName, `absolute z-[10] -translate-y-1/2 -translate-x-1/2`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`\n }}\n />\n {currentRing === 0 ? (\n <AnimatedRing\n innerSize={sizeCircle1}\n width={(sizeCircle2 - sizeCircle1) / 2}\n onAnimationFinished={() =>\n currentRing === 0 ? setCurrentRing(1) : null\n }\n repeating={true}\n className={clsx(circle2ClassName,\n { 'opacity-5': currentRing !== 0 })}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 9\n }}\n />\n ) : null}\n {currentRing === 2 ? (\n <RingWave\n startInnerSize={sizeCircle1 - waveWidth}\n endInnerSize={sizeCircle2}\n width={waveWidth}\n repeating={true}\n className={clsx(waveBaseColor, `opacity-5`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 9,\n }}\n />\n ) : null}\n <Circle\n radius={sizeCircle2 / 2}\n className={clsx(circle2ClassName,\n { 'opacity-20': currentRing < 1 },\n `absolute z-[8] -translate-y-1/2 -translate-x-1/2`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`\n }}\n />\n {currentRing === 1 ? (\n <AnimatedRing\n innerSize={sizeCircle2 - 1} // potentially harmful\n width={(sizeCircle3 - sizeCircle2) / 2}\n onAnimationFinished={() =>\n currentRing === 1 ? setCurrentRing(2) : null\n }\n repeating={true}\n className={clsx(circle3ClassName)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 7,\n }}\n />\n ) : null}\n {currentRing === 2 ? (\n <RingWave\n startInnerSize={sizeCircle2}\n endInnerSize={sizeCircle3 - waveWidth}\n width={waveWidth}\n repeating={true}\n className={clsx(waveBaseColor, `opacity-5`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 7,\n }}\n />\n ) : null}\n <Circle\n radius={sizeCircle3 / 2}\n className={clsx(circle3ClassName,\n { 'opacity-20': currentRing < 2 },\n `absolute z-[6] -translate-y-1/2 -translate-x-1/2`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`\n }}\n />\n </div>\n )\n}\n","import type { ImageProps } from 'next/image'\nimport Image from 'next/image'\n\nexport type TagProps = Omit<ImageProps, 'src' | 'alt'>\n\n/**\n * Tag icon from flaticon\n *\n * https://www.flaticon.com/free-icon/price-tag_721550?term=label&page=1&position=8&origin=tag&related_id=721550\n *\n * When using it make attribution\n */\nexport const TagIcon = ({\n className,\n width = 16,\n height = 16,\n ...props\n }: TagProps) => {\n return (\n <Image\n {...props}\n width={width}\n height={height}\n alt=\"\"\n src=\"https://cdn.helpwave.de/icons/label.png\"\n className={className}\n />\n )\n}\n","import Link from 'next/link'\nimport clsx from 'clsx'\n\nexport type Crumb = {\n display: string,\n link: string,\n}\n\ntype BreadCrumbProps = {\n crumbs: Crumb[],\n linkClassName?: string,\n containerClassName?: string,\n}\n\n/**\n * A component for showing a hierarchical link structure with an independent link on each element\n *\n * e.g. Organizations/Ward/<id>\n */\nexport const BreadCrumb = ({ crumbs, linkClassName, containerClassName }: BreadCrumbProps) => {\n const color = 'text-description'\n\n return (\n <div className={clsx('row', containerClassName)}>\n {crumbs.map((crumb, index) => (\n <div key={index}>\n <Link href={crumb.link}\n className={clsx(linkClassName, { [`${color} hover:brightness-60`]: index !== crumbs.length - 1 })}>\n {crumb.display}\n </Link>\n {index !== crumbs.length - 1 && <span className={clsx(`px-1`, color)}>/</span>}\n </div>\n ))}\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport clsx from 'clsx'\nimport { ChevronLeft, ChevronRight } from 'lucide-react'\nimport { createLoopingListWithIndex, range } from '../../util/array'\nimport { clamp } from '../../util/math'\nimport { EaseFunctions } from '../../util/easeFunctions'\nimport type { Direction } from '../../util/loopingArray'\nimport { LoopingArrayCalculator } from '../../util/loopingArray'\n\n\ntype CarouselProps = {\n children: ReactNode[],\n animationTime?: number,\n isLooping?: boolean,\n isAutoLooping?: boolean,\n autoLoopingTimeOut?: number,\n autoLoopAnimationTime?: number,\n hintNext?: boolean,\n arrows?: boolean,\n dots?: boolean,\n /**\n * Percentage that is allowed to be scrolled further\n */\n overScrollThreshold?: number,\n blurColor?: string,\n className?: string,\n heightClassName?: string,\n widthClassName?: string,\n}\n\ntype ItemType = {\n item: ReactNode,\n index: number,\n}\n\ntype CarouselAnimationState = {\n targetPosition: number,\n /**\n * Value of either 1 or -1, 1 is forwards -1 is backwards\n */\n direction: Direction,\n startPosition: number,\n startTime?: number,\n lastUpdateTime?: number,\n isAutoLooping: boolean,\n}\n\ntype DragState = {\n startX: number,\n startTime: number,\n lastX: number,\n startIndex: number,\n}\n\ntype CarouselInformation = {\n currentPosition: number,\n dragState?: DragState,\n animationState?: CarouselAnimationState,\n}\n\nexport const Carousel = ({\n children,\n animationTime = 200,\n isLooping = false,\n isAutoLooping = false,\n autoLoopingTimeOut = 5000,\n autoLoopAnimationTime = 500,\n hintNext = false,\n arrows = false,\n dots = true,\n overScrollThreshold = 0.1,\n blurColor = 'from-white',\n className = '',\n heightClassName = 'h-[24rem]',\n widthClassName = 'w-[70%] desktop:w-1/2',\n }: CarouselProps) => {\n if (isAutoLooping && !isLooping) {\n console.error('When isAutoLooping is true, isLooping should also be true')\n isLooping = true\n }\n\n const [{\n currentPosition,\n dragState,\n animationState,\n }, setCarouselInformation] = useState<CarouselInformation>({\n currentPosition: 0,\n })\n const animationId = useRef<number | undefined>(undefined)\n const timeOut = useRef<NodeJS.Timeout | undefined>(undefined)\n autoLoopingTimeOut = Math.max(0, autoLoopingTimeOut)\n\n const length = children.length\n const paddingItemCount = 3 // The number of items to append left and right of the list to allow for clean transition when looping\n\n const util = useMemo(() => new LoopingArrayCalculator(length, isLooping, overScrollThreshold), [length, isLooping, overScrollThreshold])\n const currentIndex = util.getCorrectedPosition(LoopingArrayCalculator.withoutOffset(currentPosition))\n animationTime = Math.max(200, animationTime) // in ms, must be > 0\n autoLoopAnimationTime = Math.max(200, autoLoopAnimationTime)\n\n const getStyleOffset = (index: number) => {\n const baseOffset = -50 + (index - currentPosition) * 100\n return `${baseOffset}%`\n }\n\n const animation = useCallback((time: number) => {\n let keepAnimating: boolean = true\n\n // Other calculation in the setState call to avoid updating the useCallback to often\n setCarouselInformation((state) => {\n const {\n animationState,\n dragState\n } = state\n if (animationState === undefined || dragState !== undefined) {\n keepAnimating = false\n return state\n }\n if (!animationState.startTime || !animationState.lastUpdateTime) {\n return {\n ...state,\n animationState: {\n ...animationState,\n startTime: time,\n lastUpdateTime: time\n }\n }\n }\n const useAnimationTime = animationState.isAutoLooping ? autoLoopAnimationTime : animationTime\n const progress = clamp((time - animationState.startTime) / useAnimationTime) // progress\n const easedProgress = EaseFunctions.easeInEaseOut(progress)\n const distance = util.getDistanceDirectional(animationState.startPosition, animationState.targetPosition, animationState.direction)\n const newPosition = util.getCorrectedPosition(easedProgress * distance * animationState.direction + animationState.startPosition)\n\n if (animationState.targetPosition === newPosition || progress === 1) {\n keepAnimating = false\n return ({\n currentPosition: LoopingArrayCalculator.withoutOffset(newPosition),\n animationState: undefined\n })\n }\n return ({\n currentPosition: newPosition,\n animationState: {\n ...animationState!,\n lastUpdateTime: time\n }\n })\n })\n if (keepAnimating) {\n animationId.current = requestAnimationFrame(time1 => animation(time1))\n }\n }, [animationTime, autoLoopAnimationTime, util])\n\n useEffect(() => {\n if (animationState) {\n animationId.current = requestAnimationFrame(animation)\n }\n return () => {\n if (animationId.current) {\n cancelAnimationFrame(animationId.current)\n animationId.current = 0\n }\n }\n }, [animationState]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const startAutoLoop = () => setCarouselInformation(prevState => ({\n ...prevState,\n dragState: prevState.dragState,\n animationState: prevState.animationState || prevState.dragState ? prevState.animationState : {\n startPosition: currentPosition,\n targetPosition: (currentPosition + 1) % length,\n direction: 1, // always move forward\n isAutoLooping: true\n }\n }))\n\n useEffect(() => {\n if (!animationId.current && !animationState && !dragState && !timeOut.current) {\n if (autoLoopingTimeOut > 0) {\n timeOut.current = setTimeout(() => {\n startAutoLoop()\n timeOut.current = undefined\n }, autoLoopingTimeOut)\n } else {\n startAutoLoop()\n }\n }\n }, [animationState, dragState, animationId.current, timeOut.current]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const startAnimation = (targetPosition?: number) => {\n if (targetPosition === undefined) {\n targetPosition = LoopingArrayCalculator.withoutOffset(currentPosition)\n }\n if (targetPosition === currentPosition) {\n return // we are exactly where we want to be\n }\n\n // find target index and fastest path to it\n const direction = util.getBestDirection(currentPosition, targetPosition)\n clearTimeout(timeOut.current)\n timeOut.current = undefined\n if (animationId.current) {\n cancelAnimationFrame(animationId.current)\n animationId.current = undefined\n }\n\n setCarouselInformation(prevState => ({\n ...prevState,\n dragState: undefined,\n animationState: {\n targetPosition: targetPosition!,\n direction,\n startPosition: currentPosition,\n isAutoLooping: false\n },\n timeOut: undefined\n }))\n }\n\n const canGoLeft = () => {\n return isLooping || currentPosition !== 0\n }\n\n const canGoRight = () => {\n return isLooping || currentPosition !== length - 1\n }\n\n const left = () => {\n if (canGoLeft()) {\n startAnimation(currentPosition === 0 ? length - 1 : LoopingArrayCalculator.withoutOffset(currentPosition - 1))\n }\n }\n\n const right = () => {\n if (canGoRight()) {\n startAnimation(LoopingArrayCalculator.withoutOffset((currentPosition + 1) % length))\n }\n }\n\n let items: ItemType[] = children.map((item, index) => ({\n index,\n item\n }))\n\n if (isLooping) {\n const before = createLoopingListWithIndex(children, length - 1, paddingItemCount, false).reverse().map(([index, item]) => ({\n index,\n item\n }))\n const after = createLoopingListWithIndex(children, 0, paddingItemCount).map(([index, item]) => ({\n index,\n item\n }))\n items = [\n ...before,\n ...items,\n ...after\n ]\n }\n\n const onDragStart = (x: number) => setCarouselInformation(prevState => ({\n ...prevState,\n dragState: {\n lastX: x,\n startX: x,\n startTime: Date.now(),\n startIndex: currentPosition,\n },\n animationState: undefined // cancel animation\n }))\n\n const onDrag = (x: number, width: number) => {\n // For some weird reason the clientX is 0 on the last dragUpdate before drag end causing issues\n if (!dragState || x === 0) {\n return\n }\n const offsetUpdate = (dragState.lastX - x) / width\n const newPosition = util.getCorrectedPosition(currentPosition + offsetUpdate)\n\n setCarouselInformation(prevState => ({\n ...prevState,\n currentPosition: newPosition,\n dragState: {\n ...dragState,\n lastX: x\n },\n }))\n }\n\n const onDragEnd = (x: number, width: number) => {\n if (!dragState) {\n return\n }\n const distance = dragState.startX - x\n const relativeDistance = distance / width\n const duration = (Date.now() - dragState.startTime) // in milliseconds\n const velocity = distance / (Date.now() - dragState.startTime)\n\n const isSlide = Math.abs(velocity) > 2 || (duration < 200 && (Math.abs(relativeDistance) > 0.2 || Math.abs(distance) > 50))\n if (isSlide) {\n if (distance > 0 && canGoRight()) {\n right()\n return\n } else if (distance < 0 && canGoLeft()) {\n left()\n return\n }\n }\n startAnimation()\n }\n\n const dragHandlers = {\n draggable: true,\n onDragStart: (event: React.DragEvent<HTMLDivElement>) => {\n onDragStart(event.clientX)\n event.dataTransfer.setDragImage(document.createElement('div'), 0, 0)\n },\n onDrag: (event: React.DragEvent<HTMLDivElement>) => onDrag(event.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onDragEnd: (event: React.DragEvent<HTMLDivElement>) => onDragEnd(event.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onTouchStart: (event: React.TouchEvent<HTMLDivElement>) => onDragStart(event.touches[0]!.clientX),\n onTouchMove: (event: React.TouchEvent<HTMLDivElement>) => onDrag(event.touches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onTouchEnd: (event: React.TouchEvent<HTMLDivElement>) => onDragEnd(event.changedTouches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onTouchCancel: (event: React.TouchEvent<HTMLDivElement>) => onDragEnd(event.changedTouches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n }\n\n return (\n <div className=\"col items-center w-full gap-y-2\">\n <div className={clsx(`relative w-full overflow-hidden`, heightClassName, className)}>\n {arrows && (\n <>\n <div\n className={clsx('absolute z-10 left-0 top-1/2 -translate-y-1/2 bg-gray-200 hover:bg-gray-300 rounded-lg cursor-pointer border-black border-2', { hidden: !canGoLeft() })}\n onClick={() => left()}\n >\n <ChevronLeft size={32}/>\n </div>\n <div\n className={clsx('absolute z-10 right-0 top-1/2 -translate-y-1/2 bg-gray-200 hover:bg-gray-300 rounded-lg cursor-pointer border-black border-2', { hidden: !canGoRight() })}\n onClick={() => right()}\n >\n <ChevronRight size={32}/>\n </div>\n </>\n )}\n {hintNext ? (\n <div className={clsx(`relative row h-full`, heightClassName)}>\n <div className=\"relative row h-full w-full px-2 overflow-hidden\">\n {items.map(({\n item,\n index\n }, listIndex) => (\n <div\n key={listIndex}\n className={clsx(`absolute left-[50%] h-full overflow-hidden`, widthClassName, { '!cursor-grabbing': !!dragState })}\n style={{ translate: getStyleOffset(listIndex - (isLooping ? paddingItemCount : 0)) }}\n {...dragHandlers}\n onClick={() => startAnimation(index)}\n >\n {item}\n </div>\n ))}\n </div>\n <div\n className={clsx(`hidden pointer-events-none desktop:block absolute left-0 h-full w-[20%] bg-gradient-to-r to-transparent`, blurColor)}\n />\n <div\n className={clsx(`hidden pointer-events-none desktop:block absolute right-0 h-full w-[20%] bg-gradient-to-l to-transparent`, blurColor)}\n />\n </div>\n ) : (\n <div className={clsx('px-16 h-full', { '!cursor-grabbing': !!dragState })} {...dragHandlers}>\n {children[currentIndex]}\n </div>\n )}\n </div>\n {dots && (\n <div\n className=\"row items-center justify-center w-full my-2\">\n {range(0, length - 1).map(index => (\n <button\n key={index}\n className={clsx('w-[2rem] min-w-[2rem] h-[0.75rem] min-h-[0.75rem] hover:bg-primary hover:brightness-90 first:rounded-l-md last:rounded-r-md', {\n 'bg-gray-200': currentIndex !== index,\n 'bg-primary': currentIndex === index\n })}\n onClick={() => startAnimation(index)}\n />\n ))}\n </div>\n )}\n </div>\n )\n}\n","import type { HTMLProps, PropsWithChildren, ReactNode } from 'react'\nimport clsx from 'clsx'\n\nexport type ChipColor = 'default' | 'dark' | 'red' | 'yellow' | 'green' | 'blue' | 'pink'\ntype ChipVariant = 'normal' | 'fullyRounded'\n\nexport type ChipProps = HTMLProps<HTMLDivElement> & PropsWithChildren<{\n color?: ChipColor,\n variant?: ChipVariant,\n trailingIcon?: ReactNode,\n}>\n\n/**\n * A component for displaying a single chip\n */\nexport const Chip = ({\n children,\n trailingIcon,\n color = 'default',\n variant = 'normal',\n className = '',\n ...restProps\n }: ChipProps) => {\n const colorMapping: string = {\n default: 'text-tag-default-text bg-tag-default-background',\n dark: 'text-tag-dark-text bg-tag-dark-background',\n red: 'text-tag-red-text bg-tag-red-background',\n yellow: 'text-tag-yellow-text bg-tag-yellow-background',\n green: 'text-tag-green-text bg-tag-green-background',\n blue: 'text-tag-blue-text bg-tag-blue-background',\n pink: 'text-tag-pink-text bg-tag-pink-background',\n }[color]\n\n const colorMappingIcon: string = {\n default: 'text-tag-default-icon',\n dark: 'text-tag-dark-icon',\n red: 'text-tag-red-icon',\n yellow: 'text-tag-yellow-icon',\n green: 'text-tag-green-icon',\n blue: 'text-tag-blue-icon',\n pink: 'text-tag-pink-icon',\n }[color]\n\n return (\n <div\n {...restProps}\n className={clsx(\n `row w-fit px-2 py-1`,\n colorMapping,\n {\n 'rounded-md': variant === 'normal',\n 'rounded-full': variant === 'fullyRounded',\n },\n className\n )}\n >\n {children}\n {trailingIcon && (<span className={colorMappingIcon}>{trailingIcon}</span>)}\n </div>\n )\n}\n\nexport type ChipListProps = {\n list: ChipProps[],\n className?: string,\n}\n\n/**\n * A component for displaying a list of chips\n */\nexport const ChipList = ({\n list,\n className = ''\n }: ChipListProps) => {\n return (\n <div className={clsx('flex flex-wrap gap-x-4 gap-y-2', className)}>\n {list.map((value, index) => (\n <Chip\n key={index}\n {...value}\n color={value.color ?? 'dark'}\n variant={value.variant ?? 'normal'}\n >\n {value.children}\n </Chip>\n ))}\n </div>\n )\n}\n","import type { HTMLAttributes, ReactNode } from 'react'\nimport clsx from 'clsx'\n\nexport type DividerInserterProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n children: ReactNode[],\n divider: (index: number) => ReactNode,\n}\n\n/**\n * A Component for inserting a divider in the middle of each child element\n *\n * undefined elements are removed\n */\nexport const DividerInserter = ({\n children,\n divider,\n className,\n ...restProps\n }: DividerInserterProps) => {\n const nodes: ReactNode[] = []\n\n for (let index = 0; index < children.length; index++) {\n const element = children[index]\n if (element !== undefined) {\n nodes.push(element)\n if (index < children.length - 1) {\n nodes.push(divider(index))\n }\n }\n }\n\n return (\n <div className={clsx(className)} {...restProps}>\n {nodes}\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport clsx from 'clsx'\nimport { ChevronDown, ChevronUp } from 'lucide-react'\nimport type { ExpandableProps } from './Expandable'\nimport { Expandable } from './Expandable'\nimport { MarkdownInterpreter } from './MarkdownInterpreter'\n\ntype ContentType = {\n type: 'markdown',\n value: string,\n} | {\n type: 'custom',\n value: ReactNode,\n}\n\nexport type FAQItem = Pick<ExpandableProps, 'initialExpansion' | 'className'> & {\n id: string,\n title: string,\n content: ContentType,\n}\n\nexport type FAQSectionProps = {\n entries: FAQItem[],\n expandableClassName?: string,\n}\n\n/**\n * Description\n */\nexport const FAQSection = ({\n entries,\n expandableClassName\n }: FAQSectionProps) => {\n const chevronSize = 28\n return (\n <div className=\"col gap-y-4\">\n {entries.map(({ id, title, content, ...restProps }) => (\n <Expandable\n key={id}\n {...restProps}\n label={(<h3 id={id} className=\"textstyle-title-md\">{title}</h3>)}\n clickOnlyOnHeader={false}\n icon={(expanded) => expanded ?\n (<ChevronUp size={chevronSize} className=\"text-primary\" style={{ minWidth: `${chevronSize}px` }}/>) :\n (<ChevronDown size={chevronSize} className=\"text-primary\"/>)\n }\n className={clsx('rounded-xl', expandableClassName)}\n headerClassName=\"px-6 py-4\"\n >\n <div className=\"mt-2 px-6 pb-4\">\n {content.type === 'markdown' ? (<MarkdownInterpreter text={content.value}/>) : content.value}\n </div>\n </Expandable>\n ))}\n </div>\n )\n}\n","type ASTNodeModifierType =\n 'none'\n | 'italic'\n | 'bold'\n | 'underline'\n | 'font-space'\n | 'primary'\n | 'secondary'\n | 'warn'\n | 'positive'\n | 'negative'\n\nconst astNodeInserterType = ['helpwave', 'newline'] as const\ntype ASTNodeInserterType = typeof astNodeInserterType[number]\ntype ASTNodeDefaultType = 'text'\n\ntype ASTNode = {\n type: ASTNodeModifierType,\n children: ASTNode[],\n} | {\n type: ASTNodeInserterType,\n} | {\n type: ASTNodeDefaultType,\n text: string,\n}\n\nexport type ASTNodeInterpreterProps = {\n node: ASTNode,\n isRoot?: boolean,\n className?: string,\n}\nexport const ASTNodeInterpreter = ({\n node,\n isRoot = false,\n className = '',\n }: ASTNodeInterpreterProps) => {\n switch (node.type) {\n case 'newline':\n return <br/>\n case 'text':\n return isRoot ? <span className={className}>{node.text}</span> : node.text\n case 'helpwave':\n return (<span className=\"font-bold font-space no-underline\">helpwave</span>)\n case 'none':\n return isRoot ? (\n <span className={className}>{node.children.map((value, index) => (\n <ASTNodeInterpreter key={index}\n node={value}/>\n ))}</span>\n ) :\n <>{node.children.map((value, index) => <ASTNodeInterpreter key={index} node={value}/>)}</>\n case 'bold':\n return <b>{node.children.map((value, index) => <ASTNodeInterpreter key={index} node={value}/>)}</b>\n case 'italic':\n return <i>{node.children.map((value, index) => <ASTNodeInterpreter key={index} node={value}/>)}</i>\n case 'underline':\n return (<u>{node.children.map((value, index) => (<ASTNodeInterpreter key={index} node={value}/>))}</u>)\n case 'font-space':\n return (\n <span className=\"font-space\">{node.children.map((value, index) => (\n <ASTNodeInterpreter key={index}\n node={value}/>\n ))}</span>\n )\n case 'primary':\n return (\n <span className=\"text-primary\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'secondary':\n return (\n <span className=\"text-secondary\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'warn':\n return (\n <span className=\"text-warning\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'positive':\n return (\n <span className=\"text-positive\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'negative':\n return (\n <span className=\"text-negative\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n default:\n return null\n }\n}\n\nconst modifierIdentifierMapping = [\n { id: 'i', name: 'italic' },\n { id: 'b', name: 'bold' },\n { id: 'u', name: 'underline' },\n { id: 'space', name: 'font-space' },\n { id: 'primary', name: 'primary' },\n { id: 'secondary', name: 'secondary' },\n { id: 'warn', name: 'warn' },\n { id: 'positive', name: 'positive' },\n { id: 'negative', name: 'negative' },\n] as const\n\nconst inserterIdentifierMapping = [\n { id: 'helpwave', name: 'helpwave' },\n { id: 'newline', name: 'newline' }\n] as const\nconst parseMarkdown = (\n text: string,\n commandStart: string = '\\\\',\n open: string = '{',\n close: string = '}'\n): ASTNode => {\n let start = text.indexOf(commandStart)\n const children: ASTNode[] = []\n\n // parse the text step by step\n while (text !== '') {\n if (start === -1) {\n children.push({\n type: 'text',\n text\n })\n break\n }\n children.push(parseMarkdown(text.substring(0, start)))\n text = text.substring(start)\n if (text.length <= 1) {\n children.push({\n type: 'text',\n text\n })\n text = ''\n continue\n }\n const simpleReplace = [commandStart, open, close]\n if (simpleReplace.some(value => text[1] === value)) {\n children.push({\n type: 'text',\n text: simpleReplace.find(value => text[1] === value)!\n })\n text = text.substring(2)\n start = text.indexOf(commandStart)\n continue\n }\n const inserter = inserterIdentifierMapping.find(value => text.substring(1).startsWith(value.id))\n if (inserter) {\n children.push({\n type: inserter.name,\n })\n text = text.substring(inserter.id.length + 1)\n start = text.indexOf(commandStart)\n continue\n }\n const modifier = modifierIdentifierMapping.find(value => text.substring(1).startsWith(value.id))\n if (modifier) {\n // check brackets\n if (text[modifier.id.length + 1] !== open) {\n children.push({\n type: 'text',\n text: text.substring(0, modifier.id.length + 1)\n })\n text = text.substring(modifier.id.length + 2)\n start = text.indexOf(commandStart)\n continue\n }\n let closing = -1\n let index = modifier.id.length + 2\n let counter = 1\n let escaping = false\n while (index < text.length) {\n if (text[index] === open && !escaping) {\n counter++\n }\n if (text[index] === close && !escaping) {\n counter--\n if (counter === 0) {\n closing = index\n break\n }\n }\n escaping = text[index] === commandStart\n index++\n }\n\n if (closing !== -1) {\n children.push({\n type: modifier.name,\n children: [parseMarkdown(text.substring(modifier.id.length + 2, closing))]\n })\n text = text.substring(closing + 1)\n start = text.indexOf(commandStart)\n continue\n }\n }\n // nothing could be applied to command start\n children.push({\n type: 'text',\n text: text[0]!\n })\n text = text.substring(1)\n start = text.indexOf(commandStart)\n }\n\n return {\n type: 'none',\n children\n }\n}\n\nconst optimizeTree = (node: ASTNode) => {\n if (node.type === 'text') {\n return !node.text ? undefined : node\n }\n if (astNodeInserterType.some(value => value === node.type)) {\n return node\n }\n\n const currentNode = node as\n { type: ASTNodeModifierType, children: ASTNode[] }\n\n if (currentNode.children.length === 0) {\n return undefined\n }\n\n let children: ASTNode[] = []\n for (let i = 0; i < currentNode.children.length; i++) {\n const child = optimizeTree(currentNode.children[i]!)\n if (!child) {\n continue\n }\n if (child.type === 'none') {\n children.push(...child.children)\n } else {\n children.push(child)\n }\n }\n\n currentNode.children = children\n children = []\n\n for (let i = 0; i < currentNode.children.length; i++) {\n const child = currentNode.children[i]!\n if (child) {\n if (child.type === 'text' && children[children.length - 1]?.type === 'text') {\n (children[children.length - 1]! as { type: ASTNodeDefaultType, text: string }).text += child.text\n } else {\n children.push(child)\n }\n }\n }\n currentNode.children = children\n return currentNode\n}\n\nexport type MarkdownInterpreterProps = {\n text: string,\n className?: string,\n}\n\nexport const MarkdownInterpreter = ({ text, className }: MarkdownInterpreterProps) => {\n const tree = parseMarkdown(text)\n const optimizedTree = optimizeTree(tree)!\n return <ASTNodeInterpreter node={optimizedTree} isRoot={true} className={className}/>\n}\n","import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { Language } from '../../localization/util'\n\ntype PaginationTranslation = {\n of: string,\n}\nconst defaultPaginationTranslations: Record<Language, PaginationTranslation> = {\n en: {\n of: 'of'\n },\n de: {\n of: 'von'\n }\n}\n\nexport type PaginationProps = {\n page: number, // starts with 0\n numberOfPages: number,\n onPageChanged: (page: number) => void,\n}\n\n/**\n * A Component showing the pagination allowing first, before, next and last page navigation\n */\nexport const Pagination = ({\n overwriteTranslation,\n page,\n numberOfPages,\n onPageChanged\n }: PropsForTranslation<PaginationTranslation, PaginationProps>) => {\n const translation = useTranslation(defaultPaginationTranslations, overwriteTranslation)\n\n const changePage = (page: number) => {\n onPageChanged(page)\n }\n\n const noPages = numberOfPages === 0\n const onFirstPage = page === 0 && !noPages\n const onLastPage = page === numberOfPages - 1\n\n return (\n <div className={clsx('row', { 'opacity-30': noPages })}>\n <button onClick={() => changePage(0)} disabled={onFirstPage}>\n <ChevronFirst className={clsx({ 'opacity-30': onFirstPage })}/>\n </button>\n <button onClick={() => changePage(page - 1)} disabled={onFirstPage}>\n <ChevronLeft className={clsx({ 'opacity-30': onFirstPage })}/>\n </button>\n <div className=\"min-w-[80px] justify-center mx-2\">\n <span className=\"select-none text-right flex-1\">{noPages ? 0 : page + 1}</span>\n <span className=\"select-none mx-2\">{translation.of}</span>\n <span className=\"select-none text-left flex-1\">{numberOfPages}</span>\n </div>\n <button onClick={() => changePage(page + 1)} disabled={onLastPage || noPages}>\n <ChevronRight className={clsx({ 'opacity-30': onLastPage })}/>\n </button>\n <button onClick={() => changePage(numberOfPages - 1)} disabled={onLastPage || noPages}>\n <ChevronLast className={clsx({ 'opacity-30': onLastPage })}/>\n </button>\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport { useEffect, useMemo, useState } from 'react'\nimport { Search } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { MultiSearchWithMapping } from '@/util/simpleSearch'\nimport { Input } from '../user-action/Input'\n\ntype SearchableListTranslation = {\n search: string,\n nothingFound: string,\n}\n\nconst defaultSearchableListTranslation: Record<Language, SearchableListTranslation> = {\n en: {\n search: 'Search',\n nothingFound: 'Nothing found'\n },\n de: {\n search: 'Suche',\n nothingFound: 'Nichts gefunden'\n }\n}\n\nexport type SearchableListProps<T> = {\n list: T[],\n initialSearch?: string,\n searchMapping: (value: T) => string[],\n itemMapper: (value: T) => ReactNode,\n className?: string,\n}\n\n/**\n * A component for searching a list\n */\nexport const SearchableList = <T, >({\n overwriteTranslation,\n list,\n initialSearch = '',\n searchMapping,\n itemMapper,\n className\n }: PropsForTranslation<SearchableListTranslation, SearchableListProps<T>>) => {\n const translation = useTranslation(defaultSearchableListTranslation, overwriteTranslation)\n const [search, setSearch] = useState<string>(initialSearch)\n\n useEffect(() => setSearch(initialSearch), [initialSearch])\n\n const filteredEntries = useMemo(() => MultiSearchWithMapping(search, list, searchMapping), [search, list, searchMapping])\n\n return (\n <div className={clsx('col gap-y-2', className)}>\n <div className=\"row justify-between gap-x-2 items-center\">\n <div className=\"flex-1\">\n <Input value={search} onChangeText={setSearch} placeholder={translation.search}/>\n </div>\n <Search size={20}/>\n </div>\n {filteredEntries.length > 0 && (\n <div className=\"col gap-y-1\">\n {filteredEntries.map(itemMapper)}\n </div>\n )}\n {!filteredEntries.length && <div className=\"row justify-center\">{translation.nothingFound}</div>}\n </div>\n )\n}\n","import React, { forwardRef, type InputHTMLAttributes, useEffect, useRef, useState } from 'react'\nimport clsx from 'clsx'\nimport { useSaveDelay } from '@/hooks/useSaveDelay'\nimport { noop } from '@/util/noop'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\nexport type InputProps = {\n /**\n * used for the label's `for` attribute\n */\n label?: Omit<LabelProps, 'id'>,\n /**\n * Callback for when the input's value changes\n * This is pretty much required but made optional for the rare cases where it actually isn't need such as when used with disabled\n * That could be enforced through a union type but that seems a bit overkill\n * @default noop\n */\n onChangeText?: (text: string) => void,\n className?: string,\n onEditCompleted?: (text: string) => void,\n expanded?: boolean,\n containerClassName?: string,\n} & Omit<InputHTMLAttributes<HTMLInputElement>, 'label'>\n\n/**\n * A Component for inputting text or other information\n *\n * Its state is managed must be managed by the parent\n */\nconst Input = ({\n id,\n type = 'text',\n value,\n label,\n onChange = noop,\n onChangeText = noop,\n onEditCompleted,\n className = '',\n expanded = true,\n autoFocus,\n onBlur,\n containerClassName,\n ...restProps\n }: InputProps) => {\n const {\n restartTimer,\n clearUpdateTimer\n } = useSaveDelay(() => undefined, 3000)\n const ref = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n if(autoFocus) {\n ref.current?.focus()\n }\n }, [autoFocus])\n\n return (\n <div className={clsx({ 'w-full': expanded }, containerClassName)}>\n {label && <Label {...label} htmlFor={id} className={clsx('mb-1', label.className)}/>}\n <input\n ref={ref}\n value={value}\n id={id}\n type={type}\n className={className}\n onBlur={event => {\n if (onBlur) {\n onBlur(event)\n }\n if (onEditCompleted) {\n onEditCompleted(event.target.value)\n clearUpdateTimer()\n }\n }}\n onChange={e => {\n const value = e.target.value\n if (onEditCompleted) {\n restartTimer(() => {\n onEditCompleted(value)\n clearUpdateTimer()\n })\n }\n onChange(e)\n onChangeText(value)\n }}\n {...restProps}\n />\n </div>\n )\n}\n\ntype InputUncontrolledProps = Omit<InputProps, 'value'> & {\n /**\n * @default ''\n */\n defaultValue?: string,\n}\n\n/**\n * A Component for inputting text or other information\n *\n * Its state is managed by the component itself\n */\nconst InputUncontrolled = ({\n defaultValue = '',\n onChangeText = noop,\n ...props\n }: InputUncontrolledProps) => {\n const [value, setValue] = useState(defaultValue)\n\n return (\n <Input\n {...props}\n value={value}\n onChangeText={text => {\n setValue(text)\n onChangeText(text)\n }}\n />\n )\n}\n\nexport type FormInputProps = InputHTMLAttributes<HTMLInputElement> & {\n id: string,\n labelText?: string,\n errorText?: string,\n labelClassName?: string,\n errorClassName?: string,\n containerClassName?: string,\n}\n\nconst FormInput = forwardRef<HTMLInputElement, FormInputProps>(function FormInput({\n id,\n labelText,\n errorText,\n className,\n labelClassName,\n errorClassName,\n containerClassName,\n required,\n ...restProps\n }, ref) {\n const input = (\n <input\n ref={ref}\n id={id}\n {...restProps}\n className={clsx(\n {\n 'focus:border-primary focus:ring-primary': !errorText,\n 'focus:border-negative focus:ring-negative text-negative': !!errorText,\n },\n className\n )}\n />\n )\n\n return (\n <div className={clsx('flex flex-col gap-y-1', containerClassName)}>\n {labelText && (\n <label htmlFor={id} className={clsx('textstyle-label-md', labelClassName)}>\n {labelText}\n {required && <span className=\"text-primary font-bold\">*</span>}\n </label>\n )}\n {input}\n {errorText && <label htmlFor={id} className={clsx('text-negative', errorClassName)}>{errorText}</label>}\n </div>\n )\n})\n\nexport {\n InputUncontrolled,\n Input,\n FormInput\n}\n","import { useEffect, useState } from 'react'\n\nexport function useSaveDelay(setNotificationStatus: (isShowing: boolean) => void, delay: number) {\n const [updateTimer, setUpdateTimer] = useState<NodeJS.Timeout | undefined>(undefined)\n const [notificationTimer, setNotificationTimer] = useState<NodeJS.Timeout | undefined>(undefined)\n\n const restartTimer = (onSave: () => void) => {\n clearTimeout(updateTimer)\n setUpdateTimer(setTimeout(() => {\n onSave()\n setNotificationStatus(true)\n // Show Saved Notification for fade animation duration\n clearTimeout(notificationTimer)\n setNotificationTimer(setTimeout(() => {\n setNotificationStatus(false)\n clearTimeout(notificationTimer)\n }, delay))\n clearTimeout(updateTimer)\n }, delay))\n }\n\n const clearUpdateTimer = (hasSaved = true) => {\n clearTimeout(updateTimer)\n if (hasSaved) {\n setNotificationStatus(true)\n clearTimeout(notificationTimer)\n setNotificationTimer(setTimeout(() => {\n setNotificationStatus(false)\n clearTimeout(notificationTimer)\n }, delay))\n } else {\n setNotificationStatus(false)\n }\n }\n\n useEffect(() => {\n return () => {\n clearTimeout(updateTimer)\n clearTimeout(notificationTimer)\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return { restartTimer, clearUpdateTimer }\n}","import type { LabelHTMLAttributes } from 'react'\nimport clsx from 'clsx'\n\nexport type LabelType = 'labelSmall' | 'labelMedium' | 'labelBig'\n\nconst styleMapping: Record<LabelType, string> = {\n labelSmall: 'textstyle-label-sm',\n labelMedium: 'textstyle-label-md',\n labelBig: 'textstyle-label-lg',\n}\n\nexport type LabelProps = {\n /** The text for the label */\n name?: string,\n /** The styling for the label */\n labelType?: LabelType,\n} & LabelHTMLAttributes<HTMLLabelElement>\n\n/**\n * A Label component\n */\nexport const Label = ({\n children,\n name,\n labelType = 'labelSmall',\n className,\n ...props\n }: LabelProps) => {\n return (\n <label {...props} className={clsx(styleMapping[labelType], className)}>\n {children ? children : name}\n </label>\n )\n}\n","import { Check, ChevronLeft, ChevronRight } from 'lucide-react'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport { range } from '../../util/array'\nimport { SolidButton } from '../user-action/Button'\nimport clsx from 'clsx'\n\ntype StepperBarTranslation = {\n back: string,\n next: string,\n confirm: string,\n}\n\nconst defaultStepperBarTranslation: Record<Language, StepperBarTranslation> = {\n en: {\n back: 'Back',\n next: 'Next Step',\n confirm: 'Create'\n },\n de: {\n back: 'Zurück',\n next: 'Nächster Schritt',\n confirm: 'Erstellen'\n }\n}\n\nexport type StepperInformation = {\n step: number,\n lastStep: number,\n seenSteps: Set<number>,\n}\n\nexport type StepperBarProps = {\n stepper: StepperInformation,\n onChange: (step: StepperInformation) => void,\n onFinish: () => void,\n showDots?: boolean,\n className?: string,\n}\n\n/**\n * A Component for stepping\n */\nexport const StepperBar = ({\n overwriteTranslation,\n stepper,\n onChange,\n onFinish,\n showDots = true,\n className = '',\n }: PropsForTranslation<StepperBarTranslation, StepperBarProps>) => {\n const translation = useTranslation(defaultStepperBarTranslation, overwriteTranslation)\n const dots = range(0, stepper.lastStep)\n const { step, seenSteps, lastStep } = stepper\n\n const update = (newStep: number) => {\n seenSteps.add(newStep)\n onChange({ step: newStep, seenSteps, lastStep })\n }\n\n return (\n <div\n className={clsx('sticky row p-2 border-2 justify-between rounded-lg shadow-lg', className)}\n >\n <div className=\"flex-[2] justify-start\">\n <SolidButton\n disabled={step === 0}\n onClick={() => {\n update(step - 1)\n }}\n className=\"row gap-x-1 items-center justify-center\"\n >\n <ChevronLeft size={14}/>\n {translation.back}\n </SolidButton>\n </div>\n <div className=\"row flex-[5] gap-x-2 justify-center items-center\">\n {showDots && dots.map((value, index) => {\n const seen = seenSteps.has(index)\n return (\n <div\n key={index}\n onClick={() => seen && update(index)}\n className={clsx('rounded-full w-4 h-4', {\n 'bg-primary hover:brightness-75': index === step && seen,\n 'bg-primary/40 hover:bg-primary': index !== step && seen,\n 'bg-gray-200 outline-transparent': !seen,\n },\n {\n 'cursor-pointer': seen,\n 'cursor-not-allowed': !seen,\n })}\n />\n )\n })}\n </div>\n {step !== lastStep && (\n <div className=\"flex-[2] justify-end\">\n <SolidButton\n onClick={() => update(step + 1)}\n className=\"row gap-x-1 items-center justify-center\"\n >\n {translation.next}\n <ChevronRight size={14}/>\n </SolidButton>\n </div>\n )}\n {step === lastStep && (\n <div className=\"flex-[2] justify-end\">\n <SolidButton\n // TODO check form validity\n disabled={false}\n onClick={onFinish}\n className=\"row gap-x-1 items-center justify-center\"\n >\n <Check size={14}/>\n {translation.confirm}\n </SolidButton>\n </div>\n )}\n </div>\n )\n}\n","import type { ReactElement } from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { Scrollbars } from 'react-custom-scrollbars-2'\nimport { noop } from '../../util/noop'\nimport { Checkbox } from '../user-action/Checkbox'\nimport { Pagination } from './Pagination'\nimport clsx from 'clsx'\nimport type { TextButtonProps } from '../user-action/Button'\nimport { TextButton } from '../user-action/Button'\nimport { ChevronDown, ChevronsUpDown, ChevronUp } from 'lucide-react'\n\nexport type TableStatePagination = {\n currentPage: number,\n entriesPerPage: number,\n}\nexport const defaultTableStatePagination = {\n currentPage: 0,\n entriesPerPage: 5\n}\n\nexport type TableStateSelection<T> = {\n currentSelection: T[],\n hasSelectedAll: boolean,\n hasSelectedSome: boolean,\n hasSelectedNone: boolean,\n}\n\nexport const defaultTableStateSelection = {\n currentSelection: [],\n hasSelectedAll: false,\n hasSelectedSome: false,\n hasSelectedNone: true\n}\n\nexport type TableState = {\n pagination?: TableStatePagination,\n selection?: {\n /**\n * The mapped ids of the dataType\n */\n currentSelection: string[],\n hasSelectedAll: boolean,\n hasSelectedSome: boolean,\n hasSelectedNone: boolean,\n },\n}\n\ntype IdentifierMapping<T> = (dataObject: T) => string\n\nexport const isDataObjectSelected = <T, >(tableState: TableState, dataObject: T, identifierMapping: IdentifierMapping<T>) => {\n if (!tableState.selection) {\n return false\n }\n\n return !!tableState.selection.currentSelection.find(value => value.localeCompare(identifierMapping(dataObject)) === 0)\n}\n\nexport const pageForItem = <T, >(data: T[], item: T, entriesPerPage: number, identifierMapping: IdentifierMapping<T>) => {\n const index = data.findIndex(value => identifierMapping(value) === identifierMapping(item))\n if (index !== -1) {\n return Math.floor(index / entriesPerPage)\n }\n console.warn(\"item doesn't exist on data\", item, data)\n return 0\n}\n\nexport const updatePagination = (pagination: TableStatePagination, dataLength: number): TableStatePagination => ({\n ...pagination,\n currentPage: Math.min(Math.max(Math.ceil(dataLength / pagination.entriesPerPage) - 1, 0), pagination.currentPage)\n})\n\nexport const addElementToTable = <T, >(tableState: TableState, data: T[], dataObject: T, identifierMapping: IdentifierMapping<T>) => {\n return {\n ...tableState,\n pagination: tableState.pagination ? {\n ...tableState.pagination,\n currentPage: pageForItem(data, dataObject, tableState.pagination.entriesPerPage, identifierMapping)\n } : undefined,\n selection: tableState.selection ? {\n ...tableState.selection,\n hasSelectedAll: false,\n hasSelectedSome: tableState.selection.hasSelectedAll || tableState.selection.hasSelectedSome\n } : undefined\n }\n}\n\n/**\n * data length before delete\n */\nexport const removeFromTableSelection = <T, >(tableState: TableState, deletedObjects: T[], dataLength: number, identifierMapping: IdentifierMapping<T>): TableState => {\n if (!tableState.selection) {\n return tableState\n }\n\n const deletedObjectIds = deletedObjects.map(identifierMapping)\n const elementsBefore = tableState.selection.currentSelection.length\n const currentSelection = tableState.selection.currentSelection.filter((value) => !deletedObjectIds.includes(value))\n dataLength -= elementsBefore - currentSelection.length\n\n return {\n ...tableState,\n selection: {\n currentSelection,\n hasSelectedAll: currentSelection.length === dataLength && dataLength !== 0,\n hasSelectedSome: currentSelection.length > 0 && currentSelection.length !== dataLength,\n hasSelectedNone: currentSelection.length === 0,\n },\n pagination: tableState.pagination ? updatePagination(tableState.pagination, dataLength) : undefined\n }\n}\n\nexport const changeTableSelectionSingle = <T, >(tableState: TableState, dataObject: T, dataLength: number, identifierMapping: IdentifierMapping<T>) => {\n if (!tableState.selection) {\n return tableState\n }\n\n const hasSelectedObject = isDataObjectSelected(tableState, dataObject, identifierMapping)\n let currentSelection = [...tableState.selection.currentSelection, identifierMapping(dataObject)] // case !hasSelectedObject\n if (hasSelectedObject) {\n currentSelection = tableState.selection.currentSelection.filter(value => value.localeCompare(identifierMapping(dataObject)) !== 0)\n }\n\n return {\n ...tableState,\n selection: {\n currentSelection,\n hasSelectedAll: currentSelection.length === dataLength,\n hasSelectedSome: currentSelection.length > 0 && currentSelection.length !== dataLength,\n hasSelectedNone: currentSelection.length === 0,\n }\n }\n}\n\nconst changeTableSelectionAll = <T, >(tableState: TableState, data: T[], identifierMapping: IdentifierMapping<T>) => {\n if (!tableState.selection) {\n return tableState\n }\n\n if (data.length === 0) {\n return {\n ...tableState,\n selection: {\n currentSelection: [],\n hasSelectedAll: false,\n hasSelectedSome: false,\n hasSelectedNone: true\n }\n }\n }\n\n const hasSelectedAll = !(tableState.selection.hasSelectedSome || tableState.selection.hasSelectedAll)\n return {\n ...tableState,\n selection: {\n currentSelection: hasSelectedAll ? data.map(identifierMapping) : [],\n hasSelectedAll,\n hasSelectedSome: false,\n hasSelectedNone: !hasSelectedAll\n }\n }\n}\n\nexport type TableSortingType = 'ascending' | 'descending'\nexport type TableSortingFunctionType<T> = (t1: T, t2: T) => number\n\nexport type TableProps<T> = {\n data: T[],\n /**\n * When using selection or pagination\n */\n stateManagement?: [TableState, (tableState: TableState) => void],\n identifierMapping: IdentifierMapping<T>,\n /**\n * Only the cell itself no boilerplate <tr> or <th> required\n */\n header?: ReactElement[],\n /**\n * Only the cells of the row no boilerplate <tr> or <td> required\n */\n rowMappingToCells: (dataObject: T) => ReactElement[],\n sorting?: [TableSortingFunctionType<T>, TableSortingType],\n /**\n * Always go to the page of this element\n */\n focusElement?: T,\n className?: string,\n}\n\n/* Possible extension for better customization\n * Map each element to the displayed row\n * make sure to wrap it in the <tr> and <td> you require\n rowMappingToHTMLRow?: (dataObject: T) => ReactElement\n */\n\n/**\n * A Basic stateless reusable table\n * The state must be handled and saved with the updateTableState method\n */\nexport const Table = <T, >({\n data,\n stateManagement = [{}, noop],\n identifierMapping,\n header,\n rowMappingToCells,\n sorting,\n focusElement,\n className\n }: TableProps<T>) => {\n const sortedData = [...data]\n if (sorting) {\n const [sortingFunction, sortingType] = sorting\n sortedData.sort((a, b) => sortingFunction(a, b) * (sortingType === 'ascending' ? 1 : -1))\n }\n let currentPage = 0\n let pageCount = 1\n let entriesPerPage = 5\n const [tableState, updateTableState] = stateManagement\n\n let shownElements = sortedData\n\n if (tableState?.pagination) {\n if (tableState.pagination.entriesPerPage < 1) {\n console.error('tableState.pagination.entriesPerPage must be >= 1', tableState.pagination.entriesPerPage)\n }\n entriesPerPage = Math.max(1, tableState.pagination.entriesPerPage)\n pageCount = Math.ceil(sortedData.length / entriesPerPage)\n\n if (tableState.pagination.currentPage < 0 || (tableState.pagination.currentPage >= pageCount && pageCount !== 0)) {\n console.error('tableState.pagination.currentPage < 0 || (tableState.pagination.currentPage >= pageCount && pageCount !== 0) must be fullfilled',\n [`pageCount: ${pageCount}`, `tableState.pagination.currentPage: ${tableState.pagination.currentPage}`])\n } else {\n currentPage = tableState.pagination.currentPage\n }\n\n if (focusElement) {\n currentPage = pageForItem(sortedData, focusElement, entriesPerPage, identifierMapping)\n }\n\n shownElements = sortedData.slice(currentPage * entriesPerPage, Math.min(sortedData.length, (currentPage + 1) * entriesPerPage))\n } else {\n currentPage = 0\n }\n\n const headerRow = 'border-b-2 border-gray-300'\n const headerPaddingHead = 'pb-2'\n const headerPaddingBody = 'pt-2'\n const cellPadding = 'py-1 px-2'\n\n const [scrollbarsAutoHeightMin, setScrollbarsAutoHeightMin] = useState(0)\n const tableRef = useRef<HTMLTableElement>(null)\n\n const calculateHeight = () => {\n if (tableRef.current) {\n const tableHeight = tableRef.current.offsetHeight\n const offset = 25\n setScrollbarsAutoHeightMin(tableHeight + offset)\n }\n }\n\n useEffect(() => {\n calculateHeight()\n\n // New function to unbind properly\n const handleResize = () => {\n calculateHeight()\n }\n\n window.addEventListener('resize', handleResize)\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [data, currentPage])\n\n return (\n <div className={clsx('col gap-y-4 overflow-hidden', className)}>\n <div>\n <Scrollbars autoHeight autoHeightMin={scrollbarsAutoHeightMin}>\n <table ref={tableRef} className=\"w-full mb-[12px]\">\n <thead>\n <tr className={headerRow}>\n {header && tableState.selection && (\n <th className={headerPaddingHead}>\n <Checkbox\n checked={tableState.selection.hasSelectedSome ? 'indeterminate' : tableState.selection.hasSelectedAll}\n onChange={() => updateTableState(changeTableSelectionAll(tableState, data, identifierMapping))}\n />\n </th>\n )}\n {header && header.map((value, index) => (\n <th key={`tableHeader${index}`} className={headerPaddingHead}>\n <div className=\"row justify-start px-2\">\n {value}\n </div>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {shownElements.map((value, rowIndex) => (\n <tr key={identifierMapping(value)}>\n {tableState.selection && (\n <td className={clsx(cellPadding, { [headerPaddingBody]: rowIndex === 0 })}>\n <Checkbox\n checked={isDataObjectSelected(tableState, value, identifierMapping)}\n onChange={() => {\n updateTableState(changeTableSelectionSingle(tableState, value, data.length, identifierMapping))\n }}\n />\n </td>\n )}\n {rowMappingToCells(value).map((value1, index) => (\n <td key={index}\n className={clsx(cellPadding, { [headerPaddingBody]: rowIndex === 0 })}>\n {value1}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </Scrollbars>\n </div>\n <div className=\"row justify-center\">\n {tableState.pagination && (\n <Pagination page={currentPage} numberOfPages={pageCount} onPageChanged={page => updateTableState({\n ...tableState,\n pagination: { entriesPerPage, currentPage: page }\n })}/>\n )}\n </div>\n </div>\n )\n}\n\nexport type SortButtonProps = Omit<TextButtonProps, 'onClick'> & {\n ascending?: TableSortingType,\n onClick: (newTableSorting: TableSortingType) => void,\n}\n\n/**\n * A Extension of the normal button that displays the sorting state right of the content\n */\nexport const SortButton = ({\n children,\n ascending,\n color,\n onClick,\n ...buttonProps\n }: SortButtonProps) => {\n return (\n <TextButton\n color={color}\n onClick={() => onClick(ascending === 'descending' ? 'ascending' : 'descending')}\n {...buttonProps}\n >\n <div className=\"row gap-x-2\">\n {children}\n {ascending === 'ascending' ? <ChevronUp/> : (!ascending ? <ChevronsUpDown/> : <ChevronDown/>)}\n </div>\n </TextButton>\n )\n}\n\n","import { useState } from 'react'\nimport type { CheckedState } from '@radix-ui/react-checkbox'\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox'\nimport { Check, Minus } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\ntype CheckBoxSize = 'small' | 'medium' | 'large'\n\nconst checkboxSizeMapping: Record<CheckBoxSize, string> = {\n small: 'size-4',\n medium: 'size-6',\n large: 'size-8',\n}\n\nconst checkboxIconSizeMapping: Record<CheckBoxSize, string> = {\n small: 'size-3',\n medium: 'size-5',\n large: 'size-7',\n}\n\ntype CheckboxProps = {\n /** used for the label's `for` attribute */\n id?: string,\n label?: Omit<LabelProps, 'id'>,\n /**\n * @default false\n */\n checked: CheckedState,\n disabled?: boolean,\n onChange?: (checked: boolean) => void,\n onChangeTristate?: (checked: CheckedState) => void,\n size?: CheckBoxSize,\n className?: string,\n containerClassName?: string,\n}\n\n/**\n * A Tristate checkbox\n *\n * The state is managed by the parent\n */\nconst Checkbox = ({\n id,\n label,\n checked,\n disabled,\n onChange,\n onChangeTristate,\n size = 'medium',\n className = '',\n containerClassName\n }: CheckboxProps) => {\n const usedSizeClass = checkboxSizeMapping[size]\n const innerIconSize = checkboxIconSizeMapping[size]\n\n const propagateChange = (checked: CheckedState) => {\n if (onChangeTristate) {\n onChangeTristate(checked)\n }\n if (onChange) {\n onChange(checked === 'indeterminate' ? false : checked)\n }\n }\n\n const changeValue = () => {\n const newValue = checked === 'indeterminate' ? false : !checked\n propagateChange(newValue)\n }\n\n return (\n <div className={clsx('row justify-center items-center', containerClassName)}>\n <CheckboxPrimitive.Root\n onCheckedChange={propagateChange}\n checked={checked}\n disabled={disabled}\n id={id}\n className={clsx(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {\n 'text-disabled-text border-disabled-text': disabled,\n 'border-on-background': !disabled,\n 'bg-primary/30 border-primary text-primary': checked === true || checked === 'indeterminate',\n 'hover:border-gray-400 focus:hover:border-primary': !checked\n }, className)}\n >\n <CheckboxPrimitive.Indicator>\n {checked === true && <Check className={innerIconSize}/>}\n {checked === 'indeterminate' && <Minus className={innerIconSize}/>}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n {label && (\n <Label {...label} className={clsx('cursor-pointer', label.className)} htmlFor={id}\n onClick={changeValue}/>\n )}\n </div>\n )\n}\n\ntype CheckboxUncontrolledProps = Omit<CheckboxProps, 'value' | 'checked'> & {\n /**\n * @default false\n */\n defaultValue?: CheckedState,\n}\n\n/**\n * A Tristate checkbox\n *\n * The state is managed by this component\n */\nconst CheckboxUncontrolled = ({\n onChange,\n onChangeTristate,\n defaultValue = false,\n ...props\n }: CheckboxUncontrolledProps) => {\n const [checked, setChecked] = useState(defaultValue)\n\n const handleChange = (checked: CheckedState) => {\n if (onChangeTristate) {\n onChangeTristate(checked)\n }\n if (onChange) {\n onChange(checked === 'indeterminate' ? false : checked)\n }\n setChecked(checked)\n }\n\n return (\n <Checkbox\n {...props}\n checked={checked}\n onChangeTristate={handleChange}\n />\n )\n}\n\nexport {\n CheckboxProps,\n CheckboxUncontrolled,\n Checkbox,\n}\n","import type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\n\ntype TextImageColor = 'primary' | 'secondary' | 'dark'\n\ntype TextImageTranslation = {\n showMore: string,\n}\n\nconst defaultTextImageTranslation: Record<Language, TextImageTranslation> = {\n de: {\n showMore: 'Mehr anzeigen'\n },\n en: {\n showMore: 'Show more'\n }\n}\n\nexport type TextImageProps = {\n title: string,\n description: string,\n imageUrl: string,\n onShowMoreClicked?: () => void,\n color?: TextImageColor,\n badge?: string,\n contentClassName?: string,\n className?: string,\n}\n\n/**\n * A Component for layering a Text upon a Image\n */\nexport const TextImage = ({\n overwriteTranslation,\n title,\n description,\n imageUrl,\n onShowMoreClicked,\n color = 'primary',\n badge,\n contentClassName = '',\n className = '',\n }: PropsForTranslation<TextImageTranslation, TextImageProps>) => {\n const translation = useTranslation(defaultTextImageTranslation, overwriteTranslation)\n\n const chipColorMapping: Record<TextImageColor, string> = {\n primary: 'text-text-image-primary-background bg-text-text-image-primary-text',\n secondary: 'text-text-image-secondary-background bg-text-text-image-secondary-text',\n dark: 'text-text-image-dark-background bg-text-text-image-dark-text',\n }\n\n const colorMapping: Record<TextImageColor, string> = {\n primary: 'text-text-image-primary-text bg-linear-to-r from-30% from-text-image-primary-background to-text-image-primary-background/55',\n secondary: 'text-text-image-secondary-text bg-linear-to-r from-30% from-text-image-secondary-background to-text-image-secondary-background/55',\n dark: 'text-text-image-dark-text bg-linear-to-r from-30% from-text-image-dark-background to-text-image-dark-background/55',\n }\n\n return (\n <div\n className={clsx('rounded-2xl w-full', className)}\n style={{\n backgroundImage: `url(${imageUrl})`,\n backgroundSize: 'cover',\n }}>\n <div\n className={clsx(`col px-6 py-12 rounded-2xl h-full`, colorMapping[color], contentClassName)}>\n {badge && (\n <div className={clsx(`chip-full bg-white mb-2 py-2 px-4 w-fit`, chipColorMapping[color])}>\n <span className=\"text-lg font-bold\">{badge}</span>\n </div>\n )}\n <div className=\"col gap-y-1 text-white overflow-hidden\">\n <span className=\"textstyle-title-xl\">{title}</span>\n <span className=\"text-ellipsis overflow-hidden\">{description}</span>\n </div>\n {onShowMoreClicked && (\n <div className=\"row mt-2 text-white underline\">\n <button onClick={onShowMoreClicked}>{translation.showMore}</button>\n </div>\n )}\n </div>\n </div>\n )\n}\n","export type VerticalDividerProps = {\n width?: number,\n height?: number,\n strokeWidth?: number,\n dashGap?: number,\n dashLength?: number,\n}\n\n/**\n * A Component for creating a vertical Divider\n */\nexport const VerticalDivider = ({\n width = 1,\n height = 100,\n strokeWidth = 4,\n dashGap = 4,\n dashLength = 4,\n }: VerticalDividerProps) => {\n return (\n <div style={{ width: width + 'px', height: height + 'px' }}>\n <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <line\n opacity=\"0.5\"\n x1={width / 2}\n y1={height}\n x2={width / 2}\n y2=\"0\"\n stroke=\"url(#paint_linear)\"\n strokeWidth={strokeWidth}\n strokeDasharray={`${dashLength} ${dashLength + dashGap}`}\n strokeLinecap=\"round\"\n />\n <defs>\n <linearGradient\n id=\"paint_linear\"\n x1={width / 2}\n y1=\"0\"\n x2={width / 2}\n y2={height}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop stopOpacity=\"0\" stopColor=\"currentColor\"/>\n <stop offset=\"0.5\" stopColor=\"currentColor\"/>\n <stop offset=\"1\" stopColor=\"currentColor\" stopOpacity=\"0\"/>\n </linearGradient>\n </defs>\n </svg>\n </div>\n )\n}\n","import { AlertOctagon } from 'lucide-react'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\n\ntype ErrorComponentTranslation = {\n errorOccurred: string,\n}\n\nconst defaultErrorComponentTranslation: Record<Language, ErrorComponentTranslation> = {\n en: {\n errorOccurred: 'An error occurred'\n },\n de: {\n errorOccurred: 'Ein Fehler ist aufgetreten'\n }\n}\n\nexport type ErrorComponentProps = {\n errorText?: string,\n classname?: string,\n}\n\n/**\n * The Component to show when an error occurred\n */\nexport const ErrorComponent = ({\n overwriteTranslation,\n errorText,\n classname\n }: PropsForTranslation<ErrorComponentTranslation, ErrorComponentProps>) => {\n const translation = useTranslation(defaultErrorComponentTranslation, overwriteTranslation)\n return (\n <div className={clsx('col items-center justify-center gap-y-4 w-full h-24', classname)}>\n <AlertOctagon size={64} className=\"text-warning\"/>\n {errorText ?? `${translation.errorOccurred} :(`}\n </div>\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport { useState } from 'react'\nimport type { LoadingAnimationProps } from './LoadingAnimation'\nimport { LoadingAnimation } from './LoadingAnimation'\nimport type { ErrorComponentProps } from './ErrorComponent'\nimport { ErrorComponent } from './ErrorComponent'\n\nexport type LoadingAndErrorComponentProps = PropsWithChildren<{\n isLoading?: boolean,\n hasError?: boolean,\n loadingProps?: LoadingAnimationProps,\n errorProps?: ErrorComponentProps,\n /**\n * in milliseconds\n */\n minimumLoadingDuration?: number,\n}>\n\n/**\n * A Component that shows the Error and Loading animation, when appropriate and the children otherwise\n */\nexport const LoadingAndErrorComponent = ({\n children,\n isLoading = false,\n hasError = false,\n errorProps,\n loadingProps,\n minimumLoadingDuration\n }: LoadingAndErrorComponentProps) => {\n const [isInMinimumLoading, setIsInMinimumLoading] = useState(false)\n const [hasUsedMinimumLoading, setHasUsedMinimumLoading] = useState(false)\n if (minimumLoadingDuration && !isInMinimumLoading && !hasUsedMinimumLoading) {\n setIsInMinimumLoading(true)\n setTimeout(() => {\n setIsInMinimumLoading(false)\n setHasUsedMinimumLoading(true)\n }, minimumLoadingDuration)\n }\n\n if (isLoading || (minimumLoadingDuration && isInMinimumLoading)) {\n return <LoadingAnimation {...loadingProps}/>\n }\n if (hasError) {\n return <ErrorComponent {...errorProps}/>\n }\n return children\n}\n","import type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\nimport { Helpwave } from '../icons-and-geometry/Helpwave'\n\ntype LoadingAnimationTranslation = {\n loading: string,\n}\n\nconst defaultLoadingAnimationTranslation: Record<Language, LoadingAnimationTranslation> = {\n en: {\n loading: 'Loading data'\n },\n de: {\n loading: 'Lade Daten'\n }\n}\n\nexport type LoadingAnimationProps = {\n loadingText?: string,\n classname?: string,\n}\n\n/**\n * A Component to show when loading data\n */\nexport const LoadingAnimation = ({\n overwriteTranslation,\n loadingText,\n classname\n }: PropsForTranslation<LoadingAnimationTranslation, LoadingAnimationProps>) => {\n const translation = useTranslation(defaultLoadingAnimationTranslation, overwriteTranslation)\n return (\n <div className={clsx('col items-center justify-center w-full h-24', classname)}>\n <Helpwave animate=\"loading\"/>\n {loadingText ?? `${translation.loading}...`}\n </div>\n )\n}\n","import clsx from 'clsx'\nimport type { SolidButtonProps } from '../user-action/Button'\nimport { ButtonUtil, SolidButton } from '../user-action/Button'\nimport { noop } from '@/util/noop'\nimport { Helpwave } from '../icons-and-geometry/Helpwave'\n\ntype LoadingButtonProps = {\n isLoading?: boolean,\n} & SolidButtonProps\n\nexport const LoadingButton = ({ isLoading = false, size = 'medium', onClick, ...rest }: LoadingButtonProps) => {\n const paddingClass = ButtonUtil.paddingMapping[size]\n\n return (\n <div className=\"inline-block relative\">\n {\n isLoading && (\n <div className={clsx('absolute inset-0 row items-center justify-center bg-white/40', paddingClass)}>\n <Helpwave animate=\"loading\" className=\"text-white\"/>\n </div>\n )\n }\n <SolidButton {...rest} disabled={rest.disabled} onClick={isLoading ? noop : onClick}/>\n </div>\n )\n}\n","export type ProgressIndicatorProps = {\n /*\n The amount of progress that has been made\n Value form 0 to 1\n */\n progress: number,\n strokeWidth?: number,\n size?: keyof typeof sizeMapping,\n direction?: 'clockwise' | 'counterclockwise',\n /*\n Rotation of the starting point of the indicator\n default start at 3 o'clock\n Given in degree\n */\n rotation?: number,\n}\n\nconst sizeMapping = { small: 16, medium: 24, big: 48 }\n\n/**\n * A progress indicator\n *\n * Start rotation is 3 o'clock and fills counterclockwise\n *\n * Progress is given from 0 to 1\n */\nexport const ProgressIndicator = ({\n progress,\n strokeWidth = 5,\n size = 'medium',\n direction = 'counterclockwise',\n rotation = 0\n }: ProgressIndicatorProps) => {\n const currentSize = sizeMapping[size]\n const center = currentSize / 2\n const radius = center - strokeWidth / 2\n const arcLength = 2 * Math.PI * radius\n const arcOffset = arcLength * progress\n if (direction === 'clockwise') {\n rotation += 360 * progress\n }\n return (\n <svg\n style={{\n height: `${currentSize}px`,\n width: `${currentSize}px`,\n transform: `rotate(${rotation}deg)`\n }}\n >\n <circle cx={center} cy={center} r={radius} fill=\"transparent\" strokeWidth={strokeWidth}\n className=\"stroke-primary\"\n />\n <circle cx={center} cy={center} r={radius} fill=\"transparent\" strokeWidth={strokeWidth}\n strokeDasharray={arcLength} strokeDashoffset={arcOffset} className=\"stroke-gray-300\"\n />\n </svg>\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport type { SolidButtonColor } from '../user-action/Button'\nimport { SolidButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport clsx from 'clsx'\nimport type { ModalProps } from '@/components/layout-and-navigation/Overlay'\nimport { Modal } from '@/components/layout-and-navigation/Overlay'\n\ntype ConfirmModalTranslation = {\n confirm: string,\n cancel: string,\n decline: string,\n}\n\nexport type ConfirmModalType = 'positive' | 'negative' | 'neutral' | 'primary'\n\nconst defaultConfirmDialogTranslation = {\n en: {\n confirm: 'Confirm',\n cancel: 'Cancel',\n decline: 'Decline'\n },\n de: {\n confirm: 'Bestätigen',\n cancel: 'Abbrechen',\n decline: 'Ablehnen'\n }\n}\n\ntype ButtonOverwriteType = {\n text?: string,\n color?: SolidButtonColor,\n disabled?: boolean,\n}\n\nexport type ConfirmModalProps = Omit<ModalProps, 'onClose'> & {\n isShowingDecline?: boolean,\n requireAnswer?: boolean,\n onCancel: () => void,\n onConfirm: () => void,\n onDecline?: () => void,\n confirmType?: ConfirmModalType,\n /**\n * Order: Cancel, Decline, Confirm\n */\n buttonOverwrites?: [ButtonOverwriteType, ButtonOverwriteType, ButtonOverwriteType],\n}\n\n/**\n * A Modal for asking the user for confirmation\n */\nexport const ConfirmModal = ({\n overwriteTranslation,\n children,\n onCancel,\n onConfirm,\n onDecline,\n confirmType = 'positive',\n buttonOverwrites,\n className,\n ...restProps\n }: PropsForTranslation<ConfirmModalTranslation, PropsWithChildren<ConfirmModalProps>>) => {\n const translation = useTranslation(defaultConfirmDialogTranslation, overwriteTranslation)\n\n const mapping: Record<ConfirmModalType, SolidButtonColor> = {\n neutral: 'neutral',\n negative: 'negative',\n positive: 'positive',\n primary: 'primary',\n }\n\n return (\n <Modal {...restProps} onClose={onCancel} className={clsx('justify-between', className)}>\n <div className=\"col grow\">\n {children}\n </div>\n <div className=\"row mt-3 gap-x-4 justify-end\">\n {onCancel && (\n <SolidButton\n color={buttonOverwrites?.[0].color ?? 'neutral'}\n onClick={onCancel}\n disabled={buttonOverwrites?.[0].disabled ?? false}\n >\n {buttonOverwrites?.[0].text ?? translation.cancel}\n </SolidButton>\n )}\n {onDecline && (\n <SolidButton\n color={buttonOverwrites?.[1].color ?? 'negative'}\n onClick={onDecline}\n\n disabled={buttonOverwrites?.[1].disabled ?? false}\n >\n {buttonOverwrites?.[1].text ?? translation.decline}\n </SolidButton>\n )}\n <SolidButton\n autoFocus\n color={buttonOverwrites?.[2].color ?? mapping[confirmType]}\n onClick={onConfirm}\n disabled={buttonOverwrites?.[2].disabled ?? false}\n >\n {buttonOverwrites?.[2].text ?? translation.confirm}\n </SolidButton>\n </div>\n </Modal>\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { ConfirmModalProps } from '@/components/modals/ConfirmModal'\nimport { ConfirmModal } from '@/components/modals/ConfirmModal'\n\ntype DiscardChangesModalTranslation = {\n save: string,\n cancel: string,\n dontSave: string,\n title: string,\n description: string,\n}\n\nconst defaultDiscardChangesModalTranslation = {\n en: {\n save: 'Save',\n cancel: 'Cancel',\n dontSave: 'Don\\'t save',\n title: 'Unsaved Changes',\n description: 'Do you want to save your changes?'\n },\n de: {\n save: 'Speichern',\n cancel: 'Abbrechen',\n dontSave: 'Nicht Speichern',\n title: 'Ungespeicherte Änderungen',\n description: 'Möchtest du die Änderungen speichern?'\n }\n}\n\ntype DiscardChangesModalProps = Omit<ConfirmModalProps, 'onDecline' | 'onConfirm' | 'buttonOverwrites'> & {\n isShowingDecline?: boolean,\n requireAnswer?: boolean,\n onCancel: () => void,\n onSave: () => void,\n onDontSave: () => void,\n}\n\nexport const DiscardChangesModal = ({\n overwriteTranslation,\n children,\n onCancel,\n onSave,\n onDontSave,\n headerProps,\n ...modalProps\n }: PropsForTranslation<DiscardChangesModalTranslation, PropsWithChildren<DiscardChangesModalProps>>) => {\n const translation = useTranslation(defaultDiscardChangesModalTranslation, overwriteTranslation)\n return (\n <ConfirmModal\n headerProps={{\n ...headerProps,\n titleText: headerProps?.titleText ?? translation.title,\n descriptionText: headerProps?.descriptionText ?? translation.description,\n }}\n onConfirm={onSave}\n onCancel={onCancel}\n onDecline={onDontSave}\n buttonOverwrites={[{ text: translation.cancel }, { text: translation.dontSave }, { text: translation.save }]}\n {...modalProps}\n >\n {children}\n </ConfirmModal>\n )\n}\n","import type { InputProps } from '../user-action/Input'\nimport { Input } from '../user-action/Input'\nimport type { ConfirmDialogProps } from '../dialogs/ConfirmDialog'\nimport { ConfirmDialog } from '../dialogs/ConfirmDialog'\n\nexport type InputModalProps = ConfirmDialogProps & {\n inputs: InputProps[],\n}\n\n/**\n * A modal for receiving multiple inputs\n */\nexport const InputModal = ({\n inputs,\n buttonOverwrites,\n ...restProps\n }: InputModalProps) => {\n return (\n <ConfirmDialog\n buttonOverwrites={buttonOverwrites}\n {...restProps}\n >\n {inputs.map((inputProps, index) => <Input key={`input ${index}`} {...inputProps}/>)}\n </ConfirmDialog>\n )\n}\n","import { Menu } from '@headlessui/react'\nimport { ChevronDown, ChevronUp, Search } from 'lucide-react'\nimport type { ReactNode } from 'react'\nimport { useEffect, useState } from 'react'\nimport clsx from 'clsx'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\nimport { MultiSearchWithMapping } from '@/util/simpleSearch'\nimport { Input } from '@/components/user-action/Input'\n\nexport type SelectOption<T> = {\n label: ReactNode,\n value: T,\n disabled?: boolean,\n className?: string,\n}\n\nexport type SelectProps<T> = {\n value?: T,\n label?: LabelProps,\n options: SelectOption<T>[],\n onChange: (value: T) => void,\n isHidingCurrentValue?: boolean,\n hintText?: string,\n showDisabledOptions?: boolean,\n className?: string,\n isDisabled?: boolean,\n textColor?: string,\n hoverColor?: string,\n /**\n * The items will be at the start of the select and aren't selectable\n */\n additionalItems?: ReactNode[],\n selectedDisplayOverwrite?: ReactNode,\n};\n\n/**\n * A Select Component for selecting form a list of options\n *\n * The State is managed by the parent\n */\nexport const Select = <T, >({\n value,\n label,\n options,\n onChange,\n isHidingCurrentValue = true,\n hintText = '',\n showDisabledOptions = true,\n isDisabled,\n className,\n textColor = 'text-menu-text',\n hoverColor = 'hover:brightness-90',\n additionalItems,\n selectedDisplayOverwrite,\n }: SelectProps<T>) => {\n // Notice: for more complex types this check here might need an additional compare method\n let filteredOptions = isHidingCurrentValue ? options.filter(option => option.value !== value) : options\n if (!showDisabledOptions) {\n filteredOptions = filteredOptions.filter(value => !value.disabled)\n }\n const selectedOption = options.find(option => option.value === value)\n if (value !== undefined && selectedOption === undefined && selectedDisplayOverwrite === undefined) {\n console.warn('The selected value is not found in the options list. This might be an error on your part or' +\n ' default behavior if it is complex data type on which === does not work. In case of the latter' +\n ' use selectedDisplayOverwrite to set your selected text or component')\n }\n\n const borderColor = 'border-menu-border'\n\n return (\n <div className={clsx(className)}>\n {label && (\n <Label {...label} labelType={label.labelType ?? 'labelBig'} className={clsx('mb-1', label.className)}/>\n )}\n <Menu as=\"div\" className=\"relative text-menu-text\">\n {({ open }) => (\n <>\n <Menu.Button\n className={clsx(\n 'inline-flex w-full justify-between items-center rounded-t-lg border-2 px-4 py-2 font-medium bg-menu-background text-menu-text',\n textColor, borderColor,\n {\n 'rounded-b-lg': !open,\n [hoverColor]: !isDisabled,\n 'bg-disabled-background cursor-not-allowed text-disabled': isDisabled\n }\n )}\n disabled={isDisabled}\n >\n <span>{selectedDisplayOverwrite ?? selectedOption?.label ?? hintText}</span>\n {open ? <ChevronUp/> : <ChevronDown/>}\n </Menu.Button>\n <Menu.Items\n className=\"absolute w-full z-10 rounded-b-lg bg-menu-background text-menu-text shadow-lg max-h-[500px] overflow-y-auto\"\n >\n {(additionalItems ?? []).map((item, index) => (\n <div key={`additionalItems${index}`}\n className={clsx(borderColor, 'px-4 py-2 overflow-hidden whitespace-nowrap text-ellipsis border-2 border-t-0', {\n 'border-b-0 rounded-b-lg': filteredOptions.length === 0 && index === (additionalItems?.length ?? 1) - 1,\n })}\n >\n {item}\n </div>\n ))}\n {filteredOptions.map((option, index) => (\n <Menu.Item key={`item${index}`}>\n {\n <div\n className={clsx('px-4 py-2 overflow-hidden whitespace-nowrap text-ellipsis border-2 border-t-0 cursor-pointer',\n option.className, borderColor, {\n 'brightness-90': option.value === value,\n 'brightness-95': index % 2 === 1,\n 'text-disabled bg-disabled-background cursor-not-allowed': !!option.disabled,\n 'bg-menu-background text-menu-text hover:brightness-90 cursor-pointer': !option.disabled,\n 'rounded-b-lg': index === filteredOptions.length - 1,\n })}\n onClick={() => {\n if (!option.disabled) {\n onChange(option.value)\n }\n }}\n >\n {option.label}\n </div>\n }\n </Menu.Item>\n ))}\n </Menu.Items>\n </>\n )}\n </Menu>\n </div>\n )\n}\n\nexport const SelectUncontrolled = <T, >({\n options, onChange, value, hintText, ...props\n }: SelectProps<T>) => {\n const [selected, setSelected] = useState(value)\n\n useEffect(() => {\n if (options.find(options => options.value === value)) {\n setSelected(value)\n }\n }, [options, value])\n\n return (\n <Select\n value={selected}\n options={options}\n onChange={value => {\n setSelected(value)\n onChange(value)\n }}\n hintText={hintText}\n {...props}\n />\n )\n}\n\nexport type SearchableSelectProps<T> = SelectProps<T> & {\n searchMapping: (value: SelectOption<T>) => string[],\n}\n\n/**\n * A Select where items can be searched\n */\nexport const SearchableSelect = <T, >({\n value,\n options,\n searchMapping,\n ...selectProps\n }: SearchableSelectProps<T>) => {\n const [search, setSearch] = useState<string>('')\n const filteredOptions = MultiSearchWithMapping(search, options, searchMapping)\n\n return (\n <Select\n value={value}\n options={filteredOptions}\n additionalItems={[(\n <div key=\"selectSearch\" className=\"row gap-x-2 items-center\">\n <Input autoFocus={true} value={search} onChangeText={setSearch}/>\n <Search/>\n </div>\n )]}\n {...selectProps}\n />\n )\n}\n\nexport default { Select, SelectUncontrolled, SearchableSelect }","import { type PropsWithChildren } from 'react'\nimport type { PropsForTranslation, Translation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { Select } from '../user-action/Select'\nimport type { Language } from '@/localization/util'\nimport { LanguageUtil } from '@/localization/util'\nimport { useLanguage } from '@/localization/LanguageProvider'\nimport { SolidButton } from '../user-action/Button'\nimport { Modal, type ModalProps } from '../layout-and-navigation/Overlay'\n\ntype LanguageModalTranslation = {\n title: string,\n message: string,\n done: string,\n} & Record<Language, string>\n\nconst defaultLanguageModalTranslation: Translation<LanguageModalTranslation> = {\n en: {\n title: 'Language',\n message: 'Choose your language',\n done: 'Done',\n ...LanguageUtil.languagesLocalNames\n },\n de: {\n title: 'Sprache',\n message: 'Wähle deine bevorzugte Sprache',\n done: 'Fertig',\n ...LanguageUtil.languagesLocalNames\n }\n}\n\ntype LanguageModalProps = ModalProps\n\n/**\n * A Modal for selecting the Language\n *\n * The State of open needs to be managed by the parent\n */\nexport const LanguageModal = ({\n overwriteTranslation,\n headerProps,\n onClose,\n ...modalProps\n }: PropsForTranslation<LanguageModalTranslation, PropsWithChildren<LanguageModalProps>>) => {\n const { language, setLanguage } = useLanguage()\n const translation = useTranslation(defaultLanguageModalTranslation, overwriteTranslation)\n\n return (\n <Modal\n headerProps={{\n ...headerProps,\n titleText: headerProps?.titleText ?? translation.title,\n descriptionText: headerProps?.descriptionText ?? translation.message,\n }}\n onClose={onClose}\n {...modalProps}\n >\n <div className=\"w-64\">\n <Select\n className=\"mt-2\"\n value={language}\n options={LanguageUtil.languages.map((language) => ({ label: translation[language], value: language }))}\n onChange={(language: string) => setLanguage(language as Language)}\n />\n <div className=\"row mt-3 gap-x-4 justify-end\">\n <SolidButton autoFocus color=\"positive\" onClick={onClose}>\n {translation.done}\n </SolidButton>\n </div>\n </div>\n </Modal>\n )\n}\n","import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport type { Translation } from '@/localization/useTranslation'\nimport { noop } from '@/util/noop'\n\nconst themes = ['light', 'dark'] as const\n\nexport type ThemeType = typeof themes[number]\n\nexport type ThemeTypeTranslation = Record<ThemeType, string>\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light'\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell'\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType>({\n theme: 'light',\n setTheme: noop\n})\n\ntype ThemeProviderProps = {\n initialTheme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, initialTheme = 'light' }: PropsWithChildren<ThemeProviderProps>) => {\n const [theme, setTheme] = useState<ThemeType>(initialTheme)\n\n useEffect(() => {\n if (theme !== initialTheme) {\n console.warn('ThemeProvider initial state changed: Prefer using useTheme\\'s setTheme instead')\n setTheme(initialTheme)\n }\n }, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', theme)\n }, [theme])\n\n return (\n <ThemeContext.Provider value={{ theme, setTheme }}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\n\nexport const useTheme = () => useContext(ThemeContext)\n","import { type PropsWithChildren } from 'react'\nimport type { PropsForTranslation, Translation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { Select } from '../user-action/Select'\nimport { SolidButton } from '../user-action/Button'\nimport { Modal, type ModalProps } from '../layout-and-navigation/Overlay'\nimport type { ThemeType, ThemeTypeTranslation } from '@/theming/useTheme'\nimport { useTheme } from '@/theming/useTheme'\nimport { ThemeUtil } from '@/theming/useTheme'\n\ntype ThemeModalTranslation = {\n title: string,\n message: string,\n done: string,\n} & ThemeTypeTranslation\n\nconst defaultConfirmDialogTranslation: Translation<ThemeModalTranslation> = {\n en: {\n title: 'Theme',\n message: 'Choose your preferred theme',\n done: 'Done',\n ...ThemeUtil.translation.en\n },\n de: {\n title: 'Farbschema',\n message: 'Wähle dein bevorzugtes Farbschema',\n done: 'Fertig',\n ...ThemeUtil.translation.en\n }\n}\n\ntype ThemeModalProps = ModalProps\n\n/**\n * A Modal for selecting the Theme\n *\n * The State of open needs to be managed by the parent\n */\nexport const ThemeModal = ({\n overwriteTranslation,\n headerProps,\n onClose,\n ...modalProps\n }: PropsForTranslation<ThemeModalTranslation, PropsWithChildren<ThemeModalProps>>) => {\n const { theme, setTheme } = useTheme()\n const translation = useTranslation(defaultConfirmDialogTranslation, overwriteTranslation)\n\n return (\n <Modal\n headerProps={{\n ...headerProps,\n titleText: headerProps?.titleText ?? translation.title,\n descriptionText: headerProps?.descriptionText ?? translation.message,\n }}\n onClose={onClose}\n {...modalProps}\n >\n <div className=\"w-64\">\n <Select\n className=\"mt-2\"\n value={theme}\n options={ThemeUtil.themes.map((theme) => ({ label: translation[theme], value: theme }))}\n onChange={(theme: string) => setTheme(theme as ThemeType)}\n />\n <div className=\"row mt-3 gap-x-4 justify-end\">\n <SolidButton autoFocus color=\"positive\" onClick={onClose}>\n {translation.done}\n </SolidButton>\n </div>\n </div>\n </Modal>\n )\n}\n","import { Check } from 'lucide-react'\nimport { noop } from '../../util/noop'\nimport { Checkbox } from '../user-action/Checkbox'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype CheckboxPropertyTranslation = {\n yes: string,\n no: string,\n}\n\nconst defaultCheckboxPropertyTranslation: Record<Language, CheckboxPropertyTranslation> = {\n en: {\n yes: 'Yes',\n no: 'No'\n },\n de: {\n yes: 'Ja',\n no: 'Nein'\n }\n}\n\nexport type CheckboxPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue' | 'onRemove'> & {\n value?: boolean,\n onChange?: (value: boolean) => void,\n}\n\n/**\n * An Input for a boolen properties\n */\nexport const CheckboxProperty = ({\n overwriteTranslation,\n value,\n onChange = noop,\n readOnly,\n ...baseProps\n }: PropsForTranslation<CheckboxPropertyTranslation, CheckboxPropertyProps>) => {\n const translation = useTranslation(defaultCheckboxPropertyTranslation, overwriteTranslation)\n\n return (\n <PropertyBase\n {...baseProps}\n hasValue={true}\n readOnly={readOnly}\n icon={<Check size={16}/>}\n input={() => (\n <div className=\"row py-2 px-4 items-center\">\n <Checkbox\n // TODO make bigger as in #904\n checked={value ?? true}\n disabled={readOnly}\n onChange={onChange}\n label={{ name: `${translation.yes}/${translation.no}`, labelType: 'labelMedium' }}\n />\n </div>\n )}\n />\n )\n}\n","import type { ReactNode } from 'react'\nimport { AlertTriangle } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '../../localization/util'\nimport { TextButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\n\ntype PropertyBaseTranslation = {\n remove: string,\n}\n\nconst defaultPropertyBaseTranslation: Record<Language, PropertyBaseTranslation> = {\n en: {\n remove: 'Remove'\n },\n de: {\n remove: 'Entfernen'\n }\n}\n\nexport type PropertyBaseProps = {\n name: string,\n input: (props: { softRequired: boolean, hasValue: boolean }) => ReactNode,\n onRemove?: () => void,\n hasValue: boolean,\n softRequired?: boolean,\n readOnly?: boolean,\n icon?: ReactNode,\n className?: string,\n}\n\n/**\n * A component for showing a properties with uniform styling\n */\nexport const PropertyBase = ({\n overwriteTranslation,\n name,\n input,\n softRequired = false,\n hasValue,\n icon,\n readOnly,\n onRemove,\n className = '',\n }: PropsForTranslation<PropertyBaseTranslation, PropertyBaseProps>) => {\n const translation = useTranslation(defaultPropertyBaseTranslation, overwriteTranslation)\n const requiredAndNoValue = softRequired && !hasValue\n return (\n <div className={clsx('row gap-x-0 group', className)}>\n <div\n className={\n clsx('row gap-x-2 !w-[200px] px-4 py-2 items-center rounded-l-xl border-2 border-r-0', {\n 'bg-gray-100 text-black group-hover:border-primary border-gray-400': !requiredAndNoValue,\n 'bg-warning text-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,\n }, className)}\n >\n {icon}\n {name}\n </div>\n <div className={\n clsx('row grow justify-between items-center rounded-r-xl border-2 border-l-0', {\n 'bg-white group-hover:border-primary border-gray-400': !requiredAndNoValue,\n 'bg-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,\n }, className)}\n >\n {input({ softRequired, hasValue })}\n {requiredAndNoValue && (\n <div className=\"text-warning pr-4\"><AlertTriangle size={24}/></div>\n )}\n {onRemove && (\n <TextButton\n onClick={onRemove}\n color=\"negative\"\n className={clsx('pr-4 items-center', { '!text-transparent': !hasValue || readOnly })}\n disabled={!hasValue || readOnly}\n >\n {translation.remove}\n </TextButton>\n )}\n </div>\n </div>\n )\n}\n","import { CalendarDays } from 'lucide-react'\nimport clsx from 'clsx'\nimport { formatDate, formatDateTime } from '@/util/date'\nimport { noop } from '@/util/noop'\nimport { Input } from '../user-action/Input'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\nexport type DatePropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {\n value?: Date,\n onChange?: (date: Date) => void,\n onEditComplete?: (value: Date) => void,\n type?: 'dateTime' | 'date',\n}\n\n/**\n * An Input for date properties\n */\nexport const DateProperty = ({\n value,\n onChange = noop,\n onEditComplete = noop,\n readOnly,\n type = 'dateTime',\n ...baseProps\n }: DatePropertyProps) => {\n const hasValue = !!value\n\n const dateText = value ? (type === 'dateTime' ? formatDateTime(value) : formatDate(value)) : ''\n return (\n <PropertyBase\n {...baseProps}\n hasValue={hasValue}\n icon={<CalendarDays size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <Input\n className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !w-fit !rounded-none', { 'bg-surface-warning': softRequired && !hasValue })}\n value={dateText}\n type={type === 'dateTime' ? 'datetime-local' : 'date'}\n readOnly={readOnly}\n onChange={(event) => {\n const value = event.target.value\n if (!value) {\n event.preventDefault()\n return\n }\n const dueDate = new Date(value)\n onChange(dueDate)\n }}\n onEditCompleted={(value) => onEditComplete(new Date(value))}\n />\n </div>\n )}\n />\n )\n}\n","import { List } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { MultiSelectProps } from '../user-action/MultiSelect'\nimport { MultiSelect } from '../user-action/MultiSelect'\nimport { ChipList } from '../layout-and-navigation/Chip'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype MultiSelectPropertyTranslation = {\n select: string,\n}\n\nconst defaultMultiSelectPropertyTranslation: Record<Language, MultiSelectPropertyTranslation> = {\n en: {\n select: 'Select'\n },\n de: {\n select: 'Auswählen'\n }\n}\n\nexport type MultiSelectPropertyProps<T> =\n Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'>\n\n/**\n * An Input for MultiSelect properties\n */\nexport const MultiSelectProperty = <T, >({\n overwriteTranslation,\n options,\n name,\n readOnly = false,\n softRequired,\n onRemove,\n ...multiSelectProps\n }: PropsForTranslation<MultiSelectPropertyTranslation, MultiSelectPropertyProps<T>>) => {\n const translation = useTranslation(defaultMultiSelectPropertyTranslation, overwriteTranslation)\n const hasValue = options.some(value => value.selected)\n let triggerClassName: string\n if (softRequired && !hasValue) {\n triggerClassName = 'border-warning hover:brightness-90'\n }\n\n return (\n <PropertyBase\n name={name}\n onRemove={onRemove}\n readOnly={readOnly}\n softRequired={softRequired}\n hasValue={hasValue}\n icon={<List size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <MultiSelect\n {...multiSelectProps}\n className={clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue })}\n triggerClassName={triggerClassName}\n selectedDisplay={({ items }) => {\n const selected = items.filter(value => value.selected)\n if (selected.length === 0) {\n return (<span>Select</span>)\n }\n return (\n <ChipList list={selected.map(value => ({ children: value.label }))}/>\n )\n }}\n options={options}\n disabled={readOnly}\n hintText={`${translation.select}...`}\n />\n </div>\n )}\n />\n )\n}\n","import type { ReactNode } from 'react'\nimport { useState } from 'react'\nimport { Search } from 'lucide-react'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { Language } from '@/localization/util'\nimport { MultiSearchWithMapping } from '@/util/simpleSearch'\nimport clsx from 'clsx'\nimport { Menu, MenuItem } from './Menu'\nimport { Input } from './Input'\nimport { Checkbox } from './Checkbox'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\ntype MultiSelectTranslation = {\n select: string,\n search: string,\n selected: string,\n}\n\nconst defaultMultiSelectTranslation: Record<Language, MultiSelectTranslation> = {\n en: {\n select: 'Select',\n search: 'Search',\n selected: 'selected'\n },\n de: {\n select: 'Auswählen',\n search: 'Suche',\n selected: 'ausgewählt'\n }\n}\n\n// TODO maybe add custom item builder here\nexport type MultiSelectOption<T> = {\n label: string,\n value: T,\n selected: boolean,\n disabled?: boolean,\n className?: string,\n}\n\nexport type SearchProps<T> = {\n initialSearch?: string,\n searchMapping: (value: MultiSelectOption<T>) => string[],\n}\n\nexport type MultiSelectProps<T> = {\n options: MultiSelectOption<T>[],\n onChange: (options: MultiSelectOption<T>[]) => void,\n search?: SearchProps<T>,\n disabled?: boolean,\n selectedDisplay?: (props: {\n items: MultiSelectOption<T>[],\n disabled: boolean,\n }) => ReactNode,\n label?: LabelProps,\n hintText?: string,\n showDisabledOptions?: boolean,\n className?: string,\n triggerClassName?: string,\n}\n\n/**\n * A Component for multi selection\n */\nexport const MultiSelect = <T, >({\n overwriteTranslation,\n options,\n onChange,\n search,\n disabled = false,\n selectedDisplay,\n label,\n hintText,\n showDisabledOptions = true,\n className = '',\n triggerClassName = '',\n }: PropsForTranslation<MultiSelectTranslation, MultiSelectProps<T>>) => {\n const translation = useTranslation(defaultMultiSelectTranslation, overwriteTranslation)\n const [searchText, setSearchText] = useState<string>(search?.initialSearch ?? '')\n let filteredOptions: MultiSelectOption<T>[] = options\n const enableSearch = !!search\n if (enableSearch && !!searchText) {\n filteredOptions = MultiSearchWithMapping<MultiSelectOption<T>>(\n searchText,\n filteredOptions,\n value => search.searchMapping(value)\n )\n }\n if (!showDisabledOptions) {\n filteredOptions = filteredOptions.filter(value => !value.disabled)\n }\n\n const selectedItems = options.filter(value => value.selected)\n const menuButtonText = selectedItems.length === 0 ?\n hintText ?? translation.select\n : <span>{`${selectedItems.length} ${translation.selected}`}</span>\n\n const borderColor = 'border-menu-border'\n\n return (\n <div className={clsx(className)}>\n {label && (\n <Label {...label} htmlFor={label.name} className={clsx(' mb-1', label.className)}\n labelType={label.labelType ?? 'labelBig'}/>\n )}\n <Menu<HTMLDivElement>\n alignment=\"t_\"\n trigger={(onClick, ref) => (\n <div ref={ref} onClick={disabled ? undefined : onClick}\n className={clsx(borderColor, 'bg-menu-background text-menu-text inline-w-full justify-between items-center rounded-lg border-2 px-4 py-2 font-medium',\n {\n 'hover:brightness-90 hover:border-primary cursor-pointer': !disabled,\n 'bg-disabled-background text-disabled cursor-not-allowed': disabled\n },\n triggerClassName)}\n >\n {selectedDisplay ? selectedDisplay({ items: options, disabled }) : menuButtonText}\n </div>\n )}\n menuClassName={clsx(\n '!rounded-lg !shadow-lg !max-h-[500px] !min-w-[400px] !max-w-[70vh] !overflow-y-auto !border !border-2', borderColor,\n { '!py-0': !enableSearch, '!pb-0': enableSearch }\n )}\n >\n {enableSearch && (\n <div key=\"selectSearch\" className=\"row gap-x-2 items-center px-2 py-2\">\n <Input autoFocus={true} className=\"w-full\" value={searchText} onChangeText={setSearchText}/>\n <Search/>\n </div>\n )}\n {filteredOptions.map((option, index) => (\n <MenuItem key={`item${index}`} className={clsx({\n 'cursor-not-allowed !bg-disabled-background !text-disabled-text hover:brightness-100': !!option.disabled,\n 'cursor-pointer': !option.disabled,\n })}\n >\n <div\n className={clsx('overflow-hidden whitespace-nowrap text-ellipsis row items-center gap-x-2', option.className)}\n onClick={() => {\n if (!option.disabled) {\n onChange(options.map(value => value.value === option.value ? ({\n ...option,\n selected: !value.selected\n }) : value))\n }\n }}\n >\n <Checkbox checked={option.selected} disabled={option.disabled} size=\"small\"/>\n {option.label}\n </div>\n </MenuItem>\n ))}\n </Menu>\n </div>\n )\n}\n","import { type PropsWithChildren, type ReactNode, type RefObject, useRef } from 'react'\nimport clsx from 'clsx'\nimport { useOutsideClick } from '@/hooks/useOutsideClick'\nimport { useHoverState } from '@/hooks/useHoverState'\n\ntype MenuProps<T> = PropsWithChildren<{\n trigger: (onClick: () => void, ref: RefObject<T>) => ReactNode,\n /**\n * @default 'tl'\n */\n alignment?: 'tl' | 'tr' | 'bl' | 'br' | '_l' | '_r' | 't_' | 'b_',\n showOnHover?: boolean,\n menuClassName?: string,\n}>\n\nexport type MenuItemProps = {\n onClick?: () => void,\n alignment?: 'left' | 'right',\n className?: string,\n}\nconst MenuItem = ({\n children,\n onClick,\n alignment = 'left',\n className\n }: PropsWithChildren<MenuItemProps>) => (\n <div\n className={clsx('block px-3 py-1 bg-menu-background text-menu-text hover:brightness-90', {\n 'text-right': alignment === 'right',\n 'text-left': alignment === 'left',\n }, className)}\n onClick={onClick}\n >\n {children}\n </div>\n)\n\n/**\n * A Menu Component to allow the user to see different functions\n */\nconst Menu = <T extends HTMLElement>({\n trigger,\n children,\n alignment = 'tl',\n showOnHover = false,\n menuClassName = '',\n }: MenuProps<T>) => {\n const { isHovered: isOpen, setIsHovered: setIsOpen, handlers } = useHoverState({ isDisabled: !showOnHover })\n const triggerRef = useRef<T>(null)\n const menuRef = useRef<HTMLDivElement>(null)\n useOutsideClick([triggerRef, menuRef], () => setIsOpen(false))\n\n return (\n <div\n className=\"relative\"\n {...handlers}\n >\n {trigger(() => setIsOpen(!isOpen), triggerRef)}\n {isOpen ? (\n <div ref={menuRef} onClick={e => e.stopPropagation()}\n className={clsx('absolute top-full mt-1 py-2 w-60 rounded-lg bg-menu-background text-menu-text ring-1 ring-slate-900/5 text-sm leading-6 font-semibold shadow-md z-[1]', {\n ' top-[8px]': alignment[0] === 't',\n ' bottom-[8px]': alignment[0] === 'b',\n ' left-[-8px]': alignment[1] === 'l',\n ' right-[-8px]': alignment[1] === 'r',\n }, menuClassName)}>\n {children}\n </div>\n ) : null}\n </div>\n )\n}\n\nexport { Menu, MenuItem }\n","import type { RefObject } from 'react'\nimport { useEffect } from 'react'\n\nexport const useOutsideClick = <Ts extends RefObject<HTMLElement>[]>(refs: Ts, handler: () => void) => {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // returning means not \"not clicking outside\"\n\n // if no target exists, return\n if (event.target === null) return\n // if the target is a ref's element or descendent thereof, return\n if (refs.some((ref) => !ref.current || ref.current.contains(event.target as Node))) {\n return\n }\n\n handler()\n }\n document.addEventListener('mousedown', listener)\n document.addEventListener('touchstart', listener)\n return () => {\n document.removeEventListener('mousedown', listener)\n document.removeEventListener('touchstart', listener)\n }\n }, [refs, handler])\n}\n","import { Binary } from 'lucide-react'\nimport clsx from 'clsx'\nimport { noop } from '@/util/noop'\nimport { Input } from '../user-action/Input'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype NumberPropertyTranslation = {\n value: string,\n}\n\nconst defaultNumberPropertyTranslation: Record<Language, NumberPropertyTranslation> = {\n en: {\n value: 'Value'\n },\n de: {\n value: 'Wert'\n }\n}\n\nexport type NumberPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {\n value?: number,\n suffix?: string,\n onChange?: (value: number) => void,\n onEditComplete?: (value: number) => void,\n}\n\n/**\n * An Input for number properties\n */\nexport const NumberProperty = ({\n overwriteTranslation,\n value,\n onChange = noop,\n onRemove = noop,\n onEditComplete = noop,\n readOnly,\n suffix,\n ...baseProps\n }: PropsForTranslation<NumberPropertyTranslation, NumberPropertyProps>) => {\n const translation = useTranslation(defaultNumberPropertyTranslation, overwriteTranslation)\n const hasValue = value !== undefined\n\n return (\n <PropertyBase\n {...baseProps}\n onRemove={onRemove}\n hasValue={hasValue}\n icon={<Binary size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <Input\n expanded={false}\n className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !w-fit !shadow-none !rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue })}\n value={value?.toString() ?? ''}\n type=\"number\"\n readOnly={readOnly}\n placeholder={`${translation.value}...`}\n onChangeText={(value) => {\n const numberValue = parseFloat(value)\n if (isNaN(numberValue)) {\n onRemove()\n } else {\n onChange(numberValue)\n }\n }}\n onEditCompleted={(value) => {\n const numberValue = parseFloat(value)\n if (isNaN(numberValue)) {\n onRemove()\n } else {\n onEditComplete(numberValue)\n }\n }}\n />\n {suffix && <span className={clsx('ml-1', { 'bg-surface-warning': softRequired && !hasValue })}>{suffix}</span>}\n </div>\n )}\n />\n )\n}\n","import { List } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { SearchableSelectProps } from '../user-action/Select'\nimport { SearchableSelect } from '../user-action/Select'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype SingleSelectPropertyTranslation = {\n select: string,\n}\n\nconst defaultSingleSelectPropertyTranslation: Record<Language, SingleSelectPropertyTranslation> = {\n en: {\n select: 'Select'\n },\n de: {\n select: 'Auswählen'\n }\n}\n\nexport type SingleSelectPropertyProps<T> =\n Omit<PropertyBaseProps & SearchableSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'labelClassName' | 'additionalItems'>\n\n/**\n * An Input for SingleSelect properties\n */\nexport const SingleSelectProperty = <T, >({\n overwriteTranslation,\n value,\n options,\n name,\n readOnly = false,\n softRequired,\n onRemove,\n ...multiSelectProps\n }: PropsForTranslation<SingleSelectPropertyTranslation, SingleSelectPropertyProps<T>>) => {\n const translation = useTranslation(defaultSingleSelectPropertyTranslation, overwriteTranslation)\n const hasValue = value !== undefined\n\n return (\n <PropertyBase\n name={name}\n onRemove={onRemove}\n readOnly={readOnly}\n softRequired={softRequired}\n hasValue={hasValue}\n icon={<List size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <SearchableSelect\n {...multiSelectProps}\n value={value}\n options={options}\n isDisabled={readOnly}\n className={clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue })}\n hintText={`${translation.select}...`}\n />\n </div>\n )}\n />\n )\n}\n","import { Text } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { Textarea } from '../user-action/Textarea'\nimport { noop } from '@/util/noop'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype TextPropertyTranslation = {\n value: string,\n}\n\nconst defaultTextPropertyTranslation: Record<Language, TextPropertyTranslation> = {\n en: {\n value: 'Text'\n },\n de: {\n value: 'Text'\n }\n}\n\nexport type TextPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {\n value?: string,\n onChange?: (value: string) => void,\n onEditComplete?: (value: string) => void,\n}\n\n/**\n * An Input for Text properties\n */\nexport const TextProperty = ({\n overwriteTranslation,\n value,\n readOnly,\n onChange = noop,\n onRemove = noop,\n onEditComplete = noop,\n ...baseProps\n }: PropsForTranslation<TextPropertyTranslation, TextPropertyProps>) => {\n const translation = useTranslation(defaultTextPropertyTranslation, overwriteTranslation)\n const hasValue = value !== undefined\n\n return (\n <PropertyBase\n {...baseProps}\n onRemove={onRemove}\n hasValue={hasValue}\n icon={<Text size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow pt-2 pb-1 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <Textarea\n className={clsx('ring-0 border-0 outline-0 p-0 m-0 shadow-none rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue })}\n rows={5}\n defaultStyle={false}\n value={value ?? ''}\n readOnly={readOnly}\n placeholder={`${translation.value}...`}\n onChangeText={(value) => {\n if (!value) {\n onRemove()\n } else {\n onChange(value)\n }\n }}\n onEditCompleted={(value) => {\n if (!value) {\n onRemove()\n } else {\n onEditComplete(value)\n }\n }}\n />\n </div>\n )}\n />\n )\n}\n","import type { TextareaHTMLAttributes } from 'react'\nimport { useEffect, useState } from 'react'\nimport clsx from 'clsx'\nimport { useSaveDelay } from '@/hooks/useSaveDelay'\nimport { noop } from '@/util/noop'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\nexport type TextareaProps = {\n /** Outside the area */\n label?: Omit<LabelProps, 'id'>,\n /** Inside the area */\n headline?: string,\n value?: string,\n resizable?: boolean,\n onChangeText?: (text: string) => void,\n disclaimer?: string,\n onEditCompleted?: (text: string) => void,\n defaultStyle?: boolean,\n} & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>\n\n/**\n * A Textarea component for inputting longer texts\n *\n * The State is managed by the parent\n */\nexport const Textarea = ({\n label,\n headline,\n id,\n resizable = false,\n onChange = noop,\n onChangeText = noop,\n disclaimer,\n onBlur = noop,\n onEditCompleted = noop,\n defaultStyle = true,\n className,\n ...props\n }: TextareaProps) => {\n const [hasFocus, setHasFocus] = useState(false)\n const { restartTimer, clearUpdateTimer } = useSaveDelay(() => undefined, 3000)\n\n const onEditCompletedWrapper = (text: string) => {\n onEditCompleted(text)\n clearUpdateTimer()\n }\n\n return (\n <div className=\"w-full\">\n {label && (\n <Label {...label} htmlFor={id} className={clsx('mb-1', label.className)}\n labelType={label.labelType ?? 'labelSmall'}/>\n )}\n <div\n className={`${clsx(' bg-surface text-on-surface focus-within:border-primary relative', { 'shadow border-2 border-gray-300 hover:border-primary rounded-lg': defaultStyle })}`}>\n {headline && (\n <span className=\"mx-3 mt-3 block text-gray-700 font-bold\">\n {headline}\n </span>\n )}\n <textarea\n id={id}\n className={clsx('pt-0 px-3 border-transparent focus:border-transparent focus:ring-0 appearance-none border w-full leading-tight focus:outline-none', {\n 'resize-none': !resizable,\n 'h-32': defaultStyle,\n 'mt-3': !headline\n }, className)}\n onChange={(event) => {\n const value = event.target.value\n restartTimer(() => {\n onEditCompletedWrapper(value)\n })\n onChange(event)\n onChangeText(value)\n }}\n onFocus={() => {\n setHasFocus(true)\n }}\n onBlur={(event) => {\n onBlur(event)\n onEditCompletedWrapper(event.target.value)\n setHasFocus(false)\n }}\n {...props}\n >\n </textarea>\n </div>\n {(hasFocus && disclaimer) && (\n <label className=\"text-negative\">\n {disclaimer}\n </label>\n )}\n </div>\n )\n}\n\n/**\n * A Textarea component that is not controlled by its parent\n */\nexport const TextareaUncontrolled = ({\n value = '',\n onChangeText = noop,\n ...props\n }: TextareaProps) => {\n const [text, setText] = useState<string>(value)\n\n useEffect(() => {\n setText(value)\n }, [value])\n\n return (\n <Textarea\n {...props}\n value={text}\n onChangeText={text => {\n setText(text)\n onChangeText(text)\n }}\n />\n )\n}","import type { ReactNode } from 'react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { noop } from '@/util/noop'\nimport { addDuration, subtractDuration } from '@/util/date'\nimport { SolidButton } from './Button'\nimport type { TimePickerProps } from '../date/TimePicker'\nimport { TimePicker } from '../date/TimePicker'\nimport type { DatePickerProps } from '../date/DatePicker'\nimport { DatePicker } from '../date/DatePicker'\n\ntype TimeTranslation = {\n clear: string,\n change: string,\n year: string,\n month: string,\n day: string,\n january: string,\n february: string,\n march: string,\n april: string,\n may: string,\n june: string,\n july: string,\n august: string,\n september: string,\n october: string,\n november: string,\n december: string,\n}\n\nconst defaultTimeTranslation: Record<Language, TimeTranslation> = {\n en: {\n clear: 'Clear',\n change: 'Change',\n year: 'Year',\n month: 'Month',\n day: 'Day',\n january: 'January',\n february: 'Febuary',\n march: 'March',\n april: 'April',\n may: 'May',\n june: 'June',\n july: 'July',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December',\n },\n de: {\n clear: 'Entfernen',\n change: 'Ändern',\n year: 'Jahr',\n month: 'Monat',\n day: 'Tag',\n january: 'Januar',\n february: 'Febuar',\n march: 'März',\n april: 'April',\n may: 'Mai',\n june: 'Juni',\n july: 'Juli',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December',\n }\n}\n\nexport type DateTimePickerMode = 'date' | 'time' | 'dateTime'\n\nexport type DateTimePickerProps = {\n mode?: DateTimePickerMode,\n value?: Date,\n start?: Date,\n end?: Date,\n onChange?: (date: Date) => void,\n onFinish?: (date: Date) => void,\n onRemove?: () => void,\n datePickerProps?: Omit<DatePickerProps, 'onChange' | 'value' | 'start' | 'end'>,\n timePickerProps?: Omit<TimePickerProps, 'onChange' | 'time' | 'maxHeight'>,\n}\n\n/**\n * A Component for picking a Date and Time\n */\nexport const DateTimePicker = ({\n overwriteTranslation,\n value = new Date(),\n start = subtractDuration(new Date(), { years: 50 }),\n end = addDuration(new Date(), { years: 50 }),\n mode = 'dateTime',\n onFinish = noop,\n onChange = noop,\n onRemove = noop,\n timePickerProps,\n datePickerProps,\n }: PropsForTranslation<TimeTranslation, DateTimePickerProps>) => {\n const translation = useTranslation(defaultTimeTranslation, overwriteTranslation)\n\n const useDate = mode === 'dateTime' || mode === 'date'\n const useTime = mode === 'dateTime' || mode === 'time'\n\n let dateDisplay: ReactNode\n let timeDisplay: ReactNode\n\n if (useDate) {\n dateDisplay = (\n <DatePicker\n {...datePickerProps}\n className=\"min-w-[320px] min-h-[250px]\"\n yearMonthPickerProps={{ maxHeight: 218 }}\n value={value}\n start={start}\n end={end}\n onChange={onChange}\n />\n )\n }\n if (useTime) {\n timeDisplay = (\n <TimePicker\n {...timePickerProps}\n className={clsx('h-full', { 'justify-between w-full': mode === 'time' })}\n maxHeight={250}\n time={value}\n onChange={onChange}\n />\n )\n }\n\n return (\n <div className=\"col w-fit\">\n <div className=\"row gap-x-4\">\n {dateDisplay}\n {timeDisplay}\n </div>\n <div className=\"row justify-end\">\n <div className=\"row gap-x-2 mt-1\">\n <SolidButton size=\"medium\" color=\"negative\" onClick={onRemove}>{translation.clear}</SolidButton>\n <SolidButton\n size=\"medium\"\n onClick={() => onFinish(value)}\n >\n {translation.change}\n </SolidButton>\n </div>\n </div>\n </div>\n )\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport clsx from 'clsx'\nimport { noop } from '@/util/noop'\nimport { getNeighbours, range } from '@/util/array'\nimport { clamp } from '@/util/math'\n\nexport type ScrollPickerProps<T> = {\n options: T[],\n mapping: (value: T) => string,\n selected?: T,\n onChange?: (value: T) => void,\n disabled?: boolean,\n}\n\ntype AnimationData<T> = {\n /** The index we scroll to */\n targetIndex: number,\n /** The index we are currently showing centered */\n currentIndex: number,\n items: T[],\n /** From -0.5 to 0.5 */\n transition: number,\n velocity: number,\n animationVelocity: number,\n lastTimeStamp?: number,\n lastScrollTimeStamp?: number,\n}\n\nconst up = 1\nconst down = -1\ntype Direction = 1 | -1\n\n/**\n * A component for picking an option by scrolling\n */\nexport const ScrollPicker = <T, >({\n options,\n mapping,\n selected,\n onChange = noop,\n disabled = false,\n }: ScrollPickerProps<T>) => {\n let selectedIndex = 0\n if (selected && options.indexOf(selected) !== -1) {\n selectedIndex = options.indexOf(selected)\n }\n const [{\n currentIndex,\n transition,\n items,\n lastTimeStamp\n }, setAnimation] = useState<AnimationData<T>>({\n targetIndex: selectedIndex,\n currentIndex: disabled ? selectedIndex : 0,\n velocity: 0,\n animationVelocity: Math.floor(options.length / 2),\n transition: 0,\n items: options,\n })\n\n const itemsShownCount = 5\n const shownItems = getNeighbours(range(0, items.length - 1), currentIndex).map(index => ({\n name: mapping(items[index]!), index\n }))\n\n const itemHeight = 40\n const distance = 8\n\n const containerHeight = itemHeight * (itemsShownCount - 2) + distance * (itemsShownCount - 2 + 1)\n\n const getDirection = useCallback((targetIndex: number, currentIndex: number, transition: number, length: number): Direction => {\n if (targetIndex === currentIndex) {\n return transition > 0 ? up : down\n }\n let distanceForward = targetIndex - currentIndex\n if (distanceForward < 0) {\n distanceForward += length\n }\n return distanceForward >= length / 2 ? down : up\n }, [])\n\n const animate = useCallback((timestamp: number, startTime: number | undefined) => {\n setAnimation((prevState) => {\n const {\n targetIndex,\n currentIndex,\n transition,\n animationVelocity,\n velocity,\n items,\n lastScrollTimeStamp\n } = prevState\n if (disabled) {\n return { ...prevState, currentIndex: targetIndex, velocity: 0, lastTimeStamp: timestamp }\n }\n if ((targetIndex === currentIndex && velocity === 0 && transition === 0) || !startTime) {\n return { ...prevState, lastTimeStamp: timestamp }\n }\n const progress = (timestamp - startTime) / 1000 // to seconds\n const direction = getDirection(targetIndex, currentIndex, transition, items.length)\n\n let newVelocity = velocity\n let usedVelocity\n let newCurrentIndex = currentIndex\n const isAutoScrolling = velocity === 0 && (!lastScrollTimeStamp || timestamp - lastScrollTimeStamp > 300)\n\n const newLastScrollTimeStamp = velocity !== 0 ? timestamp : lastScrollTimeStamp\n\n // manual scrolling\n if (isAutoScrolling) {\n usedVelocity = direction * animationVelocity\n } else {\n usedVelocity = velocity\n newVelocity = velocity * 0.5 // drag loss\n if (Math.abs(newVelocity) <= 0.05) {\n newVelocity = 0\n }\n }\n\n let newTransition = transition + usedVelocity * progress\n const changeThreshold = 0.5\n\n while (newTransition >= changeThreshold) {\n if (newCurrentIndex === targetIndex && newTransition >= changeThreshold && isAutoScrolling) {\n newTransition = 0\n break\n }\n newCurrentIndex = (currentIndex + 1) % items.length\n newTransition -= 1\n }\n if (newTransition >= changeThreshold) {\n newTransition = 0\n }\n while (newTransition <= -changeThreshold) {\n if (newCurrentIndex === targetIndex && newTransition <= -changeThreshold && isAutoScrolling) {\n newTransition = 0\n break\n }\n newCurrentIndex = currentIndex === 0 ? items.length - 1 : currentIndex - 1\n newTransition += 1\n }\n let newTargetIndex = targetIndex\n if (!isAutoScrolling) {\n newTargetIndex = newCurrentIndex\n }\n\n if ((currentIndex !== newTargetIndex || newTargetIndex !== targetIndex) && newTargetIndex === newCurrentIndex) {\n onChange(items[newCurrentIndex]!)\n }\n return {\n targetIndex: newTargetIndex,\n currentIndex: newCurrentIndex,\n animationVelocity,\n transition: newTransition,\n velocity: newVelocity,\n items,\n lastTimeStamp: timestamp,\n lastScrollTimeStamp: newLastScrollTimeStamp\n }\n })\n }, [disabled, getDirection, onChange])\n\n useEffect(() => {\n // constant update\n requestAnimationFrame((timestamp) => animate(timestamp, lastTimeStamp))\n })\n\n const opacity = (transition: number, index: number, itemsCount: number) => {\n const max = 100\n const min = 0\n const distance = max - min\n\n let opacityValue = min\n const unitTransition = clamp((transition) / 0.5)\n if (index === 1 || index === itemsCount - 2) {\n if (index === 1 && transition > 0) {\n opacityValue += Math.floor(unitTransition * distance)\n }\n if (index === itemsCount - 2 && transition < 0) {\n opacityValue += Math.floor(unitTransition * distance)\n }\n } else {\n opacityValue = max\n }\n\n // TODO this is not the right value for the bottom entry\n return clamp(1 - (opacityValue / max))\n }\n\n return (\n <div\n className=\"relative overflow-hidden\"\n style={{ height: containerHeight }}\n onWheel={event => {\n if (event.deltaY !== 0) {\n // TODO slower increase\n setAnimation(({ velocity, ...animationData }) =>\n ({ ...animationData, velocity: velocity + event.deltaY }))\n }\n }}\n >\n <div className=\"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2\">\n <div\n className=\"absolute z-[1] top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-full min-w-[40px] border border-y-2 border-x-0 border-[#00000033]\"\n style={{ height: `${itemHeight}px` }}\n />\n <div\n className=\"col select-none\"\n style={{\n transform: `translateY(${-transition * (distance + itemHeight)}px)`,\n columnGap: `${distance}px`,\n }}\n >\n {shownItems.map(({ name, index }, arrayIndex) => (\n <div\n key={index}\n className={clsx(\n `col items-center justify-center rounded-md`,\n {\n 'text-primary font-bold': currentIndex === index,\n 'text-on-background': currentIndex === index,\n 'cursor-pointer': !disabled,\n 'cursor-not-allowed': disabled,\n }\n )}\n style={{\n opacity: currentIndex !== index ? opacity(transition, arrayIndex, shownItems.length) : undefined,\n height: `${itemHeight}px`,\n maxHeight: `${itemHeight}px`,\n }}\n onClick={() => !disabled && setAnimation(prevState => ({ ...prevState, targetIndex: index }))}\n >\n {name}\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n","import type { HTMLInputTypeAttribute, InputHTMLAttributes } from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { Pencil } from 'lucide-react'\nimport clsx from 'clsx'\nimport { useSaveDelay } from '@/hooks/useSaveDelay'\nimport { noop } from '@/util/noop'\n\ntype InputProps = {\n /**\n * The value\n */\n value: string,\n /**\n * @default 'text'\n */\n type?: HTMLInputTypeAttribute,\n /**\n * Callback for when the input's value changes\n * This is pretty much required but made optional for the rare cases where it actually isn't need such as when used with disabled\n * That could be enforced through a union type but that seems a bit overkill\n * @default noop\n */\n onChangeText?: (text: string) => void,\n onEditCompleted?: (text: string) => void,\n labelClassName?: string,\n initialState?: 'editing' | 'display',\n size?: number,\n disclaimer?: string,\n} & Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'label' | 'type' | 'crossOrigin'>\n\n/**\n * A Text input component for inputting text. It changes appearance upon entering the edit mode and switches\n * back to display mode on loss of focus or on enter\n *\n * The State is managed by the parent\n */\nexport const ToggleableInput = ({\n type = 'text',\n value,\n onChange = noop,\n onChangeText = noop,\n onEditCompleted = noop,\n labelClassName = '',\n initialState = 'display',\n size = 16,\n disclaimer,\n onBlur,\n ...restProps\n }: InputProps) => {\n const [isEditing, setIsEditing] = useState(initialState !== 'display')\n const { restartTimer, clearUpdateTimer } = useSaveDelay(() => undefined, 3000)\n const ref = useRef<HTMLInputElement>(null)\n\n const onEditCompletedWrapper = (text: string) => {\n onEditCompleted(text)\n clearUpdateTimer()\n }\n\n useEffect(() => {\n if (isEditing) {\n ref.current?.focus()\n }\n }, [isEditing])\n\n return (\n <div>\n <div\n className={clsx('row items-center w-full gap-x-2 overflow-hidden', { 'cursor-pointer': !isEditing })}\n onClick={() => !isEditing ? setIsEditing(!isEditing) : undefined}\n >\n <div className={clsx('row overflow-hidden', { 'flex-1': isEditing })}>\n {isEditing ? (\n <input\n ref={ref}\n {...restProps}\n value={value}\n type={type}\n onChange={event => {\n const value = event.target.value\n restartTimer(() => {\n onEditCompletedWrapper(value)\n })\n onChangeText(value)\n onChange(event)\n }}\n onBlur={(event) => {\n if (onBlur) {\n onBlur(event)\n }\n onEditCompletedWrapper(value)\n setIsEditing(false)\n }}\n onKeyDown={event => {\n if (event.key === 'Enter') {\n setIsEditing(false)\n onEditCompletedWrapper(value)\n }\n }}\n className={clsx(`w-full border-none rounded-none ring-0 outline-0 text-inherit bg-inherit shadow-transparent decoration-primary p-0 underline-offset-4`, {\n underline: isEditing\n }, labelClassName)}\n onFocus={event => event.target.select()}\n />\n ) : (\n <span className={clsx('max-w-xs break-words overflow-hidden', labelClassName)}>\n {value}\n </span>\n )}\n </div>\n <Pencil\n className={clsx(`cursor-pointer`, { 'text-transparent': isEditing })}\n size={size}\n style={{ minWidth: `${size}px` }}\n />\n </div>\n {(isEditing && disclaimer) && (\n <label className=\"text-negative\">\n {disclaimer}\n </label>\n )}\n </div>\n )\n}\n\nexport const ToggleableInputUncontrolled = ({\n value: initialValue,\n onChangeText = noop,\n ...restProps\n }: InputProps) => {\n const [value, setValue] = useState(initialValue)\n\n useEffect(() => {\n setValue(initialValue)\n }, [initialValue])\n\n return (\n <ToggleableInput\n value={value}\n onChangeText={text => {\n setValue(text)\n onChangeText(text)\n }}\n {...restProps}\n />\n )\n}\n","import { z } from 'zod'\nimport type { Language } from '@/localization/util'\nimport { LanguageUtil } from '@/localization/util'\n\nexport type News = {\n title: string,\n date: Date,\n description: (string | URL)[],\n externalResource?: URL,\n keys: string[],\n}\n\nexport type LocalizedNews = Record<Language, News[]>\n\nexport const newsSchema = z.object({\n title: z.string(),\n description: z.string(),\n date: z.string(),\n image: z.string().url().optional(),\n externalResource: z.string().url().optional(),\n keys: z.array(z.string())\n}).transform<News>((obj) => {\n let description: (string | URL)[] = [obj.description]\n if (obj.image) {\n description = [new URL(obj.image), ...description]\n }\n\n return {\n title: obj.title,\n date: new Date(obj.date),\n description,\n externalResource: obj.externalResource ? new URL(obj.externalResource) : undefined,\n keys: obj.keys\n }\n})\n\nexport const newsListSchema = z.array(newsSchema)\n\nexport const localizedNewsSchema = z.record(z.enum(LanguageUtil.languages), newsListSchema)\n\nexport const filterNews = (localizedNews: News[], requiredKeys: string[]) => {\n return localizedNews.filter(news => requiredKeys.every(value => news.keys.includes(value)))\n}\n"],"mappings":"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","names":["clsx","clsx","jsx","jsxs","jsx","useEffect","useState","ChevronDown","useEffect","useState","jsx","clsx","clsx","jsx","jsxs","useEffect","useState","clsx","useState","clsx","jsx","jsxs","jsx","clsx","useEffect","useState","jsx","jsxs","jsx","jsxs","jsx","useEffect","useRef","useState","Scrollbars","clsx","jsx","jsxs","clsx","useEffect","useRef","useState","clsx","useEffect","useState","clsx","jsx","jsxs","jsx","jsxs","jsx","jsxs","Image","clsx","jsx","jsxs","clsx","jsx","useCallback","useEffect","useState","clsx","jsx","jsxs","Image","jsx","clsx","jsx","jsxs","useCallback","useEffect","useRef","useState","clsx","jsx","jsxs","clsx","jsx","jsxs","clsx","jsx","clsx","ChevronDown","ChevronUp","Fragment","jsx","jsx","ChevronLeft","ChevronRight","clsx","jsx","jsxs","useEffect","useMemo","useState","clsx","forwardRef","useEffect","useRef","useState","clsx","useEffect","useState","clsx","jsx","jsx","jsxs","forwardRef","FormInput","jsx","clsx","jsxs","jsx","jsxs","ChevronLeft","ChevronRight","clsx","jsx","jsxs","useEffect","useRef","useState","Scrollbars","useState","Check","clsx","jsx","jsxs","clsx","ChevronDown","ChevronUp","jsx","jsxs","clsx","jsx","jsxs","jsx","jsxs","clsx","jsx","jsxs","useState","clsx","jsx","jsxs","jsx","clsx","jsx","jsxs","jsx","jsxs","clsx","jsx","jsxs","jsx","jsx","ChevronDown","ChevronUp","Search","useEffect","useState","clsx","Fragment","jsx","jsxs","jsx","jsxs","createContext","useContext","useEffect","useState","jsx","createContext","jsx","jsxs","Check","clsx","jsx","jsxs","jsx","clsx","jsx","clsx","useState","Search","clsx","useRef","clsx","useEffect","jsx","jsxs","jsx","jsxs","jsx","clsx","jsx","jsxs","List","clsx","jsx","clsx","useEffect","useState","clsx","jsx","jsxs","jsx","clsx","jsx","jsxs","useCallback","useEffect","useState","clsx","jsx","jsxs","useEffect","useRef","useState","clsx","jsx","jsxs","current"]}
|
|
1
|
+
{"version":3,"sources":["../../src/coloring/shading.ts","../../src/coloring/types.ts","../../src/components/branding/HelpwaveBadge.tsx","../../src/components/layout-and-navigation/Tile.tsx","../../src/components/icons-and-geometry/Helpwave.tsx","../../src/components/date/DatePicker.tsx","../../src/localization/LanguageProvider.tsx","../../src/hooks/useLocalStorage.ts","../../src/localization/util.ts","../../src/util/noop.ts","../../src/components/user-action/Button.tsx","../../src/components/date/YearMonthPicker.tsx","../../src/components/layout-and-navigation/Expandable.tsx","../../src/components/date/DayPicker.tsx","../../src/components/date/TimeDisplay.tsx","../../src/components/date/TimePicker.tsx","../../src/components/dialogs/ConfirmDialog.tsx","../../src/components/layout-and-navigation/Overlay.tsx","../../src/hooks/useHoverState.ts","../../src/components/user-action/Tooltip.tsx","../../src/components/icons-and-geometry/Avatar.tsx","../../src/components/icons-and-geometry/Circle.tsx","../../src/components/icons-and-geometry/Ring.tsx","../../src/components/icons-and-geometry/Tag.tsx","../../src/components/layout-and-navigation/BreadCrumb.tsx","../../src/components/layout-and-navigation/Carousel.tsx","../../src/components/layout-and-navigation/Chip.tsx","../../src/components/layout-and-navigation/DividerInserter.tsx","../../src/components/layout-and-navigation/FAQSection.tsx","../../src/components/layout-and-navigation/MarkdownInterpreter.tsx","../../src/components/layout-and-navigation/Pagination.tsx","../../src/components/layout-and-navigation/SearchableList.tsx","../../src/components/user-action/Input.tsx","../../src/hooks/useSaveDelay.ts","../../src/components/user-action/Label.tsx","../../src/components/layout-and-navigation/StepperBar.tsx","../../src/components/layout-and-navigation/Table.tsx","../../src/components/user-action/Checkbox.tsx","../../src/components/layout-and-navigation/TextImage.tsx","../../src/components/layout-and-navigation/VerticalDivider.tsx","../../src/components/loading-states/ErrorComponent.tsx","../../src/components/loading-states/LoadingAndErrorComponent.tsx","../../src/components/loading-states/LoadingAnimation.tsx","../../src/components/loading-states/LoadingButton.tsx","../../src/components/loading-states/ProgressIndicator.tsx","../../src/components/modals/ConfirmModal.tsx","../../src/components/modals/DiscardChangesModal.tsx","../../src/components/modals/InputModal.tsx","../../src/components/user-action/Select.tsx","../../src/components/modals/LanguageModal.tsx","../../src/theming/useTheme.tsx","../../src/components/modals/ThemeModal.tsx","../../src/components/properties/CheckboxProperty.tsx","../../src/components/properties/PropertyBase.tsx","../../src/components/properties/DateProperty.tsx","../../src/components/properties/MultiSelectProperty.tsx","../../src/components/user-action/MultiSelect.tsx","../../src/components/user-action/Menu.tsx","../../src/hooks/useOutsideClick.ts","../../src/components/properties/NumberProperty.tsx","../../src/components/properties/SelectProperty.tsx","../../src/components/properties/TextProperty.tsx","../../src/components/user-action/Textarea.tsx","../../src/components/user-action/DateAndTimePicker.tsx","../../src/components/user-action/ScrollPicker.tsx","../../src/components/user-action/ToggleableInput.tsx","../../src/util/news.ts"],"sourcesContent":["import tinycolor from 'tinycolor2'\nimport type { ShadedColors } from '@/index'\nimport { shadingColorValues } from '@/index'\n\n// Function to generate a full shading of several colors\nexport const generateShadingColors = (partialShading: Omit<Partial<ShadedColors>, '0' | '1000'>): ShadedColors => {\n const shading: ShadedColors = {\n 0: '#FFFFFF',\n 1000: '#000000'\n } as ShadedColors\n\n let index = 1\n while (index < shadingColorValues.length - 1) {\n const previous = shadingColorValues[index - 1]!\n const current = shadingColorValues[index]!\n\n if (partialShading[current] !== undefined) {\n shading[current] = partialShading[current]\n index++\n continue\n }\n\n let j: number = index + 1\n while (j < shadingColorValues.length) {\n if (partialShading[shadingColorValues[j]!] !== undefined) {\n break\n }\n j++\n }\n if (j === shadingColorValues.length) {\n j = shadingColorValues.length - 1\n }\n\n const nextFound = shadingColorValues[j]!\n const interval = nextFound - previous\n for (let k = index; k < j; k++) {\n const current = shadingColorValues[k]!\n const previousValue = partialShading[previous] ?? shading[previous]\n const nextValue = partialShading[nextFound] ?? shading[nextFound]\n shading[current] = tinycolor.mix(tinycolor(previousValue), tinycolor(nextValue), (current - previous) / interval * 100).toHexString()\n }\n index = j\n }\n\n return shading\n}\n","export const shadingColorValues = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000] as const\nexport type ColorShadingValue = typeof shadingColorValues[number]\nexport type ShadedColors = Record<ColorShadingValue, string>\n\nexport type ColoringStyle = 'background' | 'tonal' | 'tonal-opaque' | 'text' | 'text-border'\nexport type ColorMode = 'light' | 'dark'\n\nexport type Coloring = {\n color: '',\n style?: ColoringStyle,\n mode?: ColorMode,\n hover?: boolean,\n}\n","import clsx from 'clsx'\nimport { Tile } from '@/components/layout-and-navigation/Tile'\nimport { Helpwave } from '@/components/icons-and-geometry/Helpwave'\n\ntype Size = 'small' | 'large'\n\nexport type HelpwaveBadgeProps = {\n size?: Size,\n title?: string,\n className?: string,\n}\n\n/**\n * A Badge with the helpwave logo and the helpwave name\n */\nexport const HelpwaveBadge = ({\n size = 'small',\n title = 'helpwave',\n className = ''\n }: HelpwaveBadgeProps) => {\n const iconSize: number = size === 'small' ? 24 : 64\n\n return (\n <Tile\n prefix={(<Helpwave size={iconSize}/>)}\n title={{ value: title, className: size === 'small' ? 'textstyle-title-lg text-base' : 'textstyle-title-xl' }}\n className={clsx(\n {\n 'px-2 py-1 rounded-md': size === 'small',\n 'px-4 py-1 rounded-md': size === 'large',\n }, className\n )}\n />\n )\n}\n","import type { ReactNode } from 'react'\nimport Image from 'next/image'\nimport clsx from 'clsx'\n\nexport type TileProps = {\n title: { value: string, className?: string },\n description?: { value: string, className?: string },\n prefix?: ReactNode,\n suffix?: ReactNode,\n className?: string,\n}\n\n/**\n * A component for creating a tile similar to the flutter ListTile\n */\nexport const Tile = ({\n title,\n description,\n prefix,\n suffix,\n className\n }: TileProps) => {\n return (\n <div className={clsx('row gap-x-4 w-full items-center', className)}>\n {prefix}\n <div className=\"col w-full\">\n <span className={clsx(title.className)}>{title.value}</span>\n {!!description &&\n <span className={clsx(description.className ?? 'textstyle-description')}>{description.value}</span>}\n </div>\n {suffix}\n </div>\n )\n}\n\ntype ImageLocation = 'prefix' | 'suffix'\ntype ImageSize = {\n width: number,\n height: number,\n}\n\nexport type TileWithImageProps = Omit<TileProps, 'suffix' | 'prefix'> & {\n url: string,\n imageLocation?: ImageLocation,\n imageSize?: ImageSize,\n imageClassName?: string,\n}\n\n/**\n * A Tile with an image as prefix or suffix\n */\nexport const TileWithImage = ({\n url,\n imageLocation = 'prefix',\n imageSize = { width: 24, height: 24 },\n imageClassName = '',\n ...tileProps\n }: TileWithImageProps) => {\n const image = <Image src={url} alt=\"\" {...imageSize} className={clsx(imageClassName)}/>\n return (\n <Tile\n {...tileProps}\n prefix={imageLocation === 'prefix' ? image : undefined}\n suffix={imageLocation === 'suffix' ? image : undefined}\n />\n )\n}\n","import type { SVGProps } from 'react'\nimport { clsx } from 'clsx'\n\nexport type HelpwaveProps = SVGProps<SVGSVGElement> & {\n color?: string,\n animate?: 'none' | 'loading' | 'pulse' | 'bounce',\n size?: number,\n}\n\n/**\n * The helpwave loading spinner based on the svg logo.\n */\nexport const Helpwave = ({\n color = 'currentColor',\n animate = 'none',\n size = 64,\n ...props\n }: HelpwaveProps) => {\n const isLoadingAnimation = animate === 'loading'\n let svgAnimationKey = ''\n\n if (animate === 'pulse') {\n svgAnimationKey = 'animate-pulse'\n } else if (animate === 'bounce') {\n svgAnimationKey = 'animate-bounce'\n }\n\n if (size < 0) {\n console.error('size cannot be less than 0')\n size = 64\n }\n\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 888 888\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={48}\n {...props}\n >\n <g className={clsx(svgAnimationKey)}>\n <path className={clsx({ 'animate-wave-big-left-up': isLoadingAnimation })}\n d=\"M144 543.235C144 423.259 232.164 326 340.92 326\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-big-right-down': isLoadingAnimation })}\n d=\"M537.84 544.104C429.084 544.104 340.92 446.844 340.92 326.869\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-left-up': isLoadingAnimation })}\n d=\"M462.223 518.035C462.223 432.133 525.348 362.495 603.217 362.495\" stroke={color}\n strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-right-down': isLoadingAnimation })}\n d=\"M745.001 519.773C666.696 519.773 603.218 450.136 603.218 364.233\" stroke={color}\n strokeDasharray=\"1000\"/>\n </g>\n </svg>\n )\n}\n","import { useEffect, useState } from 'react'\nimport { ArrowDown, ArrowUp, ChevronDown } from 'lucide-react'\nimport type { Language } from '@/localization/util'\nimport { useLocale } from '@/localization/LanguageProvider'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { noop } from '@/util/noop'\nimport { addDuration, isInTimeSpan, subtractDuration } from '@/util/date'\nimport clsx from 'clsx'\nimport { SolidButton, TextButton } from '../user-action/Button'\nimport type { YearMonthPickerProps } from './YearMonthPicker'\nimport { YearMonthPicker } from './YearMonthPicker'\nimport type { DayPickerProps } from './DayPicker'\nimport { DayPicker } from './DayPicker'\n\ntype DatePickerTranslation = {\n today: string,\n}\n\nconst defaultDatePickerTranslation: Record<Language, DatePickerTranslation> = {\n en: {\n today: 'Today',\n },\n de: {\n today: 'Heute',\n }\n}\n\ntype DisplayMode = 'yearMonth' | 'day'\n\nexport type DatePickerProps = {\n value?: Date,\n start?: Date,\n end?: Date,\n initialDisplay?: DisplayMode,\n onChange?: (date: Date) => void,\n dayPickerProps?: Omit<DayPickerProps, 'displayedMonth' | 'onChange' | 'selected'>,\n yearMonthPickerProps?: Omit<YearMonthPickerProps, 'displayedYearMonth' | 'onChange' | 'start' | 'end'>,\n className?: string,\n}\n\n/**\n * A Component for picking a date\n */\nexport const DatePicker = ({\n overwriteTranslation,\n value = new Date(),\n start = subtractDuration(new Date(), { years: 50 }),\n end = addDuration(new Date(), { years: 50 }),\n initialDisplay = 'day',\n onChange = noop,\n yearMonthPickerProps,\n dayPickerProps,\n className = ''\n }: PropsForTranslation<DatePickerTranslation, DatePickerProps>) => {\n const locale = useLocale()\n const translation = useTranslation(defaultDatePickerTranslation, overwriteTranslation)\n const [displayedMonth, setDisplayedMonth] = useState<Date>(value)\n const [displayMode, setDisplayMode] = useState<DisplayMode>(initialDisplay)\n\n useEffect(() => {\n setDisplayedMonth(value)\n }, [value])\n\n return (\n <div className={clsx('col gap-y-4', className)}>\n <div className=\"row items-center justify-between h-7\">\n <TextButton\n className={clsx('row gap-x-1 items-center cursor-pointer select-none', {\n 'text-disabled-text': displayMode !== 'day',\n })}\n onClick={() => setDisplayMode(displayMode === 'day' ? 'yearMonth' : 'day')}\n >\n {`${new Intl.DateTimeFormat(locale, { month: 'long' }).format(displayedMonth)} ${displayedMonth.getFullYear()}`}\n <ChevronDown size={16}/>\n </TextButton>\n {displayMode === 'day' && (\n <div className=\"row justify-end\">\n <SolidButton\n size=\"small\"\n color=\"primary\"\n disabled={!isInTimeSpan(subtractDuration(displayedMonth, { months: 1 }), start, end)}\n onClick={() => {\n setDisplayedMonth(subtractDuration(displayedMonth, { months: 1 }))\n }}\n >\n <ArrowUp size={20}/>\n </SolidButton>\n <SolidButton\n size=\"small\"\n color=\"primary\"\n disabled={!isInTimeSpan(addDuration(displayedMonth, { months: 1 }), start, end)}\n onClick={() => {\n setDisplayedMonth(addDuration(displayedMonth, { months: 1 }))\n }}\n >\n <ArrowDown size={20}/>\n </SolidButton>\n </div>\n )}\n </div>\n {displayMode === 'yearMonth' ? (\n <YearMonthPicker\n {...yearMonthPickerProps}\n displayedYearMonth={value}\n start={start}\n end={end}\n onChange={newDate => {\n setDisplayedMonth(newDate)\n setDisplayMode('day')\n }}\n />\n ) : (\n <div>\n <DayPicker\n {...dayPickerProps}\n displayedMonth={displayedMonth}\n start={start}\n end={end}\n selected={value}\n onChange={date => {\n onChange(date)\n }}\n />\n <div className=\"mt-2\">\n <TextButton\n onClick={() => {\n const newDate = new Date()\n newDate.setHours(value.getHours(), value.getMinutes())\n onChange(newDate)\n }}\n >\n {translation.today}\n </TextButton>\n </div>\n </div>\n )}\n </div>\n )\n}\n\n/**\n * Example for the Date Picker\n */\nexport const DatePickerUncontrolled = ({\n value = new Date(),\n onChange = noop,\n ...props\n }: DatePickerProps) => {\n const [date, setDate] = useState<Date>(value)\n\n useEffect(() => setDate(value), [value])\n\n return (\n <DatePicker\n {...props}\n value={date}\n onChange={date1 => {\n setDate(date1)\n onChange(date1)\n }}\n />\n )\n}\n","import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport { useLocalStorage } from '@/hooks/useLocalStorage'\nimport type { Language } from './util'\nimport { LanguageUtil } from './util'\n\nexport type LanguageContextValue = {\n language: Language,\n setLanguage: Dispatch<SetStateAction<Language>>,\n}\n\nexport const LanguageContext = createContext<LanguageContextValue>({\n language: LanguageUtil.DEFAULT_LANGUAGE,\n setLanguage: (v) => v\n})\n\nexport const useLanguage = () => useContext(LanguageContext)\n\nexport const useLocale = (overWriteLanguage?: Language) => {\n const { language } = useLanguage()\n const mapping: Record<Language, string> = {\n en: 'en-US',\n de: 'de-DE'\n }\n return mapping[overWriteLanguage ?? language]\n}\n\ntype LanguageProviderProps = {\n initialLanguage?: Language,\n}\n\nexport const LanguageProvider = ({ initialLanguage, children }: PropsWithChildren<LanguageProviderProps>) => {\n const [language, setLanguage] = useState<Language>(initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n const [storedLanguage, setStoredLanguage] = useLocalStorage<Language>('language', initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n\n useEffect(() => {\n if (language !== initialLanguage && initialLanguage) {\n console.warn('LanguageProvider initial state changed: Prefer using languageProvider\\'s setLanguage instead')\n setLanguage(initialLanguage)\n }\n }, [initialLanguage]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n // TODO set locale of html tag here as well\n setStoredLanguage(language)\n }, [language, setStoredLanguage])\n\n useEffect(() => {\n if (storedLanguage !== null) {\n setLanguage(storedLanguage)\n return\n }\n\n const LanguageToTestAgainst = Object.values(LanguageUtil.languages)\n\n const matchingBrowserLanguage = window.navigator.languages\n .map(language => LanguageToTestAgainst.find((test) => language === test || language.split('-')[0] === test))\n .filter(entry => entry !== undefined)\n\n if (matchingBrowserLanguage.length === 0) return\n\n const firstMatch = matchingBrowserLanguage[0] as Language\n setLanguage(firstMatch)\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <LanguageContext.Provider value={{\n language,\n setLanguage\n }}>\n {children}\n </LanguageContext.Provider>\n )\n}","import type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { LocalStorageService } from '../util/storage'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(value => {\n const newValue = value instanceof Function ? value(storedValue) : value\n const storageService = new LocalStorageService()\n storageService.set(key, value)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n useEffect(() => {\n setStoredValue(get())\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return [storedValue, setValue]\n}","/**\n * The supported languages\n */\nconst languages = ['en', 'de'] as const\n\n/**\n * The supported languages\n */\nexport type Language = typeof languages[number]\n\n/**\n * The supported languages' names in their respective language\n */\nconst languagesLocalNames: Record<Language, string> = {\n en: 'English',\n de: 'Deutsch',\n}\n\n/**\n * The default language\n */\nconst DEFAULT_LANGUAGE: Language = 'en'\n\n/**\n * A constant definition for holding data regarding languages\n */\nexport const LanguageUtil = {\n languages,\n DEFAULT_LANGUAGE,\n languagesLocalNames,\n}","export const noop = () => undefined\n","import type { ButtonHTMLAttributes, PropsWithChildren, ReactNode } from 'react'\nimport clsx from 'clsx'\n\n\nexport const ButtonColorUtil = {\n solid: ['primary', 'secondary', 'tertiary', 'positive', 'warning', 'negative', 'neutral'] as const,\n text: ['primary', 'negative', 'neutral'] as const,\n outline: ['primary'] as const,\n}\n\n\n/**\n * The allowed colors for the SolidButton and IconButton\n */\nexport type SolidButtonColor = typeof ButtonColorUtil.solid[number]\n/**\n * The allowed colors for the OutlineButton\n */\nexport type OutlineButtonColor = typeof ButtonColorUtil.outline[number]\n/**\n * The allowed colors for the TextButton\n */\nexport type TextButtonColor = typeof ButtonColorUtil.text[number]\n\n/**\n * The different sizes for a button\n */\ntype ButtonSizes = 'small' | 'medium' | 'large'\n\n/**\n * The shard properties between all button types\n */\nexport type ButtonProps = PropsWithChildren<{\n /**\n * @default 'medium'\n */\n size?: ButtonSizes,\n}> & ButtonHTMLAttributes<Element>\n\nconst paddingMapping: Record<ButtonSizes, string> = {\n small: 'btn-sm',\n medium: 'btn-md',\n large: 'btn-lg'\n}\n\nconst iconPaddingMapping: Record<ButtonSizes, string> = {\n small: 'icon-btn-sm',\n medium: 'icon-btn-md',\n large: 'icon-btn-lg'\n}\n\nexport const ButtonUtil = {\n paddingMapping,\n iconPaddingMapping\n}\n\ntype ButtonWithIconsProps = ButtonProps & {\n startIcon?: ReactNode,\n endIcon?: ReactNode,\n}\n\nexport type SolidButtonProps = ButtonWithIconsProps & {\n color?: SolidButtonColor,\n}\n\nexport type OutlineButtonProps = ButtonWithIconsProps & {\n color?: OutlineButtonColor,\n}\n\nexport type TextButtonProps = ButtonWithIconsProps & {\n color?: TextButtonColor,\n}\n\nexport type IconButtonProps = ButtonProps & {\n color?: SolidButtonColor,\n}\n\n/**\n * A button with a solid background and different sizes\n */\nconst SolidButton = ({\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n startIcon,\n endIcon,\n onClick,\n className,\n ...restProps\n }: SolidButtonProps) => {\n const colorClasses = {\n primary: 'bg-button-solid-primary-background text-button-solid-primary-text',\n secondary: 'bg-button-solid-secondary-background text-button-solid-secondary-text',\n tertiary: 'bg-button-solid-tertiary-background text-button-solid-tertiary-text',\n positive: 'bg-button-solid-positive-background text-button-solid-positive-text',\n warning: 'bg-button-solid-warning-background text-button-solid-warning-text',\n negative: 'bg-button-solid-negative-background text-button-solid-negative-text',\n neutral: 'bg-button-solid-neutral-background text-button-solid-neutral-text',\n }[color]\n\n const iconColorClasses = {\n primary: 'text-button-solid-primary-icon',\n secondary: 'text-button-solid-secondary-icon',\n tertiary: 'text-button-solid-tertiary-icon',\n positive: 'text-button-solid-positive-icon',\n warning: 'text-button-solid-warning-icon',\n negative: 'text-button-solid-negative-icon',\n neutral: 'text-button-solid-neutral-icon',\n }[color]\n\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className,\n {\n 'text-disabled-text bg-disabled-background': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.paddingMapping[size]\n )}\n {...restProps}\n >\n {startIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {startIcon}\n </span>\n )}\n {children}\n {endIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {endIcon}\n </span>\n )}\n </button>\n )\n}\n\n/**\n * A button with an outline border and different sizes\n */\nconst OutlineButton = ({\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n startIcon,\n endIcon,\n onClick,\n className,\n ...restProps\n }: OutlineButtonProps) => {\n const colorClasses = {\n primary: 'bg-transparent border-2 border-button-outline-primary-text text-button-outline-primary-text',\n }[color]\n\n const iconColorClasses = {\n primary: 'text-button-outline-primary-icon',\n }[color]\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className, {\n 'text-disabled-text border-disabled-outline': disabled,\n [clsx(colorClasses, 'hover:brightness-80')]: !disabled,\n },\n ButtonUtil.paddingMapping[size]\n )}\n {...restProps}\n >\n {startIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {startIcon}\n </span>\n )}\n {children}\n {endIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {endIcon}\n </span>\n )}\n </button>\n )\n}\n\n/**\n * A text that is a button that can have different sizes\n */\nconst TextButton = ({\n children,\n disabled = false,\n color = 'neutral',\n size = 'medium',\n startIcon,\n endIcon,\n onClick,\n className,\n ...restProps\n }: TextButtonProps) => {\n const colorClasses = {\n primary: 'bg-transparent text-button-text-primary-text',\n negative: 'bg-transparent text-button-text-negative-text',\n neutral: 'bg-transparent text-button-text-neutral-text',\n }[color]\n\n const iconColorClasses = {\n primary: 'text-button-text-primary-icon',\n negative: 'text-button-text-negative-icon',\n neutral: 'text-button-text-neutral-icon',\n }[color]\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className, {\n 'text-disabled-text': disabled,\n [clsx(colorClasses, 'hover:bg-button-text-hover-background rounded-full')]: !disabled,\n },\n ButtonUtil.paddingMapping[size]\n )}\n {...restProps}\n >\n {startIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {startIcon}\n </span>\n )}\n {children}\n {endIcon && (\n <span\n className={clsx({\n [iconColorClasses]: !disabled,\n [`text-disabled-icon`]: disabled\n })}\n >\n {endIcon}\n </span>\n )}\n </button>\n )\n}\n\n\n/**\n * A button for icons with a solid background and different sizes\n */\nconst IconButton = ({\n children,\n disabled = false,\n color = 'primary',\n size = 'medium',\n onClick,\n className,\n ...restProps\n }: IconButtonProps) => {\n const colorClasses = {\n primary: 'bg-button-solid-primary-background text-button-solid-primary-text',\n secondary: 'bg-button-solid-secondary-background text-button-solid-secondary-text',\n tertiary: 'bg-button-solid-tertiary-background text-button-solid-tertiary-text',\n positive: 'bg-button-solid-positive-background text-button-solid-positive-text',\n warning: 'bg-button-solid-warning-background text-button-solid-warning-text',\n negative: 'bg-button-solid-negative-background text-button-solid-negative-text',\n neutral: 'bg-button-solid-neutral-background text-button-solid-neutral-text',\n }[color]\n\n return (\n <button\n onClick={disabled ? undefined : onClick}\n disabled={disabled || onClick === undefined}\n className={clsx(\n className,\n {\n 'text-disabled-text bg-disabled-background': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.iconPaddingMapping[size]\n )}\n {...restProps}\n >\n {children}\n </button>\n )\n}\n\nexport { SolidButton, OutlineButton, TextButton, IconButton }\n","import { useEffect, useRef, useState } from 'react'\nimport { Scrollbars } from 'react-custom-scrollbars-2'\nimport { noop } from '@/util/noop'\nimport { equalSizeGroups, range } from '@/util/array'\nimport clsx from 'clsx'\nimport { Expandable } from '@/components/layout-and-navigation/Expandable'\nimport { addDuration, monthsList, subtractDuration } from '@/util/date'\nimport { useLocale } from '@/localization/LanguageProvider'\n\nexport type YearMonthPickerProps = {\n displayedYearMonth?: Date,\n start?: Date,\n end?: Date,\n onChange?: (date: Date) => void,\n className?: string,\n maxHeight?: number,\n showValueOpen?: boolean,\n}\n\n// TODO use a dynamically loading infinite list here\nexport const YearMonthPicker = ({\n displayedYearMonth = new Date(),\n start = subtractDuration(new Date(), { years: 50 }),\n end = addDuration(new Date(), { years: 50 }),\n onChange = noop,\n className = '',\n maxHeight = 300,\n showValueOpen = true\n }: YearMonthPickerProps) => {\n const locale = useLocale()\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n const scrollToItem = () => {\n if (ref.current) {\n ref.current.scrollIntoView({\n behavior: 'instant',\n block: 'center',\n })\n }\n }\n\n scrollToItem()\n }, [ref])\n\n if (end < start) {\n console.error(`startYear: (${start}) less than endYear: (${end})`)\n return null\n }\n\n const years = range(start.getFullYear(), end.getFullYear())\n\n return (\n <div className={clsx('col select-none', className)}>\n <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>\n <div className=\"col gap-y-1 mr-3\">\n {years.map(year => {\n const selectedYear = displayedYearMonth.getFullYear() === year\n return (\n <Expandable\n key={year}\n ref={(displayedYearMonth.getFullYear() ?? new Date().getFullYear()) === year ? ref : undefined}\n label={<span className={clsx({ 'text-primary font-bold': selectedYear })}>{year}</span>}\n initialExpansion={showValueOpen && selectedYear}\n >\n <div className=\"col gap-y-1 px-2 pb-2\">\n {equalSizeGroups([...monthsList], 3).map((monthList, index) => (\n <div key={index} className=\"row\">\n {monthList.map(month => {\n const monthIndex = monthsList.indexOf(month)\n const newDate = new Date(year, monthIndex)\n\n const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth()\n const firstOfMonth = new Date(year, monthIndex, 1)\n const lastOfMonth = new Date(year, monthIndex, 1)\n const isAfterStart = start === undefined || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 })\n const isBeforeEnd = end === undefined || firstOfMonth <= end\n const isValid = isAfterStart && isBeforeEnd\n return (\n <button\n key={month}\n disabled={!isValid}\n className={clsx(\n 'chip hover:brightness-95 flex-1',\n {\n 'bg-gray-50 text-black': !selectedMonth && isValid,\n 'bg-primary text-on-primary': selectedMonth && isValid,\n 'bg-disabled-background text-disabled-text': !isValid\n }\n )}\n onClick={() => {\n onChange(newDate)\n }}\n >\n {new Intl.DateTimeFormat(locale, { month: 'short' }).format(newDate)}\n </button>\n )\n })}\n </div>\n ))}\n </div>\n </Expandable>\n )\n })}\n </div>\n </Scrollbars>\n </div>\n )\n}\n\nexport const YearMonthPickerUncontrolled = ({\n displayedYearMonth = new Date(),\n onChange = noop,\n ...props\n }: YearMonthPickerProps) => {\n const [yearMonth, setYearMonth] = useState<Date>(displayedYearMonth)\n\n useEffect(() => setYearMonth(displayedYearMonth), [displayedYearMonth])\n\n return (\n <YearMonthPicker\n displayedYearMonth={yearMonth}\n onChange={date => {\n setYearMonth(date)\n onChange(date)\n }}\n {...props}\n />\n )\n}\n","import type { PropsWithChildren, ReactNode } from 'react'\nimport { forwardRef, useState } from 'react'\nimport { ChevronDown, ChevronUp } from 'lucide-react'\nimport clsx from 'clsx'\n\ntype IconBuilder = (expanded: boolean) => ReactNode\n\nexport type ExpandableProps = PropsWithChildren<{\n label: ReactNode,\n icon?: IconBuilder,\n initialExpansion?: boolean,\n /**\n * Whether the expansion should only happen when the header is clicked or on the entire component\n */\n clickOnlyOnHeader?: boolean,\n disabled?: boolean,\n className?: string,\n headerClassName?: string,\n}>\n\nconst DefaultIcon: IconBuilder = (expanded) => expanded ?\n (<ChevronUp size={16} className=\"min-w-[16px]\"/>)\n : (<ChevronDown size={16} className=\"min-w-[16px]\"/>)\n\n/**\n * A Component for showing and hiding content\n */\nexport const Expandable = forwardRef<HTMLDivElement, ExpandableProps>(({\n children,\n label,\n icon,\n initialExpansion = false,\n clickOnlyOnHeader = true,\n disabled = false,\n className = '',\n headerClassName = ''\n }, ref) => {\n const [isExpanded, setIsExpanded] = useState(initialExpansion)\n icon ??= DefaultIcon\n\n return (\n <div\n ref={ref}\n className={clsx('col gap-y-0 bg-surface text-on-surface group rounded-lg shadow-sm', { 'cursor-pointer': !clickOnlyOnHeader && !disabled }, className)}\n onClick={() => !clickOnlyOnHeader && !disabled && setIsExpanded(!isExpanded)}\n >\n <div\n className={clsx(\n 'row py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none',\n {\n 'group-hover:brightness-95': !isExpanded,\n 'hover:brightness-95': isExpanded && !disabled,\n 'cursor-pointer': clickOnlyOnHeader && !disabled,\n },\n headerClassName\n )}\n onClick={() => clickOnlyOnHeader && !disabled && setIsExpanded(!isExpanded)}\n >\n {label}\n {icon(isExpanded)}\n </div>\n {isExpanded && (\n <div className=\"col px-4 pb-2\">\n {children}\n </div>\n )}\n </div>\n )\n})\n\nExpandable.displayName = 'Expandable'\n","import type { WeekDay } from '@/util/date'\nimport { equalDate, getWeeksForCalenderMonth, isInTimeSpan } from '@/util/date'\nimport { noop } from '@/util/noop'\nimport clsx from 'clsx'\nimport { useLocale } from '@/localization/LanguageProvider'\nimport { useEffect, useState } from 'react'\n\nexport type DayPickerProps = {\n displayedMonth: Date,\n selected?: Date,\n start?: Date,\n end?: Date,\n onChange?: (date: Date) => void,\n weekStart?: WeekDay,\n markToday?: boolean,\n className?: string,\n}\n\n/**\n * A component for selecting a day of a month\n */\nexport const DayPicker = ({\n displayedMonth,\n selected,\n start,\n end,\n onChange = noop,\n weekStart = 'monday',\n markToday = true,\n className = ''\n }: DayPickerProps) => {\n const locale = useLocale()\n const month = displayedMonth.getMonth()\n const weeks = getWeeksForCalenderMonth(displayedMonth, weekStart)\n\n return (\n <div className={clsx('col gap-y-1 min-w-[220px] select-none', className)}>\n <div className=\"row text-center\">\n {weeks[0]!.map((weekDay, index) => (\n <div key={index} className=\"flex-1 font-semibold\">\n {new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(weekDay).substring(0, 2)}\n </div>\n ))}\n </div>\n {weeks.map((week, index) => (\n <div key={index} className=\"row text-center\">\n {week.map((date) => {\n const isSelected = !!selected && equalDate(selected, date)\n const isToday = equalDate(new Date(), date)\n const isSameMonth = date.getMonth() === month\n const isDayValid = isInTimeSpan(date, start, end)\n return (\n <button\n disabled={!isDayValid}\n key={date.getDate()}\n className={clsx(\n 'flex-1 rounded-full border-2 border-transparent shadow-sm',\n {\n 'text-gray-700 bg-gray-100': !isSameMonth && isDayValid,\n 'text-black bg-white': !isSelected && isSameMonth && isDayValid,\n 'text-on-primary bg-primary': isSelected,\n 'border-black': isToday && markToday,\n 'hover:brightness-90 hover:bg-primary hover:text-on-primary': isDayValid,\n 'text-disabled-text bg-disabled-background': !isDayValid\n }\n )}\n onClick={() => onChange(date)}\n >\n {date.getDate()}\n </button>\n )\n })}\n </div>\n ))}\n </div>\n )\n}\n\nexport const DayPickerUncontrolled = ({ displayedMonth, onChange = noop, ...restProps }: DayPickerProps) => {\n const [date, setDate] = useState(displayedMonth)\n\n useEffect(() => setDate(displayedMonth), [displayedMonth])\n\n return (\n <DayPicker\n displayedMonth={date}\n onChange={newDate => {\n setDate(newDate)\n onChange(newDate)\n }}\n {...restProps}\n />\n )\n}\n","import type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\n\ntype TimeDisplayTranslation = {\n today: string,\n yesterday: string,\n tomorrow: string,\n inDays: (days: number) => string,\n agoDays: (days: number) => string,\n january: string,\n february: string,\n march: string,\n april: string,\n may: string,\n june: string,\n july: string,\n august: string,\n september: string,\n october: string,\n november: string,\n december: string,\n}\n\nconst defaultTimeDisplayTranslations: Record<Language, TimeDisplayTranslation> = {\n en: {\n today: 'today',\n yesterday: 'yesterday',\n tomorrow: 'tomorrow',\n inDays: (days: number) => `in ${days} days`,\n agoDays: (days: number) => `${days} days ago`,\n january: 'January',\n february: 'February',\n march: 'March',\n april: 'April',\n may: 'May',\n june: 'June',\n july: 'July',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December'\n },\n de: {\n today: 'heute',\n yesterday: 'gestern',\n tomorrow: 'morgen',\n inDays: (days: number) => `in ${days} Tagen`,\n agoDays: (days: number) => `vor ${days} Tagen`,\n january: 'Januar',\n february: 'Februar',\n march: 'März',\n april: 'April',\n may: 'Mai',\n june: 'Juni',\n july: 'Juli',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December'\n }\n}\n\ntype TimeDisplayMode = 'daysFromToday' | 'date'\n\ntype TimeDisplayProps = {\n date: Date,\n mode?: TimeDisplayMode,\n}\n\n/**\n * A Component for displaying time and dates in a unified fashion\n */\nexport const TimeDisplay = ({\n overwriteTranslation,\n date,\n mode = 'daysFromToday'\n }: PropsForTranslation<TimeDisplayTranslation, TimeDisplayProps>) => {\n const translation = useTranslation(defaultTimeDisplayTranslations, overwriteTranslation)\n const difference = new Date().setHours(0, 0, 0, 0).valueOf() - new Date(date).setHours(0, 0, 0, 0).valueOf()\n const isBefore = difference > 0\n const differenceInDays = Math.floor(Math.abs(difference) / (1000 * 3600 * 24))\n\n let displayString\n if (differenceInDays === 0) {\n displayString = translation.today\n } else if (differenceInDays === 1) {\n displayString = isBefore ? translation.yesterday : translation.tomorrow\n } else {\n displayString = isBefore ? translation.agoDays(differenceInDays) : translation.inDays(differenceInDays)\n }\n const monthToTranslation: { [key: number]: string } = {\n 0: translation.january,\n 1: translation.february,\n 2: translation.march,\n 3: translation.april,\n 4: translation.may,\n 5: translation.june,\n 6: translation.july,\n 7: translation.august,\n 8: translation.september,\n 9: translation.october,\n 10: translation.november,\n 11: translation.december\n } as const\n\n let fullString\n if (mode === 'daysFromToday') {\n fullString = `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')} - ${displayString}`\n } else {\n fullString = `${date.getDate()}. ${monthToTranslation[date.getMonth()]} ${date.getFullYear()}`\n }\n\n return (\n <span>\n {fullString}\n </span>\n )\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { Scrollbars } from 'react-custom-scrollbars-2'\nimport { noop } from '@/util/noop'\nimport { closestMatch, range } from '@/util/array'\nimport clsx from 'clsx'\n\ntype MinuteIncrement = '1min' | '5min' | '10min' | '15min' | '30min'\n\nexport type TimePickerProps = {\n time?: Date,\n onChange?: (time: Date) => void,\n is24HourFormat?: boolean,\n minuteIncrement?: MinuteIncrement,\n maxHeight?: number,\n className?: string,\n}\n\nexport const TimePicker = ({\n time = new Date(),\n onChange = noop,\n is24HourFormat = true,\n minuteIncrement = '5min',\n maxHeight = 300,\n className = ''\n }: TimePickerProps) => {\n const minuteRef = useRef<HTMLButtonElement>(null)\n const hourRef = useRef<HTMLButtonElement>(null)\n\n const isPM = time.getHours() >= 11\n const hours = is24HourFormat ? range(0, 23) : range(1, 12)\n let minutes = range(0, 59)\n\n useEffect(() => {\n const scrollToItem = () => {\n if (minuteRef.current) {\n const container = minuteRef.current.parentElement!\n\n const hasOverflow = container.scrollHeight > maxHeight\n if (hasOverflow) {\n minuteRef.current.scrollIntoView({\n behavior: 'instant',\n block: 'nearest',\n })\n }\n }\n }\n scrollToItem()\n }, [minuteRef, minuteRef.current]) // eslint-disable-line\n\n useEffect(() => {\n const scrollToItem = () => {\n if (hourRef.current) {\n const container = hourRef.current.parentElement!\n\n const hasOverflow = container.scrollHeight > maxHeight\n if (hasOverflow) {\n hourRef.current.scrollIntoView({\n behavior: 'instant',\n block: 'nearest',\n })\n }\n }\n }\n scrollToItem()\n }, [hourRef, hourRef.current]) // eslint-disable-line\n\n switch (minuteIncrement) {\n case '5min':\n minutes = minutes.filter(value => value % 5 === 0)\n break\n case '10min':\n minutes = minutes.filter(value => value % 10 === 0)\n break\n case '15min':\n minutes = minutes.filter(value => value % 15 === 0)\n break\n case '30min':\n minutes = minutes.filter(value => value % 30 === 0)\n break\n }\n\n const closestMinute = closestMatch(minutes, (item1, item2) => Math.abs(item1 - time.getMinutes()) < Math.abs(item2 - time.getMinutes()))\n\n const style = (selected: boolean) => clsx('chip-full hover:brightness-90 hover:bg-primary hover:text-on-primary rounded-md mr-3',\n { 'bg-primary text-on-primary': selected, 'bg-white text-black': !selected })\n\n const onChangeWrapper = (transformer: (newDate: Date) => void) => {\n const newDate = new Date(time)\n transformer(newDate)\n onChange(newDate)\n }\n\n return (\n <div className={clsx('row gap-x-2 w-fit min-w-[150px] select-none', className)}>\n <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>\n <div className=\"col gap-y-1 h-full\">\n {hours.map(hour => {\n const currentHour = hour === time.getHours() - (!is24HourFormat && isPM ? 12 : 0)\n return (\n <button\n key={hour}\n ref={currentHour ? hourRef : undefined}\n className={style(currentHour)}\n onClick={() => onChangeWrapper(newDate => newDate.setHours(hour + (!is24HourFormat && isPM ? 12 : 0)))}\n >\n {hour.toString().padStart(2, '0')}\n </button>\n )\n })}\n </div>\n </Scrollbars>\n <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>\n <div className=\"col gap-y-1 h-full\">\n {minutes.map(minute => {\n const currentMinute = minute === closestMinute\n return (\n <button\n key={minute + minuteIncrement} // minute increment so that scroll works\n ref={currentMinute ? minuteRef : undefined}\n className={style(currentMinute)}\n onClick={() => onChangeWrapper(newDate => newDate.setMinutes(minute))}\n >\n {minute.toString().padStart(2, '0')}\n </button>\n )\n })}\n </div>\n </Scrollbars>\n {!is24HourFormat && (\n <div className=\"col gap-y-1\">\n <button\n className={style(!isPM)}\n onClick={() => onChangeWrapper(newDate => isPM && newDate.setHours(newDate.getHours() - 12))}\n >\n AM\n </button>\n <button\n className={style(isPM)}\n onClick={() => onChangeWrapper(newDate => !isPM && newDate.setHours(newDate.getHours() + 12))}\n >\n PM\n </button>\n </div>\n )}\n </div>\n )\n}\n\nexport const TimePickerUncontrolled = ({\n time,\n onChange = noop,\n ...props\n }: TimePickerProps) => {\n const [value, setValue] = useState(time)\n useEffect(() => setValue(time), [time])\n\n return (\n <TimePicker\n {...props}\n time={value}\n onChange={time1 => {\n setValue(time1)\n onChange(time1)\n }}\n />\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport type { SolidButtonColor } from '../user-action/Button'\nimport { SolidButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport clsx from 'clsx'\nimport type { DialogProps } from '@/components/layout-and-navigation/Overlay'\nimport { Dialog } from '@/components/layout-and-navigation/Overlay'\n\ntype ConfirmDialogTranslation = {\n confirm: string,\n cancel: string,\n decline: string,\n}\n\nexport type ConfirmDialogType = 'positive' | 'negative' | 'neutral' | 'primary'\n\nconst defaultConfirmDialogTranslation = {\n en: {\n confirm: 'Confirm',\n decline: 'Decline'\n },\n de: {\n confirm: 'Bestätigen',\n decline: 'Ablehnen'\n }\n}\n\ntype ButtonOverwriteType = {\n text?: string,\n color?: SolidButtonColor,\n disabled?: boolean,\n}\n\nexport type ConfirmDialogProps = DialogProps & {\n isShowingDecline?: boolean,\n requireAnswer?: boolean,\n onConfirm: () => void,\n onDecline?: () => void,\n confirmType?: ConfirmDialogType,\n /**\n * Order: Decline, Confirm\n */\n buttonOverwrites?: [ButtonOverwriteType, ButtonOverwriteType],\n}\n\n/**\n * A Dialog for demanding the user for confirmation\n *\n * To allow for background closing, prefer using a ConfirmModal\n */\nexport const ConfirmDialog = ({\n overwriteTranslation,\n children,\n onConfirm,\n onDecline,\n confirmType = 'positive',\n buttonOverwrites,\n className,\n ...restProps\n }: PropsForTranslation<ConfirmDialogTranslation, PropsWithChildren<ConfirmDialogProps>>) => {\n const translation = useTranslation(defaultConfirmDialogTranslation, overwriteTranslation)\n\n const mapping: Record<ConfirmDialogType, SolidButtonColor> = {\n neutral: 'primary',\n negative: 'negative',\n positive: 'positive',\n primary: 'primary',\n }\n\n return (\n <Dialog {...restProps} className={clsx('justify-between', className)}>\n <div className=\"col grow\">\n {children}\n </div>\n <div className=\"row mt-3 gap-x-4 justify-end\">\n {onDecline && (\n <SolidButton\n color={buttonOverwrites?.[0].color ?? 'negative'}\n onClick={onDecline}\n\n disabled={buttonOverwrites?.[0].disabled ?? false}\n >\n {buttonOverwrites?.[0].text ?? translation.decline}\n </SolidButton>\n )}\n <SolidButton\n autoFocus\n color={buttonOverwrites?.[1].color ?? mapping[confirmType]}\n onClick={onConfirm}\n disabled={buttonOverwrites?.[1].disabled ?? false}\n >\n {buttonOverwrites?.[1].text ?? translation.confirm}\n </SolidButton>\n </div>\n </Dialog>\n )\n}\n","import type { PropsWithChildren, ReactNode } from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport ReactDOM from 'react-dom'\nimport clsx from 'clsx'\nimport { Tooltip } from '@/components/user-action/Tooltip'\nimport { X } from 'lucide-react'\nimport { IconButton } from '@/components/user-action/Button'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { Language } from '@/localization/util'\n\nexport type OverlayProps = PropsWithChildren<{\n /**\n * Whether the overlay should be currently displayed\n */\n isOpen: boolean,\n /**\n * Callback when the background is clicked\n */\n onBackgroundClick?: () => void,\n /**\n * Styling for the background\n *\n * To remove the darkening, set bg-transparent\n */\n backgroundClassName?: string,\n}>\n\n/**\n * A generic overlay window which is managed by its parent\n */\nexport const Overlay = ({\n children,\n isOpen,\n onBackgroundClick,\n backgroundClassName,\n }: PropsWithChildren<OverlayProps>) => {\n // The element to which the overlay will be attached to\n const [root, setRoot] = useState<HTMLElement>()\n\n useEffect(() => {\n setRoot(document.body)\n }, [])\n\n if (!root || !isOpen) return null\n\n\n return ReactDOM.createPortal(\n <div className={clsx('fixed inset-0 z-[9999]')}>\n <div\n className={clsx('fixed inset-0 h-screen w-screen bg-black/30', backgroundClassName)}\n onClick={onBackgroundClick}\n />\n {children}\n </div>,\n root\n )\n}\n\n\nlet overlayStack: HTMLDivElement[] = []\n\n\n// --- Modal ---\n\ntype ModalHeaderTranslation = {\n close: string,\n}\n\nconst defaultModalHeaderTranslation: Record<Language, ModalHeaderTranslation> = {\n en: {\n close: 'Close'\n },\n de: {\n close: 'Schließen'\n }\n}\n\nexport type OverlayHeaderProps = {\n /**\n * Callback when the close button is clicked. If omitted or undefined, the button is hidden\n */\n onClose?: () => void,\n /** The title of the Modal. If you want to only set the text use `titleText` instead */\n title?: ReactNode,\n /** The title text of the Modal. If you want to set a custom title use `title` instead */\n titleText?: string,\n /** The description of the Modal. If you want to only set the text use `descriptionText` instead */\n description?: ReactNode,\n /** The description text of the Modal. If you want to set a custom description use `description` instead */\n descriptionText?: string,\n}\n\n/**\n * A header that should be in an Overlay\n */\nexport const OverlayHeader = ({\n overwriteTranslation,\n onClose,\n title,\n titleText = '',\n description,\n descriptionText = ''\n }: PropsForTranslation<ModalHeaderTranslation, OverlayHeaderProps>) => {\n const translation = useTranslation(defaultModalHeaderTranslation, overwriteTranslation)\n const hasTitleRow = !!title || !!titleText || !!onClose\n const titleRow = (\n <div className=\"row justify-between items-start gap-x-8\">\n {title ?? (\n <h2\n className={clsx('textstyle-title-lg', {\n 'mb-1': description || descriptionText,\n })}\n >\n {titleText}\n </h2>\n )}\n {!!onClose && (\n <Tooltip tooltip={translation.close}>\n <IconButton color=\"neutral\" size=\"small\" onClick={onClose}>\n <X className=\"w-full h-full\"/>\n </IconButton>\n </Tooltip>\n )}\n </div>\n )\n\n return (\n <div className=\"col\">\n {hasTitleRow && (titleRow)}\n {description ?? (descriptionText && (<span className=\"textstyle-description\">{descriptionText}</span>))}\n </div>\n )\n}\n\nexport type ModalProps = {\n isOpen: boolean,\n onClose: () => void,\n className?: string,\n backgroundClassName?: string,\n headerProps?: Omit<OverlayHeaderProps, 'onClose'>,\n}\n\n/**\n * A Generic Modal Window\n */\nexport const Modal = ({\n children,\n isOpen,\n onClose,\n className,\n backgroundClassName,\n headerProps,\n }: PropsWithChildren<ModalProps>) => {\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!isOpen) return\n\n const modal = ref.current\n\n if (!modal) {\n console.error('modal open, but no ref found')\n return\n }\n\n overlayStack.push(modal)\n\n const focusable = modal?.querySelectorAll(\n 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex=\"-1\"])'\n )\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n\n const handleKeyDown = (e: KeyboardEvent) => {\n const isTopmost = overlayStack[overlayStack.length - 1] === modal\n if (!isTopmost) return\n\n if (e.key === 'Escape') {\n e.stopPropagation()\n onClose()\n } else if (e.key === 'Tab') {\n if (focusable.length === 0) return\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n (last as HTMLElement).focus()\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n (first as HTMLElement).focus()\n }\n }\n }\n\n modal.focus()\n document.addEventListener('keydown', handleKeyDown)\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n overlayStack = overlayStack.filter(m => m !== modal)\n }\n }, [isOpen, onClose])\n\n return (\n <Overlay\n isOpen={isOpen}\n onBackgroundClick={onClose}\n backgroundClassName={backgroundClassName}\n >\n <div\n ref={ref}\n tabIndex={-1}\n className={clsx(\n 'fixed left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 col p-4 bg-overlay-background text-overlay-text rounded-xl shadow-xl',\n className\n )}\n role=\"dialog\"\n aria-modal={true}\n >\n <OverlayHeader {...headerProps} onClose={onClose}/>\n {children}\n </div>\n </Overlay>\n )\n}\n\n// --- Dialog ---\n\nexport type DialogProps = Omit<OverlayProps, 'onBackgroundClick'> & {\n headerProps?: Omit<OverlayHeaderProps, 'onClose'>,\n className?: string,\n}\n\n/**\n * A Generic Dialog Window\n */\nexport const Dialog = ({\n children,\n isOpen,\n className,\n backgroundClassName,\n headerProps,\n }: PropsWithChildren<DialogProps>) => {\n const ref = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!isOpen) return\n\n const dialog = ref.current\n\n if (!dialog) {\n console.error('dialog open, but no ref found')\n return\n }\n\n overlayStack.push(dialog)\n\n const focusable = dialog?.querySelectorAll(\n 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex=\"-1\"])'\n )\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n\n const handleKeyDown = (e: KeyboardEvent) => {\n const isTopmost = overlayStack[overlayStack.length - 1] === dialog\n if (!isTopmost) return\n\n if (e.key === 'Escape') {\n e.stopPropagation()\n } else if (e.key === 'Tab') {\n if (focusable.length === 0) return\n\n if (e.shiftKey && document.activeElement === first) {\n e.preventDefault();\n (last as HTMLElement).focus()\n } else if (!e.shiftKey && document.activeElement === last) {\n e.preventDefault();\n (first as HTMLElement).focus()\n }\n }\n }\n\n dialog.focus()\n document.addEventListener('keydown', handleKeyDown)\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown)\n overlayStack = overlayStack.filter(m => m !== dialog)\n }\n }, [isOpen])\n\n return (\n <Overlay\n isOpen={isOpen}\n backgroundClassName={backgroundClassName}\n >\n <div\n ref={ref}\n tabIndex={-1}\n className={clsx(\n 'fixed left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 col p-4 bg-overlay-background text-overlay-text rounded-xl shadow-xl',\n className\n )}\n role=\"dialog\"\n aria-modal={true}\n >\n {!!headerProps && (<OverlayHeader {...headerProps}/>)}\n {children}\n </div>\n </Overlay>\n )\n}","import type { Dispatch, SetStateAction } from 'react'\nimport { useEffect, useState } from 'react'\n\ntype UseHoverStateProps = {\n /**\n * The delay after which the menu is closed in milliseconds\n *\n * default: 200ms\n */\n closingDelay: number,\n /**\n * Whether the hover state management should be disabled\n *\n * default: false\n */\n isDisabled: boolean,\n}\n\ntype UseHoverStateReturnType = {\n /**\n * Whether the element is hovered\n */\n isHovered: boolean,\n /**\n * Function to change the current hover status\n */\n setIsHovered: Dispatch<SetStateAction<boolean>>,\n /**\n * Handlers to pass on to the component that should be hovered\n */\n handlers: {\n onMouseEnter: () => void,\n onMouseLeave: () => void,\n },\n}\n\nconst defaultUseHoverStateProps: UseHoverStateProps = {\n closingDelay: 200,\n isDisabled: false,\n}\n\n/**\n * @param props See UseHoverStateProps\n *\n * A react hook for managing the hover state of a component. The handlers provided should be\n * forwarded to the component which should be hovered over\n */\nexport const useHoverState = (props: Partial<UseHoverStateProps> | undefined = undefined): UseHoverStateReturnType => {\n const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props }\n\n const [isHovered, setIsHovered] = useState(false)\n const [timer, setTimer] = useState<NodeJS.Timeout>()\n\n const onMouseEnter = () => {\n if (isDisabled) {\n return\n }\n clearTimeout(timer)\n setIsHovered(true)\n }\n\n const onMouseLeave = () => {\n if (isDisabled) {\n return\n }\n setTimer(setTimeout(() => {\n setIsHovered(false)\n }, closingDelay))\n }\n\n useEffect(() => {\n if (timer) {\n return () => {\n clearTimeout(timer)\n }\n }\n })\n\n useEffect(() => {\n if (timer) {\n clearTimeout(timer)\n }\n }, [isDisabled]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return {\n isHovered, setIsHovered, handlers: { onMouseEnter, onMouseLeave }\n }\n}\n","import type { CSSProperties, PropsWithChildren, ReactNode } from 'react'\nimport { useHoverState } from '@/hooks/useHoverState'\nimport { clsx } from 'clsx'\n\ntype Position = 'top' | 'bottom' | 'left' | 'right'\n\nexport type TooltipProps = PropsWithChildren<{\n tooltip: string | ReactNode,\n /**\n * Number of milliseconds until the tooltip appears\n *\n * defaults to 1000ms\n */\n animationDelay?: number,\n /**\n * Class names of additional styling properties for the tooltip\n */\n tooltipClassName?: string,\n /**\n * Class names of additional styling properties for the container from which the tooltip will be created\n */\n containerClassName?: string,\n position?: Position,\n zIndex?: number,\n}>\n\n/**\n * A Component for showing a tooltip when hovering over Content\n * @param tooltip The tooltip to show can be a text or any ReactNode\n * @param children The Content for which the tooltip should be created\n * @param animationDelay The delay before the tooltip appears\n * @param tooltipClassName Additional ClassNames for the Container of the tooltip\n * @param containerClassName Additional ClassNames for the Container holding the content\n * @param position The direction of the tooltip relative to the Container\n * @param zIndex The z Index of the tooltip (you may require this when stacking modal)\n * @constructor\n */\nexport const Tooltip = ({\n tooltip,\n children,\n animationDelay = 650,\n tooltipClassName = '',\n containerClassName = '',\n position = 'bottom',\n zIndex = 10,\n }: TooltipProps) => {\n const { isHovered, handlers } = useHoverState()\n\n const positionClasses = {\n top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,\n bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,\n left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,\n right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`\n }\n\n const triangleSize = 6\n const triangleClasses = {\n top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,\n bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,\n left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,\n right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`\n }\n\n const triangleStyle: Record<Position, CSSProperties> = {\n top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },\n bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },\n left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },\n right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }\n }\n\n return (\n <div\n className={clsx('relative inline-block', containerClassName)}\n {...handlers}\n >\n {children}\n {isHovered && (\n <div\n className={clsx(\n `opacity-0 absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap\n animate-tooltip-fade-in shadow-lg bg-tooltip-background`,\n positionClasses[position], tooltipClassName\n )}\n style={{ zIndex, animationDelay: animationDelay + 'ms' }}\n >\n {tooltip}\n <div\n className={clsx(`absolute w-0 h-0`, triangleClasses[position])}\n style={{ ...triangleStyle[position], zIndex }}\n />\n </div>\n )}\n </div>\n )\n}\n","import Image from 'next/image'\nimport clsx from 'clsx'\n\nexport const avtarSizeList = ['tiny', 'small', 'medium', 'large'] as const\nexport type AvatarSize = typeof avtarSizeList[number]\nexport const avatarSizeMapping: Record<AvatarSize, number> = {\n tiny: 24,\n small: 32,\n medium: 48,\n large: 64\n}\n\nexport type AvatarProps = {\n avatarUrl: string,\n alt: string,\n size?: AvatarSize,\n className?: string,\n}\n\n/**\n * A component for showing a profile picture\n */\nexport const Avatar = ({ avatarUrl, alt, size = 'medium', className = '' }: AvatarProps) => {\n // TODO remove later\n avatarUrl = 'https://cdn.helpwave.de/boringavatar.svg'\n\n const avtarSize = {\n tiny: 24,\n small: 32,\n medium: 48,\n large: 64,\n }[size]\n\n const style = {\n width: avtarSize + 'px',\n height: avtarSize + 'px',\n maxWidth: avtarSize + 'px',\n maxHeight: avtarSize + 'px',\n minWidth: avtarSize + 'px',\n minHeight: avtarSize + 'px',\n }\n\n return (\n // TODO transparent or white background later\n <div className={clsx(`rounded-full bg-primary`, className)} style={style}>\n <Image\n className=\"rounded-full border border-gray-200\"\n style={style}\n src={avatarUrl}\n alt={alt}\n width={avtarSize}\n height={avtarSize}\n />\n </div>\n )\n}\n\nexport type AvatarGroupProps = {\n avatars: Omit<AvatarProps, 'size'>[],\n maxShownProfiles?: number,\n size?: AvatarSize,\n}\n\n/**\n * A component for showing a group of Avatar's\n */\nexport const AvatarGroup = ({\n avatars,\n maxShownProfiles = 5,\n size = 'tiny'\n }: AvatarGroupProps) => {\n const displayedProfiles = avatars.length < maxShownProfiles ? avatars : avatars.slice(0, maxShownProfiles)\n const diameter = avatarSizeMapping[size]\n const stackingOverlap = 0.5 // given as a percentage\n const notDisplayedProfiles = avatars.length - maxShownProfiles\n const avatarGroupWidth = diameter * (stackingOverlap * (displayedProfiles.length - 1) + 1)\n return (\n <div className=\"row relative\" style={{ height: diameter + 'px' }}>\n <div style={{ width: avatarGroupWidth + 'px' }}>\n {displayedProfiles.map((avatar, index) => (\n <div\n key={index}\n className=\"absolute\"\n style={{ left: (index * diameter * stackingOverlap) + 'px', zIndex: maxShownProfiles - index }}\n >\n <Avatar avatarUrl={avatar.avatarUrl} alt={avatar.alt} size={size}/>\n </div>\n ))}\n </div>\n {\n notDisplayedProfiles > 0 && (\n <div\n className=\"truncate row items-center\"\n style={{ fontSize: (diameter / 2) + 'px', marginLeft: (1 + diameter / 16) + 'px' }}\n >\n <span>+ {notDisplayedProfiles}</span>\n </div>\n )\n }\n </div>\n )\n}\n\nexport default { Avatar, AvatarGroup }\n","import type { HTMLAttributes } from 'react'\nimport clsx from 'clsx'\n\nexport type CircleProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'color'> & {\n radius: number,\n className?: string,\n}\n\nexport const Circle = ({\n radius = 20,\n className = 'bg-primary',\n style,\n ...restProps\n }: CircleProps) => {\n const size = radius * 2\n return (\n <div\n className={clsx(`rounded-full`, className)}\n style={{\n width: `${size}px`,\n height: `${size}px`,\n ...style,\n }}\n {...restProps}\n />\n )\n}\n","import type { CSSProperties } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { noop } from '../../util/noop'\nimport { Circle } from './Circle'\nimport clsx from 'clsx'\n\nexport type RingProps = {\n innerSize: number, // the size of the entire circle including the circleWidth\n width: number,\n className?: string,\n};\n\nexport const Ring = ({\n innerSize = 20,\n width = 7,\n className = 'outline-primary',\n }: RingProps) => {\n return (\n <div\n className={clsx(`bg-transparent rounded-full outline`, className)}\n style={{\n width: `${innerSize}px`,\n height: `${innerSize}px`,\n outlineWidth: `${width}px`,\n }}\n />\n )\n}\n\nexport type AnimatedRingProps = RingProps & {\n fillAnimationDuration?: number, // in seconds, 0 means no animation\n repeating?: boolean,\n onAnimationFinished?: () => void,\n style?: CSSProperties,\n};\n\nexport const AnimatedRing = ({\n innerSize,\n width,\n className,\n fillAnimationDuration = 3,\n repeating = false,\n onAnimationFinished = noop,\n style,\n }: AnimatedRingProps) => {\n const [currentWidth, setCurrentWidth] = useState(0)\n const milliseconds = 1000 * fillAnimationDuration\n\n const animate = useCallback((timestamp: number, startTime: number) => {\n const progress = Math.min((timestamp - startTime) / milliseconds, 1)\n const newWidth = Math.min(width * progress, width)\n\n setCurrentWidth(newWidth)\n\n if (progress < 1) {\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, startTime))\n } else {\n onAnimationFinished()\n if (repeating) {\n setCurrentWidth(0)\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, newTimestamp))\n }\n }\n }, [milliseconds, onAnimationFinished, repeating, width])\n\n useEffect(() => {\n if (currentWidth < width) {\n requestAnimationFrame((timestamp) => animate(timestamp, timestamp))\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div\n className=\"row items-center justify-center\"\n style={{\n width: `${innerSize + 2 * width}px`,\n height: `${innerSize + 2 * width}px`,\n ...style,\n }}\n >\n <Ring\n innerSize={innerSize}\n width={currentWidth}\n className={className}\n />\n </div>\n )\n}\n\nexport type RingWaveProps = Omit<AnimatedRingProps, 'innerSize'> & {\n startInnerSize: number,\n endInnerSize: number,\n style?: CSSProperties,\n};\n\nexport const RingWave = ({\n startInnerSize = 20,\n endInnerSize = 30,\n width,\n className,\n fillAnimationDuration = 3,\n repeating = false,\n onAnimationFinished = noop,\n style\n }: RingWaveProps) => {\n const [currentInnerSize, setCurrentInnerSize] = useState(startInnerSize)\n const distance = endInnerSize - startInnerSize\n const milliseconds = 1000 * fillAnimationDuration\n\n const animate = useCallback((timestamp: number, startTime: number) => {\n const progress = Math.min((timestamp - startTime) / milliseconds, 1)\n const newInnerSize = Math.min(\n startInnerSize + distance * progress,\n endInnerSize\n )\n\n setCurrentInnerSize(newInnerSize)\n\n if (progress < 1) {\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, startTime))\n } else {\n onAnimationFinished()\n if (repeating) {\n setCurrentInnerSize(startInnerSize)\n requestAnimationFrame((newTimestamp) => animate(newTimestamp, newTimestamp))\n }\n }\n }, [distance, endInnerSize, milliseconds, onAnimationFinished, repeating, startInnerSize])\n\n useEffect(() => {\n if (currentInnerSize < endInnerSize) {\n requestAnimationFrame((timestamp) => animate(timestamp, timestamp))\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <div\n className=\"row items-center justify-center\"\n style={{\n width: `${endInnerSize + 2 * width}px`,\n height: `${endInnerSize + 2 * width}px`,\n ...style\n }}\n >\n <Ring\n innerSize={currentInnerSize}\n width={width}\n className={className}\n />\n </div>\n )\n}\n\nexport type RadialRingsProps = {\n circle1ClassName?: string,\n circle2ClassName?: string,\n circle3ClassName?: string,\n waveWidth?: number,\n waveBaseColor?: string,\n sizeCircle1?: number,\n sizeCircle2?: number,\n sizeCircle3?: number,\n};\n\n// TODO use fixed colors here to avoid artifacts\nexport const RadialRings = ({\n circle1ClassName = 'bg-primary/90 outline-primary/90',\n circle2ClassName = 'bg-primary/60 outline-primary/60',\n circle3ClassName = 'bg-primary/40 outline-primary/40',\n waveWidth = 10,\n waveBaseColor = 'outline-white/20',\n sizeCircle1 = 100,\n sizeCircle2 = 200,\n sizeCircle3 = 300\n }: RadialRingsProps) => {\n const [currentRing, setCurrentRing] = useState(0)\n const size = sizeCircle3\n\n return (\n <div\n className=\"relative\"\n style={{\n width: `${sizeCircle3}px`,\n height: `${sizeCircle3}px`,\n }}\n >\n <Circle\n radius={sizeCircle1 / 2}\n className={clsx(circle1ClassName, `absolute z-[10] -translate-y-1/2 -translate-x-1/2`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`\n }}\n />\n {currentRing === 0 ? (\n <AnimatedRing\n innerSize={sizeCircle1}\n width={(sizeCircle2 - sizeCircle1) / 2}\n onAnimationFinished={() =>\n currentRing === 0 ? setCurrentRing(1) : null\n }\n repeating={true}\n className={clsx(circle2ClassName,\n { 'opacity-5': currentRing !== 0 })}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 9\n }}\n />\n ) : null}\n {currentRing === 2 ? (\n <RingWave\n startInnerSize={sizeCircle1 - waveWidth}\n endInnerSize={sizeCircle2}\n width={waveWidth}\n repeating={true}\n className={clsx(waveBaseColor, `opacity-5`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 9,\n }}\n />\n ) : null}\n <Circle\n radius={sizeCircle2 / 2}\n className={clsx(circle2ClassName,\n { 'opacity-20': currentRing < 1 },\n `absolute z-[8] -translate-y-1/2 -translate-x-1/2`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`\n }}\n />\n {currentRing === 1 ? (\n <AnimatedRing\n innerSize={sizeCircle2 - 1} // potentially harmful\n width={(sizeCircle3 - sizeCircle2) / 2}\n onAnimationFinished={() =>\n currentRing === 1 ? setCurrentRing(2) : null\n }\n repeating={true}\n className={clsx(circle3ClassName)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 7,\n }}\n />\n ) : null}\n {currentRing === 2 ? (\n <RingWave\n startInnerSize={sizeCircle2}\n endInnerSize={sizeCircle3 - waveWidth}\n width={waveWidth}\n repeating={true}\n className={clsx(waveBaseColor, `opacity-5`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`,\n position: 'absolute',\n translate: `-50% -50%`,\n zIndex: 7,\n }}\n />\n ) : null}\n <Circle\n radius={sizeCircle3 / 2}\n className={clsx(circle3ClassName,\n { 'opacity-20': currentRing < 2 },\n `absolute z-[6] -translate-y-1/2 -translate-x-1/2`)}\n style={{\n left: `${size / 2}px`,\n top: `${size / 2}px`\n }}\n />\n </div>\n )\n}\n","import type { ImageProps } from 'next/image'\nimport Image from 'next/image'\n\nexport type TagProps = Omit<ImageProps, 'src' | 'alt'>\n\n/**\n * Tag icon from flaticon\n *\n * https://www.flaticon.com/free-icon/price-tag_721550?term=label&page=1&position=8&origin=tag&related_id=721550\n *\n * When using it make attribution\n */\nexport const TagIcon = ({\n className,\n width = 16,\n height = 16,\n ...props\n }: TagProps) => {\n return (\n <Image\n {...props}\n width={width}\n height={height}\n alt=\"\"\n src=\"https://cdn.helpwave.de/icons/label.png\"\n className={className}\n />\n )\n}\n","import Link from 'next/link'\nimport clsx from 'clsx'\n\nexport type Crumb = {\n display: string,\n link: string,\n}\n\ntype BreadCrumbProps = {\n crumbs: Crumb[],\n linkClassName?: string,\n containerClassName?: string,\n}\n\n/**\n * A component for showing a hierarchical link structure with an independent link on each element\n *\n * e.g. Organizations/Ward/<id>\n */\nexport const BreadCrumb = ({ crumbs, linkClassName, containerClassName }: BreadCrumbProps) => {\n const color = 'text-description'\n\n return (\n <div className={clsx('row', containerClassName)}>\n {crumbs.map((crumb, index) => (\n <div key={index}>\n <Link href={crumb.link}\n className={clsx(linkClassName, { [`${color} hover:brightness-60`]: index !== crumbs.length - 1 })}>\n {crumb.display}\n </Link>\n {index !== crumbs.length - 1 && <span className={clsx(`px-1`, color)}>/</span>}\n </div>\n ))}\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport clsx from 'clsx'\nimport { ChevronLeft, ChevronRight } from 'lucide-react'\nimport { createLoopingListWithIndex, range } from '../../util/array'\nimport { clamp } from '../../util/math'\nimport { EaseFunctions } from '../../util/easeFunctions'\nimport type { Direction } from '../../util/loopingArray'\nimport { LoopingArrayCalculator } from '../../util/loopingArray'\n\n\ntype CarouselProps = {\n children: ReactNode[],\n animationTime?: number,\n isLooping?: boolean,\n isAutoLooping?: boolean,\n autoLoopingTimeOut?: number,\n autoLoopAnimationTime?: number,\n hintNext?: boolean,\n arrows?: boolean,\n dots?: boolean,\n /**\n * Percentage that is allowed to be scrolled further\n */\n overScrollThreshold?: number,\n blurColor?: string,\n className?: string,\n heightClassName?: string,\n widthClassName?: string,\n}\n\ntype ItemType = {\n item: ReactNode,\n index: number,\n}\n\ntype CarouselAnimationState = {\n targetPosition: number,\n /**\n * Value of either 1 or -1, 1 is forwards -1 is backwards\n */\n direction: Direction,\n startPosition: number,\n startTime?: number,\n lastUpdateTime?: number,\n isAutoLooping: boolean,\n}\n\ntype DragState = {\n startX: number,\n startTime: number,\n lastX: number,\n startIndex: number,\n}\n\ntype CarouselInformation = {\n currentPosition: number,\n dragState?: DragState,\n animationState?: CarouselAnimationState,\n}\n\nexport const Carousel = ({\n children,\n animationTime = 200,\n isLooping = false,\n isAutoLooping = false,\n autoLoopingTimeOut = 5000,\n autoLoopAnimationTime = 500,\n hintNext = false,\n arrows = false,\n dots = true,\n overScrollThreshold = 0.1,\n blurColor = 'from-white',\n className = '',\n heightClassName = 'h-[24rem]',\n widthClassName = 'w-[70%] desktop:w-1/2',\n }: CarouselProps) => {\n if (isAutoLooping && !isLooping) {\n console.error('When isAutoLooping is true, isLooping should also be true')\n isLooping = true\n }\n\n const [{\n currentPosition,\n dragState,\n animationState,\n }, setCarouselInformation] = useState<CarouselInformation>({\n currentPosition: 0,\n })\n const animationId = useRef<number | undefined>(undefined)\n const timeOut = useRef<NodeJS.Timeout | undefined>(undefined)\n autoLoopingTimeOut = Math.max(0, autoLoopingTimeOut)\n\n const length = children.length\n const paddingItemCount = 3 // The number of items to append left and right of the list to allow for clean transition when looping\n\n const util = useMemo(() => new LoopingArrayCalculator(length, isLooping, overScrollThreshold), [length, isLooping, overScrollThreshold])\n const currentIndex = util.getCorrectedPosition(LoopingArrayCalculator.withoutOffset(currentPosition))\n animationTime = Math.max(200, animationTime) // in ms, must be > 0\n autoLoopAnimationTime = Math.max(200, autoLoopAnimationTime)\n\n const getStyleOffset = (index: number) => {\n const baseOffset = -50 + (index - currentPosition) * 100\n return `${baseOffset}%`\n }\n\n const animation = useCallback((time: number) => {\n let keepAnimating: boolean = true\n\n // Other calculation in the setState call to avoid updating the useCallback to often\n setCarouselInformation((state) => {\n const {\n animationState,\n dragState\n } = state\n if (animationState === undefined || dragState !== undefined) {\n keepAnimating = false\n return state\n }\n if (!animationState.startTime || !animationState.lastUpdateTime) {\n return {\n ...state,\n animationState: {\n ...animationState,\n startTime: time,\n lastUpdateTime: time\n }\n }\n }\n const useAnimationTime = animationState.isAutoLooping ? autoLoopAnimationTime : animationTime\n const progress = clamp((time - animationState.startTime) / useAnimationTime) // progress\n const easedProgress = EaseFunctions.easeInEaseOut(progress)\n const distance = util.getDistanceDirectional(animationState.startPosition, animationState.targetPosition, animationState.direction)\n const newPosition = util.getCorrectedPosition(easedProgress * distance * animationState.direction + animationState.startPosition)\n\n if (animationState.targetPosition === newPosition || progress === 1) {\n keepAnimating = false\n return ({\n currentPosition: LoopingArrayCalculator.withoutOffset(newPosition),\n animationState: undefined\n })\n }\n return ({\n currentPosition: newPosition,\n animationState: {\n ...animationState!,\n lastUpdateTime: time\n }\n })\n })\n if (keepAnimating) {\n animationId.current = requestAnimationFrame(time1 => animation(time1))\n }\n }, [animationTime, autoLoopAnimationTime, util])\n\n useEffect(() => {\n if (animationState) {\n animationId.current = requestAnimationFrame(animation)\n }\n return () => {\n if (animationId.current) {\n cancelAnimationFrame(animationId.current)\n animationId.current = 0\n }\n }\n }, [animationState]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const startAutoLoop = () => setCarouselInformation(prevState => ({\n ...prevState,\n dragState: prevState.dragState,\n animationState: prevState.animationState || prevState.dragState ? prevState.animationState : {\n startPosition: currentPosition,\n targetPosition: (currentPosition + 1) % length,\n direction: 1, // always move forward\n isAutoLooping: true\n }\n }))\n\n useEffect(() => {\n if (!animationId.current && !animationState && !dragState && !timeOut.current) {\n if (autoLoopingTimeOut > 0) {\n timeOut.current = setTimeout(() => {\n startAutoLoop()\n timeOut.current = undefined\n }, autoLoopingTimeOut)\n } else {\n startAutoLoop()\n }\n }\n }, [animationState, dragState, animationId.current, timeOut.current]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const startAnimation = (targetPosition?: number) => {\n if (targetPosition === undefined) {\n targetPosition = LoopingArrayCalculator.withoutOffset(currentPosition)\n }\n if (targetPosition === currentPosition) {\n return // we are exactly where we want to be\n }\n\n // find target index and fastest path to it\n const direction = util.getBestDirection(currentPosition, targetPosition)\n clearTimeout(timeOut.current)\n timeOut.current = undefined\n if (animationId.current) {\n cancelAnimationFrame(animationId.current)\n animationId.current = undefined\n }\n\n setCarouselInformation(prevState => ({\n ...prevState,\n dragState: undefined,\n animationState: {\n targetPosition: targetPosition!,\n direction,\n startPosition: currentPosition,\n isAutoLooping: false\n },\n timeOut: undefined\n }))\n }\n\n const canGoLeft = () => {\n return isLooping || currentPosition !== 0\n }\n\n const canGoRight = () => {\n return isLooping || currentPosition !== length - 1\n }\n\n const left = () => {\n if (canGoLeft()) {\n startAnimation(currentPosition === 0 ? length - 1 : LoopingArrayCalculator.withoutOffset(currentPosition - 1))\n }\n }\n\n const right = () => {\n if (canGoRight()) {\n startAnimation(LoopingArrayCalculator.withoutOffset((currentPosition + 1) % length))\n }\n }\n\n let items: ItemType[] = children.map((item, index) => ({\n index,\n item\n }))\n\n if (isLooping) {\n const before = createLoopingListWithIndex(children, length - 1, paddingItemCount, false).reverse().map(([index, item]) => ({\n index,\n item\n }))\n const after = createLoopingListWithIndex(children, 0, paddingItemCount).map(([index, item]) => ({\n index,\n item\n }))\n items = [\n ...before,\n ...items,\n ...after\n ]\n }\n\n const onDragStart = (x: number) => setCarouselInformation(prevState => ({\n ...prevState,\n dragState: {\n lastX: x,\n startX: x,\n startTime: Date.now(),\n startIndex: currentPosition,\n },\n animationState: undefined // cancel animation\n }))\n\n const onDrag = (x: number, width: number) => {\n // For some weird reason the clientX is 0 on the last dragUpdate before drag end causing issues\n if (!dragState || x === 0) {\n return\n }\n const offsetUpdate = (dragState.lastX - x) / width\n const newPosition = util.getCorrectedPosition(currentPosition + offsetUpdate)\n\n setCarouselInformation(prevState => ({\n ...prevState,\n currentPosition: newPosition,\n dragState: {\n ...dragState,\n lastX: x\n },\n }))\n }\n\n const onDragEnd = (x: number, width: number) => {\n if (!dragState) {\n return\n }\n const distance = dragState.startX - x\n const relativeDistance = distance / width\n const duration = (Date.now() - dragState.startTime) // in milliseconds\n const velocity = distance / (Date.now() - dragState.startTime)\n\n const isSlide = Math.abs(velocity) > 2 || (duration < 200 && (Math.abs(relativeDistance) > 0.2 || Math.abs(distance) > 50))\n if (isSlide) {\n if (distance > 0 && canGoRight()) {\n right()\n return\n } else if (distance < 0 && canGoLeft()) {\n left()\n return\n }\n }\n startAnimation()\n }\n\n const dragHandlers = {\n draggable: true,\n onDragStart: (event: React.DragEvent<HTMLDivElement>) => {\n onDragStart(event.clientX)\n event.dataTransfer.setDragImage(document.createElement('div'), 0, 0)\n },\n onDrag: (event: React.DragEvent<HTMLDivElement>) => onDrag(event.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onDragEnd: (event: React.DragEvent<HTMLDivElement>) => onDragEnd(event.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onTouchStart: (event: React.TouchEvent<HTMLDivElement>) => onDragStart(event.touches[0]!.clientX),\n onTouchMove: (event: React.TouchEvent<HTMLDivElement>) => onDrag(event.touches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onTouchEnd: (event: React.TouchEvent<HTMLDivElement>) => onDragEnd(event.changedTouches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n onTouchCancel: (event: React.TouchEvent<HTMLDivElement>) => onDragEnd(event.changedTouches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n }\n\n return (\n <div className=\"col items-center w-full gap-y-2\">\n <div className={clsx(`relative w-full overflow-hidden`, heightClassName, className)}>\n {arrows && (\n <>\n <div\n className={clsx('absolute z-10 left-0 top-1/2 -translate-y-1/2 bg-gray-200 hover:bg-gray-300 rounded-lg cursor-pointer border-black border-2', { hidden: !canGoLeft() })}\n onClick={() => left()}\n >\n <ChevronLeft size={32}/>\n </div>\n <div\n className={clsx('absolute z-10 right-0 top-1/2 -translate-y-1/2 bg-gray-200 hover:bg-gray-300 rounded-lg cursor-pointer border-black border-2', { hidden: !canGoRight() })}\n onClick={() => right()}\n >\n <ChevronRight size={32}/>\n </div>\n </>\n )}\n {hintNext ? (\n <div className={clsx(`relative row h-full`, heightClassName)}>\n <div className=\"relative row h-full w-full px-2 overflow-hidden\">\n {items.map(({\n item,\n index\n }, listIndex) => (\n <div\n key={listIndex}\n className={clsx(`absolute left-[50%] h-full overflow-hidden`, widthClassName, { '!cursor-grabbing': !!dragState })}\n style={{ translate: getStyleOffset(listIndex - (isLooping ? paddingItemCount : 0)) }}\n {...dragHandlers}\n onClick={() => startAnimation(index)}\n >\n {item}\n </div>\n ))}\n </div>\n <div\n className={clsx(`hidden pointer-events-none desktop:block absolute left-0 h-full w-[20%] bg-gradient-to-r to-transparent`, blurColor)}\n />\n <div\n className={clsx(`hidden pointer-events-none desktop:block absolute right-0 h-full w-[20%] bg-gradient-to-l to-transparent`, blurColor)}\n />\n </div>\n ) : (\n <div className={clsx('px-16 h-full', { '!cursor-grabbing': !!dragState })} {...dragHandlers}>\n {children[currentIndex]}\n </div>\n )}\n </div>\n {dots && (\n <div\n className=\"row items-center justify-center w-full my-2\">\n {range(0, length - 1).map(index => (\n <button\n key={index}\n className={clsx('w-[2rem] min-w-[2rem] h-[0.75rem] min-h-[0.75rem] hover:bg-primary hover:brightness-90 first:rounded-l-md last:rounded-r-md', {\n 'bg-gray-200': currentIndex !== index,\n 'bg-primary': currentIndex === index\n })}\n onClick={() => startAnimation(index)}\n />\n ))}\n </div>\n )}\n </div>\n )\n}\n","import type { HTMLProps, PropsWithChildren, ReactNode } from 'react'\nimport clsx from 'clsx'\n\nexport type ChipColor = 'default' | 'dark' | 'red' | 'yellow' | 'green' | 'blue' | 'pink'\ntype ChipVariant = 'normal' | 'fullyRounded'\n\nexport type ChipProps = HTMLProps<HTMLDivElement> & PropsWithChildren<{\n color?: ChipColor,\n variant?: ChipVariant,\n trailingIcon?: ReactNode,\n}>\n\n/**\n * A component for displaying a single chip\n */\nexport const Chip = ({\n children,\n trailingIcon,\n color = 'default',\n variant = 'normal',\n className = '',\n ...restProps\n }: ChipProps) => {\n const colorMapping: string = {\n default: 'text-tag-default-text bg-tag-default-background',\n dark: 'text-tag-dark-text bg-tag-dark-background',\n red: 'text-tag-red-text bg-tag-red-background',\n yellow: 'text-tag-yellow-text bg-tag-yellow-background',\n green: 'text-tag-green-text bg-tag-green-background',\n blue: 'text-tag-blue-text bg-tag-blue-background',\n pink: 'text-tag-pink-text bg-tag-pink-background',\n }[color]\n\n const colorMappingIcon: string = {\n default: 'text-tag-default-icon',\n dark: 'text-tag-dark-icon',\n red: 'text-tag-red-icon',\n yellow: 'text-tag-yellow-icon',\n green: 'text-tag-green-icon',\n blue: 'text-tag-blue-icon',\n pink: 'text-tag-pink-icon',\n }[color]\n\n return (\n <div\n {...restProps}\n className={clsx(\n `row w-fit px-2 py-1`,\n colorMapping,\n {\n 'rounded-md': variant === 'normal',\n 'rounded-full': variant === 'fullyRounded',\n },\n className\n )}\n >\n {children}\n {trailingIcon && (<span className={colorMappingIcon}>{trailingIcon}</span>)}\n </div>\n )\n}\n\nexport type ChipListProps = {\n list: ChipProps[],\n className?: string,\n}\n\n/**\n * A component for displaying a list of chips\n */\nexport const ChipList = ({\n list,\n className = ''\n }: ChipListProps) => {\n return (\n <div className={clsx('flex flex-wrap gap-x-4 gap-y-2', className)}>\n {list.map((value, index) => (\n <Chip\n key={index}\n {...value}\n color={value.color ?? 'dark'}\n variant={value.variant ?? 'normal'}\n >\n {value.children}\n </Chip>\n ))}\n </div>\n )\n}\n","import type { HTMLAttributes, ReactNode } from 'react'\nimport clsx from 'clsx'\n\nexport type DividerInserterProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {\n children: ReactNode[],\n divider: (index: number) => ReactNode,\n}\n\n/**\n * A Component for inserting a divider in the middle of each child element\n *\n * undefined elements are removed\n */\nexport const DividerInserter = ({\n children,\n divider,\n className,\n ...restProps\n }: DividerInserterProps) => {\n const nodes: ReactNode[] = []\n\n for (let index = 0; index < children.length; index++) {\n const element = children[index]\n if (element !== undefined) {\n nodes.push(element)\n if (index < children.length - 1) {\n nodes.push(divider(index))\n }\n }\n }\n\n return (\n <div className={clsx(className)} {...restProps}>\n {nodes}\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport clsx from 'clsx'\nimport { ChevronDown, ChevronUp } from 'lucide-react'\nimport type { ExpandableProps } from './Expandable'\nimport { Expandable } from './Expandable'\nimport { MarkdownInterpreter } from './MarkdownInterpreter'\n\ntype ContentType = {\n type: 'markdown',\n value: string,\n} | {\n type: 'custom',\n value: ReactNode,\n}\n\nexport type FAQItem = Pick<ExpandableProps, 'initialExpansion' | 'className'> & {\n id: string,\n title: string,\n content: ContentType,\n}\n\nexport type FAQSectionProps = {\n entries: FAQItem[],\n expandableClassName?: string,\n}\n\n/**\n * Description\n */\nexport const FAQSection = ({\n entries,\n expandableClassName\n }: FAQSectionProps) => {\n const chevronSize = 28\n return (\n <div className=\"col gap-y-4\">\n {entries.map(({ id, title, content, ...restProps }) => (\n <Expandable\n key={id}\n {...restProps}\n label={(<h3 id={id} className=\"textstyle-title-md\">{title}</h3>)}\n clickOnlyOnHeader={false}\n icon={(expanded) => expanded ?\n (<ChevronUp size={chevronSize} className=\"text-primary\" style={{ minWidth: `${chevronSize}px` }}/>) :\n (<ChevronDown size={chevronSize} className=\"text-primary\"/>)\n }\n className={clsx('rounded-xl', expandableClassName)}\n >\n <div className=\"mt-2\">\n {content.type === 'markdown' ? (<MarkdownInterpreter text={content.value}/>) : content.value}\n </div>\n </Expandable>\n ))}\n </div>\n )\n}\n","type ASTNodeModifierType =\n 'none'\n | 'italic'\n | 'bold'\n | 'underline'\n | 'font-space'\n | 'primary'\n | 'secondary'\n | 'warn'\n | 'positive'\n | 'negative'\n\nconst astNodeInserterType = ['helpwave', 'newline'] as const\ntype ASTNodeInserterType = typeof astNodeInserterType[number]\ntype ASTNodeDefaultType = 'text'\n\ntype ASTNode = {\n type: ASTNodeModifierType,\n children: ASTNode[],\n} | {\n type: ASTNodeInserterType,\n} | {\n type: ASTNodeDefaultType,\n text: string,\n}\n\nexport type ASTNodeInterpreterProps = {\n node: ASTNode,\n isRoot?: boolean,\n className?: string,\n}\nexport const ASTNodeInterpreter = ({\n node,\n isRoot = false,\n className = '',\n }: ASTNodeInterpreterProps) => {\n switch (node.type) {\n case 'newline':\n return <br/>\n case 'text':\n return isRoot ? <span className={className}>{node.text}</span> : node.text\n case 'helpwave':\n return (<span className=\"font-bold font-space no-underline\">helpwave</span>)\n case 'none':\n return isRoot ? (\n <span className={className}>{node.children.map((value, index) => (\n <ASTNodeInterpreter key={index}\n node={value}/>\n ))}</span>\n ) :\n <>{node.children.map((value, index) => <ASTNodeInterpreter key={index} node={value}/>)}</>\n case 'bold':\n return <b>{node.children.map((value, index) => <ASTNodeInterpreter key={index} node={value}/>)}</b>\n case 'italic':\n return <i>{node.children.map((value, index) => <ASTNodeInterpreter key={index} node={value}/>)}</i>\n case 'underline':\n return (<u>{node.children.map((value, index) => (<ASTNodeInterpreter key={index} node={value}/>))}</u>)\n case 'font-space':\n return (\n <span className=\"font-space\">{node.children.map((value, index) => (\n <ASTNodeInterpreter key={index}\n node={value}/>\n ))}</span>\n )\n case 'primary':\n return (\n <span className=\"text-primary\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'secondary':\n return (\n <span className=\"text-secondary\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'warn':\n return (\n <span className=\"text-warning\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'positive':\n return (\n <span className=\"text-positive\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n case 'negative':\n return (\n <span className=\"text-negative\">{node.children.map((value, index) => (\n <ASTNodeInterpreter\n key={index} node={value}/>\n ))}</span>\n )\n default:\n return null\n }\n}\n\nconst modifierIdentifierMapping = [\n { id: 'i', name: 'italic' },\n { id: 'b', name: 'bold' },\n { id: 'u', name: 'underline' },\n { id: 'space', name: 'font-space' },\n { id: 'primary', name: 'primary' },\n { id: 'secondary', name: 'secondary' },\n { id: 'warn', name: 'warn' },\n { id: 'positive', name: 'positive' },\n { id: 'negative', name: 'negative' },\n] as const\n\nconst inserterIdentifierMapping = [\n { id: 'helpwave', name: 'helpwave' },\n { id: 'newline', name: 'newline' }\n] as const\nconst parseMarkdown = (\n text: string,\n commandStart: string = '\\\\',\n open: string = '{',\n close: string = '}'\n): ASTNode => {\n let start = text.indexOf(commandStart)\n const children: ASTNode[] = []\n\n // parse the text step by step\n while (text !== '') {\n if (start === -1) {\n children.push({\n type: 'text',\n text\n })\n break\n }\n children.push(parseMarkdown(text.substring(0, start)))\n text = text.substring(start)\n if (text.length <= 1) {\n children.push({\n type: 'text',\n text\n })\n text = ''\n continue\n }\n const simpleReplace = [commandStart, open, close]\n if (simpleReplace.some(value => text[1] === value)) {\n children.push({\n type: 'text',\n text: simpleReplace.find(value => text[1] === value)!\n })\n text = text.substring(2)\n start = text.indexOf(commandStart)\n continue\n }\n const inserter = inserterIdentifierMapping.find(value => text.substring(1).startsWith(value.id))\n if (inserter) {\n children.push({\n type: inserter.name,\n })\n text = text.substring(inserter.id.length + 1)\n start = text.indexOf(commandStart)\n continue\n }\n const modifier = modifierIdentifierMapping.find(value => text.substring(1).startsWith(value.id))\n if (modifier) {\n // check brackets\n if (text[modifier.id.length + 1] !== open) {\n children.push({\n type: 'text',\n text: text.substring(0, modifier.id.length + 1)\n })\n text = text.substring(modifier.id.length + 2)\n start = text.indexOf(commandStart)\n continue\n }\n let closing = -1\n let index = modifier.id.length + 2\n let counter = 1\n let escaping = false\n while (index < text.length) {\n if (text[index] === open && !escaping) {\n counter++\n }\n if (text[index] === close && !escaping) {\n counter--\n if (counter === 0) {\n closing = index\n break\n }\n }\n escaping = text[index] === commandStart\n index++\n }\n\n if (closing !== -1) {\n children.push({\n type: modifier.name,\n children: [parseMarkdown(text.substring(modifier.id.length + 2, closing))]\n })\n text = text.substring(closing + 1)\n start = text.indexOf(commandStart)\n continue\n }\n }\n // nothing could be applied to command start\n children.push({\n type: 'text',\n text: text[0]!\n })\n text = text.substring(1)\n start = text.indexOf(commandStart)\n }\n\n return {\n type: 'none',\n children\n }\n}\n\nconst optimizeTree = (node: ASTNode) => {\n if (node.type === 'text') {\n return !node.text ? undefined : node\n }\n if (astNodeInserterType.some(value => value === node.type)) {\n return node\n }\n\n const currentNode = node as\n { type: ASTNodeModifierType, children: ASTNode[] }\n\n if (currentNode.children.length === 0) {\n return undefined\n }\n\n let children: ASTNode[] = []\n for (let i = 0; i < currentNode.children.length; i++) {\n const child = optimizeTree(currentNode.children[i]!)\n if (!child) {\n continue\n }\n if (child.type === 'none') {\n children.push(...child.children)\n } else {\n children.push(child)\n }\n }\n\n currentNode.children = children\n children = []\n\n for (let i = 0; i < currentNode.children.length; i++) {\n const child = currentNode.children[i]!\n if (child) {\n if (child.type === 'text' && children[children.length - 1]?.type === 'text') {\n (children[children.length - 1]! as { type: ASTNodeDefaultType, text: string }).text += child.text\n } else {\n children.push(child)\n }\n }\n }\n currentNode.children = children\n return currentNode\n}\n\nexport type MarkdownInterpreterProps = {\n text: string,\n className?: string,\n}\n\nexport const MarkdownInterpreter = ({ text, className }: MarkdownInterpreterProps) => {\n const tree = parseMarkdown(text)\n const optimizedTree = optimizeTree(tree)!\n return <ASTNodeInterpreter node={optimizedTree} isRoot={true} className={className}/>\n}\n","import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { Language } from '../../localization/util'\n\ntype PaginationTranslation = {\n of: string,\n}\nconst defaultPaginationTranslations: Record<Language, PaginationTranslation> = {\n en: {\n of: 'of'\n },\n de: {\n of: 'von'\n }\n}\n\nexport type PaginationProps = {\n page: number, // starts with 0\n numberOfPages: number,\n onPageChanged: (page: number) => void,\n}\n\n/**\n * A Component showing the pagination allowing first, before, next and last page navigation\n */\nexport const Pagination = ({\n overwriteTranslation,\n page,\n numberOfPages,\n onPageChanged\n }: PropsForTranslation<PaginationTranslation, PaginationProps>) => {\n const translation = useTranslation(defaultPaginationTranslations, overwriteTranslation)\n\n const changePage = (page: number) => {\n onPageChanged(page)\n }\n\n const noPages = numberOfPages === 0\n const onFirstPage = page === 0 && !noPages\n const onLastPage = page === numberOfPages - 1\n\n return (\n <div className={clsx('row', { 'opacity-30': noPages })}>\n <button onClick={() => changePage(0)} disabled={onFirstPage}>\n <ChevronFirst className={clsx({ 'opacity-30': onFirstPage })}/>\n </button>\n <button onClick={() => changePage(page - 1)} disabled={onFirstPage}>\n <ChevronLeft className={clsx({ 'opacity-30': onFirstPage })}/>\n </button>\n <div className=\"min-w-[80px] justify-center mx-2\">\n <span className=\"select-none text-right flex-1\">{noPages ? 0 : page + 1}</span>\n <span className=\"select-none mx-2\">{translation.of}</span>\n <span className=\"select-none text-left flex-1\">{numberOfPages}</span>\n </div>\n <button onClick={() => changePage(page + 1)} disabled={onLastPage || noPages}>\n <ChevronRight className={clsx({ 'opacity-30': onLastPage })}/>\n </button>\n <button onClick={() => changePage(numberOfPages - 1)} disabled={onLastPage || noPages}>\n <ChevronLast className={clsx({ 'opacity-30': onLastPage })}/>\n </button>\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport { useEffect, useMemo, useState } from 'react'\nimport { Search } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { MultiSearchWithMapping } from '@/util/simpleSearch'\nimport { Input } from '../user-action/Input'\n\ntype SearchableListTranslation = {\n search: string,\n nothingFound: string,\n}\n\nconst defaultSearchableListTranslation: Record<Language, SearchableListTranslation> = {\n en: {\n search: 'Search',\n nothingFound: 'Nothing found'\n },\n de: {\n search: 'Suche',\n nothingFound: 'Nichts gefunden'\n }\n}\n\nexport type SearchableListProps<T> = {\n list: T[],\n initialSearch?: string,\n searchMapping: (value: T) => string[],\n itemMapper: (value: T) => ReactNode,\n className?: string,\n}\n\n/**\n * A component for searching a list\n */\nexport const SearchableList = <T, >({\n overwriteTranslation,\n list,\n initialSearch = '',\n searchMapping,\n itemMapper,\n className\n }: PropsForTranslation<SearchableListTranslation, SearchableListProps<T>>) => {\n const translation = useTranslation(defaultSearchableListTranslation, overwriteTranslation)\n const [search, setSearch] = useState<string>(initialSearch)\n\n useEffect(() => setSearch(initialSearch), [initialSearch])\n\n const filteredEntries = useMemo(() => MultiSearchWithMapping(search, list, searchMapping), [search, list, searchMapping])\n\n return (\n <div className={clsx('col gap-y-2', className)}>\n <div className=\"row justify-between gap-x-2 items-center\">\n <div className=\"flex-1\">\n <Input value={search} onChangeText={setSearch} placeholder={translation.search}/>\n </div>\n <Search size={20}/>\n </div>\n {filteredEntries.length > 0 && (\n <div className=\"col gap-y-1\">\n {filteredEntries.map(itemMapper)}\n </div>\n )}\n {!filteredEntries.length && <div className=\"row justify-center\">{translation.nothingFound}</div>}\n </div>\n )\n}\n","import React, { forwardRef, type InputHTMLAttributes, useEffect, useRef, useState } from 'react'\nimport clsx from 'clsx'\nimport { useSaveDelay } from '@/hooks/useSaveDelay'\nimport { noop } from '@/util/noop'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\nexport type InputProps = {\n /**\n * used for the label's `for` attribute\n */\n label?: Omit<LabelProps, 'id'>,\n /**\n * Callback for when the input's value changes\n * This is pretty much required but made optional for the rare cases where it actually isn't need such as when used with disabled\n * That could be enforced through a union type but that seems a bit overkill\n * @default noop\n */\n onChangeText?: (text: string) => void,\n className?: string,\n onEditCompleted?: (text: string) => void,\n expanded?: boolean,\n containerClassName?: string,\n} & Omit<InputHTMLAttributes<HTMLInputElement>, 'label'>\n\n/**\n * A Component for inputting text or other information\n *\n * Its state is managed must be managed by the parent\n */\nconst Input = ({\n id,\n type = 'text',\n value,\n label,\n onChange = noop,\n onChangeText = noop,\n onEditCompleted,\n className = '',\n expanded = true,\n autoFocus,\n onBlur,\n containerClassName,\n ...restProps\n }: InputProps) => {\n const {\n restartTimer,\n clearUpdateTimer\n } = useSaveDelay(() => undefined, 3000)\n const ref = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n if(autoFocus) {\n ref.current?.focus()\n }\n }, [autoFocus])\n\n return (\n <div className={clsx({ 'w-full': expanded }, containerClassName)}>\n {label && <Label {...label} htmlFor={id} className={clsx('mb-1', label.className)}/>}\n <input\n ref={ref}\n value={value}\n id={id}\n type={type}\n className={className}\n onBlur={event => {\n if (onBlur) {\n onBlur(event)\n }\n if (onEditCompleted) {\n onEditCompleted(event.target.value)\n clearUpdateTimer()\n }\n }}\n onChange={e => {\n const value = e.target.value\n if (onEditCompleted) {\n restartTimer(() => {\n onEditCompleted(value)\n clearUpdateTimer()\n })\n }\n onChange(e)\n onChangeText(value)\n }}\n {...restProps}\n />\n </div>\n )\n}\n\ntype InputUncontrolledProps = Omit<InputProps, 'value'> & {\n /**\n * @default ''\n */\n defaultValue?: string,\n}\n\n/**\n * A Component for inputting text or other information\n *\n * Its state is managed by the component itself\n */\nconst InputUncontrolled = ({\n defaultValue = '',\n onChangeText = noop,\n ...props\n }: InputUncontrolledProps) => {\n const [value, setValue] = useState(defaultValue)\n\n return (\n <Input\n {...props}\n value={value}\n onChangeText={text => {\n setValue(text)\n onChangeText(text)\n }}\n />\n )\n}\n\nexport type FormInputProps = InputHTMLAttributes<HTMLInputElement> & {\n id: string,\n labelText?: string,\n errorText?: string,\n labelClassName?: string,\n errorClassName?: string,\n containerClassName?: string,\n}\n\nconst FormInput = forwardRef<HTMLInputElement, FormInputProps>(function FormInput({\n id,\n labelText,\n errorText,\n className,\n labelClassName,\n errorClassName,\n containerClassName,\n required,\n ...restProps\n }, ref) {\n const input = (\n <input\n ref={ref}\n id={id}\n {...restProps}\n className={clsx(\n {\n 'focus:border-primary focus:ring-primary': !errorText,\n 'focus:border-negative focus:ring-negative text-negative': !!errorText,\n },\n className\n )}\n />\n )\n\n return (\n <div className={clsx('flex flex-col gap-y-1', containerClassName)}>\n {labelText && (\n <label htmlFor={id} className={clsx('textstyle-label-md', labelClassName)}>\n {labelText}\n {required && <span className=\"text-primary font-bold\">*</span>}\n </label>\n )}\n {input}\n {errorText && <label htmlFor={id} className={clsx('text-negative', errorClassName)}>{errorText}</label>}\n </div>\n )\n})\n\nexport {\n InputUncontrolled,\n Input,\n FormInput\n}\n","import { useEffect, useState } from 'react'\n\nexport function useSaveDelay(setNotificationStatus: (isShowing: boolean) => void, delay: number) {\n const [updateTimer, setUpdateTimer] = useState<NodeJS.Timeout | undefined>(undefined)\n const [notificationTimer, setNotificationTimer] = useState<NodeJS.Timeout | undefined>(undefined)\n\n const restartTimer = (onSave: () => void) => {\n clearTimeout(updateTimer)\n setUpdateTimer(setTimeout(() => {\n onSave()\n setNotificationStatus(true)\n // Show Saved Notification for fade animation duration\n clearTimeout(notificationTimer)\n setNotificationTimer(setTimeout(() => {\n setNotificationStatus(false)\n clearTimeout(notificationTimer)\n }, delay))\n clearTimeout(updateTimer)\n }, delay))\n }\n\n const clearUpdateTimer = (hasSaved = true) => {\n clearTimeout(updateTimer)\n if (hasSaved) {\n setNotificationStatus(true)\n clearTimeout(notificationTimer)\n setNotificationTimer(setTimeout(() => {\n setNotificationStatus(false)\n clearTimeout(notificationTimer)\n }, delay))\n } else {\n setNotificationStatus(false)\n }\n }\n\n useEffect(() => {\n return () => {\n clearTimeout(updateTimer)\n clearTimeout(notificationTimer)\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return { restartTimer, clearUpdateTimer }\n}","import type { LabelHTMLAttributes } from 'react'\nimport clsx from 'clsx'\n\nexport type LabelType = 'labelSmall' | 'labelMedium' | 'labelBig'\n\nconst styleMapping: Record<LabelType, string> = {\n labelSmall: 'textstyle-label-sm',\n labelMedium: 'textstyle-label-md',\n labelBig: 'textstyle-label-lg',\n}\n\nexport type LabelProps = {\n /** The text for the label */\n name?: string,\n /** The styling for the label */\n labelType?: LabelType,\n} & LabelHTMLAttributes<HTMLLabelElement>\n\n/**\n * A Label component\n */\nexport const Label = ({\n children,\n name,\n labelType = 'labelSmall',\n className,\n ...props\n }: LabelProps) => {\n return (\n <label {...props} className={clsx(styleMapping[labelType], className)}>\n {children ? children : name}\n </label>\n )\n}\n","import { Check, ChevronLeft, ChevronRight } from 'lucide-react'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport { range } from '../../util/array'\nimport { SolidButton } from '../user-action/Button'\nimport clsx from 'clsx'\n\ntype StepperBarTranslation = {\n back: string,\n next: string,\n confirm: string,\n}\n\nconst defaultStepperBarTranslation: Record<Language, StepperBarTranslation> = {\n en: {\n back: 'Back',\n next: 'Next Step',\n confirm: 'Create'\n },\n de: {\n back: 'Zurück',\n next: 'Nächster Schritt',\n confirm: 'Erstellen'\n }\n}\n\nexport type StepperInformation = {\n step: number,\n lastStep: number,\n seenSteps: Set<number>,\n}\n\nexport type StepperBarProps = {\n stepper: StepperInformation,\n onChange: (step: StepperInformation) => void,\n onFinish: () => void,\n showDots?: boolean,\n className?: string,\n}\n\n/**\n * A Component for stepping\n */\nexport const StepperBar = ({\n overwriteTranslation,\n stepper,\n onChange,\n onFinish,\n showDots = true,\n className = '',\n }: PropsForTranslation<StepperBarTranslation, StepperBarProps>) => {\n const translation = useTranslation(defaultStepperBarTranslation, overwriteTranslation)\n const dots = range(0, stepper.lastStep)\n const { step, seenSteps, lastStep } = stepper\n\n const update = (newStep: number) => {\n seenSteps.add(newStep)\n onChange({ step: newStep, seenSteps, lastStep })\n }\n\n return (\n <div\n className={clsx('sticky row p-2 border-2 justify-between rounded-lg shadow-lg', className)}\n >\n <div className=\"flex-[2] justify-start\">\n <SolidButton\n disabled={step === 0}\n onClick={() => {\n update(step - 1)\n }}\n className=\"row gap-x-1 items-center justify-center\"\n >\n <ChevronLeft size={14}/>\n {translation.back}\n </SolidButton>\n </div>\n <div className=\"row flex-[5] gap-x-2 justify-center items-center\">\n {showDots && dots.map((value, index) => {\n const seen = seenSteps.has(index)\n return (\n <div\n key={index}\n onClick={() => seen && update(index)}\n className={clsx('rounded-full w-4 h-4', {\n 'bg-primary hover:brightness-75': index === step && seen,\n 'bg-primary/40 hover:bg-primary': index !== step && seen,\n 'bg-gray-200 outline-transparent': !seen,\n },\n {\n 'cursor-pointer': seen,\n 'cursor-not-allowed': !seen,\n })}\n />\n )\n })}\n </div>\n {step !== lastStep && (\n <div className=\"flex-[2] justify-end\">\n <SolidButton\n onClick={() => update(step + 1)}\n className=\"row gap-x-1 items-center justify-center\"\n >\n {translation.next}\n <ChevronRight size={14}/>\n </SolidButton>\n </div>\n )}\n {step === lastStep && (\n <div className=\"flex-[2] justify-end\">\n <SolidButton\n // TODO check form validity\n disabled={false}\n onClick={onFinish}\n className=\"row gap-x-1 items-center justify-center\"\n >\n <Check size={14}/>\n {translation.confirm}\n </SolidButton>\n </div>\n )}\n </div>\n )\n}\n","import type { ReactElement } from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { Scrollbars } from 'react-custom-scrollbars-2'\nimport { noop } from '../../util/noop'\nimport { Checkbox } from '../user-action/Checkbox'\nimport { Pagination } from './Pagination'\nimport clsx from 'clsx'\nimport type { TextButtonProps } from '../user-action/Button'\nimport { TextButton } from '../user-action/Button'\nimport { ChevronDown, ChevronsUpDown, ChevronUp } from 'lucide-react'\n\nexport type TableStatePagination = {\n currentPage: number,\n entriesPerPage: number,\n}\nexport const defaultTableStatePagination = {\n currentPage: 0,\n entriesPerPage: 5\n}\n\nexport type TableStateSelection<T> = {\n currentSelection: T[],\n hasSelectedAll: boolean,\n hasSelectedSome: boolean,\n hasSelectedNone: boolean,\n}\n\nexport const defaultTableStateSelection = {\n currentSelection: [],\n hasSelectedAll: false,\n hasSelectedSome: false,\n hasSelectedNone: true\n}\n\nexport type TableState = {\n pagination?: TableStatePagination,\n selection?: {\n /**\n * The mapped ids of the dataType\n */\n currentSelection: string[],\n hasSelectedAll: boolean,\n hasSelectedSome: boolean,\n hasSelectedNone: boolean,\n },\n}\n\ntype IdentifierMapping<T> = (dataObject: T) => string\n\nexport const isDataObjectSelected = <T, >(tableState: TableState, dataObject: T, identifierMapping: IdentifierMapping<T>) => {\n if (!tableState.selection) {\n return false\n }\n\n return !!tableState.selection.currentSelection.find(value => value.localeCompare(identifierMapping(dataObject)) === 0)\n}\n\nexport const pageForItem = <T, >(data: T[], item: T, entriesPerPage: number, identifierMapping: IdentifierMapping<T>) => {\n const index = data.findIndex(value => identifierMapping(value) === identifierMapping(item))\n if (index !== -1) {\n return Math.floor(index / entriesPerPage)\n }\n console.warn(\"item doesn't exist on data\", item, data)\n return 0\n}\n\nexport const updatePagination = (pagination: TableStatePagination, dataLength: number): TableStatePagination => ({\n ...pagination,\n currentPage: Math.min(Math.max(Math.ceil(dataLength / pagination.entriesPerPage) - 1, 0), pagination.currentPage)\n})\n\nexport const addElementToTable = <T, >(tableState: TableState, data: T[], dataObject: T, identifierMapping: IdentifierMapping<T>) => {\n return {\n ...tableState,\n pagination: tableState.pagination ? {\n ...tableState.pagination,\n currentPage: pageForItem(data, dataObject, tableState.pagination.entriesPerPage, identifierMapping)\n } : undefined,\n selection: tableState.selection ? {\n ...tableState.selection,\n hasSelectedAll: false,\n hasSelectedSome: tableState.selection.hasSelectedAll || tableState.selection.hasSelectedSome\n } : undefined\n }\n}\n\n/**\n * data length before delete\n */\nexport const removeFromTableSelection = <T, >(tableState: TableState, deletedObjects: T[], dataLength: number, identifierMapping: IdentifierMapping<T>): TableState => {\n if (!tableState.selection) {\n return tableState\n }\n\n const deletedObjectIds = deletedObjects.map(identifierMapping)\n const elementsBefore = tableState.selection.currentSelection.length\n const currentSelection = tableState.selection.currentSelection.filter((value) => !deletedObjectIds.includes(value))\n dataLength -= elementsBefore - currentSelection.length\n\n return {\n ...tableState,\n selection: {\n currentSelection,\n hasSelectedAll: currentSelection.length === dataLength && dataLength !== 0,\n hasSelectedSome: currentSelection.length > 0 && currentSelection.length !== dataLength,\n hasSelectedNone: currentSelection.length === 0,\n },\n pagination: tableState.pagination ? updatePagination(tableState.pagination, dataLength) : undefined\n }\n}\n\nexport const changeTableSelectionSingle = <T, >(tableState: TableState, dataObject: T, dataLength: number, identifierMapping: IdentifierMapping<T>) => {\n if (!tableState.selection) {\n return tableState\n }\n\n const hasSelectedObject = isDataObjectSelected(tableState, dataObject, identifierMapping)\n let currentSelection = [...tableState.selection.currentSelection, identifierMapping(dataObject)] // case !hasSelectedObject\n if (hasSelectedObject) {\n currentSelection = tableState.selection.currentSelection.filter(value => value.localeCompare(identifierMapping(dataObject)) !== 0)\n }\n\n return {\n ...tableState,\n selection: {\n currentSelection,\n hasSelectedAll: currentSelection.length === dataLength,\n hasSelectedSome: currentSelection.length > 0 && currentSelection.length !== dataLength,\n hasSelectedNone: currentSelection.length === 0,\n }\n }\n}\n\nconst changeTableSelectionAll = <T, >(tableState: TableState, data: T[], identifierMapping: IdentifierMapping<T>) => {\n if (!tableState.selection) {\n return tableState\n }\n\n if (data.length === 0) {\n return {\n ...tableState,\n selection: {\n currentSelection: [],\n hasSelectedAll: false,\n hasSelectedSome: false,\n hasSelectedNone: true\n }\n }\n }\n\n const hasSelectedAll = !(tableState.selection.hasSelectedSome || tableState.selection.hasSelectedAll)\n return {\n ...tableState,\n selection: {\n currentSelection: hasSelectedAll ? data.map(identifierMapping) : [],\n hasSelectedAll,\n hasSelectedSome: false,\n hasSelectedNone: !hasSelectedAll\n }\n }\n}\n\nexport type TableSortingType = 'ascending' | 'descending'\nexport type TableSortingFunctionType<T> = (t1: T, t2: T) => number\n\nexport type TableProps<T> = {\n data: T[],\n /**\n * When using selection or pagination\n */\n stateManagement?: [TableState, (tableState: TableState) => void],\n identifierMapping: IdentifierMapping<T>,\n /**\n * Only the cell itself no boilerplate <tr> or <th> required\n */\n header?: ReactElement[],\n /**\n * Only the cells of the row no boilerplate <tr> or <td> required\n */\n rowMappingToCells: (dataObject: T) => ReactElement[],\n sorting?: [TableSortingFunctionType<T>, TableSortingType],\n /**\n * Always go to the page of this element\n */\n focusElement?: T,\n className?: string,\n}\n\n/* Possible extension for better customization\n * Map each element to the displayed row\n * make sure to wrap it in the <tr> and <td> you require\n rowMappingToHTMLRow?: (dataObject: T) => ReactElement\n */\n\n/**\n * A Basic stateless reusable table\n * The state must be handled and saved with the updateTableState method\n */\nexport const Table = <T, >({\n data,\n stateManagement = [{}, noop],\n identifierMapping,\n header,\n rowMappingToCells,\n sorting,\n focusElement,\n className\n }: TableProps<T>) => {\n const sortedData = [...data]\n if (sorting) {\n const [sortingFunction, sortingType] = sorting\n sortedData.sort((a, b) => sortingFunction(a, b) * (sortingType === 'ascending' ? 1 : -1))\n }\n let currentPage = 0\n let pageCount = 1\n let entriesPerPage = 5\n const [tableState, updateTableState] = stateManagement\n\n let shownElements = sortedData\n\n if (tableState?.pagination) {\n if (tableState.pagination.entriesPerPage < 1) {\n console.error('tableState.pagination.entriesPerPage must be >= 1', tableState.pagination.entriesPerPage)\n }\n entriesPerPage = Math.max(1, tableState.pagination.entriesPerPage)\n pageCount = Math.ceil(sortedData.length / entriesPerPage)\n\n if (tableState.pagination.currentPage < 0 || (tableState.pagination.currentPage >= pageCount && pageCount !== 0)) {\n console.error('tableState.pagination.currentPage < 0 || (tableState.pagination.currentPage >= pageCount && pageCount !== 0) must be fullfilled',\n [`pageCount: ${pageCount}`, `tableState.pagination.currentPage: ${tableState.pagination.currentPage}`])\n } else {\n currentPage = tableState.pagination.currentPage\n }\n\n if (focusElement) {\n currentPage = pageForItem(sortedData, focusElement, entriesPerPage, identifierMapping)\n }\n\n shownElements = sortedData.slice(currentPage * entriesPerPage, Math.min(sortedData.length, (currentPage + 1) * entriesPerPage))\n } else {\n currentPage = 0\n }\n\n const headerRow = 'border-b-2 border-gray-300'\n const headerPaddingHead = 'pb-2'\n const headerPaddingBody = 'pt-2'\n const cellPadding = 'py-1 px-2'\n\n const [scrollbarsAutoHeightMin, setScrollbarsAutoHeightMin] = useState(0)\n const tableRef = useRef<HTMLTableElement>(null)\n\n const calculateHeight = () => {\n if (tableRef.current) {\n const tableHeight = tableRef.current.offsetHeight\n const offset = 25\n setScrollbarsAutoHeightMin(tableHeight + offset)\n }\n }\n\n useEffect(() => {\n calculateHeight()\n\n // New function to unbind properly\n const handleResize = () => {\n calculateHeight()\n }\n\n window.addEventListener('resize', handleResize)\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [data, currentPage])\n\n return (\n <div className={clsx('col gap-y-4 overflow-hidden', className)}>\n <div>\n <Scrollbars autoHeight autoHeightMin={scrollbarsAutoHeightMin}>\n <table ref={tableRef} className=\"w-full mb-[12px]\">\n <thead>\n <tr className={headerRow}>\n {header && tableState.selection && (\n <th className={headerPaddingHead}>\n <Checkbox\n checked={tableState.selection.hasSelectedSome ? 'indeterminate' : tableState.selection.hasSelectedAll}\n onChange={() => updateTableState(changeTableSelectionAll(tableState, data, identifierMapping))}\n />\n </th>\n )}\n {header && header.map((value, index) => (\n <th key={`tableHeader${index}`} className={headerPaddingHead}>\n <div className=\"row justify-start px-2\">\n {value}\n </div>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {shownElements.map((value, rowIndex) => (\n <tr key={identifierMapping(value)}>\n {tableState.selection && (\n <td className={clsx(cellPadding, { [headerPaddingBody]: rowIndex === 0 })}>\n <Checkbox\n checked={isDataObjectSelected(tableState, value, identifierMapping)}\n onChange={() => {\n updateTableState(changeTableSelectionSingle(tableState, value, data.length, identifierMapping))\n }}\n />\n </td>\n )}\n {rowMappingToCells(value).map((value1, index) => (\n <td key={index}\n className={clsx(cellPadding, { [headerPaddingBody]: rowIndex === 0 })}>\n {value1}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </Scrollbars>\n </div>\n <div className=\"row justify-center\">\n {tableState.pagination && (\n <Pagination page={currentPage} numberOfPages={pageCount} onPageChanged={page => updateTableState({\n ...tableState,\n pagination: { entriesPerPage, currentPage: page }\n })}/>\n )}\n </div>\n </div>\n )\n}\n\nexport type SortButtonProps = Omit<TextButtonProps, 'onClick'> & {\n ascending?: TableSortingType,\n onClick: (newTableSorting: TableSortingType) => void,\n}\n\n/**\n * A Extension of the normal button that displays the sorting state right of the content\n */\nexport const SortButton = ({\n children,\n ascending,\n color,\n onClick,\n ...buttonProps\n }: SortButtonProps) => {\n return (\n <TextButton\n color={color}\n onClick={() => onClick(ascending === 'descending' ? 'ascending' : 'descending')}\n {...buttonProps}\n >\n <div className=\"row gap-x-2\">\n {children}\n {ascending === 'ascending' ? <ChevronUp/> : (!ascending ? <ChevronsUpDown/> : <ChevronDown/>)}\n </div>\n </TextButton>\n )\n}\n\n","import { useState } from 'react'\nimport type { CheckedState } from '@radix-ui/react-checkbox'\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox'\nimport { Check, Minus } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\ntype CheckBoxSize = 'small' | 'medium' | 'large'\n\nconst checkboxSizeMapping: Record<CheckBoxSize, string> = {\n small: 'size-4',\n medium: 'size-6',\n large: 'size-8',\n}\n\nconst checkboxIconSizeMapping: Record<CheckBoxSize, string> = {\n small: 'size-3',\n medium: 'size-5',\n large: 'size-7',\n}\n\ntype CheckboxProps = {\n /** used for the label's `for` attribute */\n id?: string,\n label?: Omit<LabelProps, 'id'>,\n /**\n * @default false\n */\n checked: CheckedState,\n disabled?: boolean,\n onChange?: (checked: boolean) => void,\n onChangeTristate?: (checked: CheckedState) => void,\n size?: CheckBoxSize,\n className?: string,\n containerClassName?: string,\n}\n\n/**\n * A Tristate checkbox\n *\n * The state is managed by the parent\n */\nconst Checkbox = ({\n id,\n label,\n checked,\n disabled,\n onChange,\n onChangeTristate,\n size = 'medium',\n className = '',\n containerClassName\n }: CheckboxProps) => {\n const usedSizeClass = checkboxSizeMapping[size]\n const innerIconSize = checkboxIconSizeMapping[size]\n\n const propagateChange = (checked: CheckedState) => {\n if (onChangeTristate) {\n onChangeTristate(checked)\n }\n if (onChange) {\n onChange(checked === 'indeterminate' ? false : checked)\n }\n }\n\n const changeValue = () => {\n const newValue = checked === 'indeterminate' ? false : !checked\n propagateChange(newValue)\n }\n\n return (\n <div className={clsx('row justify-center items-center', containerClassName)}>\n <CheckboxPrimitive.Root\n onCheckedChange={propagateChange}\n checked={checked}\n disabled={disabled}\n id={id}\n className={clsx(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {\n 'text-disabled-text border-disabled-text': disabled,\n 'border-on-background': !disabled,\n 'bg-primary/30 border-primary text-primary': checked === true || checked === 'indeterminate',\n 'hover:border-gray-400 focus:hover:border-primary': !checked\n }, className)}\n >\n <CheckboxPrimitive.Indicator>\n {checked === true && <Check className={innerIconSize}/>}\n {checked === 'indeterminate' && <Minus className={innerIconSize}/>}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n {label && (\n <Label {...label} className={clsx('cursor-pointer', label.className)} htmlFor={id}\n onClick={changeValue}/>\n )}\n </div>\n )\n}\n\ntype CheckboxUncontrolledProps = Omit<CheckboxProps, 'value' | 'checked'> & {\n /**\n * @default false\n */\n defaultValue?: CheckedState,\n}\n\n/**\n * A Tristate checkbox\n *\n * The state is managed by this component\n */\nconst CheckboxUncontrolled = ({\n onChange,\n onChangeTristate,\n defaultValue = false,\n ...props\n }: CheckboxUncontrolledProps) => {\n const [checked, setChecked] = useState(defaultValue)\n\n const handleChange = (checked: CheckedState) => {\n if (onChangeTristate) {\n onChangeTristate(checked)\n }\n if (onChange) {\n onChange(checked === 'indeterminate' ? false : checked)\n }\n setChecked(checked)\n }\n\n return (\n <Checkbox\n {...props}\n checked={checked}\n onChangeTristate={handleChange}\n />\n )\n}\n\nexport {\n CheckboxProps,\n CheckboxUncontrolled,\n Checkbox,\n}\n","import type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\n\ntype TextImageColor = 'primary' | 'secondary' | 'dark'\n\ntype TextImageTranslation = {\n showMore: string,\n}\n\nconst defaultTextImageTranslation: Record<Language, TextImageTranslation> = {\n de: {\n showMore: 'Mehr anzeigen'\n },\n en: {\n showMore: 'Show more'\n }\n}\n\nexport type TextImageProps = {\n title: string,\n description: string,\n imageUrl: string,\n onShowMoreClicked?: () => void,\n color?: TextImageColor,\n badge?: string,\n contentClassName?: string,\n className?: string,\n}\n\n/**\n * A Component for layering a Text upon a Image\n */\nexport const TextImage = ({\n overwriteTranslation,\n title,\n description,\n imageUrl,\n onShowMoreClicked,\n color = 'primary',\n badge,\n contentClassName = '',\n className = '',\n }: PropsForTranslation<TextImageTranslation, TextImageProps>) => {\n const translation = useTranslation(defaultTextImageTranslation, overwriteTranslation)\n\n const chipColorMapping: Record<TextImageColor, string> = {\n primary: 'text-text-image-primary-background bg-text-text-image-primary-text',\n secondary: 'text-text-image-secondary-background bg-text-text-image-secondary-text',\n dark: 'text-text-image-dark-background bg-text-text-image-dark-text',\n }\n\n const colorMapping: Record<TextImageColor, string> = {\n primary: 'text-text-image-primary-text bg-linear-to-r from-30% from-text-image-primary-background to-text-image-primary-background/55',\n secondary: 'text-text-image-secondary-text bg-linear-to-r from-30% from-text-image-secondary-background to-text-image-secondary-background/55',\n dark: 'text-text-image-dark-text bg-linear-to-r from-30% from-text-image-dark-background to-text-image-dark-background/55',\n }\n\n return (\n <div\n className={clsx('rounded-2xl w-full', className)}\n style={{\n backgroundImage: `url(${imageUrl})`,\n backgroundSize: 'cover',\n }}>\n <div\n className={clsx(`col px-6 py-12 rounded-2xl h-full`, colorMapping[color], contentClassName)}>\n {badge && (\n <div className={clsx(`chip-full bg-white mb-2 py-2 px-4 w-fit`, chipColorMapping[color])}>\n <span className=\"text-lg font-bold\">{badge}</span>\n </div>\n )}\n <div className=\"col gap-y-1 text-white overflow-hidden\">\n <span className=\"textstyle-title-xl\">{title}</span>\n <span className=\"text-ellipsis overflow-hidden\">{description}</span>\n </div>\n {onShowMoreClicked && (\n <div className=\"row mt-2 text-white underline\">\n <button onClick={onShowMoreClicked}>{translation.showMore}</button>\n </div>\n )}\n </div>\n </div>\n )\n}\n","export type VerticalDividerProps = {\n width?: number,\n height?: number,\n strokeWidth?: number,\n dashGap?: number,\n dashLength?: number,\n}\n\n/**\n * A Component for creating a vertical Divider\n */\nexport const VerticalDivider = ({\n width = 1,\n height = 100,\n strokeWidth = 4,\n dashGap = 4,\n dashLength = 4,\n }: VerticalDividerProps) => {\n return (\n <div style={{ width: width + 'px', height: height + 'px' }}>\n <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <line\n opacity=\"0.5\"\n x1={width / 2}\n y1={height}\n x2={width / 2}\n y2=\"0\"\n stroke=\"url(#paint_linear)\"\n strokeWidth={strokeWidth}\n strokeDasharray={`${dashLength} ${dashLength + dashGap}`}\n strokeLinecap=\"round\"\n />\n <defs>\n <linearGradient\n id=\"paint_linear\"\n x1={width / 2}\n y1=\"0\"\n x2={width / 2}\n y2={height}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop stopOpacity=\"0\" stopColor=\"currentColor\"/>\n <stop offset=\"0.5\" stopColor=\"currentColor\"/>\n <stop offset=\"1\" stopColor=\"currentColor\" stopOpacity=\"0\"/>\n </linearGradient>\n </defs>\n </svg>\n </div>\n )\n}\n","import { AlertOctagon } from 'lucide-react'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\n\ntype ErrorComponentTranslation = {\n errorOccurred: string,\n}\n\nconst defaultErrorComponentTranslation: Record<Language, ErrorComponentTranslation> = {\n en: {\n errorOccurred: 'An error occurred'\n },\n de: {\n errorOccurred: 'Ein Fehler ist aufgetreten'\n }\n}\n\nexport type ErrorComponentProps = {\n errorText?: string,\n classname?: string,\n}\n\n/**\n * The Component to show when an error occurred\n */\nexport const ErrorComponent = ({\n overwriteTranslation,\n errorText,\n classname\n }: PropsForTranslation<ErrorComponentTranslation, ErrorComponentProps>) => {\n const translation = useTranslation(defaultErrorComponentTranslation, overwriteTranslation)\n return (\n <div className={clsx('col items-center justify-center gap-y-4 w-full h-24', classname)}>\n <AlertOctagon size={64} className=\"text-warning\"/>\n {errorText ?? `${translation.errorOccurred} :(`}\n </div>\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport { useState } from 'react'\nimport type { LoadingAnimationProps } from './LoadingAnimation'\nimport { LoadingAnimation } from './LoadingAnimation'\nimport type { ErrorComponentProps } from './ErrorComponent'\nimport { ErrorComponent } from './ErrorComponent'\n\nexport type LoadingAndErrorComponentProps = PropsWithChildren<{\n isLoading?: boolean,\n hasError?: boolean,\n loadingProps?: LoadingAnimationProps,\n errorProps?: ErrorComponentProps,\n /**\n * in milliseconds\n */\n minimumLoadingDuration?: number,\n}>\n\n/**\n * A Component that shows the Error and Loading animation, when appropriate and the children otherwise\n */\nexport const LoadingAndErrorComponent = ({\n children,\n isLoading = false,\n hasError = false,\n errorProps,\n loadingProps,\n minimumLoadingDuration\n }: LoadingAndErrorComponentProps) => {\n const [isInMinimumLoading, setIsInMinimumLoading] = useState(false)\n const [hasUsedMinimumLoading, setHasUsedMinimumLoading] = useState(false)\n if (minimumLoadingDuration && !isInMinimumLoading && !hasUsedMinimumLoading) {\n setIsInMinimumLoading(true)\n setTimeout(() => {\n setIsInMinimumLoading(false)\n setHasUsedMinimumLoading(true)\n }, minimumLoadingDuration)\n }\n\n if (isLoading || (minimumLoadingDuration && isInMinimumLoading)) {\n return <LoadingAnimation {...loadingProps}/>\n }\n if (hasError) {\n return <ErrorComponent {...errorProps}/>\n }\n return children\n}\n","import type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\nimport { Helpwave } from '../icons-and-geometry/Helpwave'\n\ntype LoadingAnimationTranslation = {\n loading: string,\n}\n\nconst defaultLoadingAnimationTranslation: Record<Language, LoadingAnimationTranslation> = {\n en: {\n loading: 'Loading data'\n },\n de: {\n loading: 'Lade Daten'\n }\n}\n\nexport type LoadingAnimationProps = {\n loadingText?: string,\n classname?: string,\n}\n\n/**\n * A Component to show when loading data\n */\nexport const LoadingAnimation = ({\n overwriteTranslation,\n loadingText,\n classname\n }: PropsForTranslation<LoadingAnimationTranslation, LoadingAnimationProps>) => {\n const translation = useTranslation(defaultLoadingAnimationTranslation, overwriteTranslation)\n return (\n <div className={clsx('col items-center justify-center w-full h-24', classname)}>\n <Helpwave animate=\"loading\"/>\n {loadingText ?? `${translation.loading}...`}\n </div>\n )\n}\n","import clsx from 'clsx'\nimport type { SolidButtonProps } from '../user-action/Button'\nimport { ButtonUtil, SolidButton } from '../user-action/Button'\nimport { noop } from '@/util/noop'\nimport { Helpwave } from '../icons-and-geometry/Helpwave'\n\ntype LoadingButtonProps = {\n isLoading?: boolean,\n} & SolidButtonProps\n\nexport const LoadingButton = ({ isLoading = false, size = 'medium', onClick, ...rest }: LoadingButtonProps) => {\n const paddingClass = ButtonUtil.paddingMapping[size]\n\n return (\n <div className=\"inline-block relative\">\n {\n isLoading && (\n <div className={clsx('absolute inset-0 row items-center justify-center bg-white/40', paddingClass)}>\n <Helpwave animate=\"loading\" className=\"text-white\"/>\n </div>\n )\n }\n <SolidButton {...rest} disabled={rest.disabled} onClick={isLoading ? noop : onClick}/>\n </div>\n )\n}\n","export type ProgressIndicatorProps = {\n /*\n The amount of progress that has been made\n Value form 0 to 1\n */\n progress: number,\n strokeWidth?: number,\n size?: keyof typeof sizeMapping,\n direction?: 'clockwise' | 'counterclockwise',\n /*\n Rotation of the starting point of the indicator\n default start at 3 o'clock\n Given in degree\n */\n rotation?: number,\n}\n\nconst sizeMapping = { small: 16, medium: 24, big: 48 }\n\n/**\n * A progress indicator\n *\n * Start rotation is 3 o'clock and fills counterclockwise\n *\n * Progress is given from 0 to 1\n */\nexport const ProgressIndicator = ({\n progress,\n strokeWidth = 5,\n size = 'medium',\n direction = 'counterclockwise',\n rotation = 0\n }: ProgressIndicatorProps) => {\n const currentSize = sizeMapping[size]\n const center = currentSize / 2\n const radius = center - strokeWidth / 2\n const arcLength = 2 * Math.PI * radius\n const arcOffset = arcLength * progress\n if (direction === 'clockwise') {\n rotation += 360 * progress\n }\n return (\n <svg\n style={{\n height: `${currentSize}px`,\n width: `${currentSize}px`,\n transform: `rotate(${rotation}deg)`\n }}\n >\n <circle cx={center} cy={center} r={radius} fill=\"transparent\" strokeWidth={strokeWidth}\n className=\"stroke-primary\"\n />\n <circle cx={center} cy={center} r={radius} fill=\"transparent\" strokeWidth={strokeWidth}\n strokeDasharray={arcLength} strokeDashoffset={arcOffset} className=\"stroke-gray-300\"\n />\n </svg>\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport type { SolidButtonColor } from '../user-action/Button'\nimport { SolidButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport clsx from 'clsx'\nimport type { ModalProps } from '@/components/layout-and-navigation/Overlay'\nimport { Modal } from '@/components/layout-and-navigation/Overlay'\n\ntype ConfirmModalTranslation = {\n confirm: string,\n cancel: string,\n decline: string,\n}\n\nexport type ConfirmModalType = 'positive' | 'negative' | 'neutral' | 'primary'\n\nconst defaultConfirmDialogTranslation = {\n en: {\n confirm: 'Confirm',\n cancel: 'Cancel',\n decline: 'Decline'\n },\n de: {\n confirm: 'Bestätigen',\n cancel: 'Abbrechen',\n decline: 'Ablehnen'\n }\n}\n\ntype ButtonOverwriteType = {\n text?: string,\n color?: SolidButtonColor,\n disabled?: boolean,\n}\n\nexport type ConfirmModalProps = Omit<ModalProps, 'onClose'> & {\n isShowingDecline?: boolean,\n requireAnswer?: boolean,\n onCancel: () => void,\n onConfirm: () => void,\n onDecline?: () => void,\n confirmType?: ConfirmModalType,\n /**\n * Order: Cancel, Decline, Confirm\n */\n buttonOverwrites?: [ButtonOverwriteType, ButtonOverwriteType, ButtonOverwriteType],\n}\n\n/**\n * A Modal for asking the user for confirmation\n */\nexport const ConfirmModal = ({\n overwriteTranslation,\n children,\n onCancel,\n onConfirm,\n onDecline,\n confirmType = 'positive',\n buttonOverwrites,\n className,\n ...restProps\n }: PropsForTranslation<ConfirmModalTranslation, PropsWithChildren<ConfirmModalProps>>) => {\n const translation = useTranslation(defaultConfirmDialogTranslation, overwriteTranslation)\n\n const mapping: Record<ConfirmModalType, SolidButtonColor> = {\n neutral: 'neutral',\n negative: 'negative',\n positive: 'positive',\n primary: 'primary',\n }\n\n return (\n <Modal {...restProps} onClose={onCancel} className={clsx('justify-between', className)}>\n <div className=\"col grow\">\n {children}\n </div>\n <div className=\"row mt-3 gap-x-4 justify-end\">\n {onCancel && (\n <SolidButton\n color={buttonOverwrites?.[0].color ?? 'neutral'}\n onClick={onCancel}\n disabled={buttonOverwrites?.[0].disabled ?? false}\n >\n {buttonOverwrites?.[0].text ?? translation.cancel}\n </SolidButton>\n )}\n {onDecline && (\n <SolidButton\n color={buttonOverwrites?.[1].color ?? 'negative'}\n onClick={onDecline}\n\n disabled={buttonOverwrites?.[1].disabled ?? false}\n >\n {buttonOverwrites?.[1].text ?? translation.decline}\n </SolidButton>\n )}\n <SolidButton\n autoFocus\n color={buttonOverwrites?.[2].color ?? mapping[confirmType]}\n onClick={onConfirm}\n disabled={buttonOverwrites?.[2].disabled ?? false}\n >\n {buttonOverwrites?.[2].text ?? translation.confirm}\n </SolidButton>\n </div>\n </Modal>\n )\n}\n","import type { PropsWithChildren } from 'react'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { ConfirmModalProps } from '@/components/modals/ConfirmModal'\nimport { ConfirmModal } from '@/components/modals/ConfirmModal'\n\ntype DiscardChangesModalTranslation = {\n save: string,\n cancel: string,\n dontSave: string,\n title: string,\n description: string,\n}\n\nconst defaultDiscardChangesModalTranslation = {\n en: {\n save: 'Save',\n cancel: 'Cancel',\n dontSave: 'Don\\'t save',\n title: 'Unsaved Changes',\n description: 'Do you want to save your changes?'\n },\n de: {\n save: 'Speichern',\n cancel: 'Abbrechen',\n dontSave: 'Nicht Speichern',\n title: 'Ungespeicherte Änderungen',\n description: 'Möchtest du die Änderungen speichern?'\n }\n}\n\ntype DiscardChangesModalProps = Omit<ConfirmModalProps, 'onDecline' | 'onConfirm' | 'buttonOverwrites'> & {\n isShowingDecline?: boolean,\n requireAnswer?: boolean,\n onCancel: () => void,\n onSave: () => void,\n onDontSave: () => void,\n}\n\nexport const DiscardChangesModal = ({\n overwriteTranslation,\n children,\n onCancel,\n onSave,\n onDontSave,\n headerProps,\n ...modalProps\n }: PropsForTranslation<DiscardChangesModalTranslation, PropsWithChildren<DiscardChangesModalProps>>) => {\n const translation = useTranslation(defaultDiscardChangesModalTranslation, overwriteTranslation)\n return (\n <ConfirmModal\n headerProps={{\n ...headerProps,\n titleText: headerProps?.titleText ?? translation.title,\n descriptionText: headerProps?.descriptionText ?? translation.description,\n }}\n onConfirm={onSave}\n onCancel={onCancel}\n onDecline={onDontSave}\n buttonOverwrites={[{ text: translation.cancel }, { text: translation.dontSave }, { text: translation.save }]}\n {...modalProps}\n >\n {children}\n </ConfirmModal>\n )\n}\n","import type { InputProps } from '../user-action/Input'\nimport { Input } from '../user-action/Input'\nimport type { ConfirmDialogProps } from '../dialogs/ConfirmDialog'\nimport { ConfirmDialog } from '../dialogs/ConfirmDialog'\n\nexport type InputModalProps = ConfirmDialogProps & {\n inputs: InputProps[],\n}\n\n/**\n * A modal for receiving multiple inputs\n */\nexport const InputModal = ({\n inputs,\n buttonOverwrites,\n ...restProps\n }: InputModalProps) => {\n return (\n <ConfirmDialog\n buttonOverwrites={buttonOverwrites}\n {...restProps}\n >\n {inputs.map((inputProps, index) => <Input key={`input ${index}`} {...inputProps}/>)}\n </ConfirmDialog>\n )\n}\n","import { Menu } from '@headlessui/react'\nimport { ChevronDown, ChevronUp, Search } from 'lucide-react'\nimport type { ReactNode } from 'react'\nimport { useEffect, useState } from 'react'\nimport clsx from 'clsx'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\nimport { MultiSearchWithMapping } from '@/util/simpleSearch'\nimport { Input } from '@/components/user-action/Input'\n\nexport type SelectOption<T> = {\n label: ReactNode,\n value: T,\n disabled?: boolean,\n className?: string,\n}\n\nexport type SelectProps<T> = {\n value?: T,\n label?: LabelProps,\n options: SelectOption<T>[],\n onChange: (value: T) => void,\n isHidingCurrentValue?: boolean,\n hintText?: string,\n showDisabledOptions?: boolean,\n className?: string,\n isDisabled?: boolean,\n textColor?: string,\n hoverColor?: string,\n /**\n * The items will be at the start of the select and aren't selectable\n */\n additionalItems?: ReactNode[],\n selectedDisplayOverwrite?: ReactNode,\n};\n\n/**\n * A Select Component for selecting form a list of options\n *\n * The State is managed by the parent\n */\nexport const Select = <T, >({\n value,\n label,\n options,\n onChange,\n isHidingCurrentValue = true,\n hintText = '',\n showDisabledOptions = true,\n isDisabled,\n className,\n textColor = 'text-menu-text',\n hoverColor = 'hover:brightness-90',\n additionalItems,\n selectedDisplayOverwrite,\n }: SelectProps<T>) => {\n // Notice: for more complex types this check here might need an additional compare method\n let filteredOptions = isHidingCurrentValue ? options.filter(option => option.value !== value) : options\n if (!showDisabledOptions) {\n filteredOptions = filteredOptions.filter(value => !value.disabled)\n }\n const selectedOption = options.find(option => option.value === value)\n if (value !== undefined && selectedOption === undefined && selectedDisplayOverwrite === undefined) {\n console.warn('The selected value is not found in the options list. This might be an error on your part or' +\n ' default behavior if it is complex data type on which === does not work. In case of the latter' +\n ' use selectedDisplayOverwrite to set your selected text or component')\n }\n\n const borderColor = 'border-menu-border'\n\n return (\n <div className={clsx(className)}>\n {label && (\n <Label {...label} labelType={label.labelType ?? 'labelBig'} className={clsx('mb-1', label.className)}/>\n )}\n <Menu as=\"div\" className=\"relative text-menu-text\">\n {({ open }) => (\n <>\n <Menu.Button\n className={clsx(\n 'inline-flex w-full justify-between items-center rounded-t-lg border-2 px-4 py-2 font-medium bg-menu-background text-menu-text',\n textColor, borderColor,\n {\n 'rounded-b-lg': !open,\n [hoverColor]: !isDisabled,\n 'bg-disabled-background cursor-not-allowed text-disabled': isDisabled\n }\n )}\n disabled={isDisabled}\n >\n <span>{selectedDisplayOverwrite ?? selectedOption?.label ?? hintText}</span>\n {open ? <ChevronUp/> : <ChevronDown/>}\n </Menu.Button>\n <Menu.Items\n className=\"absolute w-full z-10 rounded-b-lg bg-menu-background text-menu-text shadow-lg max-h-[500px] overflow-y-auto\"\n >\n {(additionalItems ?? []).map((item, index) => (\n <div key={`additionalItems${index}`}\n className={clsx(borderColor, 'px-4 py-2 overflow-hidden whitespace-nowrap text-ellipsis border-2 border-t-0', {\n 'border-b-0 rounded-b-lg': filteredOptions.length === 0 && index === (additionalItems?.length ?? 1) - 1,\n })}\n >\n {item}\n </div>\n ))}\n {filteredOptions.map((option, index) => (\n <Menu.Item key={`item${index}`}>\n {\n <div\n className={clsx('px-4 py-2 overflow-hidden whitespace-nowrap text-ellipsis border-2 border-t-0 cursor-pointer',\n option.className, borderColor, {\n 'brightness-90': option.value === value,\n 'brightness-95': index % 2 === 1,\n 'text-disabled bg-disabled-background cursor-not-allowed': !!option.disabled,\n 'bg-menu-background text-menu-text hover:brightness-90 cursor-pointer': !option.disabled,\n 'rounded-b-lg': index === filteredOptions.length - 1,\n })}\n onClick={() => {\n if (!option.disabled) {\n onChange(option.value)\n }\n }}\n >\n {option.label}\n </div>\n }\n </Menu.Item>\n ))}\n </Menu.Items>\n </>\n )}\n </Menu>\n </div>\n )\n}\n\nexport const SelectUncontrolled = <T, >({\n options, onChange, value, hintText, ...props\n }: SelectProps<T>) => {\n const [selected, setSelected] = useState(value)\n\n useEffect(() => {\n if (options.find(options => options.value === value)) {\n setSelected(value)\n }\n }, [options, value])\n\n return (\n <Select\n value={selected}\n options={options}\n onChange={value => {\n setSelected(value)\n onChange(value)\n }}\n hintText={hintText}\n {...props}\n />\n )\n}\n\nexport type SearchableSelectProps<T> = SelectProps<T> & {\n searchMapping: (value: SelectOption<T>) => string[],\n}\n\n/**\n * A Select where items can be searched\n */\nexport const SearchableSelect = <T, >({\n value,\n options,\n searchMapping,\n ...selectProps\n }: SearchableSelectProps<T>) => {\n const [search, setSearch] = useState<string>('')\n const filteredOptions = MultiSearchWithMapping(search, options, searchMapping)\n\n return (\n <Select\n value={value}\n options={filteredOptions}\n additionalItems={[(\n <div key=\"selectSearch\" className=\"row gap-x-2 items-center\">\n <Input autoFocus={true} value={search} onChangeText={setSearch}/>\n <Search/>\n </div>\n )]}\n {...selectProps}\n />\n )\n}\n\nexport default { Select, SelectUncontrolled, SearchableSelect }","import { type PropsWithChildren } from 'react'\nimport type { PropsForTranslation, Translation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { Select } from '../user-action/Select'\nimport type { Language } from '@/localization/util'\nimport { LanguageUtil } from '@/localization/util'\nimport { useLanguage } from '@/localization/LanguageProvider'\nimport { SolidButton } from '../user-action/Button'\nimport { Modal, type ModalProps } from '../layout-and-navigation/Overlay'\n\ntype LanguageModalTranslation = {\n title: string,\n message: string,\n done: string,\n} & Record<Language, string>\n\nconst defaultLanguageModalTranslation: Translation<LanguageModalTranslation> = {\n en: {\n title: 'Language',\n message: 'Choose your language',\n done: 'Done',\n ...LanguageUtil.languagesLocalNames\n },\n de: {\n title: 'Sprache',\n message: 'Wähle deine bevorzugte Sprache',\n done: 'Fertig',\n ...LanguageUtil.languagesLocalNames\n }\n}\n\ntype LanguageModalProps = ModalProps\n\n/**\n * A Modal for selecting the Language\n *\n * The State of open needs to be managed by the parent\n */\nexport const LanguageModal = ({\n overwriteTranslation,\n headerProps,\n onClose,\n ...modalProps\n }: PropsForTranslation<LanguageModalTranslation, PropsWithChildren<LanguageModalProps>>) => {\n const { language, setLanguage } = useLanguage()\n const translation = useTranslation(defaultLanguageModalTranslation, overwriteTranslation)\n\n return (\n <Modal\n headerProps={{\n ...headerProps,\n titleText: headerProps?.titleText ?? translation.title,\n descriptionText: headerProps?.descriptionText ?? translation.message,\n }}\n onClose={onClose}\n {...modalProps}\n >\n <div className=\"w-64\">\n <Select\n className=\"mt-2\"\n value={language}\n options={LanguageUtil.languages.map((language) => ({ label: translation[language], value: language }))}\n onChange={(language: string) => setLanguage(language as Language)}\n />\n <div className=\"row mt-3 gap-x-4 justify-end\">\n <SolidButton autoFocus color=\"positive\" onClick={onClose}>\n {translation.done}\n </SolidButton>\n </div>\n </div>\n </Modal>\n )\n}\n","import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport type { Translation } from '@/localization/useTranslation'\nimport { noop } from '@/util/noop'\n\nconst themes = ['light', 'dark'] as const\n\nexport type ThemeType = typeof themes[number]\n\nexport type ThemeTypeTranslation = Record<ThemeType, string>\n\nconst defaultThemeTypeTranslation: Translation<ThemeTypeTranslation> = {\n en: {\n dark: 'Dark',\n light: 'Light'\n },\n de: {\n dark: 'Dunkel',\n light: 'Hell'\n }\n}\n\nexport const ThemeUtil = {\n themes,\n translation: defaultThemeTypeTranslation,\n}\n\ntype ThemeContextType = {\n theme: ThemeType,\n setTheme: Dispatch<SetStateAction<ThemeType>>,\n}\n\nexport const ThemeContext = createContext<ThemeContextType>({\n theme: 'light',\n setTheme: noop\n})\n\ntype ThemeProviderProps = {\n initialTheme?: ThemeType,\n}\n\nexport const ThemeProvider = ({ children, initialTheme = 'light' }: PropsWithChildren<ThemeProviderProps>) => {\n const [theme, setTheme] = useState<ThemeType>(initialTheme)\n\n useEffect(() => {\n if (theme !== initialTheme) {\n console.warn('ThemeProvider initial state changed: Prefer using useTheme\\'s setTheme instead')\n setTheme(initialTheme)\n }\n }, [initialTheme]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n document.documentElement.setAttribute('data-theme', theme)\n }, [theme])\n\n return (\n <ThemeContext.Provider value={{ theme, setTheme }}>\n {children}\n </ThemeContext.Provider>\n )\n}\n\n\nexport const useTheme = () => useContext(ThemeContext)\n","import { type PropsWithChildren } from 'react'\nimport type { PropsForTranslation, Translation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { Select } from '../user-action/Select'\nimport { SolidButton } from '../user-action/Button'\nimport { Modal, type ModalProps } from '../layout-and-navigation/Overlay'\nimport type { ThemeType, ThemeTypeTranslation } from '@/theming/useTheme'\nimport { useTheme } from '@/theming/useTheme'\nimport { ThemeUtil } from '@/theming/useTheme'\n\ntype ThemeModalTranslation = {\n title: string,\n message: string,\n done: string,\n} & ThemeTypeTranslation\n\nconst defaultConfirmDialogTranslation: Translation<ThemeModalTranslation> = {\n en: {\n title: 'Theme',\n message: 'Choose your preferred theme',\n done: 'Done',\n ...ThemeUtil.translation.en\n },\n de: {\n title: 'Farbschema',\n message: 'Wähle dein bevorzugtes Farbschema',\n done: 'Fertig',\n ...ThemeUtil.translation.en\n }\n}\n\ntype ThemeModalProps = ModalProps\n\n/**\n * A Modal for selecting the Theme\n *\n * The State of open needs to be managed by the parent\n */\nexport const ThemeModal = ({\n overwriteTranslation,\n headerProps,\n onClose,\n ...modalProps\n }: PropsForTranslation<ThemeModalTranslation, PropsWithChildren<ThemeModalProps>>) => {\n const { theme, setTheme } = useTheme()\n const translation = useTranslation(defaultConfirmDialogTranslation, overwriteTranslation)\n\n return (\n <Modal\n headerProps={{\n ...headerProps,\n titleText: headerProps?.titleText ?? translation.title,\n descriptionText: headerProps?.descriptionText ?? translation.message,\n }}\n onClose={onClose}\n {...modalProps}\n >\n <div className=\"w-64\">\n <Select\n className=\"mt-2\"\n value={theme}\n options={ThemeUtil.themes.map((theme) => ({ label: translation[theme], value: theme }))}\n onChange={(theme: string) => setTheme(theme as ThemeType)}\n />\n <div className=\"row mt-3 gap-x-4 justify-end\">\n <SolidButton autoFocus color=\"positive\" onClick={onClose}>\n {translation.done}\n </SolidButton>\n </div>\n </div>\n </Modal>\n )\n}\n","import { Check } from 'lucide-react'\nimport { noop } from '../../util/noop'\nimport { Checkbox } from '../user-action/Checkbox'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype CheckboxPropertyTranslation = {\n yes: string,\n no: string,\n}\n\nconst defaultCheckboxPropertyTranslation: Record<Language, CheckboxPropertyTranslation> = {\n en: {\n yes: 'Yes',\n no: 'No'\n },\n de: {\n yes: 'Ja',\n no: 'Nein'\n }\n}\n\nexport type CheckboxPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue' | 'onRemove'> & {\n value?: boolean,\n onChange?: (value: boolean) => void,\n}\n\n/**\n * An Input for a boolen properties\n */\nexport const CheckboxProperty = ({\n overwriteTranslation,\n value,\n onChange = noop,\n readOnly,\n ...baseProps\n }: PropsForTranslation<CheckboxPropertyTranslation, CheckboxPropertyProps>) => {\n const translation = useTranslation(defaultCheckboxPropertyTranslation, overwriteTranslation)\n\n return (\n <PropertyBase\n {...baseProps}\n hasValue={true}\n readOnly={readOnly}\n icon={<Check size={16}/>}\n input={() => (\n <div className=\"row py-2 px-4 items-center\">\n <Checkbox\n // TODO make bigger as in #904\n checked={value ?? true}\n disabled={readOnly}\n onChange={onChange}\n label={{ name: `${translation.yes}/${translation.no}`, labelType: 'labelMedium' }}\n />\n </div>\n )}\n />\n )\n}\n","import type { ReactNode } from 'react'\nimport { AlertTriangle } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '../../localization/util'\nimport { TextButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\n\ntype PropertyBaseTranslation = {\n remove: string,\n}\n\nconst defaultPropertyBaseTranslation: Record<Language, PropertyBaseTranslation> = {\n en: {\n remove: 'Remove'\n },\n de: {\n remove: 'Entfernen'\n }\n}\n\nexport type PropertyBaseProps = {\n name: string,\n input: (props: { softRequired: boolean, hasValue: boolean }) => ReactNode,\n onRemove?: () => void,\n hasValue: boolean,\n softRequired?: boolean,\n readOnly?: boolean,\n icon?: ReactNode,\n className?: string,\n}\n\n/**\n * A component for showing a properties with uniform styling\n */\nexport const PropertyBase = ({\n overwriteTranslation,\n name,\n input,\n softRequired = false,\n hasValue,\n icon,\n readOnly,\n onRemove,\n className = '',\n }: PropsForTranslation<PropertyBaseTranslation, PropertyBaseProps>) => {\n const translation = useTranslation(defaultPropertyBaseTranslation, overwriteTranslation)\n const requiredAndNoValue = softRequired && !hasValue\n return (\n <div className={clsx('row gap-x-0 group', className)}>\n <div\n className={\n clsx('row gap-x-2 !w-[200px] px-4 py-2 items-center rounded-l-xl border-2 border-r-0', {\n 'bg-gray-100 text-black group-hover:border-primary border-gray-400': !requiredAndNoValue,\n 'bg-warning text-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,\n }, className)}\n >\n {icon}\n {name}\n </div>\n <div className={\n clsx('row grow justify-between items-center rounded-r-xl border-2 border-l-0', {\n 'bg-white group-hover:border-primary border-gray-400': !requiredAndNoValue,\n 'bg-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,\n }, className)}\n >\n {input({ softRequired, hasValue })}\n {requiredAndNoValue && (\n <div className=\"text-warning pr-4\"><AlertTriangle size={24}/></div>\n )}\n {onRemove && (\n <TextButton\n onClick={onRemove}\n color=\"negative\"\n className={clsx('pr-4 items-center', { '!text-transparent': !hasValue || readOnly })}\n disabled={!hasValue || readOnly}\n >\n {translation.remove}\n </TextButton>\n )}\n </div>\n </div>\n )\n}\n","import { CalendarDays } from 'lucide-react'\nimport clsx from 'clsx'\nimport { formatDate, formatDateTime } from '@/util/date'\nimport { noop } from '@/util/noop'\nimport { Input } from '../user-action/Input'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\nexport type DatePropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {\n value?: Date,\n onChange?: (date: Date) => void,\n onEditComplete?: (value: Date) => void,\n type?: 'dateTime' | 'date',\n}\n\n/**\n * An Input for date properties\n */\nexport const DateProperty = ({\n value,\n onChange = noop,\n onEditComplete = noop,\n readOnly,\n type = 'dateTime',\n ...baseProps\n }: DatePropertyProps) => {\n const hasValue = !!value\n\n const dateText = value ? (type === 'dateTime' ? formatDateTime(value) : formatDate(value)) : ''\n return (\n <PropertyBase\n {...baseProps}\n hasValue={hasValue}\n icon={<CalendarDays size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <Input\n className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !w-fit !rounded-none', { 'bg-surface-warning': softRequired && !hasValue })}\n value={dateText}\n type={type === 'dateTime' ? 'datetime-local' : 'date'}\n readOnly={readOnly}\n onChange={(event) => {\n const value = event.target.value\n if (!value) {\n event.preventDefault()\n return\n }\n const dueDate = new Date(value)\n onChange(dueDate)\n }}\n onEditCompleted={(value) => onEditComplete(new Date(value))}\n />\n </div>\n )}\n />\n )\n}\n","import { List } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { MultiSelectProps } from '../user-action/MultiSelect'\nimport { MultiSelect } from '../user-action/MultiSelect'\nimport { ChipList } from '../layout-and-navigation/Chip'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype MultiSelectPropertyTranslation = {\n select: string,\n}\n\nconst defaultMultiSelectPropertyTranslation: Record<Language, MultiSelectPropertyTranslation> = {\n en: {\n select: 'Select'\n },\n de: {\n select: 'Auswählen'\n }\n}\n\nexport type MultiSelectPropertyProps<T> =\n Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'>\n\n/**\n * An Input for MultiSelect properties\n */\nexport const MultiSelectProperty = <T, >({\n overwriteTranslation,\n options,\n name,\n readOnly = false,\n softRequired,\n onRemove,\n ...multiSelectProps\n }: PropsForTranslation<MultiSelectPropertyTranslation, MultiSelectPropertyProps<T>>) => {\n const translation = useTranslation(defaultMultiSelectPropertyTranslation, overwriteTranslation)\n const hasValue = options.some(value => value.selected)\n let triggerClassName: string\n if (softRequired && !hasValue) {\n triggerClassName = 'border-warning hover:brightness-90'\n }\n\n return (\n <PropertyBase\n name={name}\n onRemove={onRemove}\n readOnly={readOnly}\n softRequired={softRequired}\n hasValue={hasValue}\n icon={<List size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <MultiSelect\n {...multiSelectProps}\n className={clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue })}\n triggerClassName={triggerClassName}\n selectedDisplay={({ items }) => {\n const selected = items.filter(value => value.selected)\n if (selected.length === 0) {\n return (<span>Select</span>)\n }\n return (\n <ChipList list={selected.map(value => ({ children: value.label }))}/>\n )\n }}\n options={options}\n disabled={readOnly}\n hintText={`${translation.select}...`}\n />\n </div>\n )}\n />\n )\n}\n","import type { ReactNode } from 'react'\nimport { useState } from 'react'\nimport { Search } from 'lucide-react'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { Language } from '@/localization/util'\nimport { MultiSearchWithMapping } from '@/util/simpleSearch'\nimport clsx from 'clsx'\nimport { Menu, MenuItem } from './Menu'\nimport { Input } from './Input'\nimport { Checkbox } from './Checkbox'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\ntype MultiSelectTranslation = {\n select: string,\n search: string,\n selected: string,\n}\n\nconst defaultMultiSelectTranslation: Record<Language, MultiSelectTranslation> = {\n en: {\n select: 'Select',\n search: 'Search',\n selected: 'selected'\n },\n de: {\n select: 'Auswählen',\n search: 'Suche',\n selected: 'ausgewählt'\n }\n}\n\n// TODO maybe add custom item builder here\nexport type MultiSelectOption<T> = {\n label: string,\n value: T,\n selected: boolean,\n disabled?: boolean,\n className?: string,\n}\n\nexport type SearchProps<T> = {\n initialSearch?: string,\n searchMapping: (value: MultiSelectOption<T>) => string[],\n}\n\nexport type MultiSelectProps<T> = {\n options: MultiSelectOption<T>[],\n onChange: (options: MultiSelectOption<T>[]) => void,\n search?: SearchProps<T>,\n disabled?: boolean,\n selectedDisplay?: (props: {\n items: MultiSelectOption<T>[],\n disabled: boolean,\n }) => ReactNode,\n label?: LabelProps,\n hintText?: string,\n showDisabledOptions?: boolean,\n className?: string,\n triggerClassName?: string,\n}\n\n/**\n * A Component for multi selection\n */\nexport const MultiSelect = <T, >({\n overwriteTranslation,\n options,\n onChange,\n search,\n disabled = false,\n selectedDisplay,\n label,\n hintText,\n showDisabledOptions = true,\n className = '',\n triggerClassName = '',\n }: PropsForTranslation<MultiSelectTranslation, MultiSelectProps<T>>) => {\n const translation = useTranslation(defaultMultiSelectTranslation, overwriteTranslation)\n const [searchText, setSearchText] = useState<string>(search?.initialSearch ?? '')\n let filteredOptions: MultiSelectOption<T>[] = options\n const enableSearch = !!search\n if (enableSearch && !!searchText) {\n filteredOptions = MultiSearchWithMapping<MultiSelectOption<T>>(\n searchText,\n filteredOptions,\n value => search.searchMapping(value)\n )\n }\n if (!showDisabledOptions) {\n filteredOptions = filteredOptions.filter(value => !value.disabled)\n }\n\n const selectedItems = options.filter(value => value.selected)\n const menuButtonText = selectedItems.length === 0 ?\n hintText ?? translation.select\n : <span>{`${selectedItems.length} ${translation.selected}`}</span>\n\n const borderColor = 'border-menu-border'\n\n return (\n <div className={clsx(className)}>\n {label && (\n <Label {...label} htmlFor={label.name} className={clsx(' mb-1', label.className)}\n labelType={label.labelType ?? 'labelBig'}/>\n )}\n <Menu<HTMLDivElement>\n alignment=\"t_\"\n trigger={(onClick, ref) => (\n <div ref={ref} onClick={disabled ? undefined : onClick}\n className={clsx(borderColor, 'bg-menu-background text-menu-text inline-w-full justify-between items-center rounded-lg border-2 px-4 py-2 font-medium',\n {\n 'hover:brightness-90 hover:border-primary cursor-pointer': !disabled,\n 'bg-disabled-background text-disabled cursor-not-allowed': disabled\n },\n triggerClassName)}\n >\n {selectedDisplay ? selectedDisplay({ items: options, disabled }) : menuButtonText}\n </div>\n )}\n menuClassName={clsx(\n '!rounded-lg !shadow-lg !max-h-[500px] !min-w-[400px] !max-w-[70vh] !overflow-y-auto !border !border-2', borderColor,\n { '!py-0': !enableSearch, '!pb-0': enableSearch }\n )}\n >\n {enableSearch && (\n <div key=\"selectSearch\" className=\"row gap-x-2 items-center px-2 py-2\">\n <Input autoFocus={true} className=\"w-full\" value={searchText} onChangeText={setSearchText}/>\n <Search/>\n </div>\n )}\n {filteredOptions.map((option, index) => (\n <MenuItem key={`item${index}`} className={clsx({\n 'cursor-not-allowed !bg-disabled-background !text-disabled-text hover:brightness-100': !!option.disabled,\n 'cursor-pointer': !option.disabled,\n })}\n >\n <div\n className={clsx('overflow-hidden whitespace-nowrap text-ellipsis row items-center gap-x-2', option.className)}\n onClick={() => {\n if (!option.disabled) {\n onChange(options.map(value => value.value === option.value ? ({\n ...option,\n selected: !value.selected\n }) : value))\n }\n }}\n >\n <Checkbox checked={option.selected} disabled={option.disabled} size=\"small\"/>\n {option.label}\n </div>\n </MenuItem>\n ))}\n </Menu>\n </div>\n )\n}\n","import { type PropsWithChildren, type ReactNode, type RefObject, useRef } from 'react'\nimport clsx from 'clsx'\nimport { useOutsideClick } from '@/hooks/useOutsideClick'\nimport { useHoverState } from '@/hooks/useHoverState'\n\ntype MenuProps<T> = PropsWithChildren<{\n trigger: (onClick: () => void, ref: RefObject<T>) => ReactNode,\n /**\n * @default 'tl'\n */\n alignment?: 'tl' | 'tr' | 'bl' | 'br' | '_l' | '_r' | 't_' | 'b_',\n showOnHover?: boolean,\n menuClassName?: string,\n}>\n\nexport type MenuItemProps = {\n onClick?: () => void,\n alignment?: 'left' | 'right',\n className?: string,\n}\nconst MenuItem = ({\n children,\n onClick,\n alignment = 'left',\n className\n }: PropsWithChildren<MenuItemProps>) => (\n <div\n className={clsx('block px-3 py-1 bg-menu-background text-menu-text hover:brightness-90', {\n 'text-right': alignment === 'right',\n 'text-left': alignment === 'left',\n }, className)}\n onClick={onClick}\n >\n {children}\n </div>\n)\n\n/**\n * A Menu Component to allow the user to see different functions\n */\nconst Menu = <T extends HTMLElement>({\n trigger,\n children,\n alignment = 'tl',\n showOnHover = false,\n menuClassName = '',\n }: MenuProps<T>) => {\n const { isHovered: isOpen, setIsHovered: setIsOpen, handlers } = useHoverState({ isDisabled: !showOnHover })\n const triggerRef = useRef<T>(null)\n const menuRef = useRef<HTMLDivElement>(null)\n useOutsideClick([triggerRef, menuRef], () => setIsOpen(false))\n\n return (\n <div\n className=\"relative\"\n {...handlers}\n >\n {trigger(() => setIsOpen(!isOpen), triggerRef)}\n {isOpen ? (\n <div ref={menuRef} onClick={e => e.stopPropagation()}\n className={clsx('absolute top-full mt-1 py-2 w-60 rounded-lg bg-menu-background text-menu-text ring-1 ring-slate-900/5 text-sm leading-6 font-semibold shadow-md z-[1]', {\n ' top-[8px]': alignment[0] === 't',\n ' bottom-[8px]': alignment[0] === 'b',\n ' left-[-8px]': alignment[1] === 'l',\n ' right-[-8px]': alignment[1] === 'r',\n }, menuClassName)}>\n {children}\n </div>\n ) : null}\n </div>\n )\n}\n\nexport { Menu, MenuItem }\n","import type { RefObject } from 'react'\nimport { useEffect } from 'react'\n\nexport const useOutsideClick = <Ts extends RefObject<HTMLElement>[]>(refs: Ts, handler: () => void) => {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n // returning means not \"not clicking outside\"\n\n // if no target exists, return\n if (event.target === null) return\n // if the target is a ref's element or descendent thereof, return\n if (refs.some((ref) => !ref.current || ref.current.contains(event.target as Node))) {\n return\n }\n\n handler()\n }\n document.addEventListener('mousedown', listener)\n document.addEventListener('touchstart', listener)\n return () => {\n document.removeEventListener('mousedown', listener)\n document.removeEventListener('touchstart', listener)\n }\n }, [refs, handler])\n}\n","import { Binary } from 'lucide-react'\nimport clsx from 'clsx'\nimport { noop } from '@/util/noop'\nimport { Input } from '../user-action/Input'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype NumberPropertyTranslation = {\n value: string,\n}\n\nconst defaultNumberPropertyTranslation: Record<Language, NumberPropertyTranslation> = {\n en: {\n value: 'Value'\n },\n de: {\n value: 'Wert'\n }\n}\n\nexport type NumberPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {\n value?: number,\n suffix?: string,\n onChange?: (value: number) => void,\n onEditComplete?: (value: number) => void,\n}\n\n/**\n * An Input for number properties\n */\nexport const NumberProperty = ({\n overwriteTranslation,\n value,\n onChange = noop,\n onRemove = noop,\n onEditComplete = noop,\n readOnly,\n suffix,\n ...baseProps\n }: PropsForTranslation<NumberPropertyTranslation, NumberPropertyProps>) => {\n const translation = useTranslation(defaultNumberPropertyTranslation, overwriteTranslation)\n const hasValue = value !== undefined\n\n return (\n <PropertyBase\n {...baseProps}\n onRemove={onRemove}\n hasValue={hasValue}\n icon={<Binary size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <Input\n expanded={false}\n className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !w-fit !shadow-none !rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue })}\n value={value?.toString() ?? ''}\n type=\"number\"\n readOnly={readOnly}\n placeholder={`${translation.value}...`}\n onChangeText={(value) => {\n const numberValue = parseFloat(value)\n if (isNaN(numberValue)) {\n onRemove()\n } else {\n onChange(numberValue)\n }\n }}\n onEditCompleted={(value) => {\n const numberValue = parseFloat(value)\n if (isNaN(numberValue)) {\n onRemove()\n } else {\n onEditComplete(numberValue)\n }\n }}\n />\n {suffix && <span className={clsx('ml-1', { 'bg-surface-warning': softRequired && !hasValue })}>{suffix}</span>}\n </div>\n )}\n />\n )\n}\n","import { List } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport type { SearchableSelectProps } from '../user-action/Select'\nimport { SearchableSelect } from '../user-action/Select'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype SingleSelectPropertyTranslation = {\n select: string,\n}\n\nconst defaultSingleSelectPropertyTranslation: Record<Language, SingleSelectPropertyTranslation> = {\n en: {\n select: 'Select'\n },\n de: {\n select: 'Auswählen'\n }\n}\n\nexport type SingleSelectPropertyProps<T> =\n Omit<PropertyBaseProps & SearchableSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'labelClassName' | 'additionalItems'>\n\n/**\n * An Input for SingleSelect properties\n */\nexport const SingleSelectProperty = <T, >({\n overwriteTranslation,\n value,\n options,\n name,\n readOnly = false,\n softRequired,\n onRemove,\n ...multiSelectProps\n }: PropsForTranslation<SingleSelectPropertyTranslation, SingleSelectPropertyProps<T>>) => {\n const translation = useTranslation(defaultSingleSelectPropertyTranslation, overwriteTranslation)\n const hasValue = value !== undefined\n\n return (\n <PropertyBase\n name={name}\n onRemove={onRemove}\n readOnly={readOnly}\n softRequired={softRequired}\n hasValue={hasValue}\n icon={<List size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <SearchableSelect\n {...multiSelectProps}\n value={value}\n options={options}\n isDisabled={readOnly}\n className={clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue })}\n hintText={`${translation.select}...`}\n />\n </div>\n )}\n />\n )\n}\n","import { Text } from 'lucide-react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { Textarea } from '../user-action/Textarea'\nimport { noop } from '@/util/noop'\nimport type { PropertyBaseProps } from './PropertyBase'\nimport { PropertyBase } from './PropertyBase'\n\ntype TextPropertyTranslation = {\n value: string,\n}\n\nconst defaultTextPropertyTranslation: Record<Language, TextPropertyTranslation> = {\n en: {\n value: 'Text'\n },\n de: {\n value: 'Text'\n }\n}\n\nexport type TextPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {\n value?: string,\n onChange?: (value: string) => void,\n onEditComplete?: (value: string) => void,\n}\n\n/**\n * An Input for Text properties\n */\nexport const TextProperty = ({\n overwriteTranslation,\n value,\n readOnly,\n onChange = noop,\n onRemove = noop,\n onEditComplete = noop,\n ...baseProps\n }: PropsForTranslation<TextPropertyTranslation, TextPropertyProps>) => {\n const translation = useTranslation(defaultTextPropertyTranslation, overwriteTranslation)\n const hasValue = value !== undefined\n\n return (\n <PropertyBase\n {...baseProps}\n onRemove={onRemove}\n hasValue={hasValue}\n icon={<Text size={16}/>}\n input={({ softRequired }) => (\n <div\n className={clsx('row grow pt-2 pb-1 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}\n >\n <Textarea\n className={clsx('ring-0 border-0 outline-0 p-0 m-0 shadow-none rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue })}\n rows={5}\n defaultStyle={false}\n value={value ?? ''}\n readOnly={readOnly}\n placeholder={`${translation.value}...`}\n onChangeText={(value) => {\n if (!value) {\n onRemove()\n } else {\n onChange(value)\n }\n }}\n onEditCompleted={(value) => {\n if (!value) {\n onRemove()\n } else {\n onEditComplete(value)\n }\n }}\n />\n </div>\n )}\n />\n )\n}\n","import type { TextareaHTMLAttributes } from 'react'\nimport { useEffect, useState } from 'react'\nimport clsx from 'clsx'\nimport { useSaveDelay } from '@/hooks/useSaveDelay'\nimport { noop } from '@/util/noop'\nimport type { LabelProps } from './Label'\nimport { Label } from './Label'\n\nexport type TextareaProps = {\n /** Outside the area */\n label?: Omit<LabelProps, 'id'>,\n /** Inside the area */\n headline?: string,\n value?: string,\n resizable?: boolean,\n onChangeText?: (text: string) => void,\n disclaimer?: string,\n onEditCompleted?: (text: string) => void,\n defaultStyle?: boolean,\n} & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>\n\n/**\n * A Textarea component for inputting longer texts\n *\n * The State is managed by the parent\n */\nexport const Textarea = ({\n label,\n headline,\n id,\n resizable = false,\n onChange = noop,\n onChangeText = noop,\n disclaimer,\n onBlur = noop,\n onEditCompleted = noop,\n defaultStyle = true,\n className,\n ...props\n }: TextareaProps) => {\n const [hasFocus, setHasFocus] = useState(false)\n const { restartTimer, clearUpdateTimer } = useSaveDelay(() => undefined, 3000)\n\n const onEditCompletedWrapper = (text: string) => {\n onEditCompleted(text)\n clearUpdateTimer()\n }\n\n return (\n <div className=\"w-full\">\n {label && (\n <Label {...label} htmlFor={id} className={clsx('mb-1', label.className)}\n labelType={label.labelType ?? 'labelSmall'}/>\n )}\n <div\n className={`${clsx(' bg-surface text-on-surface focus-within:border-primary relative', { 'shadow border-2 border-gray-300 hover:border-primary rounded-lg': defaultStyle })}`}>\n {headline && (\n <span className=\"mx-3 mt-3 block text-gray-700 font-bold\">\n {headline}\n </span>\n )}\n <textarea\n id={id}\n className={clsx('pt-0 px-3 border-transparent focus:border-transparent focus:ring-0 appearance-none border w-full leading-tight focus:outline-none', {\n 'resize-none': !resizable,\n 'h-32': defaultStyle,\n 'mt-3': !headline\n }, className)}\n onChange={(event) => {\n const value = event.target.value\n restartTimer(() => {\n onEditCompletedWrapper(value)\n })\n onChange(event)\n onChangeText(value)\n }}\n onFocus={() => {\n setHasFocus(true)\n }}\n onBlur={(event) => {\n onBlur(event)\n onEditCompletedWrapper(event.target.value)\n setHasFocus(false)\n }}\n {...props}\n >\n </textarea>\n </div>\n {(hasFocus && disclaimer) && (\n <label className=\"text-negative\">\n {disclaimer}\n </label>\n )}\n </div>\n )\n}\n\n/**\n * A Textarea component that is not controlled by its parent\n */\nexport const TextareaUncontrolled = ({\n value = '',\n onChangeText = noop,\n ...props\n }: TextareaProps) => {\n const [text, setText] = useState<string>(value)\n\n useEffect(() => {\n setText(value)\n }, [value])\n\n return (\n <Textarea\n {...props}\n value={text}\n onChangeText={text => {\n setText(text)\n onChangeText(text)\n }}\n />\n )\n}","import type { ReactNode } from 'react'\nimport clsx from 'clsx'\nimport type { Language } from '@/localization/util'\nimport type { PropsForTranslation } from '@/localization/useTranslation'\nimport { useTranslation } from '@/localization/useTranslation'\nimport { noop } from '@/util/noop'\nimport { addDuration, subtractDuration } from '@/util/date'\nimport { SolidButton } from './Button'\nimport type { TimePickerProps } from '../date/TimePicker'\nimport { TimePicker } from '../date/TimePicker'\nimport type { DatePickerProps } from '../date/DatePicker'\nimport { DatePicker } from '../date/DatePicker'\n\ntype TimeTranslation = {\n clear: string,\n change: string,\n year: string,\n month: string,\n day: string,\n january: string,\n february: string,\n march: string,\n april: string,\n may: string,\n june: string,\n july: string,\n august: string,\n september: string,\n october: string,\n november: string,\n december: string,\n}\n\nconst defaultTimeTranslation: Record<Language, TimeTranslation> = {\n en: {\n clear: 'Clear',\n change: 'Change',\n year: 'Year',\n month: 'Month',\n day: 'Day',\n january: 'January',\n february: 'Febuary',\n march: 'March',\n april: 'April',\n may: 'May',\n june: 'June',\n july: 'July',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December',\n },\n de: {\n clear: 'Entfernen',\n change: 'Ändern',\n year: 'Jahr',\n month: 'Monat',\n day: 'Tag',\n january: 'Januar',\n february: 'Febuar',\n march: 'März',\n april: 'April',\n may: 'Mai',\n june: 'Juni',\n july: 'Juli',\n august: 'August',\n september: 'September',\n october: 'October',\n november: 'November',\n december: 'December',\n }\n}\n\nexport type DateTimePickerMode = 'date' | 'time' | 'dateTime'\n\nexport type DateTimePickerProps = {\n mode?: DateTimePickerMode,\n value?: Date,\n start?: Date,\n end?: Date,\n onChange?: (date: Date) => void,\n onFinish?: (date: Date) => void,\n onRemove?: () => void,\n datePickerProps?: Omit<DatePickerProps, 'onChange' | 'value' | 'start' | 'end'>,\n timePickerProps?: Omit<TimePickerProps, 'onChange' | 'time' | 'maxHeight'>,\n}\n\n/**\n * A Component for picking a Date and Time\n */\nexport const DateTimePicker = ({\n overwriteTranslation,\n value = new Date(),\n start = subtractDuration(new Date(), { years: 50 }),\n end = addDuration(new Date(), { years: 50 }),\n mode = 'dateTime',\n onFinish = noop,\n onChange = noop,\n onRemove = noop,\n timePickerProps,\n datePickerProps,\n }: PropsForTranslation<TimeTranslation, DateTimePickerProps>) => {\n const translation = useTranslation(defaultTimeTranslation, overwriteTranslation)\n\n const useDate = mode === 'dateTime' || mode === 'date'\n const useTime = mode === 'dateTime' || mode === 'time'\n\n let dateDisplay: ReactNode\n let timeDisplay: ReactNode\n\n if (useDate) {\n dateDisplay = (\n <DatePicker\n {...datePickerProps}\n className=\"min-w-[320px] min-h-[250px]\"\n yearMonthPickerProps={{ maxHeight: 218 }}\n value={value}\n start={start}\n end={end}\n onChange={onChange}\n />\n )\n }\n if (useTime) {\n timeDisplay = (\n <TimePicker\n {...timePickerProps}\n className={clsx('h-full', { 'justify-between w-full': mode === 'time' })}\n maxHeight={250}\n time={value}\n onChange={onChange}\n />\n )\n }\n\n return (\n <div className=\"col w-fit\">\n <div className=\"row gap-x-4\">\n {dateDisplay}\n {timeDisplay}\n </div>\n <div className=\"row justify-end\">\n <div className=\"row gap-x-2 mt-1\">\n <SolidButton size=\"medium\" color=\"negative\" onClick={onRemove}>{translation.clear}</SolidButton>\n <SolidButton\n size=\"medium\"\n onClick={() => onFinish(value)}\n >\n {translation.change}\n </SolidButton>\n </div>\n </div>\n </div>\n )\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport clsx from 'clsx'\nimport { noop } from '@/util/noop'\nimport { getNeighbours, range } from '@/util/array'\nimport { clamp } from '@/util/math'\n\nexport type ScrollPickerProps<T> = {\n options: T[],\n mapping: (value: T) => string,\n selected?: T,\n onChange?: (value: T) => void,\n disabled?: boolean,\n}\n\ntype AnimationData<T> = {\n /** The index we scroll to */\n targetIndex: number,\n /** The index we are currently showing centered */\n currentIndex: number,\n items: T[],\n /** From -0.5 to 0.5 */\n transition: number,\n velocity: number,\n animationVelocity: number,\n lastTimeStamp?: number,\n lastScrollTimeStamp?: number,\n}\n\nconst up = 1\nconst down = -1\ntype Direction = 1 | -1\n\n/**\n * A component for picking an option by scrolling\n */\nexport const ScrollPicker = <T, >({\n options,\n mapping,\n selected,\n onChange = noop,\n disabled = false,\n }: ScrollPickerProps<T>) => {\n let selectedIndex = 0\n if (selected && options.indexOf(selected) !== -1) {\n selectedIndex = options.indexOf(selected)\n }\n const [{\n currentIndex,\n transition,\n items,\n lastTimeStamp\n }, setAnimation] = useState<AnimationData<T>>({\n targetIndex: selectedIndex,\n currentIndex: disabled ? selectedIndex : 0,\n velocity: 0,\n animationVelocity: Math.floor(options.length / 2),\n transition: 0,\n items: options,\n })\n\n const itemsShownCount = 5\n const shownItems = getNeighbours(range(0, items.length - 1), currentIndex).map(index => ({\n name: mapping(items[index]!), index\n }))\n\n const itemHeight = 40\n const distance = 8\n\n const containerHeight = itemHeight * (itemsShownCount - 2) + distance * (itemsShownCount - 2 + 1)\n\n const getDirection = useCallback((targetIndex: number, currentIndex: number, transition: number, length: number): Direction => {\n if (targetIndex === currentIndex) {\n return transition > 0 ? up : down\n }\n let distanceForward = targetIndex - currentIndex\n if (distanceForward < 0) {\n distanceForward += length\n }\n return distanceForward >= length / 2 ? down : up\n }, [])\n\n const animate = useCallback((timestamp: number, startTime: number | undefined) => {\n setAnimation((prevState) => {\n const {\n targetIndex,\n currentIndex,\n transition,\n animationVelocity,\n velocity,\n items,\n lastScrollTimeStamp\n } = prevState\n if (disabled) {\n return { ...prevState, currentIndex: targetIndex, velocity: 0, lastTimeStamp: timestamp }\n }\n if ((targetIndex === currentIndex && velocity === 0 && transition === 0) || !startTime) {\n return { ...prevState, lastTimeStamp: timestamp }\n }\n const progress = (timestamp - startTime) / 1000 // to seconds\n const direction = getDirection(targetIndex, currentIndex, transition, items.length)\n\n let newVelocity = velocity\n let usedVelocity\n let newCurrentIndex = currentIndex\n const isAutoScrolling = velocity === 0 && (!lastScrollTimeStamp || timestamp - lastScrollTimeStamp > 300)\n\n const newLastScrollTimeStamp = velocity !== 0 ? timestamp : lastScrollTimeStamp\n\n // manual scrolling\n if (isAutoScrolling) {\n usedVelocity = direction * animationVelocity\n } else {\n usedVelocity = velocity\n newVelocity = velocity * 0.5 // drag loss\n if (Math.abs(newVelocity) <= 0.05) {\n newVelocity = 0\n }\n }\n\n let newTransition = transition + usedVelocity * progress\n const changeThreshold = 0.5\n\n while (newTransition >= changeThreshold) {\n if (newCurrentIndex === targetIndex && newTransition >= changeThreshold && isAutoScrolling) {\n newTransition = 0\n break\n }\n newCurrentIndex = (currentIndex + 1) % items.length\n newTransition -= 1\n }\n if (newTransition >= changeThreshold) {\n newTransition = 0\n }\n while (newTransition <= -changeThreshold) {\n if (newCurrentIndex === targetIndex && newTransition <= -changeThreshold && isAutoScrolling) {\n newTransition = 0\n break\n }\n newCurrentIndex = currentIndex === 0 ? items.length - 1 : currentIndex - 1\n newTransition += 1\n }\n let newTargetIndex = targetIndex\n if (!isAutoScrolling) {\n newTargetIndex = newCurrentIndex\n }\n\n if ((currentIndex !== newTargetIndex || newTargetIndex !== targetIndex) && newTargetIndex === newCurrentIndex) {\n onChange(items[newCurrentIndex]!)\n }\n return {\n targetIndex: newTargetIndex,\n currentIndex: newCurrentIndex,\n animationVelocity,\n transition: newTransition,\n velocity: newVelocity,\n items,\n lastTimeStamp: timestamp,\n lastScrollTimeStamp: newLastScrollTimeStamp\n }\n })\n }, [disabled, getDirection, onChange])\n\n useEffect(() => {\n // constant update\n requestAnimationFrame((timestamp) => animate(timestamp, lastTimeStamp))\n })\n\n const opacity = (transition: number, index: number, itemsCount: number) => {\n const max = 100\n const min = 0\n const distance = max - min\n\n let opacityValue = min\n const unitTransition = clamp((transition) / 0.5)\n if (index === 1 || index === itemsCount - 2) {\n if (index === 1 && transition > 0) {\n opacityValue += Math.floor(unitTransition * distance)\n }\n if (index === itemsCount - 2 && transition < 0) {\n opacityValue += Math.floor(unitTransition * distance)\n }\n } else {\n opacityValue = max\n }\n\n // TODO this is not the right value for the bottom entry\n return clamp(1 - (opacityValue / max))\n }\n\n return (\n <div\n className=\"relative overflow-hidden\"\n style={{ height: containerHeight }}\n onWheel={event => {\n if (event.deltaY !== 0) {\n // TODO slower increase\n setAnimation(({ velocity, ...animationData }) =>\n ({ ...animationData, velocity: velocity + event.deltaY }))\n }\n }}\n >\n <div className=\"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2\">\n <div\n className=\"absolute z-[1] top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-full min-w-[40px] border border-y-2 border-x-0 border-[#00000033]\"\n style={{ height: `${itemHeight}px` }}\n />\n <div\n className=\"col select-none\"\n style={{\n transform: `translateY(${-transition * (distance + itemHeight)}px)`,\n columnGap: `${distance}px`,\n }}\n >\n {shownItems.map(({ name, index }, arrayIndex) => (\n <div\n key={index}\n className={clsx(\n `col items-center justify-center rounded-md`,\n {\n 'text-primary font-bold': currentIndex === index,\n 'text-on-background': currentIndex === index,\n 'cursor-pointer': !disabled,\n 'cursor-not-allowed': disabled,\n }\n )}\n style={{\n opacity: currentIndex !== index ? opacity(transition, arrayIndex, shownItems.length) : undefined,\n height: `${itemHeight}px`,\n maxHeight: `${itemHeight}px`,\n }}\n onClick={() => !disabled && setAnimation(prevState => ({ ...prevState, targetIndex: index }))}\n >\n {name}\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n","import type { HTMLInputTypeAttribute, InputHTMLAttributes } from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { Pencil } from 'lucide-react'\nimport clsx from 'clsx'\nimport { useSaveDelay } from '@/hooks/useSaveDelay'\nimport { noop } from '@/util/noop'\n\ntype InputProps = {\n /**\n * The value\n */\n value: string,\n /**\n * @default 'text'\n */\n type?: HTMLInputTypeAttribute,\n /**\n * Callback for when the input's value changes\n * This is pretty much required but made optional for the rare cases where it actually isn't need such as when used with disabled\n * That could be enforced through a union type but that seems a bit overkill\n * @default noop\n */\n onChangeText?: (text: string) => void,\n onEditCompleted?: (text: string) => void,\n labelClassName?: string,\n initialState?: 'editing' | 'display',\n size?: number,\n disclaimer?: string,\n} & Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'label' | 'type' | 'crossOrigin'>\n\n/**\n * A Text input component for inputting text. It changes appearance upon entering the edit mode and switches\n * back to display mode on loss of focus or on enter\n *\n * The State is managed by the parent\n */\nexport const ToggleableInput = ({\n type = 'text',\n value,\n onChange = noop,\n onChangeText = noop,\n onEditCompleted = noop,\n labelClassName = '',\n initialState = 'display',\n size = 16,\n disclaimer,\n onBlur,\n ...restProps\n }: InputProps) => {\n const [isEditing, setIsEditing] = useState(initialState !== 'display')\n const { restartTimer, clearUpdateTimer } = useSaveDelay(() => undefined, 3000)\n const ref = useRef<HTMLInputElement>(null)\n\n const onEditCompletedWrapper = (text: string) => {\n onEditCompleted(text)\n clearUpdateTimer()\n }\n\n useEffect(() => {\n if (isEditing) {\n ref.current?.focus()\n }\n }, [isEditing])\n\n return (\n <div>\n <div\n className={clsx('row items-center w-full gap-x-2 overflow-hidden', { 'cursor-pointer': !isEditing })}\n onClick={() => !isEditing ? setIsEditing(!isEditing) : undefined}\n >\n <div className={clsx('row overflow-hidden', { 'flex-1': isEditing })}>\n {isEditing ? (\n <input\n ref={ref}\n {...restProps}\n value={value}\n type={type}\n onChange={event => {\n const value = event.target.value\n restartTimer(() => {\n onEditCompletedWrapper(value)\n })\n onChangeText(value)\n onChange(event)\n }}\n onBlur={(event) => {\n if (onBlur) {\n onBlur(event)\n }\n onEditCompletedWrapper(value)\n setIsEditing(false)\n }}\n onKeyDown={event => {\n if (event.key === 'Enter') {\n setIsEditing(false)\n onEditCompletedWrapper(value)\n }\n }}\n className={clsx(`w-full border-none rounded-none ring-0 outline-0 text-inherit bg-inherit shadow-transparent decoration-primary p-0 underline-offset-4`, {\n underline: isEditing\n }, labelClassName)}\n onFocus={event => event.target.select()}\n />\n ) : (\n <span className={clsx('max-w-xs break-words overflow-hidden', labelClassName)}>\n {value}\n </span>\n )}\n </div>\n <Pencil\n className={clsx(`cursor-pointer`, { 'text-transparent': isEditing })}\n size={size}\n style={{ minWidth: `${size}px` }}\n />\n </div>\n {(isEditing && disclaimer) && (\n <label className=\"text-negative\">\n {disclaimer}\n </label>\n )}\n </div>\n )\n}\n\nexport const ToggleableInputUncontrolled = ({\n value: initialValue,\n onChangeText = noop,\n ...restProps\n }: InputProps) => {\n const [value, setValue] = useState(initialValue)\n\n useEffect(() => {\n setValue(initialValue)\n }, [initialValue])\n\n return (\n <ToggleableInput\n value={value}\n onChangeText={text => {\n setValue(text)\n onChangeText(text)\n }}\n {...restProps}\n />\n )\n}\n","import { z } from 'zod'\nimport type { Language } from '@/localization/util'\nimport { LanguageUtil } from '@/localization/util'\n\nexport type News = {\n title: string,\n date: Date,\n description: (string | URL)[],\n externalResource?: URL,\n keys: string[],\n}\n\nexport type LocalizedNews = Record<Language, News[]>\n\nexport const newsSchema = z.object({\n title: z.string(),\n description: z.string(),\n date: z.string(),\n image: z.string().url().optional(),\n externalResource: z.string().url().optional(),\n keys: z.array(z.string())\n}).transform<News>((obj) => {\n let description: (string | URL)[] = [obj.description]\n if (obj.image) {\n description = [new URL(obj.image), ...description]\n }\n\n return {\n title: obj.title,\n date: new Date(obj.date),\n description,\n externalResource: obj.externalResource ? new URL(obj.externalResource) : undefined,\n keys: obj.keys\n }\n})\n\nexport const newsListSchema = z.array(newsSchema)\n\nexport const localizedNewsSchema = z.record(z.enum(LanguageUtil.languages), newsListSchema)\n\nexport const filterNews = (localizedNews: News[], requiredKeys: string[]) => {\n return localizedNews.filter(news => requiredKeys.every(value => news.keys.includes(value)))\n}\n"],"mappings":"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","names":["clsx","clsx","jsx","jsxs","jsx","useEffect","useState","ChevronDown","useEffect","useState","jsx","clsx","clsx","jsx","jsxs","useEffect","useState","clsx","useState","clsx","jsx","jsxs","jsx","clsx","useEffect","useState","jsx","jsxs","jsx","jsxs","jsx","useEffect","useRef","useState","Scrollbars","clsx","jsx","jsxs","clsx","useEffect","useRef","useState","clsx","useEffect","useState","clsx","jsx","jsxs","jsx","jsxs","jsx","jsxs","Image","clsx","jsx","jsxs","clsx","jsx","useCallback","useEffect","useState","clsx","jsx","jsxs","Image","jsx","clsx","jsx","jsxs","useCallback","useEffect","useRef","useState","clsx","jsx","jsxs","clsx","jsx","jsxs","clsx","jsx","clsx","ChevronDown","ChevronUp","Fragment","jsx","jsx","ChevronLeft","ChevronRight","clsx","jsx","jsxs","useEffect","useMemo","useState","clsx","forwardRef","useEffect","useRef","useState","clsx","useEffect","useState","clsx","jsx","jsx","jsxs","forwardRef","FormInput","jsx","clsx","jsxs","jsx","jsxs","ChevronLeft","ChevronRight","clsx","jsx","jsxs","useEffect","useRef","useState","Scrollbars","useState","Check","clsx","jsx","jsxs","clsx","ChevronDown","ChevronUp","jsx","jsxs","clsx","jsx","jsxs","jsx","jsxs","clsx","jsx","jsxs","useState","clsx","jsx","jsxs","jsx","clsx","jsx","jsxs","jsx","jsxs","clsx","jsx","jsxs","jsx","jsx","ChevronDown","ChevronUp","Search","useEffect","useState","clsx","Fragment","jsx","jsxs","jsx","jsxs","createContext","useContext","useEffect","useState","jsx","createContext","jsx","jsxs","Check","clsx","jsx","jsxs","jsx","clsx","jsx","clsx","useState","Search","clsx","useRef","clsx","useEffect","jsx","jsxs","jsx","jsxs","jsx","clsx","jsx","jsxs","List","clsx","jsx","clsx","useEffect","useState","clsx","jsx","jsxs","jsx","clsx","jsx","jsxs","useCallback","useEffect","useState","clsx","jsx","jsxs","useEffect","useRef","useState","clsx","jsx","jsxs","current"]}
|