@povio/ui 2.3.0-rc.14 → 2.3.0-rc.15

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.
@@ -34,5 +34,5 @@ export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "valu
34
34
  timeZone?: string;
35
35
  }
36
36
  export type ControlledDateTimePickerProps<TFieldValues extends FieldValues> = ControlProps<DateTimePickerProps, TFieldValues>;
37
- export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso, renderStaticInput, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const DateTimePicker: <TFieldValues extends FieldValues>({ fullIso: _fullIso, renderStaticInput, ...props }: ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
38
38
  export {};
@@ -19,7 +19,7 @@ import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react
19
19
  import { useDatePicker, useLocale } from "react-aria";
20
20
  import { mergeRefs } from "@react-aria/utils";
21
21
  import { Controller, useWatch } from "react-hook-form";
22
- import { Time, createCalendar, now, toCalendarDateTime, today } from "@internationalized/date";
22
+ import { Time, createCalendar, toCalendarDate, toCalendarDateTime, today } from "@internationalized/date";
23
23
  import { useCalendarState, useDatePickerState } from "react-stately";
24
24
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
25
25
  var DateTimePickerBase = (props) => {
@@ -142,8 +142,9 @@ var DateTimePickerBase = (props) => {
142
142
  calendarState.setFocusedDate(selectedDate);
143
143
  };
144
144
  const onTodayPress = () => {
145
- dialogState.setValue(toCalendarDateTime(now(effectiveTimeZone)));
146
- calendarState.setFocusedDate(today(effectiveTimeZone));
145
+ const currentValue = DateTimeUtils.getCurrentWallClockCalendarDateTime();
146
+ dialogState.setValue(currentValue);
147
+ calendarState.setFocusedDate(toCalendarDate(currentValue));
147
148
  };
148
149
  const onOpenChange = (isOpen) => {
149
150
  state.toggle();
@@ -233,7 +234,7 @@ var DateTimePickerBase = (props) => {
233
234
  })
234
235
  });
235
236
  };
