@equinor/eds-core-react 0.42.2 → 0.42.4

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.
@@ -9691,6 +9691,7 @@ function AutocompleteInner(props, ref) {
9691
9691
  helperIcon,
9692
9692
  noOptionsText = 'No options',
9693
9693
  variant,
9694
+ onClear,
9694
9695
  ...other
9695
9696
  } = props;
9696
9697
 
@@ -10123,6 +10124,7 @@ function AutocompleteInner(props, ref) {
10123
10124
  }
10124
10125
  }, [isOpen, refs.floating]);
10125
10126
  const clear = () => {
10127
+ if (onClear) onClear();
10126
10128
  resetCombobox();
10127
10129
  //dont clear items if they are selected and disabled
10128
10130
  setSelectedItems([...selectedDisabledItemsSet]);
@@ -10438,9 +10440,13 @@ const initalState = {
10438
10440
  };
10439
10441
  const SideBarContext = /*#__PURE__*/react.createContext(initalState);
10440
10442
  const SideBarProvider = ({
10441
- children
10443
+ children,
10444
+ isOpen: isOpenProp = false
10442
10445
  }) => {
10443
- const [state, setState] = react.useState(initalState);
10446
+ const [state, setState] = react.useState({
10447
+ onToggle: null,
10448
+ isOpen: isOpenProp
10449
+ });
10444
10450
  const {
10445
10451
  isOpen,
10446
10452
  onToggle
@@ -10473,13 +10479,11 @@ const useSideBar = () => react.useContext(SideBarContext);
10473
10479
 
10474
10480
  const SideBarContainer = /*#__PURE__*/react.forwardRef(function SideBarContainer({
10475
10481
  onToggle: onToggleCallback,
10476
- open = false,
10477
10482
  children,
10478
10483
  ...rest
10479
10484
  }, ref) {
10480
10485
  const {
10481
10486
  isOpen,
10482
- setIsOpen,
10483
10487
  onToggle,
10484
10488
  setOnToggle
10485
10489
  } = useSideBar();
@@ -10488,10 +10492,6 @@ const SideBarContainer = /*#__PURE__*/react.forwardRef(function SideBarContainer
10488
10492
  setOnToggle(onToggleCallback);
10489
10493
  }
10490
10494
  }, [onToggle, onToggleCallback, setOnToggle]);
10491
- react.useEffect(() => {
10492
- setIsOpen(open);
10493
- // eslint-disable-next-line react-hooks/exhaustive-deps
10494
- }, [open]);
10495
10495
  return /*#__PURE__*/jsxRuntime.jsx(GridContainer, {
10496
10496
  ...rest,
10497
10497
  open: isOpen,
@@ -10529,6 +10529,7 @@ const SideBar$1 = /*#__PURE__*/react.forwardRef(({
10529
10529
  return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
10530
10530
  theme: token,
10531
10531
  children: /*#__PURE__*/jsxRuntime.jsx(SideBarProvider, {
10532
+ isOpen: open,
10532
10533
  children: /*#__PURE__*/jsxRuntime.jsx(SideBarContainer, {
10533
10534
  ...props,
10534
10535
  ref: ref
@@ -11171,7 +11172,9 @@ SideBar.AccordionItem.displayName = 'SideBar.AccordionItem';
11171
11172
  const StyledCell = styled__default.default(Typography).withConfig({
11172
11173
  displayName: "CalendarCell__StyledCell",
11173
11174
  componentId: "sc-y5ycmg-0"
11174
- })(["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, ({
11175
+ })(["display:flex;justify-content:center;align-items:center;cursor:pointer;&:hover{background-color:", ";}", " ", " ", " ", " ", " ", " ", ""], edsTokens.tokens.colors.interactive.table__cell__fill_hover.rgba, ({
11176
+ $focused
11177
+ }) => $focused && `outline: 2px dashed rgba(0, 112, 121, 1);`, ({
11175
11178
  $selected
11176
11179
  }) => $selected && `background-color: ${edsTokens.tokens.colors.interactive.primary__selected_highlight.rgba};`, ({
11177
11180
  $hidden
@@ -11250,7 +11253,8 @@ function CalendarCell({
11250
11253
  isOutsideVisibleRange,
11251
11254
  isDisabled,
11252
11255
  isUnavailable,
11253
- formattedDate
11256
+ formattedDate,
11257
+ isFocused
11254
11258
  } = reactAria.useCalendarCell({
11255
11259
  date
11256
11260
  }, state, ref);
@@ -11298,6 +11302,7 @@ function CalendarCell({
11298
11302
  $highlight: isHighlight,
11299
11303
  $disabled: isDisabled || isUnavailable,
11300
11304
  $density: density,
11305
+ $focused: isFocused,
11301
11306
  children: formattedDate
11302
11307
  })
11303
11308
  });
@@ -185,6 +185,7 @@ function AutocompleteInner(props, ref) {
185
185
  helperIcon,
186
186
  noOptionsText = 'No options',
187
187
  variant,
188
+ onClear,
188
189
  ...other
189
190
  } = props;
190
191
 
@@ -617,6 +618,7 @@ function AutocompleteInner(props, ref) {
617
618
  }
618
619
  }, [isOpen, refs.floating]);
619
620
  const clear = () => {
621
+ if (onClear) onClear();
620
622
  resetCombobox();
621
623
  //dont clear items if they are selected and disabled
622
624
  setSelectedItems([...selectedDisabledItemsSet]);
@@ -9,7 +9,9 @@ import { useEds } from '../../EdsProvider/eds.context.js';
9
9
  const StyledCell = styled(Typography).withConfig({
10
10
  displayName: "CalendarCell__StyledCell",
11
11
  componentId: "sc-y5ycmg-0"
12
- })(["display:flex;justify-content:center;align-items:center;cursor:pointer;&:hover{background-color:", ";}&:focus{outline:2px dashed rgba(0,112,121,1);}", " ", " ", " ", " ", " ", ""], tokens.colors.interactive.table__cell__fill_hover.rgba, ({
12
+ })(["display:flex;justify-content:center;align-items:center;cursor:pointer;&:hover{background-color:", ";}", " ", " ", " ", " ", " ", " ", ""], tokens.colors.interactive.table__cell__fill_hover.rgba, ({
13
+ $focused
14
+ }) => $focused && `outline: 2px dashed rgba(0, 112, 121, 1);`, ({
13
15
  $selected
14
16
  }) => $selected && `background-color: ${tokens.colors.interactive.primary__selected_highlight.rgba};`, ({
15
17
  $hidden
@@ -88,7 +90,8 @@ function CalendarCell({
88
90
  isOutsideVisibleRange,
89
91
  isDisabled,
90
92
  isUnavailable,
91
- formattedDate
93
+ formattedDate,
94
+ isFocused
92
95
  } = useCalendarCell({
93
96
  date
94
97
  }, state, ref);
@@ -136,6 +139,7 @@ function CalendarCell({
136
139
  $highlight: isHighlight,
137
140
  $disabled: isDisabled || isUnavailable,
138
141
  $density: density,
142
+ $focused: isFocused,
139
143
  children: formattedDate
140
144
  })
141
145
  });
@@ -7,9 +7,13 @@ const initalState = {
7
7
  };
8
8
  const SideBarContext = /*#__PURE__*/createContext(initalState);
9
9
  const SideBarProvider = ({
10
- children
10
+ children,
11
+ isOpen: isOpenProp = false
11
12
  }) => {
12
- const [state, setState] = useState(initalState);
13
+ const [state, setState] = useState({
14
+ onToggle: null,
15
+ isOpen: isOpenProp
16
+ });
13
17
  const {
14
18
  isOpen,
15
19
  onToggle
@@ -8,13 +8,11 @@ import { useEds } from '../EdsProvider/eds.context.js';
8
8
 
9
9
  const SideBarContainer = /*#__PURE__*/forwardRef(function SideBarContainer({
10
10
  onToggle: onToggleCallback,
11
- open = false,
12
11
  children,
13
12
  ...rest
14
13
  }, ref) {
15
14
  const {
16
15
  isOpen,
17
- setIsOpen,
18
16
  onToggle,
19
17
  setOnToggle
20
18
  } = useSideBar();
@@ -23,10 +21,6 @@ const SideBarContainer = /*#__PURE__*/forwardRef(function SideBarContainer({
23
21
  setOnToggle(onToggleCallback);
24
22
  }
25
23
  }, [onToggle, onToggleCallback, setOnToggle]);
26
- useEffect(() => {
27
- setIsOpen(open);
28
- // eslint-disable-next-line react-hooks/exhaustive-deps
29
- }, [open]);
30
24
  return /*#__PURE__*/jsx(GridContainer, {
31
25
  ...rest,
32
26
  open: isOpen,
@@ -64,6 +58,7 @@ const SideBar = /*#__PURE__*/forwardRef(({
64
58
  return /*#__PURE__*/jsx(ThemeProvider, {
65
59
  theme: token,
66
60
  children: /*#__PURE__*/jsx(SideBarProvider, {
61
+ isOpen: open,
67
62
  children: /*#__PURE__*/jsx(SideBarContainer, {
68
63
  ...props,
69
64
  ref: ref
@@ -87,6 +87,10 @@ export type AutocompleteProps<T> = {
87
87
  * Method that is used to compare objects by value. If omitted, objects are matched by reference.
88
88
  */
89
89
  itemCompare?: (value: T, compare: T) => boolean;
90
+ /**
91
+ * Callback for clear all button
92
+ */
93
+ onClear?: () => void;
90
94
  } & HTMLAttributes<HTMLDivElement>;
91
95
  declare function AutocompleteInner<T>(props: AutocompleteProps<T>, ref: React.ForwardedRef<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
92
96
  export declare const Autocomplete: <T>(props: AutocompleteProps<T> & {
@@ -9,7 +9,8 @@ type UseSidebarProps<T> = T & {
9
9
  };
10
10
  type ProviderProps = {
11
11
  children: ReactNode;
12
+ isOpen: boolean;
12
13
  };
13
- export declare const SideBarProvider: ({ children }: ProviderProps) => JSX.Element;
14
+ export declare const SideBarProvider: ({ children, isOpen: isOpenProp, }: ProviderProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export declare const useSideBar: () => UseSidebarProps<State>;
15
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.42.2",
3
+ "version": "0.42.4",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -88,8 +88,8 @@
88
88
  "downshift": "9.0.8",
89
89
  "react-aria": "^3.34.1",
90
90
  "@equinor/eds-icons": "^0.21.0",
91
- "@equinor/eds-utils": "0.8.5",
92
- "@equinor/eds-tokens": "0.9.2"
91
+ "@equinor/eds-tokens": "0.9.2",
92
+ "@equinor/eds-utils": "0.8.5"
93
93
  },
94
94
  "scripts": {
95
95
  "build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",