@equinor/eds-core-react 0.18.0-envis.2 → 0.19.0-dev.20220405

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 (193) hide show
  1. package/dist/eds-core-react.cjs.js +2276 -1930
  2. package/dist/esm/components/Accordion/Accordion.js +9 -9
  3. package/dist/esm/components/Accordion/Accordion.tokens.js +6 -1
  4. package/dist/esm/components/Accordion/AccordionHeader.js +61 -49
  5. package/dist/esm/components/Accordion/AccordionHeaderTitle.js +12 -10
  6. package/dist/esm/components/Accordion/AccordionItem.js +11 -10
  7. package/dist/esm/components/Accordion/AccordionPanel.js +22 -18
  8. package/dist/esm/components/Avatar/Avatar.js +21 -14
  9. package/dist/esm/components/Banner/Banner.js +12 -11
  10. package/dist/esm/components/Banner/BannerActions.js +11 -9
  11. package/dist/esm/components/Banner/BannerIcon.js +12 -10
  12. package/dist/esm/components/Banner/BannerMessage.js +5 -4
  13. package/dist/esm/components/Breadcrumbs/Breadcrumb.js +16 -12
  14. package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +7 -6
  15. package/dist/esm/components/Button/Button.js +16 -17
  16. package/dist/esm/components/Button/InnerFullWidth.js +4 -3
  17. package/dist/esm/components/Button/tokens/button.js +1 -1
  18. package/dist/esm/components/Button/tokens/contained.js +5 -5
  19. package/dist/esm/components/Button/tokens/ghost.js +4 -4
  20. package/dist/esm/components/Button/tokens/icon.js +11 -6
  21. package/dist/esm/components/Button/tokens/outlined.js +5 -5
  22. package/dist/esm/components/Card/Card.js +19 -12
  23. package/dist/esm/components/Card/CardActions.js +13 -9
  24. package/dist/esm/components/Card/CardContent.js +5 -4
  25. package/dist/esm/components/Card/CardHeader.js +5 -4
  26. package/dist/esm/components/Card/CardHeaderTitle.js +5 -4
  27. package/dist/esm/components/Card/CardMedia.js +12 -8
  28. package/dist/esm/components/Checkbox/Checkbox.js +15 -11
  29. package/dist/esm/components/Checkbox/Checkbox.tokens.js +9 -4
  30. package/dist/esm/components/Checkbox/Input.js +72 -46
  31. package/dist/esm/components/Chip/Chip.js +46 -30
  32. package/dist/esm/components/Chip/Chip.tokens.js +7 -2
  33. package/dist/esm/components/Chip/Icon.js +12 -7
  34. package/dist/esm/components/Dialog/Dialog.js +44 -20
  35. package/dist/esm/components/Dialog/Dialog.tokens.js +4 -12
  36. package/dist/esm/components/Dialog/DialogActions.js +27 -0
  37. package/dist/esm/components/Dialog/DialogContent.js +44 -0
  38. package/dist/esm/components/Dialog/DialogHeader.js +37 -0
  39. package/dist/esm/components/Dialog/DialogTitle.js +31 -0
  40. package/dist/esm/components/Dialog/index.js +11 -7
  41. package/dist/esm/components/Divider/Divider.js +6 -5
  42. package/dist/esm/components/EdsProvider/eds.context.js +5 -4
  43. package/dist/esm/components/Icon/Icon.js +77 -46
  44. package/dist/esm/components/Input/Input.js +12 -12
  45. package/dist/esm/components/Input/Input.tokens.js +4 -4
  46. package/dist/esm/components/Label/Label.js +7 -4
  47. package/dist/esm/components/List/List.js +13 -9
  48. package/dist/esm/components/List/ListItem.js +5 -4
  49. package/dist/esm/components/Menu/Menu.context.js +16 -4
  50. package/dist/esm/components/Menu/Menu.js +71 -30
  51. package/dist/esm/components/Menu/MenuItem.js +38 -25
  52. package/dist/esm/components/Menu/MenuList.js +18 -11
  53. package/dist/esm/components/Menu/MenuSection.js +1 -1
  54. package/dist/esm/components/Pagination/Pagination.js +16 -12
  55. package/dist/esm/components/Pagination/PaginationItem.js +7 -6
  56. package/dist/esm/components/Paper/Paper.js +11 -7
  57. package/dist/esm/components/Popover/Popover.js +43 -50
  58. package/dist/esm/components/Popover/Popover.tokens.js +2 -12
  59. package/dist/esm/components/Popover/PopoverActions.js +28 -0
  60. package/dist/esm/components/Popover/PopoverContent.js +12 -6
  61. package/dist/esm/components/Popover/PopoverHeader.js +36 -0
  62. package/dist/esm/components/Popover/PopoverTitle.js +13 -24
  63. package/dist/esm/components/Popover/index.js +6 -0
  64. package/dist/esm/components/Progress/Circular/CircularProgress.js +14 -10
  65. package/dist/esm/components/Progress/Dots/DotProgress.js +12 -8
  66. package/dist/esm/components/Progress/Linear/LinearProgress.js +6 -5
  67. package/dist/esm/components/Progress/Star/StarProgress.js +14 -10
  68. package/dist/esm/components/Radio/Radio.js +84 -52
  69. package/dist/esm/components/Radio/Radio.tokens.js +9 -4
  70. package/dist/esm/components/Scrim/Scrim.js +16 -20
  71. package/dist/esm/components/Search/Search.js +28 -28
  72. package/dist/esm/components/Select/MultiSelect/MultiSelect.js +27 -22
  73. package/dist/esm/components/Select/NativeSelect/NativeSelect.js +19 -17
  74. package/dist/esm/components/Select/Select.tokens.js +2 -2
  75. package/dist/esm/components/Select/SingleSelect/SingleSelect.js +29 -23
  76. package/dist/esm/components/Select/commonStyles.js +14 -13
  77. package/dist/esm/components/SideSheet/SideSheet.js +16 -13
  78. package/dist/esm/components/Slider/MinMax.js +5 -4
  79. package/dist/esm/components/Slider/Output.js +13 -9
  80. package/dist/esm/components/Slider/Slider.js +81 -38
  81. package/dist/esm/components/Slider/Slider.tokens.js +7 -2
  82. package/dist/esm/components/Slider/SliderInput.js +14 -14
  83. package/dist/esm/components/Snackbar/Snackbar.js +17 -21
  84. package/dist/esm/components/Snackbar/SnackbarAction.js +9 -7
  85. package/dist/esm/components/Switch/Switch.js +21 -15
  86. package/dist/esm/components/Switch/Switch.styles.js +24 -17
  87. package/dist/esm/components/Switch/Switch.tokens.js +6 -1
  88. package/dist/esm/components/Switch/SwitchDefault.js +39 -29
  89. package/dist/esm/components/Switch/SwitchSmall.js +38 -28
  90. package/dist/esm/components/Table/Body.js +5 -4
  91. package/dist/esm/components/Table/Caption.js +8 -5
  92. package/dist/esm/components/Table/Cell.js +9 -6
  93. package/dist/esm/components/Table/DataCell/DataCell.js +12 -12
  94. package/dist/esm/components/Table/DataCell/DataCell.tokens.js +2 -2
  95. package/dist/esm/components/Table/Head/Head.js +7 -6
  96. package/dist/esm/components/Table/HeaderCell/HeaderCell.js +7 -8
  97. package/dist/esm/components/Table/Row/Row.js +7 -5
  98. package/dist/esm/components/Table/Table.js +5 -4
  99. package/dist/esm/components/TableOfContents/LinkItem.js +10 -10
  100. package/dist/esm/components/TableOfContents/TableOfContents.js +17 -15
  101. package/dist/esm/components/Tabs/Tab.js +21 -19
  102. package/dist/esm/components/Tabs/TabList.js +27 -11
  103. package/dist/esm/components/Tabs/TabPanel.js +8 -7
  104. package/dist/esm/components/Tabs/TabPanels.js +5 -4
  105. package/dist/esm/components/Tabs/Tabs.context.js +1 -0
  106. package/dist/esm/components/Tabs/Tabs.js +45 -15
  107. package/dist/esm/components/Tabs/Tabs.tokens.js +8 -2
  108. package/dist/esm/components/TextField/Field.js +49 -38
  109. package/dist/esm/components/TextField/HelperText/HelperText.js +28 -19
  110. package/dist/esm/components/TextField/Icon/Icon.js +20 -18
  111. package/dist/esm/components/TextField/TextField.context.js +4 -3
  112. package/dist/esm/components/TextField/TextField.js +19 -19
  113. package/dist/esm/components/Textarea/Textarea.js +16 -16
  114. package/dist/esm/components/Tooltip/Tooltip.js +23 -24
  115. package/dist/esm/components/TopBar/Actions.js +5 -4
  116. package/dist/esm/components/TopBar/CustomContent.js +5 -4
  117. package/dist/esm/components/TopBar/Header.js +5 -4
  118. package/dist/esm/components/TopBar/TopBar.js +11 -11
  119. package/dist/esm/components/Typography/Typography.js +49 -28
  120. package/dist/esm/components/Typography/Typography.tokens.js +7 -2
  121. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry1.js +1 -1
  122. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry2.js +1 -1
  123. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry3.js +1 -1
  124. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_has.js +1 -1
  125. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_isObject.js +1 -1
  126. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_isPlaceholder.js +1 -1
  127. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeDeepRight.js +2 -1
  128. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeDeepWithKey.js +1 -1
  129. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeWithKey.js +1 -1
  130. package/dist/types/components/Accordion/AccordionHeader.d.ts +2 -2
  131. package/dist/types/components/Checkbox/Checkbox.d.ts +1 -1
  132. package/dist/types/components/Checkbox/Input.d.ts +1 -1
  133. package/dist/types/components/Dialog/Dialog.d.ts +18 -2
  134. package/dist/types/components/Dialog/DialogActions.d.ts +3 -0
  135. package/dist/types/components/Dialog/{CustomContent.d.ts → DialogContent.d.ts} +2 -2
  136. package/dist/types/components/Dialog/DialogHeader.d.ts +3 -0
  137. package/dist/types/components/Dialog/DialogTitle.d.ts +3 -0
  138. package/dist/types/components/Dialog/index.d.ts +10 -7
  139. package/dist/types/components/Icon/Icon.d.ts +2 -2
  140. package/dist/types/components/Menu/Menu.context.d.ts +3 -0
  141. package/dist/types/components/Menu/Menu.d.ts +1 -6
  142. package/dist/types/components/Menu/MenuList.d.ts +0 -2
  143. package/dist/types/components/Popover/Popover.d.ts +1 -1
  144. package/dist/types/components/Popover/PopoverActions.d.ts +3 -0
  145. package/dist/types/components/Popover/PopoverHeader.d.ts +3 -0
  146. package/dist/types/components/Popover/index.d.ts +5 -1
  147. package/dist/types/components/Progress/Circular/CircularProgress.d.ts +1 -1
  148. package/dist/types/components/Progress/Dots/DotProgress.d.ts +1 -1
  149. package/dist/types/components/Progress/Star/StarProgress.d.ts +1 -1
  150. package/dist/types/components/Switch/Switch.d.ts +1 -1
  151. package/dist/types/components/Switch/Switch.styles.d.ts +2 -1
  152. package/dist/types/components/Tabs/TabList.d.ts +4 -0
  153. package/dist/types/components/Tabs/Tabs.context.d.ts +1 -0
  154. package/dist/types/components/Tabs/Tabs.d.ts +4 -0
  155. package/dist/types/components/Tooltip/Tooltip.d.ts +1 -1
  156. package/package.json +37 -38
  157. package/dist/esm/components/Dialog/Actions.js +0 -26
  158. package/dist/esm/components/Dialog/CustomContent.js +0 -46
  159. package/dist/esm/components/Dialog/Title.js +0 -41
  160. package/dist/esm/hooks/useAutoResize.js +0 -39
  161. package/dist/esm/hooks/useCombinedRefs.js +0 -14
  162. package/dist/esm/hooks/useGlobalKeyPress.js +0 -34
  163. package/dist/esm/hooks/useHideBodyScroll.js +0 -20
  164. package/dist/esm/hooks/useId.js +0 -14
  165. package/dist/esm/hooks/useMountedRef.js +0 -12
  166. package/dist/esm/hooks/useOutsideClick.js +0 -18
  167. package/dist/esm/hooks/usePopper.js +0 -31
  168. package/dist/esm/hooks/useToken.js +0 -16
  169. package/dist/esm/utils/joinHandlers.js +0 -10
  170. package/dist/esm/utils/setReactInputValue.js +0 -18
  171. package/dist/esm/utils/templates/borders.js +0 -35
  172. package/dist/esm/utils/templates/common.js +0 -19
  173. package/dist/esm/utils/templates/focus.js +0 -35
  174. package/dist/esm/utils/templates/index.js +0 -52
  175. package/dist/types/components/Dialog/Actions.d.ts +0 -3
  176. package/dist/types/components/Dialog/Title.d.ts +0 -3
  177. package/dist/types/hooks/index.d.ts +0 -9
  178. package/dist/types/hooks/useAutoResize.d.ts +0 -1
  179. package/dist/types/hooks/useCombinedRefs.d.ts +0 -3
  180. package/dist/types/hooks/useGlobalKeyPress.d.ts +0 -10
  181. package/dist/types/hooks/useHideBodyScroll.d.ts +0 -1
  182. package/dist/types/hooks/useId.d.ts +0 -1
  183. package/dist/types/hooks/useMountedRef.d.ts +0 -1
  184. package/dist/types/hooks/useOutsideClick.d.ts +0 -1
  185. package/dist/types/hooks/usePopper.d.ts +0 -12
  186. package/dist/types/hooks/useToken.d.ts +0 -7
  187. package/dist/types/utils/index.d.ts +0 -4
  188. package/dist/types/utils/joinHandlers.d.ts +0 -3
  189. package/dist/types/utils/setReactInputValue.d.ts +0 -7
  190. package/dist/types/utils/templates/borders.d.ts +0 -2
  191. package/dist/types/utils/templates/common.d.ts +0 -9
  192. package/dist/types/utils/templates/focus.d.ts +0 -2
  193. package/dist/types/utils/templates/index.d.ts +0 -7
