@addsign/moje-agenda-shared-lib 2.0.12 → 2.0.13

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.
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  import { cn } from "../../utils/utils.js";
4
4
  import { Button } from "./button.js";
5
5
  import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "./command.js";
6
- import { Popover, PopoverTrigger, PopoverContent } from "./popover.js";
6
+ import { P as Popover, a as PopoverTrigger, b as PopoverContent } from "../../popover-BtPiVBn9.js";
7
7
  import { c as createLucideIcon } from "../../createLucideIcon-KSoQd4Wi.js";
8
8
  import { X } from "../../x-DciOkaU0.js";
9
9
  import { C as Check } from "../../check-B7dJm08z.js";
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { Button } from "./button.js";
3
3
  import { t as toDate, c as constructFrom, s as setMonth, f as format, C as Calendar, i as isValid } from "../../Calendar-DWT4e7Th.js";
4
- import { Popover, PopoverTrigger, PopoverContent } from "./popover.js";
4
+ import { P as Popover, a as PopoverTrigger, b as PopoverContent, c as PopoverClose } from "../../popover-BtPiVBn9.js";
5
5
  import { cn } from "../../utils/utils.js";
6
6
  import React__default, { forwardRef, useEffect } from "react";
7
7
  import { Input } from "./input.js";
@@ -62,14 +62,25 @@ function set(date, values) {
62
62
  return _date;
63
63
  }
64
64
  const DATE_FORMAT = "dd.MM.yyyy HH:mm";
65
+ const roundToNearestHalfHour = (date) => {
66
+ const minutes = date.getMinutes();
67
+ const roundedMinutes = minutes < 15 ? 0 : minutes < 45 ? 30 : 60;
68
+ return set(date, {
69
+ seconds: 0,
70
+ milliseconds: 0,
71
+ minutes: roundedMinutes,
72
+ hours: roundedMinutes === 60 ? date.getHours() + 1 : date.getHours()
73
+ });
74
+ };
65
75
  const DateTimePicker = forwardRef(
66
76
  ({ value, onChange, className, clearable = true, placeholder, ...props }, ref) => {
67
77
  const [dateTime, setDateTime] = React__default.useState(value || null);
68
78
  const [inputValue, setInputValue] = React__default.useState("");
69
79
  useEffect(() => {
70
80
  if (value) {
71
- setDateTime(value);
72
- setInputValue(format(value, DATE_FORMAT));
81
+ const roundedDate = roundToNearestHalfHour(value);
82
+ setDateTime(roundedDate);
83
+ setInputValue(format(roundedDate, DATE_FORMAT));
73
84
  } else {
74
85
  setDateTime(null);
75
86
  setInputValue("");
@@ -124,17 +135,10 @@ const DateTimePicker = forwardRef(
124
135
  };
125
136
  const handleTimeSelect = (time) => {
126
137
  const [hours, minutes] = time.split(":").map(Number);
127
- if (dateTime) {
128
- const newDateTime = set(dateTime, { hours, minutes });
129
- setDateTime(newDateTime);
130
- onChange == null ? void 0 : onChange(newDateTime);
131
- setInputValue(format(newDateTime, DATE_FORMAT));
132
- } else {
133
- const newDateTime = set(/* @__PURE__ */ new Date(), { hours, minutes });
134
- setDateTime(newDateTime);
135
- onChange == null ? void 0 : onChange(newDateTime);
136
- setInputValue(format(newDateTime, DATE_FORMAT));
137
- }
138
+ const newDateTime = set(dateTime ?? /* @__PURE__ */ new Date(), { hours, minutes });
139
+ setDateTime(newDateTime);
140
+ onChange == null ? void 0 : onChange(newDateTime);
141
+ setInputValue(format(newDateTime, DATE_FORMAT));
138
142
  };
139
143
  const handleClear = () => {
140
144
  setInputValue("");
@@ -190,20 +194,23 @@ const DateTimePicker = forwardRef(
190
194
  initialFocus: true
191
195
  }
192
196
  ),
193
- /* @__PURE__ */ jsx("div", { className: "p-3 border-t border-border", children: /* @__PURE__ */ jsxs(
194
- Select,
195
- {
196
- onValueChange: handleTimeSelect,
197
- value: dateTime ? format(dateTime, "HH:mm") : void 0,
198
- children: [
199
- /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select time", children: dateTime ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
200
- /* @__PURE__ */ jsx(Clock, { className: "mr-2 h-4 w-4" }),
201
- format(dateTime, "HH:mm")
202
- ] }) : "Select time" }) }),
203
- /* @__PURE__ */ jsx(SelectContent, { children: timeOptions.map((time) => /* @__PURE__ */ jsx(SelectItem, { value: time, children: time }, time)) })
204
- ]
205
- }
206
- ) })
197
+ /* @__PURE__ */ jsx("div", { className: "p-3 border-t border-border", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
198
+ /* @__PURE__ */ jsxs(
199
+ Select,
200
+ {
201
+ onValueChange: handleTimeSelect,
202
+ value: dateTime ? format(dateTime, "HH:mm") : void 0,
203
+ children: [
204
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select time", children: dateTime ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
205
+ /* @__PURE__ */ jsx(Clock, { className: "mr-2 h-4 w-4" }),
206
+ format(dateTime, "HH:mm")
207
+ ] }) : "Select time" }) }),
208
+ /* @__PURE__ */ jsx(SelectContent, { children: timeOptions.map((time) => /* @__PURE__ */ jsx(SelectItem, { value: time, children: time }, time)) })
209
+ ]
210
+ }
211
+ ),
212
+ /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { className: "ml-2 px-3", children: "OK" }) })
213
+ ] }) })
207
214
  ] })
208
215
  ] });
