@norges-domstoler/dds-components 21.17.0 → 21.17.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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -6733,6 +6733,36 @@ DatePicker.displayName = "DatePicker";
|
|
|
6733
6733
|
import { useTimeField } from "@react-aria/datepicker";
|
|
6734
6734
|
import { useTimeFieldState } from "@react-stately/datepicker";
|
|
6735
6735
|
import { useRef as useRef18 } from "react";
|
|
6736
|
+
|
|
6737
|
+
// src/components/date-inputs/TimePicker/TimePicker.utils.ts
|
|
6738
|
+
function formatTimeSegments(segments) {
|
|
6739
|
+
const hourSegment = segments.find((segment) => segment.type === "hour");
|
|
6740
|
+
const minuteSegment = segments.find((segment) => segment.type === "minute");
|
|
6741
|
+
const separatorSegment = segments.find(
|
|
6742
|
+
(segment) => segment.type === "literal" && segment.isPlaceholder === void 0
|
|
6743
|
+
);
|
|
6744
|
+
if (!hourSegment || !minuteSegment || !separatorSegment) {
|
|
6745
|
+
throw new Error("Invalid time segments");
|
|
6746
|
+
}
|
|
6747
|
+
const formattedHourSegment = {
|
|
6748
|
+
...hourSegment,
|
|
6749
|
+
text: hourSegment.text.padStart(2, "0"),
|
|
6750
|
+
placeholder: "\u2013\u2013"
|
|
6751
|
+
};
|
|
6752
|
+
const formattedMinuteSegment = {
|
|
6753
|
+
...minuteSegment,
|
|
6754
|
+
text: minuteSegment.text.padStart(2, "0"),
|
|
6755
|
+
placeholder: "\u2013\u2013"
|
|
6756
|
+
};
|
|
6757
|
+
const formattedSeparatorSegment = { ...separatorSegment, text: ":" };
|
|
6758
|
+
return [
|
|
6759
|
+
formattedHourSegment,
|
|
6760
|
+
formattedSeparatorSegment,
|
|
6761
|
+
formattedMinuteSegment
|
|
6762
|
+
];
|
|
6763
|
+
}
|
|
6764
|
+
|
|
6765
|
+
// src/components/date-inputs/TimePicker/TimePicker.tsx
|
|
6736
6766
|
import { jsx as jsx238 } from "react/jsx-runtime";
|
|
6737
6767
|
function TimePicker({
|
|
6738
6768
|
componentSize = "medium",
|
|
@@ -6742,7 +6772,7 @@ function TimePicker({
|
|
|
6742
6772
|
}) {
|
|
6743
6773
|
const lang = useLanguage();
|
|
6744
6774
|
if (!lang) {
|
|
6745
|
-
throw new Error("
|
|
6775
|
+
throw new Error("TimePicker must be used within a DdsProvider");
|
|
6746
6776
|
}
|
|
6747
6777
|
const internalRef = useRef18(null);
|
|
6748
6778
|
const state = useTimeFieldState({
|
|
@@ -6756,6 +6786,7 @@ function TimePicker({
|
|
|
6756
6786
|
);
|
|
6757
6787
|
const iconSize = componentSize === "xsmall" ? "small" : "medium";
|
|
6758
6788
|
const disabled = props.isDisabled || !!fieldProps["aria-disabled"];
|
|
6789
|
+
const formattedSegments = formatTimeSegments(state.segments);
|
|
6759
6790
|
return /* @__PURE__ */ jsx238(
|
|
6760
6791
|
DateInput,
|
|
6761
6792
|
{
|
|
@@ -6781,7 +6812,7 @@ function TimePicker({
|
|
|
6781
6812
|
)
|
|
6782
6813
|
}
|
|
6783
6814
|
),
|
|
6784
|
-
children:
|
|
6815
|
+
children: formattedSegments.map((segment, i) => /* @__PURE__ */ jsx238(
|
|
6785
6816
|
DateSegment,
|
|
6786
6817
|
{
|
|
6787
6818
|
componentSize,
|