@vertesia/ui 0.61.0 → 0.63.0
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/lib/esm/core/components/shadcn/calendar.js +7 -39
- package/lib/esm/core/components/shadcn/calendar.js.map +1 -1
- package/lib/esm/core/components/shadcn/filters/comboBox.js +6 -3
- package/lib/esm/core/components/shadcn/filters/comboBox.js.map +1 -1
- package/lib/esm/core/components/shadcn/filters/dateFilter.js +10 -5
- package/lib/esm/core/components/shadcn/filters/dateFilter.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/components/shadcn/calendar.d.ts +3 -3
- package/lib/vertesia-ui-core.js +1 -1
- package/lib/vertesia-ui-core.js.map +1 -1
- package/package.json +5 -5
- package/src/core/components/shadcn/calendar.tsx +9 -65
- package/src/core/components/shadcn/filters/comboBox.tsx +7 -6
- package/src/core/components/shadcn/filters/dateFilter.tsx +34 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Vertesia UI components and and hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"monaco-editor": "^0.52.2",
|
|
49
49
|
"motion": "^12.12.1",
|
|
50
50
|
"react": "^19.1.0",
|
|
51
|
-
"react-
|
|
51
|
+
"react-date-picker": "^11.0.0",
|
|
52
52
|
"react-dom": "^19.1.0",
|
|
53
53
|
"react-error-boundary": "^6.0.0",
|
|
54
54
|
"react-markdown": "^10.1.0",
|
|
55
55
|
"remark-gfm": "^4.0.1",
|
|
56
56
|
"tailwind-merge": "^3.3.0",
|
|
57
57
|
"ts-md5": "^1.3.1",
|
|
58
|
-
"@vertesia/client": "0.
|
|
59
|
-
"@vertesia/common": "0.
|
|
60
|
-
"@vertesia/json": "0.
|
|
58
|
+
"@vertesia/client": "0.63.0",
|
|
59
|
+
"@vertesia/common": "0.63.0",
|
|
60
|
+
"@vertesia/json": "0.63.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@eslint/js": "^9.27.0",
|
|
@@ -1,83 +1,27 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import
|
|
5
|
-
import { DayPicker, StyledComponent } from "react-day-picker"
|
|
4
|
+
import DatePicker from "react-date-picker"
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
import { buttonVariants } from "./button"
|
|
9
|
-
|
|
10
|
-
export type CalendarProps = React.ComponentProps<typeof DayPicker> & {
|
|
6
|
+
export type CalendarProps = React.ComponentProps<typeof DatePicker> & {
|
|
11
7
|
size?: "sm" | "md" | "lg"
|
|
12
8
|
}
|
|
13
9
|
|
|
14
10
|
function Calendar({
|
|
15
11
|
className,
|
|
16
|
-
classNames,
|
|
17
|
-
showOutsideDays = true,
|
|
18
12
|
size = "md",
|
|
19
13
|
...props
|
|
20
14
|
}: CalendarProps) {
|
|
21
|
-
const
|
|
22
|
-
sm: "
|
|
23
|
-
md: "
|
|
24
|
-
lg: "
|
|
15
|
+
const sizeClass = {
|
|
16
|
+
sm: "text-sm",
|
|
17
|
+
md: "text-base",
|
|
18
|
+
lg: "text-lg",
|
|
25
19
|
}[size]
|
|
26
20
|
|
|
27
21
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
classNames={{
|
|
32
|
-
months: "flex w-full flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0 flex-1",
|
|
33
|
-
month: "space-y-4 w-full flex flex-col",
|
|
34
|
-
caption: "flex justify-center pt-1 relative items-center",
|
|
35
|
-
caption_label: "text-sm font-medium",
|
|
36
|
-
nav: "space-x-1 flex items-center",
|
|
37
|
-
nav_button: cn(
|
|
38
|
-
buttonVariants({ variant: "outline" }),
|
|
39
|
-
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
|
|
40
|
-
),
|
|
41
|
-
nav_button_previous: "absolute left-1",
|
|
42
|
-
nav_button_next: "absolute right-1",
|
|
43
|
-
table: "w-full h-full border-collapse space-y-1",
|
|
44
|
-
head_row: "",
|
|
45
|
-
head_cell:
|
|
46
|
-
"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
|
|
47
|
-
row: "w-full mt-2",
|
|
48
|
-
cell: cn(
|
|
49
|
-
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
|
|
50
|
-
props.mode === "range"
|
|
51
|
-
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md"
|
|
52
|
-
: "[&:has([aria-selected])]:rounded-md"
|
|
53
|
-
),
|
|
54
|
-
day: cn(
|
|
55
|
-
buttonVariants({ variant: "ghost" }),
|
|
56
|
-
daySize,
|
|
57
|
-
"flex items-center justify-center",
|
|
58
|
-
"p-0 font-normal aria-selected:opacity-100"
|
|
59
|
-
),
|
|
60
|
-
day_range_start: "day-range-start",
|
|
61
|
-
day_range_end: "day-range-end",
|
|
62
|
-
day_selected:
|
|
63
|
-
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
64
|
-
day_today: "bg-accent text-accent-foreground",
|
|
65
|
-
day_outside:
|
|
66
|
-
"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
|
|
67
|
-
day_disabled: "text-muted-foreground opacity-50",
|
|
68
|
-
day_range_middle:
|
|
69
|
-
"aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
70
|
-
day_hidden: "invisible",
|
|
71
|
-
...classNames,
|
|
72
|
-
}}
|
|
73
|
-
components={{
|
|
74
|
-
IconLeft: ({ className, ...props }: StyledComponent) => (
|
|
75
|
-
<ChevronLeft className={cn("h-4 w-4", className)} {...props} />
|
|
76
|
-
),
|
|
77
|
-
IconRight: ({ className, ...props }: StyledComponent) => (
|
|
78
|
-
<ChevronRight className={cn("h-4 w-4", className)} {...props} />
|
|
79
|
-
),
|
|
80
|
-
}}
|
|
22
|
+
<DatePicker
|
|
23
|
+
className={`${className} ${sizeClass}`}
|
|
24
|
+
calendarIcon={false}
|
|
81
25
|
{...props}
|
|
82
26
|
/>
|
|
83
27
|
)
|
|
@@ -175,14 +175,15 @@ export const DateCombobox = ({
|
|
|
175
175
|
</PopoverTrigger>
|
|
176
176
|
<PopoverContent className="w-auto p-0" align="start">
|
|
177
177
|
<Calendar
|
|
178
|
-
mode="single"
|
|
179
178
|
className="p-0"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
onSelect={(date) => {
|
|
179
|
+
value={selectedDate}
|
|
180
|
+
onChange={(date) => {
|
|
183
181
|
if (date) {
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
const actualDate = Array.isArray(date) ? date[0] : date;
|
|
183
|
+
if (actualDate) {
|
|
184
|
+
setFilterValues([dayjs(actualDate).format("YYYY-MM-DD")]);
|
|
185
|
+
setOpen(false);
|
|
186
|
+
}
|
|
186
187
|
}
|
|
187
188
|
}}
|
|
188
189
|
/>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import DatePicker from "react-date-picker";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../popover";
|
|
4
5
|
import { Filter, FilterGroup } from "./types";
|
|
5
6
|
|
|
7
|
+
type ValuePiece = Date | null;
|
|
8
|
+
type Value = ValuePiece | [ValuePiece, ValuePiece];
|
|
9
|
+
|
|
6
10
|
interface DateFilterProps {
|
|
7
11
|
selectedView: string | null;
|
|
8
12
|
selectedDate: Date | undefined;
|
|
@@ -22,8 +26,11 @@ export default function DateFilter({
|
|
|
22
26
|
handleClose,
|
|
23
27
|
filterGroups,
|
|
24
28
|
}: DateFilterProps) {
|
|
25
|
-
const
|
|
26
|
-
|
|
29
|
+
const [open, setOpen] = useState(true);
|
|
30
|
+
|
|
31
|
+
const handleDateChange = (value: Value) => {
|
|
32
|
+
const date = Array.isArray(value) ? value[0] : value;
|
|
33
|
+
setSelectedDate(date || undefined);
|
|
27
34
|
if (date) {
|
|
28
35
|
const selectedGroup = filterGroups.find(g => g.name === selectedView);
|
|
29
36
|
|
|
@@ -46,19 +53,30 @@ export default function DateFilter({
|
|
|
46
53
|
} as Filter,
|
|
47
54
|
]);
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
56
|
+
setOpen(false);
|
|
57
|
+
handleClose();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
52
60
|
|
|
53
61
|
return (
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
<Popover _open={open} onOpenChange={setOpen}>
|
|
63
|
+
<PopoverTrigger className="w-full p-2 text-left hover:bg-muted/50 rounded-sm">
|
|
64
|
+
<div className="flex gap-1.5 items-center">
|
|
65
|
+
{selectedDate ? (
|
|
66
|
+
dayjs(selectedDate).format("MMM D, YYYY")
|
|
67
|
+
) : (
|
|
68
|
+
<span>Pick a date</span>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
</PopoverTrigger>
|
|
72
|
+
<PopoverContent className="w-auto p-0" align="start">
|
|
73
|
+
<DatePicker
|
|
74
|
+
value={selectedDate}
|
|
75
|
+
onChange={handleDateChange}
|
|
76
|
+
calendarIcon={false}
|
|
77
|
+
className="p-2"
|
|
78
|
+
/>
|
|
79
|
+
</PopoverContent>
|
|
80
|
+
</Popover>
|
|
63
81
|
);
|
|
64
82
|
}
|