@equinor/eds-core-react 0.40.1 → 0.41.1

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.
@@ -7,7 +7,6 @@ var edsUtils = require('@equinor/eds-utils');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
  var react$1 = require('@floating-ui/react');
9
9
  var edsIcons = require('@equinor/eds-icons');
10
- var ReactDom = require('react-dom');
11
10
  var downshift = require('downshift');
12
11
  var reactVirtual = require('@tanstack/react-virtual');
13
12
  var reactAria = require('react-aria');
@@ -18,26 +17,7 @@ var utils = require('@react-aria/utils');
18
17
 
19
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
19
 
21
- function _interopNamespace(e) {
22
- if (e && e.__esModule) return e;
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- if (k !== 'default') {
27
- var d = Object.getOwnPropertyDescriptor(e, k);
28
- Object.defineProperty(n, k, d.get ? d : {
29
- enumerable: true,
30
- get: function () { return e[k]; }
31
- });
32
- }
33
- });
34
- }
35
- n.default = e;
36
- return Object.freeze(n);
37
- }
38
-
39
20
  var styled__default = /*#__PURE__*/_interopDefault(styled);
40
- var ReactDom__namespace = /*#__PURE__*/_interopNamespace(ReactDom);
41
21
 
42
22
  const {
43
23
  typography: {
@@ -1147,10 +1127,12 @@ const tooltip = {
1147
1127
  }
1148
1128
  };
1149
1129
 
1150
- const StyledTooltip = styled__default.default.div.withConfig({
1130
+ const StyledTooltip = styled__default.default('div').withConfig({
1131
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
1132
+ }).withConfig({
1151
1133
  displayName: "Tooltip__StyledTooltip",
1152
1134
  componentId: "sc-m2im2p-0"
1153
- })(["", " ", " ", " background:", ";z-index:1500;white-space:nowrap;&::before{content:'; Has tooltip: ';clip-path:inset(50%);height:1px;width:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;}"], edsUtils.typographyTemplate(tooltip.typography), edsUtils.spacingsTemplate(tooltip.spacings), edsUtils.bordersTemplate(tooltip.border), tooltip.background);
1135
+ })(["inset:unset;border:0;overflow:visible;", " ", " ", " background:", ";white-space:nowrap;&::before{content:'; Has tooltip: ';clip-path:inset(50%);height:1px;width:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;}&::backdrop{background-color:transparent;}"], edsUtils.typographyTemplate(tooltip.typography), edsUtils.spacingsTemplate(tooltip.spacings), edsUtils.bordersTemplate(tooltip.border), tooltip.background);
1154
1136
  const ArrowWrapper$1 = styled__default.default.div.withConfig({
1155
1137
  displayName: "Tooltip__ArrowWrapper",
1156
1138
  componentId: "sc-m2im2p-1"
@@ -1245,10 +1227,13 @@ const Tooltip$2 = /*#__PURE__*/react.forwardRef(function Tooltip({
1245
1227
  ...children.props
1246
1228
  })
1247
1229
  });
1248
-
1249
- //temporary fix for tooltip inside dialog. Should be replaced by popover api when it is ready
1250
- const inDialog = edsUtils.useIsInDialog(refs.domReference.current);
1230
+ edsUtils.useIsomorphicLayoutEffect(() => {
1231
+ if (shouldOpen && open) {
1232
+ refs.floating.current?.showPopover();
1233
+ }
1234
+ }, [open, shouldOpen, refs.floating]);
1251
1235
  const TooltipEl = /*#__PURE__*/jsxRuntime.jsxs(StyledTooltip, {
1236
+ popover: "manual",
1252
1237
  ...rest,
1253
1238
  ...getFloatingProps({
1254
1239
  ref: tooltipRef,
@@ -1270,12 +1255,7 @@ const Tooltip$2 = /*#__PURE__*/react.forwardRef(function Tooltip({
1270
1255
  })]
1271
1256
  });
1272
1257
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1273
- children: [inDialog ? /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
1274
- children: shouldOpen && open && TooltipEl
1275
- }) : /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingPortal, {
1276
- id: "eds-tooltip-container",
1277
- children: shouldOpen && open && TooltipEl
1278
- }), updatedChildren]
1258
+ children: [shouldOpen && open && TooltipEl, updatedChildren]
1279
1259
  });
1280
1260
  });
1281
1261
 
