@equinor/eds-core-react 2.3.1 → 2.3.2-beta.0

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.
Files changed (44) hide show
  1. package/README.md +16 -1
  2. package/build/index.css +60 -207
  3. package/build/index.min.css +3 -3
  4. package/dist/eds-core-react.cjs +49 -24
  5. package/dist/esm/components/Autocomplete/AddNewOption.js +1 -1
  6. package/dist/esm/components/Autocomplete/Autocomplete.js +1 -1
  7. package/dist/esm/components/Autocomplete/MultipleInput.js +21 -5
  8. package/dist/esm/components/Autocomplete/Option.js +11 -2
  9. package/dist/esm/components/Autocomplete/SelectAllOption.js +1 -1
  10. package/dist/esm/components/Autocomplete/useAutocomplete.js +13 -2
  11. package/dist/esm/components/Banner/Banner.tokens.js +2 -10
  12. package/dist/esm/components/Chip/Chip.js +1 -1
  13. package/dist/esm/components/Chip/Chip.tokens.js +0 -2
  14. package/dist/esm/components/Datepicker/utils/get-calendar-date.js +1 -1
  15. package/dist/esm/components/EdsProvider/eds.context.js +31 -3
  16. package/dist/esm/components/Menu/Menu.context.js +1 -1
  17. package/dist/esm/components/SideBar/SideBar.context.js +1 -1
  18. package/dist/esm/components/Typography/Typography.js +1 -1
  19. package/dist/esm/index.js +64 -64
  20. package/dist/esm-next/components/EdsProvider/eds.context.js +11 -0
  21. package/dist/esm-next/components/Tooltip/Tooltip.js +152 -0
  22. package/dist/esm-next/components/Tooltip/Tooltip.tokens.js +54 -0
  23. package/dist/esm-next/components/Typography/Typography.new.js +67 -0
  24. package/dist/{esm → esm-next}/components/next/Button/Button.js +3 -5
  25. package/dist/index.next.cjs +3 -5
  26. package/dist/types/components/Autocomplete/Autocomplete.d.ts +1 -1
  27. package/dist/types/components/Autocomplete/AutocompleteContext.d.ts +2 -2
  28. package/dist/types/components/Autocomplete/useAutocomplete.d.ts +3 -2
  29. package/dist/types/components/Datepicker/DateRangePicker.d.ts +1 -1
  30. package/dist/types/components/SideBar/SideBarButton/index.d.ts +1 -1
  31. package/dist/types/components/Typography/index.d.ts +1 -0
  32. package/package.json +41 -34
  33. package/dist/{esm → esm-next}/components/next/Checkbox/Checkbox.js +0 -0
  34. package/dist/{esm → esm-next}/components/next/Field/Field.Description.js +0 -0
  35. package/dist/{esm → esm-next}/components/next/Field/Field.HelperMessage.js +0 -0
  36. package/dist/{esm → esm-next}/components/next/Field/Field.Label.js +0 -0
  37. package/dist/{esm → esm-next}/components/next/Field/Field.js +0 -0
  38. package/dist/{esm → esm-next}/components/next/Field/useFieldIds.js +0 -0
  39. package/dist/{esm → esm-next}/components/next/Icon/Icon.js +0 -0
  40. package/dist/{esm → esm-next}/components/next/Input/Input.js +0 -0
  41. package/dist/{esm → esm-next}/components/next/Radio/Radio.js +0 -0
  42. package/dist/{esm → esm-next}/components/next/Switch/Switch.js +0 -0
  43. package/dist/{esm → esm-next}/components/next/TextField/TextField.js +0 -0
  44. package/dist/{esm → esm-next}/index.next.js +4 -4
@@ -40,7 +40,7 @@ function AddNewOption({
40
40
  ref: rowVirtualizer.measureElement
41
41
  }),
42
42
  item,
43
- index: index
43
+ index
44
44
  });
