@equinor/eds-core-react 0.16.0 → 0.18.0-envis.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{core-react.cjs.js → eds-core-react.cjs.js} +1267 -769
- package/dist/esm/components/Accordion/Accordion.js +16 -3
- package/dist/esm/components/Accordion/Accordion.tokens.js +3 -0
- package/dist/esm/components/Accordion/AccordionHeader.js +24 -17
- package/dist/esm/components/Accordion/AccordionHeaderTitle.js +5 -5
- package/dist/esm/components/Accordion/AccordionPanel.js +13 -9
- package/dist/esm/components/Banner/Banner.js +28 -17
- package/dist/esm/components/Banner/Banner.tokens.js +9 -0
- package/dist/esm/components/Banner/BannerActions.js +8 -11
- package/dist/esm/components/Banner/BannerIcon.js +6 -4
- package/dist/esm/components/Button/Button.js +1 -1
- package/dist/esm/components/Button/InnerFullWidth.js +1 -1
- package/dist/esm/components/Button/tokens/button.js +24 -7
- package/dist/esm/components/Button/tokens/contained.js +4 -4
- package/dist/esm/components/Button/tokens/ghost.js +4 -4
- package/dist/esm/components/Button/tokens/icon.js +4 -4
- package/dist/esm/components/Button/tokens/outlined.js +4 -4
- package/dist/esm/components/Dialog/Actions.js +5 -3
- package/dist/esm/components/Dialog/CustomContent.js +10 -4
- package/dist/esm/components/Dialog/Dialog.js +24 -9
- package/dist/esm/components/Dialog/Dialog.tokens.js +3 -0
- package/dist/esm/components/Dialog/Title.js +10 -4
- package/dist/esm/components/Input/Input.tokens.js +4 -4
- package/dist/esm/components/Menu/Menu.js +7 -2
- package/dist/esm/components/Menu/MenuSection.js +2 -2
- package/dist/esm/components/Popover/Popover.js +68 -37
- package/dist/esm/components/Popover/Popover.tokens.js +3 -0
- package/dist/esm/components/Popover/PopoverTitle.js +11 -4
- package/dist/esm/components/Scrim/Scrim.js +12 -7
- package/dist/esm/components/Search/Search.js +65 -42
- package/dist/esm/components/Search/Search.tokens.js +8 -4
- package/dist/esm/components/Select/MultiSelect/MultiSelect.js +8 -2
- package/dist/esm/components/Select/Select.tokens.js +5 -2
- package/dist/esm/components/Select/commonStyles.js +1 -1
- package/dist/esm/components/Snackbar/Snackbar.js +25 -14
- package/dist/esm/components/Snackbar/Snackbar.tokens.js +3 -0
- package/dist/esm/components/Snackbar/SnackbarAction.js +6 -3
- package/dist/esm/components/Table/DataCell/DataCell.tokens.js +2 -2
- package/dist/esm/components/Table/HeaderCell/HeaderCell.js +1 -1
- package/dist/esm/components/TableOfContents/LinkItem.js +6 -3
- package/dist/esm/components/TableOfContents/TableOfContents.js +34 -16
- package/dist/esm/components/TableOfContents/TableOfContents.tokens.js +3 -0
- package/dist/esm/components/Tabs/Tab.js +11 -16
- package/dist/esm/components/Tabs/TabPanel.js +11 -8
- package/dist/esm/components/Tabs/Tabs.js +26 -13
- package/dist/esm/components/Tabs/Tabs.tokens.js +3 -0
- package/dist/esm/components/TextField/Field.js +2 -0
- package/dist/esm/components/TextField/TextField.js +4 -0
- package/dist/esm/components/TopBar/TopBar.js +21 -13
- package/dist/esm/components/TopBar/TopBar.tokens.js +5 -2
- package/dist/esm/hooks/useHideBodyScroll.js +13 -5
- package/dist/esm/hooks/useToken.js +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/internal/_curry1.js +25 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/internal/_curry2.js +38 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/internal/_curry3.js +57 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/internal/_has.js +7 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/internal/_isObject.js +7 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/internal/_isPlaceholder.js +7 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/mergeDeepRight.js +36 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/mergeDeepWithKey.js +49 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/mergeWithKey.js +53 -0
- package/dist/types/components/Group/Group.d.ts +3 -0
- package/dist/types/components/Group/Group.tokens.d.ts +4 -0
- package/dist/types/components/Group/index.d.ts +1 -0
- package/dist/types/components/Menu/MenuSection.d.ts +1 -2
- package/dist/types/components/Scrim/Scrim.d.ts +7 -3
- package/dist/types/components/TopBar/TopBar.tokens.d.ts +1 -1
- package/dist/types/hooks/useHideBodyScroll.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +13 -8
- package/dist/types/components/Combobox/Combobox.d.ts +0 -55
- package/dist/types/components/Combobox/Combobox.tokens.d.ts +0 -3
- package/dist/types/components/Combobox/index.d.ts +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { dialog } from './Dialog.tokens.js';
|
|
4
3
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
4
|
import { Divider } from '../Divider/Divider.js';
|
|
6
5
|
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
@@ -8,13 +7,20 @@ import { typographyTemplate, spacingsTemplate } from '../../utils/templates/inde
|
|
|
8
7
|
const StyledTitle = styled.div.withConfig({
|
|
9
8
|
displayName: "Title__StyledTitle",
|
|
10
9
|
componentId: "sc-i4qfl5-0"
|
|
11
|
-
})(
|
|
10
|
+
})(({
|
|
11
|
+
theme,
|
|
12
12
|
children
|
|
13
|
-
}) =>
|
|
13
|
+
}) => {
|
|
14
|
+
return css(["", " min-height:", ";align-self:end;justify-self:start;", ";", ""], typographyTemplate(theme.entities.title.typography), theme.entities.title.minHeight, spacingsTemplate(theme.entities.children.spacings), !children && css(["min-height:initial;height:'8px';"]));
|
|
15
|
+
});
|
|
14
16
|
const StyledDivider = styled(Divider).withConfig({
|
|
15
17
|
displayName: "Title__StyledDivider",
|
|
16
18
|
componentId: "sc-i4qfl5-1"
|
|
17
|
-
})(
|
|
19
|
+
})(({
|
|
20
|
+
theme
|
|
21
|
+
}) => {
|
|
22
|
+
return css(["width:100%;margin-bottom:", ";"], theme.entities.divider.spacings.bottom);
|
|
23
|
+
});
|
|
18
24
|
const Title = /*#__PURE__*/forwardRef(function Title({
|
|
19
25
|
children,
|
|
20
26
|
...rest
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens as tokens$1 } from '@equinor/eds-tokens';
|
|
2
|
-
import
|
|
2
|
+
import mergeDeepRight_1 from '../../node_modules/.pnpm/ramda@0.27.1/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 =
|
|
96
|
+
const error = mergeDeepRight_1(input, {
|
|
97
97
|
boxShadow: 'inset 0px -1px 0px 0px transparent',
|
|
98
98
|
states: {
|
|
99
99
|
active: {
|
|
@@ -116,7 +116,7 @@ const error = mergeDeepRight(input, {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
const warning =
|
|
119
|
+
const warning = mergeDeepRight_1(input, {
|
|
120
120
|
boxShadow: 'inset 0px -1px 0px 0px transparent',
|
|
121
121
|
states: {
|
|
122
122
|
active: {
|
|
@@ -139,7 +139,7 @@ const warning = mergeDeepRight(input, {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
-
const success =
|
|
142
|
+
const success = mergeDeepRight_1(input, {
|
|
143
143
|
boxShadow: 'inset 0px -1px 0px 0px transparent',
|
|
144
144
|
states: {
|
|
145
145
|
active: {
|
|
@@ -41,7 +41,7 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
|
|
|
41
41
|
if (onClose === null && onCloseCallback) {
|
|
42
42
|
setOnClose(onCloseCallback);
|
|
43
43
|
}
|
|
44
|
-
});
|
|
44
|
+
}, [onClose, onCloseCallback, setOnClose]);
|
|
45
45
|
useOutsideClick(containerEl, e => {
|
|
46
46
|
if (open && onClose !== null && !anchorEl.contains(e.target)) {
|
|
47
47
|
onClose();
|
|
@@ -72,6 +72,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
72
72
|
...rest
|
|
73
73
|
}, ref) {
|
|
74
74
|
const [containerEl, setContainerEl] = useState(null);
|
|
75
|
+
const [storedAnchorEl, setStoredAnchorEl] = useState(null);
|
|
75
76
|
const isMounted = useIsMounted();
|
|
76
77
|
const {
|
|
77
78
|
density
|
|
@@ -79,10 +80,14 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
79
80
|
const token = useToken({
|
|
80
81
|
density
|
|
81
82
|
}, menu);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
open ? setStoredAnchorEl(anchorEl) : setStoredAnchorEl(null);
|
|
85
|
+
return () => setStoredAnchorEl(null);
|
|
86
|
+
}, [anchorEl, open]);
|
|
82
87
|
const {
|
|
83
88
|
styles,
|
|
84
89
|
attributes
|
|
85
|
-
} = usePopper(
|
|
90
|
+
} = usePopper(storedAnchorEl, containerEl, null, placement, 4);
|
|
86
91
|
const props = {
|
|
87
92
|
open,
|
|
88
93
|
style: { ...styles.popper,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { memo } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { menu } from './Menu.tokens.js';
|
|
4
4
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -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__*/
|
|
15
|
+
const MenuSection = /*#__PURE__*/memo(function MenuSection(props) {
|
|
16
16
|
const {
|
|
17
17
|
children,
|
|
18
18
|
title,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { forwardRef, useState } from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
1
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
2
|
+
import styled, { css, ThemeProvider } from 'styled-components';
|
|
3
3
|
import { Icon } from '../Icon/index.js';
|
|
4
4
|
import { close } from '@equinor/eds-icons';
|
|
5
5
|
import { popover } from './Popover.tokens.js';
|
|
6
|
-
import {
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
7
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
|
|
8
8
|
import { useOutsideClick } from '../../hooks/useOutsideClick.js';
|
|
9
9
|
import { useGlobalKeyPress } from '../../hooks/useGlobalKeyPress.js';
|
|
@@ -12,27 +12,44 @@ import { typographyTemplate, spacingsTemplate } from '../../utils/templates/inde
|
|
|
12
12
|
import { bordersTemplate } from '../../utils/templates/borders.js';
|
|
13
13
|
import { Button } from '../Button/Button.js';
|
|
14
14
|
import { usePopper } from '../../hooks/usePopper.js';
|
|
15
|
+
import { useEds } from '../EdsProvider/eds.context.js';
|
|
16
|
+
import { useToken } from '../../hooks/useToken.js';
|
|
15
17
|
|
|
16
18
|
const PopoverPaper = styled(Paper).withConfig({
|
|
17
19
|
displayName: "Popover__PopoverPaper",
|
|
18
20
|
componentId: "sc-b7p1is-0"
|
|
19
|
-
})(
|
|
21
|
+
})(({
|
|
22
|
+
theme,
|
|
20
23
|
open
|
|
21
|
-
}) =>
|
|
22
|
-
|
|
23
|
-
|
|
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:", ";}"], {
|
|
26
|
+
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
|
+
});
|
|
24
29
|
const StyledCloseButton = styled(Button).withConfig({
|
|
25
30
|
displayName: "Popover__StyledCloseButton",
|
|
26
31
|
componentId: "sc-b7p1is-1"
|
|
27
|
-
})(
|
|
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);
|
|
36
|
+
});
|
|
28
37
|
const ArrowWrapper = styled.div.withConfig({
|
|
29
38
|
displayName: "Popover__ArrowWrapper",
|
|
30
39
|
componentId: "sc-b7p1is-2"
|
|
31
|
-
})(
|
|
40
|
+
})(({
|
|
41
|
+
theme
|
|
42
|
+
}) => {
|
|
43
|
+
return css(["&,&::before{position:absolute;width:", ";height:", ";z-index:-1;}&::before{content:'';}"], theme.entities.arrow.width, theme.entities.arrow.height);
|
|
44
|
+
});
|
|
32
45
|
const PopoverArrow = styled.svg.withConfig({
|
|
33
46
|
displayName: "Popover__PopoverArrow",
|
|
34
47
|
componentId: "sc-b7p1is-3"
|
|
35
|
-
})(
|
|
48
|
+
})(({
|
|
49
|
+
theme
|
|
50
|
+
}) => {
|
|
51
|
+
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
|
+
});
|
|
36
53
|
const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
37
54
|
children,
|
|
38
55
|
placement = 'bottom',
|
|
@@ -42,6 +59,7 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
42
59
|
...rest
|
|
43
60
|
}, ref) {
|
|
44
61
|
const [popperEl, setPopperEl] = useState(null);
|
|
62
|
+
const [storedAnchorEl, setStoredAnchorEl] = useState(null);
|
|
45
63
|
const [arrowRef, setArrowRef] = useState(null);
|
|
46
64
|
const popoverRef = useCombinedRefs(ref, setPopperEl);
|
|
47
65
|
useOutsideClick(popperEl, e => {
|
|
@@ -54,42 +72,55 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
54
72
|
onClose();
|
|
55
73
|
}
|
|
56
74
|
});
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
open ? setStoredAnchorEl(anchorEl) : setStoredAnchorEl(null);
|
|
77
|
+
return () => setStoredAnchorEl(null);
|
|
78
|
+
}, [anchorEl, open]);
|
|
57
79
|
const {
|
|
58
80
|
styles,
|
|
59
81
|
attributes
|
|
60
|
-
} = usePopper(
|
|
82
|
+
} = usePopper(storedAnchorEl, popperEl, arrowRef, placement);
|
|
61
83
|
const props = {
|
|
62
84
|
open,
|
|
63
85
|
...rest,
|
|
64
86
|
...attributes.popper
|
|
65
87
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
const {
|
|
89
|
+
density
|
|
90
|
+
} = useEds();
|
|
91
|
+
const token = useToken({
|
|
92
|
+
density
|
|
93
|
+
}, popover);
|
|
94
|
+
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
95
|
+
theme: token,
|
|
96
|
+
children: /*#__PURE__*/jsxs(PopoverPaper, {
|
|
97
|
+
ref: popoverRef,
|
|
98
|
+
elevation: "overlay",
|
|
99
|
+
style: styles.popper,
|
|
100
|
+
"data-testid": "popover",
|
|
101
|
+
...props,
|
|
102
|
+
children: [/*#__PURE__*/jsx(ArrowWrapper, {
|
|
103
|
+
ref: setArrowRef,
|
|
104
|
+
style: styles.arrow,
|
|
105
|
+
className: "arrow",
|
|
106
|
+
children: /*#__PURE__*/jsx(PopoverArrow, {
|
|
107
|
+
className: "arrowSvg",
|
|
108
|
+
children: /*#__PURE__*/jsx("path", {
|
|
109
|
+
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
|
+
})
|
|
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
|
|
80
121
|
})
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
onClick: onClose,
|
|
84
|
-
variant: "ghost_icon",
|
|
85
|
-
"data-testid": "popover-close",
|
|
86
|
-
"aria-label": "Close popover",
|
|
87
|
-
children: /*#__PURE__*/jsx(Icon, {
|
|
88
|
-
name: "close",
|
|
89
|
-
data: close,
|
|
90
|
-
size: 24
|
|
91
|
-
})
|
|
92
|
-
})]
|
|
122
|
+
})]
|
|
123
|
+
})
|
|
93
124
|
});
|
|
94
125
|
});
|
|
95
126
|
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { popover } from './Popover.tokens.js';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
4
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
4
|
import { Divider } from '../Divider/Divider.js';
|
|
6
5
|
|
|
7
6
|
const StyledPopoverTitle = styled.div.withConfig({
|
|
8
7
|
displayName: "PopoverTitle__StyledPopoverTitle",
|
|
9
8
|
componentId: "sc-1ben8su-0"
|
|
10
|
-
})(
|
|
9
|
+
})(({
|
|
10
|
+
theme
|
|
11
|
+
}) => {
|
|
12
|
+
return css(["margin-right:", ";max-width:calc(", " - ", ");overflow:hidden;margin-top:-", ";"], theme.entities.closeButton.width, theme.maxWidth, theme.entities.closeButton.width, theme.entities.title.spacings.top);
|
|
13
|
+
});
|
|
11
14
|
const StyledDivider = styled(Divider).withConfig({
|
|
12
15
|
displayName: "PopoverTitle__StyledDivider",
|
|
13
16
|
componentId: "sc-1ben8su-1"
|
|
14
|
-
})(
|
|
17
|
+
})(({
|
|
18
|
+
theme
|
|
19
|
+
}) => {
|
|
20
|
+
return css(["margin-left:-", ";margin-right:-", ";margin-bottom:0;width:auto;max-width:", ";"], theme.spacings.left, theme.spacings.right, theme.maxWidth);
|
|
21
|
+
});
|
|
15
22
|
const PopoverTitle = /*#__PURE__*/forwardRef(function PopoverTitle({
|
|
16
23
|
children,
|
|
17
24
|
...rest
|
|
@@ -21,25 +21,26 @@ const ScrimContent = styled.div.withConfig({
|
|
|
21
21
|
const Scrim = /*#__PURE__*/forwardRef(function Scrim({
|
|
22
22
|
children,
|
|
23
23
|
onClose,
|
|
24
|
+
open,
|
|
24
25
|
isDismissable = false,
|
|
25
26
|
...rest
|
|
26
27
|
}, ref) {
|
|
27
28
|
const props = { ...rest,
|
|
29
|
+
open,
|
|
28
30
|
isDismissable,
|
|
29
31
|
ref
|
|
30
32
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onClose(e, false);
|
|
33
|
+
useHideBodyScroll(open);
|
|
34
|
+
useGlobalKeyPress('Escape', () => {
|
|
35
|
+
if (isDismissable && onClose && open) {
|
|
36
|
+
onClose();
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
const handleMouseClose = event => {
|
|
40
41
|
if (event) {
|
|
41
|
-
if (event.type === 'click' && isDismissable) {
|
|
42
|
-
onClose && onClose(
|
|
42
|
+
if (event.type === 'click' && isDismissable && open) {
|
|
43
|
+
onClose && onClose();
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
};
|
|
@@ -49,6 +50,10 @@ const Scrim = /*#__PURE__*/forwardRef(function Scrim({
|
|
|
49
50
|
event.stopPropagation();
|
|
50
51
|
};
|
|
51
52
|
|
|
53
|
+
if (!open) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
return /*#__PURE__*/jsx(StyledScrim, {
|
|
53
58
|
onClick: handleMouseClose,
|
|
54
59
|
...props,
|
|
@@ -1,49 +1,63 @@
|
|
|
1
1
|
import { forwardRef, useRef, useState, useEffect } from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
2
|
+
import styled, { css, ThemeProvider } from 'styled-components';
|
|
3
3
|
import { search as search$1, close } from '@equinor/eds-icons';
|
|
4
4
|
import { search } from './Search.tokens.js';
|
|
5
5
|
import { Icon } from '../Icon/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
7
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
|
|
8
8
|
import { setReactInputValue } from '../../utils/setReactInputValue.js';
|
|
9
9
|
import { bordersTemplate } from '../../utils/templates/borders.js';
|
|
10
10
|
import { spacingsTemplate, typographyTemplate } from '../../utils/templates/index.js';
|
|
11
|
+
import { Input } from '../Input/Input.js';
|
|
11
12
|
import { Button } from '../Button/Button.js';
|
|
13
|
+
import { useEds } from '../EdsProvider/eds.context.js';
|
|
14
|
+
import { useToken } from '../../hooks/useToken.js';
|
|
12
15
|
|
|
13
|
-
const {
|
|
14
|
-
height,
|
|
15
|
-
spacings,
|
|
16
|
-
background,
|
|
17
|
-
typography,
|
|
18
|
-
border,
|
|
19
|
-
clickbound,
|
|
20
|
-
entities: {
|
|
21
|
-
icon,
|
|
22
|
-
placeholder,
|
|
23
|
-
button
|
|
24
|
-
},
|
|
25
|
-
states
|
|
26
|
-
} = search;
|
|
27
16
|
const Container = styled.span.withConfig({
|
|
28
17
|
displayName: "Search__Container",
|
|
29
18
|
componentId: "sc-v8l23u-0"
|
|
30
|
-
})(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}) =>
|
|
35
|
-
const
|
|
36
|
-
|
|
19
|
+
})(({
|
|
20
|
+
disabled,
|
|
21
|
+
isFocused,
|
|
22
|
+
theme
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
height,
|
|
26
|
+
spacings,
|
|
27
|
+
background,
|
|
28
|
+
border,
|
|
29
|
+
clickbound,
|
|
30
|
+
entities: {
|
|
31
|
+
icon,
|
|
32
|
+
placeholder
|
|
33
|
+
},
|
|
34
|
+
states
|
|
35
|
+
} = theme;
|
|
36
|
+
return css(["position:relative;background:", ";width:100%;height:", ";display:grid;grid-gap:8px;grid-auto-flow:column;grid-auto-columns:max-content auto max-content;align-items:center;box-sizing:border-box;", " z-index:0;svg{fill:", ";}", " ", " &::placeholder{color:", ";}", " &::after{z-index:-1;position:absolute;top:-", ";left:0;width:100%;height:", ";content:'';}&::before{position:absolute;top:0;left:0;width:auto;min-height:auto;content:'';}"], background, height, bordersTemplate(border), icon.typography.color, spacingsTemplate(spacings), isFocused && bordersTemplate(states.focus.border), placeholder.typography.color, disabled ? css(["cursor:not-allowed;"]) : css(["@media (hover:hover) and (pointer:fine){&:hover{", " cursor:text;}}"], bordersTemplate(states.focus.border)), clickbound.offset, clickbound.height);
|
|
37
|
+
});
|
|
38
|
+
const SearchInput = styled(Input).withConfig({
|
|
39
|
+
displayName: "Search__SearchInput",
|
|
37
40
|
componentId: "sc-v8l23u-1"
|
|
38
|
-
})(
|
|
41
|
+
})(({
|
|
42
|
+
theme,
|
|
39
43
|
disabled
|
|
40
|
-
}) =>
|
|
44
|
+
}) => {
|
|
45
|
+
return css(["height:calc(", " - 2px);align-self:start;box-shadow:unset;&[type='search']::-webkit-search-decoration,&[type='search']::-webkit-search-cancel-button,&[type='search']::-webkit-search-results-button,&[type='search']::-webkit-search-results-decoration{-webkit-appearance:none;}", " &:focus{outline:none;}", ""], theme.height, typographyTemplate(theme.typography), disabled && css(["cursor:not-allowed;"]));
|
|
46
|
+
});
|
|
41
47
|
const InsideButton = styled(Button).withConfig({
|
|
42
48
|
displayName: "Search__InsideButton",
|
|
43
49
|
componentId: "sc-v8l23u-2"
|
|
44
|
-
})(
|
|
50
|
+
})(({
|
|
51
|
+
theme,
|
|
45
52
|
isActive
|
|
46
|
-
}) =>
|
|
53
|
+
}) => {
|
|
54
|
+
const {
|
|
55
|
+
entities: {
|
|
56
|
+
button
|
|
57
|
+
}
|
|
58
|
+
} = theme;
|
|
59
|
+
return css(["visibility:hidden;position:absolute;right:", ";height:", ";width:", ";", ""], button.spacings.right, button.height, button.width, isActive && css(["visibility:visible;"]));
|
|
60
|
+
});
|
|
47
61
|
const Search = /*#__PURE__*/forwardRef(function Search({
|
|
48
62
|
onChange,
|
|
49
63
|
defaultValue = '',
|
|
@@ -54,6 +68,12 @@ const Search = /*#__PURE__*/forwardRef(function Search({
|
|
|
54
68
|
onFocus,
|
|
55
69
|
...rest
|
|
56
70
|
}, ref) {
|
|
71
|
+
const {
|
|
72
|
+
density
|
|
73
|
+
} = useEds();
|
|
74
|
+
const token = useToken({
|
|
75
|
+
density
|
|
76
|
+
}, search);
|
|
57
77
|
const isControlled = typeof value !== 'undefined';
|
|
58
78
|
const isActive = isControlled && value !== '' || defaultValue !== '';
|
|
59
79
|
const inputRef = useRef(null);
|
|
@@ -161,21 +181,24 @@ const Search = /*#__PURE__*/forwardRef(function Search({
|
|
|
161
181
|
}
|
|
162
182
|
}
|
|
163
183
|
};
|
|
164
|
-
return /*#__PURE__*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
185
|
+
theme: token,
|
|
186
|
+
children: /*#__PURE__*/jsxs(Container, { ...containerProps,
|
|
187
|
+
children: [/*#__PURE__*/jsx(Icon, {
|
|
188
|
+
data: search$1,
|
|
189
|
+
"aria-hidden": true,
|
|
190
|
+
size: size
|
|
191
|
+
}), /*#__PURE__*/jsx(SearchInput, { ...inputProps
|
|
192
|
+
}), /*#__PURE__*/jsx(InsideButton, { ...clearButtonProps,
|
|
193
|
+
"aria-label": 'clear search',
|
|
194
|
+
title: "clear",
|
|
195
|
+
variant: "ghost_icon",
|
|
196
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
197
|
+
data: close,
|
|
198
|
+
size: 16
|
|
199
|
+
})
|
|
200
|
+
})]
|
|
201
|
+
})
|
|
179
202
|
});
|
|
180
203
|
}); // Search.displayName = 'eds-search'
|
|
181
204
|
|
|
@@ -30,7 +30,8 @@ const {
|
|
|
30
30
|
input: {
|
|
31
31
|
text: typography
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
shape
|
|
34
35
|
} = tokens;
|
|
35
36
|
const search = {
|
|
36
37
|
background,
|
|
@@ -44,9 +45,7 @@ const search = {
|
|
|
44
45
|
},
|
|
45
46
|
spacings: {
|
|
46
47
|
left: small,
|
|
47
|
-
right: small
|
|
48
|
-
top: '6px',
|
|
49
|
-
bottom: '6px'
|
|
48
|
+
right: small
|
|
50
49
|
},
|
|
51
50
|
border: {
|
|
52
51
|
type: 'border',
|
|
@@ -97,6 +96,11 @@ const search = {
|
|
|
97
96
|
right: small
|
|
98
97
|
}
|
|
99
98
|
}
|
|
99
|
+
},
|
|
100
|
+
modes: {
|
|
101
|
+
compact: {
|
|
102
|
+
height: shape._modes.compact.straight.minHeight
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
};
|
|
102
106
|
|
|
@@ -117,8 +117,9 @@ const MultiSelect = /*#__PURE__*/forwardRef(function MultiSelect({
|
|
|
117
117
|
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
118
118
|
case useCombobox.stateChangeTypes.ItemClick:
|
|
119
119
|
case useCombobox.stateChangeTypes.InputBlur:
|
|
120
|
+
setInputValue('');
|
|
121
|
+
|
|
120
122
|
if (selectedItem) {
|
|
121
|
-
setInputValue('');
|
|
122
123
|
selectedItems.includes(selectedItem) ? removeSelectedItem(selectedItem) : addSelectedItem(selectedItem);
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -134,6 +135,11 @@ const MultiSelect = /*#__PURE__*/forwardRef(function MultiSelect({
|
|
|
134
135
|
}
|
|
135
136
|
};
|
|
136
137
|
|
|
138
|
+
const handleClear = () => {
|
|
139
|
+
reset();
|
|
140
|
+
setInputValue('');
|
|
141
|
+
};
|
|
142
|
+
|
|
137
143
|
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
138
144
|
theme: token,
|
|
139
145
|
children: /*#__PURE__*/jsxs(Container, {
|
|
@@ -157,7 +163,7 @@ const MultiSelect = /*#__PURE__*/forwardRef(function MultiSelect({
|
|
|
157
163
|
disabled: disabled || readOnly,
|
|
158
164
|
"aria-label": 'clear options',
|
|
159
165
|
title: "clear",
|
|
160
|
-
onClick:
|
|
166
|
+
onClick: handleClear,
|
|
161
167
|
style: {
|
|
162
168
|
right: 32
|
|
163
169
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
-
import
|
|
2
|
+
import mergeDeepRight_1 from '../../node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/mergeDeepRight.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
typography,
|
|
@@ -55,6 +55,9 @@ const select = {
|
|
|
55
55
|
left: spacingSmall,
|
|
56
56
|
right: spacingSmall,
|
|
57
57
|
top: '6px'
|
|
58
|
+
},
|
|
59
|
+
typography: {
|
|
60
|
+
color: colors.text.static_icons__tertiary.rgba
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
},
|
|
@@ -78,7 +81,7 @@ const select = {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
|
-
const multiSelect =
|
|
84
|
+
const multiSelect = mergeDeepRight_1(select, {
|
|
82
85
|
spacings: {
|
|
83
86
|
top: '0',
|
|
84
87
|
bottom: '0',
|
|
@@ -44,7 +44,7 @@ const StyledButton = styled(Button).withConfig({
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}) => {
|
|
47
|
-
return css(["position:absolute;right:", ";height:", ";width:", ";top:", ";"], button.spacings.right, button.height, button.height, button.spacings.top);
|
|
47
|
+
return css(["position:absolute;right:", ";height:", ";width:", ";top:", ";color:", ";"], button.spacings.right, button.height, button.height, button.spacings.top, button.typography.color);
|
|
48
48
|
});
|
|
49
49
|
const StyledInputWrapper = styled.div.withConfig({
|
|
50
50
|
displayName: "commonStyles__StyledInputWrapper",
|