@@ -1294,7 +1274,7 @@ const ToggleButton = /*#__PURE__*/react.forwardRef(function ToggleButton({
1294
1274
  }, [selectedIndexes]);
1295
1275
  function updateProps(child, isSelected, index) {
1296
1276
  const childElement = child;
1297
- if ( /*#__PURE__*/react.isValidElement(child) && child.type === Button$2) {
1277
+ if ( /*#__PURE__*/react.isValidElement(child)) {
1298
1278
  const buttonProps = {
1299
1279
  'aria-pressed': isSelected ? true : undefined,
1300
1280
  variant: isSelected ? 'contained' : 'outlined',
@@ -3909,7 +3889,7 @@ const StyledTabList = styled__default.default.div.attrs(() => ({
3909
3889
  })).withConfig({
3910
3890
  displayName: "TabList__StyledTabList",
3911
3891
  componentId: "sc-1g1p5i1-0"
3912
- })(["display:grid;grid-auto-flow:column;grid-auto-columns:", ";overflow-x:", ";scroll-snap-type:x mandatory;overscroll-behavior-x:contain;@media (prefers-reduced-motion:no-preference){scroll-behavior:smooth;}@media (hover:none){overflow-x:scroll;-webkit-overflow-scrolling:touch;scrollbar-width:0;& ::-webkit-scrollbar{width:0;height:0;}}"], ({
3892
+ })(["display:grid;grid-auto-flow:column;grid-auto-columns:", ";overflow-x:", ";scroll-snap-type:x mandatory;overscroll-behavior-x:contain;@media (prefers-reduced-motion:no-preference){scroll-behavior:smooth;}@media (hover:none){overflow-x:scroll;-webkit-overflow-scrolling:touch;scrollbar-width:none;& ::-webkit-scrollbar{width:0;height:0;}}"], ({
3913
3893
  $variant
3914
3894
  }) => variants$1[$variant], ({
3915
3895
  $scrollable
@@ -6167,20 +6147,30 @@ const snackbar = {
6167
6147
  }
6168
6148
  };
6169
6149
 
6170
- const StyledSnackbar = styled__default.default(Paper).withConfig({
6171
- displayName: "Snackbar__StyledSnackbar",
6150
+ const PopoverDiv = styled__default.default('div').withConfig({
6151
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
6152
+ ,
6153
+ displayName: "Snackbar__PopoverDiv",
6172
6154
  componentId: "sc-ac6no8-0"
6173
6155
  })(({
6174
6156
  theme,
6175
6157
  $placement
6176
6158
  }) => {
6177
- return styled.css(["position:fixed;background-color:", ";", " ", " ", " min-height:", ";box-sizing:border-box;z-index:1400;", " a,button{color:", ";}"], theme.background, edsUtils.spacingsTemplate(theme.spacings), edsUtils.bordersTemplate(theme.border), edsUtils.typographyTemplate(theme.typography), theme.minHeight, {
6159
+ return styled.css(["inset:unset;border:0;overflow:visible;position:fixed;padding:0;background-color:transparent;", " &::backdrop{background-color:transparent;}"], {
6178
6160
  top: $placement.includes('top') ? theme.spacings.top : $placement === 'left' || $placement === 'right' ? '50%' : undefined,
6179
6161
  bottom: $placement.includes('bottom') ? theme.spacings.bottom : undefined,
6180
6162
  right: $placement.includes('right') ? theme.spacings.right : undefined,
6181
6163
  left: $placement.includes('left') ? theme.spacings.left : $placement === 'top' || $placement === 'bottom' ? '50%' : undefined,
6182
6164
  transform: $placement === 'left' || $placement === 'right' ? 'translateY(-50%)' : $placement === 'top' || $placement === 'bottom' ? 'translateX(-50%)' : undefined
6183
- }, theme.entities.button.typography.color);
6165
+ });
6166
+ });
6167
+ const StyledSnackbar = styled__default.default(Paper).withConfig({
6168
+ displayName: "Snackbar__StyledSnackbar",
6169
+ componentId: "sc-ac6no8-1"
6170
+ })(({
6171
+ theme
6172
+ }) => {
6173
+ return styled.css(["background-color:", ";", " ", " ", " min-height:", ";box-sizing:border-box;a,button{color:", ";}"], theme.background, edsUtils.spacingsTemplate(theme.spacings), edsUtils.bordersTemplate(theme.border), edsUtils.typographyTemplate(theme.typography), theme.minHeight, theme.entities.button.typography.color);
6184
6174
  });
6185
6175
  const Snackbar$1 = /*#__PURE__*/react.forwardRef(function Snackbar({
6186
6176
  open = false,
@@ -6203,10 +6193,10 @@ const Snackbar$1 = /*#__PURE__*/react.forwardRef(function Snackbar({
6203
6193
  }, autoHideDuration);
6204
6194
  }
6205
6195
  return () => clearTimeout(timer.current);
6206
- }, [open, autoHideDuration, setVisible, onClose]);
6196
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6197
+ }, [open, autoHideDuration]);
6207
6198
  const props = {
6208
6199
  ref,
6209
- $placement: placement,
6210
6200
  ...rest
6211
6201
  };
6212
6202
  const {
@@ -6217,12 +6207,17 @@ const Snackbar$1 = /*#__PURE__*/react.forwardRef(function Snackbar({
6217
6207
  }, snackbar);
6218
6208
  return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
6219
6209
  theme: token,
6220
- children: visible && /*#__PURE__*/ReactDom__namespace.createPortal( /*#__PURE__*/jsxRuntime.jsx(StyledSnackbar, {
6221
- role: "alert",
6222
- elevation: "overlay",
6223
- ...props,
6224
- children: children
6225
- }), document.body)
6210
+ children: visible && /*#__PURE__*/jsxRuntime.jsx(PopoverDiv, {
6211
+ popover: "manual",
6212
+ $placement: placement,
6213
+ ref: el => el?.showPopover(),
6214
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledSnackbar, {
6215
+ role: "alert",
6216
+ elevation: "overlay",
6217
+ ...props,
6218
+ children: children
6219
+ })
6220
+ })
6226
6221
  });
6227
6222
  });
6228
6223
 
@@ -7704,6 +7699,7 @@ const MenuSection = /*#__PURE__*/react.memo(function MenuSection(props) {
7704
7699
  variant: "small"
7705
7700
  })
7706
7701
  }), title && /*#__PURE__*/jsxRuntime.jsx(Header, {
7702
+ role: "group",
7707
7703
  children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
7708
7704
  group: "navigation",
7709
7705
  variant: "label",
@@ -7814,11 +7810,13 @@ const {
7814
7810
  const MenuPaper = styled__default.default(Paper).withConfig({
7815
7811
  displayName: "Menu__MenuPaper",
7816
7812
  componentId: "sc-1vlnqcj-0"
7817
- })(["position:absolute;z-index:1400;width:fit-content;min-width:fit-content;", ";", ";"], edsUtils.bordersTemplate(border$1), ({
7818
- open
7819
- }) => styled.css({
7820
- display: open ? 'block' : 'none'
7821
- }));
7813
+ })(["width:100%;min-width:fit-content;", ";"], edsUtils.bordersTemplate(border$1));
7814
+ const StyledPopover$1 = styled__default.default('div').withConfig({
7815
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
7816
+ }).withConfig({
7817
+ displayName: "Menu__StyledPopover",
7818
+ componentId: "sc-1vlnqcj-1"
7819
+ })(["inset:unset;border:0;padding:0;margin:0;overflow:visible;background-color:transparent;&::backdrop{background-color:transparent;}"]);
7822
7820
  const MenuContainer = /*#__PURE__*/react.forwardRef(function MenuContainer({
7823
7821
  children,
7824
7822
  anchorEl,
@@ -7947,13 +7945,19 @@ const Menu$1 = /*#__PURE__*/react.forwardRef(function Menu({
7947
7945
  return react$1.autoUpdate(refs.reference.current, refs.floating.current, update);
7948
7946
  }
7949
7947
  }, [refs.reference, refs.floating, update, open]);
7948
+ edsUtils.useIsomorphicLayoutEffect(() => {
7949
+ if (open) {
7950
+ refs.floating.current?.showPopover();
7951
+ } else {
7952
+ refs.floating.current?.hidePopover();
7953
+ }
7954
+ }, [open, refs.floating]);
7950
7955
  const {
7951
7956
  getFloatingProps
7952
7957
  } = react$1.useInteractions([react$1.useDismiss(context, {
7953
7958
  escapeKey: false
7954
7959
  })]);
7955
7960
  const props = {
7956
- open,
7957
7961
  className
7958
7962
  };
7959
7963
  const menuProps = {
@@ -7962,14 +7966,10 @@ const Menu$1 = /*#__PURE__*/react.forwardRef(function Menu({
7962
7966
  anchorEl,
7963
7967
  open
7964
7968
  };
7965
-
7966
- //temporary fix when inside dialog. Should be replaced by popover api when it is ready
7967
- const inDialog = edsUtils.useIsInDialog(anchorEl);
7968
- const menuElement = /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
7969
+ return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
7969
7970
  theme: token,
7970
- children: /*#__PURE__*/jsxRuntime.jsx(MenuPaper, {
7971
- elevation: "raised",
7972
- ...props,
7971
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledPopover$1, {
7972
+ popover: "manual",
7973
7973
  ...getFloatingProps({
7974
7974
  ref: popoverRef,
7975
7975
  style: {
@@ -7979,20 +7979,18 @@ const Menu$1 = /*#__PURE__*/react.forwardRef(function Menu({
7979
7979
  left: x || 0
7980
7980
  }
7981
7981
  }),
7982
- children: /*#__PURE__*/jsxRuntime.jsx(MenuProvider, {
7983
- children: /*#__PURE__*/jsxRuntime.jsx(MenuContainer, {
7984
- ...menuProps,
7985
- ref: ref
7982
+ children: /*#__PURE__*/jsxRuntime.jsx(MenuPaper, {
7983
+ elevation: "raised",
7984
+ ...props,
7985
+ children: /*#__PURE__*/jsxRuntime.jsx(MenuProvider, {
7986
+ children: /*#__PURE__*/jsxRuntime.jsx(MenuContainer, {
7987
+ ...menuProps,
7988
+ ref: ref
7989
+ })
7986
7990
  })
7987
7991
  })
7988
7992
  })
7989
7993
  });
7990
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
7991
- children: inDialog ? menuElement : /*#__PURE__*/jsxRuntime.jsx(react$1.FloatingPortal, {
7992
- id: "eds-menu-container",
7993
- children: menuElement
7994
- })
7995
- });
7996
7994
  });
7997
7995
 
7998
7996
  const Menu = Menu$1;
@@ -9357,7 +9355,7 @@ const StyledListItem = styled__default.default.li.withConfig({
9357
9355
  $isdisabled
9358
9356
  }) => {
9359
9357
  const backgroundColor = $highlighted === 'true' ? theme.states.hover.background : $active === 'true' ? theme.states.active.background : theme.background;
9360
- return styled.css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;touch-action:manipulation;cursor:", ";", " ", " ", ""], backgroundColor, $highlighted === 'true' ? 'pointer' : 'default', edsUtils.typographyTemplate(theme.typography), edsUtils.spacingsTemplate(theme.spacings), $isdisabled === 'true' ? styled.css(["color:", ";"], theme.states.disabled.typography.color) : '');
9358
+ return styled.css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;touch-action:manipulation;z-index:3;cursor:", ";", " ", " ", ""], backgroundColor, $highlighted === 'true' ? 'pointer' : 'default', edsUtils.typographyTemplate(theme.typography), edsUtils.spacingsTemplate(theme.spacings), $isdisabled === 'true' ? styled.css(["color:", ";"], theme.states.disabled.typography.color) : '');
9361
9359
  });
9362
9360
  const Label = styled__default.default.span.withConfig({
9363
9361
  displayName: "Option__Label",
@@ -9461,7 +9459,7 @@ const findIndex = ({
9461
9459
  availableItems
9462
9460
  }) => {
9463
9461
  const nextItem = availableItems[index];
9464
- if (optionDisabled(nextItem)) {
9462
+ if (optionDisabled(nextItem) && index >= 0 && index < availableItems.length) {
9465
9463
  const nextIndex = calc(index);
9466
9464
  return findIndex({
9467
9465
  calc,
@@ -9696,7 +9694,7 @@ function AutocompleteInner(props, ref) {
9696
9694
  try {
9697
9695
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
9698
9696
  return item?.toString();
9699
- } catch (error) {
9697
+ } catch {
9700
9698
  throw new Error('Unable to find label, make sure your are using options as documented');
9701
9699
  }
9702
9700
  }, [optionLabel]);
@@ -9997,9 +9995,9 @@ function AutocompleteInner(props, ref) {
9997
9995
  // MARK: popover toggle
9998
9996
  edsUtils.useIsomorphicLayoutEffect(() => {
9999
9997
  if (isOpen) {
10000
- refs.floating.current.showPopover();
9998
+ refs.floating.current?.showPopover();
10001
9999
  } else {
10002
- refs.floating.current.hidePopover();
10000
+ refs.floating.current?.hidePopover();
10003
10001
  }
10004
10002
  }, [isOpen, refs.floating]);
10005
10003
  const clear = () => {
@@ -12199,6 +12197,7 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
12199
12197
  timezone: timezone,
12200
12198
  formatOptions: formatOptions,
12201
12199
  children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
12200
+ ...props,
12202
12201
  isOpen: isOpen,
12203
12202
  color: state.isInvalid ? 'warning' : props.variant,
12204
12203
  helperProps: helperProps ?? props.helperProps,
@@ -69,7 +69,7 @@ const findIndex = ({
69
69
  availableItems
70
70
  }) => {
71
71
  const nextItem = availableItems[index];
72
- if (optionDisabled(nextItem)) {
72
+ if (optionDisabled(nextItem) && index >= 0 && index < availableItems.length) {
73
73
  const nextIndex = calc(index);
74
74
  return findIndex({
75
75
  calc,
@@ -304,7 +304,7 @@ function AutocompleteInner(props, ref) {
304
304
  try {
305
305
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
306
306
  return item?.toString();
307
- } catch (error) {
307
+ } catch {
308
308
  throw new Error('Unable to find label, make sure your are using options as documented');
309
309
  }
310
310
  }, [optionLabel]);
@@ -605,9 +605,9 @@ function AutocompleteInner(props, ref) {
605
605
  // MARK: popover toggle
606
606
  useIsomorphicLayoutEffect(() => {
607
607
  if (isOpen) {
608
- refs.floating.current.showPopover();
608
+ refs.floating.current?.showPopover();
609
609
  } else {
610
- refs.floating.current.hidePopover();
610
+ refs.floating.current?.hidePopover();
611
611
  }
612
612
  }, [isOpen, refs.floating]);
613
613
  const clear = () => {
@@ -14,7 +14,7 @@ const StyledListItem = styled.li.withConfig({
14
14
  $isdisabled
15
15
  }) => {
16
16
  const backgroundColor = $highlighted === 'true' ? theme.states.hover.background : $active === 'true' ? theme.states.active.background : theme.background;
17
- return css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;touch-action:manipulation;cursor:", ";", " ", " ", ""], backgroundColor, $highlighted === 'true' ? 'pointer' : 'default', typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), $isdisabled === 'true' ? css(["color:", ";"], theme.states.disabled.typography.color) : '');
17
+ return css(["display:flex;grid-area:1 / -1;align-items:center;align-self:start;margin:0;list-style:none;background-color:", ";user-select:none;overflow:hidden;touch-action:manipulation;z-index:3;cursor:", ";", " ", " ", ""], backgroundColor, $highlighted === 'true' ? 'pointer' : 'default', typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), $isdisabled === 'true' ? css(["color:", ";"], theme.states.disabled.typography.color) : '');
18
18
  });
19
19
  const Label = styled.span.withConfig({
20
20
  displayName: "Option__Label",
@@ -1,5 +1,4 @@
1
1
  import { forwardRef, useState, useEffect, Children, isValidElement, cloneElement } from 'react';
2
- import { Button } from '../Button.js';
3
2
  import { jsx } from 'react/jsx-runtime';
4
3
  import { Tooltip } from '../../Tooltip/Tooltip.js';
5
4
  import { ButtonGroup } from '../ButtonGroup/ButtonGroup.js';
@@ -19,7 +18,7 @@ const ToggleButton = /*#__PURE__*/forwardRef(function ToggleButton({
19
18
  }, [selectedIndexes]);
20
19
  function updateProps(child, isSelected, index) {
21
20
  const childElement = child;
22
- if ( /*#__PURE__*/isValidElement(child) && child.type === Button) {
21
+ if ( /*#__PURE__*/isValidElement(child)) {
23
22
  const buttonProps = {
24
23
  'aria-pressed': isSelected ? true : undefined,
25
24
  variant: isSelected ? 'contained' : 'outlined',
@@ -122,6 +122,7 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
122
122
  timezone: timezone,
123
123
  formatOptions: formatOptions,
124
124
  children: /*#__PURE__*/jsx(FieldWrapper, {
125
+ ...props,
125
126
  isOpen: isOpen,
126
127
  color: state.isInvalid ? 'warning' : props.variant,
127
128
  helperProps: helperProps ?? props.helperProps,
@@ -1,11 +1,11 @@
1
1
  import { forwardRef, useMemo, useEffect } from 'react';
2
- import styled, { css, ThemeProvider } from 'styled-components';
2
+ import styled, { ThemeProvider } from 'styled-components';
3
3
  import { MenuProvider, useMenu } from './Menu.context.js';
4
4
  import { MenuList } from './MenuList.js';
5
- import { bordersTemplate, useToken, mergeRefs, useIsomorphicLayoutEffect, useIsInDialog, useGlobalKeyPress } from '@equinor/eds-utils';
5
+ import { bordersTemplate, useToken, mergeRefs, useIsomorphicLayoutEffect, useGlobalKeyPress } from '@equinor/eds-utils';
6
6
  import { menu } from './Menu.tokens.js';
7
- import { offset, flip, shift, size, useFloating, autoUpdate, useInteractions, useDismiss, FloatingPortal } from '@floating-ui/react';
8
- import { jsx, Fragment } from 'react/jsx-runtime';
7
+ import { offset, flip, shift, size, useFloating, autoUpdate, useInteractions, useDismiss } from '@floating-ui/react';
8
+ import { jsx } from 'react/jsx-runtime';
9
9
  import { Paper } from '../Paper/Paper.js';
10
10
  import { useEds } from '../EdsProvider/eds.context.js';
11
11
 
@@ -15,11 +15,13 @@ const {
15
15
  const MenuPaper = styled(Paper).withConfig({
16
16
  displayName: "Menu__MenuPaper",
17
17
  componentId: "sc-1vlnqcj-0"
18
- })(["position:absolute;z-index:1400;width:fit-content;min-width:fit-content;", ";", ";"], bordersTemplate(border), ({
19
- open
20
- }) => css({
21
- display: open ? 'block' : 'none'
22
- }));
18
+ })(["width:100%;min-width:fit-content;", ";"], bordersTemplate(border));
19
+ const StyledPopover = styled('div').withConfig({
20
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
21
+ }).withConfig({
22
+ displayName: "Menu__StyledPopover",
23
+ componentId: "sc-1vlnqcj-1"
24
+ })(["inset:unset;border:0;padding:0;margin:0;overflow:visible;background-color:transparent;&::backdrop{background-color:transparent;}"]);
23
25
  const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
24
26
  children,
25
27
  anchorEl,
@@ -148,13 +150,19 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
148
150
  return autoUpdate(refs.reference.current, refs.floating.current, update);
149
151
  }
150
152
  }, [refs.reference, refs.floating, update, open]);
153
+ useIsomorphicLayoutEffect(() => {
154
+ if (open) {
155
+ refs.floating.current?.showPopover();
156
+ } else {
157
+ refs.floating.current?.hidePopover();
158
+ }
159
+ }, [open, refs.floating]);
151
160
  const {
152
161
  getFloatingProps
153
162
  } = useInteractions([useDismiss(context, {
154
163
  escapeKey: false
155
164
  })]);
156
165
  const props = {
157
- open,
158
166
  className
159
167
  };
160
168
  const menuProps = {
@@ -163,14 +171,10 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
163
171
  anchorEl,
164
172
  open
165
173
  };
166
-
167
- //temporary fix when inside dialog. Should be replaced by popover api when it is ready
168
- const inDialog = useIsInDialog(anchorEl);
169
- const menuElement = /*#__PURE__*/jsx(ThemeProvider, {
174
+ return /*#__PURE__*/jsx(ThemeProvider, {
170
175
  theme: token,
171
- children: /*#__PURE__*/jsx(MenuPaper, {
172
- elevation: "raised",
173
- ...props,
176
+ children: /*#__PURE__*/jsx(StyledPopover, {
177
+ popover: "manual",
174
178
  ...getFloatingProps({
175
179
  ref: popoverRef,
176
180
  style: {
@@ -180,20 +184,18 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
180
184
  left: x || 0
181
185
  }
182
186
  }),
183
- children: /*#__PURE__*/jsx(MenuProvider, {
184
- children: /*#__PURE__*/jsx(MenuContainer, {
185
- ...menuProps,
186
- ref: ref
187
+ children: /*#__PURE__*/jsx(MenuPaper, {
188
+ elevation: "raised",
189
+ ...props,
190
+ children: /*#__PURE__*/jsx(MenuProvider, {
191
+ children: /*#__PURE__*/jsx(MenuContainer, {
192
+ ...menuProps,
193
+ ref: ref
194
+ })
187
195
  })
188
196
  })
189
197
  })
190
198
  });
191
- return /*#__PURE__*/jsx(Fragment, {
192
- children: inDialog ? menuElement : /*#__PURE__*/jsx(FloatingPortal, {
193
- id: "eds-menu-container",
194
- children: menuElement
195
- })
196
- });
197
199
  });
198
200
 
199
201
  export { Menu };
@@ -24,6 +24,7 @@ const MenuSection = /*#__PURE__*/memo(function MenuSection(props) {
24
24
  variant: "small"
25
25
  })
26
26
  }), title && /*#__PURE__*/jsx(Header, {
27
+ role: "group",
27
28
  children: /*#__PURE__*/jsx(Typography, {
28
29
  group: "navigation",
29
30
  variant: "label",
@@ -1,5 +1,4 @@
1
1
  import { forwardRef, useState, useRef, useEffect } from 'react';
2
- import * as ReactDom from 'react-dom';
3
2
  import styled, { css, ThemeProvider } from 'styled-components';
4
3
  import { snackbar } from './Snackbar.tokens.js';
5
4
  import { spacingsTemplate, bordersTemplate, typographyTemplate, useToken } from '@equinor/eds-utils';
@@ -7,20 +6,30 @@ import { jsx } from 'react/jsx-runtime';
7
6
  import { Paper } from '../Paper/Paper.js';
8
7
  import { useEds } from '../EdsProvider/eds.context.js';
9
8
 
10
- const StyledSnackbar = styled(Paper).withConfig({
11
- displayName: "Snackbar__StyledSnackbar",
9
+ const PopoverDiv = styled('div').withConfig({
10
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
11
+ ,
12
+ displayName: "Snackbar__PopoverDiv",
12
13
  componentId: "sc-ac6no8-0"
13
14
  })(({
14
15
  theme,
15
16
  $placement
16
17
  }) => {
17
- return css(["position:fixed;background-color:", ";", " ", " ", " min-height:", ";box-sizing:border-box;z-index:1400;", " a,button{color:", ";}"], theme.background, spacingsTemplate(theme.spacings), bordersTemplate(theme.border), typographyTemplate(theme.typography), theme.minHeight, {
18
+ return css(["inset:unset;border:0;overflow:visible;position:fixed;padding:0;background-color:transparent;", " &::backdrop{background-color:transparent;}"], {
18
19
  top: $placement.includes('top') ? theme.spacings.top : $placement === 'left' || $placement === 'right' ? '50%' : undefined,
19
20
  bottom: $placement.includes('bottom') ? theme.spacings.bottom : undefined,
20
21
  right: $placement.includes('right') ? theme.spacings.right : undefined,
21
22
  left: $placement.includes('left') ? theme.spacings.left : $placement === 'top' || $placement === 'bottom' ? '50%' : undefined,
22
23
  transform: $placement === 'left' || $placement === 'right' ? 'translateY(-50%)' : $placement === 'top' || $placement === 'bottom' ? 'translateX(-50%)' : undefined
23
- }, theme.entities.button.typography.color);
24
+ });
25
+ });
26
+ const StyledSnackbar = styled(Paper).withConfig({
27
+ displayName: "Snackbar__StyledSnackbar",
28
+ componentId: "sc-ac6no8-1"
29
+ })(({
30
+ theme
31
+ }) => {
32
+ return css(["background-color:", ";", " ", " ", " min-height:", ";box-sizing:border-box;a,button{color:", ";}"], theme.background, spacingsTemplate(theme.spacings), bordersTemplate(theme.border), typographyTemplate(theme.typography), theme.minHeight, theme.entities.button.typography.color);
24
33
  });
25
34
  const Snackbar = /*#__PURE__*/forwardRef(function Snackbar({
26
35
  open = false,
@@ -43,10 +52,10 @@ const Snackbar = /*#__PURE__*/forwardRef(function Snackbar({
43
52
  }, autoHideDuration);
44
53
  }
45
54
  return () => clearTimeout(timer.current);
46
- }, [open, autoHideDuration, setVisible, onClose]);
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }, [open, autoHideDuration]);
47
57
  const props = {
48
58
  ref,
49
- $placement: placement,
50
59
  ...rest
51
60
  };
52
61
  const {
@@ -57,12 +66,17 @@ const Snackbar = /*#__PURE__*/forwardRef(function Snackbar({
57
66
  }, snackbar);
58
67
  return /*#__PURE__*/jsx(ThemeProvider, {
59
68
  theme: token,
60
- children: visible && /*#__PURE__*/ReactDom.createPortal( /*#__PURE__*/jsx(StyledSnackbar, {
61
- role: "alert",
62
- elevation: "overlay",
63
- ...props,
64
- children: children
65
- }), document.body)
69
+ children: visible && /*#__PURE__*/jsx(PopoverDiv, {
70
+ popover: "manual",
71
+ $placement: placement,
72
+ ref: el => el?.showPopover(),
73
+ children: /*#__PURE__*/jsx(StyledSnackbar, {
74
+ role: "alert",
75
+ elevation: "overlay",
76
+ ...props,
77
+ children: children
78
+ })
79
+ })
66
80
  });
67
81
  });
68
82
 
@@ -13,7 +13,7 @@ const StyledTabList = styled.div.attrs(() => ({
13
13
  })).withConfig({
14
14
  displayName: "TabList__StyledTabList",
15
15
  componentId: "sc-1g1p5i1-0"
16
- })(["display:grid;grid-auto-flow:column;grid-auto-columns:", ";overflow-x:", ";scroll-snap-type:x mandatory;overscroll-behavior-x:contain;@media (prefers-reduced-motion:no-preference){scroll-behavior:smooth;}@media (hover:none){overflow-x:scroll;-webkit-overflow-scrolling:touch;scrollbar-width:0;& ::-webkit-scrollbar{width:0;height:0;}}"], ({
16
+ })(["display:grid;grid-auto-flow:column;grid-auto-columns:", ";overflow-x:", ";scroll-snap-type:x mandatory;overscroll-behavior-x:contain;@media (prefers-reduced-motion:no-preference){scroll-behavior:smooth;}@media (hover:none){overflow-x:scroll;-webkit-overflow-scrolling:touch;scrollbar-width:none;& ::-webkit-scrollbar{width:0;height:0;}}"], ({
17
17
  $variant
18
18
  }) => variants[$variant], ({
19
19
  $scrollable
@@ -1,14 +1,16 @@
1
1
  import { forwardRef, useRef, useState, useMemo, useEffect, cloneElement } from 'react';
2
2
  import styled from 'styled-components';
3
- import { typographyTemplate, spacingsTemplate, bordersTemplate, mergeRefs, useIsInDialog } from '@equinor/eds-utils';
3
+ import { typographyTemplate, spacingsTemplate, bordersTemplate, mergeRefs, useIsomorphicLayoutEffect } from '@equinor/eds-utils';
4
4
  import { tooltip } from './Tooltip.tokens.js';
5
- import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useHover, useFocus, useRole, useDismiss, FloatingPortal } from '@floating-ui/react';
5
+ import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useHover, useFocus, useRole, useDismiss } from '@floating-ui/react';
6
6
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
7
 
8
- const StyledTooltip = styled.div.withConfig({
8
+ const StyledTooltip = styled('div').withConfig({
9
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
10
+ }).withConfig({
9
11
  displayName: "Tooltip__StyledTooltip",
10
12
  componentId: "sc-m2im2p-0"
11
- })(["", " ", " ", " background:", ";z-index:1500;white-space:nowrap;&::before{content:'; Has tooltip: ';clip-path:inset(50%);height:1px;width:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;}"], typographyTemplate(tooltip.typography), spacingsTemplate(tooltip.spacings), bordersTemplate(tooltip.border), tooltip.background);
13
+ })(["inset:unset;border:0;overflow:visible;", " ", " ", " background:", ";white-space:nowrap;&::before{content:'; Has tooltip: ';clip-path:inset(50%);height:1px;width:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;}&::backdrop{background-color:transparent;}"], typographyTemplate(tooltip.typography), spacingsTemplate(tooltip.spacings), bordersTemplate(tooltip.border), tooltip.background);
12
14
  const ArrowWrapper = styled.div.withConfig({
13
15
  displayName: "Tooltip__ArrowWrapper",
14
16
  componentId: "sc-m2im2p-1"
@@ -103,10 +105,13 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
103
105
  ...children.props
104
106
  })
105
107
  });
106
-
107
- //temporary fix for tooltip inside dialog. Should be replaced by popover api when it is ready
108
- const inDialog = useIsInDialog(refs.domReference.current);
108
+ useIsomorphicLayoutEffect(() => {
109
+ if (shouldOpen && open) {
110
+ refs.floating.current?.showPopover();
111
+ }
112
+ }, [open, shouldOpen, refs.floating]);
109
113
  const TooltipEl = /*#__PURE__*/jsxs(StyledTooltip, {
114
+ popover: "manual",
110
115
  ...rest,
111
116
  ...getFloatingProps({
112
117
  ref: tooltipRef,
@@ -128,12 +133,7 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
128
133
  })]
129
134
  });
130
135
  return /*#__PURE__*/jsxs(Fragment, {
131
- children: [inDialog ? /*#__PURE__*/jsx(Fragment, {
132
- children: shouldOpen && open && TooltipEl
133
- }) : /*#__PURE__*/jsx(FloatingPortal, {
134
- id: "eds-tooltip-container",
135
- children: shouldOpen && open && TooltipEl
136
- }), updatedChildren]
136
+ children: [shouldOpen && open && TooltipEl, updatedChildren]
137
137
  });
138
138
  });
139
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.40.1",
3
+ "version": "0.41.1",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -35,17 +35,17 @@
35
35
  "@rollup/plugin-babel": "^6.0.4",
36
36
  "@rollup/plugin-commonjs": "^26.0.1",
37
37
  "@rollup/plugin-node-resolve": "^15.2.3",
38
- "@storybook/addon-a11y": "^8.1.11",
39
- "@storybook/addon-actions": "^8.1.11",
40
- "@storybook/addon-docs": "^8.1.11",
41
- "@storybook/addon-essentials": "^8.1.11",
42
- "@storybook/addon-links": "^8.1.11",
43
- "@storybook/blocks": "^8.1.11",
44
- "@storybook/preview-api": "^8.1.11",
45
- "@storybook/react": "^8.1.11",
46
- "@storybook/react-vite": "^8.1.11",
47
- "@testing-library/dom": "^10.3.1",
48
- "@testing-library/jest-dom": "^6.4.6",
38
+ "@storybook/addon-a11y": "^8.2.8",
39
+ "@storybook/addon-actions": "^8.2.8",
40
+ "@storybook/addon-docs": "^8.2.8",
41
+ "@storybook/addon-essentials": "^8.2.8",
42
+ "@storybook/addon-links": "^8.2.8",
43
+ "@storybook/blocks": "^8.2.8",
44
+ "@storybook/preview-api": "^8.2.8",
45
+ "@storybook/react": "^8.2.8",
46
+ "@storybook/react-vite": "^8.2.8",
47
+ "@testing-library/dom": "^10.4.0",
48
+ "@testing-library/jest-dom": "^6.4.8",
49
49
  "@testing-library/react": "16.0.0",
50
50
  "@testing-library/user-event": "14.5.2",
51
51
  "@types/jest": "^29.5.12",
@@ -58,19 +58,19 @@
58
58
  "jest-environment-jsdom": "^29.7.0",
59
59
  "jest-styled-components": "^7.2.0",
60
60
  "js-file-download": "^0.4.12",
61
- "postcss": "^8.4.39",
61
+ "postcss": "^8.4.41",
62
62
  "ramda": "^0.30.1",
63
63
  "react": "^18.3.1",
64
64
  "react-dom": "^18.3.1",
65
- "react-hook-form": "^7.52.1",
66
- "react-router-dom": "^6.24.1",
67
- "rollup": "^4.18.1",
65
+ "react-hook-form": "^7.52.2",
66
+ "react-router-dom": "^6.26.0",
67
+ "rollup": "^4.20.0",
68
68
  "rollup-plugin-delete": "^2.0.0",
69
69
  "rollup-plugin-postcss": "^4.0.2",
70
- "storybook": "^8.1.11",
71
- "styled-components": "6.1.11",
70
+ "storybook": "^8.2.8",
71
+ "styled-components": "6.1.12",
72
72
  "tsc-watch": "^6.2.0",
73
- "typescript": "^5.5.3"
73
+ "typescript": "^5.5.4"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": ">=16.8",
@@ -78,19 +78,19 @@
78
78
  "styled-components": ">=5.1"
79
79
  },
80
80
  "dependencies": {
81
- "@babel/runtime": "^7.24.7",
82
- "@floating-ui/react": "^0.26.19",
83
- "@internationalized/date": "^3.5.4",
84
- "@react-aria/utils": "^3.24.1",
85
- "@react-stately/calendar": "^3.5.1",
86
- "@react-stately/datepicker": "^3.9.4",
87
- "@react-types/shared": "^3.23.1",
88
- "@tanstack/react-virtual": "3.8.2",
89
- "downshift": "9.0.6",
90
- "react-aria": "^3.33.1",
81
+ "@babel/runtime": "^7.25.0",
82
+ "@floating-ui/react": "^0.26.22",
83
+ "@internationalized/date": "^3.5.5",
84
+ "@react-aria/utils": "^3.25.1",
85
+ "@react-stately/calendar": "^3.5.3",
86
+ "@react-stately/datepicker": "^3.10.1",
87
+ "@react-types/shared": "^3.24.1",
88
+ "@tanstack/react-virtual": "3.8.4",
89
+ "downshift": "9.0.7",
90
+ "react-aria": "^3.34.1",
91
+ "@equinor/eds-tokens": "0.9.2",
91
92
  "@equinor/eds-icons": "^0.21.0",
92
- "@equinor/eds-utils": "0.8.5",
93
- "@equinor/eds-tokens": "0.9.2"
93
+ "@equinor/eds-utils": "0.8.5"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",