@helpwave/hightide 0.10.0 → 0.10.1

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.
package/dist/index.js CHANGED
@@ -7129,6 +7129,7 @@ __export(index_exports, {
7129
7129
  useComboboxContext: () => useComboboxContext,
7130
7130
  useControlledState: () => useControlledState,
7131
7131
  useCreateForm: () => useCreateForm,
7132
+ useDateTimeFormat: () => useDateTimeFormat,
7132
7133
  useDelay: () => useDelay,
7133
7134
  useDialogContext: () => useDialogContext,
7134
7135
  useDrawerContext: () => useDrawerContext,
@@ -7176,6 +7177,7 @@ __export(index_exports, {
7176
7177
  useTableStateContext: () => useTableStateContext,
7177
7178
  useTableStateWithoutSizingContext: () => useTableStateWithoutSizingContext,
7178
7179
  useTheme: () => useTheme,
7180
+ useTimeZone: () => useTimeZone,
7179
7181
  useTooltip: () => useTooltip,
7180
7182
  useTransitionState: () => useTransitionState,
7181
7183
  useTranslatedValidators: () => useTranslatedValidators,
@@ -9444,13 +9446,29 @@ var LocaleProvider = ({
9444
9446
  children,
9445
9447
  locale,
9446
9448
  defaultLocale,
9447
- onChangedLocale
9449
+ defaultTimeZone,
9450
+ defaultIs24HourFormat,
9451
+ timeZone,
9452
+ is24HourFormat,
9453
+ onChangedLocale,
9454
+ onChangedTimeZone,
9455
+ onChangedIs24HourFormat
9448
9456
  }) => {
9449
9457
  const {
9450
9458
  value: storedLocale,
9451
9459
  setValue: setStoredLocale,
9452
9460
  deleteValue: deleteStoredLocale
9453
9461
  } = useStorage({ key: "locale", defaultValue: "system" });
9462
+ const {
9463
+ value: storedTimeZone,
9464
+ setValue: setStoredTimeZone,
9465
+ deleteValue: deleteStoredTimeZone
9466
+ } = useStorage({ key: "timeZone", defaultValue: void 0 });
9467
+ const {
9468
+ value: storedIs24HourFormat,
9469
+ setValue: setStoredIs24HourFormat,
9470
+ deleteValue: deleteStoredIs24HourFormat
9471
+ } = useStorage({ key: "is24HourFormat", defaultValue: void 0 });
9454
9472
  const { config } = useHightideConfig();
9455
9473
  const [localePreference, setLocalePreference] = (0, import_react8.useState)("system");
9456
9474
  const resolvedLocale = (0, import_react8.useMemo)(() => {
@@ -9473,10 +9491,32 @@ var LocaleProvider = ({
9473
9491
  setStoredLocale(locale);
9474
9492
  }
9475
9493
  }, [locale, deleteStoredLocale, setStoredLocale]);
9494
+ const resolvedTimeZone = (0, import_react8.useMemo)(() => {
9495
+ return timeZone ?? storedTimeZone ?? config.locale.defaultTimeZone ?? defaultTimeZone;
9496
+ }, [timeZone, storedTimeZone, config.locale.defaultTimeZone, defaultTimeZone]);
9497
+ (0, import_react8.useEffect)(() => {
9498
+ if (timeZone === void 0) return;
9499
+ setStoredTimeZone(timeZone);
9500
+ }, [timeZone, setStoredTimeZone]);
9501
+ const resolvedIs24HourFormat = (0, import_react8.useMemo)(() => {
9502
+ return is24HourFormat ?? storedIs24HourFormat ?? config.locale.defaultIs24HourFormat ?? defaultIs24HourFormat ?? true;
9503
+ }, [is24HourFormat, storedIs24HourFormat, config.locale.defaultIs24HourFormat, defaultIs24HourFormat]);
9504
+ (0, import_react8.useEffect)(() => {
9505
+ if (is24HourFormat === void 0) return;
9506
+ setStoredIs24HourFormat(is24HourFormat);
9507
+ }, [is24HourFormat, setStoredIs24HourFormat]);
9476
9508
  const onChangeRef = useEventCallbackStabilizer(onChangedLocale);
9477
9509
  (0, import_react8.useEffect)(() => {
9478
9510
  onChangeRef?.(resolvedLocale);
9479
9511
  }, [resolvedLocale, onChangeRef]);
9512
+ const onChangeTimeZoneRef = useEventCallbackStabilizer(onChangedTimeZone);
9513
+ (0, import_react8.useEffect)(() => {
9514
+ onChangeTimeZoneRef?.(resolvedTimeZone);
9515
+ }, [resolvedTimeZone, onChangeTimeZoneRef]);
9516
+ const onChangeIs24HourFormatRef = useEventCallbackStabilizer(onChangedIs24HourFormat);
9517
+ (0, import_react8.useEffect)(() => {
9518
+ onChangeIs24HourFormatRef?.(resolvedIs24HourFormat);
9519
+ }, [resolvedIs24HourFormat, onChangeIs24HourFormatRef]);
9480
9520
  (0, import_react8.useEffect)(() => {
9481
9521
  const localesToTestAgainst = Object.values(LocalizationUtil.locals);
9482
9522
  const detectLanguage = () => {
@@ -9500,6 +9540,30 @@ var LocaleProvider = ({
9500
9540
  console.warn("LocaleProvider: Attempting to change the locale while setting a fixed locale won't have any effect. Change the locale provided to the LocaleProvider instead.");
9501
9541
  }
9502
9542
  setStoredLocale(newLocale);
9543
+ },
9544
+ timeZone: resolvedTimeZone,
9545
+ setTimeZone: (newTimeZone) => {
9546
+ if (timeZone !== void 0) {
9547
+ console.warn("LocaleProvider: Attempting to change the time zone while setting a fixed time zone won't have any effect. Change the timeZone provided to the LocaleProvider instead.");
9548
+ return;
9549
+ }
9550
+ if (newTimeZone === void 0) {
9551
+ deleteStoredTimeZone();
9552
+ } else {
9553
+ setStoredTimeZone(newTimeZone);
9554
+ }
9555
+ },
9556
+ is24HourFormat: resolvedIs24HourFormat,
9557
+ setIs24HourFormat: (newIs24HourFormat) => {
9558
+ if (is24HourFormat !== void 0) {
9559
+ console.warn("LocaleProvider: Attempting to change the hour format while setting a fixed hour format won't have any effect. Change the is24HourFormat provided to the LocaleProvider instead.");
9560
+ return;
9561
+ }
9562
+ if (newIs24HourFormat === void 0) {
9563
+ deleteStoredIs24HourFormat();
9564
+ } else {
9565
+ setStoredIs24HourFormat(newIs24HourFormat);
9566
+ }
9503
9567
  }
9504
9568
  }, children });
9505
9569
  };
@@ -9510,6 +9574,20 @@ var useLocale = () => {
9510
9574
  }
9511
9575
  return context;
9512
9576
  };
9577
+ var useTimeZone = () => {
9578
+ const context = (0, import_react8.useContext)(LocaleContext);
9579
+ if (!context) {
9580
+ throw new Error("useTimeZone must be used within LocaleContext. Try adding a LocaleProvider around your app.");
9581
+ }
9582
+ return { timeZone: context.timeZone, setTimeZone: context.setTimeZone };
9583
+ };
9584
+ var useDateTimeFormat = () => {
9585
+ const context = (0, import_react8.useContext)(LocaleContext);
9586
+ return {
9587
+ is24HourFormat: context?.is24HourFormat ?? true,
9588
+ timeZone: context?.timeZone
9589
+ };
9590
+ };
9513
9591
  var useLanguage = () => {
9514
9592
  const context = (0, import_react8.useContext)(LocaleContext);
9515
9593
  if (!context) {
@@ -15682,9 +15760,7 @@ var timesInSeconds = {
15682
15760
  day: 86400,
15683
15761
  week: 604800,
15684
15762
  monthImprecise: 2629800,
15685
- // 30.4375 days
15686
15763
  yearImprecise: 31557600
15687
- // 365.25 days
15688
15764
  };
15689
15765
  var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
15690
15766
  var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
@@ -15787,6 +15863,73 @@ var withTime = (datePart, timePart) => {
15787
15863
  );
15788
15864
  return out;
15789
15865
  };
15866
+ var zonedPartsFormatterCache = /* @__PURE__ */ new Map();
15867
+ var zonedPartsFormatter = (timeZone) => {
15868
+ let formatter = zonedPartsFormatterCache.get(timeZone);
15869
+ if (!formatter) {
15870
+ formatter = new Intl.DateTimeFormat("en-US", {
15871
+ timeZone,
15872
+ hourCycle: "h23",
15873
+ year: "numeric",
15874
+ month: "2-digit",
15875
+ day: "2-digit",
15876
+ hour: "2-digit",
15877
+ minute: "2-digit",
15878
+ second: "2-digit"
15879
+ });
15880
+ zonedPartsFormatterCache.set(timeZone, formatter);
15881
+ }
15882
+ return formatter;
15883
+ };
15884
+ var zonedParts = (date, timeZone) => {
15885
+ const parts = {};
15886
+ for (const part of zonedPartsFormatter(timeZone).formatToParts(date)) {
15887
+ if (part.type !== "literal") {
15888
+ parts[part.type] = part.value;
15889
+ }
15890
+ }
15891
+ return {
15892
+ year: Number(parts.year),
15893
+ month: Number(parts.month),
15894
+ day: Number(parts.day),
15895
+ hour: Number(parts.hour) % 24,
15896
+ minute: Number(parts.minute),
15897
+ second: Number(parts.second),
15898
+ millisecond: date.getMilliseconds()
15899
+ };
15900
+ };
15901
+ var zoneOffsetMs = (date, timeZone) => {
15902
+ const parts = zonedParts(date, timeZone);
15903
+ const asUtc = Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second, parts.millisecond);
15904
+ return asUtc - date.getTime();
15905
+ };
15906
+ function toZonedDate(date, timeZone) {
15907
+ if (!date || !timeZone) {
15908
+ return date;
15909
+ }
15910
+ const parts = zonedParts(date, timeZone);
15911
+ return new Date(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second, parts.millisecond);
15912
+ }
15913
+ function fromZonedDate(date, timeZone) {
15914
+ if (!date || !timeZone) {
15915
+ return date;
15916
+ }
15917
+ const asUtc = Date.UTC(
15918
+ date.getFullYear(),
15919
+ date.getMonth(),
15920
+ date.getDate(),
15921
+ date.getHours(),
15922
+ date.getMinutes(),
15923
+ date.getSeconds(),
15924
+ date.getMilliseconds()
15925
+ );
15926
+ let offset = zoneOffsetMs(new Date(asUtc), timeZone);
15927
+ const refined = zoneOffsetMs(new Date(asUtc - offset), timeZone);
15928
+ if (refined !== offset) {
15929
+ offset = refined;
15930
+ }
15931
+ return new Date(asUtc - offset);
15932
+ }
15790
15933
  var weeksForCalenderMonth = (date, weekStart, weeks = 6) => {
15791
15934
  const month = date.getMonth();
15792
15935
  const year = date.getFullYear();
@@ -15804,8 +15947,13 @@ var weeksForCalenderMonth = (date, weekStart, weeks = 6) => {
15804
15947
  }
15805
15948
  return equalSizeGroups(dayList, 7);
15806
15949
  };
15807
- var formatAbsolute = (date, locale, format) => {
15950
+ var formatAbsolute = (date, locale, format, { timeZone, is24HourFormat = true } = {}) => {
15808
15951
  let options;
15952
+ const timeOptions = {
15953
+ hour: "2-digit",
15954
+ minute: "2-digit",
15955
+ hourCycle: is24HourFormat ? "h23" : "h12"
15956
+ };
15809
15957
  switch (format) {
15810
15958
  case "date":
15811
15959
  options = {
@@ -15816,8 +15964,7 @@ var formatAbsolute = (date, locale, format) => {
15816
15964
  break;
15817
15965
  case "time":
15818
15966
  options = {
15819
- hour: "2-digit",
15820
- minute: "2-digit"
15967
+ ...timeOptions
15821
15968
  };
15822
15969
  break;
15823
15970
  case "dateTime":
@@ -15825,12 +15972,11 @@ var formatAbsolute = (date, locale, format) => {
15825
15972
  year: "numeric",
15826
15973
  month: "2-digit",
15827
15974
  day: "2-digit",
15828
- hour: "2-digit",
15829
- minute: "2-digit"
15975
+ ...timeOptions
15830
15976
  };
15831
15977
  break;
15832
15978
  }
15833
- return new Intl.DateTimeFormat(locale, options).format(date);
15979
+ return new Intl.DateTimeFormat(locale, { ...options, timeZone }).format(date);
15834
15980
  };
15835
15981
  var formatRelative = (date, locale) => {
15836
15982
  const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
@@ -15907,6 +16053,9 @@ var DateUtils = {
15907
16053
  daysInMonth,
15908
16054
  sameTime,
15909
16055
  withTime,
16056
+ zonedParts,
16057
+ toZonedDate,
16058
+ fromZonedDate,
15910
16059
  formatAbsolute,
15911
16060
  formatRelative,
15912
16061
  addDuration,
@@ -15917,9 +16066,6 @@ var DateUtils = {
15917
16066
  toInputString,
15918
16067
  tryParseDate,
15919
16068
  toOnlyDate: normalizeToDateOnly,
15920
- /**
15921
- * Normalizes a datetime by removing seconds and milliseconds.
15922
- */
15923
16069
  toDateTimeOnly: normalizeDatetime
15924
16070
  };
15925
16071
 
@@ -16786,13 +16932,15 @@ var TimePicker = ({
16786
16932
  initialValue = /* @__PURE__ */ new Date(),
16787
16933
  onValueChange,
16788
16934
  onEditComplete,
16789
- is24HourFormat = true,
16935
+ is24HourFormat: is24HourFormatOverride,
16790
16936
  minuteIncrement = "5min",
16791
16937
  secondIncrement = "5s",
16792
16938
  millisecondIncrement = "100ms",
16793
16939
  precision = "minute",
16794
16940
  className
16795
16941
  }) => {
16942
+ const { is24HourFormat: contextIs24HourFormat } = useDateTimeFormat();
16943
+ const is24HourFormat = is24HourFormatOverride ?? contextIs24HourFormat;
16796
16944
  const [value, setValue] = useControlledState({
16797
16945
  value: controlledValue,
16798
16946
  onValueChange,
@@ -17789,19 +17937,14 @@ var DateTimeField = (0, import_react79.forwardRef)(function DateTimeField2({
17789
17937
  ...props
17790
17938
  }, forwardedRef) {
17791
17939
  const translation = useHightideTranslation();
17792
- const { locale: contextLocale } = useLocale();
17940
+ const { locale: contextLocale, is24HourFormat: contextIs24HourFormat } = useLocale();
17793
17941
  const locale = localeOverride ?? contextLocale;
17794
17942
  const [value, setValue] = useControlledState({
17795
17943
  value: controlledValue,
17796
17944
  onValueChange,
17797
17945
  defaultValue: initialValue
17798
17946
  });
17799
- const is24Hour = (0, import_react79.useMemo)(() => {
17800
- if (is24HourFormat !== void 0) {
17801
- return is24HourFormat;
17802
- }
17803
- return !new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hour12;
17804
- }, [is24HourFormat, locale]);
17947
+ const is24Hour = is24HourFormat ?? contextIs24HourFormat ?? true;
17805
17948
  const layout = (0, import_react79.useMemo)(
17806
17949
  () => buildSegmentLayout({ locale, mode, precision, is24HourFormat: is24Hour }),
17807
17950
  [locale, mode, precision, is24Hour]
@@ -17832,6 +17975,9 @@ var DateTimeField = (0, import_react79.forwardRef)(function DateTimeField2({
17832
17975
  return callback;
17833
17976
  };
17834
17977
  (0, import_react79.useEffect)(() => {
17978
+ if (editStateRef.current.buffer) {
17979
+ return;
17980
+ }
17835
17981
  const shown = composeDate(editStateRef.current.values, layout, mode, is24Hour, value ?? void 0);
17836
17982
  if ((shown?.getTime() ?? null) === (value?.getTime() ?? null)) {
17837
17983
  return;
@@ -17843,6 +17989,9 @@ var DateTimeField = (0, import_react79.forwardRef)(function DateTimeField2({
17843
17989
  }, [value, layout, mode, is24Hour]);
17844
17990
  const apply = (next) => {
17845
17991
  setEditState(next);
17992
+ if (next.buffer?.type === "year") {
17993
+ return;
17994
+ }
17846
17995
  const composed = composeDate(next.values, layout, mode, is24Hour, value ?? void 0);
17847
17996
  if (composed) {
17848
17997
  setValue(composed);
@@ -17939,6 +18088,10 @@ var DateTimeField = (0, import_react79.forwardRef)(function DateTimeField2({
17939
18088
  const onFieldBlur = (event) => {
17940
18089
  props.onBlur?.(event);
17941
18090
  const field = event.currentTarget;
18091
+ const nextFocus = event.relatedTarget;
18092
+ if (nextFocus instanceof Node && field.contains(nextFocus)) {
18093
+ return;
18094
+ }
17942
18095
  requestAnimationFrame(() => {
17943
18096
  if (field.contains(document.activeElement)) {
17944
18097
  return;
@@ -17947,6 +18100,9 @@ var DateTimeField = (0, import_react79.forwardRef)(function DateTimeField2({
17947
18100
  const composed = composeDate(editStateRef.current.values, layout, mode, is24Hour, value ?? void 0);
17948
18101
  if (composed) {
17949
18102
  setEditState({ values: decomposeDate(composed, layout, is24Hour), buffer: null });
18103
+ if (composed.getTime() !== (value?.getTime() ?? null)) {
18104
+ setValue(composed);
18105
+ }
17950
18106
  onEditComplete?.(composed);
17951
18107
  } else {
17952
18108
  onEditComplete?.(value ?? null);
@@ -18021,6 +18177,7 @@ var DateTimeInput = (0, import_react80.forwardRef)(function DateTimeInput2({
18021
18177
  allowClear = true,
18022
18178
  containerProps,
18023
18179
  mode = "date",
18180
+ timeZone: timeZoneOverride,
18024
18181
  precision = "minute",
18025
18182
  pickerProps,
18026
18183
  outsideClickCloses = true,
@@ -18041,6 +18198,8 @@ var DateTimeInput = (0, import_react80.forwardRef)(function DateTimeInput2({
18041
18198
  ...props
18042
18199
  }, forwardedRef) {
18043
18200
  const translation = useHightideTranslation();
18201
+ const { timeZone: contextTimeZone } = useLocale();
18202
+ const timeZone = timeZoneOverride ?? contextTimeZone;
18044
18203
  const [isOpen, setIsOpen] = (0, import_react80.useState)(false);
18045
18204
  const [state, setState] = useControlledState({
18046
18205
  value,
@@ -18052,6 +18211,8 @@ var DateTimeInput = (0, import_react80.forwardRef)(function DateTimeInput2({
18052
18211
  onDialogOpeningChange?.(isOpen2);
18053
18212
  setIsOpen(isOpen2);
18054
18213
  }, [onDialogOpeningChange]);
18214
+ const toZoned = (0, import_react80.useCallback)((date) => DateUtils.toZonedDate(date, timeZone), [timeZone]);
18215
+ const fromZoned = (0, import_react80.useCallback)((date) => DateUtils.fromZonedDate(date, timeZone), [timeZone]);
18055
18216
  const generatedId = (0, import_react80.useId)();
18056
18217
  const ids = (0, import_react80.useMemo)(() => ({
18057
18218
  input: inputId ?? `date-time-input-${generatedId}`,
@@ -18098,7 +18259,7 @@ var DateTimeInput = (0, import_react80.forwardRef)(function DateTimeInput2({
18098
18259
  DateTimeField,
18099
18260
  {
18100
18261
  ref: fieldRef,
18101
- value: state,
18262
+ value: toZoned(state),
18102
18263
  mode,
18103
18264
  precision,
18104
18265
  is24HourFormat,
@@ -18106,8 +18267,8 @@ var DateTimeInput = (0, import_react80.forwardRef)(function DateTimeInput2({
18106
18267
  readOnly,
18107
18268
  invalid,
18108
18269
  required,
18109
- onValueChange: setState,
18110
- onEditComplete,
18270
+ onValueChange: (next) => setState(fromZoned(next)),
18271
+ onEditComplete: (next) => onEditComplete?.(fromZoned(next)),
18111
18272
  "aria-labelledby": props["aria-labelledby"],
18112
18273
  "aria-describedby": props["aria-describedby"],
18113
18274
  className: "grow"
@@ -18172,18 +18333,19 @@ var DateTimeInput = (0, import_react80.forwardRef)(function DateTimeInput2({
18172
18333
  children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
18173
18334
  DateTimePickerDialog,
18174
18335
  {
18175
- value: dialogValue,
18336
+ value: toZoned(dialogValue),
18176
18337
  allowRemove,
18177
- onValueChange: setDialogValue,
18338
+ onValueChange: (value2) => setDialogValue(fromZoned(value2)),
18178
18339
  onEditComplete: (value2) => {
18179
- setState(value2);
18180
- onEditComplete?.(value2);
18340
+ const absolute = fromZoned(value2);
18341
+ setState(absolute);
18342
+ onEditComplete?.(absolute);
18181
18343
  changeOpenWrapper(false);
18182
18344
  },
18183
18345
  pickerProps,
18184
18346
  mode,
18185
- start,
18186
- end,
18347
+ start: toZoned(start ?? null) ?? void 0,
18348
+ end: toZoned(end ?? null) ?? void 0,
18187
18349
  weekStart,
18188
18350
  markToday,
18189
18351
  is24HourFormat,
@@ -21711,10 +21873,18 @@ var SortingList = ({ sorting, onSortingChange, availableItems }) => {
21711
21873
  var import_jsx_runtime104 = require("react/jsx-runtime");
21712
21874
  var TimeDisplay = ({
21713
21875
  date,
21714
- mode = "daysFromToday"
21876
+ mode = "daysFromToday",
21877
+ is24HourFormat: is24HourFormatOverride,
21878
+ timeZone: timeZoneOverride
21715
21879
  }) => {
21716
21880
  const translation = useHightideTranslation();
21717
- const difference = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0).valueOf() - new Date(date).setHours(0, 0, 0, 0).valueOf();
21881
+ const { locale } = useLocale();
21882
+ const { is24HourFormat: contextIs24HourFormat, timeZone: contextTimeZone } = useDateTimeFormat();
21883
+ const is24HourFormat = is24HourFormatOverride ?? contextIs24HourFormat;
21884
+ const timeZone = timeZoneOverride ?? contextTimeZone;
21885
+ const zonedDate = DateUtils.toZonedDate(date, timeZone);
21886
+ const zonedNow = DateUtils.toZonedDate(/* @__PURE__ */ new Date(), timeZone);
21887
+ const difference = new Date(zonedNow).setHours(0, 0, 0, 0).valueOf() - new Date(zonedDate).setHours(0, 0, 0, 0).valueOf();
21718
21888
  const isBefore = difference > 0;
21719
21889
  const differenceInDays = Math.floor(Math.abs(difference) / (1e3 * 3600 * 24));
21720
21890
  let displayString;
@@ -21741,9 +21911,15 @@ var TimeDisplay = ({
21741
21911
  };
21742
21912
  let fullString;
21743
21913
  if (mode === "daysFromToday") {
21744
- fullString = `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")} - ${displayString}`;
21914
+ const timeString = new Intl.DateTimeFormat(locale, {
21915
+ hour: "2-digit",
21916
+ minute: "2-digit",
21917
+ hourCycle: is24HourFormat ? "h23" : "h12",
21918
+ timeZone
21919
+ }).format(date);
21920
+ fullString = `${timeString} - ${displayString}`;
21745
21921
  } else {
21746
- fullString = `${date.getDate()}. ${monthToTranslation[date.getMonth()]} ${date.getFullYear()}`;
21922
+ fullString = `${zonedDate.getDate()}. ${monthToTranslation[zonedDate.getMonth()]} ${zonedDate.getFullYear()}`;
21747
21923
  }
21748
21924
  return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { children: fullString });
21749
21925
  };
@@ -21758,29 +21934,36 @@ var FlexibleDateTimeInput = (0, import_react111.forwardRef)(function FlexibleDat
21758
21934
  initialValue,
21759
21935
  onValueChange,
21760
21936
  fixedTime: fixedTimeOverride,
21937
+ timeZone: timeZoneOverride,
21761
21938
  actions = [],
21762
21939
  ...props
21763
21940
  }, forwardedRef) {
21764
21941
  const translation = useHightideTranslation();
21942
+ const { timeZone: contextTimeZone } = useLocale();
21943
+ const timeZone = timeZoneOverride ?? contextTimeZone;
21765
21944
  const fixedTime = fixedTimeOverride ?? new Date(1970, 0, 1, 23, 59, 59, 999);
21766
21945
  const [value, setValue] = useControlledState({
21767
21946
  value: controlledValue,
21768
21947
  onValueChange,
21769
21948
  defaultValue: initialValue
21770
21949
  });
21950
+ const zoned = (date) => DateUtils.toZonedDate(date, timeZone);
21951
+ const unzoned = (date) => DateUtils.fromZonedDate(date, timeZone);
21952
+ const hasFixedTime = (date) => DateUtils.sameTime(zoned(date), fixedTime, true, true);
21771
21953
  const [mode, setMode] = (0, import_react111.useState)(() => {
21772
- if (value && !DateUtils.sameTime(value, fixedTime, true, true)) {
21954
+ if (value && !hasFixedTime(value)) {
21773
21955
  return "dateTime";
21774
21956
  }
21775
21957
  return defaultMode;
21776
21958
  });
21777
- const toDate = (date) => DateUtils.withTime(date, fixedTime);
21778
- const toDateTime = (date) => DateUtils.sameTime(date, fixedTime, true, true) ? DateUtils.withTime(date, /* @__PURE__ */ new Date()) : date;
21959
+ const toDate = (date) => unzoned(DateUtils.withTime(zoned(date), fixedTime));
21960
+ const toDateTime = (date) => hasFixedTime(date) ? unzoned(DateUtils.withTime(zoned(date), zoned(/* @__PURE__ */ new Date()))) : date;
21779
21961
  return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
21780
21962
  DateTimeInput,
21781
21963
  {
21782
21964
  ...props,
21783
21965
  ref: forwardedRef,
21966
+ timeZone,
21784
21967
  mode,
21785
21968
  value,
21786
21969
  onValueChange: (next) => {
@@ -22119,26 +22302,46 @@ var CheckboxProperty = ({
22119
22302
  var import_lucide_react35 = require("lucide-react");
22120
22303
  var import_jsx_runtime111 = require("react/jsx-runtime");
22121
22304
  var DateProperty = ({
22305
+ name,
22122
22306
  value,
22123
22307
  onValueChange,
22124
22308
  onEditComplete,
22309
+ onRemove,
22310
+ onValueClear,
22311
+ required,
22125
22312
  readOnly,
22313
+ allowClear = true,
22314
+ allowRemove = true,
22126
22315
  type = "dateTime",
22127
- ...baseProps
22316
+ className,
22317
+ ...inputProps
22128
22318
  }) => {
22129
22319
  const hasValue = !!value;
22130
22320
  return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
22131
22321
  PropertyBase,
22132
22322
  {
22133
- ...baseProps,
22323
+ name,
22324
+ required,
22325
+ readOnly,
22326
+ allowClear,
22327
+ allowRemove,
22328
+ onRemove,
22329
+ onValueClear: onValueClear ?? (() => {
22330
+ onValueChange?.(null);
22331
+ onEditComplete?.(null);
22332
+ }),
22134
22333
  hasValue,
22135
22334
  icon: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_lucide_react35.CalendarDays, { size: 24 }),
22335
+ className,
22136
22336
  children: ({ invalid }) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
22137
22337
  DateTimeInput,
22138
22338
  {
22339
+ ...inputProps,
22139
22340
  value,
22140
22341
  mode: type,
22342
+ required,
22141
22343
  readOnly,
22344
+ allowClear: false,
22142
22345
  onValueChange,
22143
22346
  onEditComplete,
22144
22347
  "data-name": "property-input",
@@ -22560,21 +22763,23 @@ var useRerender = () => {
22560
22763
 
22561
22764
  // src/hooks/useUpdatingDateString.ts
22562
22765
  var import_react124 = require("react");
22563
- var useUpdatingDateString = ({ absoluteFormat = "dateTime", localeOverride, date }) => {
22564
- const { locale: contextLocale } = useLocale();
22766
+ var useUpdatingDateString = ({ absoluteFormat = "dateTime", localeOverride, is24HourFormat: is24HourFormatOverride, timeZone: timeZoneOverride, date }) => {
22767
+ const { locale: contextLocale, is24HourFormat: contextIs24HourFormat, timeZone: contextTimeZone } = useLocale();
22565
22768
  const locale = localeOverride ?? contextLocale;
22769
+ const is24HourFormat = is24HourFormatOverride ?? contextIs24HourFormat ?? true;
22770
+ const timeZone = timeZoneOverride ?? contextTimeZone;
22566
22771
  const [dateAndTimeStrings, setDateAndTimeStrings] = (0, import_react124.useState)({
22567
22772
  compareDate: date,
22568
- absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat),
22773
+ absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat, { is24HourFormat, timeZone }),
22569
22774
  relative: DateUtils.formatRelative(date, locale)
22570
22775
  });
22571
22776
  (0, import_react124.useEffect)(() => {
22572
22777
  setDateAndTimeStrings({
22573
22778
  compareDate: date,
22574
- absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat),
22779
+ absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat, { is24HourFormat, timeZone }),
22575
22780
  relative: DateUtils.formatRelative(date, locale)
22576
22781
  });
22577
- }, [date, absoluteFormat, locale]);
22782
+ }, [date, absoluteFormat, locale, is24HourFormat, timeZone]);
22578
22783
  (0, import_react124.useEffect)(() => {
22579
22784
  let timeoutId;
22580
22785
  const startTimer = () => {
@@ -22591,14 +22796,14 @@ var useUpdatingDateString = ({ absoluteFormat = "dateTime", localeOverride, date
22591
22796
  timeoutId = setInterval(() => {
22592
22797
  setDateAndTimeStrings({
22593
22798
  compareDate: date,
22594
- absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat),
22799
+ absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat, { is24HourFormat, timeZone }),
22595
22800
  relative: DateUtils.formatRelative(date, locale)
22596
22801
  });
22597
22802
  }, delayInSeconds * 1e3 / 2);
22598
22803
  };
22599
22804
  startTimer();
22600
22805
  return () => clearInterval(timeoutId);
22601
- }, [absoluteFormat, date, locale]);
22806
+ }, [absoluteFormat, date, locale, is24HourFormat, timeZone]);
22602
22807
  return {
22603
22808
  absolute: dateAndTimeStrings.absolute,
22604
22809
  relative: dateAndTimeStrings.relative
@@ -23161,6 +23366,7 @@ var PromiseUtils = {
23161
23366
  useComboboxContext,
23162
23367
  useControlledState,
23163
23368
  useCreateForm,
23369
+ useDateTimeFormat,
23164
23370
  useDelay,
23165
23371
  useDialogContext,
23166
23372
  useDrawerContext,
@@ -23208,6 +23414,7 @@ var PromiseUtils = {
23208
23414
  useTableStateContext,
23209
23415
  useTableStateWithoutSizingContext,
23210
23416
  useTheme,
23417
+ useTimeZone,
23211
23418
  useTooltip,
23212
23419
  useTransitionState,
23213
23420
  useTranslatedValidators,