209
216
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/calendar-clock.js","../../../node_modules/lucide-react/dist/esm/icons/clock.js","../../../node_modules/date-fns/set.mjs","../../../lib/components/ui/DateTimePicker.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst CalendarClock = createLucideIcon(\"CalendarClock\", [\n [\"path\", { d: \"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5\", key: \"1osxxc\" }],\n [\"path\", { d: \"M16 2v4\", key: \"4m81vk\" }],\n [\"path\", { d: \"M8 2v4\", key: \"1cmpym\" }],\n [\"path\", { d: \"M3 10h5\", key: \"r794hk\" }],\n [\"path\", { d: \"M17.5 17.5 16 16.3V14\", key: \"akvzfd\" }],\n [\"circle\", { cx: \"16\", cy: \"16\", r: \"6\", key: \"qoo3c4\" }]\n]);\n\nexport { CalendarClock as default };\n//# sourceMappingURL=calendar-clock.js.map\n","/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Clock = createLucideIcon(\"Clock\", [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"polyline\", { points: \"12 6 12 12 16 14\", key: \"68esgv\" }]\n]);\n\nexport { Clock as default };\n//# sourceMappingURL=clock.js.map\n","import { constructFrom } from \"./constructFrom.mjs\";\nimport { setMonth } from \"./setMonth.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name set\n * @category Common Helpers\n * @summary Set date values to a given date.\n *\n * @description\n * Set date values to a given date.\n *\n * Sets time values to date from object `values`.\n * A value is not set if it is undefined or null or doesn't exist in `values`.\n *\n * Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts\n * to use native `Date#setX` methods. If you use this function, you may not want to include the\n * other `setX` functions that date-fns provides if you are concerned about the bundle size.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The date to be changed\n * @param values - The date values to be set\n *\n * @returns The new date with options set\n *\n * @example\n * // Transform 1 September 2014 into 20 October 2015 in a single line:\n * const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })\n * //=> Tue Oct 20 2015 00:00:00\n *\n * @example\n * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:\n * const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })\n * //=> Mon Sep 01 2014 12:23:45\n */\n\nexport function set(date, values) {\n let _date = toDate(date);\n\n // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date\n if (isNaN(+_date)) {\n return constructFrom(date, NaN);\n }\n\n if (values.year != null) {\n _date.setFullYear(values.year);\n }\n\n if (values.month != null) {\n _date = setMonth(_date, values.month);\n }\n\n if (values.date != null) {\n _date.setDate(values.date);\n }\n\n if (values.hours != null) {\n _date.setHours(values.hours);\n }\n\n if (values.minutes != null) {\n _date.setMinutes(values.minutes);\n }\n\n if (values.seconds != null) {\n _date.setSeconds(values.seconds);\n }\n\n if (values.milliseconds != null) {\n _date.setMilliseconds(values.milliseconds);\n }\n\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default set;\n","import { format, parse, isValid, set } from \"date-fns\";\r\nimport { CalendarClockIcon, Clock, XIcon } from \"lucide-react\";\r\n\r\nimport { Button } from \"./button\";\r\nimport { Calendar } from \"./Calendar\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\r\nimport { cn } from \"../../utils/utils\";\r\nimport React, { forwardRef, useEffect } from \"react\";\r\nimport { Input } from \"./input\";\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from \"./select\";\r\n\r\nconst DATE_FORMAT = \"dd.MM.yyyy HH:mm\";\r\n\r\ninterface DateTimePickerProps {\r\n value?: Date;\r\n onChange?: (date: Date | undefined | null) => void;\r\n className?: string;\r\n placeholder?: string;\r\n clearable?: boolean;\r\n}\r\n\r\nconst DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\r\n (\r\n { value, onChange, className, clearable = true, placeholder, ...props },\r\n ref\r\n ) => {\r\n const [dateTime, setDateTime] = React.useState<Date | null>(value || null);\r\n const [inputValue, setInputValue] = React.useState<string | null>(\"\");\r\n\r\n useEffect(() => {\r\n if (value) {\r\n setDateTime(value);\r\n setInputValue(format(value, DATE_FORMAT));\r\n } else {\r\n setDateTime(null);\r\n setInputValue(\"\");\r\n }\r\n }, [value]);\r\n\r\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n event.stopPropagation(); // Stop bubbling to prevent interference with other components\r\n\r\n setInputValue(event.target.value);\r\n const parsedDateTime = parse(event.target.value, DATE_FORMAT, new Date());\r\n\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleInputBlur = () => {\r\n if (inputValue === \"\") {\r\n setDateTime(null);\r\n onChange?.(null);\r\n return;\r\n }\r\n\r\n const parsedDateTime = parse(inputValue || \"\", DATE_FORMAT, new Date());\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleDateSelect = (selectedDate: Date | undefined | null) => {\r\n if (selectedDate) {\r\n const newDateTime = dateTime\r\n ? set(dateTime, {\r\n year: selectedDate.getFullYear(),\r\n month: selectedDate.getMonth(),\r\n date: selectedDate.getDate(),\r\n })\r\n : set(selectedDate, { hours: 12, minutes: 0 });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n setDateTime(null);\r\n setInputValue(\"\");\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleTimeSelect = (time: string) => {\r\n const [hours, minutes] = time.split(\":\").map(Number);\r\n if (dateTime) {\r\n const newDateTime = set(dateTime, { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n const newDateTime = set(new Date(), { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n }\r\n };\r\n\r\n const handleClear = () => {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n };\r\n\r\n const timeOptions = Array.from({ length: 48 }, (_, i) => {\r\n const hours = Math.floor(i / 2);\r\n const minutes = i % 2 === 0 ? \"00\" : \"30\";\r\n return `${hours.toString().padStart(2, \"0\")}:${minutes}`;\r\n });\r\n\r\n return (\r\n <Popover>\r\n <PopoverTrigger asChild>\r\n <div className={cn(\"relative w-full\", className)}>\r\n <Input\r\n ref={ref}\r\n type=\"text\"\r\n value={inputValue || \"\"}\r\n onChange={handleInputChange}\r\n onBlur={handleInputBlur}\r\n placeholder={placeholder}\r\n className={cn(\r\n \"w-full pl-8 pr-8\",\r\n !dateTime && \"text-muted-foreground\"\r\n )}\r\n {...props}\r\n />\r\n <CalendarClockIcon className=\"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground\" />\r\n {clearable && inputValue && (\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n size=\"icon\"\r\n className=\"absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0\"\r\n onClick={handleClear}\r\n >\r\n <XIcon className=\"h-4 w-4 text-muted-foreground\" />\r\n <span className=\"sr-only\">Smazat datum a čas</span>\r\n </Button>\r\n )}\r\n </div>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\r\n <Calendar\r\n mode=\"single\"\r\n selected={dateTime || undefined}\r\n onSelect={handleDateSelect}\r\n initialFocus\r\n />\r\n <div className=\"p-3 border-t border-border\">\r\n <Select\r\n onValueChange={handleTimeSelect}\r\n value={dateTime ? format(dateTime, \"HH:mm\") : undefined}\r\n >\r\n <SelectTrigger>\r\n <SelectValue placeholder=\"Select time\">\r\n {dateTime ? (\r\n <div className=\"flex items-center\">\r\n <Clock className=\"mr-2 h-4 w-4\" />\r\n {format(dateTime, \"HH:mm\")}\r\n </div>\r\n ) : (\r\n \"Select time\"\r\n )}\r\n </SelectValue>\r\n </SelectTrigger>\r\n <SelectContent>\r\n {timeOptions.map((time) => (\r\n <SelectItem key={time} value={time}>\r\n {time}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </Select>\r\n </div>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n }\r\n);\r\n\r\nDateTimePicker.displayName = \"DateTimePicker\";\r\n\r\nexport default DateTimePicker;\r\n"],"names":["React","CalendarClockIcon","XIcon"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,gBAAgB,iBAAiB,iBAAiB;AAAA,EACtD,CAAC,QAAQ,EAAE,GAAG,gEAAgE,KAAK,SAAQ,CAAE;AAAA,EAC7F,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,UAAU,KAAK,SAAQ,CAAE;AAAA,EACvC,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,yBAAyB,KAAK,SAAQ,CAAE;AAAA,EACtD,CAAC,UAAU,EAAE,IAAI,MAAM,IAAI,MAAM,GAAG,KAAK,KAAK,UAAU;AAC1D,CAAC;AChBD;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,QAAQ,iBAAiB,SAAS;AAAA,EACtC,CAAC,UAAU,EAAE,IAAI,MAAM,IAAI,MAAM,GAAG,MAAM,KAAK,UAAU;AAAA,EACzD,CAAC,YAAY,EAAE,QAAQ,oBAAoB,KAAK,SAAQ,CAAE;AAC5D,CAAC;ACyBM,SAAS,IAAI,MAAM,QAAQ;AAChC,MAAI,QAAQ,OAAO,IAAI;AAGvB,MAAI,MAAM,CAAC,KAAK,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AA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,UAAU,YAAY;AAAA,YACtB,UAAU;AAAA,YACV,cAAY;AAAA,UAAA;AAAA,QACd;AAAA,QACA,oBAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAe;AAAA,YACf,OAAO,WAAW,OAAO,UAAU,OAAO,IAAI;AAAA,YAE9C,UAAA;AAAA,cAAC,oBAAA,eAAA,EACC,8BAAC,aAAY,EAAA,aAAY,eACtB,UACC,WAAA,qBAAC,OAAI,EAAA,WAAU,qBACb,UAAA;AAAA,gBAAC,oBAAA,OAAA,EAAM,WAAU,eAAe,CAAA;AAAA,gBAC/B,OAAO,UAAU,OAAO;AAAA,cAAA,GAC3B,IAEA,cAEJ,CAAA,GACF;AAAA,cACC,oBAAA,eAAA,EACE,UAAY,YAAA,IAAI,CAAC,SACf,oBAAA,YAAA,EAAsB,OAAO,MAC3B,UADc,KAAA,GAAA,IAEjB,CACD,GACH;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,MAAA,GACF;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"DateTimePicker.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/calendar-clock.js","../../../node_modules/lucide-react/dist/esm/icons/clock.js","../../../node_modules/date-fns/set.mjs","../../../lib/components/ui/DateTimePicker.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst CalendarClock = createLucideIcon(\"CalendarClock\", [\n [\"path\", { d: \"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5\", key: \"1osxxc\" }],\n [\"path\", { d: \"M16 2v4\", key: \"4m81vk\" }],\n [\"path\", { d: \"M8 2v4\", key: \"1cmpym\" }],\n [\"path\", { d: \"M3 10h5\", key: \"r794hk\" }],\n [\"path\", { d: \"M17.5 17.5 16 16.3V14\", key: \"akvzfd\" }],\n [\"circle\", { cx: \"16\", cy: \"16\", r: \"6\", key: \"qoo3c4\" }]\n]);\n\nexport { CalendarClock as default };\n//# sourceMappingURL=calendar-clock.js.map\n","/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Clock = createLucideIcon(\"Clock\", [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"polyline\", { points: \"12 6 12 12 16 14\", key: \"68esgv\" }]\n]);\n\nexport { Clock as default };\n//# sourceMappingURL=clock.js.map\n","import { constructFrom } from \"./constructFrom.mjs\";\nimport { setMonth } from \"./setMonth.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name set\n * @category Common Helpers\n * @summary Set date values to a given date.\n *\n * @description\n * Set date values to a given date.\n *\n * Sets time values to date from object `values`.\n * A value is not set if it is undefined or null or doesn't exist in `values`.\n *\n * Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts\n * to use native `Date#setX` methods. If you use this function, you may not want to include the\n * other `setX` functions that date-fns provides if you are concerned about the bundle size.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The date to be changed\n * @param values - The date values to be set\n *\n * @returns The new date with options set\n *\n * @example\n * // Transform 1 September 2014 into 20 October 2015 in a single line:\n * const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })\n * //=> Tue Oct 20 2015 00:00:00\n *\n * @example\n * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:\n * const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })\n * //=> Mon Sep 01 2014 12:23:45\n */\n\nexport function set(date, values) {\n let _date = toDate(date);\n\n // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date\n if (isNaN(+_date)) {\n return constructFrom(date, NaN);\n }\n\n if (values.year != null) {\n _date.setFullYear(values.year);\n }\n\n if (values.month != null) {\n _date = setMonth(_date, values.month);\n }\n\n if (values.date != null) {\n _date.setDate(values.date);\n }\n\n if (values.hours != null) {\n _date.setHours(values.hours);\n }\n\n if (values.minutes != null) {\n _date.setMinutes(values.minutes);\n }\n\n if (values.seconds != null) {\n _date.setSeconds(values.seconds);\n }\n\n if (values.milliseconds != null) {\n _date.setMilliseconds(values.milliseconds);\n }\n\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default set;\n","import { format, parse, isValid, set } from \"date-fns\";\r\nimport { CalendarClockIcon, Clock, XIcon } from \"lucide-react\";\r\n\r\nimport { Button } from \"./button\";\r\nimport { Calendar } from \"./Calendar\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\r\nimport { cn } from \"../../utils/utils\";\r\nimport React, { forwardRef, useEffect } from \"react\";\r\nimport { Input } from \"./input\";\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from \"./select\";\r\nimport { PopoverClose } from \"@radix-ui/react-popover\";\r\n\r\nconst DATE_FORMAT = \"dd.MM.yyyy HH:mm\";\r\n\r\ninterface DateTimePickerProps {\r\n value?: Date;\r\n onChange?: (date: Date | undefined | null) => void;\r\n className?: string;\r\n placeholder?: string;\r\n clearable?: boolean;\r\n}\r\n\r\n// Helper function to round to the nearest half-hour\r\nconst roundToNearestHalfHour = (date: Date) => {\r\n const minutes = date.getMinutes();\r\n const roundedMinutes = minutes < 15 ? 0 : minutes < 45 ? 30 : 60;\r\n return set(date, {\r\n seconds: 0,\r\n milliseconds: 0,\r\n minutes: roundedMinutes,\r\n hours: roundedMinutes === 60 ? date.getHours() + 1 : date.getHours(),\r\n });\r\n};\r\n\r\nconst DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\r\n (\r\n { value, onChange, className, clearable = true, placeholder, ...props },\r\n ref\r\n ) => {\r\n const [dateTime, setDateTime] = React.useState<Date | null>(value || null);\r\n const [inputValue, setInputValue] = React.useState<string | null>(\"\");\r\n\r\n useEffect(() => {\r\n if (value) {\r\n const roundedDate = roundToNearestHalfHour(value);\r\n setDateTime(roundedDate);\r\n setInputValue(format(roundedDate, DATE_FORMAT));\r\n } else {\r\n setDateTime(null);\r\n setInputValue(\"\");\r\n }\r\n }, [value]);\r\n\r\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n event.stopPropagation(); // Stop bubbling to prevent interference with other components\r\n\r\n setInputValue(event.target.value);\r\n const parsedDateTime = parse(event.target.value, DATE_FORMAT, new Date());\r\n\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleInputBlur = () => {\r\n if (inputValue === \"\") {\r\n setDateTime(null);\r\n onChange?.(null);\r\n return;\r\n }\r\n\r\n const parsedDateTime = parse(inputValue || \"\", DATE_FORMAT, new Date());\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleDateSelect = (selectedDate: Date | undefined | null) => {\r\n if (selectedDate) {\r\n const newDateTime = dateTime\r\n ? set(dateTime, {\r\n year: selectedDate.getFullYear(),\r\n month: selectedDate.getMonth(),\r\n date: selectedDate.getDate(),\r\n })\r\n : set(selectedDate, { hours: 12, minutes: 0 });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n setDateTime(null);\r\n setInputValue(\"\");\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleTimeSelect = (time: string) => {\r\n const [hours, minutes] = time.split(\":\").map(Number);\r\n\r\n const newDateTime = set(dateTime ?? new Date(), { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n };\r\n\r\n const handleClear = () => {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n };\r\n\r\n const timeOptions = Array.from({ length: 48 }, (_, i) => {\r\n const hours = Math.floor(i / 2);\r\n const minutes = i % 2 === 0 ? \"00\" : \"30\";\r\n return `${hours.toString().padStart(2, \"0\")}:${minutes}`;\r\n });\r\n\r\n return (\r\n <Popover>\r\n <PopoverTrigger asChild>\r\n <div className={cn(\"relative w-full\", className)}>\r\n <Input\r\n ref={ref}\r\n type=\"text\"\r\n value={inputValue || \"\"}\r\n onChange={handleInputChange}\r\n onBlur={handleInputBlur}\r\n placeholder={placeholder}\r\n className={cn(\r\n \"w-full pl-8 pr-8\",\r\n !dateTime && \"text-muted-foreground\"\r\n )}\r\n {...props}\r\n />\r\n <CalendarClockIcon className=\"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground\" />\r\n {clearable && inputValue && (\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n size=\"icon\"\r\n className=\"absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0\"\r\n onClick={handleClear}\r\n >\r\n <XIcon className=\"h-4 w-4 text-muted-foreground\" />\r\n <span className=\"sr-only\">Smazat datum a čas</span>\r\n </Button>\r\n )}\r\n </div>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\r\n <Calendar\r\n mode=\"single\"\r\n selected={dateTime || undefined}\r\n onSelect={handleDateSelect}\r\n initialFocus\r\n />\r\n <div className=\"p-3 border-t border-border\">\r\n <div className=\"flex items-center justify-between\">\r\n <Select\r\n onValueChange={handleTimeSelect}\r\n value={dateTime ? format(dateTime, \"HH:mm\") : undefined}\r\n >\r\n <SelectTrigger>\r\n <SelectValue placeholder=\"Select time\">\r\n {dateTime ? (\r\n <div className=\"flex items-center\">\r\n <Clock className=\"mr-2 h-4 w-4\" />\r\n {format(dateTime, \"HH:mm\")}\r\n </div>\r\n ) : (\r\n \"Select time\"\r\n )}\r\n </SelectValue>\r\n </SelectTrigger>\r\n <SelectContent>\r\n {timeOptions.map((time) => (\r\n <SelectItem key={time} value={time}>\r\n {time}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </Select>\r\n <PopoverClose asChild>\r\n <Button className=\"ml-2 px-3\">OK</Button>\r\n </PopoverClose>\r\n </div>\r\n </div>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n }\r\n);\r\n\r\nDateTimePicker.displayName = \"DateTimePicker\";\r\n\r\nexport default DateTimePicker;\r\n"],"names":["React","CalendarClockIcon","XIcon"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,gBAAgB,iBAAiB,iBAAiB;AAAA,EACtD,CAAC,QAAQ,EAAE,GAAG,gEAAgE,KAAK,SAAQ,CAAE;AAAA,EAC7F,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,UAAU,KAAK,SAAQ,CAAE;AAAA,EACvC,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,yBAAyB,KAAK,SAAQ,CAAE;AAAA,EACtD,CAAC,UAAU,EAAE,IAAI,MAAM,IAAI,MAAM,GAAG,KAAK,KAAK,UAAU;AAC1D,CAAC;AChBD;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,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aAAY,UAAA,KAAA,CAAE,EAClC,CAAA;AAAA,QAAA,EAAA,CACF,EACF,CAAA;AAAA,MAAA,GACF;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","x_google_ignoreList":[0,1,2]}
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { Button } from "./button.js";
3
3
  import { f as format, C as Calendar$1, i as isValid } from "../../Calendar-DWT4e7Th.js";
4
- import { Popover, PopoverTrigger, PopoverContent } from "./popover.js";
4
+ import { P as Popover, a as PopoverTrigger, b as PopoverContent } from "../../popover-BtPiVBn9.js";
5
5
  import { cn } from "../../utils/utils.js";
6
6
  import React__default, { forwardRef, useEffect } from "react";
7
7
  import { Input } from "./input.js";
@@ -1,318 +1,10 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { c as createContextScope, b as composeEventHandlers } from "../../index-CDCkSjVs.js";
4
- import { u as useComposedRefs, S as Slot } from "../../index-D9mvqz1C.js";
5
- import { D as DismissableLayer } from "../../index-CEVipgcd.js";
6
- import { h as hideOthers, R as ReactRemoveScroll, u as useFocusGuards, F as FocusScope } from "../../index-g4PMBWfd.js";
7
- import { u as useId } from "../../index-Deoi9R3y.js";
8
- import { c as createPopperScope, A as Anchor, C as Content, a as Arrow, R as Root2$1 } from "../../index-kx4d2yA2.js";
9
- import { P as Portal$1 } from "../../index-cAAySw6z.js";
10
- import { P as Presence } from "../../index-CA2QNu6z.js";
11
- import { P as Primitive } from "../../index-BkUJPEGE.js";
12
- import { u as useControllableState } from "../../index-DFSwSCB0.js";
13
- import { cn } from "../../utils/utils.js";
14
- var POPOVER_NAME = "Popover";
15
- var [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [
16
- createPopperScope
17
- ]);
18
- var usePopperScope = createPopperScope();
19
- var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
20
- var Popover$1 = (props) => {
21
- const {
22
- __scopePopover,
23
- children,
24
- open: openProp,
25
- defaultOpen,
26
- onOpenChange,
27
- modal = false
28
- } = props;
29
- const popperScope = usePopperScope(__scopePopover);
30
- const triggerRef = React.useRef(null);
31
- const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
32
- const [open = false, setOpen] = useControllableState({
33
- prop: openProp,
34
- defaultProp: defaultOpen,
35
- onChange: onOpenChange
36
- });
37
- return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
38
- PopoverProvider,
39
- {
40
- scope: __scopePopover,
41
- contentId: useId(),
42
- triggerRef,
43
- open,
44
- onOpenChange: setOpen,
45
- onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
46
- hasCustomAnchor,
47
- onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
48
- onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
49
- modal,
50
- children
51
- }
52
- ) });
53
- };
54
- Popover$1.displayName = POPOVER_NAME;
55
- var ANCHOR_NAME = "PopoverAnchor";
56
- var PopoverAnchor = React.forwardRef(
57
- (props, forwardedRef) => {
58
- const { __scopePopover, ...anchorProps } = props;
59
- const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
60
- const popperScope = usePopperScope(__scopePopover);
61
- const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
62
- React.useEffect(() => {
63
- onCustomAnchorAdd();
64
- return () => onCustomAnchorRemove();
65
- }, [onCustomAnchorAdd, onCustomAnchorRemove]);
66
- return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
67
- }
68
- );
69
- PopoverAnchor.displayName = ANCHOR_NAME;
70
- var TRIGGER_NAME = "PopoverTrigger";
71
- var PopoverTrigger$1 = React.forwardRef(
72
- (props, forwardedRef) => {
73
- const { __scopePopover, ...triggerProps } = props;
74
- const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
75
- const popperScope = usePopperScope(__scopePopover);
76
- const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
77
- const trigger = /* @__PURE__ */ jsx(
78
- Primitive.button,
79
- {
80
- type: "button",
81
- "aria-haspopup": "dialog",
82
- "aria-expanded": context.open,
83
- "aria-controls": context.contentId,
84
- "data-state": getState(context.open),
85
- ...triggerProps,
86
- ref: composedTriggerRef,
87
- onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
88
- }
89
- );
90
- return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: trigger });
91
- }
92
- );
93
- PopoverTrigger$1.displayName = TRIGGER_NAME;
94
- var PORTAL_NAME = "PopoverPortal";
95
- var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
96
- forceMount: void 0
97
- });
98
- var PopoverPortal = (props) => {
99
- const { __scopePopover, forceMount, children, container } = props;
100
- const context = usePopoverContext(PORTAL_NAME, __scopePopover);
101
- return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
102
- };
103
- PopoverPortal.displayName = PORTAL_NAME;
104
- var CONTENT_NAME = "PopoverContent";
105
- var PopoverContent$1 = React.forwardRef(
106
- (props, forwardedRef) => {
107
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
108
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
109
- const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
110
- return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
111
- }
112
- );
113
- PopoverContent$1.displayName = CONTENT_NAME;
114
- var PopoverContentModal = React.forwardRef(
115
- (props, forwardedRef) => {
116
- const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
117
- const contentRef = React.useRef(null);
118
- const composedRefs = useComposedRefs(forwardedRef, contentRef);
119
- const isRightClickOutsideRef = React.useRef(false);
120
- React.useEffect(() => {
121
- const content = contentRef.current;
122
- if (content)
123
- return hideOthers(content);
124
- }, []);
125
- return /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
126
- PopoverContentImpl,
127
- {
128
- ...props,
129
- ref: composedRefs,
130
- trapFocus: context.open,
131
- disableOutsidePointerEvents: true,
132
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
133
- var _a;
134
- event.preventDefault();
135
- if (!isRightClickOutsideRef.current)
136
- (_a = context.triggerRef.current) == null ? void 0 : _a.focus();
137
- }),
138
- onPointerDownOutside: composeEventHandlers(
139
- props.onPointerDownOutside,
140
- (event) => {
141
- const originalEvent = event.detail.originalEvent;
142
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
143
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
144
- isRightClickOutsideRef.current = isRightClick;
145
- },
146
- { checkForDefaultPrevented: false }
147
- ),
148
- onFocusOutside: composeEventHandlers(
149
- props.onFocusOutside,
150
- (event) => event.preventDefault(),
151
- { checkForDefaultPrevented: false }
152
- )
153
- }
154
- ) });
155
- }
156
- );
157
- var PopoverContentNonModal = React.forwardRef(
158
- (props, forwardedRef) => {
159
- const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
160
- const hasInteractedOutsideRef = React.useRef(false);
161
- const hasPointerDownOutsideRef = React.useRef(false);
162
- return /* @__PURE__ */ jsx(
163
- PopoverContentImpl,
164
- {
165
- ...props,
166
- ref: forwardedRef,
167
- trapFocus: false,
168
- disableOutsidePointerEvents: false,
169
- onCloseAutoFocus: (event) => {
170
- var _a, _b;
171
- (_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
172
- if (!event.defaultPrevented) {
173
- if (!hasInteractedOutsideRef.current)
174
- (_b = context.triggerRef.current) == null ? void 0 : _b.focus();
175
- event.preventDefault();
176
- }
177
- hasInteractedOutsideRef.current = false;
178
- hasPointerDownOutsideRef.current = false;
179
- },
180
- onInteractOutside: (event) => {
181
- var _a, _b;
182
- (_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
183
- if (!event.defaultPrevented) {
184
- hasInteractedOutsideRef.current = true;
185
- if (event.detail.originalEvent.type === "pointerdown") {
186
- hasPointerDownOutsideRef.current = true;
187
- }
188
- }
189
- const target = event.target;
190
- const targetIsTrigger = (_b = context.triggerRef.current) == null ? void 0 : _b.contains(target);
191
- if (targetIsTrigger)
192
- event.preventDefault();
193
- if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
194
- event.preventDefault();
195
- }
196
- }
197
- }
198
- );
199
- }
200
- );
201
- var PopoverContentImpl = React.forwardRef(
202
- (props, forwardedRef) => {
203
- const {
204
- __scopePopover,
205
- trapFocus,
206
- onOpenAutoFocus,
207
- onCloseAutoFocus,
208
- disableOutsidePointerEvents,
209
- onEscapeKeyDown,
210
- onPointerDownOutside,
211
- onFocusOutside,
212
- onInteractOutside,
213
- ...contentProps
214
- } = props;
215
- const context = usePopoverContext(CONTENT_NAME, __scopePopover);
216
- const popperScope = usePopperScope(__scopePopover);
217
- useFocusGuards();
218
- return /* @__PURE__ */ jsx(
219
- FocusScope,
220
- {
221
- asChild: true,
222
- loop: true,
223
- trapped: trapFocus,
224
- onMountAutoFocus: onOpenAutoFocus,
225
- onUnmountAutoFocus: onCloseAutoFocus,
226
- children: /* @__PURE__ */ jsx(
227
- DismissableLayer,
228
- {
229
- asChild: true,
230
- disableOutsidePointerEvents,
231
- onInteractOutside,
232
- onEscapeKeyDown,
233
- onPointerDownOutside,
234
- onFocusOutside,
235
- onDismiss: () => context.onOpenChange(false),
236
- children: /* @__PURE__ */ jsx(
237
- Content,
238
- {
239
- "data-state": getState(context.open),
240
- role: "dialog",
241
- id: context.contentId,
242
- ...popperScope,
243
- ...contentProps,
244
- ref: forwardedRef,
245
- style: {
246
- ...contentProps.style,
247
- // re-namespace exposed content custom properties
248
- ...{
249
- "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
250
- "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
251
- "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
252
- "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
253
- "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
254
- }
255
- }
256
- }
257
- )
258
- }
259
- )
260
- }
261
- );
262
- }
263
- );
264
- var CLOSE_NAME = "PopoverClose";
265
- var PopoverClose = React.forwardRef(
266
- (props, forwardedRef) => {
267
- const { __scopePopover, ...closeProps } = props;
268
- const context = usePopoverContext(CLOSE_NAME, __scopePopover);
269
- return /* @__PURE__ */ jsx(
270
- Primitive.button,
271
- {
272
- type: "button",
273
- ...closeProps,
274
- ref: forwardedRef,
275
- onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
276
- }
277
- );
278
- }
279
- );
280
- PopoverClose.displayName = CLOSE_NAME;
281
- var ARROW_NAME = "PopoverArrow";
282
- var PopoverArrow = React.forwardRef(
283
- (props, forwardedRef) => {
284
- const { __scopePopover, ...arrowProps } = props;
285
- const popperScope = usePopperScope(__scopePopover);
286
- return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
287
- }
288
- );
289
- PopoverArrow.displayName = ARROW_NAME;
290
- function getState(open) {
291
- return open ? "open" : "closed";
292
- }
293
- var Root2 = Popover$1;
294
- var Trigger = PopoverTrigger$1;
295
- var Portal = PopoverPortal;
296
- var Content2 = PopoverContent$1;
297
- const Popover = Root2;
298
- const PopoverTrigger = Trigger;
299
- const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
300
- Content2,
301
- {
302
- ref,
303
- align,
304
- sideOffset,
305
- className: cn(
306
- "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
307
- className
308
- ),
309
- ...props
310
- }
311
- ) }));
312
- PopoverContent.displayName = Content2.displayName;
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import { P, b, a } from "../../popover-BtPiVBn9.js";
4
+ import "../../utils/utils.js";
313
5
  export {
314
- Popover,
315
- PopoverContent,
316
- PopoverTrigger
6
+ P as Popover,
7
+ b as PopoverContent,
8
+ a as PopoverTrigger
317
9
  };
