@norges-domstoler/dds-components 0.0.0-dev-20250916080642 → 0.0.0-dev-20250917114111
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 +58 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5986,7 +5986,12 @@ var DateInput_default = {
|
|
|
5986
5986
|
};
|
|
5987
5987
|
|
|
5988
5988
|
// src/components/date-inputs/DatePicker/constants.ts
|
|
5989
|
-
var
|
|
5989
|
+
var LOCALE = {
|
|
5990
|
+
nb: "nb-NO",
|
|
5991
|
+
no: "no-NO",
|
|
5992
|
+
nn: "nn-NO",
|
|
5993
|
+
en: "en-GB"
|
|
5994
|
+
};
|
|
5990
5995
|
var timezone = "Europe/Oslo";
|
|
5991
5996
|
|
|
5992
5997
|
// src/components/date-inputs/DatePicker/Calendar/CalendarCell.tsx
|
|
@@ -6221,12 +6226,12 @@ var CalendarPopoverContent = ({
|
|
|
6221
6226
|
var import_jsx_runtime226 = require("react/jsx-runtime");
|
|
6222
6227
|
function CalendarGrid({ state, ...props }) {
|
|
6223
6228
|
const { t } = useTranslation();
|
|
6224
|
-
const { locale
|
|
6229
|
+
const { locale } = (0, import_i18n8.useLocale)();
|
|
6225
6230
|
const {
|
|
6226
6231
|
gridProps: { onKeyDown, ...gridProps },
|
|
6227
6232
|
headerProps
|
|
6228
6233
|
} = (0, import_calendar2.useCalendarGrid)(props, state);
|
|
6229
|
-
const weeksInMonth = (0, import_date3.getWeeksInMonth)(state.visibleRange.start,
|
|
6234
|
+
const weeksInMonth = (0, import_date3.getWeeksInMonth)(state.visibleRange.start, locale);
|
|
6230
6235
|
const weekDays = [
|
|
6231
6236
|
{ short: t(texts5.mo), full: t(texts5.monday) },
|
|
6232
6237
|
{ short: t(texts5.tu), full: t(texts5.tuesday) },
|
|
@@ -6408,11 +6413,11 @@ function createCalendar(identifier) {
|
|
|
6408
6413
|
}
|
|
6409
6414
|
function Calendar(props) {
|
|
6410
6415
|
const { t } = useTranslation();
|
|
6411
|
-
const { locale
|
|
6416
|
+
const { locale } = (0, import_i18n10.useLocale)();
|
|
6412
6417
|
const state = (0, import_calendar4.useCalendarState)({
|
|
6413
6418
|
...props,
|
|
6414
6419
|
createCalendar,
|
|
6415
|
-
locale
|
|
6420
|
+
locale
|
|
6416
6421
|
});
|
|
6417
6422
|
const {
|
|
6418
6423
|
calendarProps,
|
|
@@ -6552,6 +6557,39 @@ function CalendarButton({
|
|
|
6552
6557
|
);
|
|
6553
6558
|
}
|
|
6554
6559
|
|
|
6560
|
+
// src/components/date-inputs/DatePicker/DateField/DateField.utils.tsx
|
|
6561
|
+
function formatDateFieldSegments(segments) {
|
|
6562
|
+
const daySegment = segments.find((segment) => segment.type === "day");
|
|
6563
|
+
const monthSegment = segments.find((segment) => segment.type === "month");
|
|
6564
|
+
const yearSegment = segments.find((segment) => segment.type === "year");
|
|
6565
|
+
const separatorSegment = segments.find((segment) => segment.type === "literal");
|
|
6566
|
+
if (!daySegment || !monthSegment || !yearSegment || !separatorSegment) {
|
|
6567
|
+
throw new Error("Invalid date field segments");
|
|
6568
|
+
}
|
|
6569
|
+
const formattedDaySegment = {
|
|
6570
|
+
...daySegment,
|
|
6571
|
+
text: daySegment.text.padStart(2, "0"),
|
|
6572
|
+
placeholder: "dd"
|
|
6573
|
+
};
|
|
6574
|
+
const formattedMonthSegment = {
|
|
6575
|
+
...monthSegment,
|
|
6576
|
+
text: monthSegment.text.padStart(2, "0"),
|
|
6577
|
+
placeholder: "mm"
|
|
6578
|
+
};
|
|
6579
|
+
const formattedYearSegment = {
|
|
6580
|
+
...yearSegment,
|
|
6581
|
+
placeholder: "\xE5\xE5\xE5\xE5"
|
|
6582
|
+
};
|
|
6583
|
+
const formattedSeparatorSegment = { ...separatorSegment, text: "." };
|
|
6584
|
+
return [
|
|
6585
|
+
formattedDaySegment,
|
|
6586
|
+
formattedSeparatorSegment,
|
|
6587
|
+
formattedMonthSegment,
|
|
6588
|
+
formattedSeparatorSegment,
|
|
6589
|
+
formattedYearSegment
|
|
6590
|
+
];
|
|
6591
|
+
}
|
|
6592
|
+
|
|
6555
6593
|
// src/components/date-inputs/DatePicker/DateField/DateSegment.tsx
|
|
6556
6594
|
var import_datepicker = require("@react-aria/datepicker");
|
|
6557
6595
|
var import_react43 = require("react");
|
|
@@ -6566,7 +6604,6 @@ function DateSegment({
|
|
|
6566
6604
|
state,
|
|
6567
6605
|
componentSize
|
|
6568
6606
|
}) {
|
|
6569
|
-
var _a;
|
|
6570
6607
|
const ref = (0, import_react43.useRef)(null);
|
|
6571
6608
|
const { segmentProps } = (0, import_datepicker.useDateSegment)(segment, state, ref);
|
|
6572
6609
|
return /* @__PURE__ */ (0, import_jsx_runtime230.jsxs)(
|
|
@@ -6596,7 +6633,7 @@ function DateSegment({
|
|
|
6596
6633
|
children: segment.placeholder
|
|
6597
6634
|
}
|
|
6598
6635
|
),
|
|
6599
|
-
segment.isPlaceholder ? "" : segment.text
|
|
6636
|
+
segment.isPlaceholder ? "" : segment.text
|
|
6600
6637
|
]
|
|
6601
6638
|
}
|
|
6602
6639
|
);
|
|
@@ -6801,11 +6838,11 @@ function DateField({
|
|
|
6801
6838
|
clearable,
|
|
6802
6839
|
...props
|
|
6803
6840
|
}) {
|
|
6804
|
-
const { locale
|
|
6841
|
+
const { locale } = (0, import_i18n12.useLocale)();
|
|
6805
6842
|
const { t } = useTranslation();
|
|
6806
6843
|
const state = (0, import_datepicker3.useDateFieldState)({
|
|
6807
6844
|
...props,
|
|
6808
|
-
locale
|
|
6845
|
+
locale,
|
|
6809
6846
|
createCalendar: import_date5.createCalendar
|
|
6810
6847
|
});
|
|
6811
6848
|
const internalRef = (0, import_react45.useRef)(null);
|
|
@@ -6820,6 +6857,7 @@ function DateField({
|
|
|
6820
6857
|
const clearDate = () => {
|
|
6821
6858
|
state.setValue(null);
|
|
6822
6859
|
};
|
|
6860
|
+
const formattedSegments = formatDateFieldSegments(state.segments);
|
|
6823
6861
|
return /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
|
|
6824
6862
|
DateInput,
|
|
6825
6863
|
{
|
|
@@ -6858,7 +6896,7 @@ function DateField({
|
|
|
6858
6896
|
),
|
|
6859
6897
|
labelProps,
|
|
6860
6898
|
fieldProps,
|
|
6861
|
-
children:
|
|
6899
|
+
children: formattedSegments.map((segment, i) => /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
|
|
6862
6900
|
DateSegment,
|
|
6863
6901
|
{
|
|
6864
6902
|
"aria-readonly": props.isReadOnly,
|
|
@@ -6919,6 +6957,10 @@ function DatePicker({
|
|
|
6919
6957
|
ref,
|
|
6920
6958
|
...props
|
|
6921
6959
|
}) {
|
|
6960
|
+
const lang = useLanguage();
|
|
6961
|
+
if (!lang) {
|
|
6962
|
+
throw new Error("DatePicker must be used within a DdsProvider");
|
|
6963
|
+
}
|
|
6922
6964
|
const state = (0, import_datepicker5.useDatePickerState)(props);
|
|
6923
6965
|
const domRef = useFocusManagerRef(ref && refIsFocusable(ref) ? ref : null);
|
|
6924
6966
|
const internalRef = (0, import_react47.useRef)(null);
|
|
@@ -6928,7 +6970,7 @@ function DatePicker({
|
|
|
6928
6970
|
state,
|
|
6929
6971
|
internalRef
|
|
6930
6972
|
);
|
|
6931
|
-
return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(import_i18n14.I18nProvider, { locale, children: /* @__PURE__ */ (0, import_jsx_runtime236.jsxs)(
|
|
6973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(import_i18n14.I18nProvider, { locale: LOCALE[lang], children: /* @__PURE__ */ (0, import_jsx_runtime236.jsxs)(
|
|
6932
6974
|
CalendarPopover,
|
|
6933
6975
|
{
|
|
6934
6976
|
isOpen: state.isOpen,
|
|
@@ -6969,10 +7011,14 @@ function TimePicker({
|
|
|
6969
7011
|
ref,
|
|
6970
7012
|
...props
|
|
6971
7013
|
}) {
|
|
7014
|
+
const lang = useLanguage();
|
|
7015
|
+
if (!lang) {
|
|
7016
|
+
throw new Error("DatePicker must be used within a DdsProvider");
|
|
7017
|
+
}
|
|
6972
7018
|
const internalRef = (0, import_react48.useRef)(null);
|
|
6973
7019
|
const state = (0, import_datepicker7.useTimeFieldState)({
|
|
6974
7020
|
...props,
|
|
6975
|
-
locale
|
|
7021
|
+
locale: LOCALE[lang]
|
|
6976
7022
|
});
|
|
6977
7023
|
const { labelProps, fieldProps } = (0, import_datepicker6.useTimeField)(
|
|
6978
7024
|
{ ...props, hideTimeZone: true, granularity: "hour" },
|