@equinor/eds-core-react 0.16.1 → 0.17.0-dev.20220209

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 (198) hide show
  1. package/README.md +1 -1
  2. package/dist/{core-react.cjs.js → eds-core-react.cjs.js} +2731 -2290
  3. package/dist/esm/components/Accordion/Accordion.js +24 -11
  4. package/dist/esm/components/Accordion/Accordion.tokens.js +3 -0
  5. package/dist/esm/components/Accordion/AccordionHeader.js +65 -51
  6. package/dist/esm/components/Accordion/AccordionHeaderTitle.js +15 -13
  7. package/dist/esm/components/Accordion/AccordionItem.js +11 -10
  8. package/dist/esm/components/Accordion/AccordionPanel.js +32 -24
  9. package/dist/esm/components/Avatar/Avatar.js +21 -14
  10. package/dist/esm/components/Banner/Banner.js +36 -24
  11. package/dist/esm/components/Banner/Banner.tokens.js +9 -0
  12. package/dist/esm/components/Banner/BannerActions.js +16 -17
  13. package/dist/esm/components/Banner/BannerIcon.js +15 -11
  14. package/dist/esm/components/Banner/BannerMessage.js +5 -4
  15. package/dist/esm/components/Breadcrumbs/Breadcrumb.js +16 -12
  16. package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +7 -6
  17. package/dist/esm/components/Button/Button.js +17 -18
  18. package/dist/esm/components/Button/InnerFullWidth.js +5 -4
  19. package/dist/esm/components/Button/tokens/button.js +17 -10
  20. package/dist/esm/components/Button/tokens/contained.js +5 -5
  21. package/dist/esm/components/Button/tokens/ghost.js +4 -4
  22. package/dist/esm/components/Button/tokens/icon.js +4 -4
  23. package/dist/esm/components/Button/tokens/outlined.js +5 -5
  24. package/dist/esm/components/Card/Card.js +19 -12
  25. package/dist/esm/components/Card/CardActions.js +13 -9
  26. package/dist/esm/components/Card/CardContent.js +5 -4
  27. package/dist/esm/components/Card/CardHeader.js +5 -4
  28. package/dist/esm/components/Card/CardHeaderTitle.js +5 -4
  29. package/dist/esm/components/Card/CardMedia.js +12 -8
  30. package/dist/esm/components/Checkbox/Checkbox.js +15 -11
  31. package/dist/esm/components/Checkbox/Input.js +72 -46
  32. package/dist/esm/components/Chip/Chip.js +46 -30
  33. package/dist/esm/components/Chip/Icon.js +12 -7
  34. package/dist/esm/components/Dialog/Dialog.js +55 -16
  35. package/dist/esm/components/Dialog/Dialog.tokens.js +7 -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 +5 -4
  50. package/dist/esm/components/Menu/Menu.js +39 -30
  51. package/dist/esm/components/Menu/MenuItem.js +38 -25
  52. package/dist/esm/components/Menu/MenuList.js +7 -6
  53. package/dist/esm/components/Menu/MenuSection.js +3 -3
  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 +77 -58
  58. package/dist/esm/components/Popover/Popover.tokens.js +5 -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 +15 -19
  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/Scrim/Scrim.js +20 -15
  70. package/dist/esm/components/Search/Search.js +81 -58
  71. package/dist/esm/components/Search/Search.tokens.js +8 -4
  72. package/dist/esm/components/Select/MultiSelect/MultiSelect.js +35 -24
  73. package/dist/esm/components/Select/NativeSelect/NativeSelect.js +19 -17
  74. package/dist/esm/components/Select/Select.tokens.js +5 -2
  75. package/dist/esm/components/Select/SingleSelect/SingleSelect.js +29 -23
  76. package/dist/esm/components/Select/commonStyles.js +15 -14
  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 +63 -35
  81. package/dist/esm/components/Slider/SliderInput.js +14 -14
  82. package/dist/esm/components/Snackbar/Snackbar.js +36 -25
  83. package/dist/esm/components/Snackbar/Snackbar.tokens.js +3 -0
  84. package/dist/esm/components/Snackbar/SnackbarAction.js +12 -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/SwitchDefault.js +39 -29
  88. package/dist/esm/components/Switch/SwitchSmall.js +38 -28
  89. package/dist/esm/components/Table/Body.js +5 -4
  90. package/dist/esm/components/Table/Caption.js +8 -5
  91. package/dist/esm/components/Table/Cell.js +9 -6
  92. package/dist/esm/components/Table/DataCell/DataCell.js +15 -14
  93. package/dist/esm/components/Table/DataCell/DataCell.tokens.js +19 -9
  94. package/dist/esm/components/Table/Head/Head.js +7 -6
  95. package/dist/esm/components/Table/HeaderCell/HeaderCell.js +8 -9
  96. package/dist/esm/components/Table/HeaderCell/HeaderCell.tokens.js +18 -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 +13 -10
  100. package/dist/esm/components/TableOfContents/TableOfContents.js +44 -24
  101. package/dist/esm/components/TableOfContents/TableOfContents.tokens.js +3 -0
  102. package/dist/esm/components/Tabs/Tab.js +27 -30
  103. package/dist/esm/components/Tabs/TabList.js +12 -8
  104. package/dist/esm/components/Tabs/TabPanel.js +16 -12
  105. package/dist/esm/components/Tabs/TabPanels.js +5 -4
  106. package/dist/esm/components/Tabs/Tabs.js +37 -24
  107. package/dist/esm/components/Tabs/Tabs.tokens.js +3 -0
  108. package/dist/esm/components/TextField/Field.js +51 -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 +22 -18
  113. package/dist/esm/components/Textarea/Textarea.js +16 -16
  114. package/dist/esm/components/Tooltip/Tooltip.js +10 -16
  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 +27 -19
  119. package/dist/esm/components/TopBar/TopBar.tokens.js +5 -2
  120. package/dist/esm/components/Typography/Typography.js +49 -28
  121. package/dist/esm/index.js +1 -0
  122. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry1.js +1 -1
  123. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry2.js +1 -1
  124. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry3.js +1 -1
  125. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_has.js +1 -1
  126. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_isObject.js +1 -1
  127. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_isPlaceholder.js +1 -1
  128. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeDeepRight.js +2 -1
  129. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeDeepWithKey.js +1 -1
  130. package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeWithKey.js +1 -1
  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/Group/Group.d.ts +3 -0
  140. package/dist/types/components/Group/Group.tokens.d.ts +4 -0
  141. package/dist/types/components/Group/index.d.ts +1 -0
  142. package/dist/types/components/Icon/Icon.d.ts +2 -2
  143. package/dist/types/components/Menu/Menu.d.ts +1 -1
  144. package/dist/types/components/Menu/MenuSection.d.ts +1 -2
  145. package/dist/types/components/Popover/Popover.d.ts +1 -1
  146. package/dist/types/components/Popover/PopoverActions.d.ts +3 -0
  147. package/dist/types/components/Popover/PopoverHeader.d.ts +3 -0
  148. package/dist/types/components/Popover/index.d.ts +5 -1
  149. package/dist/types/components/Progress/Circular/CircularProgress.d.ts +1 -1
  150. package/dist/types/components/Progress/Dots/DotProgress.d.ts +1 -1
  151. package/dist/types/components/Progress/Star/StarProgress.d.ts +1 -1
  152. package/dist/types/components/Scrim/Scrim.d.ts +7 -3
  153. package/dist/types/components/Switch/Switch.d.ts +1 -1
  154. package/dist/types/components/Switch/Switch.styles.d.ts +2 -1
  155. package/dist/types/components/Tooltip/Tooltip.d.ts +1 -1
  156. package/dist/types/components/TopBar/TopBar.tokens.d.ts +1 -1
  157. package/dist/types/index.d.ts +1 -0
  158. package/package.json +47 -39
  159. package/dist/esm/components/Dialog/Actions.js +0 -24
  160. package/dist/esm/components/Dialog/CustomContent.js +0 -40
  161. package/dist/esm/components/Dialog/Title.js +0 -35
  162. package/dist/esm/hooks/useAutoResize.js +0 -39
  163. package/dist/esm/hooks/useCombinedRefs.js +0 -14
  164. package/dist/esm/hooks/useGlobalKeyPress.js +0 -34
  165. package/dist/esm/hooks/useHideBodyScroll.js +0 -12
  166. package/dist/esm/hooks/useId.js +0 -14
  167. package/dist/esm/hooks/useMountedRef.js +0 -12
  168. package/dist/esm/hooks/useOutsideClick.js +0 -18
  169. package/dist/esm/hooks/usePopper.js +0 -31
  170. package/dist/esm/hooks/useToken.js +0 -16
  171. package/dist/esm/utils/joinHandlers.js +0 -10
  172. package/dist/esm/utils/setReactInputValue.js +0 -18
  173. package/dist/esm/utils/templates/borders.js +0 -35
  174. package/dist/esm/utils/templates/common.js +0 -19
  175. package/dist/esm/utils/templates/focus.js +0 -35
  176. package/dist/esm/utils/templates/index.js +0 -52
  177. package/dist/types/components/Combobox/Combobox.d.ts +0 -55
  178. package/dist/types/components/Combobox/Combobox.tokens.d.ts +0 -3
  179. package/dist/types/components/Combobox/index.d.ts +0 -1
  180. package/dist/types/components/Dialog/Actions.d.ts +0 -3
  181. package/dist/types/components/Dialog/Title.d.ts +0 -3
  182. package/dist/types/hooks/index.d.ts +0 -9
  183. package/dist/types/hooks/useAutoResize.d.ts +0 -1
  184. package/dist/types/hooks/useCombinedRefs.d.ts +0 -3
  185. package/dist/types/hooks/useGlobalKeyPress.d.ts +0 -10
  186. package/dist/types/hooks/useHideBodyScroll.d.ts +0 -1
  187. package/dist/types/hooks/useId.d.ts +0 -1
  188. package/dist/types/hooks/useMountedRef.d.ts +0 -1
  189. package/dist/types/hooks/useOutsideClick.d.ts +0 -1
  190. package/dist/types/hooks/usePopper.d.ts +0 -12
  191. package/dist/types/hooks/useToken.d.ts +0 -7
  192. package/dist/types/utils/index.d.ts +0 -4
  193. package/dist/types/utils/joinHandlers.d.ts +0 -3
  194. package/dist/types/utils/setReactInputValue.d.ts +0 -7
  195. package/dist/types/utils/templates/borders.d.ts +0 -2
  196. package/dist/types/utils/templates/common.d.ts +0 -9
  197. package/dist/types/utils/templates/focus.d.ts +0 -2
  198. package/dist/types/utils/templates/index.d.ts +0 -7