318
10
  //# sourceMappingURL=popover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","sources":["../../../node_modules/@radix-ui/react-popover/dist/index.mjs","../../../lib/components/ui/popover.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/popover/src/Popover.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { DismissableLayer } from \"@radix-ui/react-dismissable-layer\";\nimport { useFocusGuards } from \"@radix-ui/react-focus-guards\";\nimport { FocusScope } from \"@radix-ui/react-focus-scope\";\nimport { useId } from \"@radix-ui/react-id\";\nimport * as PopperPrimitive from \"@radix-ui/react-popper\";\nimport { createPopperScope } from \"@radix-ui/react-popper\";\nimport { Portal as PortalPrimitive } from \"@radix-ui/react-portal\";\nimport { Presence } from \"@radix-ui/react-presence\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { hideOthers } from \"aria-hidden\";\nimport { RemoveScroll } from \"react-remove-scroll\";\nimport { jsx } from \"react/jsx-runtime\";\nvar POPOVER_NAME = \"Popover\";\nvar [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope\n]);\nvar usePopperScope = createPopperScope();\nvar [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);\nvar Popover = (props) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange\n });\n return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(\n PopoverProvider,\n {\n scope: __scopePopover,\n contentId: useId(),\n triggerRef,\n open,\n onOpenChange: setOpen,\n onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),\n hasCustomAnchor,\n onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),\n onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),\n modal,\n children\n }\n ) });\n};\nPopover.displayName = POPOVER_NAME;\nvar ANCHOR_NAME = \"PopoverAnchor\";\nvar PopoverAnchor = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });\n }\n);\nPopoverAnchor.displayName = ANCHOR_NAME;\nvar TRIGGER_NAME = \"PopoverTrigger\";\nvar PopoverTrigger = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n const trigger = /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": context.open,\n \"aria-controls\": context.contentId,\n \"data-state\": getState(context.open),\n ...triggerProps,\n ref: composedTriggerRef,\n onClick: composeEventHandlers(props.onClick, context.onOpenToggle)\n }\n );\n return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });\n }\n);\nPopoverTrigger.displayName = TRIGGER_NAME;\nvar PORTAL_NAME = \"PopoverPortal\";\nvar [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {\n forceMount: void 0\n});\nvar PopoverPortal = (props) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(PortalPrimitive, { asChild: true, container, children }) }) });\n};\nPopoverPortal.displayName = PORTAL_NAME;\nvar CONTENT_NAME = \"PopoverContent\";\nvar PopoverContent = React.forwardRef(\n (props, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });\n }\n);\nPopoverContent.displayName = CONTENT_NAME;\nvar PopoverContentModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n return /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: composedRefs,\n trapFocus: context.open,\n disableOutsidePointerEvents: true,\n onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n }),\n onPointerDownOutside: composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false }\n ),\n onFocusOutside: composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false }\n )\n }\n ) });\n }\n);\nvar PopoverContentNonModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n return /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: forwardedRef,\n trapFocus: false,\n disableOutsidePointerEvents: false,\n onCloseAutoFocus: (event) => {\n props.onCloseAutoFocus?.(event);\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n event.preventDefault();\n }\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n },\n onInteractOutside: (event) => {\n props.onInteractOutside?.(event);\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === \"pointerdown\") {\n hasPointerDownOutsideRef.current = true;\n }\n }\n const target = event.target;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n if (event.detail.originalEvent.type === \"focusin\" && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }\n }\n );\n }\n);\nvar PopoverContentImpl = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n useFocusGuards();\n return /* @__PURE__ */ jsx(\n FocusScope,\n {\n asChild: true,\n loop: true,\n trapped: trapFocus,\n onMountAutoFocus: onOpenAutoFocus,\n onUnmountAutoFocus: onCloseAutoFocus,\n children: /* @__PURE__ */ jsx(\n DismissableLayer,\n {\n asChild: true,\n disableOutsidePointerEvents,\n onInteractOutside,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onDismiss: () => context.onOpenChange(false),\n children: /* @__PURE__ */ jsx(\n PopperPrimitive.Content,\n {\n \"data-state\": getState(context.open),\n role: \"dialog\",\n id: context.contentId,\n ...popperScope,\n ...contentProps,\n ref: forwardedRef,\n style: {\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n \"--radix-popover-content-transform-origin\": \"var(--radix-popper-transform-origin)\",\n \"--radix-popover-content-available-width\": \"var(--radix-popper-available-width)\",\n \"--radix-popover-content-available-height\": \"var(--radix-popper-available-height)\",\n \"--radix-popover-trigger-width\": \"var(--radix-popper-anchor-width)\",\n \"--radix-popover-trigger-height\": \"var(--radix-popper-anchor-height)\"\n }\n }\n }\n )\n }\n )\n }\n );\n }\n);\nvar CLOSE_NAME = \"PopoverClose\";\nvar PopoverClose = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n ...closeProps,\n ref: forwardedRef,\n onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))\n }\n );\n }\n);\nPopoverClose.displayName = CLOSE_NAME;\nvar ARROW_NAME = \"PopoverArrow\";\nvar PopoverArrow = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });\n }\n);\nPopoverArrow.displayName = ARROW_NAME;\nfunction getState(open) {\n return open ? \"open\" : \"closed\";\n}\nvar Root2 = Popover;\nvar Anchor2 = PopoverAnchor;\nvar Trigger = PopoverTrigger;\nvar Portal = PopoverPortal;\nvar Content2 = PopoverContent;\nvar Close = PopoverClose;\nvar Arrow2 = PopoverArrow;\nexport {\n Anchor2 as Anchor,\n Arrow2 as Arrow,\n Close,\n Content2 as Content,\n Popover,\n PopoverAnchor,\n PopoverArrow,\n PopoverClose,\n PopoverContent,\n PopoverPortal,\n PopoverTrigger,\n Portal,\n Root2 as Root,\n Trigger,\n createPopoverScope\n};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\r\n\r\nimport { cn } from \"../../utils/utils\";\r\n\r\nconst Popover = PopoverPrimitive.Root;\r\n\r\nconst PopoverTrigger = PopoverPrimitive.Trigger;\r\n\r\nconst PopoverContent = React.forwardRef<\r\n React.ElementRef<typeof PopoverPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\r\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\r\n <PopoverPrimitive.Portal>\r\n <PopoverPrimitive.Content\r\n ref={ref}\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n </PopoverPrimitive.Portal>\r\n));\r\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\r\n\r\nexport { Popover, PopoverTrigger, PopoverContent };\r\n"],"names":["Popover","PopperPrimitive.Root","PopperPrimitive.Anchor","PopoverTrigger","PortalPrimitive","PopoverContent","RemoveScroll","PopperPrimitive.Content","PopperPrimitive.Arrow","PopoverPrimitive.Root","PopoverPrimitive.Trigger","PopoverPrimitive.Portal","PopoverPrimitive.Content"],"mappings":";;;;;;;;;;;;;AAqBA,IAAI,eAAe;AACnB,IAAI,CAAC,sBAAsB,kBAAkB,IAAI,mBAAmB,cAAc;AAAA,EAChF;AACF,CAAC;AACD,IAAI,iBAAiB,kBAAiB;AACtC,IAAI,CAAC,iBAAiB,iBAAiB,IAAI,qBAAqB,YAAY;AAC5E,IAAIA,YAAU,CAAC,UAAU;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,EACT,IAAG;AACJ,QAAM,cAAc,eAAe,cAAc;AACjD,QAAM,aAAa,MAAM,OAAO,IAAI;AACpC,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,MAAM,SAAS,KAAK;AAClE,QAAM,CAAC,OAAO,OAAO,OAAO,IAAI,qBAAqB;AAAA,IACnD,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EACd,CAAG;AACD,SAAuB,oBAAIC,SAA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Y,CAAE;AAAA,EACvG;AACH;AACA,aAAa,cAAc;AAC3B,SAAS,SAAS,MAAM;AACtB,SAAO,OAAO,SAAS;AACzB;AACA,IAAI,QAAQR;AAEZ,IAAI,UAAUG;AACd,IAAI,SAAS;AACb,IAAI,WAAWE;AClSf,MAAM,UAAUI;AAEhB,MAAM,iBAAiBC;AAEvB,MAAM,iBAAiB,MAAM,WAG3B,CAAC,EAAE,WAAW,QAAQ,UAAU,aAAa,GAAG,GAAG,MAAM,GAAG,QAC3D,oBAAAC,QAAA,EACC,UAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA,EAAA;AACN,EAAA,CACF,CACD;AACD,eAAe,cAAcA,SAAyB;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"popover.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,319 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { c as createContextScope, b as composeEventHandlers } from "./index-CDCkSjVs.js";
