@equinor/eds-core-react 0.41.2 → 0.41.3

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.
@@ -6320,19 +6320,25 @@ const PopoverPaper = styled__default.default(Paper).withConfig({
6320
6320
  paper
6321
6321
  }
6322
6322
  } = theme;
6323
- return styled.css(["", " background:", ";", " z-index:1400;&:focus-visible{", "}"], edsUtils.typographyTemplate(theme.typography), theme.background, edsUtils.bordersTemplate(theme.border), edsUtils.outlineTemplate(paper.states.focus.outline));
6323
+ return styled.css(["position:relative;", " background:", ";", " &:focus-visible{", "}"], edsUtils.typographyTemplate(theme.typography), theme.background, edsUtils.bordersTemplate(theme.border), edsUtils.outlineTemplate(paper.states.focus.outline));
6324
6324
  });
6325
+ const StyledPopover$2 = styled__default.default('div').withConfig({
6326
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
6327
+ }).withConfig({
6328
+ displayName: "Popover__StyledPopover",
6329
+ componentId: "sc-b7p1is-1"
6330
+ })(["inset:unset;border:0;padding:0;margin:0;overflow:visible;background-color:transparent;&::backdrop{background-color:transparent;}"]);
6325
6331
  const ArrowWrapper = styled__default.default.div.withConfig({
6326
6332
  displayName: "Popover__ArrowWrapper",
6327
- componentId: "sc-b7p1is-1"
6333
+ componentId: "sc-b7p1is-2"
6328
6334
  })(({
6329
6335
  theme
6330
6336
  }) => {
6331
- return styled.css(["position:absolute;width:", ";height:", ";z-index:-1;"], theme.entities.arrow.width, theme.entities.arrow.height);
6337
+ return styled.css(["position:absolute;width:", ";height:", ";"], theme.entities.arrow.width, theme.entities.arrow.height);
6332
6338
  });
