@equinor/eds-core-react 0.41.2 → 0.41.4-dev02092024

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,15 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6389
6398
  const {
6390
6399
  getFloatingProps
6391
6400
  } = react$1.useInteractions([react$1.useDismiss(context)]);
6401
+ react.useEffect(() => {
6402
+ if (open) {
6403
+ if (refs.floating.current) {
6404
+ refs.floating.current?.showPopover();
6405
+ }
6406
+ } else {
6407
+ refs.floating.current?.hidePopover();
6408
+ }
6409
+ }, [open, refs.floating]);
6392
6410
  react.useEffect(() => {
6393
6411
  if (arrowRef.current) {
6394
6412
  const staticSide = {
@@ -6424,7 +6442,6 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6424
6442
  // eslint-disable-next-line react-hooks/exhaustive-deps
6425
6443
  }, [arrowRef.current, arrowX, arrowY, finalPlacement]);
6426
6444
  const props = {
6427
- open,
6428
6445
  ...rest
6429
6446
  };
6430
6447
  const {
@@ -6433,14 +6450,10 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6433
6450
  const token = edsUtils.useToken({
6434
6451
  density
6435
6452
  }, 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
6453
  const popover$1 = /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
6440
6454
  theme: token,
6441
- children: /*#__PURE__*/jsxRuntime.jsxs(PopoverPaper, {
6442
- elevation: "overlay",
6443
- ...props,
6455
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledPopover$2, {
6456
+ popover: "manual",
6444
6457
  ...getFloatingProps({
6445
6458
  ref: popoverRef,
6446
6459
  style: {
@@ -6450,35 +6463,30 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
6450
6463
  left: x || 0
6451
6464
  }
6452
6465
  }),
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"
6466
+ children: /*#__PURE__*/jsxRuntime.jsxs(PopoverPaper, {
6467
+ elevation: "overlay",
6468
+ ...props,
6469
+ children: [/*#__PURE__*/jsxRuntime.jsx(ArrowWrapper, {
6470
+ ref: arrowRef,
6471
+ className: "arrow",
6472
+ children: /*#__PURE__*/jsxRuntime.jsx(PopoverArrow, {
6473
+ className: "arrowSvg",
6474
+ children: /*#__PURE__*/jsxRuntime.jsx("path", {
6475
+ d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
6476
+ })
6460
6477
  })
6461
- })
6462
- }), /*#__PURE__*/jsxRuntime.jsx(InnerWrapper, {
6463
- children: children
6464
- })]
6478
+ }), /*#__PURE__*/jsxRuntime.jsx(InnerWrapper, {
6479
+ children: children
6480
+ })]
6481
+ })
6465
6482
  })
6466
6483
  });
6467
6484
  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
- })
6485
+ children: trapFocus ? open && /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingFocusManager, {
6486
+ context: context,
6487
+ modal: true,
6488
+ children: popover$1
6489
+ }) : open && popover$1
6482
6490
  });
6483
6491
  });
6484
6492
 
