@equinor/eds-core-react 2.3.5 → 2.3.7

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.
Files changed (38) hide show
  1. package/build/index.css +143 -277
  2. package/build/index.min.css +1 -5
  3. package/dist/eds-core-react.cjs +209 -25
  4. package/dist/esm/components/Autocomplete/AddNewOption.js +1 -1
  5. package/dist/esm/components/Autocomplete/Autocomplete.js +1 -1
  6. package/dist/esm/components/Autocomplete/Option.js +11 -2
  7. package/dist/esm/components/Autocomplete/SelectAllOption.js +1 -1
  8. package/dist/esm/components/Autocomplete/useAutocomplete.js +13 -2
  9. package/dist/esm/components/Banner/Banner.tokens.js +2 -10
  10. package/dist/esm/components/Chip/Chip.js +1 -1
  11. package/dist/esm/components/Chip/Chip.tokens.js +0 -2
  12. package/dist/esm/components/Datepicker/DatePicker.js +4 -1
  13. package/dist/esm/components/Datepicker/DateRangePicker.js +4 -1
  14. package/dist/esm/components/Datepicker/fields/DateFieldSegments.js +11 -2
  15. package/dist/esm/components/Datepicker/utils/get-calendar-date.js +1 -1
  16. package/dist/esm/components/Datepicker/utils/getLocalizedValidationErrors.js +164 -0
  17. package/dist/esm/components/EdsProvider/eds.context.js +1 -1
  18. package/dist/esm/components/Menu/Menu.context.js +1 -1
  19. package/dist/esm/components/SideBar/SideBar.context.js +1 -1
  20. package/dist/esm/components/Table/DataCell/DataCell.js +1 -1
  21. package/dist/esm/components/Table/FooterCell/FooterCell.js +1 -1
  22. package/dist/esm/components/Table/HeaderCell/HeaderCell.js +1 -1
  23. package/dist/esm/components/Typography/Typography.js +1 -1
  24. package/dist/esm/index.js +64 -64
  25. package/dist/esm-next/components/next/Button/Button.js +3 -5
  26. package/dist/esm-next/components/next/Input/Input.js +6 -11
  27. package/dist/esm-next/components/next/TextField/TextField.js +7 -2
  28. package/dist/esm-next/index.next.js +4 -4
  29. package/dist/index.next.cjs +15 -18
  30. package/dist/types/components/Autocomplete/Autocomplete.d.ts +1 -1
  31. package/dist/types/components/Autocomplete/AutocompleteContext.d.ts +2 -2
  32. package/dist/types/components/Autocomplete/useAutocomplete.d.ts +3 -2
  33. package/dist/types/components/Datepicker/DateRangePicker.d.ts +1 -1
  34. package/dist/types/components/Datepicker/utils/getLocalizedValidationErrors.d.ts +9 -0
  35. package/dist/types/components/SideBar/SideBarButton/index.d.ts +1 -1
  36. package/dist/types/components/next/Input/Input.types.d.ts +6 -4
  37. package/dist/types/components/next/TextField/TextField.d.ts +1 -0
  38. package/package.json +33 -33
@@ -1830,7 +1830,7 @@ const StyledTableCell$2 = styled__default.default.td.withConfig({
1830
1830
  align
1831
1831
  } = theme;
1832
1832
  const backgroundColor = color === 'error' ? theme.validation.error?.background : '';
1833
- const base = styled.css(["min-height:", ";height:", ";background:", ";vertical-align:", ";box-sizing:border-box;", " ", " ", ""], height, height, backgroundColor, align.vertical, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(border));
1833
+ const base = styled.css(["min-height:", ";height:", ";background:", ";vertical-align:", ";box-sizing:border-box;", " ", " ", " a{font-size:inherit;font-weight:inherit;}"], height, height, backgroundColor, align.vertical, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(border));
1834
1834
  return base;
1835
1835
  });
1836
1836
  const TableDataCell = /*#__PURE__*/react.forwardRef(function TableDataCell({
@@ -2011,7 +2011,7 @@ const StyledTableCell$1 = styled__default.default.th.withConfig({
2011
2011
  // Firefox specific workaround (bug in v142.0) - see issue #3910
2012
2012
  // Hardcoded padding values compensate for Firefox's incorrect table cell height calculation
2013
2013
  const firefoxFix = edsUtils.isFirefox() ? styled.css(["vertical-align:top;height:auto;min-height:", ";> div{padding:", " 0;}"], height, $density === 'compact' ? '7px' : '13px') : styled.css([""]);
2014
- return styled.css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " ", " ", " ", " ", ""], height, height, background, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(theme.border), sortStylingHover, sortStylingActive, firefoxFix, $sticky ? styled.css(["position:sticky;top:0;z-index:1;"]) : '');
2014
+ return styled.css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " ", " ", " ", " a{font-size:inherit;font-weight:inherit;}", ""], height, height, background, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(theme.border), sortStylingHover, sortStylingActive, firefoxFix, $sticky ? styled.css(["position:sticky;top:0;z-index:1;"]) : '');
2015
2015
  });