6333
6339
  const InnerWrapper = styled__default.default.div.withConfig({
6334
6340
  displayName: "Popover__InnerWrapper",
6335
- componentId: "sc-b7p1is-2"
6341
+ componentId: "sc-b7p1is-3"
6336
6342
  })(({
6337
6343
  theme
6338
6344
  }) => {
@@ -6340,7 +6346,7 @@ const InnerWrapper = styled__default.default.div.withConfig({
6340
6346
  });
6341
6347
  const PopoverArrow = styled__default.default.svg.withConfig({
6342
6348
  displayName: "Popover__PopoverArrow",
6343
- componentId: "sc-b7p1is-3"
6349
+ componentId: "sc-b7p1is-4"
6344
6350
  })(({
6345
6351
  theme
6346
6352
  }) => {
@@ -6357,6 +6363,9 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6357
6363
  trapFocus,
6358
6364
  ...rest
6359
6365
  }, ref) {
6366
+ if (withinPortal) {
6367
+ console.warn('Popover "withinPortal" prop has been deprecated. Popover now uses the native popover api');
6368
+ }
6360
6369
  const arrowRef = react.useRef(null);
6361
6370
  const {
6362
6371
  x,
@@ -6389,6 +6398,13 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6389
6398
  const {
6390
6399
  getFloatingProps
6391
6400
  } = react$1.useInteractions([react$1.useDismiss(context)]);
6401
+ edsUtils.useIsomorphicLayoutEffect(() => {
6402
+ if (open) {
6403
+ refs.floating.current?.showPopover();
6404
+ } else {
6405
+ refs.floating.current?.hidePopover();
6406
+ }
6407
+ }, [open, refs.floating]);
6392
6408
  react.useEffect(() => {
6393
6409
  if (arrowRef.current) {
6394
6410
  const staticSide = {
@@ -6424,7 +6440,6 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6424
6440
  // eslint-disable-next-line react-hooks/exhaustive-deps
6425
6441
  }, [arrowRef.current, arrowX, arrowY, finalPlacement]);
6426
6442
  const props = {
6427
- open,
6428
6443
  ...rest
6429
6444
  };
6430
6445
  const {
@@ -6433,14 +6448,10 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6433
6448
  const token = edsUtils.useToken({
6434
6449
  density
6435
6450
  }, popover);
6436
-
6437
- //temporary fix when inside dialog. Should be replaced by popover api when it is ready
6438
- const inDialog = edsUtils.useIsInDialog(anchorEl);
6439
6451
  const popover$1 = /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
6440
6452
  theme: token,
6441
- children: /*#__PURE__*/jsxRuntime.jsxs(PopoverPaper, {
6442
- elevation: "overlay",
6443
- ...props,
6453
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledPopover$2, {
6454
+ popover: "manual",
6444
6455
  ...getFloatingProps({
6445
6456
  ref: popoverRef,
6446
6457
  style: {
@@ -6450,35 +6461,30 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6450
6461
  left: x || 0
6451
6462
  }
6452
6463
  }),
6453
- children: [/*#__PURE__*/jsxRuntime.jsx(ArrowWrapper, {
6454
- ref: arrowRef,
6455
- className: "arrow",
6456
- children: /*#__PURE__*/jsxRuntime.jsx(PopoverArrow, {
6457
- className: "arrowSvg",
6458
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
6459
- d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
6464
+ children: /*#__PURE__*/jsxRuntime.jsxs(PopoverPaper, {
6465
+ elevation: "overlay",
6466
+ ...props,
6467
+ children: [/*#__PURE__*/jsxRuntime.jsx(ArrowWrapper, {
6468
+ ref: arrowRef,
6469
+ className: "arrow",
6470
+ children: /*#__PURE__*/jsxRuntime.jsx(PopoverArrow, {
6471
+ className: "arrowSvg",
6472
+ children: /*#__PURE__*/jsxRuntime.jsx("path", {
6473
+ d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
6474
+ })
6460
6475
  })
6461
- })
6462
- }), /*#__PURE__*/jsxRuntime.jsx(InnerWrapper, {
6463
- children: children
6464
- })]
6476
+ }), /*#__PURE__*/jsxRuntime.jsx(InnerWrapper, {
6477
+ children: children
6478
+ })]
6479
+ })
6465
6480
  })
6466
6481
  });
6467
6482
  return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
6468
- children: withinPortal && !inDialog ? /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingPortal, {
6469
- id: "eds-popover-container",
6470
- children: open && trapFocus ? open && /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingFocusManager, {
6471
- context: context,
6472
- modal: true,
6473
- children: popover$1
6474
- }) : open && popover$1
6475
- }) : /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
6476
- children: trapFocus ? open && /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingFocusManager, {
6477
- context: context,
6478
- modal: true,
6479
- children: popover$1
6480
- }) : open && popover$1
6481
- })
6483
+ children: trapFocus ? open && /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingFocusManager, {
6484
+ context: context,
6485
+ modal: true,
6486
+ children: popover$1
6487
+ }) : open && popover$1
6482
6488
  });
6483
6489
  });
6484
6490
 
