@norges-domstoler/dds-components 0.0.0-dev-20250916080642 → 0.0.0-dev-20250922134540

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
@@ -5986,7 +5986,12 @@ var DateInput_default = {
5986
5986
  };
5987
5987
 
5988
5988
  // src/components/date-inputs/DatePicker/constants.ts
5989
- var locale = "no-NO";
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: locale2 } = (0, import_i18n8.useLocale)();
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, locale2);
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: locale2 } = (0, import_i18n10.useLocale)();
6416
+ const { locale } = (0, import_i18n10.useLocale)();
6412
6417
  const state = (0, import_calendar4.useCalendarState)({
6413
6418
  ...props,
6414
6419
  createCalendar,
6415
- locale: locale2
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.padStart(String((_a = segment.maxValue) != null ? _a : "").length, "0")
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: locale2 } = (0, import_i18n12.useLocale)();
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: locale2,
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: state.segments.map((segment, i) => /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(
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" },
@@ -10940,12 +10986,12 @@ var COUNTRIES = {
10940
10986
  CO: { name: "Colombia", id: "CO", dialCode: "+57" },
10941
10987
  KM: { name: "Komorene (\u202B\u062C\u0632\u0631 \u0627\u0644\u0642\u0645\u0631\u202C\u200E)", id: "KM", dialCode: "+269" },
10942
10988
  CD: {
10943
- name: "Kongo (DR) (Jamhuri ya Kisoemokrasia ya Kongo)",
10989
+ name: "Kongo, den demokratiske republikken (R\xE9publique d\xE9mocratique du Congo)",
10944
10990
  id: "CD",
10945
10991
  dialCode: "+243"
10946
10992
  },
10947
10993
  CG: {
10948
- name: "Kongo (Republikken) (Congo-Brazzaville)",
10994
+ name: "Kongo, republikken (R\xE9publique du Congo)",
10949
10995
  id: "CG",
10950
10996
  dialCode: "+242"
10951
10997
  },
@@ -11023,7 +11069,7 @@ var COUNTRIES = {
11023
11069
  IR: { name: "Iran (\u202B\u0627\u06CC\u0631\u0627\u0646\u202C\u200E)", id: "IR", dialCode: "+98" },
11024
11070
  IQ: { name: "Irak (\u202B\u0627\u0644\u0639\u0631\u0627\u0642\u202C\u200E)", id: "IQ", dialCode: "+964" },
11025
11071
  IE: { name: "Irland (\xC9ire)", id: "IE", dialCode: "+353" },
11026
- IM: { name: "Isle of Man", id: "IM", dialCode: "+44" },
11072
+ IM: { name: "Man (Isle of Man)", id: "IM", dialCode: "+44" },
11027
11073
  IL: { name: "Israel (\u202B\u05D9\u05E9\u05E8\u05D0\u05DC\u202C\u200E)", id: "IL", dialCode: "+972" },
11028
11074
  IT: { name: "Italia", id: "IT", dialCode: "+39" },
11029
11075
  JM: { name: "Jamaica", id: "JM", dialCode: "+1" },
@@ -11047,7 +11093,7 @@ var COUNTRIES = {
11047
11093
  LU: { name: "Luxembourg", id: "LU", dialCode: "+352" },
11048
11094
  MO: { name: "Macao (\u6FB3\u9580)", id: "MO", dialCode: "+853" },
11049
11095
  MK: {
11050
- name: "Nord-Makedonia (FYROM) (\u041C\u0430\u043A\u0435\u0434\u043E\u043D\u0438\u0458\u0430)",
11096
+ name: "Nord-Makedonia (\u041C\u0430\u043A\u0435\u0434\u043E\u043D\u0438\u0458\u0430)",
11051
11097
  id: "MK",
11052
11098
  dialCode: "+389"
11053
11099
  },
@@ -11136,7 +11182,7 @@ var COUNTRIES = {
11136
11182
  },
11137
11183
  LC: { name: "Saint Lucia", id: "LC", dialCode: "+1758" },
11138
11184
  MF: {
11139
- name: "Saint Martin (Saint-Martin (partie fran\xE7aise))",
11185
+ name: "Saint-Martin (Collectivit\xE9 de Saint-Martin)",
11140
11186
  id: "MF",
11141
11187
  dialCode: "+590"
11142
11188
  },