2016
2016
  const CellInner$1 = styled__default.default.div.withConfig({
2017
2017
  displayName: "HeaderCell__CellInner",
@@ -2061,7 +2061,7 @@ const StyledTableCell = styled__default.default.th.withConfig({
2061
2061
  typography,
2062
2062
  spacings
2063
2063
  } = theme;
2064
- return styled.css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " ", ""], height, height, background, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(theme.border), $sticky ? styled.css(["position:sticky;bottom:0;z-index:2;"]) : '');
2064
+ return styled.css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " a{font-size:inherit;font-weight:inherit;}", ""], height, height, background, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(theme.border), $sticky ? styled.css(["position:sticky;bottom:0;z-index:2;"]) : '');
2065
2065
  });
2066
2066
  const CellInner = styled__default.default.div.withConfig({
2067
2067
  displayName: "FooterCell__CellInner",
@@ -5443,8 +5443,6 @@ const enabled$3 = {
5443
5443
  },
5444
5444
  entities: {
5445
5445
  icon: {
5446
- height: medium$3,
5447
- width: medium$3,
5448
5446
  border: {
5449
5447
  radius: borderRadius$3,
5450
5448
  type: 'border',
@@ -5596,7 +5594,7 @@ const Chip = /*#__PURE__*/react.forwardRef(function Chip({
5596
5594
  };
5597
5595
  const resizedChildren = react.Children.map(children, child => {
5598
5596
  // We force size on Icon & Avatar component
5599
- if (child.props) {
5597
+ if (child?.props) {
5600
5598
  return /*#__PURE__*/react.cloneElement(child, {
5601
5599
  size: 16,
5602
5600
  disabled
@@ -6964,11 +6962,7 @@ const info$1 = {
6964
6962
  color: infoColor
6965
6963
  }
6966
6964
  }
6967
- },
6968
- modes: {
6969
- compact: {}
6970
- }
6971
- };
6965
+ }};
6972
6966
  const warning$1 = {
6973
6967
  entities: {
6974
6968
  icon: {
@@ -6977,11 +6971,7 @@ const warning$1 = {
6977
6971
  color: warningColor
6978
6972
  }
6979
6973
  }
6980
- },
6981
- modes: {
6982
- compact: {}
6983
- }
6984
- };
6974
+ }};
6985
6975
 
6986
6976
  var tokens$2 = /*#__PURE__*/Object.freeze({
6987
6977
  __proto__: null,
@@ -9694,7 +9684,9 @@ function Option({
9694
9684
  const isSelected = selectedItemsLabels.includes(label);
9695
9685
  const optionComponent = _optionComponent?.(item, isSelected);
9696
9686
  const highlighted = highlightedIndex === index && !isDisabled ? 'true' : 'false';
9697
- const itemProps = getItemProps({
9687
+
9688
+ // Guard: downshift 9.x validates that item exists in the items array
9689
+ const itemProps = item !== undefined ? getItemProps({
9698
9690
  ...(multiline && {
9699
9691
  ref: rowVirtualizer.measureElement
9700
9692
  }),
@@ -9706,7 +9698,14 @@ function Option({
9706
9698
  height: `${virtualItem.size}px`
9707
9699
  })
9708
9700
  }
9709
- });
9701
+ }) : {
9702
+ style: {
9703
+ transform: `translateY(${virtualItem.start}px)`,
9704
+ ...(!multiline && {
9705
+ height: `${virtualItem.size}px`
9706
+ })
9707
+ }
9708
+ };
9710
9709
  return /*#__PURE__*/jsxRuntime.jsxs(StyledListItem, {
9711
9710
  $isdisabled: isDisabled ? 'true' : 'false',
9712
9711
  $highlighted: highlighted,
@@ -9766,7 +9765,7 @@ function AddNewOption({
9766
9765
  ref: rowVirtualizer.measureElement
9767
9766
  }),
9768
9767
  item,
9769
- index: index
9768
+ index
9770
9769
  });
9771
9770
  return /*#__PURE__*/jsxRuntime.jsxs(StyledListItem, {
9772
9771
  $highlighted: highlighted,
@@ -9818,7 +9817,7 @@ function SelectAllOption({
9818
9817
  ref: rowVirtualizer.measureElement
9819
9818
  }),
9820
9819
  item,
9821
- index: index
9820
+ index
9822
9821
  });
9823
9822
  return /*#__PURE__*/jsxRuntime.jsxs(StyledListItem, {
9824
9823
  ref: ref,
@@ -10333,7 +10332,13 @@ const useAutocomplete = ({
10333
10332
  ...multipleSelectionProps,
10334
10333
  onSelectedItemsChange: changes => {
10335
10334
  if (onOptionsChange) {
10336
- let selectedItems = changes.selectedItems.filter(item => item !== AllSymbol || item !== AddSymbol);
10335
+ // AddSymbol/AllSymbol are handled manually in onStateChange,
10336
+ // so skip propagating when they appear in selectedItems
10337
+ // (downshift 9.x propagates selectedItem to useMultipleSelection)
10338
+ if (changes.selectedItems.some(item => item === AllSymbol || item === AddSymbol)) {
10339
+ return;
10340
+ }
10341
+ let selectedItems = changes.selectedItems;
10337
10342
  if (itemCompare) {
10338
10343
  selectedItems = inputOptions.filter(item => selectedItems.some(compare => itemCompare(item, compare)));
10339
10344
  }
@@ -10490,6 +10495,9 @@ const useAutocomplete = ({
10490
10495
  toggleAllSelected();
10491
10496
  } else if (selectedItem === AddSymbol && typedInputValue.trim()) {
10492
10497
  onAddNewOption?.(typedInputValue);
10498
+ if (clearSearchOnChange) {
10499
+ setTypedInputValue('');
10500
+ }
10493
10501
  } else if (multiple) {
10494
10502
  const shouldRemove = itemCompare ? selectedItems.some(i => itemCompare(selectedItem, i)) : selectedItems.includes(selectedItem);
10495
10503
  if (shouldRemove) {
@@ -10715,7 +10723,9 @@ const useAutocomplete = ({
10715
10723
  };
10716
10724
  case downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
10717
10725
  case downshift.useCombobox.stateChangeTypes.ItemClick:
10718
- if (clearSearchOnChange) {
10726
+ // Don't clear typedInputValue for AddSymbol — onStateChange needs
10727
+ // it to call onAddNewOption (downshift 9.x runs onStateChange after re-render)
10728
+ if (clearSearchOnChange && changes.selectedItem !== AddSymbol) {
10719
10729
  setTypedInputValue('');
10720
10730
  }
10721
10731
  return {
@@ -12523,14 +12533,23 @@ function DateSegment({
12523
12533
 
12524
12534
  // In some cases we need to use the index as key
12525
12535
  /* eslint-disable react/no-array-index-key */
12536
+ // Use January 1st as placeholder when no value is set.
12537
+ // This ensures the day segment allows values up to 31,
12538
+ // preventing eager auto-advance when typing "3" (which
12539
+ // would otherwise auto-complete to "03" in months with
12540
+ // fewer than 30 days, like February).
12541
+ const DEFAULT_PLACEHOLDER = new date.CalendarDate(new Date().getFullYear(), 1, 1);
12542
+
12526
12543
  /**
12527
12544
  * A field that wraps segments for inputting a date / date-time
12528
12545
  */
12529
12546
  const DateFieldSegments = /*#__PURE__*/react.forwardRef((props, ref) => {
12547
+ const placeholderValue = props.placeholderValue ?? DEFAULT_PLACEHOLDER;
12530
12548
  const state = datepicker.useDateFieldState({
12531
12549
  ...props,
12532
12550
  locale: props.locale,
12533
- createCalendar: date.createCalendar
12551
+ createCalendar: date.createCalendar,
12552
+ placeholderValue
12534
12553
  });
12535
12554
  const {
12536
12555
  fieldProps
@@ -12678,6 +12697,167 @@ const useGetLocale = locale => {
12678
12697
  return locale ?? currentLocale ?? browserLocale;
12679
12698
  };
12680
12699
 
12700
+ /**
12701
+ * Validation message translations matching @react-stately/datepicker's built-in messages.
12702
+ * Sourced from @react-stately/datepicker's intlStrings bundle.
12703
+ * Unsupported locales fall back to English.
12704
+ */
12705
+ const allTranslations = {
12706
+ 'en-US': {
12707
+ rangeUnderflow: args => `Value must be ${args.minValue} or later.`,
12708
+ rangeOverflow: args => `Value must be ${args.maxValue} or earlier.`,
12709
+ unavailableDate: 'Selected date unavailable.'
12710
+ },
12711
+ 'nb-NO': {
12712
+ rangeUnderflow: args => `Verdien m\u00e5 v\u00e6re ${args.minValue} eller senere.`,
12713
+ rangeOverflow: args => `Verdien m\u00e5 v\u00e6re ${args.maxValue} eller tidligere.`,
12714
+ unavailableDate: 'Valgt dato utilgjengelig.'
12715
+ },
12716
+ 'da-DK': {
12717
+ rangeUnderflow: args => `V\u00e6rdien skal v\u00e6re ${args.minValue} eller senere.`,
12718
+ rangeOverflow: args => `V\u00e6rdien skal v\u00e6re ${args.maxValue} eller tidligere.`,
12719
+ unavailableDate: 'Den valgte dato er ikke tilg\u00e6ngelig.'
12720
+ },
12721
+ 'sv-SE': {
12722
+ rangeUnderflow: args => `V\u00e4rdet m\u00e5ste vara ${args.minValue} eller senare.`,
12723
+ rangeOverflow: args => `V\u00e4rdet m\u00e5ste vara ${args.maxValue} eller tidigare.`,
12724
+ unavailableDate: 'Valt datum \u00e4r inte tillg\u00e4ngligt.'
12725
+ },
12726
+ 'de-DE': {
12727
+ rangeUnderflow: args => `Der Wert muss ${args.minValue} oder sp\u00e4ter sein.`,
12728
+ rangeOverflow: args => `Der Wert muss ${args.maxValue} oder fr\u00fcher sein.`,
12729
+ unavailableDate: 'Das ausgew\u00e4hlte Datum ist nicht verf\u00fcgbar.'
12730
+ },
12731
+ 'fr-FR': {
12732
+ rangeUnderflow: args => `La valeur doit \u00eatre ${args.minValue} ou ult\u00e9rieure.`,
12733
+ rangeOverflow: args => `La valeur doit \u00eatre ${args.maxValue} ou ant\u00e9rieure.`,
12734
+ unavailableDate: 'Date s\u00e9lectionn\u00e9e non disponible.'
12735
+ },
12736
+ 'es-ES': {
12737
+ rangeUnderflow: args => `El valor debe ser ${args.minValue} o posterior.`,
12738
+ rangeOverflow: args => `El valor debe ser ${args.maxValue} o anterior.`,
12739
+ unavailableDate: 'Fecha seleccionada no disponible.'
12740
+ },
12741
+ 'pt-BR': {
12742
+ rangeUnderflow: args => `O valor deve ser ${args.minValue} ou posterior.`,
12743
+ rangeOverflow: args => `O valor deve ser ${args.maxValue} ou anterior.`,
12744
+ unavailableDate: 'Data selecionada indispon\u00edvel.'
12745
+ },
12746
+ 'pt-PT': {
12747
+ rangeUnderflow: args => `O valor tem de ser ${args.minValue} ou posterior.`,
12748
+ rangeOverflow: args => `O valor tem de ser ${args.maxValue} ou anterior.`,
12749
+ unavailableDate: 'Data selecionada indispon\u00edvel.'
12750
+ },
12751
+ 'pl-PL': {
12752
+ rangeUnderflow: args => `Warto\u015b\u0107 musi wynosi\u0107 ${args.minValue} lub p\u00f3\u017aniej.`,
12753
+ rangeOverflow: args => `Warto\u015b\u0107 musi wynosi\u0107 ${args.maxValue} lub wcze\u015bniej.`,
12754
+ unavailableDate: 'Wybrana data jest niedost\u0119pna.'
12755
+ },
12756
+ 'nl-NL': {
12757
+ rangeUnderflow: args => `Waarde moet ${args.minValue} of later zijn.`,
12758
+ rangeOverflow: args => `Waarde moet ${args.maxValue} of eerder zijn.`,
12759
+ unavailableDate: 'Geselecteerde datum niet beschikbaar.'
12760
+ },
12761
+ 'it-IT': {
12762
+ rangeUnderflow: args => `Il valore deve essere ${args.minValue} o successivo.`,
12763
+ rangeOverflow: args => `Il valore deve essere ${args.maxValue} o precedente.`,
12764
+ unavailableDate: 'Data selezionata non disponibile.'
12765
+ },
12766
+ 'ja-JP': {
12767
+ rangeUnderflow: args => `\u5024\u306f${args.minValue}\u4ee5\u964d\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002`,
12768
+ rangeOverflow: args => `\u5024\u306f${args.maxValue}\u4ee5\u524d\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002`,
12769
+ unavailableDate: '\u9078\u629e\u3057\u305f\u65e5\u4ed8\u306f\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002'
12770
+ },
12771
+ 'ko-KR': {
12772
+ rangeUnderflow: args => `\uac12\uc740 ${args.minValue} \uc774\ud6c4\uc5ec\uc57c \ud569\ub2c8\ub2e4.`,
12773
+ rangeOverflow: args => `\uac12\uc740 ${args.maxValue} \uc774\uc804\uc774\uc5b4\uc57c \ud569\ub2c8\ub2e4.`,
12774
+ unavailableDate: '\uc120\ud0dd\ud55c \ub0a0\uc9dc\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.'
12775
+ },
12776
+ 'zh-CN': {
12777
+ rangeUnderflow: args => `\u503c\u5fc5\u987b\u4e3a ${args.minValue} \u6216\u66f4\u665a\u3002`,
12778
+ rangeOverflow: args => `\u503c\u5fc5\u987b\u4e3a ${args.maxValue} \u6216\u66f4\u65e9\u3002`,
12779
+ unavailableDate: '\u6240\u9009\u65e5\u671f\u4e0d\u53ef\u7528\u3002'
12780
+ },
12781
+ 'zh-TW': {
12782
+ rangeUnderflow: args => `\u503c\u5fc5\u9808\u70ba ${args.minValue} \u6216\u66f4\u665a\u3002`,
12783
+ rangeOverflow: args => `\u503c\u5fc5\u9808\u70ba ${args.maxValue} \u6216\u66f4\u65e9\u3002`,
12784
+ unavailableDate: '\u6240\u9078\u65e5\u671f\u4e0d\u53ef\u7528\u3002'
12785
+ },
12786
+ 'ru-RU': {
12787
+ rangeUnderflow: args => `\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c ${args.minValue} \u0438\u043b\u0438 \u043f\u043e\u0437\u0436\u0435.`,
12788
+ rangeOverflow: args => `\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c ${args.maxValue} \u0438\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435.`,
12789
+ unavailableDate: '\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u0434\u0430\u0442\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430.'
12790
+ },
12791
+ 'uk-UA': {
12792
+ rangeUnderflow: args => `\u0417\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u043c\u0430\u0454 \u0431\u0443\u0442\u0438 ${args.minValue} \u0430\u0431\u043e \u043f\u0456\u0437\u043d\u0456\u0448\u0435.`,
12793
+ rangeOverflow: args => `\u0417\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u043c\u0430\u0454 \u0431\u0443\u0442\u0438 ${args.maxValue} \u0430\u0431\u043e \u0440\u0430\u043d\u0456\u0448\u0435.`,
12794
+ unavailableDate: '\u0412\u0438\u0431\u0440\u0430\u043d\u0430 \u0434\u0430\u0442\u0430 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430.'
12795
+ },
12796
+ 'ar-AE': {
12797
+ rangeUnderflow: args => `\u064a\u062c\u0628 \u0623\u0646 \u062a\u0643\u0648\u0646 \u0627\u0644\u0642\u064a\u0645\u0629 ${args.minValue} \u0623\u0648 \u0623\u062d\u062f\u062b.`,
12798
+ rangeOverflow: args => `\u064a\u062c\u0628 \u0623\u0646 \u062a\u0643\u0648\u0646 \u0627\u0644\u0642\u064a\u0645\u0629 ${args.maxValue} \u0623\u0648 \u0623\u0642\u062f\u0645.`,
12799
+ unavailableDate: '\u0627\u0644\u062a\u0627\u0631\u064a\u062e \u0627\u0644\u0645\u062d\u062f\u062f \u063a\u064a\u0631 \u0645\u062a\u0627\u062d.'
12800
+ },
12801
+ 'fi-FI': {
12802
+ rangeUnderflow: args => `Arvon on oltava ${args.minValue} tai my\u00f6hempi.`,
12803
+ rangeOverflow: args => `Arvon on oltava ${args.maxValue} tai aikaisempi.`,
12804
+ unavailableDate: 'Valittu p\u00e4iv\u00e4m\u00e4\u00e4r\u00e4 ei ole k\u00e4ytett\u00e4viss\u00e4.'
12805
+ }
12806
+ };
12807
+ const englishFallback = allTranslations['en-US'];
12808
+
12809
+ /**
12810
+ * Find the best matching locale from available translations.
12811
+ * Tries exact match first (e.g. "nb-NO"), then language prefix match (e.g. "nb" → "nb-NO").
12812
+ */
12813
+ function findLocaleMessages(locale) {
12814
+ if (allTranslations[locale]) return allTranslations[locale];
12815
+ const language = Intl.Locale ? new Intl.Locale(locale).language : locale.split('-')[0];
12816
+
12817
+ // First match wins: e.g. "pt" → "pt-BR", "zh" → "zh-CN"
12818
+ for (const key of Object.keys(allTranslations)) {
12819
+ const keyLang = key.split('-')[0];
12820
+ if (keyLang === language) return allTranslations[key];
12821
+ }
12822
+ return englishFallback;
12823
+ }
12824
+ function formatMessage(msg, args) {
12825
+ return typeof msg === 'function' ? msg(args) : msg;
12826
+ }
12827
+
12828
+ /**
12829
+ * Generates validation error messages using the provided locale instead of
12830
+ * navigator.language (which is what react-stately uses internally).
12831
+ *
12832
+ * This fixes the issue where validation messages appear in the browser's
12833
+ * language rather than the locale configured via I18nProvider.
12834
+ */
12835
+ function getLocalizedValidationErrors(validationDetails, locale, minValue, maxValue, timezone) {
12836
+ const msgs = findLocaleMessages(locale);
12837
+ const dateFormatter = new date.DateFormatter(locale, {
12838
+ year: 'numeric',
12839
+ month: 'numeric',
12840
+ day: 'numeric'
12841
+ });
12842
+ const timeZone = timezone ?? dateFormatter.resolvedOptions().timeZone;
12843
+ const errors = [];
12844
+ if (validationDetails.rangeUnderflow && minValue && msgs.rangeUnderflow) {
12845
+ errors.push(formatMessage(msgs.rangeUnderflow, {
12846
+ minValue: dateFormatter.format(minValue.toDate(timeZone))
12847
+ }));
12848
+ }
12849
+ if (validationDetails.rangeOverflow && maxValue && msgs.rangeOverflow) {
12850
+ errors.push(formatMessage(msgs.rangeOverflow, {
12851
+ maxValue: dateFormatter.format(maxValue.toDate(timeZone))
12852
+ }));
12853
+ }
12854
+ // react-stately maps isDateUnavailable to badInput (not customError)
12855
+ if (validationDetails.badInput && msgs.unavailableDate) {
12856
+ errors.push(formatMessage(msgs.unavailableDate, {}));
12857
+ }
12858
+ return errors;
12859
+ }
12860
+
12681
12861
  const DatePicker = /*#__PURE__*/react.forwardRef(({
12682
12862
  onChange,
12683
12863
  label,
@@ -12772,8 +12952,10 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
12772
12952
  fieldProps,
12773
12953
  calendarProps
12774
12954
  } = reactAria.useDatePicker(dateCreateProps, pickerState, ref);
12955
+ const localizedErrors = pickerState.displayValidation.isInvalid ? getLocalizedValidationErrors(pickerState.displayValidation.validationDetails, locale, _minValue, _maxValue, timezone) : [];
12956
+ const errorMessages = localizedErrors.length > 0 ? localizedErrors : pickerState.displayValidation.validationErrors;
12775
12957
  const helperPropsInvalid = pickerState.displayValidation.isInvalid ? {
12776
- text: pickerState.displayValidation.validationErrors.join('\n'),
12958
+ text: errorMessages.join('\n'),
12777
12959
  color: edsTokens.tokens.colors.interactive.warning__text.rgba,
12778
12960
  icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
12779
12961
  size: 16,
@@ -13023,8 +13205,10 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
13023
13205
  buttonProps,
13024
13206
  calendarProps
13025
13207
  } = reactAria.useDateRangePicker(dateRangePickerStateProps, state, ref);
13208
+ const localizedErrors = state.displayValidation.isInvalid ? getLocalizedValidationErrors(state.displayValidation.validationDetails, locale, _minValue, _maxValue, timezone) : [];
13209
+ const errorMessages = localizedErrors.length > 0 ? localizedErrors : state.displayValidation.validationErrors;
13026
13210
  const helperProps = state.displayValidation.isInvalid ? {
13027
- text: state.displayValidation.validationErrors.join('\n'),
13211
+ text: errorMessages.join('\n'),
13028
13212
  color: edsTokens.tokens.colors.interactive.warning__text.rgba,
13029
13213
  icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
13030
13214
  size: 16,
@@ -40,7 +40,7 @@ function AddNewOption({
40
40
  ref: rowVirtualizer.measureElement
41
41
  }),
42
42
  item,
43
- index: index
43
+ index
44
44
  });
45
45
  return /*#__PURE__*/jsxs(StyledListItem, {
46
46
  $highlighted: highlighted,
@@ -1,5 +1,5 @@
1
1
  import { useFloating, offset, flip, size } from '@floating-ui/react';
2
- import styled, { css, ThemeProvider } from 'styled-components';
2
+ import styled, { ThemeProvider, css } from 'styled-components';
3
3
  import { Button } from '../Button/index.js';
4
4
  import { AutocompleteContext } from './AutocompleteContext.js';
5
5
  import { MultipleInput } from './MultipleInput.js';
@@ -48,7 +48,9 @@ function Option({
48
48
  const isSelected = selectedItemsLabels.includes(label);
49
49
  const optionComponent = _optionComponent?.(item, isSelected);
50
50
  const highlighted = highlightedIndex === index && !isDisabled ? 'true' : 'false';
51
- const itemProps = getItemProps({
51
+
52
+ // Guard: downshift 9.x validates that item exists in the items array
53
+ const itemProps = item !== undefined ? getItemProps({
52
54
  ...(multiline && {
53
55
  ref: rowVirtualizer.measureElement
54
56
  }),
@@ -60,7 +62,14 @@ function Option({
60
62
  height: `${virtualItem.size}px`
61
63
  })
62
64
  }
63
- });
65
+ }) : {
66
+ style: {
67
+ transform: `translateY(${virtualItem.start}px)`,
68
+ ...(!multiline && {
69
+ height: `${virtualItem.size}px`
70
+ })
71
+ }
72
+ };
64
73
  return /*#__PURE__*/jsxs(StyledListItem, {
65
74
  $isdisabled: isDisabled ? 'true' : 'false',
66
75
  $highlighted: highlighted,
@@ -27,7 +27,7 @@ function SelectAllOption({
27
27
  ref: rowVirtualizer.measureElement
28
28
  }),
29
29
  item,
30
- index: index
30
+ index
31
31
  });
32
32
  return /*#__PURE__*/jsxs(StyledListItem, {
33
33
  ref: ref,
@@ -112,7 +112,13 @@ const useAutocomplete = ({
112
112
  ...multipleSelectionProps,
113
113
  onSelectedItemsChange: changes => {
114
114
  if (onOptionsChange) {
115
- let selectedItems = changes.selectedItems.filter(item => item !== AllSymbol || item !== AddSymbol);
115
+ // AddSymbol/AllSymbol are handled manually in onStateChange,
116
+ // so skip propagating when they appear in selectedItems
117
+ // (downshift 9.x propagates selectedItem to useMultipleSelection)
118
+ if (changes.selectedItems.some(item => item === AllSymbol || item === AddSymbol)) {
119
+ return;
120
+ }
121
+ let selectedItems = changes.selectedItems;
116
122
  if (itemCompare) {
117
123
  selectedItems = inputOptions.filter(item => selectedItems.some(compare => itemCompare(item, compare)));
118
124
  }
@@ -269,6 +275,9 @@ const useAutocomplete = ({
269
275
  toggleAllSelected();
270
276
  } else if (selectedItem === AddSymbol && typedInputValue.trim()) {
271
277
  onAddNewOption?.(typedInputValue);
278
+ if (clearSearchOnChange) {
279
+ setTypedInputValue('');
280
+ }
272
281
  } else if (multiple) {
273
282
  const shouldRemove = itemCompare ? selectedItems.some(i => itemCompare(selectedItem, i)) : selectedItems.includes(selectedItem);
274
283
  if (shouldRemove) {
@@ -494,7 +503,9 @@ const useAutocomplete = ({
494
503
  };
495
504
  case useCombobox.stateChangeTypes.InputKeyDownEnter:
496
505
  case useCombobox.stateChangeTypes.ItemClick:
497
- if (clearSearchOnChange) {
506
+ // Don't clear typedInputValue for AddSymbol — onStateChange needs
507
+ // it to call onAddNewOption (downshift 9.x runs onStateChange after re-render)
508
+ if (clearSearchOnChange && changes.selectedItem !== AddSymbol) {
498
509
  setTypedInputValue('');
499
510
  }
500
511
  return {
@@ -74,11 +74,7 @@ const info = {
74
74
  color: infoColor
75
75
  }
76
76
  }
77
- },
78
- modes: {
79
- compact: {}
80
- }
81
- };
77
+ }};
82
78
  const warning = {
83
79
  entities: {
84
80
  icon: {
@@ -87,10 +83,6 @@ const warning = {
87
83
  color: warningColor
88
84
  }
89
85
  }
90
- },
91
- modes: {
92
- compact: {}
93
- }
94
- };
86
+ }};
95
87
 
96
88
  export { enabled, info, warning };
@@ -85,7 +85,7 @@ const Chip = /*#__PURE__*/forwardRef(function Chip({
85
85
  };
86
86
  const resizedChildren = Children.map(children, child => {
87
87
  // We force size on Icon & Avatar component
88
- if (child.props) {
88
+ if (child?.props) {
89
89
  return /*#__PURE__*/cloneElement(child, {
90
90
  size: 16,
91
91
  disabled
@@ -107,8 +107,6 @@ const enabled = {
107
107
  },
108
108
  entities: {
109
109
  icon: {
110
- height: medium,
111
- width: medium,
112
110
  border: {
113
111
  radius: borderRadius,
114
112
  type: 'border',
@@ -13,6 +13,7 @@ import { tokens } from '@equinor/eds-tokens';
13
13
  import { Icon } from '../Icon/index.js';
14
14
  import { getCalendarDate } from './utils/get-calendar-date.js';
15
15
  import { useGetLocale } from './utils/useGetLocale.js';
16
+ import { getLocalizedValidationErrors } from './utils/getLocalizedValidationErrors.js';
16
17
  import { jsx } from 'react/jsx-runtime';
17
18
 
18
19
  const DatePicker = /*#__PURE__*/forwardRef(({
@@ -109,8 +110,10 @@ const DatePicker = /*#__PURE__*/forwardRef(({
109
110
  fieldProps,
110
111
  calendarProps
111
112
  } = useDatePicker(dateCreateProps, pickerState, ref);
113
+ const localizedErrors = pickerState.displayValidation.isInvalid ? getLocalizedValidationErrors(pickerState.displayValidation.validationDetails, locale, _minValue, _maxValue, timezone) : [];
114
+ const errorMessages = localizedErrors.length > 0 ? localizedErrors : pickerState.displayValidation.validationErrors;
112
115
  const helperPropsInvalid = pickerState.displayValidation.isInvalid ? {
113
- text: pickerState.displayValidation.validationErrors.join('\n'),
116
+ text: errorMessages.join('\n'),
114
117
  color: tokens.colors.interactive.warning__text.rgba,
115
118
  icon: /*#__PURE__*/jsx(Icon, {
116
119
  size: 16,
@@ -13,6 +13,7 @@ import { tokens } from '@equinor/eds-tokens';
13
13
  import { Icon } from '../Icon/index.js';
14
14
  import { getCalendarDate } from './utils/get-calendar-date.js';
15
15
  import { useGetLocale } from './utils/useGetLocale.js';
16
+ import { getLocalizedValidationErrors } from './utils/getLocalizedValidationErrors.js';
16
17
  import { jsx } from 'react/jsx-runtime';
17
18
 
18
19
  const DateRangePicker = /*#__PURE__*/forwardRef(({
@@ -96,8 +97,10 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
96
97
  buttonProps,
97
98
  calendarProps
98
99
  } = useDateRangePicker(dateRangePickerStateProps, state, ref);
100
+ const localizedErrors = state.displayValidation.isInvalid ? getLocalizedValidationErrors(state.displayValidation.validationDetails, locale, _minValue, _maxValue, timezone) : [];
101
+ const errorMessages = localizedErrors.length > 0 ? localizedErrors : state.displayValidation.validationErrors;
99
102
  const helperProps = state.displayValidation.isInvalid ? {
100
- text: state.displayValidation.validationErrors.join('\n'),
103
+ text: errorMessages.join('\n'),
101
104
  color: tokens.colors.interactive.warning__text.rgba,
102
105
  icon: /*#__PURE__*/jsx(Icon, {
103
106
  size: 16,
@@ -1,20 +1,29 @@
1
1
  import { useDateFieldState } from '@react-stately/datepicker';
2
2
  import { useDateField } from 'react-aria';
3
- import { createCalendar } from '@internationalized/date';
3
+ import { CalendarDate, createCalendar } from '@internationalized/date';
4
4
  import { DateSegment } from './DateSegment.js';
5
5
  import { forwardRef } from 'react';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
8
  // In some cases we need to use the index as key
9
9
  /* eslint-disable react/no-array-index-key */
10
+ // Use January 1st as placeholder when no value is set.
11
+ // This ensures the day segment allows values up to 31,
12
+ // preventing eager auto-advance when typing "3" (which
13
+ // would otherwise auto-complete to "03" in months with
14
+ // fewer than 30 days, like February).
15
+ const DEFAULT_PLACEHOLDER = new CalendarDate(new Date().getFullYear(), 1, 1);
16
+
10
17
  /**
11
18
  * A field that wraps segments for inputting a date / date-time
12
19
  */
13
20
  const DateFieldSegments = /*#__PURE__*/forwardRef((props, ref) => {
21
+ const placeholderValue = props.placeholderValue ?? DEFAULT_PLACEHOLDER;
14
22
  const state = useDateFieldState({
15
23
  ...props,
16
24
  locale: props.locale,
17
- createCalendar
25
+ createCalendar,
26
+ placeholderValue
18
27
  });
19
28
  const {
20
29
  fieldProps
@@ -1,4 +1,4 @@
1
- import { toCalendarDateTime, toCalendarDate, fromDate } from '@internationalized/date';
1
+ import { toCalendarDateTime, fromDate, toCalendarDate } from '@internationalized/date';
2
2
 
3
3
  const getCalendarDate = (value, timezone, showTimeInput = false) => {
4
4
  if (!value) return null;