4
+ import { u as useComposedRefs, S as Slot } from "./index-D9mvqz1C.js";
5
+ import { D as DismissableLayer } from "./index-CEVipgcd.js";
6
+ import { h as hideOthers, R as ReactRemoveScroll, u as useFocusGuards, F as FocusScope } from "./index-g4PMBWfd.js";
7
+ import { u as useId } from "./index-Deoi9R3y.js";
8
+ import { c as createPopperScope, A as Anchor, C as Content, a as Arrow, R as Root2$1 } from "./index-kx4d2yA2.js";
9
+ import { P as Portal$1 } from "./index-cAAySw6z.js";
10
+ import { P as Presence } from "./index-CA2QNu6z.js";
11
+ import { P as Primitive } from "./index-BkUJPEGE.js";
12
+ import { u as useControllableState } from "./index-DFSwSCB0.js";
13
+ import { cn } from "./utils/utils.js";
14
+ var POPOVER_NAME = "Popover";
15
+ var [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [
16
+ createPopperScope
17
+ ]);
18
+ var usePopperScope = createPopperScope();
19
+ var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
20
+ var Popover$1 = (props) => {
21
+ const {
22
+ __scopePopover,
23
+ children,
24
+ open: openProp,
25
+ defaultOpen,
26
+ onOpenChange,
27
+ modal = false
28
+ } = props;
29
+ const popperScope = usePopperScope(__scopePopover);
30
+ const triggerRef = React.useRef(null);
31
+ const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
32
+ const [open = false, setOpen] = useControllableState({
33
+ prop: openProp,
34
+ defaultProp: defaultOpen,
35
+ onChange: onOpenChange
36
+ });
37
+ return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
38
+ PopoverProvider,
39
+ {
40
+ scope: __scopePopover,
41
+ contentId: useId(),
42
+ triggerRef,
43
+ open,
44
+ onOpenChange: setOpen,
45
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
46
+ hasCustomAnchor,
47
+ onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
48
+ onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),
49
+ modal,
50
+ children
51
+ }
52
+ ) });
53
+ };
54
+ Popover$1.displayName = POPOVER_NAME;
55
+ var ANCHOR_NAME = "PopoverAnchor";
56
+ var PopoverAnchor = React.forwardRef(
57
+ (props, forwardedRef) => {
58
+ const { __scopePopover, ...anchorProps } = props;
59
+ const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
60
+ const popperScope = usePopperScope(__scopePopover);
61
+ const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
62
+ React.useEffect(() => {
63
+ onCustomAnchorAdd();
64
+ return () => onCustomAnchorRemove();
65
+ }, [onCustomAnchorAdd, onCustomAnchorRemove]);
66
+ return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
67
+ }
68
+ );
69
+ PopoverAnchor.displayName = ANCHOR_NAME;
70
+ var TRIGGER_NAME = "PopoverTrigger";
71
+ var PopoverTrigger$1 = React.forwardRef(
72
+ (props, forwardedRef) => {
73
+ const { __scopePopover, ...triggerProps } = props;
74
+ const context = usePopoverContext(TRIGGER_NAME, __scopePopover);
75
+ const popperScope = usePopperScope(__scopePopover);
76
+ const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
77
+ const trigger = /* @__PURE__ */ jsx(
78
+ Primitive.button,
79
+ {
80
+ type: "button",
81
+ "aria-haspopup": "dialog",
82
+ "aria-expanded": context.open,
83
+ "aria-controls": context.contentId,
84
+ "data-state": getState(context.open),
85
+ ...triggerProps,
86
+ ref: composedTriggerRef,
87
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
88
+ }
89
+ );
90
+ return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: trigger });
91
+ }
92
+ );
93
+ PopoverTrigger$1.displayName = TRIGGER_NAME;
94
+ var PORTAL_NAME = "PopoverPortal";
95
+ var [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {
96
+ forceMount: void 0
97
+ });
98
+ var PopoverPortal = (props) => {
99
+ const { __scopePopover, forceMount, children, container } = props;
100
+ const context = usePopoverContext(PORTAL_NAME, __scopePopover);
101
+ return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
102
+ };
103
+ PopoverPortal.displayName = PORTAL_NAME;
104
+ var CONTENT_NAME = "PopoverContent";
105
+ var PopoverContent$1 = React.forwardRef(
106
+ (props, forwardedRef) => {
107
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
108
+ const { forceMount = portalContext.forceMount, ...contentProps } = props;
109
+ const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
110
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });
111
+ }
112
+ );
113
+ PopoverContent$1.displayName = CONTENT_NAME;
114
+ var PopoverContentModal = React.forwardRef(
115
+ (props, forwardedRef) => {
116
+ const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
117
+ const contentRef = React.useRef(null);
118
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
119
+ const isRightClickOutsideRef = React.useRef(false);
120
+ React.useEffect(() => {
121
+ const content = contentRef.current;
122
+ if (content)
123
+ return hideOthers(content);
124
+ }, []);
125
+ return /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(
126
+ PopoverContentImpl,
127
+ {
128
+ ...props,
129
+ ref: composedRefs,
130
+ trapFocus: context.open,
131
+ disableOutsidePointerEvents: true,
132
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
133
+ var _a;
134
+ event.preventDefault();
135
+ if (!isRightClickOutsideRef.current)
136
+ (_a = context.triggerRef.current) == null ? void 0 : _a.focus();
137
+ }),
138
+ onPointerDownOutside: composeEventHandlers(
139
+ props.onPointerDownOutside,
140
+ (event) => {
141
+ const originalEvent = event.detail.originalEvent;
142
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
143
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
144
+ isRightClickOutsideRef.current = isRightClick;
145
+ },
146
+ { checkForDefaultPrevented: false }
147
+ ),
148
+ onFocusOutside: composeEventHandlers(
149
+ props.onFocusOutside,
150
+ (event) => event.preventDefault(),
151
+ { checkForDefaultPrevented: false }
152
+ )
153
+ }
154
+ ) });
155
+ }
156
+ );
157
+ var PopoverContentNonModal = React.forwardRef(
158
+ (props, forwardedRef) => {
159
+ const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
160
+ const hasInteractedOutsideRef = React.useRef(false);
161
+ const hasPointerDownOutsideRef = React.useRef(false);
162
+ return /* @__PURE__ */ jsx(
163
+ PopoverContentImpl,
164
+ {
165
+ ...props,
166
+ ref: forwardedRef,
167
+ trapFocus: false,
168
+ disableOutsidePointerEvents: false,
169
+ onCloseAutoFocus: (event) => {
170
+ var _a, _b;
171
+ (_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
172
+ if (!event.defaultPrevented) {
173
+ if (!hasInteractedOutsideRef.current)
174
+ (_b = context.triggerRef.current) == null ? void 0 : _b.focus();
175
+ event.preventDefault();
176
+ }
177
+ hasInteractedOutsideRef.current = false;
178
+ hasPointerDownOutsideRef.current = false;
179
+ },
180
+ onInteractOutside: (event) => {
181
+ var _a, _b;
182
+ (_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
183
+ if (!event.defaultPrevented) {
184
+ hasInteractedOutsideRef.current = true;
185
+ if (event.detail.originalEvent.type === "pointerdown") {
186
+ hasPointerDownOutsideRef.current = true;
187
+ }
188
+ }
189
+ const target = event.target;
190
+ const targetIsTrigger = (_b = context.triggerRef.current) == null ? void 0 : _b.contains(target);
191
+ if (targetIsTrigger)
192
+ event.preventDefault();
193
+ if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
194
+ event.preventDefault();
195
+ }
196
+ }
197
+ }
198
+ );
199
+ }
200
+ );
201
+ var PopoverContentImpl = React.forwardRef(
202
+ (props, forwardedRef) => {
203
+ const {
204
+ __scopePopover,
205
+ trapFocus,
206
+ onOpenAutoFocus,
207
+ onCloseAutoFocus,
208
+ disableOutsidePointerEvents,
209
+ onEscapeKeyDown,
210
+ onPointerDownOutside,
211
+ onFocusOutside,
212
+ onInteractOutside,
213
+ ...contentProps
214
+ } = props;
215
+ const context = usePopoverContext(CONTENT_NAME, __scopePopover);
216
+ const popperScope = usePopperScope(__scopePopover);
217
+ useFocusGuards();
218
+ return /* @__PURE__ */ jsx(
219
+ FocusScope,
220
+ {
221
+ asChild: true,
222
+ loop: true,
223
+ trapped: trapFocus,
224
+ onMountAutoFocus: onOpenAutoFocus,
225
+ onUnmountAutoFocus: onCloseAutoFocus,
226
+ children: /* @__PURE__ */ jsx(
227
+ DismissableLayer,
228
+ {
229
+ asChild: true,
230
+ disableOutsidePointerEvents,
231
+ onInteractOutside,
232
+ onEscapeKeyDown,
233
+ onPointerDownOutside,
234
+ onFocusOutside,
235
+ onDismiss: () => context.onOpenChange(false),
236
+ children: /* @__PURE__ */ jsx(
237
+ Content,
238
+ {
239
+ "data-state": getState(context.open),
240
+ role: "dialog",
241
+ id: context.contentId,
242
+ ...popperScope,
243
+ ...contentProps,
244
+ ref: forwardedRef,
245
+ style: {
246
+ ...contentProps.style,
247
+ // re-namespace exposed content custom properties
248
+ ...{
249
+ "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
250
+ "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
251
+ "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
252
+ "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
253
+ "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
254
+ }
255
+ }
256
+ }
257
+ )
258
+ }
259
+ )
260
+ }
261
+ );
262
+ }
263
+ );
264
+ var CLOSE_NAME = "PopoverClose";
265
+ var PopoverClose = React.forwardRef(
266
+ (props, forwardedRef) => {
267
+ const { __scopePopover, ...closeProps } = props;
268
+ const context = usePopoverContext(CLOSE_NAME, __scopePopover);
269
+ return /* @__PURE__ */ jsx(
270
+ Primitive.button,
271
+ {
272
+ type: "button",
273
+ ...closeProps,
274
+ ref: forwardedRef,
275
+ onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
276
+ }
277
+ );
278
+ }
279
+ );
280
+ PopoverClose.displayName = CLOSE_NAME;
281
+ var ARROW_NAME = "PopoverArrow";
282
+ var PopoverArrow = React.forwardRef(
283
+ (props, forwardedRef) => {
284
+ const { __scopePopover, ...arrowProps } = props;
285
+ const popperScope = usePopperScope(__scopePopover);
286
+ return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
287
+ }
288
+ );
289
+ PopoverArrow.displayName = ARROW_NAME;
290
+ function getState(open) {
291
+ return open ? "open" : "closed";
292
+ }
293
+ var Root2 = Popover$1;
294
+ var Trigger = PopoverTrigger$1;
295
+ var Portal = PopoverPortal;
296
+ var Content2 = PopoverContent$1;
297
+ const Popover = Root2;
298
+ const PopoverTrigger = Trigger;
299
+ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
300
+ Content2,
301
+ {
302
+ ref,
303
+ align,
304
+ sideOffset,
305
+ className: cn(
306
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
307
+ className
308
+ ),
309
+ ...props
310
+ }
311
+ ) }));
312
+ PopoverContent.displayName = Content2.displayName;
313
+ export {
314
+ Popover as P,
315
+ PopoverTrigger as a,
316
+ PopoverContent as b,
317
+ PopoverClose as c
318
+ };
319
+ //# sourceMappingURL=popover-BtPiVBn9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-BtPiVBn9.js","sources":["../node_modules/@radix-ui/react-popover/dist/index.mjs","../lib/components/ui/popover.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/popover/src/Popover.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { DismissableLayer } from \"@radix-ui/react-dismissable-layer\";\nimport { useFocusGuards } from \"@radix-ui/react-focus-guards\";\nimport { FocusScope } from \"@radix-ui/react-focus-scope\";\nimport { useId } from \"@radix-ui/react-id\";\nimport * as PopperPrimitive from \"@radix-ui/react-popper\";\nimport { createPopperScope } from \"@radix-ui/react-popper\";\nimport { Portal as PortalPrimitive } from \"@radix-ui/react-portal\";\nimport { Presence } from \"@radix-ui/react-presence\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { hideOthers } from \"aria-hidden\";\nimport { RemoveScroll } from \"react-remove-scroll\";\nimport { jsx } from \"react/jsx-runtime\";\nvar POPOVER_NAME = \"Popover\";\nvar [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope\n]);\nvar usePopperScope = createPopperScope();\nvar [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);\nvar Popover = (props) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange\n });\n return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(\n PopoverProvider,\n {\n scope: __scopePopover,\n contentId: useId(),\n triggerRef,\n open,\n onOpenChange: setOpen,\n onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),\n hasCustomAnchor,\n onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),\n onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),\n modal,\n children\n }\n ) });\n};\nPopover.displayName = POPOVER_NAME;\nvar ANCHOR_NAME = \"PopoverAnchor\";\nvar PopoverAnchor = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });\n }\n);\nPopoverAnchor.displayName = ANCHOR_NAME;\nvar TRIGGER_NAME = \"PopoverTrigger\";\nvar PopoverTrigger = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n const trigger = /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": context.open,\n \"aria-controls\": context.contentId,\n \"data-state\": getState(context.open),\n ...triggerProps,\n ref: composedTriggerRef,\n onClick: composeEventHandlers(props.onClick, context.onOpenToggle)\n }\n );\n return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });\n }\n);\nPopoverTrigger.displayName = TRIGGER_NAME;\nvar PORTAL_NAME = \"PopoverPortal\";\nvar [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {\n forceMount: void 0\n});\nvar PopoverPortal = (props) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(PortalPrimitive, { asChild: true, container, children }) }) });\n};\nPopoverPortal.displayName = PORTAL_NAME;\nvar CONTENT_NAME = \"PopoverContent\";\nvar PopoverContent = React.forwardRef(\n (props, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });\n }\n);\nPopoverContent.displayName = CONTENT_NAME;\nvar PopoverContentModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n return /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: composedRefs,\n trapFocus: context.open,\n disableOutsidePointerEvents: true,\n onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n }),\n onPointerDownOutside: composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false }\n ),\n onFocusOutside: composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false }\n )\n }\n ) });\n }\n);\nvar PopoverContentNonModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n return /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: forwardedRef,\n trapFocus: false,\n disableOutsidePointerEvents: false,\n onCloseAutoFocus: (event) => {\n props.onCloseAutoFocus?.(event);\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n event.preventDefault();\n }\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n },\n onInteractOutside: (event) => {\n props.onInteractOutside?.(event);\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === \"pointerdown\") {\n hasPointerDownOutsideRef.current = true;\n }\n }\n const target = event.target;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n if (event.detail.originalEvent.type === \"focusin\" && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }\n }\n );\n }\n);\nvar PopoverContentImpl = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n useFocusGuards();\n return /* @__PURE__ */ jsx(\n FocusScope,\n {\n asChild: true,\n loop: true,\n trapped: trapFocus,\n onMountAutoFocus: onOpenAutoFocus,\n onUnmountAutoFocus: onCloseAutoFocus,\n children: /* @__PURE__ */ jsx(\n DismissableLayer,\n {\n asChild: true,\n disableOutsidePointerEvents,\n onInteractOutside,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onDismiss: () => context.onOpenChange(false),\n children: /* @__PURE__ */ jsx(\n PopperPrimitive.Content,\n {\n \"data-state\": getState(context.open),\n role: \"dialog\",\n id: context.contentId,\n ...popperScope,\n ...contentProps,\n ref: forwardedRef,\n style: {\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n \"--radix-popover-content-transform-origin\": \"var(--radix-popper-transform-origin)\",\n \"--radix-popover-content-available-width\": \"var(--radix-popper-available-width)\",\n \"--radix-popover-content-available-height\": \"var(--radix-popper-available-height)\",\n \"--radix-popover-trigger-width\": \"var(--radix-popper-anchor-width)\",\n \"--radix-popover-trigger-height\": \"var(--radix-popper-anchor-height)\"\n }\n }\n }\n )\n }\n )\n }\n );\n }\n);\nvar CLOSE_NAME = \"PopoverClose\";\nvar PopoverClose = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n ...closeProps,\n ref: forwardedRef,\n onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))\n }\n );\n }\n);\nPopoverClose.displayName = CLOSE_NAME;\nvar ARROW_NAME = \"PopoverArrow\";\nvar PopoverArrow = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });\n }\n);\nPopoverArrow.displayName = ARROW_NAME;\nfunction getState(open) {\n return open ? \"open\" : \"closed\";\n}\nvar Root2 = Popover;\nvar Anchor2 = PopoverAnchor;\nvar Trigger = PopoverTrigger;\nvar Portal = PopoverPortal;\nvar Content2 = PopoverContent;\nvar Close = PopoverClose;\nvar Arrow2 = PopoverArrow;\nexport {\n Anchor2 as Anchor,\n Arrow2 as Arrow,\n Close,\n Content2 as Content,\n Popover,\n PopoverAnchor,\n PopoverArrow,\n PopoverClose,\n PopoverContent,\n PopoverPortal,\n PopoverTrigger,\n Portal,\n Root2 as Root,\n Trigger,\n createPopoverScope\n};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\r\n\r\nimport { cn } from \"../../utils/utils\";\r\n\r\nconst Popover = PopoverPrimitive.Root;\r\n\r\nconst PopoverTrigger = PopoverPrimitive.Trigger;\r\n\r\nconst PopoverContent = React.forwardRef<\r\n React.ElementRef<typeof PopoverPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\r\n>(({ className, align = \"center\", sideOffset = 4, ...props }, ref) => (\r\n <PopoverPrimitive.Portal>\r\n <PopoverPrimitive.Content\r\n ref={ref}\r\n align={align}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n \"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\r\n className\r\n )}\r\n {...props}\r\n />\r\n </PopoverPrimitive.Portal>\r\n));\r\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\r\n\r\nexport { Popover, PopoverTrigger, PopoverContent };\r\n"],"names":["Popover","PopperPrimitive.Root","PopperPrimitive.Anchor","PopoverTrigger","PortalPrimitive","PopoverContent","RemoveScroll","PopperPrimitive.Content","PopperPrimitive.Arrow","PopoverPrimitive.Root","PopoverPrimitive.Trigger","PopoverPrimitive.Portal","PopoverPrimitive.Content"],"mappings":";;;;;;;;;;;;;AAqBA,IAAI,eAAe;AACnB,IAAI,CAAC,sBAAsB,kBAAkB,IAAI,mBAAmB,cAAc;AAAA,EAChF;AACF,CAAC;AACD,IAAI,iBAAiB,kBAAiB;AACtC,IAAI,CAAC,iBAAiB,iBAAiB,IAAI,qBAAqB,YAAY;AAC5E,IAAIA,YAAU,C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,MAAM;AAAA,QACN,GAAG;AAAA,QACH,KAAK;AAAA,QACL,SAAS,qBAAqB,MAAM,SAAS,MAAM,QAAQ,aAAa,KAAK,CAAC;AAAA,MAC/E;AAAA,IACP;AAAA,EACG;AACH;AACA,aAAa,cAAc;AAC3B,IAAI,aAAa;AACjB,IAAI,eAAe,MAAM;AAAA,EACvB,CAAC,OAAO,iBAAiB;AACvB,UAAM,EAAE,gBAAgB,GAAG,WAAU,IAAK;AAC1C,UAAM,cAAc,eAAe,cAAc;AACjD,WAAuB,oBAAIC,OAAuB,EAAE,GAAG,aAAa,GAAG,YAAY,KAAK,aAAY,CAAE;AAAA,EACvG;AACH;AACA,aAAa,cAAc;AAC3B,SAAS,SAAS,MAAM;AACtB,SAAO,OAAO,SAAS;AACzB;AACA,IAAI,QAAQR;AAEZ,IAAI,UAAUG;AACd,IAAI,SAAS;AACb,IAAI,WAAWE;AClSf,MAAM,UAAUI;AAEhB,MAAM,iBAAiBC;AAEvB,MAAM,iBAAiB,MAAM,WAG3B,CAAC,EAAE,WAAW,QAAQ,UAAU,aAAa,GAAG,GAAG,MAAM,GAAG,QAC3D,oBAAAC,QAAA,EACC,UAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,IACC,GAAG;AAAA,EAAA;AACN,EAAA,CACF,CACD;AACD,eAAe,cAAcA,SAAyB;","x_google_ignoreList":[0]}
@@ -14,6 +14,7 @@ import {
14
14
  SelectTrigger,
15
15
  SelectValue,
16
16
  } from "./select";