@@ -3,75 +3,106 @@ import styled from 'styled-components';
3
3
  import { get } from './library.js';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
5
5
 
6
- const customIcon = icon => ({
7
- icon,
8
- count: Math.floor(Math.random() * 1000)
9
- });
6
+ const transform = _ref => {
7
+ let {
8
+ rotation
9
+ } = _ref;
10
+ return rotation ? "transform: rotate(".concat(rotation, "deg)") : '';
11
+ };
10
12
 
11
- const transform = ({
12
- rotation
13
- }) => rotation ? "transform: rotate(".concat(rotation, "deg)") : '';
14
-
15
- const StyledSvg = styled.svg.attrs(({
16
- height,
17
- width,
18
- fill
19
- }) => ({
20
- name: null,
21
- xmlns: 'http://www.w3.org/2000/svg',
22
- height: "".concat(height, "px"),
23
- width: "".concat(width, "px"),
24
- fill
25
- })).withConfig({
13
+ const StyledSvg = styled.svg.attrs(_ref2 => {
14
+ let {
15
+ height,
16
+ width,
17
+ fill
18
+ } = _ref2;
19
+ return {
20
+ name: null,
21
+ xmlns: 'http://www.w3.org/2000/svg',
22
+ height: "".concat(height, "px"),
23
+ width: "".concat(width, "px"),
24
+ fill
25
+ };
26
+ }).withConfig({
26
27
  displayName: "Icon__StyledSvg",
27
28
  componentId: "sc-6evbi1-0"
28
29
  })(["", ""], transform);
29
- const StyledPath = styled.path.attrs(({
30
- height,
31
- size
32
- }) => ({
33
- size: null,
34
- fillRule: 'evenodd',
35
- clipRule: 'evenodd',
36
- transform: size / height !== 1 ? "scale(".concat(size / height, ")") : null
37
- })).withConfig({
30
+ const StyledPath = styled.path.attrs(_ref3 => {
31
+ let {
32
+ height,
33
+ size
34
+ } = _ref3;
35
+ return {
36
+ size: null,
37
+ fillRule: 'evenodd',
38
+ clipRule: 'evenodd',
39
+ transform: size / height !== 1 ? "scale(".concat(size / height, ")") : null
40
+ };
41
+ }).withConfig({
38
42
  displayName: "Icon__StyledPath",
39
43
  componentId: "sc-6evbi1-1"
40
44
  })([""]);
41
- const Icon = /*#__PURE__*/forwardRef(function Icon({
42
- size = 24,
43
- color = 'currentColor',
44
- name,
45
- className,
46
- rotation,
47
- title,
48
- data,
49
- ...rest
50
- }, ref) {
51
- const {
45
+
46
+ const customIcon = icon => ({
47
+ icon,
48
+ count: Math.floor(Math.random() * 1000)
49
+ });
50
+
51
+ const findIcon = (name, data, size) => {
52
+ // eslint-disable-next-line prefer-const
53
+ let {
52
54
  icon,
53
55
  count
54
56
  } = data ? customIcon(data) : get(name);
55
57
 
58
+ if (size < 24) {
59
+ var _icon$sizes;
60
+
61
+ // fallback to normal icon if small is not made yet
62
+ icon = ((_icon$sizes = icon.sizes) === null || _icon$sizes === void 0 ? void 0 : _icon$sizes.small) || icon;
63
+ }
64
+
65
+ return {
66
+ icon,
67
+ count
68
+ };
69
+ };
70
+
71
+ const Icon = /*#__PURE__*/forwardRef(function Icon(_ref4, ref) {
72
+ let {
73
+ size = 24,
74
+ color = 'currentColor',
75
+ name,
76
+ rotation,
77
+ title,
78
+ data,
79
+ ...rest
80
+ } = _ref4;
81
+ // eslint-disable-next-line prefer-const
82
+ const {
83
+ icon,
84
+ count
85
+ } = findIcon(name, data, size);
86
+
56
87
  if (typeof icon === 'undefined') {
57
88
  throw Error("Icon \"".concat(name, "\" not found. Have you added it using Icon.add() or using data props?"));
58
89
  }
59
90
 
91
+ const height = size ? size : parseInt(icon.width);
92
+ const width = size ? size : parseInt(icon.height);
60
93
  let svgProps = {
61
- height: size,
62
- width: size,
94
+ height,
95
+ width,
63
96
  fill: color,
64
- viewBox: "0 0 ".concat(size, " ").concat(size),
65
- className,
97
+ viewBox: "0 0 ".concat(width, " ").concat(height),
66
98
  rotation,
67
99
  name,
68
- 'aria-hidden': true,
69
- title: null
100
+ 'aria-hidden': true
70
101
  };
71
102
  const pathProps = {
72
103
  d: icon.svgPathData,
73
104
  height: icon.height ? icon.height : size,
74
- size
105
+ size: size || icon.height
75
106
  }; // Accessibility
76
107
 
77
108
  let titleId = '';
@@ -1,18 +1,17 @@
1
1
  import { forwardRef } from 'react';
2
2
  import styled, { css, ThemeProvider } from 'styled-components';
3
3
  import { inputToken } from './Input.tokens.js';
4
+ import { outlineTemplate, typographyTemplate, spacingsTemplate, useToken } from '@equinor/eds-utils';
4
5
  import { jsx } from 'react/jsx-runtime';
5
- import { outlineTemplate } from '../../utils/templates/focus.js';
6
- import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
7
6
  import { useEds } from '../EdsProvider/eds.context.js';
8
- import { useToken } from '../../hooks/useToken.js';
9
7
 
10
8
  const StyledInput = styled.input.withConfig({
11
9
  displayName: "Input__StyledInput",
12
10
  componentId: "sc-1ykv024-0"
13
- })(({
14
- theme
15
- }) => {
11
+ })(_ref => {
12
+ let {
13
+ theme
14
+ } = _ref;
16
15
  const {
17
16
  states: {
18
17
  focus: {
@@ -28,12 +27,13 @@ const StyledInput = styled.input.withConfig({
28
27
  } = theme;
29
28
  return css(["width:100%;box-sizing:border-box;margin:0;appearance:none;background:", ";border:none;height:", ";box-shadow:", ";", " ", " ", ";&::placeholder{color:", ";}&:active,&:focus{outline-offset:0;box-shadow:none;", "}&:disabled{color:", ";cursor:not-allowed;box-shadow:none;outline:none;&:focus,&:active{outline:none;}}&[readOnly]{background:", ";box-shadow:", ";}"], theme.background, theme.minHeight, boxShadow, outlineTemplate(activeOutline), typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), theme.entities.placeholder.typography.color, outlineTemplate(focusOutline), disabled.typography.color, readOnly.background, readOnly.boxShadow);
30
29
  });
31
- const Input = /*#__PURE__*/forwardRef(function Input({
32
- variant = 'default',
33
- disabled = false,
34
- type = 'text',
35
- ...other
36
- }, ref) {
30
+ const Input = /*#__PURE__*/forwardRef(function Input(_ref2, ref) {
31
+ let {
32
+ variant = 'default',
33
+ disabled = false,
34
+ type = 'text',
35
+ ...other
36
+ } = _ref2;
37
37
  const actualVariant = variant === 'default' ? 'input' : variant;
38
38
  const inputVariant = inputToken[actualVariant];
39
39
  const {
@@ -1,5 +1,5 @@
1
1
  import { tokens as tokens$1 } from '@equinor/eds-tokens';
2
- import mergeDeepRight_1 from '../../node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/mergeDeepRight.js';
2
+ import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.27.2/node_modules/ramda/src/mergeDeepRight.js';
3
3
 
4
4
  const {
5
5
  colors: {
@@ -93,7 +93,7 @@ const input = {
93
93
  }
94
94
  }
95
95
  };
96
- const error = mergeDeepRight_1(input, {
96
+ const error = mergeDeepRight(input, {
97
97
  boxShadow: 'inset 0px -1px 0px 0px transparent',
98
98
  states: {
99
99
  active: {
@@ -116,7 +116,7 @@ const error = mergeDeepRight_1(input, {
116
116
  }
117
117
  }
118
118
  });
119
- const warning = mergeDeepRight_1(input, {
119
+ const warning = mergeDeepRight(input, {
120
120
  boxShadow: 'inset 0px -1px 0px 0px transparent',
121
121
  states: {
122
122
  active: {
@@ -139,7 +139,7 @@ const warning = mergeDeepRight_1(input, {
139
139
  }
140
140
  }
141
141
  });
142
- const success = mergeDeepRight_1(input, {
142
+ const success = mergeDeepRight(input, {
143
143
  boxShadow: 'inset 0px -1px 0px 0px transparent',
144
144
  states: {
145
145
  active: {
@@ -1,15 +1,18 @@
1
1
  import { forwardRef } from 'react';
2
2
  import styled from 'styled-components';
3
+ import { typographyTemplate } from '@equinor/eds-utils';
3
4
  import { label } from './Label.tokens.js';
4
5
  import { jsxs, jsx } from 'react/jsx-runtime';
5
- import { typographyTemplate } from '../../utils/templates/index.js';
6
6
 
7
7
  const LabelBase = styled.label.withConfig({
8
8
  displayName: "Label__LabelBase",
9
9
  componentId: "sc-1gi2bcn-0"
10
- })(["display:flex;justify-content:space-between;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], typographyTemplate(label.typography), label.spacings.left, label.spacings.right, ({
11
- disabledText
12
- }) => disabledText ? label.states.disabled.typography.color : label.typography.color);
10
+ })(["display:flex;justify-content:space-between;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], typographyTemplate(label.typography), label.spacings.left, label.spacings.right, _ref => {
11
+ let {
12
+ disabledText
13
+ } = _ref;
14
+ return disabledText ? label.states.disabled.typography.color : label.typography.color;
15
+ });
13
16
  const Text = styled.span.withConfig({
14
17
  displayName: "Label__Text",
15
18
  componentId: "sc-1gi2bcn-1"
@@ -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
@@ -6,9 +6,10 @@ const initalState = {
6
6
  onClose: null
7
7
  };
8
8
  const MenuContext = /*#__PURE__*/createContext(initalState);
9
- const MenuProvider = ({
10
- children
11
- }) => {
9
+ const MenuProvider = _ref => {
10
+ let {
11
+ children
12
+ } = _ref;
12
13
  const [state, setState] = useState(initalState);
13
14
  const {
14
15
  focusedIndex,
@@ -23,8 +24,8 @@ const MenuProvider = ({
23
24
 
24
25
  const setOnClose = onClose => {
25
26
  const onCloseHelper = () => {
26
- onClose();
27
27
  setFocusedIndex(-1);
28
+ onClose();
28
29
  };
29
30
 
30
31
  setState(prevState => ({ ...prevState,
@@ -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,19 +15,23 @@ 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:300;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
37
  onClose
@@ -41,7 +40,7 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
41
40
  if (onClose === null && onCloseCallback) {
42
41
  setOnClose(onCloseCallback);
43
42
  }
44
- });
43
+ }, [onClose, onCloseCallback, setOnClose]);
45
44
  useOutsideClick(containerEl, e => {
46
45
  if (open && onClose !== null && !anchorEl.contains(e.target)) {
47
46
  onClose();
@@ -55,7 +54,11 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
55
54
  });
56
55
  useGlobalKeyPress('Enter', () => {
57
56
  if (open && onClose !== null) {
58
- if (window.document.contains(anchorEl)) anchorEl.focus();
57
+ setTimeout(() => {
58
+ if (window.document.contains(anchorEl)) {
59
+ anchorEl.focus();
60
+ }
61
+ }, 0);
59
62
  }
60
63
  });
61
64
  return /*#__PURE__*/jsx(MenuList, { ...rest,
@@ -63,15 +66,17 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
63
66
  children: children
64
67
  });
65
68
  });
66
- const Menu = /*#__PURE__*/forwardRef(function Menu({
67
- anchorEl,
68
- open,
69
- placement = 'auto',
70
- style,
71
- className,
72
- ...rest
73
- }, ref) {
69
+ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref3, ref) {
70
+ let {
71
+ anchorEl,
72
+ open,
73
+ placement = 'auto',
74
+ style,
75
+ className,
76
+ ...rest
77
+ } = _ref3;
74
78
  const [containerEl, setContainerEl] = useState(null);
79
+ const [storedAnchorEl, setStoredAnchorEl] = useState(null);
75
80
  const isMounted = useIsMounted();
76
81
  const {
77
82
  density
@@ -79,10 +84,14 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
79
84
  const token = useToken({
80
85
  density
81
86
  }, menu);
87
+ useEffect(() => {
88
+ open ? setStoredAnchorEl(anchorEl) : setStoredAnchorEl(null);
89
+ return () => setStoredAnchorEl(null);
90
+ }, [anchorEl, open]);
82
91
  const {
83
92
  styles,
84
93
  attributes
85
- } = usePopper(anchorEl, containerEl, null, placement, 4);
94
+ } = usePopper(storedAnchorEl, containerEl, null, placement, 4);
86
95
  const props = {
87
96
  open,
88
97
  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,11 +17,12 @@ 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
+ focus,
24
+ ...rest
25
+ } = _ref;
25
26
  const {
26
27
  focusedIndex,
27
28
  setFocusedIndex
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
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
 
@@ -12,7 +12,7 @@ const Header = styled.div.attrs(() => ({
12
12
  displayName: "MenuSection__Header",
13
13
  componentId: "sc-gfcbvg-0"
14
14
  })(["", " &:focus{outline:none;}"], spacingsTemplate(menu.entities.title.spacings));
15
- const MenuSection = /*#__PURE__*/React.memo(function MenuSection(props) {
15
+ const MenuSection = /*#__PURE__*/memo(function MenuSection(props) {
16
16
  const {
17
17
  children,
18
18
  title,
@@ -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,