@equinor/eds-core-react 0.42.6-dev-11212024 → 0.43.0-dev-12102024

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.
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
4
  var react = require('react');
@@ -912,7 +913,8 @@ const initalState$2 = {
912
913
  const EdsContext = /*#__PURE__*/react.createContext(initalState$2);
913
914
  const EdsProvider = ({
914
915
  children,
915
- density
916
+ density,
917
+ rootElement
916
918
  }) => {
917
919
  const [state, setState] = react.useState({
918
920
  ...initalState$2,
@@ -929,6 +931,7 @@ const EdsProvider = ({
929
931
  }, [density, state.density]);
930
932
  const value = {
931
933
  density: state.density,
934
+ rootElement,
932
935
  setDensity
933
936
  };
934
937
  return /*#__PURE__*/jsxRuntime.jsx(EdsContext.Provider, {
@@ -1148,11 +1151,15 @@ const Tooltip$2 = /*#__PURE__*/react.forwardRef(function Tooltip({
1148
1151
  children,
1149
1152
  style,
1150
1153
  enterDelay = 100,
1154
+ portalContainer,
1151
1155
  ...rest
1152
1156
  }, ref) {
1153
1157
  const arrowRef = react.useRef(null);
1154
1158
  const [open, setOpen] = react.useState(false);
1155
1159
  const shouldOpen = title !== '' && typeof document !== 'undefined';
1160
+ const {
1161
+ rootElement
1162
+ } = useEds();
1156
1163
  const {
1157
1164
  x,
1158
1165
  y,
@@ -1240,6 +1247,7 @@ const Tooltip$2 = /*#__PURE__*/react.forwardRef(function Tooltip({
1240
1247
  ...rest,
1241
1248
  ...getFloatingProps({
1242
1249
  ref: tooltipRef,
1250
+ className: `eds-tooltip ${rest.className ?? ''}`,
1243
1251
  style: {
1244
1252
  ...style,
1245
1253
  position: strategy,
@@ -1258,7 +1266,7 @@ const Tooltip$2 = /*#__PURE__*/react.forwardRef(function Tooltip({
1258
1266
  })]
1259
1267
  });
1260
1268
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1261
- children: [shouldOpen && open && /*#__PURE__*/reactDom.createPortal(TooltipEl, document.body), updatedChildren]
1269
+ children: [shouldOpen && open && /*#__PURE__*/reactDom.createPortal(TooltipEl, portalContainer ?? rootElement ?? document.body), updatedChildren]
1262
1270
  });
1263
1271
  });
1264
1272
 
@@ -8,7 +8,8 @@ const initalState = {
8
8
  const EdsContext = /*#__PURE__*/createContext(initalState);
9
9
  const EdsProvider = ({
10
10
  children,
11
- density
11
+ density,
12
+ rootElement
12
13
  }) => {
13
14
  const [state, setState] = useState({
14
15
  ...initalState,
@@ -25,6 +26,7 @@ const EdsProvider = ({
25
26
  }, [density, state.density]);
26
27
  const value = {
27
28
  density: state.density,
29
+ rootElement,
28
30
  setDensity
29
31
  };
30
32
  return /*#__PURE__*/jsx(EdsContext.Provider, {
@@ -5,6 +5,7 @@ import { typographyTemplate, spacingsTemplate, bordersTemplate, mergeRefs } from
5
5
  import { tooltip } from './Tooltip.tokens.js';
6
6
  import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useHover, useFocus, useRole, useDismiss } from '@floating-ui/react';
7
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
+ import { useEds } from '../EdsProvider/eds.context.js';
8
9
 
9
10
  const StyledTooltip = styled('div').withConfig({
10
11
  shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
@@ -26,11 +27,15 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
26
27
  children,
27
28
  style,
28
29
  enterDelay = 100,
30
+ portalContainer,
29
31
  ...rest
30
32
  }, ref) {
31
33
  const arrowRef = useRef(null);
32
34
  const [open, setOpen] = useState(false);
33
35
  const shouldOpen = title !== '' && typeof document !== 'undefined';
36
+ const {
37
+ rootElement
38
+ } = useEds();
34
39
  const {
35
40
  x,
36
41
  y,
@@ -118,6 +123,7 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
118
123
  ...rest,
119
124
  ...getFloatingProps({
120
125
  ref: tooltipRef,
126
+ className: `eds-tooltip ${rest.className ?? ''}`,
121
127
  style: {
122
128
  ...style,
123
129
  position: strategy,
@@ -136,7 +142,7 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
136
142
  })]
137
143
  });
138
144
  return /*#__PURE__*/jsxs(Fragment, {
139
- children: [shouldOpen && open && /*#__PURE__*/createPortal(TooltipEl, document.body), updatedChildren]
145
+ children: [shouldOpen && open && /*#__PURE__*/createPortal(TooltipEl, portalContainer ?? rootElement ?? document.body), updatedChildren]
140
146
  });
141
147
  });
142
148
 
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  export { Button } from './components/Button/index.js';
2
3
  export { Table } from './components/Table/index.js';
3
4
  export { Icon } from './components/Icon/index.js';
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
  export type Density = 'compact' | 'comfortable';
3
3
  type State = {
4
4
  density: Density;
5
+ rootElement?: HTMLElement | null;
5
6
  };
6
7
  type UseEdsProps<T> = {
7
8
  /** Use this to update the `density` from nested components in `EdsProvider` */
@@ -9,6 +10,7 @@ type UseEdsProps<T> = {
9
10
  } & T;
10
11
  export type EdsProviderProps = {
11
12
  density?: Density;
13
+ rootElement?: HTMLElement | null;
12
14
  children: ReactNode;
13
15
  };
14
16
  export declare const EdsProvider: React.FC<EdsProviderProps>;
@@ -9,6 +9,10 @@ export type TooltipProps = {
9
9
  children: React.ReactElement & React.RefAttributes<HTMLElement>;
10
10
  /** Delay in ms, default 100 */
11
11
  enterDelay?: number;
12
+ /** Portal container
13
+ * @default document.body
14
+ * */
15
+ portalContainer?: HTMLElement;
12
16
  } & HTMLAttributes<HTMLDivElement>;
13
17
  export declare const Tooltip: import("react").ForwardRefExoticComponent<{
14
18
  /** Tooltip placement relative to anchor */
@@ -19,4 +23,8 @@ export declare const Tooltip: import("react").ForwardRefExoticComponent<{
19
23
  children: React.ReactElement & React.RefAttributes<HTMLElement>;
20
24
  /** Delay in ms, default 100 */
21
25
  enterDelay?: number;
26
+ /** Portal container
27
+ * @default document.body
28
+ * */
29
+ portalContainer?: HTMLElement;
22
30
  } & HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.42.6-dev-11212024",
3
+ "version": "0.43.0-dev-12102024",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -66,6 +66,7 @@
66
66
  "rollup": "^4.22.5",
67
67
  "rollup-plugin-delete": "^2.1.0",
68
68
  "rollup-plugin-postcss": "^4.0.2",
69
+ "rollup-preserve-directives": "^1.1.3",
69
70
  "storybook": "^8.3.4",
70
71
  "styled-components": "6.1.12",
71
72
  "tsc-watch": "^6.2.0",
@@ -84,11 +85,11 @@
84
85
  "@react-stately/calendar": "^3.5.3",
85
86
  "@react-stately/datepicker": "^3.10.1",
86
87
  "@react-types/shared": "^3.24.1",
87
- "@tanstack/react-virtual": "3.10.8",
88
+ "@tanstack/react-virtual": "3.11.1",
88
89
  "downshift": "9.0.8",
89
90
  "react-aria": "^3.34.1",
90
- "@equinor/eds-tokens": "0.9.2",
91
91
  "@equinor/eds-icons": "^0.21.0",
92
+ "@equinor/eds-tokens": "0.9.2",
92
93
  "@equinor/eds-utils": "0.8.5"
93
94
  },
94
95
  "scripts": {