@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.d.mts +54 -51
- package/dist/index.d.ts +54 -51
- package/dist/index.js +252 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +250 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9148,13 +9148,29 @@ var LocaleProvider = ({
|
|
|
9148
9148
|
children,
|
|
9149
9149
|
locale,
|
|
9150
9150
|
defaultLocale,
|
|
9151
|
-
|
|
9151
|
+
defaultTimeZone,
|
|
9152
|
+
defaultIs24HourFormat,
|
|
9153
|
+
timeZone,
|
|
9154
|
+
is24HourFormat,
|
|
9155
|
+
onChangedLocale,
|
|
9156
|
+
onChangedTimeZone,
|
|
9157
|
+
onChangedIs24HourFormat
|
|
9152
9158
|
}) => {
|
|
9153
9159
|
const {
|
|
9154
9160
|
value: storedLocale,
|
|
9155
9161
|
setValue: setStoredLocale,
|
|
9156
9162
|
deleteValue: deleteStoredLocale
|
|
9157
9163
|
} = useStorage({ key: "locale", defaultValue: "system" });
|
|
9164
|
+
const {
|
|
9165
|
+
value: storedTimeZone,
|
|
9166
|
+
setValue: setStoredTimeZone,
|
|
9167
|
+
deleteValue: deleteStoredTimeZone
|
|
9168
|
+
} = useStorage({ key: "timeZone", defaultValue: void 0 });
|
|
9169
|
+
const {
|
|
9170
|
+
value: storedIs24HourFormat,
|
|
9171
|
+
setValue: setStoredIs24HourFormat,
|
|
9172
|
+
deleteValue: deleteStoredIs24HourFormat
|
|
9173
|
+
} = useStorage({ key: "is24HourFormat", defaultValue: void 0 });
|
|
9158
9174
|
const { config } = useHightideConfig();
|
|
9159
9175
|
const [localePreference, setLocalePreference] = useState4("system");
|
|
9160
9176
|
const resolvedLocale = useMemo4(() => {
|
|
@@ -9177,10 +9193,32 @@ var LocaleProvider = ({
|
|
|
9177
9193
|
setStoredLocale(locale);
|
|
9178
9194
|
}
|
|
9179
9195
|
}, [locale, deleteStoredLocale, setStoredLocale]);
|
|
9196
|
+
const resolvedTimeZone = useMemo4(() => {
|
|
9197
|
+
return timeZone ?? storedTimeZone ?? config.locale.defaultTimeZone ?? defaultTimeZone;
|
|
9198
|
+
}, [timeZone, storedTimeZone, config.locale.defaultTimeZone, defaultTimeZone]);
|
|
9199
|
+
useEffect4(() => {
|
|
9200
|
+
if (timeZone === void 0) return;
|
|
9201
|
+
setStoredTimeZone(timeZone);
|
|
9202
|
+
}, [timeZone, setStoredTimeZone]);
|
|
9203
|
+
const resolvedIs24HourFormat = useMemo4(() => {
|
|
9204
|
+
return is24HourFormat ?? storedIs24HourFormat ?? config.locale.defaultIs24HourFormat ?? defaultIs24HourFormat ?? true;
|
|
9205
|
+
}, [is24HourFormat, storedIs24HourFormat, config.locale.defaultIs24HourFormat, defaultIs24HourFormat]);
|
|
9206
|
+
useEffect4(() => {
|
|
9207
|
+
if (is24HourFormat === void 0) return;
|
|
9208
|
+
setStoredIs24HourFormat(is24HourFormat);
|
|
9209
|
+
}, [is24HourFormat, setStoredIs24HourFormat]);
|
|
9180
9210
|
const onChangeRef = useEventCallbackStabilizer(onChangedLocale);
|
|
9181
9211
|
useEffect4(() => {
|
|
9182
9212
|
onChangeRef?.(resolvedLocale);
|
|
9183
9213
|
}, [resolvedLocale, onChangeRef]);
|
|
9214
|
+
const onChangeTimeZoneRef = useEventCallbackStabilizer(onChangedTimeZone);
|
|
9215
|
+
useEffect4(() => {
|
|
9216
|
+
onChangeTimeZoneRef?.(resolvedTimeZone);
|
|
9217
|
+
}, [resolvedTimeZone, onChangeTimeZoneRef]);
|
|
9218
|
+
const onChangeIs24HourFormatRef = useEventCallbackStabilizer(onChangedIs24HourFormat);
|
|
9219
|
+
useEffect4(() => {
|
|
9220
|
+
onChangeIs24HourFormatRef?.(resolvedIs24HourFormat);
|
|
9221
|
+
}, [resolvedIs24HourFormat, onChangeIs24HourFormatRef]);
|
|
9184
9222
|
useEffect4(() => {
|
|
9185
9223
|
const localesToTestAgainst = Object.values(LocalizationUtil.locals);
|
|
9186
9224
|
const detectLanguage = () => {
|
|
@@ -9204,6 +9242,30 @@ var LocaleProvider = ({
|
|
|
9204
9242
|
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.");
|
|
9205
9243
|
}
|
|
9206
9244
|
setStoredLocale(newLocale);
|
|
9245
|
+
},
|
|
9246
|
+
timeZone: resolvedTimeZone,
|
|
9247
|
+
setTimeZone: (newTimeZone) => {
|
|
9248
|
+
if (timeZone !== void 0) {
|
|
9249
|
+
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.");
|
|
9250
|
+
return;
|
|
9251
|
+
}
|
|
9252
|
+
if (newTimeZone === void 0) {
|
|
9253
|
+
deleteStoredTimeZone();
|
|
9254
|
+
} else {
|
|
9255
|
+
setStoredTimeZone(newTimeZone);
|
|
9256
|
+
}
|
|
9257
|
+
},
|
|
9258
|
+
is24HourFormat: resolvedIs24HourFormat,
|
|
9259
|
+
setIs24HourFormat: (newIs24HourFormat) => {
|
|
9260
|
+
if (is24HourFormat !== void 0) {
|
|
9261
|
+
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.");
|
|
9262
|
+
return;
|
|
9263
|
+
}
|
|
9264
|
+
if (newIs24HourFormat === void 0) {
|
|
9265
|
+
deleteStoredIs24HourFormat();
|
|
9266
|
+
} else {
|
|
9267
|
+
setStoredIs24HourFormat(newIs24HourFormat);
|
|
9268
|
+
}
|
|
9207
9269
|
}
|
|
9208
9270
|
}, children });
|
|
9209
9271
|
};
|
|
@@ -9214,6 +9276,20 @@ var useLocale = () => {
|
|
|
9214
9276
|
}
|
|
9215
9277
|
return context;
|
|
9216
9278
|
};
|
|
9279
|
+
var useTimeZone = () => {
|
|
9280
|
+
const context = useContext2(LocaleContext);
|
|
9281
|
+
if (!context) {
|
|
9282
|
+
throw new Error("useTimeZone must be used within LocaleContext. Try adding a LocaleProvider around your app.");
|
|
9283
|
+
}
|
|
9284
|
+
return { timeZone: context.timeZone, setTimeZone: context.setTimeZone };
|
|
9285
|
+
};
|
|
9286
|
+
var useDateTimeFormat = () => {
|
|
9287
|
+
const context = useContext2(LocaleContext);
|
|
9288
|
+
return {
|
|
9289
|
+
is24HourFormat: context?.is24HourFormat ?? true,
|
|
9290
|
+
timeZone: context?.timeZone
|
|
9291
|
+
};
|
|
9292
|
+
};
|
|
9217
9293
|
var useLanguage = () => {
|
|
9218
9294
|
const context = useContext2(LocaleContext);
|
|
9219
9295
|
if (!context) {
|
|
@@ -15418,9 +15494,7 @@ var timesInSeconds = {
|
|
|
15418
15494
|
day: 86400,
|
|
15419
15495
|
week: 604800,
|
|
15420
15496
|
monthImprecise: 2629800,
|
|
15421
|
-
// 30.4375 days
|
|
15422
15497
|
yearImprecise: 31557600
|
|
15423
|
-
// 365.25 days
|
|
15424
15498
|
};
|
|
15425
15499
|
var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
15426
15500
|
var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
@@ -15523,6 +15597,73 @@ var withTime = (datePart, timePart) => {
|
|
|
15523
15597
|
);
|
|
15524
15598
|
return out;
|
|
15525
15599
|
};
|
|
15600
|
+
var zonedPartsFormatterCache = /* @__PURE__ */ new Map();
|
|
15601
|
+
var zonedPartsFormatter = (timeZone) => {
|
|
15602
|
+
let formatter = zonedPartsFormatterCache.get(timeZone);
|
|
15603
|
+
if (!formatter) {
|
|
15604
|
+
formatter = new Intl.DateTimeFormat("en-US", {
|
|
15605
|
+
timeZone,
|
|
15606
|
+
hourCycle: "h23",
|
|
15607
|
+
year: "numeric",
|
|
15608
|
+
month: "2-digit",
|
|
15609
|
+
day: "2-digit",
|
|
15610
|
+
hour: "2-digit",
|
|
15611
|
+
minute: "2-digit",
|
|
15612
|
+
second: "2-digit"
|
|
15613
|
+
});
|
|
15614
|
+
zonedPartsFormatterCache.set(timeZone, formatter);
|
|
15615
|
+
}
|
|
15616
|
+
return formatter;
|
|
15617
|
+
};
|
|
15618
|
+
var zonedParts = (date, timeZone) => {
|
|
15619
|
+
const parts = {};
|
|
15620
|
+
for (const part of zonedPartsFormatter(timeZone).formatToParts(date)) {
|
|
15621
|
+
if (part.type !== "literal") {
|
|
15622
|
+
parts[part.type] = part.value;
|
|
15623
|
+
}
|
|
15624
|
+
}
|
|
15625
|
+
return {
|
|
15626
|
+
year: Number(parts.year),
|
|
15627
|
+
month: Number(parts.month),
|
|
15628
|
+
day: Number(parts.day),
|
|
15629
|
+
hour: Number(parts.hour) % 24,
|
|
15630
|
+
minute: Number(parts.minute),
|
|
15631
|
+
second: Number(parts.second),
|
|
15632
|
+
millisecond: date.getMilliseconds()
|
|
15633
|
+
};
|
|
15634
|
+
};
|
|
15635
|
+
var zoneOffsetMs = (date, timeZone) => {
|
|
15636
|
+
const parts = zonedParts(date, timeZone);
|
|
15637
|
+
const asUtc = Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second, parts.millisecond);
|
|
15638
|
+
return asUtc - date.getTime();
|
|
15639
|
+
};
|
|
15640
|
+
function toZonedDate(date, timeZone) {
|
|
15641
|
+
if (!date || !timeZone) {
|
|
15642
|
+
return date;
|
|
15643
|
+
}
|
|
15644
|
+
const parts = zonedParts(date, timeZone);
|
|
15645
|
+
return new Date(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second, parts.millisecond);
|
|
15646
|
+
}
|
|
15647
|
+
function fromZonedDate(date, timeZone) {
|
|
15648
|
+
if (!date || !timeZone) {
|
|
15649
|
+
return date;
|
|
15650
|
+
}
|
|
15651
|
+
const asUtc = Date.UTC(
|
|
15652
|
+
date.getFullYear(),
|
|
15653
|
+
date.getMonth(),
|
|
15654
|
+
date.getDate(),
|
|
15655
|
+
date.getHours(),
|
|
15656
|
+
date.getMinutes(),
|
|
15657
|
+
date.getSeconds(),
|
|
15658
|
+
date.getMilliseconds()
|
|
15659
|
+
);
|
|
15660
|
+
let offset = zoneOffsetMs(new Date(asUtc), timeZone);
|
|
15661
|
+
const refined = zoneOffsetMs(new Date(asUtc - offset), timeZone);
|
|
15662
|
+
if (refined !== offset) {
|
|
15663
|
+
offset = refined;
|
|
15664
|
+
}
|
|
15665
|
+
return new Date(asUtc - offset);
|
|
15666
|
+
}
|
|
15526
15667
|
var weeksForCalenderMonth = (date, weekStart, weeks = 6) => {
|
|
15527
15668
|
const month = date.getMonth();
|
|
15528
15669
|
const year = date.getFullYear();
|
|
@@ -15540,8 +15681,13 @@ var weeksForCalenderMonth = (date, weekStart, weeks = 6) => {
|
|
|
15540
15681
|
}
|
|
15541
15682
|
return equalSizeGroups(dayList, 7);
|
|
15542
15683
|
};
|
|
15543
|
-
var formatAbsolute = (date, locale, format) => {
|
|
15684
|
+
var formatAbsolute = (date, locale, format, { timeZone, is24HourFormat = true } = {}) => {
|
|
15544
15685
|
let options;
|
|
15686
|
+
const timeOptions = {
|
|
15687
|
+
hour: "2-digit",
|
|
15688
|
+
minute: "2-digit",
|
|
15689
|
+
hourCycle: is24HourFormat ? "h23" : "h12"
|
|
15690
|
+
};
|
|
15545
15691
|
switch (format) {
|
|
15546
15692
|
case "date":
|
|
15547
15693
|
options = {
|
|
@@ -15552,8 +15698,7 @@ var formatAbsolute = (date, locale, format) => {
|
|
|
15552
15698
|
break;
|
|
15553
15699
|
case "time":
|
|
15554
15700
|
options = {
|
|
15555
|
-
|
|
15556
|
-
minute: "2-digit"
|
|
15701
|
+
...timeOptions
|
|
15557
15702
|
};
|
|
15558
15703
|
break;
|
|
15559
15704
|
case "dateTime":
|
|
@@ -15561,12 +15706,11 @@ var formatAbsolute = (date, locale, format) => {
|
|
|
15561
15706
|
year: "numeric",
|
|
15562
15707
|
month: "2-digit",
|
|
15563
15708
|
day: "2-digit",
|
|
15564
|
-
|
|
15565
|
-
minute: "2-digit"
|
|
15709
|
+
...timeOptions
|
|
15566
15710
|
};
|
|
15567
15711
|
break;
|
|
15568
15712
|
}
|
|
15569
|
-
return new Intl.DateTimeFormat(locale, options).format(date);
|
|
15713
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone }).format(date);
|
|
15570
15714
|
};
|
|
15571
15715
|
var formatRelative = (date, locale) => {
|
|
15572
15716
|
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
@@ -15643,6 +15787,9 @@ var DateUtils = {
|
|
|
15643
15787
|
daysInMonth,
|
|
15644
15788
|
sameTime,
|
|
15645
15789
|
withTime,
|
|
15790
|
+
zonedParts,
|
|
15791
|
+
toZonedDate,
|
|
15792
|
+
fromZonedDate,
|
|
15646
15793
|
formatAbsolute,
|
|
15647
15794
|
formatRelative,
|
|
15648
15795
|
addDuration,
|
|
@@ -15653,9 +15800,6 @@ var DateUtils = {
|
|
|
15653
15800
|
toInputString,
|
|
15654
15801
|
tryParseDate,
|
|
15655
15802
|
toOnlyDate: normalizeToDateOnly,
|
|
15656
|
-
/**
|
|
15657
|
-
* Normalizes a datetime by removing seconds and milliseconds.
|
|
15658
|
-
*/
|
|
15659
15803
|
toDateTimeOnly: normalizeDatetime
|
|
15660
15804
|
};
|
|
15661
15805
|
|
|
@@ -16522,13 +16666,15 @@ var TimePicker = ({
|
|
|
16522
16666
|
initialValue = /* @__PURE__ */ new Date(),
|
|
16523
16667
|
onValueChange,
|
|
16524
16668
|
onEditComplete,
|
|
16525
|
-
is24HourFormat
|
|
16669
|
+
is24HourFormat: is24HourFormatOverride,
|
|
16526
16670
|
minuteIncrement = "5min",
|
|
16527
16671
|
secondIncrement = "5s",
|
|
16528
16672
|
millisecondIncrement = "100ms",
|
|
16529
16673
|
precision = "minute",
|
|
16530
16674
|
className
|
|
16531
16675
|
}) => {
|
|
16676
|
+
const { is24HourFormat: contextIs24HourFormat } = useDateTimeFormat();
|
|
16677
|
+
const is24HourFormat = is24HourFormatOverride ?? contextIs24HourFormat;
|
|
16532
16678
|
const [value, setValue] = useControlledState({
|
|
16533
16679
|
value: controlledValue,
|
|
16534
16680
|
onValueChange,
|
|
@@ -17525,19 +17671,14 @@ var DateTimeField = forwardRef18(function DateTimeField2({
|
|
|
17525
17671
|
...props
|
|
17526
17672
|
}, forwardedRef) {
|
|
17527
17673
|
const translation = useHightideTranslation();
|
|
17528
|
-
const { locale: contextLocale } = useLocale();
|
|
17674
|
+
const { locale: contextLocale, is24HourFormat: contextIs24HourFormat } = useLocale();
|
|
17529
17675
|
const locale = localeOverride ?? contextLocale;
|
|
17530
17676
|
const [value, setValue] = useControlledState({
|
|
17531
17677
|
value: controlledValue,
|
|
17532
17678
|
onValueChange,
|
|
17533
17679
|
defaultValue: initialValue
|
|
17534
17680
|
});
|
|
17535
|
-
const is24Hour =
|
|
17536
|
-
if (is24HourFormat !== void 0) {
|
|
17537
|
-
return is24HourFormat;
|
|
17538
|
-
}
|
|
17539
|
-
return !new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hour12;
|
|
17540
|
-
}, [is24HourFormat, locale]);
|
|
17681
|
+
const is24Hour = is24HourFormat ?? contextIs24HourFormat ?? true;
|
|
17541
17682
|
const layout = useMemo30(
|
|
17542
17683
|
() => buildSegmentLayout({ locale, mode, precision, is24HourFormat: is24Hour }),
|
|
17543
17684
|
[locale, mode, precision, is24Hour]
|
|
@@ -17568,6 +17709,9 @@ var DateTimeField = forwardRef18(function DateTimeField2({
|
|
|
17568
17709
|
return callback;
|
|
17569
17710
|
};
|
|
17570
17711
|
useEffect36(() => {
|
|
17712
|
+
if (editStateRef.current.buffer) {
|
|
17713
|
+
return;
|
|
17714
|
+
}
|
|
17571
17715
|
const shown = composeDate(editStateRef.current.values, layout, mode, is24Hour, value ?? void 0);
|
|
17572
17716
|
if ((shown?.getTime() ?? null) === (value?.getTime() ?? null)) {
|
|
17573
17717
|
return;
|
|
@@ -17579,6 +17723,9 @@ var DateTimeField = forwardRef18(function DateTimeField2({
|
|
|
17579
17723
|
}, [value, layout, mode, is24Hour]);
|
|
17580
17724
|
const apply = (next) => {
|
|
17581
17725
|
setEditState(next);
|
|
17726
|
+
if (next.buffer?.type === "year") {
|
|
17727
|
+
return;
|
|
17728
|
+
}
|
|
17582
17729
|
const composed = composeDate(next.values, layout, mode, is24Hour, value ?? void 0);
|
|
17583
17730
|
if (composed) {
|
|
17584
17731
|
setValue(composed);
|
|
@@ -17675,6 +17822,10 @@ var DateTimeField = forwardRef18(function DateTimeField2({
|
|
|
17675
17822
|
const onFieldBlur = (event) => {
|
|
17676
17823
|
props.onBlur?.(event);
|
|
17677
17824
|
const field = event.currentTarget;
|
|
17825
|
+
const nextFocus = event.relatedTarget;
|
|
17826
|
+
if (nextFocus instanceof Node && field.contains(nextFocus)) {
|
|
17827
|
+
return;
|
|
17828
|
+
}
|
|
17678
17829
|
requestAnimationFrame(() => {
|
|
17679
17830
|
if (field.contains(document.activeElement)) {
|
|
17680
17831
|
return;
|
|
@@ -17683,6 +17834,9 @@ var DateTimeField = forwardRef18(function DateTimeField2({
|
|
|
17683
17834
|
const composed = composeDate(editStateRef.current.values, layout, mode, is24Hour, value ?? void 0);
|
|
17684
17835
|
if (composed) {
|
|
17685
17836
|
setEditState({ values: decomposeDate(composed, layout, is24Hour), buffer: null });
|
|
17837
|
+
if (composed.getTime() !== (value?.getTime() ?? null)) {
|
|
17838
|
+
setValue(composed);
|
|
17839
|
+
}
|
|
17686
17840
|
onEditComplete?.(composed);
|
|
17687
17841
|
} else {
|
|
17688
17842
|
onEditComplete?.(value ?? null);
|
|
@@ -17757,6 +17911,7 @@ var DateTimeInput = forwardRef19(function DateTimeInput2({
|
|
|
17757
17911
|
allowClear = true,
|
|
17758
17912
|
containerProps,
|
|
17759
17913
|
mode = "date",
|
|
17914
|
+
timeZone: timeZoneOverride,
|
|
17760
17915
|
precision = "minute",
|
|
17761
17916
|
pickerProps,
|
|
17762
17917
|
outsideClickCloses = true,
|
|
@@ -17777,6 +17932,8 @@ var DateTimeInput = forwardRef19(function DateTimeInput2({
|
|
|
17777
17932
|
...props
|
|
17778
17933
|
}, forwardedRef) {
|
|
17779
17934
|
const translation = useHightideTranslation();
|
|
17935
|
+
const { timeZone: contextTimeZone } = useLocale();
|
|
17936
|
+
const timeZone = timeZoneOverride ?? contextTimeZone;
|
|
17780
17937
|
const [isOpen, setIsOpen] = useState31(false);
|
|
17781
17938
|
const [state, setState] = useControlledState({
|
|
17782
17939
|
value,
|
|
@@ -17788,6 +17945,8 @@ var DateTimeInput = forwardRef19(function DateTimeInput2({
|
|
|
17788
17945
|
onDialogOpeningChange?.(isOpen2);
|
|
17789
17946
|
setIsOpen(isOpen2);
|
|
17790
17947
|
}, [onDialogOpeningChange]);
|
|
17948
|
+
const toZoned = useCallback31((date) => DateUtils.toZonedDate(date, timeZone), [timeZone]);
|
|
17949
|
+
const fromZoned = useCallback31((date) => DateUtils.fromZonedDate(date, timeZone), [timeZone]);
|
|
17791
17950
|
const generatedId = useId16();
|
|
17792
17951
|
const ids = useMemo31(() => ({
|
|
17793
17952
|
input: inputId ?? `date-time-input-${generatedId}`,
|
|
@@ -17834,7 +17993,7 @@ var DateTimeInput = forwardRef19(function DateTimeInput2({
|
|
|
17834
17993
|
DateTimeField,
|
|
17835
17994
|
{
|
|
17836
17995
|
ref: fieldRef,
|
|
17837
|
-
value: state,
|
|
17996
|
+
value: toZoned(state),
|
|
17838
17997
|
mode,
|
|
17839
17998
|
precision,
|
|
17840
17999
|
is24HourFormat,
|
|
@@ -17842,8 +18001,8 @@ var DateTimeInput = forwardRef19(function DateTimeInput2({
|
|
|
17842
18001
|
readOnly,
|
|
17843
18002
|
invalid,
|
|
17844
18003
|
required,
|
|
17845
|
-
onValueChange: setState,
|
|
17846
|
-
onEditComplete,
|
|
18004
|
+
onValueChange: (next) => setState(fromZoned(next)),
|
|
18005
|
+
onEditComplete: (next) => onEditComplete?.(fromZoned(next)),
|
|
17847
18006
|
"aria-labelledby": props["aria-labelledby"],
|
|
17848
18007
|
"aria-describedby": props["aria-describedby"],
|
|
17849
18008
|
className: "grow"
|
|
@@ -17908,18 +18067,19 @@ var DateTimeInput = forwardRef19(function DateTimeInput2({
|
|
|
17908
18067
|
children: /* @__PURE__ */ jsx73(
|
|
17909
18068
|
DateTimePickerDialog,
|
|
17910
18069
|
{
|
|
17911
|
-
value: dialogValue,
|
|
18070
|
+
value: toZoned(dialogValue),
|
|
17912
18071
|
allowRemove,
|
|
17913
|
-
onValueChange: setDialogValue,
|
|
18072
|
+
onValueChange: (value2) => setDialogValue(fromZoned(value2)),
|
|
17914
18073
|
onEditComplete: (value2) => {
|
|
17915
|
-
|
|
17916
|
-
|
|
18074
|
+
const absolute = fromZoned(value2);
|
|
18075
|
+
setState(absolute);
|
|
18076
|
+
onEditComplete?.(absolute);
|
|
17917
18077
|
changeOpenWrapper(false);
|
|
17918
18078
|
},
|
|
17919
18079
|
pickerProps,
|
|
17920
18080
|
mode,
|
|
17921
|
-
start,
|
|
17922
|
-
end,
|
|
18081
|
+
start: toZoned(start ?? null) ?? void 0,
|
|
18082
|
+
end: toZoned(end ?? null) ?? void 0,
|
|
17923
18083
|
weekStart,
|
|
17924
18084
|
markToday,
|
|
17925
18085
|
is24HourFormat,
|
|
@@ -21452,10 +21612,18 @@ var SortingList = ({ sorting, onSortingChange, availableItems }) => {
|
|
|
21452
21612
|
import { jsx as jsx103 } from "react/jsx-runtime";
|
|
21453
21613
|
var TimeDisplay = ({
|
|
21454
21614
|
date,
|
|
21455
|
-
mode = "daysFromToday"
|
|
21615
|
+
mode = "daysFromToday",
|
|
21616
|
+
is24HourFormat: is24HourFormatOverride,
|
|
21617
|
+
timeZone: timeZoneOverride
|
|
21456
21618
|
}) => {
|
|
21457
21619
|
const translation = useHightideTranslation();
|
|
21458
|
-
const
|
|
21620
|
+
const { locale } = useLocale();
|
|
21621
|
+
const { is24HourFormat: contextIs24HourFormat, timeZone: contextTimeZone } = useDateTimeFormat();
|
|
21622
|
+
const is24HourFormat = is24HourFormatOverride ?? contextIs24HourFormat;
|
|
21623
|
+
const timeZone = timeZoneOverride ?? contextTimeZone;
|
|
21624
|
+
const zonedDate = DateUtils.toZonedDate(date, timeZone);
|
|
21625
|
+
const zonedNow = DateUtils.toZonedDate(/* @__PURE__ */ new Date(), timeZone);
|
|
21626
|
+
const difference = new Date(zonedNow).setHours(0, 0, 0, 0).valueOf() - new Date(zonedDate).setHours(0, 0, 0, 0).valueOf();
|
|
21459
21627
|
const isBefore = difference > 0;
|
|
21460
21628
|
const differenceInDays = Math.floor(Math.abs(difference) / (1e3 * 3600 * 24));
|
|
21461
21629
|
let displayString;
|
|
@@ -21482,9 +21650,15 @@ var TimeDisplay = ({
|
|
|
21482
21650
|
};
|
|
21483
21651
|
let fullString;
|
|
21484
21652
|
if (mode === "daysFromToday") {
|
|
21485
|
-
|
|
21653
|
+
const timeString = new Intl.DateTimeFormat(locale, {
|
|
21654
|
+
hour: "2-digit",
|
|
21655
|
+
minute: "2-digit",
|
|
21656
|
+
hourCycle: is24HourFormat ? "h23" : "h12",
|
|
21657
|
+
timeZone
|
|
21658
|
+
}).format(date);
|
|
21659
|
+
fullString = `${timeString} - ${displayString}`;
|
|
21486
21660
|
} else {
|
|
21487
|
-
fullString = `${
|
|
21661
|
+
fullString = `${zonedDate.getDate()}. ${monthToTranslation[zonedDate.getMonth()]} ${zonedDate.getFullYear()}`;
|
|
21488
21662
|
}
|
|
21489
21663
|
return /* @__PURE__ */ jsx103("span", { children: fullString });
|
|
21490
21664
|
};
|
|
@@ -21499,29 +21673,36 @@ var FlexibleDateTimeInput = forwardRef31(function FlexibleDateTimeInput2({
|
|
|
21499
21673
|
initialValue,
|
|
21500
21674
|
onValueChange,
|
|
21501
21675
|
fixedTime: fixedTimeOverride,
|
|
21676
|
+
timeZone: timeZoneOverride,
|
|
21502
21677
|
actions = [],
|
|
21503
21678
|
...props
|
|
21504
21679
|
}, forwardedRef) {
|
|
21505
21680
|
const translation = useHightideTranslation();
|
|
21681
|
+
const { timeZone: contextTimeZone } = useLocale();
|
|
21682
|
+
const timeZone = timeZoneOverride ?? contextTimeZone;
|
|
21506
21683
|
const fixedTime = fixedTimeOverride ?? new Date(1970, 0, 1, 23, 59, 59, 999);
|
|
21507
21684
|
const [value, setValue] = useControlledState({
|
|
21508
21685
|
value: controlledValue,
|
|
21509
21686
|
onValueChange,
|
|
21510
21687
|
defaultValue: initialValue
|
|
21511
21688
|
});
|
|
21689
|
+
const zoned = (date) => DateUtils.toZonedDate(date, timeZone);
|
|
21690
|
+
const unzoned = (date) => DateUtils.fromZonedDate(date, timeZone);
|
|
21691
|
+
const hasFixedTime = (date) => DateUtils.sameTime(zoned(date), fixedTime, true, true);
|
|
21512
21692
|
const [mode, setMode] = useState42(() => {
|
|
21513
|
-
if (value && !
|
|
21693
|
+
if (value && !hasFixedTime(value)) {
|
|
21514
21694
|
return "dateTime";
|
|
21515
21695
|
}
|
|
21516
21696
|
return defaultMode;
|
|
21517
21697
|
});
|
|
21518
|
-
const toDate = (date) => DateUtils.withTime(date, fixedTime);
|
|
21519
|
-
const toDateTime = (date) =>
|
|
21698
|
+
const toDate = (date) => unzoned(DateUtils.withTime(zoned(date), fixedTime));
|
|
21699
|
+
const toDateTime = (date) => hasFixedTime(date) ? unzoned(DateUtils.withTime(zoned(date), zoned(/* @__PURE__ */ new Date()))) : date;
|
|
21520
21700
|
return /* @__PURE__ */ jsx104(
|
|
21521
21701
|
DateTimeInput,
|
|
21522
21702
|
{
|
|
21523
21703
|
...props,
|
|
21524
21704
|
ref: forwardedRef,
|
|
21705
|
+
timeZone,
|
|
21525
21706
|
mode,
|
|
21526
21707
|
value,
|
|
21527
21708
|
onValueChange: (next) => {
|
|
@@ -21860,26 +22041,46 @@ var CheckboxProperty = ({
|
|
|
21860
22041
|
import { CalendarDays } from "lucide-react";
|
|
21861
22042
|
import { jsx as jsx110 } from "react/jsx-runtime";
|
|
21862
22043
|
var DateProperty = ({
|
|
22044
|
+
name,
|
|
21863
22045
|
value,
|
|
21864
22046
|
onValueChange,
|
|
21865
22047
|
onEditComplete,
|
|
22048
|
+
onRemove,
|
|
22049
|
+
onValueClear,
|
|
22050
|
+
required,
|
|
21866
22051
|
readOnly,
|
|
22052
|
+
allowClear = true,
|
|
22053
|
+
allowRemove = true,
|
|
21867
22054
|
type = "dateTime",
|
|
21868
|
-
|
|
22055
|
+
className,
|
|
22056
|
+
...inputProps
|
|
21869
22057
|
}) => {
|
|
21870
22058
|
const hasValue = !!value;
|
|
21871
22059
|
return /* @__PURE__ */ jsx110(
|
|
21872
22060
|
PropertyBase,
|
|
21873
22061
|
{
|
|
21874
|
-
|
|
22062
|
+
name,
|
|
22063
|
+
required,
|
|
22064
|
+
readOnly,
|
|
22065
|
+
allowClear,
|
|
22066
|
+
allowRemove,
|
|
22067
|
+
onRemove,
|
|
22068
|
+
onValueClear: onValueClear ?? (() => {
|
|
22069
|
+
onValueChange?.(null);
|
|
22070
|
+
onEditComplete?.(null);
|
|
22071
|
+
}),
|
|
21875
22072
|
hasValue,
|
|
21876
22073
|
icon: /* @__PURE__ */ jsx110(CalendarDays, { size: 24 }),
|
|
22074
|
+
className,
|
|
21877
22075
|
children: ({ invalid }) => /* @__PURE__ */ jsx110(
|
|
21878
22076
|
DateTimeInput,
|
|
21879
22077
|
{
|
|
22078
|
+
...inputProps,
|
|
21880
22079
|
value,
|
|
21881
22080
|
mode: type,
|
|
22081
|
+
required,
|
|
21882
22082
|
readOnly,
|
|
22083
|
+
allowClear: false,
|
|
21883
22084
|
onValueChange,
|
|
21884
22085
|
onEditComplete,
|
|
21885
22086
|
"data-name": "property-input",
|
|
@@ -22301,21 +22502,23 @@ var useRerender = () => {
|
|
|
22301
22502
|
|
|
22302
22503
|
// src/hooks/useUpdatingDateString.ts
|
|
22303
22504
|
import { useEffect as useEffect58, useState as useState48 } from "react";
|
|
22304
|
-
var useUpdatingDateString = ({ absoluteFormat = "dateTime", localeOverride, date }) => {
|
|
22305
|
-
const { locale: contextLocale } = useLocale();
|
|
22505
|
+
var useUpdatingDateString = ({ absoluteFormat = "dateTime", localeOverride, is24HourFormat: is24HourFormatOverride, timeZone: timeZoneOverride, date }) => {
|
|
22506
|
+
const { locale: contextLocale, is24HourFormat: contextIs24HourFormat, timeZone: contextTimeZone } = useLocale();
|
|
22306
22507
|
const locale = localeOverride ?? contextLocale;
|
|
22508
|
+
const is24HourFormat = is24HourFormatOverride ?? contextIs24HourFormat ?? true;
|
|
22509
|
+
const timeZone = timeZoneOverride ?? contextTimeZone;
|
|
22307
22510
|
const [dateAndTimeStrings, setDateAndTimeStrings] = useState48({
|
|
22308
22511
|
compareDate: date,
|
|
22309
|
-
absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat),
|
|
22512
|
+
absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat, { is24HourFormat, timeZone }),
|
|
22310
22513
|
relative: DateUtils.formatRelative(date, locale)
|
|
22311
22514
|
});
|
|
22312
22515
|
useEffect58(() => {
|
|
22313
22516
|
setDateAndTimeStrings({
|
|
22314
22517
|
compareDate: date,
|
|
22315
|
-
absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat),
|
|
22518
|
+
absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat, { is24HourFormat, timeZone }),
|
|
22316
22519
|
relative: DateUtils.formatRelative(date, locale)
|
|
22317
22520
|
});
|
|
22318
|
-
}, [date, absoluteFormat, locale]);
|
|
22521
|
+
}, [date, absoluteFormat, locale, is24HourFormat, timeZone]);
|
|
22319
22522
|
useEffect58(() => {
|
|
22320
22523
|
let timeoutId;
|
|
22321
22524
|
const startTimer = () => {
|
|
@@ -22332,14 +22535,14 @@ var useUpdatingDateString = ({ absoluteFormat = "dateTime", localeOverride, date
|
|
|
22332
22535
|
timeoutId = setInterval(() => {
|
|
22333
22536
|
setDateAndTimeStrings({
|
|
22334
22537
|
compareDate: date,
|
|
22335
|
-
absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat),
|
|
22538
|
+
absolute: DateUtils.formatAbsolute(date, locale, absoluteFormat, { is24HourFormat, timeZone }),
|
|
22336
22539
|
relative: DateUtils.formatRelative(date, locale)
|
|
22337
22540
|
});
|
|
22338
22541
|
}, delayInSeconds * 1e3 / 2);
|
|
22339
22542
|
};
|
|
22340
22543
|
startTimer();
|
|
22341
22544
|
return () => clearInterval(timeoutId);
|
|
22342
|
-
}, [absoluteFormat, date, locale]);
|
|
22545
|
+
}, [absoluteFormat, date, locale, is24HourFormat, timeZone]);
|
|
22343
22546
|
return {
|
|
22344
22547
|
absolute: dateAndTimeStrings.absolute,
|
|
22345
22548
|
relative: dateAndTimeStrings.relative
|
|
@@ -22901,6 +23104,7 @@ export {
|
|
|
22901
23104
|
useComboboxContext,
|
|
22902
23105
|
useControlledState,
|
|
22903
23106
|
useCreateForm,
|
|
23107
|
+
useDateTimeFormat,
|
|
22904
23108
|
useDelay,
|
|
22905
23109
|
useDialogContext,
|
|
22906
23110
|
useDrawerContext,
|
|
@@ -22948,6 +23152,7 @@ export {
|
|
|
22948
23152
|
useTableStateContext,
|
|
22949
23153
|
useTableStateWithoutSizingContext,
|
|
22950
23154
|
useTheme,
|
|
23155
|
+
useTimeZone,
|
|
22951
23156
|
useTooltip,
|
|
22952
23157
|
useTransitionState,
|
|
22953
23158
|
useTranslatedValidators,
|