45
45
  return /*#__PURE__*/jsxs(StyledListItem, {
46
46
  $highlighted: highlighted,
@@ -1,5 +1,5 @@
1
1
  import { useFloating, offset, flip, size } from '@floating-ui/react';
2
- import styled, { css, ThemeProvider } from 'styled-components';
2
+ import styled, { ThemeProvider, css } from 'styled-components';
3
3
  import { Button } from '../Button/index.js';
4
4
  import { AutocompleteContext } from './AutocompleteContext.js';
5
5
  import { MultipleInput } from './MultipleInput.js';
@@ -4,6 +4,7 @@ import { useAutocompleteContext } from './AutocompleteContext.js';
4
4
  import { RightAdornments } from './RightAdornments.js';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
6
6
  import { Chip } from '../Chip/Chip.js';
7
+ import { useEds } from '../EdsProvider/eds.context.js';
7
8
  import { Input } from '../Input/Input.js';
8
9
 
9
10
  const UnstyledInput = styled.input.withConfig({
@@ -13,8 +14,15 @@ const UnstyledInput = styled.input.withConfig({
13
14
  const ChipContainer = styled.div.withConfig({
14
15
  displayName: "MultipleInput__ChipContainer",
15
16
  componentId: "sc-1evc1aa-1"
16
- })(["display:flex;flex-wrap:wrap;gap:0.5rem;height:100%;"]);
17
+ })(["display:flex;flex-wrap:wrap;align-items:center;align-content:center;min-height:100%;gap:", ";margin:", ";"], ({
18
+ $density
19
+ }) => $density === 'compact' ? '2px' : '0.5rem', ({
20
+ $density
21
+ }) => $density === 'compact' ? '-2px 0' : '0');
17
22
  const MultipleInput = () => {
23
+ const {
24
+ density
25
+ } = useEds();
18
26
  const {
19
27
  selectedItems,
20
28
  selectionDisplay,
@@ -49,23 +57,31 @@ const MultipleInput = () => {
49
57
  e.stopPropagation();
50
58
  handleChipRemove(item, index, false);
51
59
  };
60
+ const minHeight = density === 'compact' ? '24px' : '36px';
52
61
  return /*#__PURE__*/jsx(Input, {
53
62
  as: 'div',
54
63
  variant: variant,
55
64
  rightAdornmentsWidth: hideClearButton ? 24 + 8 : 24 * 2 + 8,
56
65
  rightAdornments: /*#__PURE__*/jsx(RightAdornments, {}),
57
66
  readOnly: readOnly,
58
- style: {
67
+ style: selectionDisplay === 'chips' ? {
59
68
  height: 'auto',
60
- minHeight: '36px'
61
- },
69
+ minHeight
70
+ } : undefined,
71
+ "data-density": density,
62
72
  children: /*#__PURE__*/jsxs(ChipContainer, {
73
+ $density: density,
63
74
  children: [selectionDisplay === 'chips' && selectedItems.map((item, index) => /*#__PURE__*/jsx(Chip, {
64
75
  ref: el => {
65
76
  if (el) chipRefs.current.set(getLabel(item), el);else chipRefs.current.delete(getLabel(item));
66
77
  },
67
78
  style: {
68
- outline: '1px solid var(--eds-color-accent-12)'
79
+ outline: '1px solid var(--eds-color-accent-12)',
80
+ ...(density === 'compact' && {
81
+ height: '16px',
82
+ fontSize: '12px',
83
+ gridGap: '0px'
84
+ })
69
85
  },
70
86
  onDelete: handleChipDelete(item, index),
71
87
  onClick: handleChipClick(item, index),
@@ -48,7 +48,9 @@ function Option({
48
48
  const isSelected = selectedItemsLabels.includes(label);
49
49
  const optionComponent = _optionComponent?.(item, isSelected);
50
50
  const highlighted = highlightedIndex === index && !isDisabled ? 'true' : 'false';
51
- const itemProps = getItemProps({
51
+
52
+ // Guard: downshift 9.x validates that item exists in the items array
53
+ const itemProps = item !== undefined ? getItemProps({
52
54
  ...(multiline && {
53
55
  ref: rowVirtualizer.measureElement
54
56
  }),
@@ -60,7 +62,14 @@ function Option({
60
62
  height: `${virtualItem.size}px`
61
63
  })
62
64
  }
63
- });
65
+ }) : {
66
+ style: {
67
+ transform: `translateY(${virtualItem.start}px)`,
68
+ ...(!multiline && {
69
+ height: `${virtualItem.size}px`
70
+ })
71
+ }
72
+ };
64
73
  return /*#__PURE__*/jsxs(StyledListItem, {
65
74
  $isdisabled: isDisabled ? 'true' : 'false',
66
75
  $highlighted: highlighted,
@@ -27,7 +27,7 @@ function SelectAllOption({
27
27
  ref: rowVirtualizer.measureElement
28
28
  }),
29
29
  item,
30
- index: index
30
+ index
31
31
  });
32
32
  return /*#__PURE__*/jsxs(StyledListItem, {
33
33
  ref: ref,
@@ -112,7 +112,13 @@ const useAutocomplete = ({
112
112
  ...multipleSelectionProps,
113
113
  onSelectedItemsChange: changes => {
114
114
  if (onOptionsChange) {
115
- let selectedItems = changes.selectedItems.filter(item => item !== AllSymbol || item !== AddSymbol);
115
+ // AddSymbol/AllSymbol are handled manually in onStateChange,
116
+ // so skip propagating when they appear in selectedItems
117
+ // (downshift 9.x propagates selectedItem to useMultipleSelection)
118
+ if (changes.selectedItems.some(item => item === AllSymbol || item === AddSymbol)) {
119
+ return;
120
+ }
121
+ let selectedItems = changes.selectedItems;
116
122
  if (itemCompare) {
117
123
  selectedItems = inputOptions.filter(item => selectedItems.some(compare => itemCompare(item, compare)));
118
124
  }
@@ -269,6 +275,9 @@ const useAutocomplete = ({
269
275
  toggleAllSelected();
270
276
  } else if (selectedItem === AddSymbol && typedInputValue.trim()) {
271
277
  onAddNewOption?.(typedInputValue);
278
+ if (clearSearchOnChange) {
279
+ setTypedInputValue('');
280
+ }
272
281
  } else if (multiple) {
273
282
  const shouldRemove = itemCompare ? selectedItems.some(i => itemCompare(selectedItem, i)) : selectedItems.includes(selectedItem);
274
283
  if (shouldRemove) {
@@ -494,7 +503,9 @@ const useAutocomplete = ({
494
503
  };
495
504
  case useCombobox.stateChangeTypes.InputKeyDownEnter:
496
505
  case useCombobox.stateChangeTypes.ItemClick:
497
- if (clearSearchOnChange) {
506
+ // Don't clear typedInputValue for AddSymbol — onStateChange needs
507
+ // it to call onAddNewOption (downshift 9.x runs onStateChange after re-render)
508
+ if (clearSearchOnChange && changes.selectedItem !== AddSymbol) {
498
509
  setTypedInputValue('');
499
510
  }
500
511
  return {
@@ -74,11 +74,7 @@ const info = {
74
74
  color: infoColor
75
75
  }
76
76
  }
77
- },
78
- modes: {
79
- compact: {}
80
- }
81
- };
77
+ }};
82
78
  const warning = {
83
79
  entities: {
84
80
  icon: {
@@ -87,10 +83,6 @@ const warning = {
87
83
  color: warningColor
88
84
  }
89
85
  }
90
- },
91
- modes: {
92
- compact: {}
93
- }
94
- };
86
+ }};
95
87
 
96
88
  export { enabled, info, warning };
@@ -85,7 +85,7 @@ const Chip = /*#__PURE__*/forwardRef(function Chip({
85
85
  };
86
86
  const resizedChildren = Children.map(children, child => {
87
87
  // We force size on Icon & Avatar component
88
- if (child.props) {
88
+ if (child?.props) {
89
89
  return /*#__PURE__*/cloneElement(child, {
90
90
  size: 16,
91
91
  disabled
@@ -107,8 +107,6 @@ const enabled = {
107
107
  },
108
108
  entities: {
109
109
  icon: {
110
- height: medium,
111
- width: medium,
112
110
  border: {
113
111
  radius: borderRadius,
114
112
  type: 'border',
@@ -1,4 +1,4 @@
1
- import { toCalendarDateTime, toCalendarDate, fromDate } from '@internationalized/date';
1
+ import { toCalendarDateTime, fromDate, toCalendarDate } from '@internationalized/date';
2
2
 
3
3
  const getCalendarDate = (value, timezone, showTimeInput = false) => {
4
4
  if (!value) return null;
@@ -1,11 +1,39 @@
1
- import { useContext, createContext } from 'react';
2
- import 'react/jsx-runtime';
1
+ import { useState, useEffect, useContext, createContext } from 'react';
2
+ import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  const initalState = {
5
5
  /** Density for all components inside `EdsProvider` */
6
6
  density: 'comfortable'
7
7
  };
8
8
  const EdsContext = /*#__PURE__*/createContext(initalState);
9
+ const EdsProvider = ({
10
+ children,
11
+ density,
12
+ rootElement
13
+ }) => {
14
+ const [state, setState] = useState({
15
+ ...initalState,
16
+ density: density || 'comfortable'
17
+ });
18
+ const setDensity = density => setState(prevState => ({
19
+ ...prevState,
20
+ density
21
+ }));
22
+ useEffect(() => {
23
+ if (typeof density !== 'undefined' && density !== state.density) {
24
+ setDensity(density);
25
+ }
26
+ }, [density, state.density]);
27
+ const value = {
28
+ density: state.density,
29
+ rootElement,
30
+ setDensity
31
+ };
32
+ return /*#__PURE__*/jsx(EdsContext.Provider, {
33
+ value: value,
34
+ children: children
35
+ });
36
+ };
9
37
  const useEds = () => useContext(EdsContext);
10
38
 
11
- export { useEds };
39
+ export { EdsProvider, useEds };
@@ -1,4 +1,4 @@
1
- import { useContext, useState, createContext } from 'react';
1
+ import { useState, useContext, createContext } from 'react';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  const initalState = {
@@ -1,4 +1,4 @@
1
- import { useContext, createContext, useState, useCallback } from 'react';
1
+ import { useContext, useState, useCallback, createContext } from 'react';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  const initalState = {
@@ -1,7 +1,7 @@
1
1
  import { forwardRef } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { typographyTemplate, outlineTemplate } from '@equinor/eds-utils';
4
- import { quickVariants, typography, colors, link } from './Typography.tokens.js';
4
+ import { quickVariants, typography, link, colors } from './Typography.tokens.js';
5
5
  import { jsx } from 'react/jsx-runtime';
6
6
 
7
7
  const getElementType = (variant, link) => {
package/dist/esm/index.js CHANGED
@@ -16,85 +16,85 @@ export { Progress } from './components/Progress/index.js';
16
16
  export { Breadcrumbs } from './components/Breadcrumbs/index.js';
17
17
  export { Menu } from './components/Menu/index.js';
18
18
  export { SideBar } from './components/SideBar/index.js';
19
- export { ButtonGroup } from './components/Button/ButtonGroup/ButtonGroup.js';
20
- export { ToggleButton } from './components/Button/ToggleButton/ToggleButton.js';
21
- export { TypographyNext } from './components/Typography/Typography.new.js';
22
- export { Heading } from './components/Typography/Heading.js';
23
- export { Paragraph } from './components/Typography/Paragraph.js';
24
- export { Typography } from './components/Typography/Typography.js';
25
- export { Body as TableBody } from './components/Table/Body.js';
26
- export { Cell as TableCell } from './components/Table/Cell.js';
27
- export { Head as TableHead } from './components/Table/Head/Head.js';
28
- export { Foot as TableFoot } from './components/Table/Foot/Foot.js';
29
- export { Row as TableRow } from './components/Table/Row/Row.js';
30
- export { Caption as TableCaption } from './components/Table/Caption.js';
31
- export { Divider } from './components/Divider/Divider.js';
32
- export { TextField } from './components/TextField/TextField.js';
33
- export { Textarea } from './components/Textarea/Textarea.js';
34
- export { ListItem } from './components/List/ListItem.js';
35
- export { AccordionItem } from './components/Accordion/AccordionItem.js';
36
19
  export { AccordionHeader } from './components/Accordion/AccordionHeader.js';
37
- export { AccordionHeaderTitle } from './components/Accordion/AccordionHeaderTitle.js';
38
20
  export { AccordionHeaderActions } from './components/Accordion/AccordionHeaderActions.js';
21
+ export { AccordionHeaderTitle } from './components/Accordion/AccordionHeaderTitle.js';
22
+ export { AccordionItem } from './components/Accordion/AccordionItem.js';
39
23
  export { AccordionPanel } from './components/Accordion/AccordionPanel.js';
40
- export { Tab } from './components/Tabs/Tab.js';
41
- export { TabPanels } from './components/Tabs/TabPanels.js';
42
- export { TabPanel } from './components/Tabs/TabPanel.js';
43
- export { TabList } from './components/Tabs/TabList.js';
24
+ export { AddSymbol, AllSymbol, Autocomplete, StyledButton, defaultOptionDisabled } from './components/Autocomplete/Autocomplete.js';
25
+ export { Avatar } from './components/Avatar/Avatar.js';
26
+ export { BannerActions } from './components/Banner/BannerActions.js';
27
+ export { BannerIcon } from './components/Banner/BannerIcon.js';
28
+ export { BannerMessage } from './components/Banner/BannerMessage.js';
29
+ export { Breadcrumb } from './components/Breadcrumbs/Breadcrumb.js';
30
+ export { ButtonGroup } from './components/Button/ButtonGroup/ButtonGroup.js';
44
31
  export { CardActions } from './components/Card/CardActions.js';
45
32
  export { CardContent } from './components/Card/CardContent.js';
46
33
  export { CardHeader } from './components/Card/CardHeader.js';
47
- export { CardMedia } from './components/Card/CardMedia.js';
48
34
  export { CardHeaderTitle } from './components/Card/CardHeaderTitle.js';
49
- export { Actions as TopbarActions } from './components/TopBar/Actions.js';
50
- export { Header as TopbarHeader } from './components/TopBar/Header.js';
51
- export { CustomContent as TopbarCustomContent } from './components/TopBar/CustomContent.js';
35
+ export { CardMedia } from './components/Card/CardMedia.js';
36
+ export { Checkbox } from './components/Checkbox/Checkbox.js';
37
+ export { Chip } from './components/Chip/Chip.js';
38
+ export { CircularProgress } from './components/Progress/Circular/CircularProgress.js';
39
+ export { DatePicker } from './components/Datepicker/DatePicker.js';
40
+ export { DateRangePicker } from './components/Datepicker/DateRangePicker.js';
52
41
  export { DialogActions } from './components/Dialog/DialogActions.js';
53
- export { DialogTitle } from './components/Dialog/DialogTitle.js';
54
42
  export { DialogContent } from './components/Dialog/DialogContent.js';
55
43
  export { DialogHeader } from './components/Dialog/DialogHeader.js';
56
- export { Scrim } from './components/Scrim/Scrim.js';
57
- export { LinkItem as TableOfContentsLinkItem } from './components/TableOfContents/LinkItem.js';
58
- export { SideSheet } from './components/SideSheet/SideSheet.js';
59
- export { Chip } from './components/Chip/Chip.js';
60
- export { Avatar } from './components/Avatar/Avatar.js';
61
- export { Search } from './components/Search/Search.js';
62
- export { Slider } from './components/Slider/Slider.js';
63
- export { Tooltip } from './components/Tooltip/Tooltip.js';
64
- export { SnackbarAction } from './components/Snackbar/SnackbarAction.js';
65
- export { PopoverTitle } from './components/Popover/PopoverTitle.js';
66
- export { PopoverContent } from './components/Popover/PopoverContent.js';
67
- export { PopoverHeader } from './components/Popover/PopoverHeader.js';
68
- export { PopoverActions } from './components/Popover/PopoverActions.js';
69
- export { BannerIcon } from './components/Banner/BannerIcon.js';
70
- export { BannerMessage } from './components/Banner/BannerMessage.js';
71
- export { BannerActions } from './components/Banner/BannerActions.js';
72
- export { LinearProgress } from './components/Progress/Linear/LinearProgress.js';
73
- export { CircularProgress } from './components/Progress/Circular/CircularProgress.js';
74
- export { StarProgress } from './components/Progress/Star/StarProgress.js';
44
+ export { DialogTitle } from './components/Dialog/DialogTitle.js';
45
+ export { Divider } from './components/Divider/Divider.js';
75
46
  export { DotProgress } from './components/Progress/Dots/DotProgress.js';
76
- export { Breadcrumb } from './components/Breadcrumbs/Breadcrumb.js';
47
+ export { EdsProvider, useEds } from './components/EdsProvider/eds.context.js';
48
+ export { Heading } from './components/Typography/Heading.js';
49
+ export { Input } from './components/Input/Input.js';
50
+ export { InputWrapper } from './components/InputWrapper/InputWrapper.js';
51
+ export { Label } from './components/Label/Label.js';
52
+ export { LinearProgress } from './components/Progress/Linear/LinearProgress.js';
53
+ export { ListItem } from './components/List/ListItem.js';
77
54
  export { MenuItem } from './components/Menu/MenuItem.js';
78
55
  export { MenuSection } from './components/Menu/MenuSection.js';
79
- export { Pagination } from './components/Pagination/Pagination.js';
80
56
  export { NativeSelect } from './components/Select/NativeSelect.js';
81
- export { Label } from './components/Label/Label.js';
82
- export { Input } from './components/Input/Input.js';
83
- export { Checkbox } from './components/Checkbox/Checkbox.js';
84
- export { Radio } from './components/Radio/Radio.js';
85
- export { Switch } from './components/Switch/Switch.js';
86
- export { EdsProvider, useEds } from './components/EdsProvider/eds.context.js';
57
+ export { Pagination } from './components/Pagination/Pagination.js';
87
58
  export { Paper } from './components/Paper/Paper.js';
88
- export { AddSymbol, AllSymbol, Autocomplete, StyledButton, defaultOptionDisabled } from './components/Autocomplete/Autocomplete.js';
89
- export { InputWrapper } from './components/InputWrapper/InputWrapper.js';
90
- export { useInputField } from './components/InputWrapper/useInputField.js';
91
- export { useSideBar } from './components/SideBar/SideBar.context.js';
92
- export { SidebarLink } from './components/SideBar/SidebarLink/index.js';
59
+ export { Paragraph } from './components/Typography/Paragraph.js';
60
+ export { PopoverActions } from './components/Popover/PopoverActions.js';
61
+ export { PopoverContent } from './components/Popover/PopoverContent.js';
62
+ export { PopoverHeader } from './components/Popover/PopoverHeader.js';
63
+ export { PopoverTitle } from './components/Popover/PopoverTitle.js';
64
+ export { Radio } from './components/Radio/Radio.js';
65
+ export { Scrim } from './components/Scrim/Scrim.js';
66
+ export { Search } from './components/Search/Search.js';
67
+ export { SideBarAccordion } from './components/SideBar/SideBarAccordion/index.js';
68
+ export { SideBarAccordionItem } from './components/SideBar/SideBarAccordionItem/index.js';
69
+ export { SideBarButton } from './components/SideBar/SideBarButton/index.js';
93
70
  export { SideBarContent } from './components/SideBar/SideBarContent.js';
94
71
  export { SideBarFooter } from './components/SideBar/SideBarFooter.js';
95
72
  export { SideBarToggle } from './components/SideBar/SideBarToggle.js';
96
- export { SideBarButton } from './components/SideBar/SideBarButton/index.js';
97
- export { SideBarAccordion } from './components/SideBar/SideBarAccordion/index.js';
98
- export { SideBarAccordionItem } from './components/SideBar/SideBarAccordionItem/index.js';
99
- export { DatePicker } from './components/Datepicker/DatePicker.js';
100
- export { DateRangePicker } from './components/Datepicker/DateRangePicker.js';
73
+ export { SideSheet } from './components/SideSheet/SideSheet.js';
74
+ export { SidebarLink } from './components/SideBar/SidebarLink/index.js';
75
+ export { Slider } from './components/Slider/Slider.js';
76
+ export { SnackbarAction } from './components/Snackbar/SnackbarAction.js';
77
+ export { StarProgress } from './components/Progress/Star/StarProgress.js';
78
+ export { Switch } from './components/Switch/Switch.js';
79
+ export { Tab } from './components/Tabs/Tab.js';
80
+ export { TabList } from './components/Tabs/TabList.js';
81
+ export { TabPanel } from './components/Tabs/TabPanel.js';
82
+ export { TabPanels } from './components/Tabs/TabPanels.js';
83
+ export { Body as TableBody } from './components/Table/Body.js';
84
+ export { Caption as TableCaption } from './components/Table/Caption.js';
85
+ export { Cell as TableCell } from './components/Table/Cell.js';
86
+ export { Foot as TableFoot } from './components/Table/Foot/Foot.js';
87
+ export { Head as TableHead } from './components/Table/Head/Head.js';
88
+ export { LinkItem as TableOfContentsLinkItem } from './components/TableOfContents/LinkItem.js';
89
+ export { Row as TableRow } from './components/Table/Row/Row.js';
90
+ export { TextField } from './components/TextField/TextField.js';
91
+ export { Textarea } from './components/Textarea/Textarea.js';
92
+ export { ToggleButton } from './components/Button/ToggleButton/ToggleButton.js';
93
+ export { Tooltip } from './components/Tooltip/Tooltip.js';
94
+ export { Actions as TopbarActions } from './components/TopBar/Actions.js';
95
+ export { CustomContent as TopbarCustomContent } from './components/TopBar/CustomContent.js';
96
+ export { Header as TopbarHeader } from './components/TopBar/Header.js';
97
+ export { Typography } from './components/Typography/Typography.js';
98
+ export { TypographyNext } from './components/Typography/Typography.new.js';
99
+ export { useInputField } from './components/InputWrapper/useInputField.js';
100
+ export { useSideBar } from './components/SideBar/SideBar.context.js';
@@ -0,0 +1,11 @@
1
+ import { useContext, createContext } from 'react';
2
+ import 'react/jsx-runtime';
3
+
4
+ const initalState = {
5
+ /** Density for all components inside `EdsProvider` */
6
+ density: 'comfortable'
7
+ };
8
+ const EdsContext = /*#__PURE__*/createContext(initalState);
9
+ const useEds = () => useContext(EdsContext);
10
+
11
+ export { useEds };
@@ -0,0 +1,152 @@
1
+ import { forwardRef, useRef, useState, useMemo, useEffect, cloneElement } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import styled from 'styled-components';
4
+ import { mergeRefs, typographyTemplate, spacingsTemplate, bordersTemplate } from '@equinor/eds-utils';
5
+ import { tooltip } from './Tooltip.tokens.js';
6
+ import { useFloating, autoUpdate, offset, flip, shift, arrow, useInteractions, useHover, useFocus, useRole, useDismiss } from '@floating-ui/react';
7
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
+ import { useEds } from '../EdsProvider/eds.context.js';
9
+
10
+ const StyledTooltip = styled('div').withConfig({
11
+ shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
12
+ }).withConfig({
13
+ displayName: "Tooltip__StyledTooltip",
14
+ componentId: "sc-m2im2p-0"
15
+ })(["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);
16
+ const ArrowWrapper = styled.div.withConfig({
17
+ displayName: "Tooltip__ArrowWrapper",
18
+ componentId: "sc-m2im2p-1"
19
+ })(["position:absolute;width:", ";height:", ";z-index:-1;"], tooltip.entities.arrow.width, tooltip.entities.arrow.height);
20
+ const TooltipArrow = styled.svg.withConfig({
21
+ displayName: "Tooltip__TooltipArrow",
22
+ componentId: "sc-m2im2p-2"
23
+ })(["width:", ";height:", ";position:absolute;fill:", ";"], tooltip.entities.arrow.width, tooltip.entities.arrow.height, tooltip.background);
24
+ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
25
+ title,
26
+ placement = 'bottom',
27
+ children,
28
+ style,
29
+ enterDelay = 100,
30
+ disabled = false,
31
+ portalContainer,
32
+ ...rest
33
+ }, ref) {
34
+ const arrowRef = useRef(null);
35
+ const [open, setOpen] = useState(false);
36
+ const {
37
+ rootElement
38
+ } = useEds();
39
+ const shouldOpen = Boolean(title) && typeof document !== 'undefined';
40
+ const {
41
+ x,
42
+ y,
43
+ refs,
44
+ strategy,
45
+ context,
46
+ middlewareData: {
47
+ arrow: {
48
+ x: arrowX,
49
+ y: arrowY
50
+ } = {}
51
+ },
52
+ placement: finalPlacement,
53
+ elements
54
+ } = useFloating({
55
+ placement,
56
+ open,
57
+ onOpenChange: setOpen,
58
+ middleware: [offset(14), flip(), shift({
59
+ padding: 8
60
+ }), arrow({
61
+ element: arrowRef
62
+ })],
63
+ whileElementsMounted: autoUpdate
64
+ });
65
+ const mergedAnchorRef = useMemo(() => mergeRefs(refs.setReference), [refs.setReference]);
66
+ const tooltipRef = useMemo(() => mergeRefs(refs.setFloating, ref), [refs.setFloating, ref]);
67
+ const {
68
+ getReferenceProps,
69
+ getFloatingProps
70
+ } = useInteractions([useHover(context, {
71
+ delay: {
72
+ open: enterDelay
73
+ }
74
+ }), useFocus(context), useRole(context, {
75
+ role: 'tooltip'
76
+ }), useDismiss(context)]);
77
+ useEffect(() => {
78
+ const staticSide = {
79
+ top: 'bottom',
80
+ right: 'left',
81
+ bottom: 'top',
82
+ left: 'right'
83
+ }[finalPlacement.split('-')[0]];
84
+ let arrowTransform = 'none';
85
+ switch (staticSide) {
86
+ case 'right':
87
+ arrowTransform = 'rotateY(180deg)';
88
+ break;
89
+ case 'left':
90
+ arrowTransform = 'none';
91
+ break;
92
+ case 'top':
93
+ arrowTransform = 'rotate(90deg)';
94
+ break;
95
+ case 'bottom':
96
+ arrowTransform = 'rotate(-90deg)';
97
+ break;
98
+ }
99
+ if (arrowRef.current) {
100
+ Object.assign(arrowRef.current.style, {
101
+ left: arrowX != null ? `${arrowX}px` : '',
102
+ top: arrowY != null ? `${arrowY}px` : '',
103
+ right: '',
104
+ bottom: '',
105
+ [staticSide]: '-6px',
106
+ transform: arrowTransform
107
+ });
108
+ }
109
+ });
110
+ const updatedChildren = /*#__PURE__*/cloneElement(children,
111
+ // eslint-disable-line @typescript-eslint/no-explicit-any
112
+ {
113
+ ...getReferenceProps(children.props),
114
+ ref: mergeRefs(
115
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
116
+ children.props.ref, mergedAnchorRef)
117
+ });
118
+ useEffect(() => {
119
+ if (!elements.floating) return;
120
+ if (elements.floating.isConnected && shouldOpen && open) {
121
+ elements.floating.showPopover();
122
+ }
123
+ }, [open, shouldOpen, elements.floating]);
124
+ const TooltipEl = /*#__PURE__*/jsxs(StyledTooltip, {
125
+ popover: "manual",
126
+ ...rest,
127
+ ...getFloatingProps({
128
+ ref: tooltipRef,
129
+ className: `eds-tooltip ${rest.className ?? ''}`,
130
+ style: {
131
+ ...style,
132
+ position: strategy,
133
+ top: y || 0,
134
+ left: x || 0
135
+ }
136
+ }),
137
+ children: [title, /*#__PURE__*/jsx(ArrowWrapper, {
138
+ ref: arrowRef,
139
+ children: /*#__PURE__*/jsx(TooltipArrow, {
140
+ className: "arrowSvg",
141
+ children: /*#__PURE__*/jsx("path", {
142
+ d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
143
+ })
144
+ })
145
+ })]
146
+ });
147
+ return /*#__PURE__*/jsxs(Fragment, {
148
+ children: [updatedChildren, shouldOpen && open && !disabled && /*#__PURE__*/createPortal(TooltipEl, portalContainer ?? rootElement ?? document.body)]
149
+ });
150
+ });
151
+
152
+ export { Tooltip };
@@ -0,0 +1,54 @@
1
+ import { tokens } from '@equinor/eds-tokens';
2
+
3
+ const {
4
+ colors: {
5
+ text: {
6
+ static_icons__primary_white: {
7
+ rgba: white
8
+ }
9
+ },
10
+ ui: {
11
+ background__overlay: {
12
+ rgba: background
13
+ }
14
+ }
15
+ },
16
+ typography: {
17
+ ui
18
+ },
19
+ spacings: {
20
+ comfortable: {
21
+ x_large: spacingXlarge,
22
+ small: spacingSmall
23
+ }
24
+ },
25
+ shape: {
26
+ corners: {
27
+ borderRadius
28
+ }
29
+ }
30
+ } = tokens;
31
+ const tooltip = {
32
+ typography: {
33
+ ...ui.tooltip,
34
+ color: white
35
+ },
36
+ background,
37
+ border: {
38
+ type: 'border',
39
+ radius: borderRadius
40
+ },
41
+ entities: {
42
+ arrow: {
43
+ width: '6px',
44
+ height: spacingSmall}
45
+ },
46
+ spacings: {
47
+ left: spacingSmall,
48
+ right: spacingSmall,
49
+ top: spacingSmall,
50
+ bottom: spacingSmall
51
+ }
52
+ };
53
+
54
+ export { tooltip };