@equinor/eds-core-react 0.39.1-dev13062024 → 0.40.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.
@@ -9490,8 +9490,10 @@ function mergeEventsFromRight(props1, props2) {
9490
9490
  const findNextIndex = ({
9491
9491
  index,
9492
9492
  optionDisabled,
9493
- availableItems
9493
+ availableItems,
9494
+ allDisabled
9494
9495
  }) => {
9496
+ if (allDisabled) return 0;
9495
9497
  const options = {
9496
9498
  index,
9497
9499
  optionDisabled,
@@ -9511,8 +9513,10 @@ const findNextIndex = ({
9511
9513
  const findPrevIndex = ({
9512
9514
  index,
9513
9515
  optionDisabled,
9514
- availableItems
9516
+ availableItems,
9517
+ allDisabled
9515
9518
  }) => {
9519
+ if (allDisabled) return 0;
9516
9520
  const options = {
9517
9521
  index,
9518
9522
  optionDisabled,
@@ -9591,6 +9595,7 @@ function AutocompleteInner(props, ref) {
9591
9595
  const [inputOptions, setInputOptions] = react.useState(options);
9592
9596
  const [_availableItems, setAvailableItems] = react.useState(inputOptions);
9593
9597
  const [typedInputValue, setTypedInputValue] = react.useState('');
9598
+ const inputRef = react.useRef(null);
9594
9599
  const showSelectAll = react.useMemo(() => {
9595
9600
  if (!multiple && allowSelectAll) {
9596
9601
  throw new Error(`allowSelectAll can only be used with multiple`);
@@ -9659,6 +9664,7 @@ function AutocompleteInner(props, ref) {
9659
9664
  const disabledItemsSet = new Set(inputOptions.filter(optionDisabled));
9660
9665
  return inputOptions.filter(x => !disabledItemsSet.has(x));
9661
9666
  }, [inputOptions, optionDisabled]);
9667
+ const allDisabled = enabledItems.length === 0;
9662
9668
  const selectedDisabledItemsSet = react.useMemo(() => new Set(selectedItems.filter(optionDisabled)), [selectedItems, optionDisabled]);
9663
9669
  const selectedEnabledItems = react.useMemo(() => selectedItems.filter(x => !selectedDisabledItemsSet.has(x)), [selectedItems, selectedDisabledItemsSet]);
9664
9670
  const allSelectedState = react.useMemo(() => {
@@ -9829,7 +9835,8 @@ function AutocompleteInner(props, ref) {
9829
9835
  highlightedIndex: findNextIndex({
9830
9836
  index: changes.highlightedIndex,
9831
9837
  availableItems,
9832
- optionDisabled
9838
+ optionDisabled,
9839
+ allDisabled
9833
9840
  })
9834
9841
  };
9835
9842
  case downshift.useCombobox.stateChangeTypes.InputKeyDownArrowUp:
@@ -9845,7 +9852,8 @@ function AutocompleteInner(props, ref) {
9845
9852
  highlightedIndex: findPrevIndex({
9846
9853
  index: changes.highlightedIndex,
9847
9854
  availableItems,
9848
- optionDisabled
9855
+ optionDisabled,
9856
+ allDisabled
9849
9857
  })
9850
9858
  };
9851
9859
  default:
@@ -9890,7 +9898,8 @@ function AutocompleteInner(props, ref) {
9890
9898
  highlightedIndex: findNextIndex({
9891
9899
  index: changes.highlightedIndex,
9892
9900
  availableItems,
9893
- optionDisabled
9901
+ optionDisabled,
9902
+ allDisabled
9894
9903
  })
9895
9904
  };
9896
9905
  case downshift.useCombobox.stateChangeTypes.InputKeyDownArrowUp:
@@ -9906,7 +9915,8 @@ function AutocompleteInner(props, ref) {
9906
9915
  highlightedIndex: findPrevIndex({
9907
9916
  index: changes.highlightedIndex,
9908
9917
  availableItems,
9909
- optionDisabled
9918
+ optionDisabled,
9919
+ allDisabled
9910
9920
  })
9911
9921
  };
9912
9922
  case downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
@@ -10001,6 +10011,7 @@ function AutocompleteInner(props, ref) {
10001
10011
  //dont clear items if they are selected and disabled
10002
10012
  setSelectedItems([...selectedDisabledItemsSet]);
10003
10013
  setTypedInputValue('');
10014
+ inputRef.current?.focus();
10004
10015
  };
10005
10016
  const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly && !hideClearButton;
10006
10017
  const showNoOptions = isOpen && !availableItems.length && noOptionsText.length > 0;
@@ -10105,7 +10116,8 @@ function AutocompleteInner(props, ref) {
10105
10116
  });
10106
10117
  const inputProps = getInputProps(getDropdownProps({
10107
10118
  preventKeyAction: multiple ? isOpen : undefined,
10108
- disabled
10119
+ disabled,
10120
+ ref: inputRef
10109
10121
  }));
10110
10122
  const consolidatedEvents = mergeEventsFromRight(other, inputProps);
10111
10123
 
@@ -11624,9 +11636,16 @@ const useDatePickerContext = () => react.useContext(DatePickerContext);
11624
11636
  const Segment = styled__default.default.div.withConfig({
11625
11637
  displayName: "DateSegment__Segment",
11626
11638
  componentId: "sc-19uidpx-0"
11627
- })(["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, ({
11639
+ })(({
11640
+ $placeholder,
11628
11641
  $disabled
11629
- }) => $disabled && `color: ${edsTokens.tokens.colors.interactive.disabled__text.rgba};`);
11642
+ }) => {
11643
+ return styled.css(["font-family:", ";&:focus-visible{outline:2px solid ", ";background-color:", ";}", " ", ""], edsTokens.tokens.typography.input.text.fontFamily, edsTokens.tokens.colors.interactive.primary__resting.rgba, edsTokens.tokens.colors.ui.background__medium.rgba, $placeholder ? styled.css({
11644
+ color: edsTokens.tokens.colors.text.static_icons__tertiary.rgba
11645
+ }) : styled.css({
11646
+ color: edsTokens.tokens.colors.text.static_icons__default.rgba
11647
+ }), $disabled && styled.css(["color:", ";"], edsTokens.tokens.colors.interactive.disabled__text.rgba));
11648
+ });
11630
11649
 
11631
11650
  /**
11632
11651
  * DateSegment is used to represent a single segment of a date in the DateField (i.e. day, month, year)
@@ -11778,10 +11797,11 @@ const Toggle = ({
11778
11797
  disabled,
11779
11798
  buttonProps,
11780
11799
  valueString,
11800
+ showClearButton,
11781
11801
  readonly
11782
11802
  }) => {
11783
11803
  return readonly || disabled ? null : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
11784
- children: [/*#__PURE__*/jsxRuntime.jsx(StyledButton, {
11804
+ children: [showClearButton && /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
11785
11805
  disabled: disabled,
11786
11806
  variant: 'ghost_icon',
11787
11807
  "aria-label": 'Reset',
@@ -11833,9 +11853,12 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11833
11853
  defaultValue,
11834
11854
  showTimeInput,
11835
11855
  granularity,
11856
+ hideClearButton,
11836
11857
  disabled: isDisabled,
11837
11858
  readOnly: isReadOnly,
11838
11859
  formatOptions,
11860
+ helperProps,
11861
+ variant,
11839
11862
  ...props
11840
11863
  }, forwardedRef) => {
11841
11864
  timezone = timezone ?? defaultTimezone;
@@ -11890,7 +11913,8 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11890
11913
  locale
11891
11914
  } = reactAria.useLocale();
11892
11915
  const dateCreateProps = {
11893
- ...props,
11916
+ helperProps,
11917
+ variant,
11894
11918
  isDisabled,
11895
11919
  value: _value,
11896
11920
  hideTimeZone: true,
@@ -11911,7 +11935,7 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11911
11935
  fieldProps,
11912
11936
  calendarProps
11913
11937
  } = reactAria.useDatePicker(dateCreateProps, pickerState, ref);
11914
- const helperProps = pickerState.displayValidation.isInvalid ? {
11938
+ const helperPropsInvalid = pickerState.displayValidation.isInvalid ? {
11915
11939
  text: pickerState.displayValidation.validationErrors.join('\n'),
11916
11940
  color: edsTokens.tokens.colors.interactive.warning__text.rgba,
11917
11941
  icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
@@ -11919,6 +11943,7 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11919
11943
  data: edsIcons.warning_outlined
11920
11944
  })
11921
11945
  } : undefined;
11946
+ const showClearButton = pickerState.dateValue !== null && !hideClearButton;
11922
11947
 
11923
11948
  // innerValue is used as a fallback, especially for uncontrolled inputs, so it needs to be reset when value / defaultValue is reset
11924
11949
  react.useEffect(() => {
@@ -11928,6 +11953,7 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11928
11953
  timezone: timezone,
11929
11954
  formatOptions: formatOptions,
11930
11955
  children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
11956
+ ...props,
11931
11957
  isOpen: isOpen,
11932
11958
  readonly: fieldProps.isReadOnly,
11933
11959
  pickerRef: pickerRef,
@@ -11942,8 +11968,8 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11942
11968
  }),
11943
11969
  disabled: isDisabled,
11944
11970
  readOnly: isReadOnly,
11945
- color: pickerState.isInvalid ? 'warning' : props.variant,
11946
- helperProps: helperProps ?? props.helperProps,
11971
+ color: pickerState.isInvalid ? 'warning' : variant,
11972
+ helperProps: helperPropsInvalid ?? helperProps,
11947
11973
  children: /*#__PURE__*/jsxRuntime.jsx(DateField, {
11948
11974
  fieldProps: fieldProps,
11949
11975
  groupProps: groupProps,
@@ -11951,6 +11977,7 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11951
11977
  ref: ref,
11952
11978
  onChange: _onChange,
11953
11979
  rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
11980
+ showClearButton: showClearButton,
11954
11981
  setOpen: setIsOpen,
11955
11982
  open: isOpen,
11956
11983
  icon: edsIcons.calendar,
@@ -11964,7 +11991,7 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
11964
11991
  day: '2-digit'
11965
11992
  })
11966
11993
  }),
11967
- variant: props.variant
11994
+ variant: variant
11968
11995
  })
11969
11996
  })
11970
11997
  });
