@addsign/moje-agenda-shared-lib 2.0.3 → 2.0.4
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/assets/style.css +3 -0
- package/dist/assets/tailwind.css +25 -24
- package/dist/components/datatable/DataTable.js +1 -0
- package/dist/components/datatable/DataTable.js.map +1 -1
- package/dist/components/datatable/DataTableServer.js +1 -0
- package/dist/components/datatable/DataTableServer.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBar.js +1 -0
- package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBarServer.js +1 -0
- package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
- package/dist/components/form/FileInput.js +1 -0
- package/dist/components/form/FileInput.js.map +1 -1
- package/dist/components/form/FileInputMultiple.js +1 -0
- package/dist/components/form/FileInputMultiple.js.map +1 -1
- package/dist/components/form/FormField.js +1 -0
- package/dist/components/form/FormField.js.map +1 -1
- package/dist/components/form/PositionsSelectorSingle.js +1 -0
- package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
- package/dist/components/form/SelectField.js +1 -0
- package/dist/components/form/SelectField.js.map +1 -1
- package/dist/components/profiles/ProfileOverview.js +1 -0
- package/dist/components/profiles/ProfileOverview.js.map +1 -1
- package/dist/components/ui/Combobox.js +1 -0
- package/dist/components/ui/Combobox.js.map +1 -1
- package/dist/components/ui/DateTimePicker.d.ts +1 -1
- package/dist/components/ui/DateTimePicker.js +25 -13
- package/dist/components/ui/DateTimePicker.js.map +1 -1
- package/dist/components/ui/datepicker.js +11 -0
- package/dist/components/ui/datepicker.js.map +1 -1
- package/dist/components/ui/input.js +1 -0
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +21 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/lib/components/ui/Combobox.tsx +1 -0
- package/lib/components/ui/DatePicker.tsx +11 -0
- package/lib/components/ui/DateTimePicker.tsx +30 -16
- package/lib/components/ui/input.tsx +1 -0
- package/lib/components/ui/textarea.tsx +22 -0
- package/lib/main.ts +1 -0
- package/package.json +1 -1
|
@@ -38,6 +38,16 @@ const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(
|
|
|
38
38
|
|
|
39
39
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
40
40
|
setInputValue(event.target.value);
|
|
41
|
+
const parsedDate = parse(event.target.value, DATE_FORMAT, new Date());
|
|
42
|
+
if (isValid(parsedDate)) {
|
|
43
|
+
setDate(parsedDate);
|
|
44
|
+
onChange?.(parsedDate);
|
|
45
|
+
setInputValue(format(parsedDate, DATE_FORMAT));
|
|
46
|
+
} else {
|
|
47
|
+
setInputValue("");
|
|
48
|
+
setDate(undefined);
|
|
49
|
+
onChange?.(undefined);
|
|
50
|
+
}
|
|
41
51
|
};
|
|
42
52
|
|
|
43
53
|
const handleInputBlur = () => {
|
|
@@ -95,6 +105,7 @@ const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(
|
|
|
95
105
|
<CalendarIcon className="absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
|
96
106
|
{clearable && inputValue && (
|
|
97
107
|
<Button
|
|
108
|
+
type="button"
|
|
98
109
|
variant="ghost"
|
|
99
110
|
size="icon"
|
|
100
111
|
className="absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0"
|
|
@@ -19,7 +19,7 @@ const DATE_FORMAT = "dd.MM.yyyy HH:mm";
|
|
|
19
19
|
|
|
20
20
|
interface DateTimePickerProps {
|
|
21
21
|
value?: Date;
|
|
22
|
-
onChange?: (date: Date | undefined) => void;
|
|
22
|
+
onChange?: (date: Date | undefined | null) => void;
|
|
23
23
|
className?: string;
|
|
24
24
|
placeholder?: string;
|
|
25
25
|
clearable?: boolean;
|
|
@@ -30,43 +30,56 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
|
|
|
30
30
|
{ value, onChange, className, clearable = true, placeholder, ...props },
|
|
31
31
|
ref
|
|
32
32
|
) => {
|
|
33
|
-
const [dateTime, setDateTime] = React.useState<Date |
|
|
34
|
-
const [inputValue, setInputValue] = React.useState<string>("");
|
|
33
|
+
const [dateTime, setDateTime] = React.useState<Date | null>(value || null);
|
|
34
|
+
const [inputValue, setInputValue] = React.useState<string | null>("");
|
|
35
35
|
|
|
36
36
|
useEffect(() => {
|
|
37
37
|
if (value) {
|
|
38
38
|
setDateTime(value);
|
|
39
39
|
setInputValue(format(value, DATE_FORMAT));
|
|
40
40
|
} else {
|
|
41
|
-
setDateTime(
|
|
41
|
+
setDateTime(null);
|
|
42
42
|
setInputValue("");
|
|
43
43
|
}
|
|
44
44
|
}, [value]);
|
|
45
45
|
|
|
46
46
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
47
|
+
event.stopPropagation(); // Stop bubbling to prevent interference with other components
|
|
48
|
+
|
|
47
49
|
setInputValue(event.target.value);
|
|
50
|
+
const parsedDateTime = parse(event.target.value, DATE_FORMAT, new Date());
|
|
51
|
+
|
|
52
|
+
if (isValid(parsedDateTime)) {
|
|
53
|
+
setDateTime(parsedDateTime);
|
|
54
|
+
onChange?.(parsedDateTime);
|
|
55
|
+
setInputValue(format(parsedDateTime, DATE_FORMAT));
|
|
56
|
+
} else {
|
|
57
|
+
setInputValue("");
|
|
58
|
+
setDateTime(null);
|
|
59
|
+
onChange?.(null);
|
|
60
|
+
}
|
|
48
61
|
};
|
|
49
62
|
|
|
50
63
|
const handleInputBlur = () => {
|
|
51
64
|
if (inputValue === "") {
|
|
52
|
-
setDateTime(
|
|
53
|
-
onChange?.(
|
|
65
|
+
setDateTime(null);
|
|
66
|
+
onChange?.(null);
|
|
54
67
|
return;
|
|
55
68
|
}
|
|
56
69
|
|
|
57
|
-
const parsedDateTime = parse(inputValue, DATE_FORMAT, new Date());
|
|
70
|
+
const parsedDateTime = parse(inputValue || "", DATE_FORMAT, new Date());
|
|
58
71
|
if (isValid(parsedDateTime)) {
|
|
59
72
|
setDateTime(parsedDateTime);
|
|
60
73
|
onChange?.(parsedDateTime);
|
|
61
74
|
setInputValue(format(parsedDateTime, DATE_FORMAT));
|
|
62
75
|
} else {
|
|
63
76
|
setInputValue("");
|
|
64
|
-
setDateTime(
|
|
65
|
-
onChange?.(
|
|
77
|
+
setDateTime(null);
|
|
78
|
+
onChange?.(null);
|
|
66
79
|
}
|
|
67
80
|
};
|
|
68
81
|
|
|
69
|
-
const handleDateSelect = (selectedDate: Date | undefined) => {
|
|
82
|
+
const handleDateSelect = (selectedDate: Date | undefined | null) => {
|
|
70
83
|
if (selectedDate) {
|
|
71
84
|
const newDateTime = dateTime
|
|
72
85
|
? set(dateTime, {
|
|
@@ -79,9 +92,9 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
|
|
|
79
92
|
onChange?.(newDateTime);
|
|
80
93
|
setInputValue(format(newDateTime, DATE_FORMAT));
|
|
81
94
|
} else {
|
|
82
|
-
setDateTime(
|
|
95
|
+
setDateTime(null);
|
|
83
96
|
setInputValue("");
|
|
84
|
-
onChange?.(
|
|
97
|
+
onChange?.(null);
|
|
85
98
|
}
|
|
86
99
|
};
|
|
87
100
|
|
|
@@ -102,8 +115,8 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
|
|
|
102
115
|
|
|
103
116
|
const handleClear = () => {
|
|
104
117
|
setInputValue("");
|
|
105
|
-
setDateTime(
|
|
106
|
-
onChange?.(
|
|
118
|
+
setDateTime(null);
|
|
119
|
+
onChange?.(null);
|
|
107
120
|
};
|
|
108
121
|
|
|
109
122
|
const timeOptions = Array.from({ length: 48 }, (_, i) => {
|
|
@@ -119,7 +132,7 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
|
|
|
119
132
|
<Input
|
|
120
133
|
ref={ref}
|
|
121
134
|
type="text"
|
|
122
|
-
value={inputValue}
|
|
135
|
+
value={inputValue || ""}
|
|
123
136
|
onChange={handleInputChange}
|
|
124
137
|
onBlur={handleInputBlur}
|
|
125
138
|
placeholder={placeholder}
|
|
@@ -132,6 +145,7 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
|
|
|
132
145
|
<CalendarClockIcon className="absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
|
133
146
|
{clearable && inputValue && (
|
|
134
147
|
<Button
|
|
148
|
+
type="button"
|
|
135
149
|
variant="ghost"
|
|
136
150
|
size="icon"
|
|
137
151
|
className="absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0"
|
|
@@ -146,7 +160,7 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
|
|
|
146
160
|
<PopoverContent className="w-auto p-0" align="start">
|
|
147
161
|
<Calendar
|
|
148
162
|
mode="single"
|
|
149
|
-
selected={dateTime}
|
|
163
|
+
selected={dateTime || undefined}
|
|
150
164
|
onSelect={handleDateSelect}
|
|
151
165
|
initialFocus
|
|
152
166
|
/>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../utils/utils";
|
|
4
|
+
|
|
5
|
+
const Textarea = React.forwardRef<
|
|
6
|
+
HTMLTextAreaElement,
|
|
7
|
+
React.ComponentProps<"textarea">
|
|
8
|
+
>(({ className, ...props }, ref) => {
|
|
9
|
+
return (
|
|
10
|
+
<textarea
|
|
11
|
+
className={cn(
|
|
12
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-ring placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
ref={ref}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
Textarea.displayName = "Textarea";
|
|
21
|
+
|
|
22
|
+
export { Textarea };
|
package/lib/main.ts
CHANGED
|
@@ -59,6 +59,7 @@ export * from "./components/ui/Combobox.tsx";
|
|
|
59
59
|
export * from "./components/ui/select.tsx";
|
|
60
60
|
export * from "./components/ui/tooltip.tsx";
|
|
61
61
|
export * from "./components/ui/separator.tsx";
|
|
62
|
+
export * from "./components/ui/textarea.tsx";
|
|
62
63
|
export { Button as ButtonCN, buttonVariants } from "./components/ui/button.tsx";
|
|
63
64
|
|
|
64
65
|
|