@bouku/core 0.4.9 → 0.5.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.
|
@@ -5,9 +5,10 @@ export type DateRange = {
|
|
|
5
5
|
type Props = DateRange & {
|
|
6
6
|
size?: "xs" | "sm";
|
|
7
7
|
min?: string;
|
|
8
|
+
max?: string;
|
|
8
9
|
update: (next: DateRange) => void;
|
|
9
|
-
initial
|
|
10
|
+
initial?: DateRange;
|
|
10
11
|
};
|
|
11
|
-
export declare function DateRangePicker({ from, to, size, min, update, initial }: Props): import("react").JSX.Element;
|
|
12
|
+
export declare function DateRangePicker({ from, to, size, min, max, update, initial }: Props): import("react").JSX.Element;
|
|
12
13
|
export declare const formatDateLabel: (value: string) => string;
|
|
13
14
|
export default DateRangePicker;
|
|
@@ -4,7 +4,7 @@ import { DatePicker } from "./picker.js";
|
|
|
4
4
|
import { Button } from "../button/normal.js";
|
|
5
5
|
import Trash from "../../assets/icons/trash.svg";
|
|
6
6
|
import Calendar from "../../assets/icons/calendar.svg";
|
|
7
|
-
export function DateRangePicker({ from, to, size = "sm", min, update, initial }) {
|
|
7
|
+
export function DateRangePicker({ from, to, size = "sm", min, max, update, initial = { from: "", to: "" } }) {
|
|
8
8
|
const label = from && to
|
|
9
9
|
? `${formatDateLabel(from)} – ${formatDateLabel(to)}`
|
|
10
10
|
: from
|
|
@@ -13,7 +13,7 @@ export function DateRangePicker({ from, to, size = "sm", min, update, initial })
|
|
|
13
13
|
? `Until ${formatDateLabel(to)}`
|
|
14
14
|
: null;
|
|
15
15
|
const Trigger = (_jsx(Button, { size: size, style: "bg-surface-dark border-border-darker", icon: label ? undefined : _jsx(Calendar, {}), children: label ?? "Filter Date" }));
|
|
16
|
-
return (_jsxs(Dropdown, { trigger: Trigger, align: "right", style: "gap-3 min-w-56 p-4", children: [_jsx(DatePicker, { id: "from", label: "From", size: "sm", style: "gap-1", min: min, max: to ||
|
|
16
|
+
return (_jsxs(Dropdown, { trigger: Trigger, align: "right", style: "gap-3 min-w-56 p-4", children: [_jsx(DatePicker, { id: "from", label: "From", size: "sm", style: "gap-1", min: min, max: to || max, value: from, update: v => update({ from: v, to }) }), _jsx(DatePicker, { id: "to", label: "To", size: "sm", style: "gap-1", min: from || min, max: max, value: to, update: v => update({ from, to: v }) }), (from || to) && (_jsx(Button, { size: "xs", style: "mx-auto py-1 px-2 gap-1", variant: "error", icon: _jsx(Trash, {}), action: () => update(initial), children: "Clear" }))] }));
|
|
17
17
|
}
|
|
18
18
|
export const formatDateLabel = (value) => {
|
|
19
19
|
if (!value)
|