@voyantjs/products-ui 0.104.1 → 0.104.2

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.
@@ -4,11 +4,11 @@ import { formatMessage } from "@voyantjs/i18n";
4
4
  import { useProductItineraries } from "@voyantjs/products-react";
5
5
  import { Button, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea, } from "@voyantjs/ui/components";
6
6
  import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyantjs/ui/components/combobox";
7
+ import { DatePicker } from "@voyantjs/ui/components/date-picker";
7
8
  import { Loader2 } from "lucide-react";
8
9
  import { useEffect, useMemo, useRef } from "react";
9
10
  import { useForm } from "react-hook-form";
10
11
  import { z } from "zod/v4";
11
- import { DatePicker } from "./date-picker.js";
12
12
  import { useProductDetailApi, useProductDetailMessages } from "./host.js";
13
13
  import { getTimezoneLabel, TIMEZONE_IDS, TIMEZONE_OPTIONS } from "./timezone-options.js";
14
14
  import { zodResolver } from "./zod-resolver.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/products-ui",
3
- "version": "0.104.1",
3
+ "version": "0.104.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,26 +50,26 @@
50
50
  "react-dom": "^19.0.0",
51
51
  "react-hook-form": "^7.60.0",
52
52
  "zod": "^4.3.6",
53
- "@voyantjs/availability": "0.104.1",
54
- "@voyantjs/availability-react": "0.104.1",
55
- "@voyantjs/catalog-react": "0.104.1",
56
- "@voyantjs/extras-react": "0.104.1",
57
- "@voyantjs/finance": "0.104.1",
58
- "@voyantjs/finance-ui": "0.104.1",
59
- "@voyantjs/markets-react": "0.104.1",
60
- "@voyantjs/pricing-react": "0.104.1",
61
- "@voyantjs/pricing-ui": "0.104.1",
62
- "@voyantjs/products-react": "0.104.1",
63
- "@voyantjs/suppliers-react": "0.104.1",
64
- "@voyantjs/ui": "0.104.1",
65
- "@voyantjs/utils": "0.104.1"
53
+ "@voyantjs/availability": "^0.104.1",
54
+ "@voyantjs/catalog-react": "^0.104.1",
55
+ "@voyantjs/availability-react": "^0.104.1",
56
+ "@voyantjs/finance": "^0.104.2",
57
+ "@voyantjs/finance-ui": "^0.104.2",
58
+ "@voyantjs/markets-react": "^0.104.1",
59
+ "@voyantjs/pricing-react": "^0.104.1",
60
+ "@voyantjs/pricing-ui": "^0.104.1",
61
+ "@voyantjs/products-react": "^0.104.2",
62
+ "@voyantjs/ui": "^0.104.2",
63
+ "@voyantjs/suppliers-react": "^0.104.1",
64
+ "@voyantjs/utils": "^0.104.1",
65
+ "@voyantjs/extras-react": "^0.104.1"
66
66
  },
