@equinor/eds-core-react 0.36.0 → 0.37.0

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 (67) hide show
  1. package/dist/eds-core-react.cjs +1192 -53
  2. package/dist/esm/components/Autocomplete/Autocomplete.js +1 -1
  3. package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +1 -1
  4. package/dist/esm/components/Button/Button.js +1 -1
  5. package/dist/esm/components/Button/tokens/contained_icon.js +2 -2
  6. package/dist/esm/components/Button/tokens/icon.js +1 -1
  7. package/dist/esm/components/Datepicker/DatePicker.js +156 -0
  8. package/dist/esm/components/Datepicker/DateRangePicker.js +151 -0
  9. package/dist/esm/components/Datepicker/calendars/Calendar.js +83 -0
  10. package/dist/esm/components/Datepicker/calendars/CalendarCell.js +144 -0
  11. package/dist/esm/components/Datepicker/calendars/CalendarGrid.js +65 -0
  12. package/dist/esm/components/Datepicker/calendars/CalendarHeader.js +90 -0
  13. package/dist/esm/components/Datepicker/calendars/CalendarWrapper.js +8 -0
  14. package/dist/esm/components/Datepicker/calendars/RangeCalendar.js +72 -0
  15. package/dist/esm/components/Datepicker/calendars/YearGrid.js +90 -0
  16. package/dist/esm/components/Datepicker/fields/DateField.js +40 -0
  17. package/dist/esm/components/Datepicker/fields/DateFieldSegments.js +43 -0
  18. package/dist/esm/components/Datepicker/fields/DateRangeField.js +43 -0
  19. package/dist/esm/components/Datepicker/fields/DateSegment.js +47 -0
  20. package/dist/esm/components/Datepicker/fields/FieldWrapper.js +136 -0
  21. package/dist/esm/components/Datepicker/fields/Toggle.js +61 -0
  22. package/dist/esm/components/Datepicker/utils/context.js +21 -0
  23. package/dist/esm/components/Datepicker/utils/get-calendar-date.js +8 -0
  24. package/dist/esm/components/Datepicker/utils/useConvertedValidationFunctions.js +20 -0
  25. package/dist/esm/components/Label/Label.js +1 -1
  26. package/dist/esm/components/Menu/MenuItem.js +1 -1
  27. package/dist/esm/components/TextField/TextField.js +2 -1
  28. package/dist/esm/components/Textarea/Textarea.js +9 -3
  29. package/dist/esm/index.js +2 -0
  30. package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/mergeDeepRight.js +1 -2
  31. package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/mergeDeepWithKey.js +1 -2
  32. package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/mergeWith.js +1 -2
  33. package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/mergeWithKey.js +1 -2
  34. package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/pickBy.js +1 -2
  35. package/dist/types/components/Autocomplete/Autocomplete.d.ts +2 -2
  36. package/dist/types/components/Chip/Icon.d.ts +3 -1
  37. package/dist/types/components/Datepicker/DatePicker.d.ts +23 -0
  38. package/dist/types/components/Datepicker/DatePicker.spec.d.ts +1 -0
  39. package/dist/types/components/Datepicker/DateRangePicker.d.ts +39 -0
  40. package/dist/types/components/Datepicker/DateRangePicker.spec.d.ts +1 -0
  41. package/dist/types/components/Datepicker/calendars/Calendar.d.ts +17 -0
  42. package/dist/types/components/Datepicker/calendars/CalendarCell.d.ts +9 -0
  43. package/dist/types/components/Datepicker/calendars/CalendarGrid.d.ts +10 -0
  44. package/dist/types/components/Datepicker/calendars/CalendarHeader.d.ts +12 -0
  45. package/dist/types/components/Datepicker/calendars/CalendarWrapper.d.ts +273 -0
  46. package/dist/types/components/Datepicker/calendars/RangeCalendar.d.ts +11 -0
  47. package/dist/types/components/Datepicker/calendars/YearGrid.d.ts +4 -0
  48. package/dist/types/components/Datepicker/fields/DateField.d.ts +20 -0
  49. package/dist/types/components/Datepicker/fields/DateFieldSegments.d.ts +6 -0
  50. package/dist/types/components/Datepicker/fields/DateRangeField.d.ts +12 -0
  51. package/dist/types/components/Datepicker/fields/DateSegment.d.ts +8 -0
  52. package/dist/types/components/Datepicker/fields/FieldWrapper.d.ts +31 -0
  53. package/dist/types/components/Datepicker/fields/Toggle.d.ts +15 -0
  54. package/dist/types/components/Datepicker/index.d.ts +2 -0
  55. package/dist/types/components/Datepicker/props.d.ts +105 -0
  56. package/dist/types/components/Datepicker/utils/context.d.ts +9 -0
  57. package/dist/types/components/Datepicker/utils/get-calendar-date.d.ts +1 -0
  58. package/dist/types/components/Datepicker/utils/timezone.d.ts +1 -0
  59. package/dist/types/components/Datepicker/utils/types.d.ts +6 -0
  60. package/dist/types/components/Datepicker/utils/useConvertedValidationFunctions.d.ts +8 -0
  61. package/dist/types/components/Label/Label.d.ts +2 -2
  62. package/dist/types/components/Select/NativeSelect.d.ts +3 -3
  63. package/dist/types/components/Switch/Switch.styles.d.ts +6 -7
  64. package/dist/types/components/Tabs/TabList.d.ts +2 -13
  65. package/dist/types/components/TextField/TextField.d.ts +1 -1
  66. package/dist/types/index.d.ts +1 -0
  67. package/package.json +22 -19
@@ -10,6 +10,11 @@ var edsIcons = require('@equinor/eds-icons');
10
10
  var ReactDom = require('react-dom');
11
11
  var downshift = require('downshift');
12
12
  var reactVirtual = require('@tanstack/react-virtual');
13
+ var reactAria = require('react-aria');
14
+ var calendar = require('@react-stately/calendar');
15
+ var date = require('@internationalized/date');
16
+ var datepicker = require('@react-stately/datepicker');
17
+ var utils = require('@react-aria/utils');
13
18
 
14
19
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
20
 
@@ -314,7 +319,6 @@ _curry3(function mergeWithKey(fn, l, r) {
314
319
  }
315
320
  return result;
316
321
  });
317
- var mergeWithKey$1 = mergeWithKey;
318
322
 
319
323
  /**
320
324
  * Creates a new object with the own properties of the two provided objects.
@@ -347,7 +351,7 @@ var mergeWithKey$1 = mergeWithKey;
347
351
 
348
352
  var mergeDeepWithKey = /*#__PURE__*/