17
+ import { PopoverClose } from "@radix-ui/react-popover";
17
18
 
18
19
  const DATE_FORMAT = "dd.MM.yyyy HH:mm";
19
20
 
@@ -25,6 +26,18 @@ interface DateTimePickerProps {
25
26
  clearable?: boolean;
26
27
  }
27
28
 
29
+ // Helper function to round to the nearest half-hour
30
+ const roundToNearestHalfHour = (date: Date) => {
31
+ const minutes = date.getMinutes();
32
+ const roundedMinutes = minutes < 15 ? 0 : minutes < 45 ? 30 : 60;
33
+ return set(date, {
34
+ seconds: 0,
35
+ milliseconds: 0,
36
+ minutes: roundedMinutes,
37
+ hours: roundedMinutes === 60 ? date.getHours() + 1 : date.getHours(),
38
+ });
39
+ };
40
+
28
41
  const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
29
42
  (
30
43
  { value, onChange, className, clearable = true, placeholder, ...props },
@@ -35,8 +48,9 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
35
48
 
36
49
  useEffect(() => {
37
50
  if (value) {
38
- setDateTime(value);
39
- setInputValue(format(value, DATE_FORMAT));
51
+ const roundedDate = roundToNearestHalfHour(value);
52
+ setDateTime(roundedDate);
53
+ setInputValue(format(roundedDate, DATE_FORMAT));
40
54
  } else {
41
55
  setDateTime(null);
42
56
  setInputValue("");
@@ -100,17 +114,11 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
100
114
 
101
115
  const handleTimeSelect = (time: string) => {
102
116
  const [hours, minutes] = time.split(":").map(Number);
103
- if (dateTime) {
104
- const newDateTime = set(dateTime, { hours, minutes });
105
- setDateTime(newDateTime);
106
- onChange?.(newDateTime);
107
- setInputValue(format(newDateTime, DATE_FORMAT));
108
- } else {
109
- const newDateTime = set(new Date(), { hours, minutes });
110
- setDateTime(newDateTime);
111
- onChange?.(newDateTime);
112
- setInputValue(format(newDateTime, DATE_FORMAT));
113
- }
117
+
118
+ const newDateTime = set(dateTime ?? new Date(), { hours, minutes });
119
+ setDateTime(newDateTime);
120
+ onChange?.(newDateTime);
121
+ setInputValue(format(newDateTime, DATE_FORMAT));
114
122
  };
115
123
 
116
124
  const handleClear = () => {
@@ -165,30 +173,35 @@ const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(
165
173
  initialFocus
166
174
  />
167
175
  <div className="p-3 border-t border-border">
168
- <Select
169
- onValueChange={handleTimeSelect}
170
- value={dateTime ? format(dateTime, "HH:mm") : undefined}
171
- >
172
- <SelectTrigger>
173
- <SelectValue placeholder="Select time">
174
- {dateTime ? (
175
- <div className="flex items-center">
176
- <Clock className="mr-2 h-4 w-4" />
177
- {format(dateTime, "HH:mm")}
178
- </div>
179
- ) : (
180
- "Select time"
181
- )}
182
- </SelectValue>
183
- </SelectTrigger>
184
- <SelectContent>
185
- {timeOptions.map((time) => (
186
- <SelectItem key={time} value={time}>
187
- {time}
188
- </SelectItem>
189
- ))}
190
- </SelectContent>
191
- </Select>
176
+ <div className="flex items-center justify-between">
177
+ <Select
178
+ onValueChange={handleTimeSelect}
179
+ value={dateTime ? format(dateTime, "HH:mm") : undefined}
180
+ >
181
+ <SelectTrigger>
182
+ <SelectValue placeholder="Select time">
183
+ {dateTime ? (
184
+ <div className="flex items-center">
185
+ <Clock className="mr-2 h-4 w-4" />
186
+ {format(dateTime, "HH:mm")}
187
+ </div>
188
+ ) : (
189
+ "Select time"
190
+ )}
191
+ </SelectValue>
192
+ </SelectTrigger>
193
+ <SelectContent>
194
+ {timeOptions.map((time) => (
195
+ <SelectItem key={time} value={time}>
196
+ {time}
197
+ </SelectItem>
198
+ ))}
199
+ </SelectContent>
200
+ </Select>
201
+ <PopoverClose asChild>
202
+ <Button className="ml-2 px-3">OK</Button>
203
+ </PopoverClose>
204
+ </div>
192
205
  </div>
193
206
  </PopoverContent>
194
207
  </Popover>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@addsign/moje-agenda-shared-lib",
3
3
  "private": false,
4
- "version": "2.0.12",
4
+ "version": "2.0.13",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",