67
67
  "dependencies": {
68
68
  "date-fns": "^4.1.0",
69
69
  "motion": "^12.38.0",
70
70
  "react-day-picker": "^9.8.0",
71
71
  "sonner": "^2.0.7",
72
- "@voyantjs/i18n": "0.104.1"
72
+ "@voyantjs/i18n": "^0.104.1"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@tanstack/react-query": "^5.100.11",
@@ -82,21 +82,21 @@
82
82
  "typescript": "^6.0.2",
83
83
  "vitest": "^4.1.2",
84
84
  "zod": "^4.3.6",
85
- "@voyantjs/availability": "0.104.1",
86
- "@voyantjs/availability-react": "0.104.1",
87
- "@voyantjs/catalog-react": "0.104.1",
88
- "@voyantjs/extras-react": "0.104.1",
89
- "@voyantjs/finance": "0.104.1",
90
- "@voyantjs/finance-ui": "0.104.1",
91
- "@voyantjs/i18n": "0.104.1",
92
- "@voyantjs/markets-react": "0.104.1",
93
- "@voyantjs/pricing-react": "0.104.1",
94
- "@voyantjs/pricing-ui": "0.104.1",
95
- "@voyantjs/products-react": "0.104.1",
96
- "@voyantjs/suppliers-react": "0.104.1",
97
- "@voyantjs/ui": "0.104.1",
98
- "@voyantjs/utils": "0.104.1",
99
- "@voyantjs/voyant-typescript-config": "0.1.0"
85
+ "@voyantjs/availability": "^0.104.1",
86
+ "@voyantjs/availability-react": "^0.104.1",
87
+ "@voyantjs/extras-react": "^0.104.1",
88
+ "@voyantjs/catalog-react": "^0.104.1",
89
+ "@voyantjs/finance": "^0.104.2",
90
+ "@voyantjs/finance-ui": "^0.104.2",
91
+ "@voyantjs/markets-react": "^0.104.1",
92
+ "@voyantjs/i18n": "^0.104.1",
93
+ "@voyantjs/pricing-react": "^0.104.1",
94
+ "@voyantjs/pricing-ui": "^0.104.1",
95
+ "@voyantjs/products-react": "^0.104.2",
96
+ "@voyantjs/suppliers-react": "^0.104.1",
97
+ "@voyantjs/ui": "^0.104.2",
98
+ "@voyantjs/utils": "^0.104.1",
99
+ "@voyantjs/voyant-typescript-config": "^0.1.0"
100
100
  },
