@helpwave/hightide 0.0.8 → 0.0.11
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/README.md +1 -1
- package/dist/coloring/shading.d.ts +2 -0
- package/dist/coloring/shading.js +40 -0
- package/dist/coloring/types.d.ts +11 -0
- package/dist/coloring/types.js +1 -0
- package/dist/components/Avatar.d.ts +14 -0
- package/dist/components/Avatar.js +35 -0
- package/dist/components/AvatarGroup.d.ts +10 -0
- package/dist/components/AvatarGroup.js +13 -0
- package/dist/components/BreadCrumb.d.ts +16 -0
- package/dist/components/BreadCrumb.js +12 -0
- package/dist/components/Button.d.ts +41 -0
- package/dist/components/Button.js +84 -0
- package/dist/components/ChipList.d.ts +21 -0
- package/dist/components/ChipList.js +38 -0
- package/dist/components/Circle.d.ts +6 -0
- package/dist/components/Circle.js +10 -0
- package/dist/components/ErrorComponent.d.ts +13 -0
- package/dist/components/ErrorComponent.js +19 -0
- package/dist/components/Expandable.d.ts +30 -0
- package/dist/components/Expandable.js +16 -0
- package/dist/components/HelpwaveBadge.d.ts +11 -0
- package/dist/components/HelpwaveBadge.js +14 -0
- package/dist/components/HideableContentSection.d.ts +10 -0
- package/dist/components/HideableContentSection.js +15 -0
- package/dist/components/InputGroup.d.ts +13 -0
- package/dist/components/InputGroup.js +33 -0
- package/dist/components/LoadingAndErrorComponent.d.ts +17 -0
- package/dist/components/LoadingAndErrorComponent.js +25 -0
- package/dist/components/LoadingAnimation.d.ts +13 -0
- package/dist/components/LoadingAnimation.js +19 -0
- package/dist/components/LoadingButton.d.ts +6 -0
- package/dist/components/LoadingButton.js +10 -0
- package/dist/components/MarkdownInterpreter.d.ts +25 -0
- package/dist/components/MarkdownInterpreter.js +190 -0
- package/dist/components/Pagination.d.ts +14 -0
- package/dist/components/Pagination.js +25 -0
- package/dist/components/Profile.d.ts +28 -0
- package/dist/components/Profile.js +45 -0
- package/dist/components/ProgressIndicator.d.ts +21 -0
- package/dist/components/ProgressIndicator.js +24 -0
- package/dist/components/Ring.d.ts +31 -0
- package/dist/components/Ring.js +113 -0
- package/dist/components/SearchableList.d.ts +18 -0
- package/dist/components/SearchableList.js +27 -0
- package/dist/components/SortButton.d.ts +10 -0
- package/dist/components/SortButton.js +9 -0
- package/dist/components/Span.js +1 -0
- package/dist/components/StepperBar.d.ts +23 -0
- package/dist/components/StepperBar.js +47 -0
- package/dist/components/Table.d.ts +87 -0
- package/dist/components/Table.js +187 -0
- package/dist/components/TechRadar.d.ts +36 -0
- package/dist/components/TechRadar.js +191 -0
- package/dist/components/TextImage.d.ts +20 -0
- package/dist/components/TextImage.js +31 -0
- package/dist/components/TimeDisplay.d.ts +30 -0
- package/dist/components/TimeDisplay.js +83 -0
- package/dist/components/Tooltip.d.ts +34 -0
- package/dist/components/Tooltip.js +38 -0
- package/dist/components/VerticalDivider.d.ts +11 -0
- package/dist/components/VerticalDivider.js +7 -0
- package/dist/components/date/DatePicker.d.ts +26 -0
- package/dist/components/date/DatePicker.js +58 -0
- package/dist/components/date/DayPicker.d.ts +16 -0
- package/dist/components/date/DayPicker.js +37 -0
- package/dist/components/date/TimePicker.d.ts +12 -0
- package/dist/components/date/TimePicker.js +79 -0
- package/dist/components/date/YearMonthPicker.d.ts +11 -0
- package/dist/components/date/YearMonthPicker.js +59 -0
- package/dist/components/examples/InputGroupExample.d.ts +6 -0
- package/dist/components/examples/InputGroupExample.js +21 -0
- package/dist/components/examples/MultiSelectExample.d.ts +7 -0
- package/dist/components/examples/MultiSelectExample.js +27 -0
- package/dist/components/examples/SearchableSelectExample.d.ts +6 -0
- package/dist/components/examples/SearchableSelectExample.js +17 -0
- package/dist/components/examples/SelectExample.d.ts +4 -0
- package/dist/components/examples/SelectExample.js +15 -0
- package/dist/components/examples/StackingModals.d.ts +4 -0
- package/dist/components/examples/StackingModals.js +15 -0
- package/dist/components/examples/TableExample.d.ts +9 -0
- package/dist/components/examples/TableExample.js +92 -0
- package/dist/components/examples/TextareaExample.d.ts +6 -0
- package/dist/components/examples/TextareaExample.js +10 -0
- package/dist/components/examples/TileExample.d.ts +9 -0
- package/dist/components/examples/TileExample.js +9 -0
- package/dist/components/examples/Title.js +1 -0
- package/dist/components/examples/date/DateTimePickerExample.d.ts +10 -0
- package/dist/components/examples/date/DateTimePickerExample.js +21 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.js +13 -0
- package/dist/components/examples/properties/DatePropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/DatePropertyExample.js +23 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.js +16 -0
- package/dist/components/examples/properties/NumberPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/NumberPropertyExample.js +13 -0
- package/dist/components/examples/properties/SelectPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/SelectPropertyExample.js +18 -0
- package/dist/components/examples/properties/TextPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/TextPropertyExample.js +13 -0
- package/dist/components/icons/Helpwave.d.ts +10 -0
- package/dist/components/icons/Helpwave.js +20 -0
- package/dist/components/icons/Tag.d.ts +10 -0
- package/dist/components/icons/Tag.js +12 -0
- package/dist/components/layout/Carousel.d.ts +22 -0
- package/dist/components/layout/Carousel.js +233 -0
- package/dist/components/layout/DividerInserter.d.ts +11 -0
- package/dist/components/layout/DividerInserter.js +20 -0
- package/dist/components/layout/FAQSection.d.ts +23 -0
- package/dist/components/layout/FAQSection.js +14 -0
- package/dist/components/layout/Tile.d.ts +34 -0
- package/dist/components/layout/Tile.js +18 -0
- package/dist/components/modals/ConfirmDialog.d.ts +34 -0
- package/dist/components/modals/ConfirmDialog.js +31 -0
- package/dist/components/modals/DiscardChangesDialog.d.ts +19 -0
- package/dist/components/modals/DiscardChangesDialog.js +24 -0
- package/dist/components/modals/InputModal.d.ts +9 -0
- package/dist/components/modals/InputModal.js +9 -0
- package/dist/components/modals/LanguageModal.d.ts +17 -0
- package/dist/components/modals/LanguageModal.js +35 -0
- package/dist/components/modals/Modal.d.ts +38 -0
- package/dist/components/modals/Modal.js +57 -0
- package/dist/components/modals/ModalRegister.d.ts +11 -0
- package/dist/components/modals/ModalRegister.js +28 -0
- package/dist/components/properties/CheckboxProperty.d.ts +15 -0
- package/dist/components/properties/CheckboxProperty.js +27 -0
- package/dist/components/properties/DateProperty.d.ts +11 -0
- package/dist/components/properties/DateProperty.js +22 -0
- package/dist/components/properties/MultiSelectProperty.d.ts +12 -0
- package/dist/components/properties/MultiSelectProperty.js +33 -0
- package/dist/components/properties/NumberProperty.d.ts +16 -0
- package/dist/components/properties/NumberProperty.js +42 -0
- package/dist/components/properties/PropertyBase.d.ts +23 -0
- package/dist/components/properties/PropertyBase.js +27 -0
- package/dist/components/properties/SelectProperty.d.ts +12 -0
- package/dist/components/properties/SelectProperty.js +22 -0
- package/dist/components/properties/TextProperty.d.ts +15 -0
- package/dist/components/properties/TextProperty.js +37 -0
- package/dist/components/user-input/Checkbox.d.ts +37 -0
- package/dist/components/user-input/Checkbox.js +63 -0
- package/dist/components/user-input/DateAndTimePicker.d.ts +39 -0
- package/dist/components/user-input/DateAndTimePicker.js +65 -0
- package/dist/components/user-input/Input.d.ts +61 -0
- package/dist/components/user-input/Input.js +61 -0
- package/dist/components/user-input/Label.d.ts +12 -0
- package/dist/components/user-input/Label.js +12 -0
- package/dist/components/user-input/Menu.d.ts +21 -0
- package/dist/components/user-input/Menu.js +26 -0
- package/dist/components/user-input/MultiSelect.d.ts +39 -0
- package/dist/components/user-input/MultiSelect.js +57 -0
- package/dist/components/user-input/ScrollPicker.d.ts +11 -0
- package/dist/components/user-input/ScrollPicker.js +151 -0
- package/dist/components/user-input/SearchableSelect.d.ts +8 -0
- package/dist/components/user-input/SearchableSelect.js +14 -0
- package/dist/components/user-input/Select.d.ts +32 -0
- package/dist/components/user-input/Select.js +48 -0
- package/dist/components/user-input/Textarea.d.ts +20 -0
- package/dist/components/user-input/Textarea.js +33 -0
- package/dist/components/user-input/ToggleableInput.d.ts +32 -0
- package/dist/components/user-input/ToggleableInput.js +40 -0
- package/{globals.css → dist/css/globals.css} +1 -1
- package/dist/hooks/useHoverState.d.ts +40 -0
- package/dist/hooks/useHoverState.js +46 -0
- package/dist/hooks/useLanguage.d.ts +17 -0
- package/dist/hooks/useLanguage.js +51 -0
- package/dist/hooks/useLocalStorage.d.ts +4 -0
- package/dist/hooks/useLocalStorage.js +24 -0
- package/dist/hooks/useOutsideClick.d.ts +2 -0
- package/dist/hooks/useOutsideClick.js +22 -0
- package/dist/hooks/useSaveDelay.d.ts +5 -0
- package/dist/hooks/useSaveDelay.js +41 -0
- package/dist/hooks/useTheme.d.ts +16 -0
- package/dist/hooks/useTheme.js +32 -0
- package/dist/hooks/useTranslation.d.ts +24 -0
- package/dist/hooks/useTranslation.js +11 -0
- package/dist/util/array.d.ts +23 -0
- package/dist/util/array.js +103 -0
- package/{util/builder.ts → dist/util/builder.d.ts} +1 -4
- package/dist/util/builder.js +9 -0
- package/dist/util/date.d.ts +28 -0
- package/dist/util/date.js +133 -0
- package/dist/util/easeFunctions.d.ts +9 -0
- package/dist/util/easeFunctions.js +30 -0
- package/dist/util/emailValidation.d.ts +1 -0
- package/dist/util/emailValidation.js +3 -0
- package/dist/util/loopingArray.d.ts +23 -0
- package/dist/util/loopingArray.js +67 -0
- package/dist/util/math.d.ts +1 -0
- package/dist/util/math.js +3 -0
- package/dist/util/news.d.ts +98 -0
- package/dist/util/news.js +27 -0
- package/dist/util/noop.d.ts +1 -0
- package/dist/util/noop.js +1 -0
- package/{util/simpleSearch.ts → dist/util/simpleSearch.d.ts} +4 -21
- package/dist/util/simpleSearch.js +62 -0
- package/dist/util/storage.d.ts +15 -0
- package/dist/util/storage.js +32 -0
- package/dist/util/types.d.ts +1 -0
- package/dist/util/types.js +1 -0
- package/package.json +7 -8
- package/coloring/shading.ts +0 -46
- package/coloring/types.ts +0 -13
- package/components/Avatar.tsx +0 -58
- package/components/AvatarGroup.tsx +0 -48
- package/components/BreadCrumb.tsx +0 -35
- package/components/Button.tsx +0 -236
- package/components/ChipList.tsx +0 -89
- package/components/Circle.tsx +0 -27
- package/components/ErrorComponent.tsx +0 -40
- package/components/Expandable.tsx +0 -61
- package/components/HelpwaveBadge.tsx +0 -35
- package/components/HideableContentSection.tsx +0 -43
- package/components/InputGroup.tsx +0 -72
- package/components/LoadingAndErrorComponent.tsx +0 -47
- package/components/LoadingAnimation.tsx +0 -40
- package/components/LoadingButton.tsx +0 -27
- package/components/MarkdownInterpreter.tsx +0 -278
- package/components/Pagination.tsx +0 -65
- package/components/Profile.tsx +0 -124
- package/components/ProgressIndicator.tsx +0 -58
- package/components/Ring.tsx +0 -286
- package/components/SearchableList.tsx +0 -69
- package/components/SortButton.tsx +0 -33
- package/components/StepperBar.tsx +0 -124
- package/components/Table.tsx +0 -330
- package/components/TechRadar.tsx +0 -247
- package/components/TextImage.tsx +0 -86
- package/components/TimeDisplay.tsx +0 -121
- package/components/Tooltip.tsx +0 -92
- package/components/VerticalDivider.tsx +0 -51
- package/components/date/DatePicker.tsx +0 -164
- package/components/date/DayPicker.tsx +0 -95
- package/components/date/TimePicker.tsx +0 -167
- package/components/date/YearMonthPicker.tsx +0 -130
- package/components/examples/InputGroupExample.tsx +0 -58
- package/components/examples/MultiSelectExample.tsx +0 -57
- package/components/examples/SearchableSelectExample.tsx +0 -34
- package/components/examples/SelectExample.tsx +0 -28
- package/components/examples/StackingModals.tsx +0 -54
- package/components/examples/TableExample.tsx +0 -159
- package/components/examples/TextareaExample.tsx +0 -23
- package/components/examples/TileExample.tsx +0 -25
- package/components/examples/date/DateTimePickerExample.tsx +0 -53
- package/components/examples/properties/CheckboxPropertyExample.tsx +0 -29
- package/components/examples/properties/DatePropertyExample.tsx +0 -44
- package/components/examples/properties/MultiSelectPropertyExample.tsx +0 -39
- package/components/examples/properties/NumberPropertyExample.tsx +0 -28
- package/components/examples/properties/SelectPropertyExample.tsx +0 -39
- package/components/examples/properties/TextPropertyExample.tsx +0 -30
- package/components/icons/Helpwave.tsx +0 -51
- package/components/icons/Tag.tsx +0 -29
- package/components/layout/Carousel.tsx +0 -396
- package/components/layout/DividerInserter.tsx +0 -37
- package/components/layout/FAQSection.tsx +0 -57
- package/components/layout/Tile.tsx +0 -67
- package/components/modals/ConfirmDialog.tsx +0 -105
- package/components/modals/DiscardChangesDialog.tsx +0 -71
- package/components/modals/InputModal.tsx +0 -26
- package/components/modals/LanguageModal.tsx +0 -76
- package/components/modals/Modal.tsx +0 -149
- package/components/modals/ModalRegister.tsx +0 -45
- package/components/properties/CheckboxProperty.tsx +0 -62
- package/components/properties/DateProperty.tsx +0 -58
- package/components/properties/MultiSelectProperty.tsx +0 -82
- package/components/properties/NumberProperty.tsx +0 -86
- package/components/properties/PropertyBase.tsx +0 -84
- package/components/properties/SelectProperty.tsx +0 -67
- package/components/properties/TextProperty.tsx +0 -81
- package/components/user-input/Checkbox.tsx +0 -139
- package/components/user-input/DateAndTimePicker.tsx +0 -156
- package/components/user-input/Input.tsx +0 -192
- package/components/user-input/Label.tsx +0 -32
- package/components/user-input/Menu.tsx +0 -75
- package/components/user-input/MultiSelect.tsx +0 -158
- package/components/user-input/ScrollPicker.tsx +0 -240
- package/components/user-input/SearchableSelect.tsx +0 -36
- package/components/user-input/Select.tsx +0 -132
- package/components/user-input/Textarea.tsx +0 -86
- package/components/user-input/ToggleableInput.tsx +0 -115
- package/hooks/useHoverState.ts +0 -88
- package/hooks/useLanguage.tsx +0 -78
- package/hooks/useLocalStorage.tsx +0 -33
- package/hooks/useOutsideClick.ts +0 -25
- package/hooks/useSaveDelay.ts +0 -46
- package/hooks/useTheme.tsx +0 -57
- package/hooks/useTranslation.ts +0 -43
- package/index.ts +0 -0
- package/util/array.ts +0 -115
- package/util/date.ts +0 -180
- package/util/easeFunctions.ts +0 -37
- package/util/emailValidation.ts +0 -3
- package/util/loopingArray.ts +0 -94
- package/util/math.ts +0 -3
- package/util/news.ts +0 -43
- package/util/noop.ts +0 -1
- package/util/storage.ts +0 -37
- package/util/types.ts +0 -4
- /package/{components/Span.tsx → dist/components/Span.d.ts} +0 -0
- /package/{components/examples/Title.tsx → dist/components/examples/Title.d.ts} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
export type ModalContextType = {
|
|
3
|
+
register: string[];
|
|
4
|
+
addToRegister: (id: string) => void;
|
|
5
|
+
removeFromRegister: (id: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const ModalContext: import("react").Context<ModalContextType>;
|
|
8
|
+
/**
|
|
9
|
+
* A Simple Wrapper for the context
|
|
10
|
+
*/
|
|
11
|
+
export declare const ModalRegister: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useState } from 'react';
|
|
3
|
+
import { noop } from '../../util/noop';
|
|
4
|
+
export const ModalContext = createContext({
|
|
5
|
+
register: [],
|
|
6
|
+
addToRegister: noop,
|
|
7
|
+
removeFromRegister: noop,
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* A Simple Wrapper for the context
|
|
11
|
+
*/
|
|
12
|
+
export const ModalRegister = ({ children }) => {
|
|
13
|
+
const [register, setRegister] = useState([]);
|
|
14
|
+
const inRegister = (id) => {
|
|
15
|
+
return !!register.find(value => value === id);
|
|
16
|
+
};
|
|
17
|
+
const addToRegister = (id) => {
|
|
18
|
+
if (!inRegister(id)) {
|
|
19
|
+
setRegister([...register, id]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const removeFromRegister = (id) => {
|
|
23
|
+
if (inRegister(id)) {
|
|
24
|
+
setRegister(register.filter(value => value !== id));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return (_jsx(ModalContext.Provider, { value: { register, addToRegister, removeFromRegister }, children: children }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
2
|
+
import type { PropertyBaseProps } from './PropertyBase';
|
|
3
|
+
type CheckboxPropertyTranslation = {
|
|
4
|
+
yes: string;
|
|
5
|
+
no: string;
|
|
6
|
+
};
|
|
7
|
+
export type CheckboxPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue' | 'onRemove'> & {
|
|
8
|
+
value?: boolean;
|
|
9
|
+
onChange?: (value: boolean) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* An Input for a boolen properties
|
|
13
|
+
*/
|
|
14
|
+
export declare const CheckboxProperty: ({ overwriteTranslation, value, onChange, readOnly, ...baseProps }: PropsForTranslation<CheckboxPropertyTranslation, CheckboxPropertyProps>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Check } from 'lucide-react';
|
|
3
|
+
import { noop } from '../../util/noop';
|
|
4
|
+
import { Checkbox } from '../user-input/Checkbox';
|
|
5
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
6
|
+
import { PropertyBase } from './PropertyBase';
|
|
7
|
+
const defaultCheckboxPropertyTranslation = {
|
|
8
|
+
en: {
|
|
9
|
+
yes: 'Yes',
|
|
10
|
+
no: 'No'
|
|
11
|
+
},
|
|
12
|
+
de: {
|
|
13
|
+
yes: 'Ja',
|
|
14
|
+
no: 'Nein'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* An Input for a boolen properties
|
|
19
|
+
*/
|
|
20
|
+
export const CheckboxProperty = ({ overwriteTranslation, value, onChange = noop, readOnly, ...baseProps }) => {
|
|
21
|
+
const translation = useTranslation(defaultCheckboxPropertyTranslation, overwriteTranslation);
|
|
22
|
+
return (_jsx(PropertyBase, { ...baseProps, hasValue: true, readOnly: readOnly, icon: _jsx(Check, { size: 16 }), input: () => (_jsx("div", { className: "row py-2 px-4 items-center", children: _jsx(Checkbox
|
|
23
|
+
// TODO make bigger as in #904
|
|
24
|
+
, {
|
|
25
|
+
// TODO make bigger as in #904
|
|
26
|
+
checked: value !== null && value !== void 0 ? value : true, disabled: readOnly, onChange: onChange, label: { name: `${translation.yes}/${translation.no}`, labelType: 'labelMedium' } }) })) }));
|
|
27
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PropertyBaseProps } from './PropertyBase';
|
|
2
|
+
export type DatePropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {
|
|
3
|
+
value?: Date;
|
|
4
|
+
onChange?: (date: Date) => void;
|
|
5
|
+
onEditComplete?: (value: Date) => void;
|
|
6
|
+
type?: 'dateTime' | 'date';
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* An Input for date properties
|
|
10
|
+
*/
|
|
11
|
+
export declare const DateProperty: ({ value, onChange, onEditComplete, readOnly, type, ...baseProps }: DatePropertyProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarDays } from 'lucide-react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { formatDate, formatDateTime } from '../../util/date';
|
|
5
|
+
import { noop } from '../../util/noop';
|
|
6
|
+
import { Input } from '../user-input/Input';
|
|
7
|
+
import { PropertyBase } from './PropertyBase';
|
|
8
|
+
/**
|
|
9
|
+
* An Input for date properties
|
|
10
|
+
*/
|
|
11
|
+
export const DateProperty = ({ value, onChange = noop, onEditComplete = noop, readOnly, type = 'dateTime', ...baseProps }) => {
|
|
12
|
+
const hasValue = !!value;
|
|
13
|
+
const dateText = value ? (type === 'dateTime' ? formatDateTime(value) : formatDate(value)) : '';
|
|
14
|
+
return (_jsx(PropertyBase, { ...baseProps, hasValue: hasValue, icon: _jsx(CalendarDays, { size: 16 }), input: ({ softRequired }) => (_jsx("div", { className: clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue }), children: _jsx(Input, { className: clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !w-fit !rounded-none', { 'bg-surface-warning': softRequired && !hasValue }), value: dateText, type: type === 'dateTime' ? 'datetime-local' : 'date', readOnly: readOnly, onChange: (value, event) => {
|
|
15
|
+
if (!event.target.value) {
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const dueDate = new Date(value);
|
|
20
|
+
onChange(dueDate);
|
|
21
|
+
}, onEditCompleted: (value) => onEditComplete(new Date(value)) }) })) }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
2
|
+
import type { MultiSelectProps } from '../user-input/MultiSelect';
|
|
3
|
+
import type { PropertyBaseProps } from './PropertyBase';
|
|
4
|
+
type MultiSelectPropertyTranslation = {
|
|
5
|
+
select: string;
|
|
6
|
+
};
|
|
7
|
+
export type MultiSelectPropertyProps<T> = Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'>;
|
|
8
|
+
/**
|
|
9
|
+
* An Input for MultiSelect properties
|
|
10
|
+
*/
|
|
11
|
+
export declare const MultiSelectProperty: <T>({ overwriteTranslation, options, name, readOnly, softRequired, onRemove, ...multiSelectProps }: PropsForTranslation<MultiSelectPropertyTranslation, MultiSelectPropertyProps<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { List } from 'lucide-react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
5
|
+
import { MultiSelect } from '../user-input/MultiSelect';
|
|
6
|
+
import { ChipList } from '../ChipList';
|
|
7
|
+
import { PropertyBase } from './PropertyBase';
|
|
8
|
+
const defaultMultiSelectPropertyTranslation = {
|
|
9
|
+
en: {
|
|
10
|
+
select: 'Select'
|
|
11
|
+
},
|
|
12
|
+
de: {
|
|
13
|
+
select: 'Auswählen'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An Input for MultiSelect properties
|
|
18
|
+
*/
|
|
19
|
+
export const MultiSelectProperty = ({ overwriteTranslation, options, name, readOnly = false, softRequired, onRemove, ...multiSelectProps }) => {
|
|
20
|
+
const translation = useTranslation(defaultMultiSelectPropertyTranslation, overwriteTranslation);
|
|
21
|
+
const hasValue = options.some(value => value.selected);
|
|
22
|
+
let triggerClassName;
|
|
23
|
+
if (softRequired && !hasValue) {
|
|
24
|
+
triggerClassName = 'border-warning hover:brightness-90';
|
|
25
|
+
}
|
|
26
|
+
return (_jsx(PropertyBase, { name: name, onRemove: onRemove, readOnly: readOnly, softRequired: softRequired, hasValue: hasValue, icon: _jsx(List, { size: 16 }), input: ({ softRequired }) => (_jsx("div", { className: clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue }), children: _jsx(MultiSelect, { ...multiSelectProps, className: clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue }), triggerClassName: triggerClassName, selectedDisplay: ({ items }) => {
|
|
27
|
+
const selected = items.filter(value => value.selected);
|
|
28
|
+
if (selected.length === 0) {
|
|
29
|
+
return (_jsx("span", { children: "Select" }));
|
|
30
|
+
}
|
|
31
|
+
return (_jsx(ChipList, { list: selected.map(value => ({ children: value.label })) }));
|
|
32
|
+
}, options: options, disabled: readOnly, hintText: `${translation.select}...` }) })) }));
|
|
33
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
2
|
+
import type { PropertyBaseProps } from './PropertyBase';
|
|
3
|
+
type NumberPropertyTranslation = {
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type NumberPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {
|
|
7
|
+
value?: number;
|
|
8
|
+
suffix?: string;
|
|
9
|
+
onChange?: (value: number) => void;
|
|
10
|
+
onEditComplete?: (value: number) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* An Input for number properties
|
|
14
|
+
*/
|
|
15
|
+
export declare const NumberProperty: ({ overwriteTranslation, value, onChange, onRemove, onEditComplete, readOnly, suffix, ...baseProps }: PropsForTranslation<NumberPropertyTranslation, NumberPropertyProps>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Binary } from 'lucide-react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { noop } from '../../util/noop';
|
|
5
|
+
import { Input } from '../user-input/Input';
|
|
6
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
7
|
+
import { PropertyBase } from './PropertyBase';
|
|
8
|
+
const defaultNumberPropertyTranslation = {
|
|
9
|
+
en: {
|
|
10
|
+
value: 'Value'
|
|
11
|
+
},
|
|
12
|
+
de: {
|
|
13
|
+
value: 'Wert'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An Input for number properties
|
|
18
|
+
*/
|
|
19
|
+
export const NumberProperty = ({ overwriteTranslation, value, onChange = noop, onRemove = noop, onEditComplete = noop, readOnly, suffix, ...baseProps }) => {
|
|
20
|
+
const translation = useTranslation(defaultNumberPropertyTranslation, overwriteTranslation);
|
|
21
|
+
const hasValue = value !== undefined;
|
|
22
|
+
return (_jsx(PropertyBase, { ...baseProps, onRemove: onRemove, hasValue: hasValue, icon: _jsx(Binary, { size: 16 }), input: ({ softRequired }) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return (_jsxs("div", { className: clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue }), children: [_jsx(Input, { expanded: false, className: clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !w-fit !shadow-none !rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue }), value: (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '', type: "number", readOnly: readOnly, placeholder: `${translation.value}...`, onChange: (value) => {
|
|
25
|
+
const numberValue = parseFloat(value);
|
|
26
|
+
if (isNaN(numberValue)) {
|
|
27
|
+
onRemove();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
onChange(numberValue);
|
|
31
|
+
}
|
|
32
|
+
}, onEditCompleted: (value) => {
|
|
33
|
+
const numberValue = parseFloat(value);
|
|
34
|
+
if (isNaN(numberValue)) {
|
|
35
|
+
onRemove();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
onEditComplete(numberValue);
|
|
39
|
+
}
|
|
40
|
+
} }), suffix && _jsx("span", { className: clsx('ml-1', { 'bg-surface-warning': softRequired && !hasValue }), children: suffix })] }));
|
|
41
|
+
} }));
|
|
42
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
3
|
+
type PropertyBaseTranslation = {
|
|
4
|
+
remove: string;
|
|
5
|
+
};
|
|
6
|
+
export type PropertyBaseProps = {
|
|
7
|
+
name: string;
|
|
8
|
+
input: (props: {
|
|
9
|
+
softRequired: boolean;
|
|
10
|
+
hasValue: boolean;
|
|
11
|
+
}) => ReactNode;
|
|
12
|
+
onRemove?: () => void;
|
|
13
|
+
hasValue: boolean;
|
|
14
|
+
softRequired?: boolean;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
icon?: ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A component for showing a properties with uniform styling
|
|
21
|
+
*/
|
|
22
|
+
export declare const PropertyBase: ({ overwriteTranslation, name, input, softRequired, hasValue, icon, readOnly, onRemove, className, }: PropsForTranslation<PropertyBaseTranslation, PropertyBaseProps>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AlertTriangle } from 'lucide-react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { TextButton } from '../Button';
|
|
5
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
6
|
+
const defaultPropertyBaseTranslation = {
|
|
7
|
+
en: {
|
|
8
|
+
remove: 'Remove'
|
|
9
|
+
},
|
|
10
|
+
de: {
|
|
11
|
+
remove: 'Entfernen'
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A component for showing a properties with uniform styling
|
|
16
|
+
*/
|
|
17
|
+
export const PropertyBase = ({ overwriteTranslation, name, input, softRequired = false, hasValue, icon, readOnly, onRemove, className = '', }) => {
|
|
18
|
+
const translation = useTranslation(defaultPropertyBaseTranslation, overwriteTranslation);
|
|
19
|
+
const requiredAndNoValue = softRequired && !hasValue;
|
|
20
|
+
return (_jsxs("div", { className: clsx('row gap-x-0 group', className), children: [_jsxs("div", { className: clsx('row gap-x-2 !w-[200px] px-4 py-2 items-center rounded-l-xl border-2 border-r-0', {
|
|
21
|
+
'bg-gray-100 text-black group-hover:border-primary border-gray-400': !requiredAndNoValue,
|
|
22
|
+
'bg-warning text-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,
|
|
23
|
+
}, className), children: [icon, name] }), _jsxs("div", { className: clsx('row grow justify-between items-center rounded-r-xl border-2 border-l-0', {
|
|
24
|
+
'bg-white group-hover:border-primary border-gray-400': !requiredAndNoValue,
|
|
25
|
+
'bg-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,
|
|
26
|
+
}, className), children: [input({ softRequired, hasValue }), requiredAndNoValue && (_jsx("div", { className: "text-warning pr-4", children: _jsx(AlertTriangle, { size: 24 }) })), onRemove && (_jsx(TextButton, { onClick: onRemove, color: "negative", className: clsx('pr-4 items-center', { '!text-transparent': !hasValue || readOnly }), disabled: !hasValue || readOnly, children: translation.remove }))] })] }));
|
|
27
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
2
|
+
import type { SearchableSelectProps } from '../user-input/SearchableSelect';
|
|
3
|
+
import type { PropertyBaseProps } from './PropertyBase';
|
|
4
|
+
type SingleSelectPropertyTranslation = {
|
|
5
|
+
select: string;
|
|
6
|
+
};
|
|
7
|
+
export type SingleSelectPropertyProps<T> = Omit<PropertyBaseProps & SearchableSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'labelClassName' | 'additionalItems'>;
|
|
8
|
+
/**
|
|
9
|
+
* An Input for SingleSelect properties
|
|
10
|
+
*/
|
|
11
|
+
export declare const SingleSelectProperty: <T>({ overwriteTranslation, value, options, name, readOnly, softRequired, onRemove, ...multiSelectProps }: PropsForTranslation<SingleSelectPropertyTranslation, SingleSelectPropertyProps<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { List } from 'lucide-react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
5
|
+
import { SearchableSelect } from '../user-input/SearchableSelect';
|
|
6
|
+
import { PropertyBase } from './PropertyBase';
|
|
7
|
+
const defaultSingleSelectPropertyTranslation = {
|
|
8
|
+
en: {
|
|
9
|
+
select: 'Select'
|
|
10
|
+
},
|
|
11
|
+
de: {
|
|
12
|
+
select: 'Auswählen'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* An Input for SingleSelect properties
|
|
17
|
+
*/
|
|
18
|
+
export const SingleSelectProperty = ({ overwriteTranslation, value, options, name, readOnly = false, softRequired, onRemove, ...multiSelectProps }) => {
|
|
19
|
+
const translation = useTranslation(defaultSingleSelectPropertyTranslation, overwriteTranslation);
|
|
20
|
+
const hasValue = value !== undefined;
|
|
21
|
+
return (_jsx(PropertyBase, { name: name, onRemove: onRemove, readOnly: readOnly, softRequired: softRequired, hasValue: hasValue, icon: _jsx(List, { size: 16 }), input: ({ softRequired }) => (_jsx("div", { className: clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue }), children: _jsx(SearchableSelect, { ...multiSelectProps, value: value, options: options, isDisabled: readOnly, className: clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue }), hintText: `${translation.select}...` }) })) }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
2
|
+
import type { PropertyBaseProps } from './PropertyBase';
|
|
3
|
+
type TextPropertyTranslation = {
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type TextPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {
|
|
7
|
+
value?: string;
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
onEditComplete?: (value: string) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* An Input for Text properties
|
|
13
|
+
*/
|
|
14
|
+
export declare const TextProperty: ({ overwriteTranslation, value, readOnly, onChange, onRemove, onEditComplete, ...baseProps }: PropsForTranslation<TextPropertyTranslation, TextPropertyProps>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'lucide-react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
5
|
+
import { Textarea } from '../user-input/Textarea';
|
|
6
|
+
import { noop } from '../../util/noop';
|
|
7
|
+
import { PropertyBase } from './PropertyBase';
|
|
8
|
+
const defaultTextPropertyTranslation = {
|
|
9
|
+
en: {
|
|
10
|
+
value: 'Text'
|
|
11
|
+
},
|
|
12
|
+
de: {
|
|
13
|
+
value: 'Text'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An Input for Text properties
|
|
18
|
+
*/
|
|
19
|
+
export const TextProperty = ({ overwriteTranslation, value, readOnly, onChange = noop, onRemove = noop, onEditComplete = noop, ...baseProps }) => {
|
|
20
|
+
const translation = useTranslation(defaultTextPropertyTranslation, overwriteTranslation);
|
|
21
|
+
const hasValue = value !== undefined;
|
|
22
|
+
return (_jsx(PropertyBase, { ...baseProps, onRemove: onRemove, hasValue: hasValue, icon: _jsx(Text, { size: 16 }), input: ({ softRequired }) => (_jsx("div", { className: clsx('row grow pt-2 pb-1 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue }), children: _jsx(Textarea, { className: clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue }), rows: 5, defaultStyle: false, value: value !== null && value !== void 0 ? value : '', readOnly: readOnly, placeholder: `${translation.value}...`, onChange: (value) => {
|
|
23
|
+
if (!value) {
|
|
24
|
+
onRemove();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
onChange(value);
|
|
28
|
+
}
|
|
29
|
+
}, onEditCompleted: (value) => {
|
|
30
|
+
if (!value) {
|
|
31
|
+
onRemove();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
onEditComplete(value);
|
|
35
|
+
}
|
|
36
|
+
} }) })) }));
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CheckedState } from '@radix-ui/react-checkbox';
|
|
2
|
+
import type { LabelProps } from './Label';
|
|
3
|
+
type CheckBoxSize = 'small' | 'medium' | 'large';
|
|
4
|
+
type CheckboxProps = {
|
|
5
|
+
/** used for the label's `for` attribute */
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: Omit<LabelProps, 'id'>;
|
|
8
|
+
/**
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
checked: CheckedState;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (checked: boolean) => void;
|
|
14
|
+
onChangeTristate?: (checked: CheckedState) => void;
|
|
15
|
+
size?: CheckBoxSize;
|
|
16
|
+
className?: string;
|
|
17
|
+
containerClassName?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A Tristate checkbox
|
|
21
|
+
*
|
|
22
|
+
* The state is managed by the parent
|
|
23
|
+
*/
|
|
24
|
+
declare const ControlledCheckbox: ({ id, label, checked, disabled, onChange, onChangeTristate, size, className, containerClassName }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
type UncontrolledCheckboxProps = Omit<CheckboxProps, 'value' | 'checked'> & {
|
|
26
|
+
/**
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
defaultValue?: CheckedState;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A Tristate checkbox
|
|
33
|
+
*
|
|
34
|
+
* The state is managed by this component
|
|
35
|
+
*/
|
|
36
|
+
declare const UncontrolledCheckbox: ({ onChange, onChangeTristate, defaultValue, ...props }: UncontrolledCheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export { UncontrolledCheckbox, ControlledCheckbox as Checkbox };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
4
|
+
import { Check, Minus } from 'lucide-react';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { Label } from './Label';
|
|
7
|
+
const checkboxSizeMapping = {
|
|
8
|
+
small: 'size-4',
|
|
9
|
+
medium: 'size-6',
|
|
10
|
+
large: 'size-8',
|
|
11
|
+
};
|
|
12
|
+
const checkboxIconSizeMapping = {
|
|
13
|
+
small: 'size-3',
|
|
14
|
+
medium: 'size-5',
|
|
15
|
+
large: 'size-7',
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A Tristate checkbox
|
|
19
|
+
*
|
|
20
|
+
* The state is managed by the parent
|
|
21
|
+
*/
|
|
22
|
+
const ControlledCheckbox = ({ id, label, checked, disabled, onChange, onChangeTristate, size = 'medium', className = '', containerClassName }) => {
|
|
23
|
+
const usedSizeClass = checkboxSizeMapping[size];
|
|
24
|
+
const innerIconSize = checkboxIconSizeMapping[size];
|
|
25
|
+
const propagateChange = (checked) => {
|
|
26
|
+
if (onChangeTristate) {
|
|
27
|
+
onChangeTristate(checked);
|
|
28
|
+
}
|
|
29
|
+
if (onChange) {
|
|
30
|
+
onChange(checked === 'indeterminate' ? false : checked);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const changeValue = () => {
|
|
34
|
+
const newValue = checked === 'indeterminate' ? false : !checked;
|
|
35
|
+
propagateChange(newValue);
|
|
36
|
+
};
|
|
37
|
+
return (_jsxs("div", { className: clsx('row justify-center items-center', containerClassName), children: [_jsx(CheckboxPrimitive.Root, { onCheckedChange: propagateChange, checked: checked, disabled: disabled, id: id, className: clsx(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {
|
|
38
|
+
'text-disabled-text border-disabled-text': disabled,
|
|
39
|
+
'border-on-background': !disabled,
|
|
40
|
+
'bg-primary/30 border-primary text-primary': checked === true || checked === 'indeterminate',
|
|
41
|
+
'hover:border-gray-400 focus:hover:border-primary': !checked
|
|
42
|
+
}, className), children: _jsxs(CheckboxPrimitive.Indicator, { children: [checked === true && _jsx(Check, { className: innerIconSize }), checked === 'indeterminate' && _jsx(Minus, { className: innerIconSize })] }) }), label &&
|
|
43
|
+
_jsx(Label, { ...label, className: clsx('cursor-pointer', label.className), htmlFor: id, onClick: changeValue })] }));
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A Tristate checkbox
|
|
47
|
+
*
|
|
48
|
+
* The state is managed by this component
|
|
49
|
+
*/
|
|
50
|
+
const UncontrolledCheckbox = ({ onChange, onChangeTristate, defaultValue = false, ...props }) => {
|
|
51
|
+
const [checked, setChecked] = useState(defaultValue);
|
|
52
|
+
const handleChange = (checked) => {
|
|
53
|
+
if (onChangeTristate) {
|
|
54
|
+
onChangeTristate(checked);
|
|
55
|
+
}
|
|
56
|
+
if (onChange) {
|
|
57
|
+
onChange(checked === 'indeterminate' ? false : checked);
|
|
58
|
+
}
|
|
59
|
+
setChecked(checked);
|
|
60
|
+
};
|
|
61
|
+
return (_jsx(ControlledCheckbox, { ...props, checked: checked, onChangeTristate: handleChange }));
|
|
62
|
+
};
|
|
63
|
+
export { UncontrolledCheckbox, ControlledCheckbox as Checkbox };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PropsForTranslation } from '../../hooks/useTranslation';
|
|
2
|
+
import type { TimePickerProps } from '../date/TimePicker';
|
|
3
|
+
import type { DatePickerProps } from '../date/DatePicker';
|
|
4
|
+
type TimeTranslation = {
|
|
5
|
+
clear: string;
|
|
6
|
+
change: string;
|
|
7
|
+
year: string;
|
|
8
|
+
month: string;
|
|
9
|
+
day: string;
|
|
10
|
+
january: string;
|
|
11
|
+
february: string;
|
|
12
|
+
march: string;
|
|
13
|
+
april: string;
|
|
14
|
+
may: string;
|
|
15
|
+
june: string;
|
|
16
|
+
july: string;
|
|
17
|
+
august: string;
|
|
18
|
+
september: string;
|
|
19
|
+
october: string;
|
|
20
|
+
november: string;
|
|
21
|
+
december: string;
|
|
22
|
+
};
|
|
23
|
+
export type DateTimePickerMode = 'date' | 'time' | 'dateTime';
|
|
24
|
+
export type DateTimePickerProps = {
|
|
25
|
+
mode?: DateTimePickerMode;
|
|
26
|
+
value?: Date;
|
|
27
|
+
start?: Date;
|
|
28
|
+
end?: Date;
|
|
29
|
+
onChange?: (date: Date) => void;
|
|
30
|
+
onFinish?: (date: Date) => void;
|
|
31
|
+
onRemove?: () => void;
|
|
32
|
+
datePickerProps?: Omit<DatePickerProps, 'onChange' | 'value' | 'start' | 'end'>;
|
|
33
|
+
timePickerProps?: Omit<TimePickerProps, 'onChange' | 'time' | 'maxHeight'>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A Component for picking a Date and Time
|
|
37
|
+
*/
|
|
38
|
+
export declare const DateTimePicker: ({ overwriteTranslation, value, start, end, mode, onFinish, onChange, onRemove, timePickerProps, datePickerProps, }: PropsForTranslation<TimeTranslation, DateTimePickerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useTranslation } from '../../hooks/useTranslation';
|
|
4
|
+
import { noop } from '../../util/noop';
|
|
5
|
+
import { addDuration, subtractDuration } from '../../util/date';
|
|
6
|
+
import { SolidButton } from '../Button';
|
|
7
|
+
import { TimePicker } from '../date/TimePicker';
|
|
8
|
+
import { DatePicker } from '../date/DatePicker';
|
|
9
|
+
const defaultTimeTranslation = {
|
|
10
|
+
en: {
|
|
11
|
+
clear: 'Clear',
|
|
12
|
+
change: 'Change',
|
|
13
|
+
year: 'Year',
|
|
14
|
+
month: 'Month',
|
|
15
|
+
day: 'Day',
|
|
16
|
+
january: 'January',
|
|
17
|
+
february: 'Febuary',
|
|
18
|
+
march: 'March',
|
|
19
|
+
april: 'April',
|
|
20
|
+
may: 'May',
|
|
21
|
+
june: 'June',
|
|
22
|
+
july: 'July',
|
|
23
|
+
august: 'August',
|
|
24
|
+
september: 'September',
|
|
25
|
+
october: 'October',
|
|
26
|
+
november: 'November',
|
|
27
|
+
december: 'December',
|
|
28
|
+
},
|
|
29
|
+
de: {
|
|
30
|
+
clear: 'Entfernen',
|
|
31
|
+
change: 'Ändern',
|
|
32
|
+
year: 'Jahr',
|
|
33
|
+
month: 'Monat',
|
|
34
|
+
day: 'Tag',
|
|
35
|
+
january: 'Januar',
|
|
36
|
+
february: 'Febuar',
|
|
37
|
+
march: 'März',
|
|
38
|
+
april: 'April',
|
|
39
|
+
may: 'Mai',
|
|
40
|
+
june: 'Juni',
|
|
41
|
+
july: 'Juli',
|
|
42
|
+
august: 'August',
|
|
43
|
+
september: 'September',
|
|
44
|
+
october: 'October',
|
|
45
|
+
november: 'November',
|
|
46
|
+
december: 'December',
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A Component for picking a Date and Time
|
|
51
|
+
*/
|
|
52
|
+
export const DateTimePicker = ({ overwriteTranslation, value = new Date(), start = subtractDuration(new Date(), { years: 50 }), end = addDuration(new Date(), { years: 50 }), mode = 'dateTime', onFinish = noop, onChange = noop, onRemove = noop, timePickerProps, datePickerProps, }) => {
|
|
53
|
+
const translation = useTranslation(defaultTimeTranslation, overwriteTranslation);
|
|
54
|
+
const useDate = mode === 'dateTime' || mode === 'date';
|
|
55
|
+
const useTime = mode === 'dateTime' || mode === 'time';
|
|
56
|
+
let dateDisplay;
|
|
57
|
+
let timeDisplay;
|
|
58
|
+
if (useDate) {
|
|
59
|
+
dateDisplay = (_jsx(DatePicker, { ...datePickerProps, className: "min-w-[320px] min-h-[250px]", yearMonthPickerProps: { maxHeight: 218 }, value: value, start: start, end: end, onChange: onChange }));
|
|
60
|
+
}
|
|
61
|
+
if (useTime) {
|
|
62
|
+
timeDisplay = (_jsx(TimePicker, { ...timePickerProps, className: clsx('h-full', { 'justify-between w-full': mode === 'time' }), maxHeight: 250, time: value, onChange: onChange }));
|
|
63
|
+
}
|
|
64
|
+
return (_jsxs("div", { className: "col w-fit", children: [_jsxs("div", { className: "row gap-x-4", children: [dateDisplay, timeDisplay] }), _jsx("div", { className: "row justify-end", children: _jsxs("div", { className: "row gap-x-2 mt-1", children: [_jsx(SolidButton, { size: "medium", color: "negative", onClick: onRemove, children: translation.clear }), _jsx(SolidButton, { size: "medium", onClick: () => onFinish(value), children: translation.change })] }) })] }));
|
|
65
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { type ChangeEvent, type HTMLInputTypeAttribute, type InputHTMLAttributes } from 'react';
|
|
2
|
+
import type { LabelProps } from './Label';
|
|
3
|
+
export type InputProps = {
|
|
4
|
+
/**
|
|
5
|
+
* used for the label's `for` attribute
|
|
6
|
+
*/
|
|
7
|
+
id?: string;
|
|
8
|
+
value: string;
|
|
9
|
+
label?: Omit<LabelProps, 'id'>;
|
|
10
|
+
/**
|
|
11
|
+
* @default 'text'
|
|
12
|
+
*/
|
|
13
|
+
type?: HTMLInputTypeAttribute;
|
|
14
|
+
/**
|
|
15
|
+
* Callback for when the input's value changes
|
|
16
|
+
* This is pretty much required but made optional for the rare cases where it actually isn't need such as when used with disabled
|
|
17
|
+
* That could be enforced through a union type but that seems a bit overkill
|
|
18
|
+
* @default noop
|
|
19
|
+
*/
|
|
20
|
+
onChange?: (text: string, event: ChangeEvent<HTMLInputElement>) => void;
|
|
21
|
+
onChangeEvent?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
22
|
+
className?: string;
|
|
23
|
+
onEditCompleted?: (text: string, event: ChangeEvent<HTMLInputElement>) => void;
|
|
24
|
+
expanded?: boolean;
|
|
25
|
+
containerClassName?: string;
|
|
26
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'value' | 'label' | 'type' | 'onChange' | 'crossOrigin'>;
|
|
27
|
+
/**
|
|
28
|
+
* A Component for inputting text or other information
|
|
29
|
+
*
|
|
30
|
+
* Its state is managed must be managed by the parent
|
|
31
|
+
*/
|
|
32
|
+
declare const ControlledInput: ({ id, type, value, label, onChange, onChangeEvent, className, onEditCompleted, expanded, onBlur, containerClassName, ...restProps }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
type UncontrolledInputProps = Omit<InputProps, 'value'> & {
|
|
34
|
+
/**
|
|
35
|
+
* @default ''
|
|
36
|
+
*/
|
|
37
|
+
defaultValue?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A Component for inputting text or other information
|
|
41
|
+
*
|
|
42
|
+
* Its state is managed by the component itself
|
|
43
|
+
*/
|
|
44
|
+
declare const UncontrolledInput: ({ defaultValue, onChange, ...props }: UncontrolledInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export type FormInputProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
46
|
+
id: string;
|
|
47
|
+
labelText?: string;
|
|
48
|
+
errorText?: string;
|
|
49
|
+
labelClassName?: string;
|
|
50
|
+
errorClassName?: string;
|
|
51
|
+
containerClassName?: string;
|
|
52
|
+
};
|
|
53
|
+
declare const FormInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
54
|
+
id: string;
|
|
55
|
+
labelText?: string;
|
|
56
|
+
errorText?: string;
|
|
57
|
+
labelClassName?: string;
|
|
58
|
+
errorClassName?: string;
|
|
59
|
+
containerClassName?: string;
|
|
60
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
61
|
+
export { UncontrolledInput, ControlledInput as Input, FormInput };
|