236
- var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
237
+ var DateTimePicker = ({ fullIso: _fullIso = true, renderStaticInput, ...props }) => {
237
238
  const ui = UIConfig.useConfig();
238
239
  const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
239
240
  const { locale } = useLocale();
@@ -259,8 +260,7 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
259
260
  const effectiveTimeZone = "UTC";
260
261
  const formatDateValue = (dateValue) => {
261
262
  if (dateValue === null) return null;
262
- if (fullIso) return DateTimeUtils.fromDateValueToISO(dateValue, effectiveTimeZone);
263
- return DateTimeUtils.fromDateValueToISO(dateValue, effectiveTimeZone);
263
+ return DateTimeUtils.fromDateValueFieldsToUTCISO(dateValue);
264
264
  };
265
265
  const parseDateValue = (isoString) => {
266
266
  if (isoString == null) return isoString;
@@ -2,6 +2,7 @@ import { UIStyle } from "../../../../config/uiStyle.context.js";
2
2
  import { Typography } from "../../../text/Typography/Typography.js";
3
3
  import { UIConfig } from "../../../../config/uiConfig.context.js";
4
4
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
5
+ import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
5
6
  import { DateField } from "./DateField.js";
6
7
  import { datePickerInputContentRow } from "./datePickerInput.cva.js";
7
8
  import { getDatePickerTodayIcon } from "./datePickerTodayIcon.js";
@@ -14,7 +15,7 @@ import { clsx } from "clsx";
14
15
  import { useImperativeHandle, useRef, useState } from "react";
15
16
  import { Button } from "react-aria-components";
16
17
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
17
- import { now, toCalendarDateTime, today } from "@internationalized/date";
18
+ import { today } from "@internationalized/date";
18
19
  //#region src/components/inputs/DateTime/shared/DatePickerInput.tsx
19
20
  var DatePickerInput = (t0) => {
20
21
  const $ = c(96);
@@ -102,7 +103,7 @@ var DatePickerInput = (t0) => {
102
103
  if ($[11] !== effectiveTimeZone || $[12] !== endFieldProps || $[13] !== fieldProps || $[14] !== isDateTime) {
103
104
  t11 = () => {
104
105
  if (isDateTime) {
105
- const calendarDateTime = toCalendarDateTime(now(effectiveTimeZone));
106
+ const calendarDateTime = DateTimeUtils.getCurrentWallClockCalendarDateTime();
106
107
  fieldProps.onChange?.(calendarDateTime);
107
108
  if (endFieldProps) endFieldProps.onChange?.(calendarDateTime);
108
109
  } else {
@@ -19,7 +19,7 @@ declare const componentRegistry: {
19
19
  readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../../..').SelectItem<any>, TQueryFn extends import('../Selection/Autocomplete/queryAutocomplete.types').QueryFn>({ query, queryParams, queryOptions, queryMap, leadingContent, ...props }: import('../Selection/Autocomplete/queryAutocomplete.types').QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
20
20
  readonly segment: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key>(props: import('../../..').ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
21
21
  readonly datePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, granularity, minValue, maxValue, renderStaticInput, ...props }: import('../DateTime/DatePicker/DatePicker').ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
22
- readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, renderStaticInput, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
22
+ readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso: _fullIso, renderStaticInput, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
23
23
  readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
24
24
  readonly dateRangePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: import('../DateTime/DateRangePicker/DateRangePicker').ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
25
25
  readonly unknown: null;
@@ -22,6 +22,8 @@ export declare namespace DateTimeUtils {
22
22
  export function formatCalendarDateTimeLocalized(calendarDateTime: Pick<CalendarDateTime, "day" | "month" | "year" | "hour" | "minute">, locale?: string, options?: LocalizedDateFormatOptions): string;
23
23
  export function fromISOtoZonedDateTime(isoString: string, timeZone?: string): ZonedDateTime;
24
24
  export function fromDateValueToISO(dateValue: DateValue, timeZone?: string): string;
25
+ export function fromDateValueFieldsToUTCISO(dateValue: DateValue): string;
26
+ export function getCurrentWallClockCalendarDateTime(): CalendarDateTime;
25
27
  export function fromDateValueToOffsetISO(dateValue: DateValue, timeZone?: string): string;
26
28
  export function fromLocalToZonedDateTime(date: Date, timeZone?: string): ZonedDateTime;
27
29
  export function fromDateValueToLocal(dateValue: DateValue, timeZone?: string): Date;
@@ -136,6 +136,16 @@ var DateTimeUtils;
136
136
  return dateValue.toDate(resolvedTimeZone).toISOString();
137
137
  }
138
138
  _DateTimeUtils.fromDateValueToISO = fromDateValueToISO;
139
+ function fromDateValueFieldsToUTCISO(dateValue) {
140
+ const dateTimeFields = dateValue;
141
+ return new CalendarDateTime(dateValue.year, dateValue.month, dateValue.day, dateTimeFields.hour ?? 0, dateTimeFields.minute ?? 0, dateTimeFields.second ?? 0, dateTimeFields.millisecond ?? 0).toDate("UTC").toISOString();
142
+ }
143
+ _DateTimeUtils.fromDateValueFieldsToUTCISO = fromDateValueFieldsToUTCISO;
144
+ function getCurrentWallClockCalendarDateTime() {
145
+ const date = /* @__PURE__ */ new Date();
146
+ return new CalendarDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
147
+ }
148
+ _DateTimeUtils.getCurrentWallClockCalendarDateTime = getCurrentWallClockCalendarDateTime;
139
149
  function fromDateValueToOffsetISO(dateValue, timeZone) {
140
150
  const resolvedTimeZone = resolveTimeZone(timeZone);
141
151
  const date = dateValue.toDate(resolvedTimeZone);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.3.0-rc.14",
3
+ "version": "2.3.0-rc.15",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",