@@ -9562,7 +9568,6 @@ function AutocompleteInner(props, ref) {
9562
9568
  itemCompare,
9563
9569
  allowSelectAll,
9564
9570
  initialSelectedOptions: _initialSelectedOptions = [],
9565
- disablePortal,
9566
9571
  optionDisabled = defaultOptionDisabled,
9567
9572
  optionsFilter,
9568
9573
  autoWidth,
@@ -9582,9 +9587,6 @@ function AutocompleteInner(props, ref) {
9582
9587
  // MARK: initializing data/setup
9583
9588
  const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
9584
9589
  const initialSelectedOptions = _initialSelectedOptions ? itemCompare ? options.filter(item => _initialSelectedOptions.some(compare => itemCompare(item, compare))) : _initialSelectedOptions : undefined;
9585
- if (disablePortal) {
9586
- console.warn('Autocomplete "disablePortal" prop has been deprecated. Autocomplete now uses the native popover api');
9587
- }
9588
9590
  const isControlled = Boolean(selectedOptions);
9589
9591
  const [inputOptions, setInputOptions] = react.useState(options);
9590
9592
  const [_availableItems, setAvailableItems] = react.useState(inputOptions);
@@ -9774,7 +9776,12 @@ function AutocompleteInner(props, ref) {
9774
9776
  if (selectedItem === AllSymbol) {
9775
9777
  toggleAllSelected();
9776
9778
  } else if (multiple) {
9777
- selectedItems.includes(selectedItem) ? removeSelectedItem(selectedItem) : addSelectedItem(selectedItem);
9779
+ const shouldRemove = itemCompare ? selectedItems.some(i => itemCompare(selectedItem, i)) : selectedItems.includes(selectedItem);
9780
+ if (shouldRemove) {
9781
+ removeSelectedItem(selectedItem);
9782
+ } else {
9783
+ addSelectedItem(selectedItem);
9784
+ }
9778
9785
  } else {
9779
9786
  setSelectedItems([selectedItem]);
9780
9787
  }
@@ -172,7 +172,6 @@ function AutocompleteInner(props, ref) {
172
172
  itemCompare,
173
173
  allowSelectAll,
174
174
  initialSelectedOptions: _initialSelectedOptions = [],
175
- disablePortal,
176
175
  optionDisabled = defaultOptionDisabled,
177
176
  optionsFilter,
178
177
  autoWidth,
@@ -192,9 +191,6 @@ function AutocompleteInner(props, ref) {
192
191
  // MARK: initializing data/setup
193
192
  const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
194
193
  const initialSelectedOptions = _initialSelectedOptions ? itemCompare ? options.filter(item => _initialSelectedOptions.some(compare => itemCompare(item, compare))) : _initialSelectedOptions : undefined;
195
- if (disablePortal) {
196
- console.warn('Autocomplete "disablePortal" prop has been deprecated. Autocomplete now uses the native popover api');
197
- }
198
194
  const isControlled = Boolean(selectedOptions);
199
195
  const [inputOptions, setInputOptions] = useState(options);
200
196
  const [_availableItems, setAvailableItems] = useState(inputOptions);
@@ -384,7 +380,12 @@ function AutocompleteInner(props, ref) {
384
380
  if (selectedItem === AllSymbol) {
385
381
  toggleAllSelected();
386
382
  } else if (multiple) {
387
- selectedItems.includes(selectedItem) ? removeSelectedItem(selectedItem) : addSelectedItem(selectedItem);
383
+ const shouldRemove = itemCompare ? selectedItems.some(i => itemCompare(selectedItem, i)) : selectedItems.includes(selectedItem);
384
+ if (shouldRemove) {
385
+ removeSelectedItem(selectedItem);
386
+ } else {
387
+ addSelectedItem(selectedItem);
388
+ }
388
389
  } else {
389
390
  setSelectedItems([selectedItem]);
390
391
  }
@@ -1,8 +1,8 @@
1
1
  import { forwardRef, useRef, useMemo, useEffect } from 'react';
2
2
  import styled, { css, ThemeProvider } from 'styled-components';
3
- import { typographyTemplate, bordersTemplate, outlineTemplate, mergeRefs, useToken, useIsInDialog } from '@equinor/eds-utils';
3
+ import { typographyTemplate, bordersTemplate, outlineTemplate, mergeRefs, useIsomorphicLayoutEffect, useToken } from '@equinor/eds-utils';
4
4
  import { popover } from './Popover.tokens.js';
5
- import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useDismiss, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
5
+ import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useDismiss, FloatingFocusManager } from '@floating-ui/react';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import { Paper } from '../Paper/Paper.js';
8
8
  import { useEds } from '../EdsProvider/eds.context.js';
@@ -18,19 +18,25 @@ const PopoverPaper = styled(Paper).withConfig({
18
18
  paper
19
19
  }
20
20
  } = theme;
21
- return css(["", " background:", ";", " z-index:1400;&:focus-visible{", "}"], typographyTemplate(theme.typography), theme.background, bordersTemplate(theme.border), outlineTemplate(paper.states.focus.outline));
21
+ return css(["position:relative;", " background:", ";", " &:focus-visible{", "}"], typographyTemplate(theme.typography), theme.background, bordersTemplate(theme.border), outlineTemplate(paper.states.focus.outline));
22
22
  });
23
+ const StyledPopover = styled('div').withConfig({
24
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
25
+ }).withConfig({
26
+ displayName: "Popover__StyledPopover",
27
+ componentId: "sc-b7p1is-1"
28
+ })(["inset:unset;border:0;padding:0;margin:0;overflow:visible;background-color:transparent;&::backdrop{background-color:transparent;}"]);
23
29
  const ArrowWrapper = styled.div.withConfig({
24
30
  displayName: "Popover__ArrowWrapper",
25
- componentId: "sc-b7p1is-1"
31
+ componentId: "sc-b7p1is-2"
26
32
  })(({
27
33
  theme
28
34
  }) => {
29
- return css(["position:absolute;width:", ";height:", ";z-index:-1;"], theme.entities.arrow.width, theme.entities.arrow.height);
35
+ return css(["position:absolute;width:", ";height:", ";"], theme.entities.arrow.width, theme.entities.arrow.height);
30
36
  });
31
37
  const InnerWrapper = styled.div.withConfig({
32
38
  displayName: "Popover__InnerWrapper",
33
- componentId: "sc-b7p1is-2"
39
+ componentId: "sc-b7p1is-3"
34
40
  })(({
35
41
  theme
36
42
  }) => {
@@ -38,7 +44,7 @@ const InnerWrapper = styled.div.withConfig({
38
44
  });
39
45
  const PopoverArrow = styled.svg.withConfig({
40
46
  displayName: "Popover__PopoverArrow",
41
- componentId: "sc-b7p1is-3"
47
+ componentId: "sc-b7p1is-4"
42
48
  })(({
43
49
  theme
44
50
  }) => {
@@ -55,6 +61,9 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
55
61
  trapFocus,
56
62
  ...rest
57
63
  }, ref) {
64
+ if (withinPortal) {
65
+ console.warn('Popover "withinPortal" prop has been deprecated. Popover now uses the native popover api');
66
+ }
58
67
  const arrowRef = useRef(null);
59
68
  const {
60
69
  x,
@@ -87,6 +96,13 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
87
96
  const {
88
97
  getFloatingProps
89
98
  } = useInteractions([useDismiss(context)]);
99
+ useIsomorphicLayoutEffect(() => {
100
+ if (open) {
101
+ refs.floating.current?.showPopover();
102
+ } else {
103
+ refs.floating.current?.hidePopover();
104
+ }
105
+ }, [open, refs.floating]);
90
106
  useEffect(() => {
91
107
  if (arrowRef.current) {
92
108
  const staticSide = {
@@ -122,7 +138,6 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
122
138
  // eslint-disable-next-line react-hooks/exhaustive-deps
123
139
  }, [arrowRef.current, arrowX, arrowY, finalPlacement]);
124
140
  const props = {
125
- open,
126
141
  ...rest
127
142
  };
128
143
  const {
@@ -131,14 +146,10 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
131
146
  const token = useToken({
132
147
  density
133
148
  }, popover);
134
-
135
- //temporary fix when inside dialog. Should be replaced by popover api when it is ready
136
- const inDialog = useIsInDialog(anchorEl);
137
149
  const popover$1 = /*#__PURE__*/jsx(ThemeProvider, {
138
150
  theme: token,
139
- children: /*#__PURE__*/jsxs(PopoverPaper, {
140
- elevation: "overlay",
141
- ...props,
151
+ children: /*#__PURE__*/jsx(StyledPopover, {
152
+ popover: "manual",
142
153
  ...getFloatingProps({
143
154
  ref: popoverRef,
144
155
  style: {
@@ -148,35 +159,30 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
148
159
  left: x || 0
149
160
  }
150
161
  }),
151
- children: [/*#__PURE__*/jsx(ArrowWrapper, {
152
- ref: arrowRef,
153
- className: "arrow",
154
- children: /*#__PURE__*/jsx(PopoverArrow, {
155
- className: "arrowSvg",
156
- children: /*#__PURE__*/jsx("path", {
157
- d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
162
+ children: /*#__PURE__*/jsxs(PopoverPaper, {
163
+ elevation: "overlay",
164
+ ...props,
165
+ children: [/*#__PURE__*/jsx(ArrowWrapper, {
166
+ ref: arrowRef,
167
+ className: "arrow",
168
+ children: /*#__PURE__*/jsx(PopoverArrow, {
169
+ className: "arrowSvg",
170
+ children: /*#__PURE__*/jsx("path", {
171
+ d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
172
+ })
158
173
  })
159
- })
160
- }), /*#__PURE__*/jsx(InnerWrapper, {
161
- children: children
162
- })]
174
+ }), /*#__PURE__*/jsx(InnerWrapper, {
175
+ children: children
176
+ })]
177
+ })
163
178
  })
164
179
  });
165
180
  return /*#__PURE__*/jsx(Fragment, {
166
- children: withinPortal && !inDialog ? /*#__PURE__*/jsx(FloatingPortal, {
167
- id: "eds-popover-container",
168
- children: open && trapFocus ? open && /*#__PURE__*/jsx(FloatingFocusManager, {
169
- context: context,
170
- modal: true,
171
- children: popover$1
172
- }) : open && popover$1
173
- }) : /*#__PURE__*/jsx(Fragment, {
174
- children: trapFocus ? open && /*#__PURE__*/jsx(FloatingFocusManager, {
175
- context: context,
176
- modal: true,
177
- children: popover$1
178
- }) : open && popover$1
179
- })
181
+ children: trapFocus ? open && /*#__PURE__*/jsx(FloatingFocusManager, {
182
+ context: context,
183
+ modal: true,
184
+ children: popover$1
185
+ }) : open && popover$1
180
186
  });
181
187
  });
182
188
 
@@ -61,10 +61,6 @@ export type AutocompleteProps<T> = {
61
61
  optionLabel?: (option: T) => string;
62
62
  /** Custom option template */
63
63
  optionComponent?: (option: T, isSelected: boolean) => ReactNode;
64
- /** Disable use of react portal for dropdown
65
- * @deprecated Autocomplete now uses the native popover api to render the dropdown. This prop will be removed in a future version
66
- */
67
- disablePortal?: boolean;
68
64
  /** Disable option
69
65
  * @default () => false
70
66
  */
@@ -9,7 +9,9 @@ export type PopoverProps = {
9
9
  anchorEl?: HTMLElement | null;
10
10
  /** Is Popover open */
11
11
  open: boolean;
12
- /** initializes react portal for dropdown, default to false. */
12
+ /**
13
+ * @deprecated Popover now uses the native popover api instead of react portal. This prop will be removed in a future version
14
+ */
13
15
  withinPortal?: boolean;
14
16
  /** Determines whether focus should be trapped within dropdown,
15
17
  * default to false. */
@@ -24,7 +26,9 @@ export declare const Popover: import("react").ForwardRefExoticComponent<{
24
26
  anchorEl?: HTMLElement | null;
25
27
  /** Is Popover open */
26
28
  open: boolean;
27
- /** initializes react portal for dropdown, default to false. */
29
+ /**
30
+ * @deprecated Popover now uses the native popover api instead of react portal. This prop will be removed in a future version
31
+ */
28
32
  withinPortal?: boolean;
29
33
  /** Determines whether focus should be trapped within dropdown,
30
34
  * default to false. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.41.2",
3
+ "version": "0.41.3",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -89,8 +89,8 @@
89
89
  "downshift": "9.0.7",
90
90
  "react-aria": "^3.34.1",
91
91
  "@equinor/eds-tokens": "0.9.2",
92
- "@equinor/eds-utils": "0.8.5",
93
- "@equinor/eds-icons": "^0.21.0"
92
+ "@equinor/eds-icons": "^0.21.0",
93
+ "@equinor/eds-utils": "0.8.5"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",