@helpwave/hightide 0.8.10 → 0.8.11
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 +293 -296
- package/dist/index.d.ts +293 -296
- package/dist/index.js +166 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +206 -67
- package/dist/index.mjs.map +1 -1
- package/dist/style/globals.css +1 -1
- package/dist/style/uncompiled/theme/components/time-picker.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14655,6 +14655,9 @@ var TimePicker = ({
|
|
|
14655
14655
|
onEditComplete,
|
|
14656
14656
|
is24HourFormat = true,
|
|
14657
14657
|
minuteIncrement = "5min",
|
|
14658
|
+
secondIncrement = "5s",
|
|
14659
|
+
millisecondIncrement = "100ms",
|
|
14660
|
+
precision = "minute",
|
|
14658
14661
|
className
|
|
14659
14662
|
}) => {
|
|
14660
14663
|
const [value, setValue] = useControlledState({
|
|
@@ -14666,22 +14669,58 @@ var TimePicker = ({
|
|
|
14666
14669
|
const hourRef = (0, import_react64.useRef)(null);
|
|
14667
14670
|
const isPM = value.getHours() > 11;
|
|
14668
14671
|
const hours = is24HourFormat ? range(24) : range(12);
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
|
|
14680
|
-
|
|
14681
|
-
|
|
14682
|
-
|
|
14683
|
-
|
|
14684
|
-
|
|
14672
|
+
const minutes = (0, import_react64.useMemo)(() => {
|
|
14673
|
+
const full = range(60);
|
|
14674
|
+
switch (minuteIncrement) {
|
|
14675
|
+
case "5min":
|
|
14676
|
+
return full.filter((value2) => value2 % 5 === 0);
|
|
14677
|
+
case "10min":
|
|
14678
|
+
return full.filter((value2) => value2 % 10 === 0);
|
|
14679
|
+
case "15min":
|
|
14680
|
+
return full.filter((value2) => value2 % 15 === 0);
|
|
14681
|
+
case "30min":
|
|
14682
|
+
return full.filter((value2) => value2 % 30 === 0);
|
|
14683
|
+
}
|
|
14684
|
+
}, [minuteIncrement]);
|
|
14685
|
+
const seconds = (0, import_react64.useMemo)(() => {
|
|
14686
|
+
const full = range(60);
|
|
14687
|
+
switch (secondIncrement) {
|
|
14688
|
+
case "1s":
|
|
14689
|
+
return full.filter((value2) => value2 % 1 === 0);
|
|
14690
|
+
case "5s":
|
|
14691
|
+
return full.filter((value2) => value2 % 5 === 0);
|
|
14692
|
+
case "10s":
|
|
14693
|
+
return full.filter((value2) => value2 % 10 === 0);
|
|
14694
|
+
case "15s":
|
|
14695
|
+
return full.filter((value2) => value2 % 15 === 0);
|
|
14696
|
+
case "30s":
|
|
14697
|
+
return full.filter((value2) => value2 % 30 === 0);
|
|
14698
|
+
}
|
|
14699
|
+
}, [secondIncrement]);
|
|
14700
|
+
const milliseconds = (0, import_react64.useMemo)(() => {
|
|
14701
|
+
const full = range(1e3);
|
|
14702
|
+
switch (millisecondIncrement) {
|
|
14703
|
+
case "1ms":
|
|
14704
|
+
return full.filter((value2) => value2 % 1 === 0);
|
|
14705
|
+
case "5ms":
|
|
14706
|
+
return full.filter((value2) => value2 % 5 === 0);
|
|
14707
|
+
case "10ms":
|
|
14708
|
+
return full.filter((value2) => value2 % 10 === 0);
|
|
14709
|
+
case "25ms":
|
|
14710
|
+
return full.filter((value2) => value2 % 25 === 0);
|
|
14711
|
+
case "50ms":
|
|
14712
|
+
return full.filter((value2) => value2 % 50 === 0);
|
|
14713
|
+
case "100ms":
|
|
14714
|
+
return full.filter((value2) => value2 % 100 === 0);
|
|
14715
|
+
case "250ms":
|
|
14716
|
+
return full.filter((value2) => value2 % 250 === 0);
|
|
14717
|
+
case "500ms":
|
|
14718
|
+
return full.filter((value2) => value2 % 500 === 0);
|
|
14719
|
+
}
|
|
14720
|
+
}, [millisecondIncrement]);
|
|
14721
|
+
const closestMinute = (0, import_react64.useMemo)(() => closestMatch(minutes, (item1, item2) => Math.abs(item1 - value.getMinutes()) < Math.abs(item2 - value.getMinutes())), [minutes, value]);
|
|
14722
|
+
const closestSecond = (0, import_react64.useMemo)(() => closestMatch(seconds, (item1, item2) => Math.abs(item1 - value.getSeconds()) < Math.abs(item2 - value.getSeconds())), [seconds, value]);
|
|
14723
|
+
const closestMillisecond = (0, import_react64.useMemo)(() => closestMatch(milliseconds, (item1, item2) => Math.abs(item1 - value.getMilliseconds()) < Math.abs(item2 - value.getMilliseconds())), [milliseconds, value]);
|
|
14685
14724
|
const hour = value.getHours();
|
|
14686
14725
|
(0, import_react64.useEffect)(() => {
|
|
14687
14726
|
minuteRef.current?.scrollIntoView({
|
|
@@ -14732,6 +14771,36 @@ var TimePicker = ({
|
|
|
14732
14771
|
minute + minuteIncrement
|
|
14733
14772
|
);
|
|
14734
14773
|
}) }),
|
|
14774
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Visibility, { isVisible: precision === "second" || precision === "millisecond", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { "data-name": "time-picker-value-column", children: seconds.map((second) => {
|
|
14775
|
+
const isSelected = second === closestSecond;
|
|
14776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
14777
|
+
Button,
|
|
14778
|
+
{
|
|
14779
|
+
size: "sm",
|
|
14780
|
+
color: isSelected ? "primary" : "neutral",
|
|
14781
|
+
ref: isSelected ? minuteRef : void 0,
|
|
14782
|
+
onClick: () => onChangeWrapper((newDate) => newDate.setSeconds(second)),
|
|
14783
|
+
className: "min-w-16",
|
|
14784
|
+
children: second.toString().padStart(2, "0")
|
|
14785
|
+
},
|
|
14786
|
+
second + secondIncrement
|
|
14787
|
+
);
|
|
14788
|
+
}) }) }),
|
|
14789
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Visibility, { isVisible: precision === "millisecond", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { "data-name": "time-picker-value-column", children: milliseconds.map((millisecond) => {
|
|
14790
|
+
const isSelected = millisecond === closestMillisecond;
|
|
14791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
14792
|
+
Button,
|
|
14793
|
+
{
|
|
14794
|
+
size: "sm",
|
|
14795
|
+
color: isSelected ? "primary" : "neutral",
|
|
14796
|
+
ref: isSelected ? minuteRef : void 0,
|
|
14797
|
+
onClick: () => onChangeWrapper((newDate) => newDate.setMilliseconds(millisecond)),
|
|
14798
|
+
className: "min-w-16",
|
|
14799
|
+
children: millisecond.toString().padStart(2, "0")
|
|
14800
|
+
},
|
|
14801
|
+
millisecond + millisecondIncrement
|
|
14802
|
+
);
|
|
14803
|
+
}) }) }),
|
|
14735
14804
|
!is24HourFormat && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { "data-name": "time-picker-value-column", children: [
|
|
14736
14805
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
14737
14806
|
Button,
|
|
@@ -14902,14 +14971,40 @@ var formatRelative = (date, locale) => {
|
|
|
14902
14971
|
if (Math.abs(diffInSeconds) < timesInSeconds.yearImprecise) return rtf.format(Math.round(diffInSeconds / timesInSeconds.monthImprecise), "month");
|
|
14903
14972
|
return rtf.format(Math.round(diffInSeconds / timesInSeconds.yearImprecise), "year");
|
|
14904
14973
|
};
|
|
14905
|
-
var toInputString = (date, format) => {
|
|
14974
|
+
var toInputString = (date, format, precision = "minute", isLocalTime = true) => {
|
|
14975
|
+
const pad = (n, l = 2) => String(n).padStart(l, "0");
|
|
14976
|
+
const parts = isLocalTime ? {
|
|
14977
|
+
y: date.getFullYear(),
|
|
14978
|
+
m: date.getMonth() + 1,
|
|
14979
|
+
d: date.getDate(),
|
|
14980
|
+
h: date.getHours(),
|
|
14981
|
+
min: date.getMinutes(),
|
|
14982
|
+
s: date.getSeconds(),
|
|
14983
|
+
ms: date.getMilliseconds()
|
|
14984
|
+
} : {
|
|
14985
|
+
y: date.getUTCFullYear(),
|
|
14986
|
+
m: date.getUTCMonth() + 1,
|
|
14987
|
+
d: date.getUTCDate(),
|
|
14988
|
+
h: date.getUTCHours(),
|
|
14989
|
+
min: date.getUTCMinutes(),
|
|
14990
|
+
s: date.getUTCSeconds(),
|
|
14991
|
+
ms: date.getUTCMilliseconds()
|
|
14992
|
+
};
|
|
14993
|
+
const dateStr = `${pad(parts.y, 4)}-${pad(parts.m)}-${pad(parts.d)}`;
|
|
14994
|
+
let timeStr = `${pad(parts.h)}:${pad(parts.min)}`;
|
|
14995
|
+
if (precision === "second" || precision === "millisecond") {
|
|
14996
|
+
timeStr += `:${pad(parts.s)}`;
|
|
14997
|
+
}
|
|
14998
|
+
if (precision === "millisecond") {
|
|
14999
|
+
timeStr += `.${pad(parts.ms, 3)}`;
|
|
15000
|
+
}
|
|
14906
15001
|
switch (format) {
|
|
14907
15002
|
case "date":
|
|
14908
|
-
return
|
|
15003
|
+
return dateStr;
|
|
14909
15004
|
case "time":
|
|
14910
|
-
return
|
|
15005
|
+
return timeStr;
|
|
14911
15006
|
case "dateTime":
|
|
14912
|
-
return
|
|
15007
|
+
return `${dateStr}T${timeStr}`;
|
|
14913
15008
|
}
|
|
14914
15009
|
};
|
|
14915
15010
|
var DateUtils = {
|
|
@@ -15026,7 +15121,8 @@ var DayPicker = ({
|
|
|
15026
15121
|
date.getDate(),
|
|
15027
15122
|
value.getHours(),
|
|
15028
15123
|
value.getMinutes(),
|
|
15029
|
-
value.getSeconds()
|
|
15124
|
+
value.getSeconds(),
|
|
15125
|
+
value.getMilliseconds()
|
|
15030
15126
|
);
|
|
15031
15127
|
setValue(newDate);
|
|
15032
15128
|
onEditComplete?.(newDate);
|
|
@@ -15300,6 +15396,9 @@ var DateTimePicker = ({
|
|
|
15300
15396
|
is24HourFormat,
|
|
15301
15397
|
minuteIncrement,
|
|
15302
15398
|
weekStart,
|
|
15399
|
+
secondIncrement,
|
|
15400
|
+
millisecondIncrement,
|
|
15401
|
+
precision,
|
|
15303
15402
|
onValueChange,
|
|
15304
15403
|
onEditComplete,
|
|
15305
15404
|
timePickerProps,
|
|
@@ -15337,6 +15436,9 @@ var DateTimePicker = ({
|
|
|
15337
15436
|
...timePickerProps,
|
|
15338
15437
|
is24HourFormat,
|
|
15339
15438
|
minuteIncrement,
|
|
15439
|
+
secondIncrement,
|
|
15440
|
+
millisecondIncrement,
|
|
15441
|
+
precision,
|
|
15340
15442
|
value,
|
|
15341
15443
|
onValueChange: setValue,
|
|
15342
15444
|
onEditComplete
|
|
@@ -15359,6 +15461,15 @@ var DateTimePickerDialog = ({
|
|
|
15359
15461
|
onEditComplete,
|
|
15360
15462
|
mode = "date",
|
|
15361
15463
|
pickerProps,
|
|
15464
|
+
start,
|
|
15465
|
+
end,
|
|
15466
|
+
weekStart,
|
|
15467
|
+
markToday,
|
|
15468
|
+
is24HourFormat,
|
|
15469
|
+
minuteIncrement,
|
|
15470
|
+
secondIncrement,
|
|
15471
|
+
millisecondIncrement,
|
|
15472
|
+
precision,
|
|
15362
15473
|
labelId,
|
|
15363
15474
|
label
|
|
15364
15475
|
}) => {
|
|
@@ -15384,7 +15495,16 @@ var DateTimePickerDialog = ({
|
|
|
15384
15495
|
mode,
|
|
15385
15496
|
value: state,
|
|
15386
15497
|
onValueChange: setState,
|
|
15387
|
-
onEditComplete: setState
|
|
15498
|
+
onEditComplete: setState,
|
|
15499
|
+
start,
|
|
15500
|
+
end,
|
|
15501
|
+
weekStart,
|
|
15502
|
+
markToday,
|
|
15503
|
+
is24HourFormat,
|
|
15504
|
+
minuteIncrement,
|
|
15505
|
+
secondIncrement,
|
|
15506
|
+
millisecondIncrement,
|
|
15507
|
+
precision
|
|
15388
15508
|
}
|
|
15389
15509
|
),
|
|
15390
15510
|
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "flex-row-2 justify-end", children: [
|
|
@@ -15809,6 +15929,15 @@ var DateTimeInput = (0, import_react78.forwardRef)(function DateTimeInput2({
|
|
|
15809
15929
|
pickerProps,
|
|
15810
15930
|
outsideClickCloses = true,
|
|
15811
15931
|
onDialogOpeningChange,
|
|
15932
|
+
start,
|
|
15933
|
+
end,
|
|
15934
|
+
weekStart,
|
|
15935
|
+
markToday,
|
|
15936
|
+
is24HourFormat,
|
|
15937
|
+
minuteIncrement,
|
|
15938
|
+
secondIncrement,
|
|
15939
|
+
millisecondIncrement,
|
|
15940
|
+
precision,
|
|
15812
15941
|
disabled = false,
|
|
15813
15942
|
readOnly = false,
|
|
15814
15943
|
invalid = false,
|
|
@@ -15824,7 +15953,7 @@ var DateTimeInput = (0, import_react78.forwardRef)(function DateTimeInput2({
|
|
|
15824
15953
|
});
|
|
15825
15954
|
const [dialogValue, setDialogValue] = (0, import_react78.useState)(state ?? /* @__PURE__ */ new Date());
|
|
15826
15955
|
const [stringInputState, setStringInputState] = (0, import_react78.useState)({
|
|
15827
|
-
state: state ? DateUtils.toInputString(state, mode) : "",
|
|
15956
|
+
state: state ? DateUtils.toInputString(state, mode, precision) : "",
|
|
15828
15957
|
date: void 0
|
|
15829
15958
|
});
|
|
15830
15959
|
(0, import_react78.useEffect)(() => {
|
|
@@ -15865,8 +15994,9 @@ var DateTimeInput = (0, import_react78.forwardRef)(function DateTimeInput2({
|
|
|
15865
15994
|
id: ids.input,
|
|
15866
15995
|
value: stringInputState.state,
|
|
15867
15996
|
onChange: (event) => {
|
|
15868
|
-
const date = event.target.
|
|
15869
|
-
|
|
15997
|
+
const date = new Date(event.target.value ?? "");
|
|
15998
|
+
const isValid = !isNaN(date.getTime());
|
|
15999
|
+
if (isValid) {
|
|
15870
16000
|
restartTimer(() => {
|
|
15871
16001
|
innerRef.current?.blur();
|
|
15872
16002
|
setState(date);
|
|
@@ -15877,7 +16007,7 @@ var DateTimeInput = (0, import_react78.forwardRef)(function DateTimeInput2({
|
|
|
15877
16007
|
}
|
|
15878
16008
|
setStringInputState({
|
|
15879
16009
|
state: event.target.value,
|
|
15880
|
-
date:
|
|
16010
|
+
date: isValid ? date : void 0
|
|
15881
16011
|
});
|
|
15882
16012
|
},
|
|
15883
16013
|
onBlur: (event) => {
|
|
@@ -15953,7 +16083,16 @@ var DateTimeInput = (0, import_react78.forwardRef)(function DateTimeInput2({
|
|
|
15953
16083
|
changeOpenWrapper(false);
|
|
15954
16084
|
},
|
|
15955
16085
|
pickerProps,
|
|
15956
|
-
mode
|
|
16086
|
+
mode,
|
|
16087
|
+
start,
|
|
16088
|
+
end,
|
|
16089
|
+
weekStart,
|
|
16090
|
+
markToday,
|
|
16091
|
+
is24HourFormat,
|
|
16092
|
+
minuteIncrement,
|
|
16093
|
+
secondIncrement,
|
|
16094
|
+
millisecondIncrement,
|
|
16095
|
+
precision
|
|
15957
16096
|
}
|
|
15958
16097
|
)
|
|
15959
16098
|
}
|