@@ -9562,7 +9570,6 @@ function AutocompleteInner(props, ref) {
9562
9570
  itemCompare,
9563
9571
  allowSelectAll,
9564
9572
  initialSelectedOptions: _initialSelectedOptions = [],
9565
- disablePortal,
9566
9573
  optionDisabled = defaultOptionDisabled,
9567
9574
  optionsFilter,
9568
9575
  autoWidth,
@@ -9582,9 +9589,6 @@ function AutocompleteInner(props, ref) {
9582
9589
  // MARK: initializing data/setup
9583
9590
  const selectedOptions = _selectedOptions ? itemCompare ? options.filter(item => _selectedOptions.some(compare => itemCompare(item, compare))) : _selectedOptions : undefined;
9584
9591
  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
9592
  const isControlled = Boolean(selectedOptions);
9589
9593
  const [inputOptions, setInputOptions] = react.useState(options);
9590
9594
  const [_availableItems, setAvailableItems] = react.useState(inputOptions);
@@ -9774,7 +9778,12 @@ function AutocompleteInner(props, ref) {
9774
9778
  if (selectedItem === AllSymbol) {
9775
9779
  toggleAllSelected();
9776
9780
  } else if (multiple) {
9777
- selectedItems.includes(selectedItem) ? removeSelectedItem(selectedItem) : addSelectedItem(selectedItem);
9781
+ const shouldRemove = itemCompare ? selectedItems.some(i => itemCompare(selectedItem, i)) : selectedItems.includes(selectedItem);
9782
+ if (shouldRemove) {
9783
+ removeSelectedItem(selectedItem);
9784
+ } else {
9785
+ addSelectedItem(selectedItem);
9786
+ }
9778
9787
  } else {
9779
9788
  setSelectedItems([selectedItem]);
9780
9789
  }
@@ -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, 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,15 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
87
96
  const {
88
97
  getFloatingProps
89
98
  } = useInteractions([useDismiss(context)]);
99
+ useEffect(() => {
100
+ if (open) {
101
+ if (refs.floating.current) {
102
+ refs.floating.current?.showPopover();
103
+ }
104
+ } else {
105
+ refs.floating.current?.hidePopover();
106
+ }
107
+ }, [open, refs.floating]);
90
108
  useEffect(() => {
91
109
  if (arrowRef.current) {
92
110
  const staticSide = {
@@ -122,7 +140,6 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
122
140
  // eslint-disable-next-line react-hooks/exhaustive-deps
123
141
  }, [arrowRef.current, arrowX, arrowY, finalPlacement]);
124
142
  const props = {
125
- open,
126
143
  ...rest
127
144
  };
128
145
  const {
@@ -131,14 +148,10 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
131
148
  const token = useToken({
132
149
  density
133
150
  }, popover);
134
-
135
- //temporary fix when inside dialog. Should be replaced by popover api when it is ready
136
- const inDialog = useIsInDialog(anchorEl);
137
151
  const popover$1 = /*#__PURE__*/jsx(ThemeProvider, {
138
152
  theme: token,
139
- children: /*#__PURE__*/jsxs(PopoverPaper, {
140
- elevation: "overlay",
141
- ...props,
153
+ children: /*#__PURE__*/jsx(StyledPopover, {
154
+ popover: "manual",
142
155
  ...getFloatingProps({
143
156
  ref: popoverRef,
144
157
  style: {
@@ -148,35 +161,30 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
148
161
  left: x || 0
149
162
  }
150
163
  }),
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"
164
+ children: /*#__PURE__*/jsxs(PopoverPaper, {
165
+ elevation: "overlay",
166
+ ...props,
167
+ children: [/*#__PURE__*/jsx(ArrowWrapper, {
168
+ ref: arrowRef,
169
+ className: "arrow",
170
+ children: /*#__PURE__*/jsx(PopoverArrow, {
171
+ className: "arrowSvg",
172
+ children: /*#__PURE__*/jsx("path", {
173
+ d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
174
+ })
158
175
  })
159
- })
160
- }), /*#__PURE__*/jsx(InnerWrapper, {
161
- children: children
162
- })]
176
+ }), /*#__PURE__*/jsx(InnerWrapper, {
177
+ children: children
178
+ })]
179
+ })
163
180
  })
164
181
  });
165
182
  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
- })
183
+ children: trapFocus ? open && /*#__PURE__*/jsx(FloatingFocusManager, {
184
+ context: context,
185
+ modal: true,
186
+ children: popover$1
187
+ }) : open && popover$1
180
188
  });
181
189
  });
182
190
 
@@ -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.4-dev02092024",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -85,12 +85,12 @@
85
85
  "@react-stately/calendar": "^3.5.3",
86
86
  "@react-stately/datepicker": "^3.10.1",
87
87
  "@react-types/shared": "^3.24.1",
88
- "@tanstack/react-virtual": "3.8.4",
89
- "downshift": "9.0.7",
88
+ "@tanstack/react-virtual": "3.10.6",
89
+ "downshift": "9.0.8",
90
90
  "react-aria": "^3.34.1",
91
+ "@equinor/eds-icons": "^0.21.0",
91
92
  "@equinor/eds-tokens": "0.9.2",
92
- "@equinor/eds-utils": "0.8.5",
93
- "@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",