@helpwave/hightide 0.1.8 → 0.1.9
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/components/date/DatePicker.d.mts +3 -4
- package/dist/components/date/DatePicker.d.ts +3 -4
- package/dist/components/date/DatePicker.js +117 -13
- package/dist/components/date/DatePicker.js.map +1 -1
- package/dist/components/date/DatePicker.mjs +117 -13
- package/dist/components/date/DatePicker.mjs.map +1 -1
- package/dist/components/date/TimeDisplay.d.mts +5 -19
- package/dist/components/date/TimeDisplay.d.ts +5 -19
- package/dist/components/date/TimeDisplay.js +121 -37
- package/dist/components/date/TimeDisplay.js.map +1 -1
- package/dist/components/date/TimeDisplay.mjs +121 -37
- package/dist/components/date/TimeDisplay.mjs.map +1 -1
- package/dist/components/dialogs/ConfirmDialog.d.mts +2 -5
- package/dist/components/dialogs/ConfirmDialog.d.ts +2 -5
- package/dist/components/dialogs/ConfirmDialog.js +155 -23
- package/dist/components/dialogs/ConfirmDialog.js.map +1 -1
- package/dist/components/dialogs/ConfirmDialog.mjs +155 -23
- package/dist/components/dialogs/ConfirmDialog.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Overlay.d.mts +2 -3
- package/dist/components/layout-and-navigation/Overlay.d.ts +2 -3
- package/dist/components/layout-and-navigation/Overlay.js +150 -10
- package/dist/components/layout-and-navigation/Overlay.js.map +1 -1
- package/dist/components/layout-and-navigation/Overlay.mjs +150 -10
- package/dist/components/layout-and-navigation/Overlay.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Pagination.d.mts +2 -3
- package/dist/components/layout-and-navigation/Pagination.d.ts +2 -3
- package/dist/components/layout-and-navigation/Pagination.js +145 -13
- package/dist/components/layout-and-navigation/Pagination.js.map +1 -1
- package/dist/components/layout-and-navigation/Pagination.mjs +145 -13
- package/dist/components/layout-and-navigation/Pagination.mjs.map +1 -1
- package/dist/components/layout-and-navigation/SearchableList.d.mts +3 -2
- package/dist/components/layout-and-navigation/SearchableList.d.ts +3 -2
- package/dist/components/layout-and-navigation/SearchableList.js +149 -11
- package/dist/components/layout-and-navigation/SearchableList.js.map +1 -1
- package/dist/components/layout-and-navigation/SearchableList.mjs +149 -11
- package/dist/components/layout-and-navigation/SearchableList.mjs.map +1 -1
- package/dist/components/layout-and-navigation/StepperBar.d.mts +2 -5
- package/dist/components/layout-and-navigation/StepperBar.d.ts +2 -5
- package/dist/components/layout-and-navigation/StepperBar.js +145 -15
- package/dist/components/layout-and-navigation/StepperBar.js.map +1 -1
- package/dist/components/layout-and-navigation/StepperBar.mjs +145 -15
- package/dist/components/layout-and-navigation/StepperBar.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Table.js +145 -13
- package/dist/components/layout-and-navigation/Table.js.map +1 -1
- package/dist/components/layout-and-navigation/Table.mjs +145 -13
- package/dist/components/layout-and-navigation/Table.mjs.map +1 -1
- package/dist/components/layout-and-navigation/TextImage.d.mts +3 -4
- package/dist/components/layout-and-navigation/TextImage.d.ts +3 -4
- package/dist/components/layout-and-navigation/TextImage.js +153 -19
- package/dist/components/layout-and-navigation/TextImage.js.map +1 -1
- package/dist/components/layout-and-navigation/TextImage.mjs +153 -19
- package/dist/components/layout-and-navigation/TextImage.mjs.map +1 -1
- package/dist/components/loading-states/ErrorComponent.js +48 -8
- package/dist/components/loading-states/ErrorComponent.js.map +1 -1
- package/dist/components/loading-states/ErrorComponent.mjs +48 -8
- package/dist/components/loading-states/ErrorComponent.mjs.map +1 -1
- package/dist/components/loading-states/LoadingAndErrorComponent.d.mts +1 -0
- package/dist/components/loading-states/LoadingAndErrorComponent.d.ts +1 -0
- package/dist/components/loading-states/LoadingAndErrorComponent.js +147 -15
- package/dist/components/loading-states/LoadingAndErrorComponent.js.map +1 -1
- package/dist/components/loading-states/LoadingAndErrorComponent.mjs +147 -15
- package/dist/components/loading-states/LoadingAndErrorComponent.mjs.map +1 -1
- package/dist/components/loading-states/LoadingAnimation.d.mts +2 -3
- package/dist/components/loading-states/LoadingAnimation.d.ts +2 -3
- package/dist/components/loading-states/LoadingAnimation.js +145 -13
- package/dist/components/loading-states/LoadingAnimation.js.map +1 -1
- package/dist/components/loading-states/LoadingAnimation.mjs +145 -13
- package/dist/components/loading-states/LoadingAnimation.mjs.map +1 -1
- package/dist/components/modals/ConfirmModal.d.mts +2 -5
- package/dist/components/modals/ConfirmModal.d.ts +2 -5
- package/dist/components/modals/ConfirmModal.js +156 -26
- package/dist/components/modals/ConfirmModal.js.map +1 -1
- package/dist/components/modals/ConfirmModal.mjs +156 -26
- package/dist/components/modals/ConfirmModal.mjs.map +1 -1
- package/dist/components/modals/DiscardChangesModal.d.mts +2 -7
- package/dist/components/modals/DiscardChangesModal.d.ts +2 -7
- package/dist/components/modals/DiscardChangesModal.js +160 -46
- package/dist/components/modals/DiscardChangesModal.js.map +1 -1
- package/dist/components/modals/DiscardChangesModal.mjs +160 -46
- package/dist/components/modals/DiscardChangesModal.mjs.map +1 -1
- package/dist/components/modals/InputModal.d.mts +1 -0
- package/dist/components/modals/InputModal.d.ts +1 -0
- package/dist/components/modals/InputModal.js +156 -26
- package/dist/components/modals/InputModal.js.map +1 -1
- package/dist/components/modals/InputModal.mjs +156 -26
- package/dist/components/modals/InputModal.mjs.map +1 -1
- package/dist/components/modals/LanguageModal.d.mts +3 -2
- package/dist/components/modals/LanguageModal.d.ts +3 -2
- package/dist/components/modals/LanguageModal.js +161 -23
- package/dist/components/modals/LanguageModal.js.map +1 -1
- package/dist/components/modals/LanguageModal.mjs +161 -23
- package/dist/components/modals/LanguageModal.mjs.map +1 -1
- package/dist/components/modals/ThemeModal.d.mts +5 -5
- package/dist/components/modals/ThemeModal.d.ts +5 -5
- package/dist/components/modals/ThemeModal.js +169 -29
- package/dist/components/modals/ThemeModal.js.map +1 -1
- package/dist/components/modals/ThemeModal.mjs +169 -29
- package/dist/components/modals/ThemeModal.mjs.map +1 -1
- package/dist/components/properties/CheckboxProperty.d.mts +3 -5
- package/dist/components/properties/CheckboxProperty.d.ts +3 -5
- package/dist/components/properties/CheckboxProperty.js +147 -25
- package/dist/components/properties/CheckboxProperty.js.map +1 -1
- package/dist/components/properties/CheckboxProperty.mjs +147 -25
- package/dist/components/properties/CheckboxProperty.mjs.map +1 -1
- package/dist/components/properties/DateProperty.d.mts +1 -0
- package/dist/components/properties/DateProperty.d.ts +1 -0
- package/dist/components/properties/DateProperty.js +145 -13
- package/dist/components/properties/DateProperty.js.map +1 -1
- package/dist/components/properties/DateProperty.mjs +145 -13
- package/dist/components/properties/DateProperty.mjs.map +1 -1
- package/dist/components/properties/MultiSelectProperty.d.mts +4 -5
- package/dist/components/properties/MultiSelectProperty.d.ts +4 -5
- package/dist/components/properties/MultiSelectProperty.js +160 -42
- package/dist/components/properties/MultiSelectProperty.js.map +1 -1
- package/dist/components/properties/MultiSelectProperty.mjs +160 -42
- package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
- package/dist/components/properties/NumberProperty.d.mts +1 -0
- package/dist/components/properties/NumberProperty.d.ts +1 -0
- package/dist/components/properties/NumberProperty.js +147 -15
- package/dist/components/properties/NumberProperty.js.map +1 -1
- package/dist/components/properties/NumberProperty.mjs +147 -15
- package/dist/components/properties/NumberProperty.mjs.map +1 -1
- package/dist/components/properties/PropertyBase.d.mts +2 -3
- package/dist/components/properties/PropertyBase.d.ts +2 -3
- package/dist/components/properties/PropertyBase.js +145 -13
- package/dist/components/properties/PropertyBase.js.map +1 -1
- package/dist/components/properties/PropertyBase.mjs +145 -13
- package/dist/components/properties/PropertyBase.mjs.map +1 -1
- package/dist/components/properties/SelectProperty.d.mts +2 -3
- package/dist/components/properties/SelectProperty.d.ts +2 -3
- package/dist/components/properties/SelectProperty.js +150 -28
- package/dist/components/properties/SelectProperty.js.map +1 -1
- package/dist/components/properties/SelectProperty.mjs +150 -28
- package/dist/components/properties/SelectProperty.mjs.map +1 -1
- package/dist/components/properties/TextProperty.d.mts +2 -1
- package/dist/components/properties/TextProperty.d.ts +2 -1
- package/dist/components/properties/TextProperty.js +149 -17
- package/dist/components/properties/TextProperty.js.map +1 -1
- package/dist/components/properties/TextProperty.mjs +149 -17
- package/dist/components/properties/TextProperty.mjs.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.d.mts +4 -20
- package/dist/components/user-action/DateAndTimePicker.d.ts +4 -20
- package/dist/components/user-action/DateAndTimePicker.js +215 -51
- package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.mjs +215 -51
- package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
- package/dist/components/user-action/MultiSelect.d.mts +4 -8
- package/dist/components/user-action/MultiSelect.d.ts +4 -8
- package/dist/components/user-action/MultiSelect.js +156 -22
- package/dist/components/user-action/MultiSelect.js.map +1 -1
- package/dist/components/user-action/MultiSelect.mjs +156 -22
- package/dist/components/user-action/MultiSelect.mjs.map +1 -1
- package/dist/components/user-action/Select.js +149 -11
- package/dist/components/user-action/Select.js.map +1 -1
- package/dist/components/user-action/Select.mjs +149 -11
- package/dist/components/user-action/Select.mjs.map +1 -1
- package/dist/css/globals.css +13 -4
- package/dist/css/uncompiled/globals.css +4 -4
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +332 -300
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +329 -300
- package/dist/index.mjs.map +1 -1
- package/dist/localization/defaults/form.d.mts +54 -0
- package/dist/localization/defaults/form.d.ts +54 -0
- package/dist/localization/defaults/form.js +127 -0
- package/dist/localization/defaults/form.js.map +1 -0
- package/dist/localization/defaults/form.mjs +103 -0
- package/dist/localization/defaults/form.mjs.map +1 -0
- package/dist/localization/defaults/time.d.mts +39 -0
- package/dist/localization/defaults/time.d.ts +39 -0
- package/dist/localization/defaults/time.js +101 -0
- package/dist/localization/defaults/time.js.map +1 -0
- package/dist/localization/defaults/time.mjs +76 -0
- package/dist/localization/defaults/time.mjs.map +1 -0
- package/dist/localization/useTranslation.d.mts +30 -6
- package/dist/localization/useTranslation.d.ts +30 -6
- package/dist/localization/useTranslation.js +46 -6
- package/dist/localization/useTranslation.js.map +1 -1
- package/dist/localization/useTranslation.mjs +46 -6
- package/dist/localization/useTranslation.mjs.map +1 -1
- package/dist/theming/useTheme.d.mts +4 -2
- package/dist/theming/useTheme.d.ts +4 -2
- package/dist/theming/useTheme.js +10 -2
- package/dist/theming/useTheme.js.map +1 -1
- package/dist/theming/useTheme.mjs +10 -2
- package/dist/theming/useTheme.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/properties/DateProperty.tsx","../../../src/util/date.ts","../../../src/util/noop.ts","../../../src/components/user-action/Input.tsx","../../../src/hooks/useSaveDelay.ts","../../../src/components/user-action/Label.tsx","../../../src/components/properties/PropertyBase.tsx","../../../src/components/user-action/Button.tsx","../../../src/localization/LanguageProvider.tsx","../../../src/hooks/useLocalStorage.ts","../../../src/localization/util.ts","../../../src/localization/useTranslation.ts"],"sourcesContent":["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 { equalSizeGroups } from './array'\n\nexport const monthsList = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as const\nexport type Month = typeof monthsList[number]\n\nexport const weekDayList = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] as const\nexport type WeekDay = typeof weekDayList[number]\n\nexport const formatDate = (date: Date) => {\n const year = date.getFullYear().toString().padStart(4, '0')\n const month = (date.getMonth() + 1).toString().padStart(2, '0')\n const day = (date.getDate()).toString().padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nexport const formatDateTime = (date: Date) => {\n const dateString = formatDate(date)\n const hours = date.getHours().toString().padStart(2, '0')\n const minutes = date.getMinutes().toString().padStart(2, '0')\n return `${dateString}T${hours}:${minutes}`\n}\n\nexport const getDaysInMonth = (year: number, month: number): number => {\n const lastDayOfMonth = new Date(year, month + 1, 0)\n return lastDayOfMonth.getDate()\n}\n\nexport type Duration = {\n years?: number,\n months?: number,\n days?: number,\n hours?: number,\n minutes?: number,\n seconds?: number,\n milliseconds?: number,\n}\n\nexport const changeDuration = (date: Date, duration: Duration, isAdding?: boolean): Date => {\n const {\n years = 0,\n months = 0,\n days = 0,\n hours = 0,\n minutes = 0,\n seconds = 0,\n milliseconds = 0,\n } = duration\n\n // Check ranges\n if (years < 0) {\n console.error(`Range error years must be greater than 0: received ${years}`)\n return new Date(date)\n }\n if (months < 0 || months > 11) {\n console.error(`Range error month must be 0 <= month <= 11: received ${months}`)\n return new Date(date)\n }\n if (days < 0) {\n console.error(`Range error days must be greater than 0: received ${days}`)\n return new Date(date)\n }\n if (hours < 0 || hours > 23) {\n console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`)\n return new Date(date)\n }\n if (minutes < 0 || minutes > 59) {\n console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`)\n return new Date(date)\n }\n if (seconds < 0 || seconds > 59) {\n console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`)\n return new Date(date)\n }\n if (milliseconds < 0) {\n console.error(`Range error seconds must be greater than 0: received ${milliseconds}`)\n return new Date(date)\n }\n\n const multiplier = isAdding ? 1 : -1\n\n const newDate = new Date(date)\n\n newDate.setFullYear(newDate.getFullYear() + multiplier * years)\n\n newDate.setMonth(newDate.getMonth() + multiplier * months)\n\n newDate.setDate(newDate.getDate() + multiplier * days)\n\n newDate.setHours(newDate.getHours() + multiplier * hours)\n\n newDate.setMinutes(newDate.getMinutes() + multiplier * minutes)\n\n newDate.setSeconds(newDate.getSeconds() + multiplier * seconds)\n\n newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds)\n\n return newDate\n}\n\nexport const addDuration = (date: Date, duration: Duration): Date => {\n return changeDuration(date, duration, true)\n}\n\nexport const subtractDuration = (date: Date, duration: Duration): Date => {\n return changeDuration(date, duration, false)\n}\n\nexport const getBetweenDuration = (startDate: Date, endDate: Date): Duration => {\n const durationInMilliseconds = endDate.getTime() - startDate.getTime()\n\n const millisecondsInSecond = 1000\n const millisecondsInMinute = 60 * millisecondsInSecond\n const millisecondsInHour = 60 * millisecondsInMinute\n const millisecondsInDay = 24 * millisecondsInHour\n const millisecondsInMonth = 30 * millisecondsInDay // Rough estimation, can be adjusted\n\n const years = Math.floor(durationInMilliseconds / (365.25 * millisecondsInDay))\n const months = Math.floor(durationInMilliseconds / millisecondsInMonth)\n const days = Math.floor(durationInMilliseconds / millisecondsInDay)\n const hours = Math.floor((durationInMilliseconds % millisecondsInDay) / millisecondsInHour)\n const seconds = Math.floor((durationInMilliseconds % millisecondsInHour) / millisecondsInSecond)\n const milliseconds = durationInMilliseconds % millisecondsInSecond\n\n return {\n years,\n months,\n days,\n hours,\n seconds,\n milliseconds,\n }\n}\n\n/** Checks if a given date is in the range of two dates\n *\n * An undefined value for startDate or endDate means no bound for the start or end respectively\n */\nexport const isInTimeSpan = (value: Date, startDate?: Date, endDate?: Date): boolean => {\n if (startDate && endDate) {\n console.assert(startDate <= endDate)\n return startDate <= value && value <= endDate\n } else if (startDate) {\n return startDate <= value\n } else if (endDate) {\n return endDate >= value\n } else {\n return true\n }\n}\n\n/** Compare two dates on the year, month, day */\nexport const equalDate = (date1: Date, date2: Date) => {\n return date1.getFullYear() === date2.getFullYear()\n && date1.getMonth() === date2.getMonth()\n && date1.getDate() === date2.getDate()\n}\n\nexport const getWeeksForCalenderMonth = (date: Date, weekStart: WeekDay, weeks: number = 6) => {\n const month = date.getMonth()\n const year = date.getFullYear()\n\n const dayList: Date[] = []\n let currentDate = new Date(year, month, 1) // Start of month\n const weekStartIndex = weekDayList.indexOf(weekStart)\n\n // Move the current day to the week before\n while (currentDate.getDay() !== weekStartIndex) {\n currentDate = subtractDuration(currentDate, { days: 1 })\n }\n\n while (dayList.length < 7 * weeks) {\n const date = new Date(currentDate)\n date.setHours(date.getHours(), date.getMinutes()) // To make sure we are not overwriting the time\n dayList.push(date)\n currentDate = addDuration(currentDate, { days: 1 })\n }\n\n // weeks\n return equalSizeGroups(dayList, 7)\n}\n","export const noop = () => undefined\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 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-property-title-background property-title-text group-hover:border-primary': !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 gap-x-0 grow justify-between items-center rounded-r-xl border-2 border-l-0', {\n 'bg-surface group-hover:border-primary': !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 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 {\n 'text-disabled-text bg-disabled-background cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.paddingMapping[size],\n className\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 {\n 'text-disabled-text border-disabled-outline cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:brightness-80')]: !disabled,\n },\n ButtonUtil.paddingMapping[size],\n className\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 {\n 'text-disabled-text cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:bg-button-text-hover-background rounded-full')]: !disabled,\n },\n ButtonUtil.paddingMapping[size],\n className\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 {\n 'text-disabled-text bg-disabled-background cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.iconPaddingMapping[size],\n className\n )}\n {...restProps}\n >\n {children}\n </button>\n )\n}\n\nexport { SolidButton, OutlineButton, TextButton, IconButton }\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}","import { useLanguage } from './LanguageProvider'\nimport type { Language } from './util'\n\nexport type Translation<T> = Record<Language, T>\n\ntype OverwriteTranslationType<Translation extends Record<string, unknown>> = {\n language?: Language,\n translation?: Partial<Record<Language, Partial<Translation>>>,\n}\n\n/**\n * Adds the `language` prop to the component props.\n *\n * @param Translation the type of the translation object\n *\n * @param Props the type of the component props, defaults to `Record<string, never>`,\n * if you don't expect any other props other than `language` and get an\n * error when using your component (because it uses `forwardRef` etc.)\n * you can try out `Record<string, unknown>`, this might resolve your\n * problem as `SomeType & never` is still `never` but `SomeType & unknown`\n * is `SomeType` which means that adding back props (like `ref` etc.)\n * works properly\n */\nexport type PropsForTranslation<\n Translation extends Record<string, unknown>,\n Props = Record<string, never>\n> = Props & {\n overwriteTranslation?: OverwriteTranslationType<Translation>,\n};\n\nexport const useTranslation = <Translation extends Record<string, unknown>>(\n defaults: Record<Language, Translation>,\n translationOverwrite: OverwriteTranslationType<Translation> = {}\n): Translation => {\n const { language: languageProp, translation: overwrite } = translationOverwrite\n const { language: inferredLanguage } = useLanguage()\n const usedLanguage = languageProp ?? inferredLanguage\n let defaultValues: Translation = defaults[usedLanguage]\n if (overwrite && overwrite[usedLanguage]) {\n defaultValues = { ...defaultValues, ...overwrite[usedLanguage] }\n }\n return defaultValues\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,OAAOA,WAAU;;;ACOV,IAAM,aAAa,CAAC,SAAe;AACxC,QAAM,OAAO,KAAK,YAAY,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AAC1D,QAAM,SAAS,KAAK,SAAS,IAAI,GAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AAC9D,QAAM,MAAO,KAAK,QAAQ,EAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AACvD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC;AAEO,IAAM,iBAAiB,CAAC,SAAe;AAC5C,QAAM,aAAa,WAAW,IAAI;AAClC,QAAM,QAAQ,KAAK,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AACxD,QAAM,UAAU,KAAK,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AAC5D,SAAO,GAAG,UAAU,IAAI,KAAK,IAAI,OAAO;AAC1C;;;ACpBO,IAAM,OAAO,MAAM;;;ACA1B,SAAgB,YAAsC,aAAAC,YAAW,QAAQ,YAAAC,iBAAgB;AACzF,OAAOC,WAAU;;;ACDjB,SAAS,WAAW,gBAAgB;AAE7B,SAAS,aAAa,uBAAqD,OAAe;AAC/F,QAAM,CAAC,aAAa,cAAc,IAAI,SAAqC,MAAS;AACpF,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAqC,MAAS;AAEhG,QAAM,eAAe,CAAC,WAAuB;AAC3C,iBA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;AAAA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;;;ANlDY,gBAAAC,YAAA;AAfL,IAAM,eAAe,CAAC;AAAA,EACE;AAAA,EACA,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,MAAyB;AACpD,QAAM,WAAW,CAAC,CAAC;AAEnB,QAAM,WAAW,QAAS,SAAS,aAAa,eAAe,KAAK,IAAI,WAAW,KAAK,IAAK;AAC7F,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA,MAAM,gBAAAA,KAAC,gBAAa,MAAM,IAAG;AAAA,MAC7B,OAAO,CAAC,EAAE,aAAa,MACrB,gBAAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAWC,MAAK,qCAAqC,EAAE,gBAAgB,gBAAgB,CAAC,SAAS,CAAC;AAAA,UAElG,0BAAAD;AAAA,YAAC;AAAA;AAAA,cACC,WAAWC,MAAK,4EAA4E,EAAE,sBAAsB,gBAAgB,CAAC,SAAS,CAAC;AAAA,cAC/I,OAAO;AAAA,cACP,MAAM,SAAS,aAAa,mBAAmB;AAAA,cAC/C;AAAA,cACA,UAAU,CAAC,UAAU;AACnB,sBAAMC,SAAQ,MAAM,OAAO;AAC3B,oBAAI,CAACA,QAAO;AACV,wBAAM,eAAe;AACrB;AAAA,gBACF;AACA,sBAAM,UAAU,IAAI,KAAKA,MAAK;AAC9B,yBAAS,OAAO;AAAA,cAClB;AAAA,cACA,iBAAiB,CAACA,WAAU,eAAe,IAAI,KAAKA,MAAK,CAAC;AAAA;AAAA,UAC5D;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ;AAEJ;","names":["clsx","useEffect","useState","clsx","jsx","useEffect","clsx","value","FormInput","jsx","clsx","clsx","clsx","jsx","jsxs","jsxs","clsx","jsx","useEffect","useState","useEffect","useState","jsx","jsx","jsxs","clsx","jsx","clsx","value"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/properties/DateProperty.tsx","../../../src/util/date.ts","../../../src/util/noop.ts","../../../src/components/user-action/Input.tsx","../../../src/hooks/useSaveDelay.ts","../../../src/components/user-action/Label.tsx","../../../src/components/properties/PropertyBase.tsx","../../../src/components/user-action/Button.tsx","../../../src/localization/LanguageProvider.tsx","../../../src/hooks/useLocalStorage.ts","../../../src/localization/util.ts","../../../src/localization/useTranslation.ts","../../../src/localization/defaults/form.ts"],"sourcesContent":["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 { equalSizeGroups } from './array'\n\nexport const monthsList = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'] as const\nexport type Month = typeof monthsList[number]\n\nexport const weekDayList = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] as const\nexport type WeekDay = typeof weekDayList[number]\n\nexport const formatDate = (date: Date) => {\n const year = date.getFullYear().toString().padStart(4, '0')\n const month = (date.getMonth() + 1).toString().padStart(2, '0')\n const day = (date.getDate()).toString().padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nexport const formatDateTime = (date: Date) => {\n const dateString = formatDate(date)\n const hours = date.getHours().toString().padStart(2, '0')\n const minutes = date.getMinutes().toString().padStart(2, '0')\n return `${dateString}T${hours}:${minutes}`\n}\n\nexport const getDaysInMonth = (year: number, month: number): number => {\n const lastDayOfMonth = new Date(year, month + 1, 0)\n return lastDayOfMonth.getDate()\n}\n\nexport type Duration = {\n years?: number,\n months?: number,\n days?: number,\n hours?: number,\n minutes?: number,\n seconds?: number,\n milliseconds?: number,\n}\n\nexport const changeDuration = (date: Date, duration: Duration, isAdding?: boolean): Date => {\n const {\n years = 0,\n months = 0,\n days = 0,\n hours = 0,\n minutes = 0,\n seconds = 0,\n milliseconds = 0,\n } = duration\n\n // Check ranges\n if (years < 0) {\n console.error(`Range error years must be greater than 0: received ${years}`)\n return new Date(date)\n }\n if (months < 0 || months > 11) {\n console.error(`Range error month must be 0 <= month <= 11: received ${months}`)\n return new Date(date)\n }\n if (days < 0) {\n console.error(`Range error days must be greater than 0: received ${days}`)\n return new Date(date)\n }\n if (hours < 0 || hours > 23) {\n console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`)\n return new Date(date)\n }\n if (minutes < 0 || minutes > 59) {\n console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`)\n return new Date(date)\n }\n if (seconds < 0 || seconds > 59) {\n console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`)\n return new Date(date)\n }\n if (milliseconds < 0) {\n console.error(`Range error seconds must be greater than 0: received ${milliseconds}`)\n return new Date(date)\n }\n\n const multiplier = isAdding ? 1 : -1\n\n const newDate = new Date(date)\n\n newDate.setFullYear(newDate.getFullYear() + multiplier * years)\n\n newDate.setMonth(newDate.getMonth() + multiplier * months)\n\n newDate.setDate(newDate.getDate() + multiplier * days)\n\n newDate.setHours(newDate.getHours() + multiplier * hours)\n\n newDate.setMinutes(newDate.getMinutes() + multiplier * minutes)\n\n newDate.setSeconds(newDate.getSeconds() + multiplier * seconds)\n\n newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds)\n\n return newDate\n}\n\nexport const addDuration = (date: Date, duration: Duration): Date => {\n return changeDuration(date, duration, true)\n}\n\nexport const subtractDuration = (date: Date, duration: Duration): Date => {\n return changeDuration(date, duration, false)\n}\n\nexport const getBetweenDuration = (startDate: Date, endDate: Date): Duration => {\n const durationInMilliseconds = endDate.getTime() - startDate.getTime()\n\n const millisecondsInSecond = 1000\n const millisecondsInMinute = 60 * millisecondsInSecond\n const millisecondsInHour = 60 * millisecondsInMinute\n const millisecondsInDay = 24 * millisecondsInHour\n const millisecondsInMonth = 30 * millisecondsInDay // Rough estimation, can be adjusted\n\n const years = Math.floor(durationInMilliseconds / (365.25 * millisecondsInDay))\n const months = Math.floor(durationInMilliseconds / millisecondsInMonth)\n const days = Math.floor(durationInMilliseconds / millisecondsInDay)\n const hours = Math.floor((durationInMilliseconds % millisecondsInDay) / millisecondsInHour)\n const seconds = Math.floor((durationInMilliseconds % millisecondsInHour) / millisecondsInSecond)\n const milliseconds = durationInMilliseconds % millisecondsInSecond\n\n return {\n years,\n months,\n days,\n hours,\n seconds,\n milliseconds,\n }\n}\n\n/** Checks if a given date is in the range of two dates\n *\n * An undefined value for startDate or endDate means no bound for the start or end respectively\n */\nexport const isInTimeSpan = (value: Date, startDate?: Date, endDate?: Date): boolean => {\n if (startDate && endDate) {\n console.assert(startDate <= endDate)\n return startDate <= value && value <= endDate\n } else if (startDate) {\n return startDate <= value\n } else if (endDate) {\n return endDate >= value\n } else {\n return true\n }\n}\n\n/** Compare two dates on the year, month, day */\nexport const equalDate = (date1: Date, date2: Date) => {\n return date1.getFullYear() === date2.getFullYear()\n && date1.getMonth() === date2.getMonth()\n && date1.getDate() === date2.getDate()\n}\n\nexport const getWeeksForCalenderMonth = (date: Date, weekStart: WeekDay, weeks: number = 6) => {\n const month = date.getMonth()\n const year = date.getFullYear()\n\n const dayList: Date[] = []\n let currentDate = new Date(year, month, 1) // Start of month\n const weekStartIndex = weekDayList.indexOf(weekStart)\n\n // Move the current day to the week before\n while (currentDate.getDay() !== weekStartIndex) {\n currentDate = subtractDuration(currentDate, { days: 1 })\n }\n\n while (dayList.length < 7 * weeks) {\n const date = new Date(currentDate)\n date.setHours(date.getHours(), date.getMinutes()) // To make sure we are not overwriting the time\n dayList.push(date)\n currentDate = addDuration(currentDate, { days: 1 })\n }\n\n // weeks\n return equalSizeGroups(dayList, 7)\n}\n","export const noop = () => undefined\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 type { ReactNode } from 'react'\nimport { AlertTriangle } from 'lucide-react'\nimport clsx from 'clsx'\nimport { TextButton } from '../user-action/Button'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport type { FormTranslationType } from '../../localization/defaults/form'\nimport { formTranslation } from '../../localization/defaults/form'\n\ntype PropertyBaseTranslation = FormTranslationType\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([formTranslation], 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-property-title-background property-title-text group-hover:border-primary': !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 gap-x-0 grow justify-between items-center rounded-r-xl border-2 border-l-0', {\n 'bg-surface group-hover:border-primary': !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 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 {\n 'text-disabled-text bg-disabled-background cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.paddingMapping[size],\n className\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 {\n 'text-disabled-text border-disabled-outline cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:brightness-80')]: !disabled,\n },\n ButtonUtil.paddingMapping[size],\n className\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 {\n 'text-disabled-text cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:bg-button-text-hover-background rounded-full')]: !disabled,\n },\n ButtonUtil.paddingMapping[size],\n className\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 {\n 'text-disabled-text bg-disabled-background cursor-not-allowed': disabled,\n [clsx(colorClasses, 'hover:brightness-90')]: !disabled\n },\n ButtonUtil.iconPaddingMapping[size],\n className\n )}\n {...restProps}\n >\n {children}\n </button>\n )\n}\n\nexport { SolidButton, OutlineButton, TextButton, IconButton }\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}","import { useLanguage } from './LanguageProvider'\nimport type { Language } from './util'\n\n/**\n * A type describing the pluralization of a word\n */\nexport type TranslationPlural = {\n zero?: string,\n one?: string,\n two?: string,\n few?: string,\n many?: string,\n other: string,\n}\n\n/**\n * The type describing all values of a translation\n */\nexport type TranslationType = Record<string, string | TranslationPlural>\n\n/**\n * The type of translations\n */\nexport type Translation<T extends TranslationType> = Record<Language, T>\n\ntype OverwriteTranslationType<T extends TranslationType> = {\n language?: Language,\n translation?: Translation<Partial<T>>,\n}\n\n/**\n * Adds the `language` prop to the component props.\n *\n * @param Translation the type of the translation object\n *\n * @param Props the type of the component props, defaults to `Record<string, never>`,\n * if you don't expect any other props other than `language` and get an\n * error when using your component (because it uses `forwardRef` etc.)\n * you can try out `Record<string, unknown>`, this might resolve your\n * problem as `SomeType & never` is still `never` but `SomeType & unknown`\n * is `SomeType` which means that adding back props (like `ref` etc.)\n * works properly\n */\nexport type PropsForTranslation<\n Translation extends TranslationType,\n Props = Record<string, never>\n> = Props & {\n overwriteTranslation?: OverwriteTranslationType<Translation>,\n};\n\ntype StringKeys<T> = Extract<keyof T, string>;\n\ntype TranslationFunctionOptions = {\n replacements?: Record<string, string>,\n count?: number,\n}\ntype TranslationFunction<T extends TranslationType> = (key: StringKeys<T>, options?: TranslationFunctionOptions) => string\n\n\nexport const useTranslation = <T extends TranslationType>(\n translations: Translation<Partial<TranslationType>>[],\n overwriteTranslation: OverwriteTranslationType<T> = {}\n): TranslationFunction<T> => {\n const { language: languageProp, translation: overwrite } = overwriteTranslation\n const { language: inferredLanguage } = useLanguage()\n const usedLanguage = languageProp ?? inferredLanguage\n const usedTranslations = [...translations]\n if (overwrite) {\n usedTranslations.push(overwrite)\n }\n\n return (key: StringKeys<T>, options?: TranslationFunctionOptions): string => {\n const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options }\n\n try {\n for (let i = translations.length - 1; i >= 0; i--) {\n const translation = translations[i]\n const localizedTranslation = translation[usedLanguage]\n if (!localizedTranslation) {\n continue\n }\n const value = localizedTranslation[key]\n if(!value) {\n continue\n }\n\n let forProcessing: string\n if (typeof value !== 'string') {\n if (count <= 0 && value?.zero) {\n forProcessing = value.zero\n } else if (count === 1 && value?.one) {\n forProcessing = value.one\n } else if (count === 2 && value?.two) {\n forProcessing = value.two\n } else if (count <= 10 && value?.few) {\n forProcessing = value.few\n } else if (count > 10 && value?.many) {\n forProcessing = value.many\n } else {\n forProcessing = value.other\n }\n } else {\n forProcessing = value\n }\n forProcessing = forProcessing.replace(/\\{\\{(\\w+)}}/g, (_, placeholder) => {\n return replacements[placeholder] ?? `{{${placeholder}}}` // fallback if key is missing\n })\n return forProcessing\n }\n } catch (e) {\n console.error(e)\n }\n return `{{${usedLanguage}:${key}}}`\n }\n}","import type { Translation } from '../useTranslation'\n\nexport type FormTranslationType = {\n all: string,\n back: string,\n cancel: string,\n change: string,\n clear: string,\n close: string,\n confirm: string,\n decline: string,\n delete: string,\n discard: string,\n discardChanges: string,\n done: string,\n edit: string,\n enterText: string,\n error: string,\n exit: string,\n fieldRequiredError: string,\n invalidEmailError: string,\n less: string,\n loading: string,\n maxLengthError: string,\n minLengthError: string,\n more: string,\n next: string,\n no: string,\n none: string,\n of: string,\n optional: string,\n pleaseWait: string,\n previous: string,\n remove: string,\n required: string,\n reset: string,\n save: string,\n search: string,\n select: string,\n selectOption: string,\n show: string,\n showMore: string,\n showLess: string,\n submit: string,\n success: string,\n unsavedChanges: string,\n unsavedChangesSaveQuestion: string,\n update: string,\n yes: string,\n}\n\nexport const formTranslation: Translation<FormTranslationType> = {\n en: {\n all: 'All',\n back: 'Back',\n cancel: 'Cancel',\n change: 'Change',\n clear: 'Clear',\n close: 'Close',\n confirm: 'Confirm',\n decline: 'Decline',\n delete: 'Delete',\n discard: 'Discard',\n discardChanges: 'Discard Changes',\n done: 'Done',\n edit: 'Edit',\n enterText: 'Enter text here',\n error: 'Error',\n exit: 'Exit',\n fieldRequiredError: 'This field is required.',\n invalidEmailError: 'Please enter a valid email address.',\n less: 'Less',\n loading: 'Loading',\n maxLengthError: 'Maximum length exceeded.',\n minLengthError: 'Minimum length not met.',\n more: 'More',\n next: 'Next',\n no: 'No',\n none: 'None',\n of: 'of',\n optional: 'Optional',\n pleaseWait: 'Please wait...',\n previous: 'Previous',\n remove: 'Remove',\n required: 'Required',\n reset: 'Reset',\n save: 'Save',\n search: 'Search',\n select: 'Select',\n selectOption: 'Select an option',\n show: 'Show',\n showMore: 'Show more',\n showLess: 'Show less',\n submit: 'Submit',\n success: 'Success',\n update: 'Update',\n unsavedChanges: 'Unsaved Changes',\n unsavedChangesSaveQuestion: 'Do you want to save your changes?',\n yes: 'Yes',\n },\n de: {\n all: 'Alle',\n back: 'Zurück',\n cancel: 'Abbrechen',\n change: 'Ändern',\n clear: 'Löschen',\n close: 'Schließen',\n confirm: 'Bestätigen',\n decline: 'Ablehnen',\n delete: 'Löschen',\n discard: 'Verwerfen',\n discardChanges: 'Änderungen Verwerfen',\n done: 'Fertig',\n edit: 'Bearbeiten',\n enterText: 'Text hier eingeben',\n error: 'Fehler',\n exit: 'Beenden',\n fieldRequiredError: 'Dieses Feld ist erforderlich.',\n invalidEmailError: 'Bitte geben Sie eine gültige E-Mail-Adresse ein.',\n less: 'Weniger',\n loading: 'Lädt',\n maxLengthError: 'Maximale Länge überschritten.',\n minLengthError: 'Mindestlänge nicht erreicht.',\n more: 'Mehr',\n next: 'Weiter',\n no: 'Nein',\n none: 'Nichts',\n of: 'von',\n optional: 'Optional',\n pleaseWait: 'Bitte warten...',\n previous: 'Vorherige',\n remove: 'Entfernen',\n required: 'Erforderlich',\n reset: 'Zurücksetzen',\n save: 'Speichern',\n search: 'Suche',\n select: 'Select',\n selectOption: 'Option auswählen',\n show: 'Anzeigen',\n showMore: 'Mehr anzeigen',\n showLess: 'Weniger anzeigen',\n submit: 'Abschicken',\n success: 'Erfolg',\n update: 'Update',\n unsavedChanges: 'Ungespeicherte Änderungen',\n unsavedChangesSaveQuestion: 'Möchtest du die Änderungen speichern?',\n yes: 'Ja',\n }\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,OAAOA,WAAU;;;ACOV,IAAM,aAAa,CAAC,SAAe;AACxC,QAAM,OAAO,KAAK,YAAY,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AAC1D,QAAM,SAAS,KAAK,SAAS,IAAI,GAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AAC9D,QAAM,MAAO,KAAK,QAAQ,EAAG,SAAS,EAAE,SAAS,GAAG,GAAG;AACvD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC;AAEO,IAAM,iBAAiB,CAAC,SAAe;AAC5C,QAAM,aAAa,WAAW,IAAI;AAClC,QAAM,QAAQ,KAAK,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AACxD,QAAM,UAAU,KAAK,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AAC5D,SAAO,GAAG,UAAU,IAAI,KAAK,IAAI,OAAO;AAC1C;;;ACpBO,IAAM,OAAO,MAAM;;;ACA1B,SAAgB,YAAsC,aAAAC,YAAW,QAAQ,YAAAC,iBAAgB;AACzF,OAAOC,WAAU;;;ACDjB,SAAS,WAAW,gBAAgB;AAE7B,SAAS,aAAa,uBAAqD,OAAe;AAC/F,QAAM,CAAC,aAAa,cAAc,IAAI,SAAqC,MAAS;AACpF,QAAM,CAAC,mBAAmB,oBAAoB,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;AAAA;AAAA,UAC5D;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ;AAEJ;","names":["clsx","useEffect","useState","clsx","jsx","useEffect","clsx","value","FormInput","jsx","clsx","clsx","clsx","jsx","jsxs","jsxs","clsx","jsx","useEffect","useState","useEffect","useState","jsx","jsx","jsxs","clsx","jsx","clsx","value"]}
|
|
@@ -2,18 +2,17 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { PropsForTranslation } from '../../localization/useTranslation.mjs';
|
|
3
3
|
import { MultiSelectProps } from '../user-action/MultiSelect.mjs';
|
|
4
4
|
import { PropertyBaseProps } from './PropertyBase.mjs';
|
|
5
|
+
import { FormTranslationType } from '../../localization/defaults/form.mjs';
|
|
5
6
|
import '../../localization/util.mjs';
|
|
6
7
|
import 'react';
|
|
7
8
|
import '../user-action/Label.mjs';
|
|
8
9
|
import '../user-action/Select.mjs';
|
|
9
10
|
|
|
10
|
-
type MultiSelectPropertyTranslation =
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
type MultiSelectPropertyProps<T> = Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'>;
|
|
11
|
+
type MultiSelectPropertyTranslation = FormTranslationType;
|
|
12
|
+
type MultiSelectPropertyProps<T> = Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'> & PropsForTranslation<MultiSelectPropertyTranslation>;
|
|
14
13
|
/**
|
|
15
14
|
* An Input for MultiSelect properties
|
|
16
15
|
*/
|
|
17
|
-
declare const MultiSelectProperty: <T>({ overwriteTranslation, options, name, readOnly, softRequired, onRemove, ...multiSelectProps }:
|
|
16
|
+
declare const MultiSelectProperty: <T>({ overwriteTranslation, options, name, readOnly, softRequired, onRemove, ...multiSelectProps }: MultiSelectPropertyProps<T>) => react_jsx_runtime.JSX.Element;
|
|
18
17
|
|
|
19
18
|
export { MultiSelectProperty, type MultiSelectPropertyProps };
|
|
@@ -2,18 +2,17 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { PropsForTranslation } from '../../localization/useTranslation.js';
|
|
3
3
|
import { MultiSelectProps } from '../user-action/MultiSelect.js';
|
|
4
4
|
import { PropertyBaseProps } from './PropertyBase.js';
|
|
5
|
+
import { FormTranslationType } from '../../localization/defaults/form.js';
|
|
5
6
|
import '../../localization/util.js';
|
|
6
7
|
import 'react';
|
|
7
8
|
import '../user-action/Label.js';
|
|
8
9
|
import '../user-action/Select.js';
|
|
9
10
|
|
|
10
|
-
type MultiSelectPropertyTranslation =
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
type MultiSelectPropertyProps<T> = Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'>;
|
|
11
|
+
type MultiSelectPropertyTranslation = FormTranslationType;
|
|
12
|
+
type MultiSelectPropertyProps<T> = Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'> & PropsForTranslation<MultiSelectPropertyTranslation>;
|
|
14
13
|
/**
|
|
15
14
|
* An Input for MultiSelect properties
|
|
16
15
|
*/
|
|
17
|
-
declare const MultiSelectProperty: <T>({ overwriteTranslation, options, name, readOnly, softRequired, onRemove, ...multiSelectProps }:
|
|
16
|
+
declare const MultiSelectProperty: <T>({ overwriteTranslation, options, name, readOnly, softRequired, onRemove, ...multiSelectProps }: MultiSelectPropertyProps<T>) => react_jsx_runtime.JSX.Element;
|
|
18
17
|
|
|
19
18
|
export { MultiSelectProperty, type MultiSelectPropertyProps };
|
|
@@ -63,15 +63,55 @@ var LanguageContext = (0, import_react2.createContext)({
|
|
|
63
63
|
var useLanguage = () => (0, import_react2.useContext)(LanguageContext);
|
|
64
64
|
|
|
65
65
|
// src/localization/useTranslation.ts
|
|
66
|
-
var useTranslation = (
|
|
67
|
-
const { language: languageProp, translation: overwrite } =
|
|
66
|
+
var useTranslation = (translations, overwriteTranslation = {}) => {
|
|
67
|
+
const { language: languageProp, translation: overwrite } = overwriteTranslation;
|
|
68
68
|
const { language: inferredLanguage } = useLanguage();
|
|
69
69
|
const usedLanguage = languageProp ?? inferredLanguage;
|
|
70
|
-
|
|
71
|
-
if (overwrite
|
|
72
|
-
|
|
70
|
+
const usedTranslations = [...translations];
|
|
71
|
+
if (overwrite) {
|
|
72
|
+
usedTranslations.push(overwrite);
|
|
73
73
|
}
|
|
74
|
-
return
|
|
74
|
+
return (key, options) => {
|
|
75
|
+
const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
|
|
76
|
+
try {
|
|
77
|
+
for (let i = translations.length - 1; i >= 0; i--) {
|
|
78
|
+
const translation = translations[i];
|
|
79
|
+
const localizedTranslation = translation[usedLanguage];
|
|
80
|
+
if (!localizedTranslation) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const value = localizedTranslation[key];
|
|
84
|
+
if (!value) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
let forProcessing;
|
|
88
|
+
if (typeof value !== "string") {
|
|
89
|
+
if (count <= 0 && value?.zero) {
|
|
90
|
+
forProcessing = value.zero;
|
|
91
|
+
} else if (count === 1 && value?.one) {
|
|
92
|
+
forProcessing = value.one;
|
|
93
|
+
} else if (count === 2 && value?.two) {
|
|
94
|
+
forProcessing = value.two;
|
|
95
|
+
} else if (count <= 10 && value?.few) {
|
|
96
|
+
forProcessing = value.few;
|
|
97
|
+
} else if (count > 10 && value?.many) {
|
|
98
|
+
forProcessing = value.many;
|
|
99
|
+
} else {
|
|
100
|
+
forProcessing = value.other;
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
forProcessing = value;
|
|
104
|
+
}
|
|
105
|
+
forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
|
|
106
|
+
return replacements[placeholder] ?? `{{${placeholder}}}`;
|
|
107
|
+
});
|
|
108
|
+
return forProcessing;
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
console.error(e);
|
|
112
|
+
}
|
|
113
|
+
return `{{${usedLanguage}:${key}}}`;
|
|
114
|
+
};
|
|
75
115
|
};
|
|
76
116
|
|
|
77
117
|
// src/components/user-action/MultiSelect.tsx
|
|
@@ -469,15 +509,113 @@ var useSearch = ({
|
|
|
469
509
|
};
|
|
470
510
|
};
|
|
471
511
|
|
|
512
|
+
// src/localization/defaults/form.ts
|
|
513
|
+
var formTranslation = {
|
|
514
|
+
en: {
|
|
515
|
+
all: "All",
|
|
516
|
+
back: "Back",
|
|
517
|
+
cancel: "Cancel",
|
|
518
|
+
change: "Change",
|
|
519
|
+
clear: "Clear",
|
|
520
|
+
close: "Close",
|
|
521
|
+
confirm: "Confirm",
|
|
522
|
+
decline: "Decline",
|
|
523
|
+
delete: "Delete",
|
|
524
|
+
discard: "Discard",
|
|
525
|
+
discardChanges: "Discard Changes",
|
|
526
|
+
done: "Done",
|
|
527
|
+
edit: "Edit",
|
|
528
|
+
enterText: "Enter text here",
|
|
529
|
+
error: "Error",
|
|
530
|
+
exit: "Exit",
|
|
531
|
+
fieldRequiredError: "This field is required.",
|
|
532
|
+
invalidEmailError: "Please enter a valid email address.",
|
|
533
|
+
less: "Less",
|
|
534
|
+
loading: "Loading",
|
|
535
|
+
maxLengthError: "Maximum length exceeded.",
|
|
536
|
+
minLengthError: "Minimum length not met.",
|
|
537
|
+
more: "More",
|
|
538
|
+
next: "Next",
|
|
539
|
+
no: "No",
|
|
540
|
+
none: "None",
|
|
541
|
+
of: "of",
|
|
542
|
+
optional: "Optional",
|
|
543
|
+
pleaseWait: "Please wait...",
|
|
544
|
+
previous: "Previous",
|
|
545
|
+
remove: "Remove",
|
|
546
|
+
required: "Required",
|
|
547
|
+
reset: "Reset",
|
|
548
|
+
save: "Save",
|
|
549
|
+
search: "Search",
|
|
550
|
+
select: "Select",
|
|
551
|
+
selectOption: "Select an option",
|
|
552
|
+
show: "Show",
|
|
553
|
+
showMore: "Show more",
|
|
554
|
+
showLess: "Show less",
|
|
555
|
+
submit: "Submit",
|
|
556
|
+
success: "Success",
|
|
557
|
+
update: "Update",
|
|
558
|
+
unsavedChanges: "Unsaved Changes",
|
|
559
|
+
unsavedChangesSaveQuestion: "Do you want to save your changes?",
|
|
560
|
+
yes: "Yes"
|
|
561
|
+
},
|
|
562
|
+
de: {
|
|
563
|
+
all: "Alle",
|
|
564
|
+
back: "Zur\xFCck",
|
|
565
|
+
cancel: "Abbrechen",
|
|
566
|
+
change: "\xC4ndern",
|
|
567
|
+
clear: "L\xF6schen",
|
|
568
|
+
close: "Schlie\xDFen",
|
|
569
|
+
confirm: "Best\xE4tigen",
|
|
570
|
+
decline: "Ablehnen",
|
|
571
|
+
delete: "L\xF6schen",
|
|
572
|
+
discard: "Verwerfen",
|
|
573
|
+
discardChanges: "\xC4nderungen Verwerfen",
|
|
574
|
+
done: "Fertig",
|
|
575
|
+
edit: "Bearbeiten",
|
|
576
|
+
enterText: "Text hier eingeben",
|
|
577
|
+
error: "Fehler",
|
|
578
|
+
exit: "Beenden",
|
|
579
|
+
fieldRequiredError: "Dieses Feld ist erforderlich.",
|
|
580
|
+
invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
|
|
581
|
+
less: "Weniger",
|
|
582
|
+
loading: "L\xE4dt",
|
|
583
|
+
maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
|
|
584
|
+
minLengthError: "Mindestl\xE4nge nicht erreicht.",
|
|
585
|
+
more: "Mehr",
|
|
586
|
+
next: "Weiter",
|
|
587
|
+
no: "Nein",
|
|
588
|
+
none: "Nichts",
|
|
589
|
+
of: "von",
|
|
590
|
+
optional: "Optional",
|
|
591
|
+
pleaseWait: "Bitte warten...",
|
|
592
|
+
previous: "Vorherige",
|
|
593
|
+
remove: "Entfernen",
|
|
594
|
+
required: "Erforderlich",
|
|
595
|
+
reset: "Zur\xFCcksetzen",
|
|
596
|
+
save: "Speichern",
|
|
597
|
+
search: "Suche",
|
|
598
|
+
select: "Select",
|
|
599
|
+
selectOption: "Option ausw\xE4hlen",
|
|
600
|
+
show: "Anzeigen",
|
|
601
|
+
showMore: "Mehr anzeigen",
|
|
602
|
+
showLess: "Weniger anzeigen",
|
|
603
|
+
submit: "Abschicken",
|
|
604
|
+
success: "Erfolg",
|
|
605
|
+
update: "Update",
|
|
606
|
+
unsavedChanges: "Ungespeicherte \xC4nderungen",
|
|
607
|
+
unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
|
|
608
|
+
yes: "Ja"
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
|
|
472
612
|
// src/components/layout-and-navigation/SearchableList.tsx
|
|
473
613
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
474
614
|
var defaultSearchableListTranslation = {
|
|
475
615
|
en: {
|
|
476
|
-
search: "Search",
|
|
477
616
|
nothingFound: "Nothing found"
|
|
478
617
|
},
|
|
479
618
|
de: {
|
|
480
|
-
search: "Suche",
|
|
481
619
|
nothingFound: "Nichts gefunden"
|
|
482
620
|
}
|
|
483
621
|
};
|
|
@@ -492,7 +630,7 @@ var SearchableList = ({
|
|
|
492
630
|
className,
|
|
493
631
|
resultListClassName
|
|
494
632
|
}) => {
|
|
495
|
-
const translation = useTranslation(defaultSearchableListTranslation, overwriteTranslation);
|
|
633
|
+
const translation = useTranslation([defaultSearchableListTranslation, formTranslation], overwriteTranslation);
|
|
496
634
|
const { result, hasResult, search, setSearch } = useSearch({ list, initialSearch, searchMapping });
|
|
497
635
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_clsx4.default)("col gap-y-2", className), children: [
|
|
498
636
|
list.length > minimumItemsForSearch && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "row justify-between gap-x-4 items-center", children: [
|
|
@@ -501,14 +639,14 @@ var SearchableList = ({
|
|
|
501
639
|
{
|
|
502
640
|
value: search,
|
|
503
641
|
onChangeText: setSearch,
|
|
504
|
-
placeholder: translation
|
|
642
|
+
placeholder: translation("search"),
|
|
505
643
|
autoFocus,
|
|
506
644
|
className: "w-full"
|
|
507
645
|
}
|
|
508
646
|
),
|
|
509
647
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IconButton, { color: "neutral", disabled: search.length === 0, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.Search, { className: "w-full h-full" }) })
|
|
510
648
|
] }),
|
|
511
|
-
hasResult ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_clsx4.default)("col gap-y-1", resultListClassName), children: result.map(itemMapper) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "row text-description py-2 px-2", children: translation
|
|
649
|
+
hasResult ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: (0, import_clsx4.default)("col gap-y-1", resultListClassName), children: result.map(itemMapper) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "row text-description py-2 px-2", children: translation("nothingFound") })
|
|
512
650
|
] });
|
|
513
651
|
};
|
|
514
652
|
|
|
@@ -643,14 +781,10 @@ var useOutsideClick = (refs, handler) => {
|
|
|
643
781
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
644
782
|
var defaultMultiSelectTranslation = {
|
|
645
783
|
en: {
|
|
646
|
-
|
|
647
|
-
search: "Search",
|
|
648
|
-
selected: "selected"
|
|
784
|
+
selected: `{{amount}} selected`
|
|
649
785
|
},
|
|
650
786
|
de: {
|
|
651
|
-
|
|
652
|
-
search: "Suche",
|
|
653
|
-
selected: "ausgew\xE4hlt"
|
|
787
|
+
selected: `{{amount}} ausgew\xE4hlt`
|
|
654
788
|
}
|
|
655
789
|
};
|
|
656
790
|
var MultiSelect = ({
|
|
@@ -665,7 +799,7 @@ var MultiSelect = ({
|
|
|
665
799
|
useChipDisplay = false,
|
|
666
800
|
className = ""
|
|
667
801
|
}) => {
|
|
668
|
-
const translation = useTranslation(defaultMultiSelectTranslation, overwriteTranslation);
|
|
802
|
+
const translation = useTranslation([formTranslation, defaultMultiSelectTranslation], overwriteTranslation);
|
|
669
803
|
const triggerRef = (0, import_react7.useRef)(null);
|
|
670
804
|
const menuRef = (0, import_react7.useRef)(null);
|
|
671
805
|
const [isOpen, setIsOpen] = (0, import_react7.useState)(false);
|
|
@@ -698,8 +832,8 @@ var MultiSelect = ({
|
|
|
698
832
|
onClick: () => setIsOpen(!isOpen),
|
|
699
833
|
disabled: isDisabled,
|
|
700
834
|
children: [
|
|
701
|
-
!isShowingHint && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-semibold text-menu-text", children: selectedDisplayOverwrite ?? (useChipDisplay && selectedItems ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChipList, { list: selectedItems.map((value) => ({ children: value.label })) }) :
|
|
702
|
-
isShowingHint && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "textstyle-description", children: hintText ?? translation
|
|
835
|
+
!isShowingHint && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-semibold text-menu-text", children: selectedDisplayOverwrite ?? (useChipDisplay && selectedItems ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChipList, { list: selectedItems.map((value) => ({ children: value.label })) }) : translation("selected", { replacements: { amount: selectedItems.length.toString() } })) }),
|
|
836
|
+
isShowingHint && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "textstyle-description", children: hintText ?? translation("select") }),
|
|
703
837
|
isOpen ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronUp, { size: 24, className: "min-w-6" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronDown, { className: "min-w-6" })
|
|
704
838
|
]
|
|
705
839
|
}
|
|
@@ -749,7 +883,7 @@ var MultiSelect = ({
|
|
|
749
883
|
})));
|
|
750
884
|
},
|
|
751
885
|
disabled: options.every((value) => value.selected || value.disabled),
|
|
752
|
-
children: "
|
|
886
|
+
children: translation("all")
|
|
753
887
|
}
|
|
754
888
|
),
|
|
755
889
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -763,7 +897,7 @@ var MultiSelect = ({
|
|
|
763
897
|
selected: false
|
|
764
898
|
})));
|
|
765
899
|
},
|
|
766
|
-
children: "
|
|
900
|
+
children: translation("none")
|
|
767
901
|
}
|
|
768
902
|
)
|
|
769
903
|
] }),
|
|
@@ -780,14 +914,6 @@ var MultiSelect = ({
|
|
|
780
914
|
var import_lucide_react4 = require("lucide-react");
|
|
781
915
|
var import_clsx8 = __toESM(require("clsx"));
|
|
782
916
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
783
|
-
var defaultPropertyBaseTranslation = {
|
|
784
|
-
en: {
|
|
785
|
-
remove: "Remove"
|
|
786
|
-
},
|
|
787
|
-
de: {
|
|
788
|
-
remove: "Entfernen"
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
917
|
var PropertyBase = ({
|
|
792
918
|
overwriteTranslation,
|
|
793
919
|
name,
|
|
@@ -799,7 +925,7 @@ var PropertyBase = ({
|
|
|
799
925
|
onRemove,
|
|
800
926
|
className = ""
|
|
801
927
|
}) => {
|
|
802
|
-
const translation = useTranslation(
|
|
928
|
+
const translation = useTranslation([formTranslation], overwriteTranslation);
|
|
803
929
|
const requiredAndNoValue = softRequired && !hasValue;
|
|
804
930
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: (0, import_clsx8.default)("row gap-x-0 group", className), children: [
|
|
805
931
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
@@ -832,7 +958,7 @@ var PropertyBase = ({
|
|
|
832
958
|
color: "negative",
|
|
833
959
|
className: (0, import_clsx8.default)("pr-4 items-center", { "!text-transparent": !hasValue || readOnly }),
|
|
834
960
|
disabled: !hasValue || readOnly,
|
|
835
|
-
children: translation
|
|
961
|
+
children: translation("remove")
|
|
836
962
|
}
|
|
837
963
|
)
|
|
838
964
|
]
|
|
@@ -843,14 +969,6 @@ var PropertyBase = ({
|
|
|
843
969
|
|
|
844
970
|
// src/components/properties/MultiSelectProperty.tsx
|
|
845
971
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
846
|
-
var defaultMultiSelectPropertyTranslation = {
|
|
847
|
-
en: {
|
|
848
|
-
select: "Select"
|
|
849
|
-
},
|
|
850
|
-
de: {
|
|
851
|
-
select: "Ausw\xE4hlen"
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
972
|
var MultiSelectProperty = ({
|
|
855
973
|
overwriteTranslation,
|
|
856
974
|
options,
|
|
@@ -860,7 +978,7 @@ var MultiSelectProperty = ({
|
|
|
860
978
|
onRemove,
|
|
861
979
|
...multiSelectProps
|
|
862
980
|
}) => {
|
|
863
|
-
const translation = useTranslation(
|
|
981
|
+
const translation = useTranslation([formTranslation], overwriteTranslation);
|
|
864
982
|
const hasValue = options.some((value) => value.selected);
|
|
865
983
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
866
984
|
PropertyBase,
|
|
@@ -883,7 +1001,7 @@ var MultiSelectProperty = ({
|
|
|
883
1001
|
options,
|
|
884
1002
|
isDisabled: readOnly,
|
|
885
1003
|
useChipDisplay: true,
|
|
886
|
-
hintText: `${translation
|
|
1004
|
+
hintText: `${translation("select")}...`
|
|
887
1005
|
}
|
|
888
1006
|
)
|
|
889
1007
|
}
|