101
101
  "files": [
102
102
  "dist",
@@ -1,44 +0,0 @@
1
- import { Calendar } from "@voyantjs/ui/components/calendar";
2
- import * as React from "react";
3
- type CalendarProps = React.ComponentProps<typeof Calendar>;
4
- type SinglePreset = {
5
- label: string;
6
- value: string | null;
7
- };
8
- type DateRangeValue = {
9
- from: string | null;
10
- to: string | null;
11
- };
12
- type RangePreset = {
13
- label: string;
14
- value: DateRangeValue | null;
15
- };
16
- type SharedProps = Omit<CalendarProps, "mode" | "selected" | "onSelect" | "disabled"> & {
17
- placeholder?: React.ReactNode;
18
- displayFormat?: string;
19
- className?: string;
20
- contentClassName?: string;
21
- clearable?: boolean;
22
- /** Disable the entire picker (prevents opening the popover). */
23
- disabled?: boolean;
24
- /** Per-day disable matcher, forwarded to the underlying Calendar. */
25
- dateDisabled?: CalendarProps["disabled"];
26
- };
27
- type DatePickerProps = SharedProps & {
28
- value?: string | null;
29
- defaultValue?: string | null;
30
- onChange?: (value: string | null) => void;
31
- presets?: SinglePreset[];
32
- };
33
- type DateRangePickerProps = SharedProps & {
34
- value?: DateRangeValue | null;
35
- defaultValue?: DateRangeValue | null;
36
- onChange?: (value: DateRangeValue | null) => void;
37
- presets?: RangePreset[];
38
- };
39
- export declare function DatePicker({ value, defaultValue, onChange, presets, placeholder, // i18n-literal-ok primitive default, overridden by callers
40
- displayFormat, className, contentClassName, clearable, disabled, dateDisabled, ...calendarProps }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
41
- export declare function DateRangePicker({ value, defaultValue, onChange, presets, placeholder, // i18n-literal-ok primitive default, overridden by callers
42
- displayFormat, className, contentClassName, clearable, disabled, dateDisabled, numberOfMonths, ...calendarProps }: DateRangePickerProps): import("react/jsx-runtime").JSX.Element;
43
- export type { DatePickerProps, DateRangePickerProps, DateRangeValue };
44
- //# sourceMappingURL=date-picker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAA;AAO3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,KAAK,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE1D,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CAClB,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,KAAK,WAAW,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC,GAAG;IACtF,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,E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,EAAE,CAAA"}
@@ -1,125 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Button } from "@voyantjs/ui/components/button";
4
- import { Calendar } from "@voyantjs/ui/components/calendar";
5
- import { Popover, PopoverContent, PopoverTrigger } from "@voyantjs/ui/components/popover";
6
- import { Separator } from "@voyantjs/ui/components/separator";
7
- import { cn } from "@voyantjs/ui/lib/utils";
8
- import { format, isValid, parseISO } from "date-fns";
9
- import { CalendarIcon, XIcon } from "lucide-react";
10
- import * as React from "react";
11
- function parseDateValue(value) {
12
- if (!value)
13
- return undefined;
14
- const parsed = parseISO(value);
15
- return isValid(parsed) ? parsed : undefined;
16
- }
17
- function formatDateValue(value) {
18
- return value ? format(value, "yyyy-MM-dd") : null;
19
- }
20
- function hasRangeValue(value) {
21
- return Boolean(value?.from || value?.to);
22
- }
23
- function formatRangeLabel(value, displayFormat, placeholder) {
24
- if (!value?.from && !value?.to)
25
- return placeholder;
26
- const from = parseDateValue(value?.from);
27
- const to = parseDateValue(value?.to);
28
- if (from && to) {
29
- return `${format(from, displayFormat)} - ${format(to, displayFormat)}`;
30
- }
31
- if (from) {
32
- return `${format(from, displayFormat)} -`;
33
- }
34
- if (to) {
35
- return `- ${format(to, displayFormat)}`;
36
- }
37
- return placeholder;
38
- }
39
- function DatePickerTrigger({ className, empty, disabled, children, ...props }) {
40
- return (_jsxs(Button
41
- // Spread base-ui's PopoverTrigger props (onClick, ref, aria/data state)
42
- // first so the popover actually toggles; explicit styling props follow.
43
- , { ...props, variant: "outline", "data-empty": empty, disabled: disabled, className: cn("w-full justify-start text-left font-normal data-[empty=true]:text-muted-foreground", className), children: [_jsx(CalendarIcon, { className: "h-4 w-4" }), _jsx("span", { className: "truncate", children: children })] }));
44
- }
45
- function DatePickerFooter({ clearable, hasValue, onClear }) {
46
- if (!clearable || !hasValue)
47
- return null;
48
- return (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsx("div", { className: "flex justify-end p-2", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: onClear, children: [_jsx(XIcon, { className: "h-4 w-4" }), "Clear"] }) })] }));
49
- }
50
- function SinglePresets({ presets, onSelect }) {
51
- if (presets.length === 0)
52
- return null;
53
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex flex-wrap gap-2 p-3 pb-0", children: presets.map((preset) => (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => onSelect(preset.value), children: preset.label }, preset.label))) }), _jsx("div", { className: "px-3 pt-3", children: _jsx(Separator, {}) })] }));
54
- }
55
- function RangePresets({ presets, onSelect }) {
56
- if (presets.length === 0)
57
- return null;
58
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex flex-wrap gap-2 p-3 pb-0", children: presets.map((preset) => (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => onSelect(preset.value), children: preset.label }, preset.label))) }), _jsx("div", { className: "px-3 pt-3", children: _jsx(Separator, {}) })] }));
59
- }
60
- export function DatePicker({ value, defaultValue, onChange, presets = [], placeholder = "Pick a date", // i18n-literal-ok primitive default, overridden by callers
61
- displayFormat = "PPP", className, contentClassName, clearable = true, disabled, dateDisabled, ...calendarProps }) {
62
- const [open, setOpen] = React.useState(false);
63
- const [internalValue, setInternalValue] = React.useState(defaultValue ?? null);
64
- const isControlled = value !== undefined;
65
- const selectedValue = isControlled ? (value ?? null) : internalValue;
66
- const selectedDate = parseDateValue(selectedValue);
67
- const handleChange = React.useCallback((nextValue) => {
68
- if (!isControlled) {
69
- setInternalValue(nextValue);
70
- }
71
- onChange?.(nextValue);
72
- }, [isControlled, onChange]);
73
- const handleSelect = (nextDate) => {
74
- handleChange(formatDateValue(nextDate));
75
- if (nextDate) {
76
- setOpen(false);
77
- }
78
- };
79
- const label = selectedDate ? format(selectedDate, displayFormat) : placeholder;
80
- return (_jsxs(Popover, { open: disabled ? false : open, onOpenChange: disabled ? undefined : setOpen, children: [_jsx(PopoverTrigger, { render: _jsx(DatePickerTrigger, { className: className, empty: !selectedDate, disabled: disabled }), children: label }), _jsxs(PopoverContent, { align: "start", className: cn("w-auto p-0", contentClassName), children: [_jsx(SinglePresets, { presets: presets, onSelect: (presetValue) => {
81
- handleChange(presetValue);
82
- setOpen(false);
83
- } }), _jsx(Calendar, { mode: "single", selected: selectedDate, onSelect: handleSelect, defaultMonth: selectedDate, disabled: dateDisabled, ...calendarProps }), _jsx(DatePickerFooter, { clearable: clearable, hasValue: Boolean(selectedDate), onClear: () => {
84
- handleChange(null);
85
- setOpen(false);
86
- } })] })] }));
87
- }
88
- export function DateRangePicker({ value, defaultValue, onChange, presets = [], placeholder = "Pick a date range", // i18n-literal-ok primitive default, overridden by callers
89
- displayFormat = "LLL d, y", className, contentClassName, clearable = true, disabled, dateDisabled, numberOfMonths = 2, ...calendarProps }) {
90
- const [open, setOpen] = React.useState(false);
91
- const [internalValue, setInternalValue] = React.useState(defaultValue ?? null);
92
- const isControlled = value !== undefined;
93
- const selectedValue = isControlled ? (value ?? null) : internalValue;
94
- const selectedRange = selectedValue
95
- ? {
96
- from: parseDateValue(selectedValue.from),
97
- to: parseDateValue(selectedValue.to),
98
- }
99
- : undefined;
100
- const handleChange = React.useCallback((nextValue) => {
101
- if (!isControlled) {
102
- setInternalValue(nextValue);
103
- }
104
- onChange?.(nextValue);
105
- }, [isControlled, onChange]);
106
- const handleSelect = (nextRange) => {
107
- const nextValue = nextRange?.from || nextRange?.to
108
- ? {
109
- from: formatDateValue(nextRange.from),
110
- to: formatDateValue(nextRange.to),
111
- }
112
- : null;
113
- handleChange(nextValue);
114
- if (nextRange?.from && nextRange.to) {
115
- setOpen(false);
116
- }
117
- };
118
- return (_jsxs(Popover, { open: disabled ? false : open, onOpenChange: disabled ? undefined : setOpen, children: [_jsx(PopoverTrigger, { render: _jsx(DatePickerTrigger, { className: className, empty: !hasRangeValue(selectedValue), disabled: disabled }), children: formatRangeLabel(selectedValue, displayFormat, placeholder) }), _jsxs(PopoverContent, { align: "start", className: cn("w-auto p-0", contentClassName), children: [_jsx(RangePresets, { presets: presets, onSelect: (presetValue) => {
119
- handleChange(presetValue);
120
- setOpen(false);
121
- } }), _jsx(Calendar, { mode: "range", selected: selectedRange, onSelect: handleSelect, defaultMonth: selectedRange?.from, numberOfMonths: numberOfMonths, disabled: dateDisabled, ...calendarProps }), _jsx(DatePickerFooter, { clearable: clearable, hasValue: hasRangeValue(selectedValue), onClear: () => {
122
- handleChange(null);
123
- setOpen(false);
124
- } })] })] }));
125
- }