@@ -1,8 +1,8 @@
1
1
  import { forwardRef } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { list } from './List.tokens.js';
4
+ import { typographyTemplate } from '@equinor/eds-utils';
4
5
  import { jsx } from 'react/jsx-runtime';
5
- import { typographyTemplate } from '../../utils/templates/index.js';
6
6
 
7
7
  const {
8
8
  typography
@@ -10,14 +10,18 @@ const {
10
10
  const StyledList = styled.ul.withConfig({
11
11
  displayName: "List__StyledList",
12
12
  componentId: "sc-v9d2hy-0"
13
- })(["", " ", ""], ({
14
- as
15
- }) => as === 'ol' ? css(["& ol{list-style-type:lower-alpha;}"]) : '', typographyTemplate(typography));
16
- const List = /*#__PURE__*/forwardRef(function List({
17
- children,
18
- variant = 'bullet',
19
- ...props
20
- }, ref) {
13
+ })(["", " ", ""], _ref => {
14
+ let {
15
+ as
16
+ } = _ref;
17
+ return as === 'ol' ? css(["& ol{list-style-type:lower-alpha;}"]) : '';
18
+ }, typographyTemplate(typography));
19
+ const List = /*#__PURE__*/forwardRef(function List(_ref2, ref) {
20
+ let {
21
+ children,
22
+ variant = 'bullet',
23
+ ...props
24
+ } = _ref2;
21
25
  const as = variant === 'numbered' ? 'ol' : 'ul';
22
26
  return /*#__PURE__*/jsx(StyledList, {
23
27
  as: as,
@@ -1,10 +1,11 @@
1
1
  import { forwardRef } from 'react';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
- const ListItem = /*#__PURE__*/forwardRef(function ListItem({
5
- children,
6
- ...props
7
- }, ref) {
4
+ const ListItem = /*#__PURE__*/forwardRef(function ListItem(_ref, ref) {
5
+ let {
6
+ children,
7
+ ...props
8
+ } = _ref;
8
9
  return /*#__PURE__*/jsx("li", { ...props,
9
10
  ref: ref,
10
11
  children: children
@@ -3,15 +3,18 @@ import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  const initalState = {
5
5
  focusedIndex: -1,
6
+ initialFocus: null,
6
7
  onClose: null
7
8
  };
8
9
  const MenuContext = /*#__PURE__*/createContext(initalState);
9
- const MenuProvider = ({
10
- children
11
- }) => {
10
+ const MenuProvider = _ref => {
11
+ let {
12
+ children
13
+ } = _ref;
12
14
  const [state, setState] = useState(initalState);
13
15
  const {
14
16
  focusedIndex,
17
+ initialFocus,
15
18
  onClose
16
19
  } = state;
17
20
 
@@ -21,10 +24,17 @@ const MenuProvider = ({
21
24
  }));
22
25
  };
23
26
 
27
+ const setInitialFocus = initialFocus => {
28
+ setState(prevState => ({ ...prevState,
29
+ initialFocus: initialFocus
30
+ }));
31
+ };
32
+
24
33
  const setOnClose = onClose => {
25
34
  const onCloseHelper = () => {
26
- onClose();
27
35
  setFocusedIndex(-1);
36
+ setInitialFocus(null);
37
+ onClose();
28
38
  };
29
39
 
30
40
  setState(prevState => ({ ...prevState,
@@ -35,6 +45,8 @@ const MenuProvider = ({
35
45
  const value = {
36
46
  setFocusedIndex,
37
47
  focusedIndex,
48
+ setInitialFocus,
49
+ initialFocus,
38
50
  setOnClose,
39
51
  onClose
40
52
  };
@@ -3,16 +3,11 @@ import * as ReactDom from 'react-dom';
3
3
  import styled, { css, ThemeProvider } from 'styled-components';
4
4
  import { MenuProvider, useMenu } from './Menu.context.js';
5
5
  import { MenuList } from './MenuList.js';
6
+ import { bordersTemplate, useIsMounted, useToken, usePopper, useOutsideClick, useGlobalKeyPress } from '@equinor/eds-utils';
6
7
  import { menu } from './Menu.tokens.js';
7
8
  import { jsx, Fragment } from 'react/jsx-runtime';
8
- import { useIsMounted } from '../../hooks/useMountedRef.js';
9
- import { useOutsideClick } from '../../hooks/useOutsideClick.js';
10
- import { useGlobalKeyPress } from '../../hooks/useGlobalKeyPress.js';
11
9
  import { Paper } from '../Paper/Paper.js';
12
- import { bordersTemplate } from '../../utils/templates/borders.js';
13
10
  import { useEds } from '../EdsProvider/eds.context.js';
14
- import { useToken } from '../../hooks/useToken.js';
15
- import { usePopper } from '../../hooks/usePopper.js';
16
11
 
17
12
  const {
18
13
  border
@@ -20,28 +15,64 @@ const {
20
15
  const MenuPaper = styled(Paper).withConfig({
21
16
  displayName: "Menu__MenuPaper",
22
17
  componentId: "sc-1vlnqcj-0"
23
- })(["position:absolute;z-index:300;width:fit-content;min-width:fit-content;", ";", ""], bordersTemplate(border), ({
24
- open
25
- }) => css({
26
- visibility: open ? null : 'hidden'
27
- }));
28
- const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
29
- children,
30
- anchorEl,
31
- onClose: onCloseCallback,
32
- open,
33
- containerEl,
34
- ...rest
35
- }, ref) {
18
+ })(["position:absolute;z-index:1400;width:fit-content;min-width:fit-content;", ";", ""], bordersTemplate(border), _ref => {
19
+ let {
20
+ open
21
+ } = _ref;
22
+ return css({
23
+ visibility: open ? null : 'hidden'
24
+ });
25
+ });
26
+ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer(_ref2, ref) {
27
+ let {
28
+ children,
29
+ anchorEl,
30
+ onClose: onCloseCallback,
31
+ open,
32
+ containerEl,
33
+ ...rest
34
+ } = _ref2;
36
35
  const {
37
36
  setOnClose,
38
- onClose
37
+ onClose,
38
+ setInitialFocus
39
39
  } = useMenu();
40
40
  useEffect(() => {
41
41
  if (onClose === null && onCloseCallback) {
42
42
  setOnClose(onCloseCallback);
43
43
  }
44
44
  }, [onClose, onCloseCallback, setOnClose]);
45
+ useEffect(() => {
46
+ const openWithKey = e => {
47
+ const {
48
+ key
49
+ } = e; //activate menu with arrows according to wai-aria best practices
50
+
51
+ if (key === 'ArrowDown' || key === 'ArrowUp') {
52
+ e.preventDefault();
53
+ e.stopPropagation();
54
+ anchorEl.dispatchEvent(new Event('click', {
55
+ bubbles: true
56
+ }));
57
+ }
58
+
59
+ switch (key) {
60
+ case 'Enter':
61
+ case 'ArrowDown':
62
+ setInitialFocus('first');
63
+ break;
64
+
65
+ case 'ArrowUp':
66
+ setInitialFocus('last');
67
+ break;
68
+ }
69
+ };
70
+
71
+ if (anchorEl) anchorEl.addEventListener('keydown', openWithKey);
72
+ return () => {
73
+ if (anchorEl) anchorEl.removeEventListener('keydown', openWithKey);
74
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
75
+ }, [anchorEl]);
45
76
  useOutsideClick(containerEl, e => {
46
77
  if (open && onClose !== null && !anchorEl.contains(e.target)) {
47
78
  onClose();
@@ -55,7 +86,11 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
55
86
  });
56
87
  useGlobalKeyPress('Enter', () => {
57
88
  if (open && onClose !== null) {
58
- if (window.document.contains(anchorEl)) anchorEl.focus();
89
+ setTimeout(() => {
90
+ if (window.document.contains(anchorEl)) {
91
+ anchorEl.focus();
92
+ }
93
+ }, 0);
59
94
  }
60
95
  });
61
96
  return /*#__PURE__*/jsx(MenuList, { ...rest,
@@ -63,14 +98,15 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
63
98
  children: children
64
99
  });
65
100
  });
66
- const Menu = /*#__PURE__*/forwardRef(function Menu({
67
- anchorEl,
68
- open,
69
- placement = 'auto',
70
- style,
71
- className,
72
- ...rest
73
- }, ref) {
101
+ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref3, ref) {
102
+ let {
103
+ anchorEl,
104
+ open,
105
+ placement = 'auto',
106
+ style,
107
+ className,
108
+ ...rest
109
+ } = _ref3;
74
110
  const [containerEl, setContainerEl] = useState(null);
75
111
  const [storedAnchorEl, setStoredAnchorEl] = useState(null);
76
112
  const isMounted = useIsMounted();
@@ -87,7 +123,12 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
87
123
  const {
88
124
  styles,
89
125
  attributes
90
- } = usePopper(storedAnchorEl, containerEl, null, placement, 4);
126
+ } = usePopper({
127
+ anchorEl: storedAnchorEl,
128
+ popperEl: containerEl,
129
+ placement,
130
+ offset: 4
131
+ });
91
132
  const props = {
92
133
  open,
93
134
  style: { ...styles.popper,
@@ -1,11 +1,9 @@
1
1
  import { memo, forwardRef } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { menu } from './Menu.tokens.js';
4
+ import { typographyTemplate, spacingsTemplate, outlineTemplate, useCombinedRefs } from '@equinor/eds-utils';
4
5
  import { useMenu } from './Menu.context.js';
5
6
  import { jsx } from 'react/jsx-runtime';
6
- import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
7
- import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
8
- import { outlineTemplate } from '../../utils/templates/focus.js';
9
7
 
10
8
  const {
11
9
  typography,
@@ -21,32 +19,45 @@ const {
21
19
  icon
22
20
  }
23
21
  } = menu;
24
- const Item = styled.button.attrs(({
25
- isFocused
26
- }) => ({
27
- role: 'menuitem',
28
- tabIndex: isFocused ? -1 : 0
29
- })).withConfig({
22
+ const Item = styled.button.attrs(_ref => {
23
+ let {
24
+ isFocused
25
+ } = _ref;
26
+ return {
27
+ role: 'menuitem',
28
+ tabIndex: isFocused ? -1 : 0
29
+ };
30
+ }).withConfig({
30
31
  displayName: "MenuItem__Item",
31
32
  componentId: "sc-1g9fpbe-0"
32
- })(["border:0;background-color:transparent;width:auto;position:relative;z-index:2;", " ", " ", " ", ""], typographyTemplate(typography), ({
33
- theme
34
- }) => spacingsTemplate(theme.entities.item.spacings), ({
35
- active
36
- }) => active && css(["background:", ";*{color:", ";}"], activeToken.background, activeToken.typography.color), ({
37
- disabled
38
- }) => disabled ? css(["*{color:", ";}svg{fill:", ";}&:focus{outline:none;}@media (hover:hover) and (pointer:fine){&:hover{cursor:not-allowed;}}"], disabledToken.typography.color, icon.states.disabled.typography.color) : css(["@media (hover:hover) and (pointer:fine){&:hover{z-index:1;cursor:pointer;background:", ";}}&:focus{z-index:3;", "}"], hover.background, outlineTemplate(focus.outline)));
33
+ })(["border:0;background-color:transparent;width:auto;position:relative;z-index:2;", " ", " ", " ", ""], typographyTemplate(typography), _ref2 => {
34
+ let {
35
+ theme
36
+ } = _ref2;
37
+ return spacingsTemplate(theme.entities.item.spacings);
38
+ }, _ref3 => {
39
+ let {
40
+ active
41
+ } = _ref3;
42
+ return active && css(["background:", ";*{color:", ";}"], activeToken.background, activeToken.typography.color);
43
+ }, _ref4 => {
44
+ let {
45
+ disabled
46
+ } = _ref4;
47
+ return disabled ? css(["*{color:", ";}svg{fill:", ";}&:focus{outline:none;}@media (hover:hover) and (pointer:fine){&:hover{cursor:not-allowed;}}"], disabledToken.typography.color, icon.states.disabled.typography.color) : css(["@media (hover:hover) and (pointer:fine){&:hover{z-index:1;cursor:pointer;background:", ";}}&:focus{z-index:3;", "}"], hover.background, outlineTemplate(focus.outline));
48
+ });
39
49
  const Content = styled.div.withConfig({
40
50
  displayName: "MenuItem__Content",
41
51
  componentId: "sc-1g9fpbe-1"
42
52
  })(["width:auto;display:grid;grid-gap:16px;grid-auto-flow:column;grid-auto-columns:max-content auto max-content;align-items:center;"]);
43
- const MenuItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function MenuItem({
44
- children,
45
- disabled,
46
- index = 0,
47
- onClick,
48
- ...rest
49
- }, ref) {
53
+ const MenuItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function MenuItem(_ref5, ref) {
54
+ let {
55
+ children,
56
+ disabled,
57
+ index = 0,
58
+ onClick,
59
+ ...rest
60
+ } = _ref5;
50
61
  const {
51
62
  focusedIndex,
52
63
  setFocusedIndex,
@@ -66,8 +77,10 @@ const MenuItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function MenuItem({
66
77
  };
67
78
  return /*#__PURE__*/jsx(Item, { ...props,
68
79
  ref: useCombinedRefs(ref, el => {
69
- if (el !== null && isFocused) {
70
- el.focus();
80
+ if (isFocused) {
81
+ requestAnimationFrame(() => {
82
+ if (el !== null) el.focus();
83
+ });
71
84
  }
72
85
  }),
73
86
  onFocus: () => toggleFocus(index),
@@ -4,8 +4,8 @@ import { useMenu } from './Menu.context.js';
4
4
  import { MenuItem } from './MenuItem.js';
5
5
  import { MenuSection } from './MenuSection.js';
6
6
  import { menu } from './Menu.tokens.js';
7
+ import { spacingsTemplate } from '@equinor/eds-utils';
7
8
  import { jsx } from 'react/jsx-runtime';
8
- import { spacingsTemplate } from '../../utils/templates/index.js';
9
9
 
10
10
  const List = styled.div.withConfig({
11
11
  displayName: "MenuList__List",
@@ -17,19 +17,24 @@ function isIndexable(item) {
17
17
  return false;
18
18
  }
19
19
 
20
- const MenuList = /*#__PURE__*/forwardRef(function MenuList({
21
- children,
22
- focus,
23
- ...rest
24
- }, ref) {
20
+ const MenuList = /*#__PURE__*/forwardRef(function MenuList(_ref, ref) {
21
+ let {
22
+ children,
23
+ ...rest
24
+ } = _ref;
25
25
  const {
26
26
  focusedIndex,
27
- setFocusedIndex
27
+ setFocusedIndex,
28
+ initialFocus
28
29
  } = useMenu();
29
30
  let index = -1;
30
31
  const focusableIndexs = useMemo(() => [], []);
31
32
  const updatedChildren = useMemo(() => Children.map(children, child => {
33
+ if (!child) return child;
34
+
32
35
  if (child.type === MenuSection) {
36
+ index++;
37
+ const menuSectionIndex = index;
33
38
  const updatedGrandChildren = Children.map(child.props.children, grandChild => {
34
39
  index++;
35
40
  if (isIndexable(grandChild)) focusableIndexs.push(index);
@@ -37,7 +42,9 @@ const MenuList = /*#__PURE__*/forwardRef(function MenuList({
37
42
  index
38
43
  });
39
44
  });
40
- return /*#__PURE__*/cloneElement(child, null, updatedGrandChildren);
45
+ return /*#__PURE__*/cloneElement(child, {
46
+ index: menuSectionIndex
47
+ }, updatedGrandChildren);
41
48
  } else {
42
49
  index++;
43
50
  if (isIndexable(child)) focusableIndexs.push(index);
@@ -49,15 +56,15 @@ const MenuList = /*#__PURE__*/forwardRef(function MenuList({
49
56
  const firstFocusIndex = focusableIndexs[0];
50
57
  const lastFocusIndex = focusableIndexs[focusableIndexs.length - 1];
51
58
  useEffect(() => {
52
- if (focus === 'first') {
59
+ if (initialFocus === 'first') {
53
60
  setFocusedIndex(firstFocusIndex);
54
61
  }
55
62
 
56
- if (focus === 'last') {
63
+ if (initialFocus === 'last') {
57
64
  setFocusedIndex(lastFocusIndex);
58
65
  } // eslint-disable-next-line react-hooks/exhaustive-deps
59
66
 
60
- }, [focus, firstFocusIndex, lastFocusIndex]);
67
+ }, [initialFocus, firstFocusIndex, lastFocusIndex]);
61
68
 
62
69
  const handleMenuItemChange = (direction, fallbackIndex) => {
63
70
  const i = direction === 'down' ? 1 : -1;
@@ -1,8 +1,8 @@
1
1
  import { memo } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { menu } from './Menu.tokens.js';
4
+ import { spacingsTemplate } from '@equinor/eds-utils';
4
5
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
- import { spacingsTemplate } from '../../utils/templates/index.js';
6
6
  import { Divider } from '../Divider/Divider.js';
7
7
  import { Typography } from '../Typography/Typography.js';
8
8
 
@@ -1,12 +1,12 @@
1
1
  import { forwardRef, useState, useLayoutEffect } from 'react';
2
2
  import styled from 'styled-components';
3
+ import { useIsMounted } from '@equinor/eds-utils';
3
4
  import { Icon } from '../Icon/index.js';
4
5
  import { PaginationItem } from './PaginationItem.js';
5
6
  import { pagination } from './Pagination.tokens.js';
6
7
  import { chevron_left, chevron_right, more_horizontal } from '@equinor/eds-icons';
7
8
  import { PaginationControl } from './paginationControl.js';
8
9
  import { jsx, jsxs } from 'react/jsx-runtime';
9
- import { useIsMounted } from '../../hooks/useMountedRef.js';
10
10
  import { Typography } from '../Typography/Typography.js';
11
11
  import { Button } from '../Button/Button.js';
12
12
 
@@ -19,9 +19,12 @@ Icon.add(icons);
19
19
  const Navigation = styled.nav.withConfig({
20
20
  displayName: "Pagination__Navigation",
21
21
  componentId: "sc-13cpp3o-0"
22
- })(["display:flex;justify-content:space-between;align-items:center;flex-wrap:nowrap;margin-left:", ";"], ({
23
- withItemIndicator
24
- }) => withItemIndicator ? pagination.spacings.left : 0);
22
+ })(["display:flex;justify-content:space-between;align-items:center;flex-wrap:nowrap;margin-left:", ";"], _ref => {
23
+ let {
24
+ withItemIndicator
25
+ } = _ref;
26
+ return withItemIndicator ? pagination.spacings.left : 0;
27
+ });
25
28
  const OrderedList = styled.ol.withConfig({
26
29
  displayName: "Pagination__OrderedList",
27
30
  componentId: "sc-13cpp3o-1"
@@ -47,14 +50,15 @@ function getAriaLabel(page, selected) {
47
50
  return "".concat(selected === page ? 'Current page, ' : 'Go to ', "page ").concat(page);
48
51
  }
49
52
 
50
- const Pagination = /*#__PURE__*/forwardRef(function Pagination({
51
- totalItems,
52
- defaultPage = 1,
53
- withItemIndicator,
54
- itemsPerPage = 10,
55
- onChange,
56
- ...rest
57
- }, ref) {
53
+ const Pagination = /*#__PURE__*/forwardRef(function Pagination(_ref2, ref) {
54
+ let {
55
+ totalItems,
56
+ defaultPage = 1,
57
+ withItemIndicator,
58
+ itemsPerPage = 10,
59
+ onChange,
60
+ ...rest
61
+ } = _ref2;
58
62
  const pages = Math.ceil(totalItems / itemsPerPage); // Total page numbers
59
63
 
60
64
  const columns = pages < 5 ? pages + 2 : 7; // Total pages to display on the control + 2: < and >
@@ -3,12 +3,13 @@ import { pagination } from './Pagination.tokens.js';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
  import { Button } from '../Button/Button.js';
5
5
 
6
- const PaginationItem = /*#__PURE__*/forwardRef(function PaginationItem({
7
- page,
8
- selected,
9
- onClick,
10
- ...rest
11
- }, ref) {
6
+ const PaginationItem = /*#__PURE__*/forwardRef(function PaginationItem(_ref, ref) {
7
+ let {
8
+ page,
9
+ selected,
10
+ onClick,
11
+ ...rest
12
+ } = _ref;
12
13
  const props = {
13
14
  ref,
14
15
  page,
@@ -6,13 +6,17 @@ import { jsx } from 'react/jsx-runtime';
6
6
  const StyledPaper = styled.div.withConfig({
7
7
  displayName: "Paper__StyledPaper",
8
8
  componentId: "sc-6ncnv9-0"
9
- })(["min-width:", ";max-width:", ";background:", ";box-shadow:", ";"], paper.minWidth, paper.maxWidth, paper.background, ({
10
- elevation
11
- }) => elevation);
12
- const Paper = /*#__PURE__*/forwardRef(function Paper({
13
- elevation: elevation$1,
14
- ...rest
15
- }, ref) {
9
+ })(["min-width:", ";max-width:", ";background:", ";box-shadow:", ";"], paper.minWidth, paper.maxWidth, paper.background, _ref => {
10
+ let {
11
+ elevation
12
+ } = _ref;
13
+ return elevation;
14
+ });
15
+ const Paper = /*#__PURE__*/forwardRef(function Paper(_ref2, ref) {
16
+ let {
17
+ elevation: elevation$1,
18
+ ...rest
19
+ } = _ref2;
16
20
  const props = { ...rest,
17
21
  elevation: elevation[elevation$1] || 'none'
18
22
  };
@@ -1,63 +1,59 @@
1
1
  import { forwardRef, useState, useEffect } from 'react';
2
2
  import styled, { css, ThemeProvider } from 'styled-components';
3
- import { Icon } from '../Icon/index.js';
4
- import { close } from '@equinor/eds-icons';
3
+ import { typographyTemplate, bordersTemplate, useCombinedRefs, useOutsideClick, useGlobalKeyPress, usePopper, useToken } from '@equinor/eds-utils';
5
4
  import { popover } from './Popover.tokens.js';
6
5
  import { jsx, jsxs } from 'react/jsx-runtime';
7
- import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
8
- import { useOutsideClick } from '../../hooks/useOutsideClick.js';
9
- import { useGlobalKeyPress } from '../../hooks/useGlobalKeyPress.js';
10
6
  import { Paper } from '../Paper/Paper.js';
11
- import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
12
- import { bordersTemplate } from '../../utils/templates/borders.js';
13
- import { Button } from '../Button/Button.js';
14
- import { usePopper } from '../../hooks/usePopper.js';
15
7
  import { useEds } from '../EdsProvider/eds.context.js';
16
- import { useToken } from '../../hooks/useToken.js';
17
8
 
18
9
  const PopoverPaper = styled(Paper).withConfig({
19
10
  displayName: "Popover__PopoverPaper",
20
11
  componentId: "sc-b7p1is-0"
21
- })(({
22
- theme,
23
- open
24
- }) => {
25
- return css(["", " ", " ", " display:grid;grid-gap:", ";grid-auto-columns:auto;align-items:center;align-content:start;background:", ";width:max-content;max-height:", ";max-width:", ";min-height:", ";", " z-index:300;.arrow{z-index:-1;width:", ";height:", ";}&[data-popper-placement^='top'] > .arrow{bottom:", ";.arrowSvg{transform:rotate(-90deg);}}&[data-popper-placement^='bottom'] > .arrow{top:", ";.arrowSvg{transform:rotate(90deg);}}&[data-popper-placement^='left'] > .arrow{right:", ";.arrowSvg{transform:rotate(-180deg);}}&[data-popper-placement^='right'] > .arrow{left:", ";}"], {
12
+ })(_ref => {
13
+ let {
14
+ theme,
15
+ open
16
+ } = _ref;
17
+ return css(["", " ", " display:grid;grid-auto-columns:auto;align-items:center;align-content:start;background:", ";width:max-content;max-height:", ";max-width:", ";", " z-index:1400;.arrow{z-index:-1;width:", ";height:", ";}&[data-popper-placement^='top'] > .arrow{bottom:", ";.arrowSvg{transform:rotate(-90deg);}}&[data-popper-placement^='bottom'] > .arrow{top:", ";.arrowSvg{transform:rotate(90deg);}}&[data-popper-placement^='left'] > .arrow{right:", ";.arrowSvg{transform:rotate(-180deg);}}&[data-popper-placement^='right'] > .arrow{left:", ";}"], {
26
18
  visibility: open ? null : 'hidden'
27
- }, typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), theme.spacings.bottom, theme.background, theme.maxHeight, theme.maxWidth, theme.minHeight, bordersTemplate(theme.border), theme.entities.arrow.width, theme.entities.arrow.height, theme.entities.arrow.spacings.bottom, theme.entities.arrow.spacings.top, theme.entities.arrow.spacings.right, theme.entities.arrow.spacings.left);
28
- });
29
- const StyledCloseButton = styled(Button).withConfig({
30
- displayName: "Popover__StyledCloseButton",
31
- componentId: "sc-b7p1is-1"
32
- })(({
33
- theme
34
- }) => {
35
- return css(["position:absolute;top:", ";right:", ";height:", ";width:", ";&:after{height:", ";}"], theme.entities.closeButton.spacings.top, theme.spacings.right, theme.entities.closeButton.height, theme.entities.closeButton.width, theme.entities.closeButton.height);
19
+ }, typographyTemplate(theme.typography), theme.background, theme.maxHeight, theme.maxWidth, bordersTemplate(theme.border), theme.entities.arrow.width, theme.entities.arrow.height, theme.entities.arrow.spacings.bottom, theme.entities.arrow.spacings.top, theme.entities.arrow.spacings.right, theme.entities.arrow.spacings.left);
36
20
  });
37
21
  const ArrowWrapper = styled.div.withConfig({
38
22
  displayName: "Popover__ArrowWrapper",
39
- componentId: "sc-b7p1is-2"
40
- })(({
41
- theme
42
- }) => {
23
+ componentId: "sc-b7p1is-1"
24
+ })(_ref2 => {
25
+ let {
26
+ theme
27
+ } = _ref2;
43
28
  return css(["&,&::before{position:absolute;width:", ";height:", ";z-index:-1;}&::before{content:'';}"], theme.entities.arrow.width, theme.entities.arrow.height);
44
29
  });
30
+ const InnerWrapper = styled.div.withConfig({
31
+ displayName: "Popover__InnerWrapper",
32
+ componentId: "sc-b7p1is-2"
33
+ })(_ref3 => {
34
+ let {
35
+ theme
36
+ } = _ref3;
37
+ return css(["display:grid;grid-gap:", ";"], theme.spacings.bottom);
38
+ });
45
39
  const PopoverArrow = styled.svg.withConfig({
46
40
  displayName: "Popover__PopoverArrow",
47
41
  componentId: "sc-b7p1is-3"
48
- })(({
49
- theme
50
- }) => {
42
+ })(_ref4 => {
43
+ let {
44
+ theme
45
+ } = _ref4;
51
46
  return css(["width:", ";height:", ";position:absolute;fill:", ";filter:drop-shadow(-4px 0px 2px rgba(0,0,0,0.2));"], theme.entities.arrow.width, theme.entities.arrow.height, theme.background);
52
47
  });
53
- const Popover = /*#__PURE__*/forwardRef(function Popover({
54
- children,
55
- placement = 'bottom',
56
- anchorEl,
57
- open,
58
- onClose,
59
- ...rest
60
- }, ref) {
48
+ const Popover = /*#__PURE__*/forwardRef(function Popover(_ref5, ref) {
49
+ let {
50
+ children,
51
+ placement = 'bottom',
52
+ anchorEl,
53
+ open,
54
+ onClose,
55
+ ...rest
56
+ } = _ref5;
61
57
  const [popperEl, setPopperEl] = useState(null);
62
58
  const [storedAnchorEl, setStoredAnchorEl] = useState(null);
63
59
  const [arrowRef, setArrowRef] = useState(null);
@@ -79,7 +75,12 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
79
75
  const {
80
76
  styles,
81
77
  attributes
82
- } = usePopper(storedAnchorEl, popperEl, arrowRef, placement);
78
+ } = usePopper({
79
+ anchorEl: storedAnchorEl,
80
+ popperEl,
81
+ arrowRef,
82
+ placement
83
+ });
83
84
  const props = {
84
85
  open,
85
86
  ...rest,
@@ -109,16 +110,8 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
109
110
  d: "M0.504838 4.86885C-0.168399 4.48524 -0.168399 3.51476 0.504838 3.13115L6 8.59227e-08L6 8L0.504838 4.86885Z"
110
111
  })
111
112
  })
112
- }), children, /*#__PURE__*/jsx(StyledCloseButton, {
113
- onClick: onClose,
114
- variant: "ghost_icon",
115
- "data-testid": "popover-close",
116
- "aria-label": "Close popover",
117
- children: /*#__PURE__*/jsx(Icon, {
118
- name: "close",
119
- data: close,
120
- size: 24
121
- })
113
+ }), /*#__PURE__*/jsx(InnerWrapper, {
114
+ children: children
122
115
  })]
123
116
  })
124
117
  });