@@ -12080,6 +12107,7 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
12080
12107
  timezone,
12081
12108
  defaultValue,
12082
12109
  formatOptions,
12110
+ hideClearButton,
12083
12111
  disabled: isDisabled,
12084
12112
  readOnly: isReadOnly,
12085
12113
  ...props
@@ -12157,6 +12185,7 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
12157
12185
  data: edsIcons.warning_outlined
12158
12186
  })
12159
12187
  } : undefined;
12188
+ const showClearButton = state.dateRange !== null && !hideClearButton;
12160
12189
  const formattedValue = state.formatValue(locale, {
12161
12190
  year: 'numeric',
12162
12191
  month: 'short',
@@ -12199,6 +12228,7 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
12199
12228
  variant: props.variant,
12200
12229
  disabled: isDisabled,
12201
12230
  rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
12231
+ showClearButton: showClearButton,
12202
12232
  buttonProps: buttonProps,
12203
12233
  disabled: isDisabled,
12204
12234
  readonly: isReadOnly,
@@ -1,4 +1,4 @@
1
- import { forwardRef, useState, useMemo, useEffect, useCallback, useRef } from 'react';
1
+ import { forwardRef, useState, useRef, useMemo, useEffect, useCallback } from 'react';
2
2
  import { useMultipleSelection, useCombobox } from 'downshift';
3
3
  import { useVirtualizer } from '@tanstack/react-virtual';
4
4
  import styled, { css, ThemeProvider } from 'styled-components';
@@ -94,8 +94,10 @@ function mergeEventsFromRight(props1, props2) {
94
94
  const findNextIndex = ({
95
95
  index,
96
96
  optionDisabled,
97
- availableItems
97
+ availableItems,
98
+ allDisabled
98
99
  }) => {
100
+ if (allDisabled) return 0;
99
101
  const options = {
100
102
  index,
101
103
  optionDisabled,
@@ -115,8 +117,10 @@ const findNextIndex = ({
115
117
  const findPrevIndex = ({
116
118
  index,
117
119
  optionDisabled,
118
- availableItems
120
+ availableItems,
121
+ allDisabled
119
122
  }) => {
123
+ if (allDisabled) return 0;
120
124
  const options = {
121
125
  index,
122
126
  optionDisabled,
@@ -195,6 +199,7 @@ function AutocompleteInner(props, ref) {
195
199
  const [inputOptions, setInputOptions] = useState(options);
196
200
  const [_availableItems, setAvailableItems] = useState(inputOptions);
197
201
  const [typedInputValue, setTypedInputValue] = useState('');
202
+ const inputRef = useRef(null);
198
203
  const showSelectAll = useMemo(() => {
199
204
  if (!multiple && allowSelectAll) {
200
205
  throw new Error(`allowSelectAll can only be used with multiple`);
@@ -263,6 +268,7 @@ function AutocompleteInner(props, ref) {
263
268
  const disabledItemsSet = new Set(inputOptions.filter(optionDisabled));
264
269
  return inputOptions.filter(x => !disabledItemsSet.has(x));
265
270
  }, [inputOptions, optionDisabled]);
271
+ const allDisabled = enabledItems.length === 0;
266
272
  const selectedDisabledItemsSet = useMemo(() => new Set(selectedItems.filter(optionDisabled)), [selectedItems, optionDisabled]);
267
273
  const selectedEnabledItems = useMemo(() => selectedItems.filter(x => !selectedDisabledItemsSet.has(x)), [selectedItems, selectedDisabledItemsSet]);
268
274
  const allSelectedState = useMemo(() => {
@@ -433,7 +439,8 @@ function AutocompleteInner(props, ref) {
433
439
  highlightedIndex: findNextIndex({
434
440
  index: changes.highlightedIndex,
435
441
  availableItems,
436
- optionDisabled
442
+ optionDisabled,
443
+ allDisabled
437
444
  })
438
445
  };
439
446
  case useCombobox.stateChangeTypes.InputKeyDownArrowUp:
@@ -449,7 +456,8 @@ function AutocompleteInner(props, ref) {
449
456
  highlightedIndex: findPrevIndex({
450
457
  index: changes.highlightedIndex,
451
458
  availableItems,
452
- optionDisabled
459
+ optionDisabled,
460
+ allDisabled
453
461
  })
454
462
  };
455
463
  default:
@@ -494,7 +502,8 @@ function AutocompleteInner(props, ref) {
494
502
  highlightedIndex: findNextIndex({
495
503
  index: changes.highlightedIndex,
496
504
  availableItems,
497
- optionDisabled
505
+ optionDisabled,
506
+ allDisabled
498
507
  })
499
508
  };
500
509
  case useCombobox.stateChangeTypes.InputKeyDownArrowUp:
@@ -510,7 +519,8 @@ function AutocompleteInner(props, ref) {
510
519
  highlightedIndex: findPrevIndex({
511
520
  index: changes.highlightedIndex,
512
521
  availableItems,
513
- optionDisabled
522
+ optionDisabled,
523
+ allDisabled
514
524
  })
515
525
  };
516
526
  case useCombobox.stateChangeTypes.InputKeyDownEnter:
@@ -605,6 +615,7 @@ function AutocompleteInner(props, ref) {
605
615
  //dont clear items if they are selected and disabled
606
616
  setSelectedItems([...selectedDisabledItemsSet]);
607
617
  setTypedInputValue('');
618
+ inputRef.current?.focus();
608
619
  };
609
620
  const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly && !hideClearButton;
610
621
  const showNoOptions = isOpen && !availableItems.length && noOptionsText.length > 0;
@@ -709,7 +720,8 @@ function AutocompleteInner(props, ref) {
709
720
  });
710
721
  const inputProps = getInputProps(getDropdownProps({
711
722
  preventKeyAction: multiple ? isOpen : undefined,
712
- disabled
723
+ disabled,
724
+ ref: inputRef
713
725
  }));
714
726
  const consolidatedEvents = mergeEventsFromRight(other, inputProps);
715
727
 
@@ -27,9 +27,12 @@ const DatePicker = /*#__PURE__*/forwardRef(({
27
27
  defaultValue,
28
28
  showTimeInput,
29
29
  granularity,
30
+ hideClearButton,
30
31
  disabled: isDisabled,
31
32
  readOnly: isReadOnly,
32
33
  formatOptions,
34
+ helperProps,
35
+ variant,
33
36
  ...props
34
37
  }, forwardedRef) => {
35
38
  timezone = timezone ?? defaultTimezone;
@@ -84,7 +87,8 @@ const DatePicker = /*#__PURE__*/forwardRef(({
84
87
  locale
85
88
  } = useLocale();
86
89
  const dateCreateProps = {
87
- ...props,
90
+ helperProps,
91
+ variant,
88
92
  isDisabled,
89
93
  value: _value,
90
94
  hideTimeZone: true,
@@ -105,7 +109,7 @@ const DatePicker = /*#__PURE__*/forwardRef(({
105
109
  fieldProps,
106
110
  calendarProps
107
111
  } = useDatePicker(dateCreateProps, pickerState, ref);
108
- const helperProps = pickerState.displayValidation.isInvalid ? {
112
+ const helperPropsInvalid = pickerState.displayValidation.isInvalid ? {
109
113
  text: pickerState.displayValidation.validationErrors.join('\n'),
110
114
  color: tokens.colors.interactive.warning__text.rgba,
111
115
  icon: /*#__PURE__*/jsx(Icon, {
@@ -113,6 +117,7 @@ const DatePicker = /*#__PURE__*/forwardRef(({
113
117
  data: warning_outlined
114
118
  })
115
119
  } : undefined;
120
+ const showClearButton = pickerState.dateValue !== null && !hideClearButton;
116
121
 
117
122
  // innerValue is used as a fallback, especially for uncontrolled inputs, so it needs to be reset when value / defaultValue is reset
118
123
  useEffect(() => {
@@ -122,6 +127,7 @@ const DatePicker = /*#__PURE__*/forwardRef(({
122
127
  timezone: timezone,
123
128
  formatOptions: formatOptions,
124
129
  children: /*#__PURE__*/jsx(FieldWrapper, {
130
+ ...props,
125
131
  isOpen: isOpen,
126
132
  readonly: fieldProps.isReadOnly,
127
133
  pickerRef: pickerRef,
@@ -136,8 +142,8 @@ const DatePicker = /*#__PURE__*/forwardRef(({
136
142
  }),
137
143
  disabled: isDisabled,
138
144
  readOnly: isReadOnly,
139
- color: pickerState.isInvalid ? 'warning' : props.variant,
140
- helperProps: helperProps ?? props.helperProps,
145
+ color: pickerState.isInvalid ? 'warning' : variant,
146
+ helperProps: helperPropsInvalid ?? helperProps,
141
147
  children: /*#__PURE__*/jsx(DateField, {
142
148
  fieldProps: fieldProps,
143
149
  groupProps: groupProps,
@@ -145,6 +151,7 @@ const DatePicker = /*#__PURE__*/forwardRef(({
145
151
  ref: ref,
146
152
  onChange: _onChange,
147
153
  rightAdornments: /*#__PURE__*/jsx(Toggle, {
154
+ showClearButton: showClearButton,
148
155
  setOpen: setIsOpen,
149
156
  open: isOpen,
150
157
  icon: calendar,
@@ -158,7 +165,7 @@ const DatePicker = /*#__PURE__*/forwardRef(({
158
165
  day: '2-digit'
159
166
  })
160
167
  }),
161
- variant: props.variant
168
+ variant: variant
162
169
  })
163
170
  })
164
171
  });
@@ -26,6 +26,7 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
26
26
  timezone,
27
27
  defaultValue,
28
28
  formatOptions,
29
+ hideClearButton,
29
30
  disabled: isDisabled,
30
31
  readOnly: isReadOnly,
31
32
  ...props
@@ -103,6 +104,7 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
103
104
  data: warning_outlined
104
105
  })
105
106
  } : undefined;
107
+ const showClearButton = state.dateRange !== null && !hideClearButton;
106
108
  const formattedValue = state.formatValue(locale, {
107
109
  year: 'numeric',
108
110
  month: 'short',
@@ -145,6 +147,7 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
145
147
  variant: props.variant,
146
148
  disabled: isDisabled,
147
149
  rightAdornments: /*#__PURE__*/jsx(Toggle, {
150
+ showClearButton: showClearButton,
148
151
  buttonProps: buttonProps,
149
152
  disabled: isDisabled,
150
153
  readonly: isReadOnly,
@@ -1,6 +1,6 @@
1
1
  import { useState, useRef } from 'react';
2
2
  import { useDateFormatter, useDateSegment } from 'react-aria';
3
- import styled from 'styled-components';
3
+ import styled, { css } from 'styled-components';
4
4
  import { tokens } from '@equinor/eds-tokens';
5
5
  import { useDatePickerContext } from '../utils/context.js';
6
6
  import { jsx } from 'react/jsx-runtime';
@@ -8,9 +8,16 @@ import { jsx } from 'react/jsx-runtime';
8
8
  const Segment = styled.div.withConfig({
9
9
  displayName: "DateSegment__Segment",
10
10
  componentId: "sc-19uidpx-0"
11
- })(["color:", ";font-family:", ";&:focus-visible{outline:2px solid ", ";background-color:", ";}", ""], tokens.typography.input.text.color, tokens.typography.input.text.fontFamily, tokens.colors.interactive.primary__resting.rgba, tokens.colors.ui.background__medium.rgba, ({
11
+ })(({
12
+ $placeholder,
12
13
  $disabled
13
- }) => $disabled && `color: ${tokens.colors.interactive.disabled__text.rgba};`);
14
+ }) => {
15
+ return css(["font-family:", ";&:focus-visible{outline:2px solid ", ";background-color:", ";}", " ", ""], tokens.typography.input.text.fontFamily, tokens.colors.interactive.primary__resting.rgba, tokens.colors.ui.background__medium.rgba, $placeholder ? css({
16
+ color: tokens.colors.text.static_icons__tertiary.rgba
17
+ }) : css({
18
+ color: tokens.colors.text.static_icons__default.rgba
19
+ }), $disabled && css(["color:", ";"], tokens.colors.interactive.disabled__text.rgba));
20
+ });
14
21
 
15
22
  /**
16
23
  * DateSegment is used to represent a single segment of a date in the DateField (i.e. day, month, year)
@@ -21,10 +21,11 @@ const Toggle = ({
21
21
  disabled,
22
22
  buttonProps,
23
23
  valueString,
24
+ showClearButton,
24
25
  readonly
25
26
  }) => {
26
27
  return readonly || disabled ? null : /*#__PURE__*/jsxs(Fragment, {
27
- children: [/*#__PURE__*/jsx(StyledButton, {
28
+ children: [showClearButton && /*#__PURE__*/jsx(StyledButton, {
28
29
  disabled: disabled,
29
30
  variant: 'ghost_icon',
30
31
  "aria-label": 'Reset',
@@ -3,7 +3,7 @@
3
3
  * DatePicker component encapsulates the logic for selecting a single date.
4
4
  * Either by accessible input field or by a calendar.
5
5
  */
6
- export declare const DatePicker: import("react").ForwardRefExoticComponent<Partial<{
6
+ export declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLDivElement>, "onChange"> & Partial<{
7
7
  variant: import("../types").Variants;
8
8
  disabled?: boolean;
9
9
  readOnly?: boolean;
@@ -17,6 +17,7 @@ export declare const DatePicker: import("react").ForwardRefExoticComponent<Parti
17
17
  Footer: (props: import("./props").HeaderFooterProps<import("@react-stately/calendar").CalendarState>) => import("react").ReactNode;
18
18
  Header: (props: import("./props").HeaderFooterProps<import("@react-stately/calendar").CalendarState>) => import("react").ReactNode;
19
19
  showTimeInput?: boolean;
20
+ hideClearButton?: boolean;
20
21
  defaultValue?: Date;
21
22
  timezone: string;
22
23
  granularity?: "hour" | "minute" | "second";
@@ -3,25 +3,7 @@
3
3
  * DateRangePicker component encapsulates the logic for selecting a range of dates
4
4
  * Either by accessible input fields or by a calendar.
5
5
  */
6
- export declare const DateRangePicker: import("react").ForwardRefExoticComponent<Omit<Partial<{
7
- variant: import("../types").Variants;
8
- disabled?: boolean;
9
- readOnly?: boolean;
10
- helperProps?: import("../InputWrapper/HelperText").HelperTextProps;
11
- value: Date;
12
- onChange: (date: Date) => void;
13
- label: string;
14
- minValue: Date;
15
- maxValue: Date;
16
- isDateUnavailable?: (v: Date) => boolean;
17
- Footer: (props: import("./props").HeaderFooterProps<import("@react-stately/calendar").CalendarState>) => import("react").ReactNode;
18
- Header: (props: import("./props").HeaderFooterProps<import("@react-stately/calendar").CalendarState>) => import("react").ReactNode;
19
- showTimeInput?: boolean;
20
- defaultValue?: Date;
21
- timezone: string;
22
- granularity?: "hour" | "minute" | "second";
23
- formatOptions?: import("react-aria").DateFormatterOptions;
24
- }>, "defaultValue" | "onChange" | "value" | "multiple" | "showTimeInput" | "stateRef"> & Partial<{
6
+ export declare const DateRangePicker: import("react").ForwardRefExoticComponent<Omit<import("./props").DatePickerProps, "defaultValue" | "onChange" | "value" | "multiple" | "showTimeInput" | "stateRef"> & Partial<{
25
7
  onChange: (range: {
26
8
  from: Date;
27
9
  to: Date;
@@ -3,7 +3,7 @@ import { AriaButtonProps } from 'react-aria';
3
3
  /**
4
4
  * Toggle component encapsulates the reset and open calendar buttons
5
5
  */
6
- export declare const Toggle: ({ reset, setOpen, open, icon, disabled, buttonProps, valueString, readonly, }: {
6
+ export declare const Toggle: ({ reset, setOpen, open, icon, disabled, buttonProps, valueString, showClearButton, readonly, }: {
7
7
  reset: () => void;
8
8
  setOpen: (open: boolean) => void;
9
9
  open: boolean;
@@ -12,4 +12,5 @@ export declare const Toggle: ({ reset, setOpen, open, icon, disabled, buttonProp
12
12
  readonly: boolean;
13
13
  buttonProps: AriaButtonProps;
14
14
  valueString: string;
15
+ showClearButton: boolean;
15
16
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,3 @@
1
1
  export * from './DatePicker';
2
2
  export * from './DateRangePicker';
3
+ export * from './props';
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, ReactNode } from 'react';
1
+ import { MutableRefObject, ReactNode, HTMLAttributes } from 'react';
2
2
  import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
3
3
  import { Variants } from '../types';
4
4
  import { HelperTextProps } from '../InputWrapper/HelperText';
@@ -14,7 +14,7 @@ export type HeaderFooterProps<T = CalendarState | RangeCalendarState> = {
14
14
  month: number;
15
15
  state: T;
16
16
  };
17
- export type DatePickerProps = Partial<{
17
+ export type DatePickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & Partial<{
18
18
  /**
19
19
  * The variant / state of the datepicker field
20
20
  * @default undefined
@@ -71,6 +71,11 @@ export type DatePickerProps = Partial<{
71
71
  * Whether to allow picking the time as well as the date
72
72
  */
73
73
  showTimeInput?: boolean;
74
+ /**
75
+ * hide the clear button even when date is set
76
+ * @default false
77
+ */
78
+ hideClearButton?: boolean;
74
79
  /**
75
80
  * Uncontrolled value
76
81
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.39.1-dev13062024",
3
+ "version": "0.40.0",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"