349
353
  _curry3(function mergeDeepWithKey(fn, lObj, rObj) {
350
- return mergeWithKey$1(function (k, lVal, rVal) {
354
+ return mergeWithKey(function (k, lVal, rVal) {
351
355
  if (_isObject(lVal) && _isObject(rVal)) {
352
356
  return mergeDeepWithKey(fn, lVal, rVal);
353
357
  } else {
@@ -355,7 +359,6 @@ _curry3(function mergeDeepWithKey(fn, lObj, rObj) {
355
359
  }
356
360
  }, lObj, rObj);
357
361
  });
358
- var mergeDeepWithKey$1 = mergeDeepWithKey;
359
362
 
360
363
  /**
361
364
  * Creates a new object with the own properties of the first object merged with
@@ -381,11 +384,10 @@ var mergeDeepWithKey$1 = mergeDeepWithKey;
381
384
 
382
385
  var mergeDeepRight = /*#__PURE__*/
383
386
  _curry2(function mergeDeepRight(lObj, rObj) {
384
- return mergeDeepWithKey$1(function (k, lVal, rVal) {
387
+ return mergeDeepWithKey(function (k, lVal, rVal) {
385
388
  return rVal;
386
389
  }, lObj, rObj);
387
390
  });
388
- var mergeDeepRight$1 = mergeDeepRight;
389
391
 
390
392
  /**
391
393
  * Creates a new object with the own properties of the two provided objects. If
@@ -413,11 +415,10 @@ var mergeDeepRight$1 = mergeDeepRight;
413
415
 
414
416
  var mergeWith = /*#__PURE__*/
415
417
  _curry3(function mergeWith(fn, l, r) {
416
- return mergeWithKey$1(function (_, _l, _r) {
418
+ return mergeWithKey(function (_, _l, _r) {
417
419
  return fn(_l, _r);
418
420
  }, l, r);
419
421
  });
420
- var mergeWith$1 = mergeWith;
421
422
 
422
423
  /**
423
424
  * Returns a partial copy of an object containing only the keys that satisfy
@@ -450,7 +451,6 @@ _curry2(function pickBy(test, obj) {
450
451
  }
451
452
  return result;
452
453
  });
453
- var pickBy$1 = pickBy;
454
454
 
455
455
  const {
456
456
  colors: {
@@ -486,7 +486,7 @@ const {
486
486
  }
487
487
  }
488
488
  } = edsTokens.tokens;
489
- const primary$a = mergeDeepRight$1(button, {
489
+ const primary$a = mergeDeepRight(button, {
490
490
  background: primaryColor$7,
491
491
  typography: {
492
492
  color: primaryWhite$2
@@ -504,7 +504,7 @@ const primary$a = mergeDeepRight$1(button, {
504
504
  }
505
505
  }
506
506
  });
507
- const secondary$5 = mergeDeepRight$1(primary$a, {
507
+ const secondary$5 = mergeDeepRight(primary$a, {
508
508
  background: secondaryColor$3,
509
509
  border: {
510
510
  color: secondaryColor$3
@@ -518,7 +518,7 @@ const secondary$5 = mergeDeepRight$1(primary$a, {
518
518
  }
519
519
  }
520
520
  });
521
- const danger$6 = mergeDeepRight$1(primary$a, {
521
+ const danger$6 = mergeDeepRight(primary$a, {
522
522
  background: dangerColor$3,
523
523
  border: {
524
524
  color: dangerColor$3
@@ -571,7 +571,7 @@ const {
571
571
  }
572
572
  }
573
573
  } = edsTokens.tokens;
574
- const primary$9 = mergeDeepRight$1(button, {
574
+ const primary$9 = mergeDeepRight(button, {
575
575
  typography: {
576
576
  color: primaryColor$6
577
577
  },
@@ -600,7 +600,7 @@ const primary$9 = mergeDeepRight$1(button, {
600
600
  }
601
601
  }
602
602
  });
603
- const secondary$4 = mergeDeepRight$1(primary$9, {
603
+ const secondary$4 = mergeDeepRight(primary$9, {
604
604
  typography: {
605
605
  color: secondaryColor$2
606
606
  },
@@ -619,7 +619,7 @@ const secondary$4 = mergeDeepRight$1(primary$9, {
619
619
  }
620
620
  }
621
621
  });
622
- const danger$5 = mergeDeepRight$1(primary$9, {
622
+ const danger$5 = mergeDeepRight(primary$9, {
623
623
  typography: {
624
624
  color: dangerColor$2
625
625
  },
@@ -672,7 +672,7 @@ const {
672
672
  }
673
673
  }
674
674
  } = edsTokens.tokens;
675
- const primary$8 = mergeDeepRight$1(button, {
675
+ const primary$8 = mergeDeepRight(button, {
676
676
  typography: {
677
677
  color: primaryColor$5
678
678
  },
@@ -691,7 +691,7 @@ const primary$8 = mergeDeepRight$1(button, {
691
691
  }
692
692
  }
693
693
  });
694
- const secondary$3 = mergeDeepRight$1(primary$8, {
694
+ const secondary$3 = mergeDeepRight(primary$8, {
695
695
  typography: {
696
696
  color: secondaryColor$1
697
697
  },
@@ -704,7 +704,7 @@ const secondary$3 = mergeDeepRight$1(primary$8, {
704
704
  }
705
705
  }
706
706
  });
707
- const danger$4 = mergeDeepRight$1(primary$8, {
707
+ const danger$4 = mergeDeepRight(primary$8, {
708
708
  typography: {
709
709
  color: dangerColor$1
710
710
  },
@@ -758,7 +758,7 @@ const {
758
758
  }
759
759
  }
760
760
  } = edsTokens.tokens;
761
- const primary$7 = mergeDeepRight$1(button, {
761
+ const primary$7 = mergeDeepRight(button, {
762
762
  height: shape$4.icon_button.minHeight,
763
763
  width: shape$4.icon_button.minWidth,
764
764
  typography: {
@@ -776,7 +776,7 @@ const primary$7 = mergeDeepRight$1(button, {
776
776
  clickbound: {
777
777
  width: clicboundHeight$1,
778
778
  offset: {
779
- top: '0',
779
+ top: `${(parseInt(clicboundHeight$1) - parseInt(shape$4.icon_button.minWidth)) / 2}px`,
780
780
  left: `${(parseInt(clicboundHeight$1) - parseInt(shape$4.icon_button.minWidth)) / 2}px`
781
781
  }
782
782
  },
@@ -814,7 +814,7 @@ const primary$7 = mergeDeepRight$1(button, {
814
814
  }
815
815
  }
816
816
  });
817
- const secondary$2 = mergeDeepRight$1(primary$7, {
817
+ const secondary$2 = mergeDeepRight(primary$7, {
818
818
  typography: {
819
819
  color: secondaryColor
820
820
  },
@@ -827,7 +827,7 @@ const secondary$2 = mergeDeepRight$1(primary$7, {
827
827
  }
828
828
  }
829
829
  });
830
- const danger$3 = mergeDeepRight$1(primary$7, {
830
+ const danger$3 = mergeDeepRight(primary$7, {
831
831
  typography: {
832
832
  color: dangerColor
833
833
  },
@@ -862,8 +862,8 @@ const contained_icon = {
862
862
  clickbound: {
863
863
  width: clicboundHeight,
864
864
  offset: {
865
- top: '0',
866
- left: `${(parseInt(clicboundHeight) - parseInt('40px')) / 2}px`
865
+ top: `${(parseInt(clicboundHeight) - parseInt(shape$3.icon_button.minWidth)) / 2}px`,
866
+ left: `${(parseInt(clicboundHeight) - parseInt(shape$3.icon_button.minWidth)) / 2}px`
867
867
  }
868
868
  },
869
869
  states: {
@@ -888,9 +888,9 @@ const contained_icon = {
888
888
  }
889
889
  }
890
890
  };
891
- const primary$6 = mergeDeepRight$1(primary$a, contained_icon);
892
- const secondary$1 = mergeDeepRight$1(secondary$5, contained_icon);
893
- const danger$2 = mergeDeepRight$1(danger$6, contained_icon);
891
+ const primary$6 = mergeDeepRight(primary$a, contained_icon);
892
+ const secondary$1 = mergeDeepRight(secondary$5, contained_icon);
893
+ const danger$2 = mergeDeepRight(danger$6, contained_icon);
894
894
 
895
895
  const token$5 = {
896
896
  primary: {
@@ -970,7 +970,7 @@ const EdsProvider = ({
970
970
  };
971
971
  const useEds = () => react.useContext(EdsContext);
972
972
 
973
- const getVariant = (tokenSet, variant) => {
973
+ const getVariant$1 = (tokenSet, variant) => {
974
974
  switch (variant) {
975
975
  case 'ghost':
976
976
  return tokenSet.ghost;
@@ -988,12 +988,12 @@ const getVariant = (tokenSet, variant) => {
988
988
  const getToken$1 = (variant, color) => {
989
989
  switch (color) {
990
990
  case 'danger':
991
- return getVariant(token$5.danger, variant);
991
+ return getVariant$1(token$5.danger, variant);
992
992
  case 'secondary':
993
- return getVariant(token$5.secondary, variant);
993
+ return getVariant$1(token$5.secondary, variant);
994
994
  case 'primary':
995
995
  default:
996
- return getVariant(token$5.primary, variant);
996
+ return getVariant$1(token$5.primary, variant);
997
997
  }
998
998
  };
999
999
  const Inner = styled__default.default.span.withConfig({
@@ -1015,7 +1015,7 @@ const ButtonBase = styled__default.default.button.withConfig({
1015
1015
  hover,
1016
1016
  disabled
1017
1017
  } = states;
1018
- return styled.css(["box-sizing:border-box;margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::before{position:absolute;top:0;left:0;width:auto;min-height:auto;content:'';}&::after{position:absolute;top:-", ";left:-", ";width:", ";height:", ";content:'';}@media (hover:hover) and (pointer:fine){&:hover{background:", ";color:", ";", ";}}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}&::-moz-focus-inner{border:0;}&:disabled,&[aria-disabled='true']{cursor:not-allowed;background:", ";", ";", ";@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}}"], theme.background, theme.height, theme.width, edsUtils.spacingsTemplate(theme.spacings), edsUtils.bordersTemplate(theme.border), edsUtils.typographyTemplate(theme.typography), clickbound?.offset?.top, clickbound?.offset?.left, clickbound?.width, clickbound?.height, hover.background, hover.typography?.color, edsUtils.bordersTemplate(hover?.border), edsUtils.outlineTemplate(focus.outline), edsUtils.outlineTemplate(focus.outline), disabled.background, edsUtils.bordersTemplate(disabled.border), edsUtils.typographyTemplate(disabled.typography), disabled.background);
1018
+ return styled.css(["box-sizing:border-box;margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::after{position:absolute;top:-", ";left:-", ";width:", ";height:", ";content:'';}@media (hover:hover) and (pointer:fine){&:hover{background:", ";color:", ";", ";}}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}&::-moz-focus-inner{border:0;}&:disabled,&[aria-disabled='true']{cursor:not-allowed;background:", ";", ";", ";@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}}"], theme.background, theme.height, theme.width, edsUtils.spacingsTemplate(theme.spacings), edsUtils.bordersTemplate(theme.border), edsUtils.typographyTemplate(theme.typography), clickbound?.offset?.top, clickbound?.offset?.left, clickbound?.width, clickbound?.height, hover.background, hover.typography?.color, edsUtils.bordersTemplate(hover?.border), edsUtils.outlineTemplate(focus.outline), edsUtils.outlineTemplate(focus.outline), disabled.background, edsUtils.bordersTemplate(disabled.border), edsUtils.typographyTemplate(disabled.typography), disabled.background);
1019
1019
  });
1020
1020
  const Button$2 = /*#__PURE__*/react.forwardRef(function Button({
1021
1021
  color = 'primary',
@@ -1656,7 +1656,7 @@ const tableCell = {
1656
1656
  const applyVariant = (variant, token) => {
1657
1657
  switch (variant) {
1658
1658
  case 'numeric':
1659
- return mergeDeepRight$1(token, token.variants.numeric);
1659
+ return mergeDeepRight(token, token.variants.numeric);
1660
1660
  default:
1661
1661
  return token;
1662
1662
  }
@@ -2195,7 +2195,7 @@ const label = {
2195
2195
  const LabelBase = styled__default.default.label.withConfig({
2196
2196
  displayName: "Label__LabelBase",
2197
2197
  componentId: "sc-1gi2bcn-0"
2198
- })(["display:flex;justify-content:space-between;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], edsUtils.typographyTemplate(label.typography), label.spacings.left, label.spacings.right, ({
2198
+ })(["display:flex;justify-content:space-between;align-items:flex-end;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], edsUtils.typographyTemplate(label.typography), label.spacings.left, label.spacings.right, ({
2199
2199
  $disabledText
2200
2200
  }) => $disabledText ? label.states.disabled.typography.color : label.typography.color);
2201
2201
  const Text$3 = styled__default.default.span.withConfig({
@@ -2398,7 +2398,7 @@ const input$2 = {
2398
2398
  }
2399
2399
  }
2400
2400
  };
2401
- const error$4 = mergeDeepRight$1(input$2, {
2401
+ const error$4 = mergeDeepRight(input$2, {
2402
2402
  boxShadow: 'none',
2403
2403
  outline: {
2404
2404
  color: danger__resting$1.rgba
@@ -2419,7 +2419,7 @@ const error$4 = mergeDeepRight$1(input$2, {
2419
2419
  }
2420
2420
  }
2421
2421
  });
2422
- const warning$4 = mergeDeepRight$1(input$2, {
2422
+ const warning$4 = mergeDeepRight(input$2, {
2423
2423
  boxShadow: 'none',
2424
2424
  outline: {
2425
2425
  color: warning__resting$1.rgba
@@ -2440,7 +2440,7 @@ const warning$4 = mergeDeepRight$1(input$2, {
2440
2440
  }
2441
2441
  }
2442
2442
  });
2443
- const success$1 = mergeDeepRight$1(input$2, {
2443
+ const success$1 = mergeDeepRight(input$2, {
2444
2444
  boxShadow: 'none',
2445
2445
  outline: {
2446
2446
  color: success__resting$1.rgba
@@ -2633,7 +2633,7 @@ const input$1 = {
2633
2633
  }
2634
2634
  }
2635
2635
  };
2636
- const error$3 = mergeDeepRight$1(input$1, {
2636
+ const error$3 = mergeDeepRight(input$1, {
2637
2637
  boxShadow: 'none',
2638
2638
  outline: {
2639
2639
  color: danger__resting.rgba
@@ -2661,7 +2661,7 @@ const error$3 = mergeDeepRight$1(input$1, {
2661
2661
  }
2662
2662
  }
2663
2663
  });
2664
- const warning$3 = mergeDeepRight$1(input$1, {
2664
+ const warning$3 = mergeDeepRight(input$1, {
2665
2665
  boxShadow: 'none',
2666
2666
  outline: {
2667
2667
  color: warning__resting.rgba
@@ -2689,7 +2689,7 @@ const warning$3 = mergeDeepRight$1(input$1, {
2689
2689
  }
2690
2690
  }
2691
2691
  });
2692
- const success = mergeDeepRight$1(input$1, {
2692
+ const success = mergeDeepRight(input$1, {
2693
2693
  boxShadow: 'none',
2694
2694
  outline: {
2695
2695
  color: success__resting.rgba
@@ -2901,15 +2901,21 @@ const Textarea = /*#__PURE__*/react.forwardRef(function Textarea({
2901
2901
  variant,
2902
2902
  ...other
2903
2903
  };
2904
- const adornmentsToTop = {
2904
+ const leftAdornmentStyles = {
2905
2905
  style: {
2906
2906
  alignItems: 'flex-start'
2907
2907
  }
2908
2908
  };
2909
+ const rigthAdornmentStyles = {
2910
+ style: {
2911
+ alignItems: 'flex-start',
2912
+ pointerEvents: 'none'
2913
+ }
2914
+ };
2909
2915
  return /*#__PURE__*/jsxRuntime.jsx(Input$4, {
2910
2916
  as: "textarea",
2911
- rightAdornmentsProps: adornmentsToTop,
2912
- leftAdornmentsProps: adornmentsToTop,
2917
+ rightAdornmentsProps: rigthAdornmentStyles,
2918
+ leftAdornmentsProps: leftAdornmentStyles,
2913
2919
  style: {
2914
2920
  height: 'auto'
2915
2921
  },
@@ -2947,13 +2953,14 @@ const TextField = /*#__PURE__*/react.forwardRef(function TextField({
2947
2953
  ...other
2948
2954
  }, ref) {
2949
2955
  const helperTextId = edsUtils.useId(null, 'helpertext');
2956
+ const hasRightAdornments = Boolean(unit || inputIcon);
2950
2957
  let fieldProps = {
2951
2958
  'aria-invalid': variant === 'error' || undefined,
2952
2959
  disabled,
2953
2960
  placeholder,
2954
2961
  id,
2955
2962
  variant,
2956
- rightAdornments: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2963
+ rightAdornments: hasRightAdornments && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2957
2964
  children: [inputIcon, /*#__PURE__*/jsxRuntime.jsx("span", {
2958
2965
  children: unit
2959
2966
  })]
@@ -7349,7 +7356,7 @@ const Breadcrumbs$1 = /*#__PURE__*/react.forwardRef(function Breadcrumbs({
7349
7356
  }, "collapsed"), allCrumbs[allCrumbs.length - 1]];
7350
7357
  };
7351
7358
  const allCrumbs = react.Children.toArray(children).map((child, index) =>
7352
-
7359
+ /*#__PURE__*/
7353
7360
  // eslint-disable-next-line react/no-array-index-key
7354
7361
  jsxRuntime.jsxs(react.Fragment, {
7355
7362
  children: [/*#__PURE__*/jsxRuntime.jsx(ListItem$1, {
@@ -7634,7 +7641,7 @@ const Item = styled__default.default.button.attrs(({
7634
7641
  $active
7635
7642
  }) => $active && styled.css(["background:", ";*{color:", ";}"], activeToken.background, activeToken.typography.color), ({
7636
7643
  disabled
7637
- }) => disabled ? styled.css(["*{color:", ";}svg{fill:", ";}&:focus{outline:none;}@media (hover:hover) and (pointer:fine){&:hover{cursor:not-allowed;}}"], disabledToken.typography.color, icon.states.disabled.typography.color) : styled.css(["@media (hover:hover) and (pointer:fine){&:hover{z-index:1;cursor:pointer;background:", ";}}&:focus{z-index:3;", "}"], hover.background, edsUtils.outlineTemplate(focus$2.outline)));
7644
+ }) => disabled ? styled.css(["*{color:", ";}svg{fill:", ";}@media (hover:hover) and (pointer:fine){&:hover{cursor:not-allowed;}}"], disabledToken.typography.color, icon.states.disabled.typography.color) : styled.css(["@media (hover:hover) and (pointer:fine){&:hover{cursor:pointer;background:", ";}}&:focus-visible{z-index:3;", "}"], hover.background, edsUtils.outlineTemplate(focus$2.outline)));
7638
7645
  const Content = styled__default.default.div.withConfig({
7639
7646
  displayName: "MenuItem__Content",
7640
7647
  componentId: "sc-1g9fpbe-1"
@@ -9335,7 +9342,7 @@ const selectTokens = {
9335
9342
  }
9336
9343
  }
9337
9344
  };
9338
- const multiSelect = mergeDeepRight$1(selectTokens, {
9345
+ const multiSelect = mergeDeepRight(selectTokens, {
9339
9346
  spacings: {
9340
9347
  top: '0',
9341
9348
  bottom: '0',
@@ -9438,7 +9445,7 @@ const AutocompleteNoOptions = styled__default.default(AutocompleteOption).withCo
9438
9445
  })(({
9439
9446
  theme
9440
9447
  }) => styled.css(["color:", ";"], theme.entities.noOptions.typography.color));
9441
- const StyledButton = styled__default.default(Button$1).withConfig({
9448
+ const StyledButton$1 = styled__default.default(Button$1).withConfig({
9442
9449
  displayName: "Autocomplete__StyledButton",
9443
9450
  componentId: "sc-yvif0e-4"
9444
9451
  })(({
@@ -9473,9 +9480,9 @@ const findIndex = ({
9473
9480
  };
9474
9481
  const isEvent = (val, key) => /^on[A-Z](.*)/.test(key) && typeof val === 'function';
9475
9482
  function mergeEventsFromRight(props1, props2) {
9476
- const events1 = pickBy$1(isEvent, props1);
9477
- const events2 = pickBy$1(isEvent, props2);
9478
- return mergeWith$1((event1, event2) => {
9483
+ const events1 = pickBy(isEvent, props1);
9484
+ const events2 = pickBy(isEvent, props2);
9485
+ return mergeWith((event1, event2) => {
9479
9486
  return (...args) => {
9480
9487
  event1(...args);
9481
9488
  event2(...args);
@@ -9936,7 +9943,7 @@ function AutocompleteInner(props, ref) {
9936
9943
  setTypedInputValue('');
9937
9944
  };
9938
9945
  const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly && !hideClearButton;
9939
- const showNoOptions = isOpen && !availableItems.length && inputValue.length > 0 && noOptionsText.length > 0;
9946
+ const showNoOptions = isOpen && !availableItems.length && noOptionsText.length > 0;
9940
9947
  const selectedItemsLabels = react.useMemo(() => selectedItems.map(getLabel), [selectedItems, getLabel]);
9941
9948
 
9942
9949
  //temporary fix when inside dialog. Should be replaced by popover api when it is ready
@@ -10063,7 +10070,7 @@ function AutocompleteInner(props, ref) {
10063
10070
  rightAdornments: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
10064
10071
  children: [loading && /*#__PURE__*/jsxRuntime.jsx(Progress.Circular, {
10065
10072
  size: 16
10066
- }), showClearButton && /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
10073
+ }), showClearButton && /*#__PURE__*/jsxRuntime.jsx(StyledButton$1, {
10067
10074
  variant: "ghost_icon",
10068
10075
  disabled: disabled || readOnly,
10069
10076
  "aria-label": 'clear options',
@@ -10073,7 +10080,7 @@ function AutocompleteInner(props, ref) {
10073
10080
  data: edsIcons.close,
10074
10081
  size: 16
10075
10082
  })
10076
- }), !readOnly && /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
10083
+ }), !readOnly && /*#__PURE__*/jsxRuntime.jsx(StyledButton$1, {
10077
10084
  variant: "ghost_icon",
10078
10085
  ...getToggleButtonProps({
10079
10086
  disabled: disabled || readOnly
@@ -10973,6 +10980,1136 @@ SideBar.Button.displayName = 'SideBar.Button';
10973
10980
  SideBar.Accordion.displayName = 'SideBar.Accordion';
10974
10981
  SideBar.AccordionItem.displayName = 'SideBar.AccordionItem';
10975
10982
 
10983
+ const StyledCell = styled__default.default(Typography).withConfig({
10984
+ displayName: "CalendarCell__StyledCell",
10985
+ componentId: "sc-y5ycmg-0"
10986
+ })(["display:flex;justify-content:center;align-items:center;cursor:pointer;&:hover{background-color:", ";}&:focus{outline:2px dashed rgba(0,112,121,1);}", " ", " ", " ", " ", " ", ""], edsTokens.tokens.colors.interactive.table__cell__fill_hover.rgba, ({
10987
+ $selected
10988
+ }) => $selected && `background-color: ${edsTokens.tokens.colors.interactive.primary__selected_highlight.rgba};`, ({
10989
+ $hidden
10990
+ }) => $hidden && `visibility: hidden;`, ({
10991
+ $highlight
10992
+ }) => {
10993
+ switch ($highlight) {
10994
+ case 'SINGLE':
10995
+ case 'NONE':
10996
+ case 'BOTH':
10997
+ return 'border-radius: 50%;';
10998
+ case 'END':
10999
+ return 'border-radius: 0% 50% 50% 0;';
11000
+ case 'START':
11001
+ return 'border-radius: 50% 0% 0% 50%;';
11002
+ case 'RANGE':
11003
+ return '';
11004
+ }
11005
+ }, ({
11006
+ $disabled
11007
+ }) => $disabled && `
11008
+
11009
+ color: ${edsTokens.tokens.colors.interactive.disabled__text.rgba};
11010
+ &:hover {
11011
+ background-color: transparent;
11012
+ cursor: not-allowed;
11013
+ }
11014
+ `, ({
11015
+ $selected,
11016
+ $disabled
11017
+ }) => {
11018
+ if ($selected && $disabled) {
11019
+ return `background-color: ${edsTokens.tokens.colors.interactive.warning__highlight.rgba};
11020
+ &:hover {
11021
+ background-color: ${edsTokens.tokens.colors.interactive.warning__highlight.rgba};
11022
+ }`;
11023
+ }
11024
+ }, ({
11025
+ $density
11026
+ }) => {
11027
+ switch ($density) {
11028
+ case 'compact':
11029
+ return `
11030
+ height: 32px;
11031
+ width: 32px;
11032
+ padding: 2px;
11033
+ `;
11034
+ case 'comfortable':
11035
+ return `
11036
+ height: 40px;
11037
+ width: 40px;
11038
+ padding: 4px;
11039
+ `;
11040
+ }
11041
+ });
11042
+ const StyledTd = styled__default.default.td.withConfig({
11043
+ displayName: "CalendarCell__StyledTd",
11044
+ componentId: "sc-y5ycmg-1"
11045
+ })(["border:0;border-spacing:0;"]);
11046
+
11047
+ /**
11048
+ * CalendarCell is used to represent a single cell in {@link Calendar} and {@link RangeCalendar}
11049
+ */
11050
+ function CalendarCell({
11051
+ state,
11052
+ date
11053
+ }) {
11054
+ const ref = react.useRef(null);
11055
+ const {
11056
+ density
11057
+ } = useEds();
11058
+ const {
11059
+ cellProps,
11060
+ buttonProps,
11061
+ isSelected,
11062
+ isOutsideVisibleRange,
11063
+ isDisabled,
11064
+ isUnavailable,
11065
+ formattedDate
11066
+ } = reactAria.useCalendarCell({
11067
+ date
11068
+ }, state, ref);
11069
+
11070
+ /**
11071
+ * Determines how the selection should be highlighted
11072
+ * If range is selected, it will highlight start - end, with differing border-radius
11073
+ */
11074
+ const isHighlight = react.useMemo(() => {
11075
+ if (isSelected && 'highlightedRange' in state) {
11076
+ const start = state.highlightedRange.start;
11077
+ const end = state.highlightedRange.end;
11078
+ const startSame = start.day === date.day && start.month === date.month && start.year === date.year;
11079
+ const endSame = end.day === date.day && end.month === date.month && end.year === date.year;
11080
+ if (startSame && endSame) {
11081
+ return 'BOTH';
11082
+ }
11083
+ if (startSame) {
11084
+ return 'START';
11085
+ } else if (endSame) {
11086
+ return 'END';
11087
+ } else {
11088
+ return 'RANGE';
11089
+ }
11090
+ } else if (isSelected) {
11091
+ return 'SINGLE';
11092
+ }
11093
+ return 'NONE';
11094
+ }, [date.day, date.month, date.year, isSelected, state]);
11095
+ return /*#__PURE__*/jsxRuntime.jsx(StyledTd, {
11096
+ ...cellProps,
11097
+ style: {
11098
+ border: 0,
11099
+ borderSpacing: 0,
11100
+ padding: 0
11101
+ },
11102
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledCell, {
11103
+ ...buttonProps,
11104
+ as: 'div',
11105
+ ref: ref,
11106
+ tabIndex: 0,
11107
+ $hidden: isOutsideVisibleRange,
11108
+ className: `cell ${isSelected ? 'selected' : ''} ${isUnavailable ? 'unavailable' : ''}${isDisabled ? 'disabled' : ''}`,
11109
+ $selected: isSelected,
11110
+ $highlight: isHighlight,
11111
+ $disabled: isDisabled || isUnavailable,
11112
+ $density: density,
11113
+ children: formattedDate
11114
+ })
11115
+ });
11116
+ }
11117
+
11118
+ // Disable no-autofocus - it's not the native autofocus attribute, but react-aria's autoFocus prop
11119
+ /* eslint-disable jsx-a11y/no-autofocus */
11120
+ const Grid = styled__default.default.div.withConfig({
11121
+ displayName: "YearGrid__Grid",
11122
+ componentId: "sc-1l9jho8-0"
11123
+ })(["display:grid;grid-template-columns:repeat(6,1fr);grid-gap:8px;margin:8px;"]);
11124
+ const GridColumn = styled__default.default.button.withConfig({
11125
+ displayName: "YearGrid__GridColumn",
11126
+ componentId: "sc-1l9jho8-1"
11127
+ })(["background-color:transparent;outline:none;border:none;display:flex;justify-content:center;cursor:pointer;padding:8px;font-size:", ";font-family:", ";font-weight:", ";line-height:", ";color:", ";border-radius:999px;", ";&:hover{background-color:#f0f0f0;}&:focus{outline:2px dashed ", ";}"], edsTokens.tokens.typography.navigation.button.fontSize, edsTokens.tokens.typography.navigation.button.fontFamily, edsTokens.tokens.typography.navigation.button.fontWeight, edsTokens.tokens.typography.navigation.button.lineHeight, edsTokens.tokens.colors.text.static_icons__default.rgba, ({
11128
+ $active
11129
+ }) => $active ? `background-color: ${edsTokens.tokens.colors.interactive.primary__selected_highlight.rgba}` : '', edsTokens.tokens.colors.interactive.primary__resting.rgba);
11130
+ const GridFocusManager = ({
11131
+ year: selectedYear,
11132
+ setFocusedYear
11133
+ }) => {
11134
+ const focusManager = reactAria.useFocusManager();
11135
+ const onKeyDown = e => {
11136
+ const target = e.currentTarget;
11137
+ const parent = target.parentElement;
11138
+ switch (e.key) {
11139
+ case 'ArrowRight':
11140
+ e.preventDefault();
11141
+ focusManager.focusNext({
11142
+ wrap: true
11143
+ });
11144
+ break;
11145
+ case 'ArrowLeft':
11146
+ e.preventDefault();
11147
+ focusManager.focusPrevious({
11148
+ wrap: true
11149
+ });
11150
+ break;
11151
+ case 'ArrowDown':
11152
+ {
11153
+ e.preventDefault();
11154
+ const selfIndex = Array.from(parent.children).indexOf(target);
11155
+ const focusElement = Array.from(parent.children).at(selfIndex + 5);
11156
+ focusManager.focusNext({
11157
+ from: focusElement
11158
+ });
11159
+ break;
11160
+ }
11161
+ case 'ArrowUp':
11162
+ {
11163
+ e.preventDefault();
11164
+ const selfIndex = Array.from(parent.children).indexOf(target);
11165
+ const focusElement = Array.from(parent.children).at(selfIndex - 5);
11166
+ focusManager.focusPrevious({
11167
+ from: focusElement
11168
+ });
11169
+ break;
11170
+ }
11171
+ }
11172
+ };
11173
+ const years = Array.from({
11174
+ length: 36
11175
+ }, (_, i) => i + (selectedYear - 30 / 2));
11176
+ return years.map(year => /*#__PURE__*/jsxRuntime.jsx(GridColumn, {
11177
+ $active: selectedYear === year,
11178
+ onKeyDown: onKeyDown,
11179
+ onClick: () => setFocusedYear(year),
11180
+ "aria-label": `Set year to ${year}`,
11181
+ tabIndex: 0,
11182
+ children: year
11183
+ }, year));
11184
+ };
11185
+ const YearGrid = ({
11186
+ setFocusedYear,
11187
+ year: selectedYear
11188
+ }) => {
11189
+ return /*#__PURE__*/jsxRuntime.jsx(Grid, {
11190
+ children: /*#__PURE__*/jsxRuntime.jsx(reactAria.FocusScope, {
11191
+ contain: true,
11192
+ restoreFocus: true,
11193
+ autoFocus: true,
11194
+ children: /*#__PURE__*/jsxRuntime.jsx(GridFocusManager, {
11195
+ year: selectedYear,
11196
+ setFocusedYear: setFocusedYear
11197
+ })
11198
+ })
11199
+ });
11200
+ };
11201
+
11202
+ /* eslint-disable react/no-array-index-key */
11203
+
11204
+ function CalendarGrid({
11205
+ state,
11206
+ showYearPicker,
11207
+ setShowYearPicker,
11208
+ ...props
11209
+ }) {
11210
+ const {
11211
+ locale
11212
+ } = reactAria.useLocale();
11213
+ const {
11214
+ gridProps,
11215
+ headerProps,
11216
+ weekDays
11217
+ } = reactAria.useCalendarGrid({
11218
+ ...props,
11219
+ weekdayStyle: 'long'
11220
+ }, state);
11221
+
11222
+ // Get the number of weeks in the month so that we can render the proper number of rows.
11223
+ const howManyWeeksInMonth = date.getWeeksInMonth(state.visibleRange.start, locale);
11224
+ const weeksInMonthArray = [...new Array(howManyWeeksInMonth).keys()];
11225
+ return showYearPicker ? /*#__PURE__*/jsxRuntime.jsx(YearGrid, {
11226
+ year: state.focusedDate.year,
11227
+ setFocusedYear: year => {
11228
+ state.setFocusedDate(state.focusedDate.set({
11229
+ year
11230
+ }));
11231
+ setShowYearPicker(false);
11232
+ }
11233
+ }) : /*#__PURE__*/jsxRuntime.jsxs("table", {
11234
+ ...gridProps,
11235
+ style: {
11236
+ borderSpacing: '0px'
11237
+ },
11238
+ children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
11239
+ ...headerProps,
11240
+ children: /*#__PURE__*/jsxRuntime.jsx("tr", {
11241
+ children: weekDays.map((day, index) => /*#__PURE__*/jsxRuntime.jsx("th", {
11242
+ style: {
11243
+ textAlign: 'center'
11244
+ },
11245
+ abbr: day,
11246
+ children: day.charAt(0).toLocaleUpperCase()
11247
+ }, `${day}-${index}`))
11248
+ })
11249
+ }), /*#__PURE__*/jsxRuntime.jsx("tbody", {
11250
+ children: weeksInMonthArray.map(weekIndex => /*#__PURE__*/jsxRuntime.jsx("tr", {
11251
+ children: state.getDatesInWeek(weekIndex).map((date, i) => date ? /*#__PURE__*/jsxRuntime.jsx(CalendarCell, {
11252
+ state: state,
11253
+ date: date
11254
+ }, date.toString()) : /*#__PURE__*/jsxRuntime.jsx("td", {}, `placeholder-${i}`))
11255
+ }, weekIndex))
11256
+ })]
11257
+ });
11258
+ }
11259
+
11260
+ const HeaderWrapper = styled__default.default.div.withConfig({
11261
+ displayName: "CalendarHeader__HeaderWrapper",
11262
+ componentId: "sc-kuy15-0"
11263
+ })(["display:flex;justify-content:space-between;align-items:center;text-transform:capitalize;width:100%;"]);
11264
+ function TodayPicker({
11265
+ onClick,
11266
+ disabled
11267
+ }) {
11268
+ const today = new Date();
11269
+ return /*#__PURE__*/jsxRuntime.jsx(Button$1, {
11270
+ disabled: disabled,
11271
+ onClick: () => onClick(new date.CalendarDate(today.getFullYear(), today.getMonth() + 1, today.getDate())),
11272
+ variant: 'ghost',
11273
+ style: {
11274
+ marginLeft: 16
11275
+ },
11276
+ children: "Today"
11277
+ });
11278
+ }
11279
+ const HeaderActions = styled__default.default.div.withConfig({
11280
+ displayName: "CalendarHeader__HeaderActions",
11281
+ componentId: "sc-kuy15-1"
11282
+ })(["display:flex;align-items:center;width:100%;"]);
11283
+
11284
+ /**
11285
+ * The default header for the calendar components if no custom header is provided
11286
+ */
11287
+ function CalendarHeader({
11288
+ state,
11289
+ title,
11290
+ previousMonthDisabled,
11291
+ nextMonthDisabled,
11292
+ showYearPicker,
11293
+ setShowYearPicker
11294
+ }) {
11295
+ return /*#__PURE__*/jsxRuntime.jsx(HeaderWrapper, {
11296
+ children: /*#__PURE__*/jsxRuntime.jsxs(HeaderActions, {
11297
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button$1, {
11298
+ variant: 'ghost_icon',
11299
+ "aria-label": 'Previous month',
11300
+ disabled: previousMonthDisabled || showYearPicker,
11301
+ onClick: () => state.focusPreviousPage(),
11302
+ children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
11303
+ data: edsIcons.chevron_left
11304
+ })
11305
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
11306
+ style: {
11307
+ flex: '1 1 auto'
11308
+ }
11309
+ }), /*#__PURE__*/jsxRuntime.jsxs(Button$1, {
11310
+ onClick: () => setShowYearPicker(!showYearPicker),
11311
+ "data-testid": 'heading',
11312
+ "aria-live": 'polite',
11313
+ variant: 'ghost',
11314
+ style: {
11315
+ fontSize: edsTokens.tokens.typography.heading.h5.fontSize,
11316
+ textTransform: 'capitalize'
11317
+ },
11318
+ children: [title, /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
11319
+ data: showYearPicker ? edsIcons.chevron_up : edsIcons.chevron_down
11320
+ })]
11321
+ }), /*#__PURE__*/jsxRuntime.jsx(TodayPicker, {
11322
+ disabled: showYearPicker,
11323
+ onClick: v => state.setFocusedDate(v)
11324
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
11325
+ style: {
11326
+ flex: '1 1 auto'
11327
+ }
11328
+ }), /*#__PURE__*/jsxRuntime.jsx(Button$1, {
11329
+ variant: 'ghost_icon',
11330
+ onClick: () => state.focusNextPage(),
11331
+ disabled: nextMonthDisabled || showYearPicker,
11332
+ "aria-label": 'Next month',
11333
+ children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
11334
+ data: edsIcons.chevron_right
11335
+ })
11336
+ })]
11337
+ })
11338
+ });
11339
+ }
11340
+
11341
+ const CalendarWrapper = styled__default.default.div.withConfig({
11342
+ displayName: "CalendarWrapper",
11343
+ componentId: "sc-14hqwiu-0"
11344
+ })(["display:grid;grid-gap:16px;max-height:80vh;width:max-content;max-width:560px;overflow:auto;"]);
11345
+
11346
+ const Calendar = /*#__PURE__*/react.forwardRef(({
11347
+ Header,
11348
+ Footer,
11349
+ ...props
11350
+ }, ref) => {
11351
+ const [showYearPicker, setShowYearPicker] = react.useState(false);
11352
+ const {
11353
+ locale
11354
+ } = reactAria.useLocale();
11355
+ const calendarState = calendar.useCalendarState({
11356
+ ...props,
11357
+ locale,
11358
+ createCalendar: date.createCalendar
11359
+ });
11360
+ const {
11361
+ calendarProps,
11362
+ prevButtonProps,
11363
+ nextButtonProps,
11364
+ title
11365
+ } = reactAria.useCalendar(props, calendarState);
11366
+ return /*#__PURE__*/jsxRuntime.jsxs(CalendarWrapper, {
11367
+ ref: ref,
11368
+ ...calendarProps,
11369
+ children: [/*#__PURE__*/jsxRuntime.jsx(Popover.Header, {
11370
+ style: {
11371
+ width: '100%'
11372
+ },
11373
+ children: Header ? /*#__PURE__*/jsxRuntime.jsx(Header, {
11374
+ month: calendarState.focusedDate.month,
11375
+ state: calendarState,
11376
+ setMonth: month => calendarState.setFocusedDate(calendarState.focusedDate.set({
11377
+ month
11378
+ })),
11379
+ setYear: year => calendarState.setFocusedDate(calendarState.focusedDate.set({
11380
+ year
11381
+ })),
11382
+ year: calendarState.focusedDate.year
11383
+ }) : /*#__PURE__*/jsxRuntime.jsx(CalendarHeader, {
11384
+ state: calendarState,
11385
+ title: title,
11386
+ previousMonthDisabled: prevButtonProps.isDisabled,
11387
+ nextMonthDisabled: nextButtonProps.isDisabled,
11388
+ setShowYearPicker: setShowYearPicker,
11389
+ showYearPicker: showYearPicker
11390
+ })
11391
+ }), /*#__PURE__*/jsxRuntime.jsx(Popover.Content, {
11392
+ className: "calendar",
11393
+ style: {
11394
+ height: 'fit-content'
11395
+ },
11396
+ children: /*#__PURE__*/jsxRuntime.jsx(CalendarGrid, {
11397
+ state: calendarState,
11398
+ setShowYearPicker: setShowYearPicker,
11399
+ showYearPicker: showYearPicker
11400
+ })
11401
+ }), Footer && /*#__PURE__*/jsxRuntime.jsx(Popover.Actions, {
11402
+ children: /*#__PURE__*/jsxRuntime.jsx(Footer, {
11403
+ month: calendarState.focusedDate.month,
11404
+ state: calendarState,
11405
+ setMonth: month => calendarState.setFocusedDate(calendarState.focusedDate.set({
11406
+ month
11407
+ })),
11408
+ setYear: year => calendarState.setFocusedDate(calendarState.focusedDate.set({
11409
+ year
11410
+ })),
11411
+ year: calendarState.focusedDate.year
11412
+ })
11413
+ })]
11414
+ });
11415
+ });
11416
+ Calendar.displayName = 'Calendar';
11417
+
11418
+ const getVariant = variant => {
11419
+ if (variant === 'error') {
11420
+ return edsTokens.tokens.colors.interactive.danger__resting.rgba;
11421
+ }
11422
+ if (variant === 'success') {
11423
+ return edsTokens.tokens.colors.interactive.success__resting.rgba;
11424
+ }
11425
+ if (variant === 'warning') {
11426
+ return edsTokens.tokens.colors.interactive.warning__resting.rgba;
11427
+ }
11428
+ return edsTokens.tokens.colors.interactive.primary__resting.rgba;
11429
+ };
11430
+ const getVariantText = variant => {
11431
+ if (variant === 'error') {
11432
+ return edsTokens.tokens.colors.interactive.danger__text.rgba;
11433
+ }
11434
+ if (variant === 'success') {
11435
+ return edsTokens.tokens.colors.interactive.success__text.rgba;
11436
+ }
11437
+ if (variant === 'warning') {
11438
+ return edsTokens.tokens.colors.interactive.warning__text.rgba;
11439
+ }
11440
+ return edsTokens.tokens.typography.input.text.color;
11441
+ };
11442
+ const StyledInputFieldWrapper = styled__default.default.div.withConfig({
11443
+ displayName: "FieldWrapper__StyledInputFieldWrapper",
11444
+ componentId: "sc-1h0kqs9-0"
11445
+ })(["display:flex;align-items:center;background-color:", ";height:", ";padding:0 8px;", " ", " color:", ";cursor:default;"], edsTokens.tokens.colors.ui.background__light.rgba, ({
11446
+ $density
11447
+ }) => $density === 'compact' ? '24px' : '36px', ({
11448
+ $variant,
11449
+ $disabled,
11450
+ $readonly
11451
+ }) => {
11452
+ if (!$variant && !$readonly) {
11453
+ return `&:focus-within:not(.invalid) {
11454
+ outline: 2px solid
11455
+ ${edsTokens.tokens.colors.interactive.primary__resting.rgba};
11456
+ }
11457
+
11458
+ ${!$disabled && `&:not(:focus-within) {
11459
+ box-shadow: inset 0 -1px 0 0 ${edsTokens.tokens.colors.text.static_icons__tertiary.rgba};`}
11460
+ }
11461
+ `;
11462
+ }
11463
+ return `outline: 2px solid ${getVariant($variant)};`;
11464
+ }, ({
11465
+ $readonly
11466
+ }) => {
11467
+ return $readonly && `background-color: ${edsTokens.tokens.colors.ui.background__default.rgba};
11468
+ outline: none;`;
11469
+ }, p => getVariantText(p.$variant));
11470
+ /**
11471
+ * Applies styles around the date input fields (density, color etc.)
11472
+ */
11473
+ const InputFieldWrapper = /*#__PURE__*/react.forwardRef(({
11474
+ children,
11475
+ color,
11476
+ disabled,
11477
+ readonly,
11478
+ ...props
11479
+ }, ref) => {
11480
+ const {
11481
+ density
11482
+ } = useEds();
11483
+ // As the props returned are designed for react-aria, some of them are not valid DOM props (i.e. onPress).
11484
+ // The filterDOMProps-method strips out the invalid props, but it also removes event listeners due to casing
11485
+ const filteredProps = utils.filterDOMProps(props);
11486
+ // filterDOMProps also strips event handlers
11487
+ const eventHandlers = Object.keys(props).filter(k => k.startsWith('on')).reduce((a, b) => ({
11488
+ ...a,
11489
+ [b]: props[b]
11490
+ }), {});
11491
+ return /*#__PURE__*/jsxRuntime.jsx(StyledInputFieldWrapper, {
11492
+ ref: ref,
11493
+ $density: density,
11494
+ $variant: color,
11495
+ $disabled: disabled ?? false,
11496
+ $readonly: readonly ?? false,
11497
+ ...filteredProps,
11498
+ ...eventHandlers,
11499
+ children: children
11500
+ });
11501
+ });
11502
+ const FieldWrapper = /*#__PURE__*/react.forwardRef(({
11503
+ children,
11504
+ pickerRef,
11505
+ calendar,
11506
+ isOpen,
11507
+ setIsOpen,
11508
+ label,
11509
+ readonly,
11510
+ ...props
11511
+ }, ref) => {
11512
+ react.useEffect(() => {
11513
+ if (isOpen === false) {
11514
+ // Focus the first segment in the input field
11515
+ const segment = ref.current?.querySelector('.segment');
11516
+ segment?.focus();
11517
+ }
11518
+ }, [ref, isOpen, pickerRef]);
11519
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
11520
+ children: [/*#__PURE__*/jsxRuntime.jsx(InputWrapper$2, {
11521
+ readOnly: readonly,
11522
+ label: label,
11523
+ onKeyDownCapture: event => {
11524
+ const isIconTarget = event.target instanceof SVGSVGElement;
11525
+ if (!isIconTarget && (event.code === 'Space' || event.code === 'Enter')) {
11526
+ setIsOpen(true);
11527
+ }
11528
+ },
11529
+ ...props,
11530
+ children: children
11531
+ }), /*#__PURE__*/jsxRuntime.jsx(Popover, {
11532
+ open: isOpen ?? false,
11533
+ onClose: () => setIsOpen(false),
11534
+ anchorEl: ref.current,
11535
+ placement: 'bottom-start',
11536
+ withinPortal: true,
11537
+ children: calendar
11538
+ })]
11539
+ });
11540
+ });
11541
+ InputFieldWrapper.displayName = 'InputFieldWrapper';
11542
+ FieldWrapper.displayName = 'FieldWrapper';
11543
+
11544
+ const Segment = styled__default.default.div.withConfig({
11545
+ displayName: "DateSegment__Segment",
11546
+ componentId: "sc-19uidpx-0"
11547
+ })(["color:", ";font-family:", ";&:focus-visible{outline:2px solid ", ";background-color:", ";}", ""], edsTokens.tokens.typography.input.text.color, edsTokens.tokens.typography.input.text.fontFamily, edsTokens.tokens.colors.interactive.primary__resting.rgba, edsTokens.tokens.colors.ui.background__medium.rgba, ({
11548
+ $disabled
11549
+ }) => $disabled && `color: ${edsTokens.tokens.colors.interactive.disabled__text.rgba};`);
11550
+
11551
+ /**
11552
+ * DateSegment is used to represent a single segment of a date in the DateField (i.e. day, month, year)
11553
+ */
11554
+ function DateSegment({
11555
+ segment,
11556
+ state
11557
+ }) {
11558
+ const ref = react.useRef(null);
11559
+ const {
11560
+ segmentProps
11561
+ } = reactAria.useDateSegment(segment, state, ref);
11562
+ return /*#__PURE__*/jsxRuntime.jsx(Segment, {
11563
+ ...segmentProps,
11564
+ $invalid: state.isInvalid,
11565
+ $disabled: state.isDisabled,
11566
+ $placeholder: segment.isPlaceholder,
11567
+ style: {
11568
+ padding: segment.type === 'literal' ? '0 2px' : '0'
11569
+ },
11570
+ onKeyDown: e => {
11571
+ if (e.code === 'Enter' || e.code === 'Space') {
11572
+ e.stopPropagation();
11573
+ e.preventDefault();
11574
+ } else if (segmentProps.onKeyDown) {
11575
+ segmentProps.onKeyDown(e);
11576
+ }
11577
+ },
11578
+ ref: ref,
11579
+ className: `segment ${segment.isPlaceholder ? 'placeholder' : ''}`,
11580
+ children: segment.isPlaceholder || segment.type === 'literal' ? segment.text : segment.text.padStart(segment.type === 'year' ? 4 : 2, '0')
11581
+ });
11582
+ }
11583
+
11584
+ // In some cases we need to use the index as key
11585
+ /* eslint-disable react/no-array-index-key */
11586
+ /**
11587
+ * A field that wraps segments for inputting a date / date-time
11588
+ */
11589
+ const DateFieldSegments = /*#__PURE__*/react.forwardRef((props, ref) => {
11590
+ const {
11591
+ locale
11592
+ } = reactAria.useLocale();
11593
+ const state = datepicker.useDateFieldState({
11594
+ ...props,
11595
+ locale,
11596
+ createCalendar: date.createCalendar
11597
+ });
11598
+ const {
11599
+ fieldProps
11600
+ } = reactAria.useDateField({
11601
+ ...props,
11602
+ // Type-casting as react-aria expects string | ReactNode, but we only pass strings
11603
+ 'aria-label': props.label ?? 'Date input field'
11604
+ }, state, ref);
11605
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
11606
+ ...fieldProps,
11607
+ style: {
11608
+ display: 'flex'
11609
+ },
11610
+ ref: ref,
11611
+ children: state.segments.map((segment, i) => /*#__PURE__*/jsxRuntime.jsx(DateSegment, {
11612
+ segment: segment,
11613
+ state: state
11614
+ }, i))
11615
+ });
11616
+ });
11617
+ DateFieldSegments.displayName = 'SingleDateField';
11618
+
11619
+ /**
11620
+ * Datefield is the input field used in {@link DatePicker} to type in a single date.
11621
+ * Encapsulates styling / functionality for typing a date
11622
+ */
11623
+ const DateField = /*#__PURE__*/react.forwardRef(function ({
11624
+ fieldProps,
11625
+ groupProps,
11626
+ variant,
11627
+ dateCreateProps,
11628
+ ...props
11629
+ }, ref) {
11630
+ const state = datepicker.useDateFieldState(dateCreateProps);
11631
+ const inputRef = react.useRef(null);
11632
+ return /*#__PURE__*/jsxRuntime.jsxs(InputFieldWrapper, {
11633
+ ...groupProps,
11634
+ readonly: fieldProps.isReadOnly,
11635
+ disabled: state.isDisabled,
11636
+ color: state.isInvalid ? 'warning' : variant,
11637
+ ref: ref,
11638
+ className: `field ${state.isInvalid ? 'invalid' : 'valid'}`,
11639
+ children: [/*#__PURE__*/jsxRuntime.jsx(DateFieldSegments, {
11640
+ ...state,
11641
+ ...fieldProps,
11642
+ ref: inputRef
11643
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
11644
+ style: {
11645
+ flex: '1 1 auto'
11646
+ }
11647
+ }), props.rightAdornments]
11648
+ });
11649
+ });
11650
+ DateField.displayName = 'DateField';
11651
+
11652
+ const intl = new Intl.DateTimeFormat();
11653
+ const defaultTimezone = intl.resolvedOptions().timeZone;
11654
+ const DatePickerContext = /*#__PURE__*/react.createContext({
11655
+ timezone: defaultTimezone
11656
+ });
11657
+ const DatePickerProvider = ({
11658
+ timezone,
11659
+ children
11660
+ }) => {
11661
+ return /*#__PURE__*/jsxRuntime.jsx(DatePickerContext.Provider, {
11662
+ value: {
11663
+ timezone: timezone ?? defaultTimezone
11664
+ },
11665
+ children: children
11666
+ });
11667
+ };
11668
+
11669
+ const useConvertedValidationFunctions = (minValue, maxValue, isDateUnavailable, timezone) => {
11670
+ const tz = timezone ?? defaultTimezone;
11671
+ const _minValue = minValue ? date.toCalendarDate(date.fromDate(minValue, tz)) : undefined;
11672
+ const _maxValue = maxValue ? date.toCalendarDate(date.fromDate(maxValue, tz)) : undefined;
11673
+ const _minTimeValue = minValue ? date.fromDate(minValue, tz) : undefined;
11674
+ const _maxTimeValue = maxValue ? date.fromDate(maxValue, tz) : undefined;
11675
+ const _isDateUnavailable = value => isDateUnavailable ? isDateUnavailable(value.toDate(tz)) : false;
11676
+ return {
11677
+ _minValue,
11678
+ _maxValue,
11679
+ _isDateUnavailable,
11680
+ _minTimeValue,
11681
+ _maxTimeValue
11682
+ };
11683
+ };
11684
+
11685
+ const StyledButton = styled__default.default(Button$2).withConfig({
11686
+ displayName: "Toggle__StyledButton",
11687
+ componentId: "sc-1bwqcj7-0"
11688
+ })(["height:24px;width:24px;"]);
11689
+
11690
+ /**
11691
+ * Toggle component encapsulates the reset and open calendar buttons
11692
+ */
11693
+ const Toggle = ({
11694
+ reset,
11695
+ setOpen,
11696
+ open,
11697
+ icon,
11698
+ disabled,
11699
+ buttonProps,
11700
+ valueString,
11701
+ readonly
11702
+ }) => {
11703
+ return readonly || disabled ? null : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
11704
+ children: [/*#__PURE__*/jsxRuntime.jsx(StyledButton, {
11705
+ disabled: disabled,
11706
+ variant: 'ghost_icon',
11707
+ "aria-label": 'Reset',
11708
+ onClick: () => {
11709
+ reset();
11710
+ },
11711
+ onKeyDown: e => {
11712
+ if (e.code === 'Enter' || e.code === 'Space') {
11713
+ e.preventDefault();
11714
+ e.stopPropagation();
11715
+ reset();
11716
+ }
11717
+ },
11718
+ children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
11719
+ data: edsIcons.close
11720
+ })
11721
+ }), /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
11722
+ ...utils.filterDOMProps(buttonProps),
11723
+ disabled: disabled,
11724
+ "aria-label": valueString ? `Change date, ${valueString}` : `Change date`,
11725
+ variant: 'ghost_icon',
11726
+ onClick: e => {
11727
+ e.preventDefault();
11728
+ e.stopPropagation();
11729
+ setOpen(!open);
11730
+ },
11731
+ children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
11732
+ data: icon
11733
+ })
11734
+ })]
11735
+ });
11736
+ };
11737
+
11738
+ const getCalendarDate = (value, timezone, showTimeInput = false) => {
11739
+ if (!value) return null;
11740
+ return showTimeInput ? date.toCalendarDateTime(date.fromDate(value, timezone)) : date.toCalendarDate(date.fromDate(value, timezone));
11741
+ };
11742
+
11743
+ const DatePicker = /*#__PURE__*/react.forwardRef(({
11744
+ onChange,
11745
+ label,
11746
+ value,
11747
+ isDateUnavailable,
11748
+ minValue,
11749
+ maxValue,
11750
+ Footer,
11751
+ Header,
11752
+ timezone,
11753
+ defaultValue,
11754
+ showTimeInput,
11755
+ granularity,
11756
+ disabled: isDisabled,
11757
+ readOnly: isReadOnly,
11758
+ ...props
11759
+ }, forwardedRef) => {
11760
+ timezone = timezone ?? defaultTimezone;
11761
+ const [innerValue, setInnerValue] = react.useState(() => {
11762
+ const initialValue = value ?? defaultValue;
11763
+ if (initialValue) {
11764
+ if (showTimeInput) {
11765
+ return date.toCalendarDateTime(date.fromDate(initialValue, timezone));
11766
+ } else {
11767
+ return date.toCalendarDate(date.fromDate(initialValue, timezone));
11768
+ }
11769
+ }
11770
+ return null;
11771
+ });
11772
+ const [isOpen, setIsOpen] = react.useState(null);
11773
+ const inputRef = react.useRef(null);
11774
+ const pickerRef = react.useRef(null);
11775
+ const ref = forwardedRef || inputRef;
11776
+ const {
11777
+ _minValue,
11778
+ _maxValue,
11779
+ _isDateUnavailable
11780
+ } = useConvertedValidationFunctions(minValue, maxValue, isDateUnavailable, timezone);
11781
+ const _onChange = react.useCallback(value => {
11782
+ // Set internal value
11783
+ if (value) {
11784
+ setInnerValue(showTimeInput ? date.toCalendarDateTime(value) : date.toCalendarDate(value));
11785
+ } else {
11786
+ setInnerValue(null);
11787
+ }
11788
+ // Close the picker after selecting a date
11789
+ if (isOpen) {
11790
+ setIsOpen(false);
11791
+ }
11792
+ // Call onChange callback from props
11793
+ if (onChange) {
11794
+ if (!value) {
11795
+ onChange(null);
11796
+ } else {
11797
+ const date = value.toDate(timezone);
11798
+ onChange(date);
11799
+ }
11800
+ }
11801
+ }, [onChange, isOpen, showTimeInput, timezone]);
11802
+ const _value = getCalendarDate(value, timezone, showTimeInput) ?? innerValue;
11803
+ const {
11804
+ locale
11805
+ } = reactAria.useLocale();
11806
+ const dateCreateProps = {
11807
+ ...props,
11808
+ isDisabled,
11809
+ value: _value,
11810
+ hideTimeZone: true,
11811
+ locale,
11812
+ createCalendar: date.createCalendar,
11813
+ onChange: _onChange,
11814
+ minValue: _minValue,
11815
+ maxValue: _maxValue,
11816
+ isDateUnavailable: _isDateUnavailable,
11817
+ label: label || 'Date picker',
11818
+ isReadOnly,
11819
+ granularity
11820
+ };
11821
+ const pickerState = datepicker.useDatePickerState(dateCreateProps);
11822
+ const {
11823
+ groupProps,
11824
+ buttonProps,
11825
+ fieldProps,
11826
+ calendarProps
11827
+ } = reactAria.useDatePicker(dateCreateProps, pickerState, ref);
11828
+ const helperProps = pickerState.displayValidation.isInvalid ? {
11829
+ text: pickerState.displayValidation.validationErrors.join('\n'),
11830
+ color: edsTokens.tokens.colors.interactive.warning__text.rgba,
11831
+ icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
11832
+ size: 16,
11833
+ data: edsIcons.warning_outlined
11834
+ })
11835
+ } : undefined;
11836
+ return /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
11837
+ timezone: timezone,
11838
+ children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
11839
+ isOpen: isOpen,
11840
+ readonly: fieldProps.isReadOnly,
11841
+ pickerRef: pickerRef,
11842
+ ref: ref,
11843
+ setIsOpen: setIsOpen,
11844
+ label: label,
11845
+ calendar: /*#__PURE__*/jsxRuntime.jsx(Calendar, {
11846
+ ref: pickerRef,
11847
+ Footer: Footer,
11848
+ Header: Header,
11849
+ ...calendarProps
11850
+ }),
11851
+ disabled: isDisabled,
11852
+ readOnly: isReadOnly,
11853
+ color: pickerState.isInvalid ? 'warning' : props.variant,
11854
+ helperProps: helperProps ?? props.helperProps,
11855
+ children: /*#__PURE__*/jsxRuntime.jsx(DateField, {
11856
+ fieldProps: fieldProps,
11857
+ groupProps: groupProps,
11858
+ dateCreateProps: dateCreateProps,
11859
+ ref: ref,
11860
+ onChange: _onChange,
11861
+ rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
11862
+ setOpen: setIsOpen,
11863
+ open: isOpen,
11864
+ icon: edsIcons.calendar,
11865
+ disabled: isDisabled,
11866
+ readonly: isReadOnly,
11867
+ reset: () => _onChange(null),
11868
+ buttonProps: buttonProps,
11869
+ valueString: pickerState.formatValue(locale, {
11870
+ year: 'numeric',
11871
+ month: 'short',
11872
+ day: '2-digit'
11873
+ })
11874
+ }),
11875
+ variant: props.variant
11876
+ })
11877
+ })
11878
+ });
11879
+ });
11880
+ DatePicker.displayName = 'DatePicker';
11881
+
11882
+ const RangeCalendar = /*#__PURE__*/react.forwardRef(({
11883
+ Header,
11884
+ Footer,
11885
+ ...props
11886
+ }, ref) => {
11887
+ const [showYearPicker, setShowYearPicker] = react.useState(false);
11888
+ const {
11889
+ locale
11890
+ } = reactAria.useLocale();
11891
+ const state = calendar.useRangeCalendarState({
11892
+ ...props,
11893
+ locale,
11894
+ createCalendar: date.createCalendar
11895
+ });
11896
+ const {
11897
+ calendarProps,
11898
+ title
11899
+ } = reactAria.useRangeCalendar(props, state, ref);
11900
+ return /*#__PURE__*/jsxRuntime.jsxs(CalendarWrapper, {
11901
+ ...calendarProps,
11902
+ ref: ref,
11903
+ children: [/*#__PURE__*/jsxRuntime.jsx(Popover.Header, {
11904
+ children: Header ? /*#__PURE__*/jsxRuntime.jsx(Header, {
11905
+ month: state.focusedDate.month,
11906
+ state: state,
11907
+ setMonth: month => state.setFocusedDate(state.focusedDate.set({
11908
+ month
11909
+ })),
11910
+ setYear: year => state.setFocusedDate(state.focusedDate.set({
11911
+ year
11912
+ })),
11913
+ year: state.focusedDate.year
11914
+ }) : /*#__PURE__*/jsxRuntime.jsx(CalendarHeader, {
11915
+ state: state,
11916
+ title: title,
11917
+ setShowYearPicker: setShowYearPicker,
11918
+ showYearPicker: showYearPicker
11919
+ })
11920
+ }), /*#__PURE__*/jsxRuntime.jsx(Popover.Content, {
11921
+ children: /*#__PURE__*/jsxRuntime.jsx(CalendarGrid, {
11922
+ state: state,
11923
+ setShowYearPicker: setShowYearPicker,
11924
+ showYearPicker: showYearPicker
11925
+ })
11926
+ }), Footer && /*#__PURE__*/jsxRuntime.jsx(Popover.Actions, {
11927
+ children: /*#__PURE__*/jsxRuntime.jsx(Footer, {
11928
+ month: state.focusedDate.month,
11929
+ state: state,
11930
+ setMonth: month => state.setFocusedDate(state.focusedDate.set({
11931
+ month
11932
+ })),
11933
+ setYear: year => state.setFocusedDate(state.focusedDate.set({
11934
+ year
11935
+ })),
11936
+ year: state.focusedDate.year
11937
+ })
11938
+ })]
11939
+ });
11940
+ });
11941
+ RangeCalendar.displayName = 'RangeCalendar';
11942
+
11943
+ /**
11944
+ * DateRangeField is the input field used in {@link DateRangePicker} to type in a date range.
11945
+ */
11946
+ const DateRangeField = /*#__PURE__*/react.forwardRef(function (props, ref) {
11947
+ const fromRef = react.useRef(null);
11948
+ const toRef = react.useRef(null);
11949
+ return /*#__PURE__*/jsxRuntime.jsxs(InputFieldWrapper, {
11950
+ ref: ref,
11951
+ readonly: props.startFieldProps.isReadOnly,
11952
+ className: "field",
11953
+ disabled: props.disabled,
11954
+ color: props.variant,
11955
+ ...props.groupProps,
11956
+ children: [/*#__PURE__*/jsxRuntime.jsx(DateFieldSegments, {
11957
+ ...props.startFieldProps,
11958
+ ref: fromRef
11959
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
11960
+ as: 'span',
11961
+ variant: 'text',
11962
+ group: 'input',
11963
+ style: {
11964
+ padding: '0 4px'
11965
+ },
11966
+ children: "\u2014"
11967
+ }), /*#__PURE__*/jsxRuntime.jsx(DateFieldSegments, {
11968
+ ...props.endFieldProps,
11969
+ ref: toRef
11970
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
11971
+ style: {
11972
+ flex: '1 1 auto'
11973
+ }
11974
+ }), props.rightAdornments]
11975
+ });
11976
+ });
11977
+ DateRangeField.displayName = 'DateRangeField';
11978
+
11979
+ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
11980
+ onChange,
11981
+ label,
11982
+ value,
11983
+ isDateUnavailable,
11984
+ minValue,
11985
+ maxValue,
11986
+ Footer,
11987
+ Header,
11988
+ timezone,
11989
+ defaultValue,
11990
+ disabled: isDisabled,
11991
+ readOnly: isReadOnly,
11992
+ ...props
11993
+ }, forwardedRef) => {
11994
+ timezone = timezone ?? defaultTimezone;
11995
+ const [innerValue, setInnerValue] = react.useState(() => {
11996
+ const initialValue = value ?? defaultValue;
11997
+ if (initialValue) {
11998
+ return {
11999
+ start: initialValue.from ? date.toCalendarDate(date.fromDate(initialValue.from, timezone)) : null,
12000
+ end: initialValue.to ? date.toCalendarDate(date.fromDate(initialValue.to, timezone)) : null
12001
+ };
12002
+ }
12003
+ });
12004
+ const [isOpen, setIsOpen] = react.useState(null);
12005
+ const inputRef = react.useRef(null);
12006
+ const pickerRef = react.useRef(null);
12007
+ const ref = forwardedRef || inputRef;
12008
+ const {
12009
+ locale
12010
+ } = reactAria.useLocale();
12011
+ const {
12012
+ _minValue,
12013
+ _maxValue,
12014
+ _isDateUnavailable
12015
+ } = useConvertedValidationFunctions(minValue, maxValue, isDateUnavailable, timezone);
12016
+ const _onChange = react.useCallback(rangeValue => {
12017
+ setInnerValue(rangeValue);
12018
+ // Close picker on selecting date
12019
+ if (isOpen) {
12020
+ setIsOpen(false);
12021
+ }
12022
+ // Propagate change
12023
+ if (onChange) {
12024
+ if (!rangeValue) onChange(null);else {
12025
+ onChange({
12026
+ from: rangeValue.start?.toDate(timezone) ?? null,
12027
+ to: rangeValue.end?.toDate(timezone) ?? null
12028
+ });
12029
+ }
12030
+ }
12031
+ }, [onChange, isOpen, timezone]);
12032
+ const _value = value ? {
12033
+ start: getCalendarDate(value.from, timezone),
12034
+ end: getCalendarDate(value.to, timezone)
12035
+ } : innerValue;
12036
+ const dateRangePickerStateProps = {
12037
+ maxValue: _maxValue,
12038
+ minValue: _minValue,
12039
+ isDateUnavailable: _isDateUnavailable,
12040
+ onChange: _onChange,
12041
+ label: label ?? 'Date-range',
12042
+ value: _value,
12043
+ isDisabled: isDisabled,
12044
+ isReadOnly: isReadOnly
12045
+ };
12046
+ const state = datepicker.useDateRangePickerState(dateRangePickerStateProps);
12047
+ const {
12048
+ groupProps,
12049
+ startFieldProps,
12050
+ endFieldProps,
12051
+ buttonProps,
12052
+ calendarProps
12053
+ } = reactAria.useDateRangePicker(dateRangePickerStateProps, state, ref);
12054
+ const helperProps = state.displayValidation.isInvalid ? {
12055
+ text: state.displayValidation.validationErrors.join('\n'),
12056
+ color: edsTokens.tokens.colors.interactive.warning__text.rgba,
12057
+ icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
12058
+ size: 16,
12059
+ data: edsIcons.warning_outlined
12060
+ })
12061
+ } : undefined;
12062
+ const formattedValue = state.formatValue(locale, {
12063
+ year: 'numeric',
12064
+ month: 'short',
12065
+ day: '2-digit'
12066
+ });
12067
+ const valueString = formattedValue ? Object.values(formattedValue).join(' - ') : null;
12068
+ return /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
12069
+ timezone: timezone,
12070
+ children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
12071
+ isOpen: isOpen,
12072
+ color: state.isInvalid ? 'warning' : props.variant,
12073
+ helperProps: helperProps ?? props.helperProps,
12074
+ readonly: startFieldProps.isReadOnly,
12075
+ ref: ref,
12076
+ pickerRef: pickerRef,
12077
+ setIsOpen: setIsOpen,
12078
+ label: label,
12079
+ calendar: /*#__PURE__*/jsxRuntime.jsx(RangeCalendar, {
12080
+ ref: pickerRef,
12081
+ maxValue: _maxValue,
12082
+ minValue: _minValue,
12083
+ isDateUnavailable: _isDateUnavailable,
12084
+ Footer: Footer,
12085
+ Header: Header,
12086
+ ...calendarProps
12087
+ }),
12088
+ children: /*#__PURE__*/jsxRuntime.jsx(DateRangeField, {
12089
+ startFieldProps: startFieldProps,
12090
+ endFieldProps: endFieldProps,
12091
+ groupProps: groupProps,
12092
+ ref: ref,
12093
+ variant: props.variant,
12094
+ disabled: isDisabled,
12095
+ rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
12096
+ buttonProps: buttonProps,
12097
+ disabled: isDisabled,
12098
+ readonly: isReadOnly,
12099
+ reset: () => {
12100
+ _onChange(null);
12101
+ },
12102
+ setOpen: setIsOpen,
12103
+ open: isOpen,
12104
+ icon: edsIcons.calendar_date_range,
12105
+ valueString: valueString
12106
+ })
12107
+ })
12108
+ })
12109
+ });
12110
+ });
12111
+ DateRangePicker.displayName = 'DateRangePicker';
12112
+
10976
12113
  exports.Accordion = Accordion;
10977
12114
  exports.Autocomplete = Autocomplete;
10978
12115
  exports.Avatar = Avatar;
@@ -10983,6 +12120,8 @@ exports.Card = Card;
10983
12120
  exports.Checkbox = Checkbox;
10984
12121
  exports.Chip = Chip;
10985
12122
  exports.CircularProgress = CircularProgress;
12123
+ exports.DatePicker = DatePicker;
12124
+ exports.DateRangePicker = DateRangePicker;
10986
12125
  exports.Dialog = Dialog;
10987
12126
  exports.Divider = Divider;
10988
12127
  exports.DotProgress = DotProgress;