@webiny/admin-ui 6.5.0-beta.5 → 6.5.0-beta.7
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.
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import react, { useState } from "react";
|
|
2
|
-
import { format } from "date-fns";
|
|
3
2
|
import { UTC_TIMEZONES } from "@webiny/utils";
|
|
4
3
|
import { Calendar } from "../../Calendar/index.js";
|
|
5
4
|
import { PopoverPrimitive } from "../../Popover/index.js";
|
|
6
5
|
import { SelectPrimitive } from "../../Select/index.js";
|
|
7
|
-
import { extractTimezone, formatDateForDisplay, formatTimeValue, getLocalTimezone, parseTimeValue } from "../utils/dateHelpers.js";
|
|
8
|
-
import {
|
|
6
|
+
import { extractTimezone, formatDateForDisplay, formatTimeValue, getLocalTimezone, parseTimeValue, toIsoWithTz } from "../utils/dateHelpers.js";
|
|
7
|
+
import { parseToDate, utcToTimezoneDate } from "../utils/timezoneHelpers.js";
|
|
9
8
|
import { DatePickerTrigger } from "./components/DatePickerTrigger.js";
|
|
10
9
|
import { TimePicker } from "./components/TimePicker.js";
|
|
11
10
|
const timezoneOptions = UTC_TIMEZONES.map((tz)=>({
|
|
@@ -15,18 +14,19 @@ const timezoneOptions = UTC_TIMEZONES.map((tz)=>({
|
|
|
15
14
|
const DateTimePicker = ({ value, onChange, placeholder, disabled, size, variant, invalid, weekStartsOn, onOpenChange, className, withTimezone, displayFormat, minDate, maxDate })=>{
|
|
16
15
|
const [open, setOpen] = useState(false);
|
|
17
16
|
const existingTz = withTimezone && value ? extractTimezone(value) : void 0;
|
|
18
|
-
const [
|
|
17
|
+
const [selectedTimezone, setSelectedTimezone] = useState(getLocalTimezone());
|
|
18
|
+
const timezone = existingTz || selectedTimezone;
|
|
19
19
|
const handleOpenChange = (isOpen)=>{
|
|
20
20
|
setOpen(isOpen);
|
|
21
21
|
if (onOpenChange) onOpenChange(isOpen);
|
|
22
22
|
};
|
|
23
23
|
const currentDate = parseToDate(value);
|
|
24
24
|
const displayDate = withTimezone && currentDate ? utcToTimezoneDate(currentDate, timezone) : currentDate;
|
|
25
|
-
const displayValue = withTimezone ? displayDate ? formatDateForDisplay(
|
|
25
|
+
const displayValue = withTimezone ? displayDate ? formatDateForDisplay(toIsoWithTz(displayDate, timezone), "dateTimeTz", displayFormat) : void 0 : formatDateForDisplay(value, "dateTimeLocal", displayFormat);
|
|
26
26
|
const timeValue = displayDate ? formatTimeValue(displayDate) : "";
|
|
27
27
|
const emitChange = (date, tz)=>{
|
|
28
28
|
if (!onChange) return;
|
|
29
|
-
withTimezone ? onChange(
|
|
29
|
+
withTimezone ? onChange(toIsoWithTz(date, tz || timezone)) : onChange(date.toISOString());
|
|
30
30
|
};
|
|
31
31
|
const handleDateSelect = (date)=>{
|
|
32
32
|
if (!date) return;
|
|
@@ -42,7 +42,8 @@ const DateTimePicker = ({ value, onChange, placeholder, disabled, size, variant,
|
|
|
42
42
|
emitChange(base);
|
|
43
43
|
};
|
|
44
44
|
const handleTimezoneChange = (tz)=>{
|
|
45
|
-
|
|
45
|
+
setSelectedTimezone(tz);
|
|
46
|
+
if (displayDate) emitChange(displayDate, tz);
|
|
46
47
|
};
|
|
47
48
|
return /*#__PURE__*/ react.createElement("div", {
|
|
48
49
|
className: className
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker/primitives/DateTimePicker.js","sources":["../../../src/DatePicker/primitives/DateTimePicker.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"DatePicker/primitives/DateTimePicker.js","sources":["../../../src/DatePicker/primitives/DateTimePicker.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { UTC_TIMEZONES } from \"@webiny/utils\";\nimport { Calendar } from \"~/Calendar/index.js\";\nimport { PopoverPrimitive } from \"~/Popover/index.js\";\nimport { SelectPrimitive } from \"~/Select/index.js\";\nimport type { DateTimeLocalPickerProps, DateTimeTzPickerProps } from \"../utils/types.js\";\nimport {\n extractTimezone,\n formatDateForDisplay,\n formatTimeValue,\n getLocalTimezone,\n parseTimeValue,\n toIsoWithTz\n} from \"../utils/dateHelpers.js\";\nimport { parseToDate, utcToTimezoneDate } from \"../utils/timezoneHelpers.js\";\nimport { DatePickerTrigger } from \"./components/DatePickerTrigger.js\";\nimport { TimePicker } from \"./components/TimePicker.js\";\n\ntype DateTimePickerInternalProps = (DateTimeLocalPickerProps | DateTimeTzPickerProps) & {\n withTimezone: boolean;\n};\n\nconst timezoneOptions = UTC_TIMEZONES.map(tz => ({ value: tz.value, label: tz.label }));\n\nconst DateTimePicker = ({\n value,\n onChange,\n placeholder,\n disabled,\n size,\n variant,\n invalid,\n weekStartsOn,\n onOpenChange,\n className,\n withTimezone,\n displayFormat,\n minDate,\n maxDate\n}: DateTimePickerInternalProps) => {\n const [open, setOpen] = useState(false);\n\n const existingTz = withTimezone && value ? extractTimezone(value) : undefined;\n const [selectedTimezone, setSelectedTimezone] = useState(getLocalTimezone());\n // The value carries its own offset; the selected one applies only until a value exists.\n const timezone = existingTz || selectedTimezone;\n\n const handleOpenChange = (isOpen: boolean) => {\n setOpen(isOpen);\n if (onOpenChange) {\n onOpenChange(isOpen);\n }\n };\n\n const currentDate = parseToDate(value);\n\n const displayDate =\n withTimezone && currentDate ? utcToTimezoneDate(currentDate, timezone) : currentDate;\n\n const displayValue = withTimezone\n ? displayDate\n ? formatDateForDisplay(toIsoWithTz(displayDate, timezone), \"dateTimeTz\", displayFormat)\n : undefined\n : formatDateForDisplay(value, \"dateTimeLocal\", displayFormat);\n\n const timeValue = displayDate ? formatTimeValue(displayDate) : \"\";\n\n const emitChange = (date: Date, tz?: string) => {\n if (!onChange) {\n return;\n }\n if (withTimezone) {\n // Wall time of `date` is the time in the selected timezone: \"2026-05-01T14:30:00+02:00\".\n onChange(toIsoWithTz(date, tz || timezone));\n } else {\n // Absolute instant: \"2026-05-01T12:30:00.000Z\".\n onChange(date.toISOString());\n }\n };\n\n const handleDateSelect = (date: Date | undefined) => {\n if (!date) {\n return;\n }\n if (displayDate) {\n date.setHours(displayDate.getHours(), displayDate.getMinutes());\n }\n emitChange(date);\n };\n\n const handleTimeChange = (time: string | undefined) => {\n if (!time) {\n return;\n }\n const parsed = parseTimeValue(time);\n if (!parsed) {\n return;\n }\n const base = displayDate ? new Date(displayDate) : new Date();\n base.setHours(parsed.hours, parsed.minutes, 0, 0);\n emitChange(base);\n };\n\n const handleTimezoneChange = (tz: string) => {\n setSelectedTimezone(tz);\n // Keep the picked wall time, re-label it with the new offset.\n if (displayDate) {\n emitChange(displayDate, tz);\n }\n };\n\n return (\n <div className={className}>\n <PopoverPrimitive open={open} onOpenChange={handleOpenChange}>\n <DatePickerTrigger\n displayValue={displayValue}\n placeholder={placeholder ?? \"Pick date & time\"}\n disabled={disabled}\n size={size}\n variant={variant}\n invalid={invalid}\n />\n <PopoverPrimitive.Content align=\"start\">\n <div className=\"flex flex-col gap-sm\">\n <Calendar\n mode=\"single\"\n selected={displayDate}\n onSelect={handleDateSelect}\n weekStartsOn={weekStartsOn}\n disabled={[\n ...(minDate ? [{ before: minDate }] : []),\n ...(maxDate ? [{ after: maxDate }] : [])\n ]}\n />\n <div className=\"flex gap-sm px-md pb-md\">\n <div className=\"flex-1\">\n <TimePicker\n value={timeValue}\n onChange={handleTimeChange}\n disabled={disabled}\n size=\"md\"\n />\n </div>\n {withTimezone && (\n <div className=\"flex-1\">\n <SelectPrimitive\n value={timezone}\n onChange={handleTimezoneChange}\n options={timezoneOptions}\n disabled={disabled}\n size=\"md\"\n />\n </div>\n )}\n </div>\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive>\n </div>\n );\n};\n\nexport { DateTimePicker };\n"],"names":["timezoneOptions","UTC_TIMEZONES","tz","DateTimePicker","value","onChange","placeholder","disabled","size","variant","invalid","weekStartsOn","onOpenChange","className","withTimezone","displayFormat","minDate","maxDate","open","setOpen","useState","existingTz","extractTimezone","undefined","selectedTimezone","setSelectedTimezone","getLocalTimezone","timezone","handleOpenChange","isOpen","currentDate","parseToDate","displayDate","utcToTimezoneDate","displayValue","formatDateForDisplay","toIsoWithTz","timeValue","formatTimeValue","emitChange","date","handleDateSelect","handleTimeChange","time","parsed","parseTimeValue","base","Date","handleTimezoneChange","PopoverPrimitive","DatePickerTrigger","Calendar","TimePicker","SelectPrimitive"],"mappings":";;;;;;;;;AAsBA,MAAMA,kBAAkBC,cAAc,GAAG,CAACC,CAAAA,KAAO;QAAE,OAAOA,GAAG,KAAK;QAAE,OAAOA,GAAG,KAAK;IAAC;AAEpF,MAAMC,iBAAiB,CAAC,EACpBC,KAAK,EACLC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,IAAI,EACJC,OAAO,EACPC,OAAO,EACPC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,YAAY,EACZC,aAAa,EACbC,OAAO,EACPC,OAAO,EACmB;IAC1B,MAAM,CAACC,MAAMC,QAAQ,GAAGC,SAAS;IAEjC,MAAMC,aAAaP,gBAAgBV,QAAQkB,gBAAgBlB,SAASmB;IACpE,MAAM,CAACC,kBAAkBC,oBAAoB,GAAGL,SAASM;IAEzD,MAAMC,WAAWN,cAAcG;IAE/B,MAAMI,mBAAmB,CAACC;QACtBV,QAAQU;QACR,IAAIjB,cACAA,aAAaiB;IAErB;IAEA,MAAMC,cAAcC,YAAY3B;IAEhC,MAAM4B,cACFlB,gBAAgBgB,cAAcG,kBAAkBH,aAAaH,YAAYG;IAE7E,MAAMI,eAAepB,eACfkB,cACIG,qBAAqBC,YAAYJ,aAAaL,WAAW,cAAcZ,iBACvEQ,SACJY,qBAAqB/B,OAAO,iBAAiBW;IAEnD,MAAMsB,YAAYL,cAAcM,gBAAgBN,eAAe;IAE/D,MAAMO,aAAa,CAACC,MAAYtC;QAC5B,IAAI,CAACG,UACD;QAEAS,eAEAT,SAAS+B,YAAYI,MAAMtC,MAAMyB,aAGjCtB,SAASmC,KAAK,WAAW;IAEjC;IAEA,MAAMC,mBA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@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/admin-ui",
|
|
3
|
-
"version": "6.5.0-beta.
|
|
3
|
+
"version": "6.5.0-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@monaco-editor/react": "4.7.0",
|
|
20
20
|
"@radix-ui/react-scroll-area": "1.2.18",
|
|
21
21
|
"@tanstack/react-table": "9.2.4",
|
|
22
|
-
"@webiny/icons": "6.5.0-beta.
|
|
23
|
-
"@webiny/react-composition": "6.5.0-beta.
|
|
24
|
-
"@webiny/utils": "6.5.0-beta.
|
|
22
|
+
"@webiny/icons": "6.5.0-beta.7",
|
|
23
|
+
"@webiny/react-composition": "6.5.0-beta.7",
|
|
24
|
+
"@webiny/utils": "6.5.0-beta.7",
|
|
25
25
|
"bytes": "3.1.2",
|
|
26
26
|
"class-variance-authority": "0.7.1",
|
|
27
27
|
"clsx": "2.1.1",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@types/react-color": "3.0.13",
|
|
57
57
|
"@types/react-custom-scrollbars": "4.0.13",
|
|
58
58
|
"@types/react-virtualized": "9.22.3",
|
|
59
|
-
"@webiny/build-tools": "6.5.0-beta.
|
|
60
|
-
"@webiny/project": "6.5.0-beta.
|
|
59
|
+
"@webiny/build-tools": "6.5.0-beta.7",
|
|
60
|
+
"@webiny/project": "6.5.0-beta.7",
|
|
61
61
|
"chalk": "6.0.1",
|
|
62
62
|
"oxfmt": "0.70.0",
|
|
63
63
|
"rimraf": "6.1.3",
|