@equinor/eds-core-react 0.35.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eds-core-react.cjs +5582 -4353
- package/dist/esm/components/Accordion/Accordion.js +21 -23
- package/dist/esm/components/Accordion/Accordion.tokens.js +65 -23
- package/dist/esm/components/Accordion/AccordionHeader.js +74 -62
- package/dist/esm/components/Accordion/AccordionHeaderActions.js +22 -20
- package/dist/esm/components/Accordion/AccordionHeaderTitle.js +22 -20
- package/dist/esm/components/Accordion/AccordionItem.js +28 -35
- package/dist/esm/components/Accordion/AccordionPanel.js +27 -26
- package/dist/esm/components/Accordion/index.js +1 -1
- package/dist/esm/components/Autocomplete/Autocomplete.js +451 -329
- package/dist/esm/components/Autocomplete/Autocomplete.tokens.js +33 -17
- package/dist/esm/components/Autocomplete/Option.js +35 -32
- package/dist/esm/components/Avatar/Avatar.js +19 -26
- package/dist/esm/components/Avatar/Avatar.tokens.js +1 -1
- package/dist/esm/components/Banner/Banner.js +26 -27
- package/dist/esm/components/Banner/Banner.tokens.js +47 -18
- package/dist/esm/components/Banner/BannerActions.js +18 -19
- package/dist/esm/components/Banner/BannerIcon.js +26 -25
- package/dist/esm/components/Banner/BannerMessage.js +13 -14
- package/dist/esm/components/Banner/index.js +1 -1
- package/dist/esm/components/Breadcrumbs/Breadcrumb.js +30 -32
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +46 -53
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.tokens.js +20 -5
- package/dist/esm/components/Breadcrumbs/index.js +1 -1
- package/dist/esm/components/Button/Button.js +46 -46
- package/dist/esm/components/Button/ButtonGroup/ButtonGroup.js +22 -22
- package/dist/esm/components/Button/ButtonGroup/ButtonGroup.tokens.js +8 -2
- package/dist/esm/components/Button/InnerFullWidth.js +8 -10
- package/dist/esm/components/Button/ToggleButton/ToggleButton.js +23 -33
- package/dist/esm/components/Button/index.js +1 -1
- package/dist/esm/components/Button/tokens/button.js +62 -31
- package/dist/esm/components/Button/tokens/contained.js +38 -14
- package/dist/esm/components/Button/tokens/contained_icon.js +13 -10
- package/dist/esm/components/Button/tokens/ghost.js +36 -13
- package/dist/esm/components/Button/tokens/icon.js +46 -20
- package/dist/esm/components/Button/tokens/index.js +1 -1
- package/dist/esm/components/Button/tokens/outlined.js +42 -15
- package/dist/esm/components/Card/Card.js +24 -27
- package/dist/esm/components/Card/Card.tokens.js +32 -11
- package/dist/esm/components/Card/CardActions.js +22 -23
- package/dist/esm/components/Card/CardContent.js +12 -12
- package/dist/esm/components/Card/CardHeader.js +15 -13
- package/dist/esm/components/Card/CardHeaderTitle.js +12 -12
- package/dist/esm/components/Card/CardMedia.js +20 -20
- package/dist/esm/components/Card/index.js +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js +20 -21
- package/dist/esm/components/Checkbox/Checkbox.tokens.js +41 -16
- package/dist/esm/components/Checkbox/Input.js +75 -84
- package/dist/esm/components/Chip/Chip.js +61 -64
- package/dist/esm/components/Chip/Chip.tokens.js +68 -26
- package/dist/esm/components/Chip/Icon.js +13 -11
- package/dist/esm/components/Dialog/Dialog.js +34 -35
- package/dist/esm/components/Dialog/Dialog.tokens.js +32 -10
- package/dist/esm/components/Dialog/DialogActions.js +13 -14
- package/dist/esm/components/Dialog/DialogContent.js +19 -20
- package/dist/esm/components/Dialog/DialogHeader.js +16 -15
- package/dist/esm/components/Dialog/DialogTitle.js +13 -14
- package/dist/esm/components/Dialog/index.js +1 -1
- package/dist/esm/components/Divider/Divider.js +24 -25
- package/dist/esm/components/Divider/Divider.tokens.js +24 -10
- package/dist/esm/components/EdsProvider/eds.context.js +18 -26
- package/dist/esm/components/Icon/Icon.js +75 -78
- package/dist/esm/components/Icon/index.js +1 -1
- package/dist/esm/components/Icon/library.js +9 -8
- package/dist/esm/components/Input/Input.js +93 -92
- package/dist/esm/components/Input/Input.tokens.js +56 -40
- package/dist/esm/components/InputWrapper/HelperText/HelperText.js +24 -28
- package/dist/esm/components/InputWrapper/HelperText/HelperText.token.js +11 -7
- package/dist/esm/components/InputWrapper/InputWrapper.js +34 -35
- package/dist/esm/components/InputWrapper/InputWrapper.tokens.js +56 -40
- package/dist/esm/components/Label/Label.js +16 -20
- package/dist/esm/components/Label/Label.tokens.js +11 -7
- package/dist/esm/components/List/List.js +17 -19
- package/dist/esm/components/List/List.tokens.js +6 -2
- package/dist/esm/components/List/ListItem.js +7 -8
- package/dist/esm/components/List/index.js +1 -1
- package/dist/esm/components/Menu/Menu.context.js +35 -42
- package/dist/esm/components/Menu/Menu.js +111 -108
- package/dist/esm/components/Menu/Menu.tokens.js +57 -24
- package/dist/esm/components/Menu/MenuItem.js +59 -61
- package/dist/esm/components/Menu/MenuList.js +52 -55
- package/dist/esm/components/Menu/MenuSection.js +9 -9
- package/dist/esm/components/Menu/index.js +1 -1
- package/dist/esm/components/Pagination/Pagination.js +70 -75
- package/dist/esm/components/Pagination/Pagination.tokens.js +18 -5
- package/dist/esm/components/Pagination/PaginationItem.js +18 -19
- package/dist/esm/components/Pagination/paginationControl.js +18 -22
- package/dist/esm/components/Paper/Paper.js +15 -18
- package/dist/esm/components/Paper/Paper.tokens.js +12 -4
- package/dist/esm/components/Popover/Popover.js +98 -87
- package/dist/esm/components/Popover/Popover.tokens.js +37 -11
- package/dist/esm/components/Popover/PopoverActions.js +15 -14
- package/dist/esm/components/Popover/PopoverContent.js +15 -14
- package/dist/esm/components/Popover/PopoverHeader.js +16 -15
- package/dist/esm/components/Popover/PopoverTitle.js +15 -14
- package/dist/esm/components/Popover/index.js +1 -1
- package/dist/esm/components/Progress/Circular/CircularProgress.js +33 -42
- package/dist/esm/components/Progress/Circular/CircularProgress.tokens.js +24 -8
- package/dist/esm/components/Progress/Dots/DotProgress.js +20 -23
- package/dist/esm/components/Progress/Dots/DotProgress.tokens.js +20 -8
- package/dist/esm/components/Progress/Linear/LinearProgress.js +25 -31
- package/dist/esm/components/Progress/Linear/LinearProgress.tokens.js +13 -4
- package/dist/esm/components/Progress/Star/StarProgress.js +23 -27
- package/dist/esm/components/Progress/Star/StarProgress.tokens.js +10 -2
- package/dist/esm/components/Progress/index.js +1 -1
- package/dist/esm/components/Radio/Radio.js +71 -83
- package/dist/esm/components/Radio/Radio.tokens.js +41 -16
- package/dist/esm/components/Scrim/Scrim.js +20 -23
- package/dist/esm/components/Scrim/Scrim.tokens.js +11 -3
- package/dist/esm/components/Search/Search.js +24 -31
- package/dist/esm/components/Select/NativeSelect.js +45 -44
- package/dist/esm/components/Select/NativeSelect.tokens.js +15 -10
- package/dist/esm/components/SideBar/SideBar.context.js +27 -33
- package/dist/esm/components/SideBar/SideBar.js +42 -40
- package/dist/esm/components/SideBar/SideBar.tokens.js +49 -20
- package/dist/esm/components/SideBar/SideBarAccordion/index.js +98 -90
- package/dist/esm/components/SideBar/SideBarAccordionItem/index.js +46 -33
- package/dist/esm/components/SideBar/SideBarButton/index.js +61 -45
- package/dist/esm/components/SideBar/SideBarContent.js +13 -13
- package/dist/esm/components/SideBar/SideBarFooter.js +13 -13
- package/dist/esm/components/SideBar/SideBarToggle.js +40 -26
- package/dist/esm/components/SideBar/SidebarLink/index.js +87 -48
- package/dist/esm/components/SideBar/index.js +1 -1
- package/dist/esm/components/SideSheet/SideSheet.js +27 -27
- package/dist/esm/components/SideSheet/SideSheet.tokens.js +29 -12
- package/dist/esm/components/Slider/MinMax.js +10 -6
- package/dist/esm/components/Slider/Output.js +15 -18
- package/dist/esm/components/Slider/Slider.js +157 -188
- package/dist/esm/components/Slider/Slider.tokens.js +67 -19
- package/dist/esm/components/Slider/SliderInput.js +37 -34
- package/dist/esm/components/Snackbar/Snackbar.js +39 -45
- package/dist/esm/components/Snackbar/Snackbar.tokens.js +45 -17
- package/dist/esm/components/Snackbar/SnackbarAction.js +15 -14
- package/dist/esm/components/Snackbar/index.js +1 -1
- package/dist/esm/components/Switch/Switch.js +37 -42
- package/dist/esm/components/Switch/Switch.styles.js +17 -20
- package/dist/esm/components/Switch/Switch.tokens.js +66 -21
- package/dist/esm/components/Switch/SwitchDefault.js +38 -36
- package/dist/esm/components/Switch/SwitchSmall.js +38 -33
- package/dist/esm/components/Table/Body.js +8 -9
- package/dist/esm/components/Table/Caption.js +12 -14
- package/dist/esm/components/Table/Cell.js +15 -14
- package/dist/esm/components/Table/DataCell/DataCell.js +27 -26
- package/dist/esm/components/Table/DataCell/DataCell.tokens.js +79 -38
- package/dist/esm/components/Table/Head/Head.js +10 -11
- package/dist/esm/components/Table/Head/Head.tokens.js +15 -4
- package/dist/esm/components/Table/HeaderCell/HeaderCell.js +37 -33
- package/dist/esm/components/Table/HeaderCell/HeaderCell.tokens.js +65 -28
- package/dist/esm/components/Table/Inner.context.js +2 -2
- package/dist/esm/components/Table/Row/Row.js +12 -16
- package/dist/esm/components/Table/Row/Row.tokens.js +13 -4
- package/dist/esm/components/Table/Table.js +8 -9
- package/dist/esm/components/Table/index.js +1 -1
- package/dist/esm/components/TableOfContents/LinkItem.js +11 -11
- package/dist/esm/components/TableOfContents/TableOfContents.js +25 -26
- package/dist/esm/components/TableOfContents/TableOfContents.tokens.js +46 -21
- package/dist/esm/components/TableOfContents/index.js +1 -1
- package/dist/esm/components/Tabs/Tab.js +30 -29
- package/dist/esm/components/Tabs/TabList.js +50 -62
- package/dist/esm/components/Tabs/TabPanel.js +19 -18
- package/dist/esm/components/Tabs/TabPanels.js +16 -17
- package/dist/esm/components/Tabs/Tabs.context.js +3 -5
- package/dist/esm/components/Tabs/Tabs.js +37 -53
- package/dist/esm/components/Tabs/Tabs.tokens.js +56 -21
- package/dist/esm/components/Tabs/index.js +1 -1
- package/dist/esm/components/TextField/TextField.js +64 -59
- package/dist/esm/components/Textarea/Textarea.js +38 -38
- package/dist/esm/components/Tooltip/Tooltip.js +79 -81
- package/dist/esm/components/Tooltip/Tooltip.tokens.js +33 -13
- package/dist/esm/components/TopBar/Actions.js +9 -11
- package/dist/esm/components/TopBar/CustomContent.js +9 -11
- package/dist/esm/components/TopBar/Header.js +9 -11
- package/dist/esm/components/TopBar/TopBar.js +24 -25
- package/dist/esm/components/TopBar/TopBar.tokens.js +10 -4
- package/dist/esm/components/TopBar/index.js +1 -1
- package/dist/esm/components/Typography/Typography.js +42 -54
- package/dist/esm/components/Typography/Typography.tokens.js +50 -23
- package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isPlaceholder.js +1 -3
- package/dist/types/components/Accordion/Accordion.types.d.ts +1 -1
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +13 -0
- package/dist/types/components/Autocomplete/Option.d.ts +1 -0
- package/dist/types/components/Slider/Slider.d.ts +11 -3
- package/package.json +6 -7
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
1
|
import { forwardRef } from 'react';
|
|
4
2
|
import { useId } from '@equinor/eds-utils';
|
|
5
3
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -7,84 +5,91 @@ import { InputWrapper } from '../InputWrapper/InputWrapper.js';
|
|
|
7
5
|
import { Textarea } from '../Textarea/Textarea.js';
|
|
8
6
|
import { Input } from '../Input/Input.js';
|
|
9
7
|
|
|
10
|
-
var _excluded = ["id", "label", "meta", "unit", "helperText", "placeholder", "disabled", "multiline", "className", "variant", "inputIcon", "helperIcon", "style", "rowsMax", "textareaRef", "inputRef"];
|
|
11
8
|
/** Proxy component for working around typescript and element type switching */
|
|
12
|
-
|
|
13
|
-
return props.$multiline ? /*#__PURE__*/jsx(Textarea,
|
|
14
|
-
ref: ref
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const Field = /*#__PURE__*/forwardRef(function Field(props, ref) {
|
|
10
|
+
return props.$multiline ? /*#__PURE__*/jsx(Textarea, {
|
|
11
|
+
ref: ref,
|
|
12
|
+
...props
|
|
13
|
+
}) : /*#__PURE__*/jsx(Input, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
18
17
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
const TextField = /*#__PURE__*/forwardRef(function TextField({
|
|
19
|
+
id,
|
|
20
|
+
label,
|
|
21
|
+
meta,
|
|
22
|
+
unit,
|
|
23
|
+
helperText,
|
|
24
|
+
placeholder,
|
|
25
|
+
disabled,
|
|
26
|
+
multiline = false,
|
|
27
|
+
className,
|
|
28
|
+
variant,
|
|
29
|
+
inputIcon,
|
|
30
|
+
helperIcon,
|
|
31
|
+
style,
|
|
32
|
+
rowsMax,
|
|
33
|
+
textareaRef,
|
|
34
|
+
inputRef,
|
|
35
|
+
...other
|
|
36
|
+
}, ref) {
|
|
37
|
+
const helperTextId = useId(null, 'helpertext');
|
|
38
|
+
let fieldProps = {
|
|
40
39
|
'aria-invalid': variant === 'error' || undefined,
|
|
41
|
-
disabled
|
|
42
|
-
placeholder
|
|
43
|
-
id
|
|
44
|
-
variant
|
|
40
|
+
disabled,
|
|
41
|
+
placeholder,
|
|
42
|
+
id,
|
|
43
|
+
variant,
|
|
45
44
|
rightAdornments: /*#__PURE__*/jsxs(Fragment, {
|
|
46
45
|
children: [inputIcon, /*#__PURE__*/jsx("span", {
|
|
47
46
|
children: unit
|
|
48
47
|
})]
|
|
49
48
|
}),
|
|
50
|
-
rowsMax
|
|
49
|
+
rowsMax,
|
|
51
50
|
ref: inputRef || textareaRef,
|
|
52
|
-
$multiline: multiline
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
$multiline: multiline,
|
|
52
|
+
...other
|
|
53
|
+
};
|
|
54
|
+
let helperProps = {
|
|
55
55
|
id: null,
|
|
56
56
|
text: helperText,
|
|
57
57
|
icon: helperIcon,
|
|
58
|
-
disabled
|
|
58
|
+
disabled
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
ref
|
|
62
|
-
className
|
|
63
|
-
style:
|
|
64
|
-
width: '100%'
|
|
65
|
-
|
|
60
|
+
const containerProps = {
|
|
61
|
+
ref,
|
|
62
|
+
className,
|
|
63
|
+
style: {
|
|
64
|
+
width: '100%',
|
|
65
|
+
...style
|
|
66
|
+
},
|
|
66
67
|
color: variant
|
|
67
68
|
};
|
|
68
|
-
|
|
69
|
+
const labelProps = {
|
|
69
70
|
htmlFor: id,
|
|
70
|
-
label
|
|
71
|
-
meta
|
|
72
|
-
disabled
|
|
71
|
+
label,
|
|
72
|
+
meta,
|
|
73
|
+
disabled
|
|
73
74
|
};
|
|
74
75
|
if (helperText) {
|
|
75
|
-
fieldProps =
|
|
76
|
-
'aria-describedby': helperTextId
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
fieldProps = {
|
|
77
|
+
'aria-describedby': helperTextId,
|
|
78
|
+
...fieldProps
|
|
79
|
+
};
|
|
80
|
+
helperProps = {
|
|
81
|
+
...helperProps,
|
|
79
82
|
id: helperTextId
|
|
80
|
-
}
|
|
83
|
+
};
|
|
81
84
|
}
|
|
82
|
-
return /*#__PURE__*/jsx(InputWrapper,
|
|
85
|
+
return /*#__PURE__*/jsx(InputWrapper, {
|
|
83
86
|
helperProps: helperProps,
|
|
84
|
-
labelProps: labelProps
|
|
85
|
-
|
|
86
|
-
children: /*#__PURE__*/jsx(Field,
|
|
87
|
-
|
|
87
|
+
labelProps: labelProps,
|
|
88
|
+
...containerProps,
|
|
89
|
+
children: /*#__PURE__*/jsx(Field, {
|
|
90
|
+
...fieldProps
|
|
91
|
+
})
|
|
92
|
+
});
|
|
88
93
|
});
|
|
89
94
|
|
|
90
95
|
export { TextField };
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
1
|
import { forwardRef, useState, useCallback } from 'react';
|
|
2
|
+
import * as Input_tokens from '../Input/Input.tokens.js';
|
|
5
3
|
import { input as input$1 } from '../Input/Input.tokens.js';
|
|
6
4
|
import { useAutoResize, mergeRefs } from '@equinor/eds-utils';
|
|
7
5
|
import { jsx } from 'react/jsx-runtime';
|
|
8
6
|
import { Input } from '../Input/Input.js';
|
|
9
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
const {
|
|
10
|
+
input
|
|
11
|
+
} = Input_tokens;
|
|
12
|
+
const Textarea = /*#__PURE__*/forwardRef(function Textarea({
|
|
13
|
+
variant,
|
|
14
|
+
disabled = false,
|
|
15
|
+
type = 'text',
|
|
16
|
+
rowsMax,
|
|
17
|
+
...other
|
|
18
|
+
}, ref) {
|
|
19
|
+
const [textareaEl, setTextareaEl] = useState(null);
|
|
20
|
+
const {
|
|
21
|
+
density
|
|
22
|
+
} = useEds();
|
|
23
|
+
const spacings = density === 'compact' ? input.modes.compact.spacings : input.spacings;
|
|
24
|
+
const {
|
|
25
|
+
lineHeight
|
|
26
|
+
} = input$1.typography;
|
|
27
|
+
const {
|
|
28
|
+
top,
|
|
29
|
+
bottom
|
|
30
|
+
} = spacings;
|
|
31
|
+
let fontSize = 16;
|
|
32
32
|
if (textareaEl) {
|
|
33
33
|
fontSize = parseInt(window.getComputedStyle(textareaEl).fontSize);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const padding = parseInt(top) + parseInt(bottom);
|
|
36
|
+
const maxHeight = parseFloat(lineHeight) * fontSize * rowsMax + padding;
|
|
37
37
|
useAutoResize(textareaEl, rowsMax ? maxHeight : null);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, [setTextareaEl, ref])();
|
|
41
|
-
var inputProps = _objectSpread({
|
|
38
|
+
const combinedRef = useCallback(() => mergeRefs(ref, setTextareaEl), [setTextareaEl, ref])();
|
|
39
|
+
const inputProps = {
|
|
42
40
|
ref: combinedRef,
|
|
43
|
-
type
|
|
44
|
-
disabled
|
|
45
|
-
variant
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
type,
|
|
42
|
+
disabled,
|
|
43
|
+
variant,
|
|
44
|
+
...other
|
|
45
|
+
};
|
|
46
|
+
const adornmentsToTop = {
|
|
48
47
|
style: {
|
|
49
48
|
alignItems: 'flex-start'
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
|
-
return /*#__PURE__*/jsx(Input,
|
|
51
|
+
return /*#__PURE__*/jsx(Input, {
|
|
53
52
|
as: "textarea",
|
|
54
53
|
rightAdornmentsProps: adornmentsToTop,
|
|
55
54
|
leftAdornmentsProps: adornmentsToTop,
|
|
56
55
|
style: {
|
|
57
56
|
height: 'auto'
|
|
58
|
-
}
|
|
59
|
-
|
|
57
|
+
},
|
|
58
|
+
...inputProps
|
|
59
|
+
});
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
export { Textarea };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
1
|
import { forwardRef, useRef, useState, useMemo, useEffect, cloneElement } from 'react';
|
|
6
2
|
import styled from 'styled-components';
|
|
7
3
|
import { typographyTemplate, spacingsTemplate, bordersTemplate, mergeRefs, useIsInDialog } from '@equinor/eds-utils';
|
|
@@ -9,78 +5,73 @@ import { tooltip } from './Tooltip.tokens.js';
|
|
|
9
5
|
import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useHover, useFocus, useRole, useDismiss, FloatingPortal } from '@floating-ui/react';
|
|
10
6
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
var StyledTooltip = styled.div.withConfig({
|
|
8
|
+
const StyledTooltip = styled.div.withConfig({
|
|
14
9
|
displayName: "Tooltip__StyledTooltip",
|
|
15
10
|
componentId: "sc-m2im2p-0"
|
|
16
11
|
})(["", " ", " ", " background:", ";z-index:1500;white-space:nowrap;&::before{content:'; Has tooltip: ';clip-path:inset(50%);height:1px;width:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;}"], typographyTemplate(tooltip.typography), spacingsTemplate(tooltip.spacings), bordersTemplate(tooltip.border), tooltip.background);
|
|
17
|
-
|
|
12
|
+
const ArrowWrapper = styled.div.withConfig({
|
|
18
13
|
displayName: "Tooltip__ArrowWrapper",
|
|
19
14
|
componentId: "sc-m2im2p-1"
|
|
20
15
|
})(["position:absolute;width:", ";height:", ";z-index:-1;"], tooltip.entities.arrow.width, tooltip.entities.arrow.height);
|
|
21
|
-
|
|
16
|
+
const TooltipArrow = styled.svg.withConfig({
|
|
22
17
|
displayName: "Tooltip__TooltipArrow",
|
|
23
18
|
componentId: "sc-m2im2p-2"
|
|
24
19
|
})(["width:", ";height:", ";position:absolute;fill:", ";"], tooltip.entities.arrow.width, tooltip.entities.arrow.height, tooltip.background);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
getReferenceProps = _useInteractions.getReferenceProps,
|
|
75
|
-
getFloatingProps = _useInteractions.getFloatingProps;
|
|
76
|
-
useEffect(function () {
|
|
77
|
-
var staticSide = {
|
|
20
|
+
const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
|
|
21
|
+
title,
|
|
22
|
+
placement = 'bottom',
|
|
23
|
+
children,
|
|
24
|
+
style,
|
|
25
|
+
enterDelay = 100,
|
|
26
|
+
...rest
|
|
27
|
+
}, ref) {
|
|
28
|
+
const arrowRef = useRef(null);
|
|
29
|
+
const [open, setOpen] = useState(false);
|
|
30
|
+
const shouldOpen = title !== '';
|
|
31
|
+
const {
|
|
32
|
+
x,
|
|
33
|
+
y,
|
|
34
|
+
refs,
|
|
35
|
+
strategy,
|
|
36
|
+
context,
|
|
37
|
+
middlewareData: {
|
|
38
|
+
arrow: {
|
|
39
|
+
x: arrowX,
|
|
40
|
+
y: arrowY
|
|
41
|
+
} = {}
|
|
42
|
+
},
|
|
43
|
+
placement: finalPlacement
|
|
44
|
+
} = useFloating({
|
|
45
|
+
placement,
|
|
46
|
+
open,
|
|
47
|
+
onOpenChange: setOpen,
|
|
48
|
+
middleware: [offset(14), flip(), shift({
|
|
49
|
+
padding: 8
|
|
50
|
+
}), arrow({
|
|
51
|
+
element: arrowRef
|
|
52
|
+
})],
|
|
53
|
+
whileElementsMounted: autoUpdate
|
|
54
|
+
});
|
|
55
|
+
const anchorRef = useMemo(() => mergeRefs(refs.setReference, children?.ref), [refs.setReference, children?.ref]);
|
|
56
|
+
const tooltipRef = useMemo(() => mergeRefs(refs.setFloating, ref), [refs.setFloating, ref]);
|
|
57
|
+
const {
|
|
58
|
+
getReferenceProps,
|
|
59
|
+
getFloatingProps
|
|
60
|
+
} = useInteractions([useHover(context, {
|
|
61
|
+
delay: {
|
|
62
|
+
open: enterDelay
|
|
63
|
+
}
|
|
64
|
+
}), useFocus(context), useRole(context, {
|
|
65
|
+
role: 'tooltip'
|
|
66
|
+
}), useDismiss(context)]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const staticSide = {
|
|
78
69
|
top: 'bottom',
|
|
79
70
|
right: 'left',
|
|
80
71
|
bottom: 'top',
|
|
81
72
|
left: 'right'
|
|
82
73
|
}[finalPlacement.split('-')[0]];
|
|
83
|
-
|
|
74
|
+
let arrowTransform = 'none';
|
|
84
75
|
switch (staticSide) {
|
|
85
76
|
case 'right':
|
|
86
77
|
arrowTransform = 'rotateY(180deg)';
|
|
@@ -96,29 +87,36 @@ var Tooltip = /*#__PURE__*/forwardRef(function Tooltip(_ref, ref) {
|
|
|
96
87
|
break;
|
|
97
88
|
}
|
|
98
89
|
if (arrowRef.current) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
top: arrowY != null ? "".concat(arrowY, "px") : '',
|
|
90
|
+
Object.assign(arrowRef.current.style, {
|
|
91
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
92
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
103
93
|
right: '',
|
|
104
|
-
bottom: ''
|
|
105
|
-
|
|
94
|
+
bottom: '',
|
|
95
|
+
[staticSide]: '-6px',
|
|
96
|
+
transform: arrowTransform
|
|
97
|
+
});
|
|
106
98
|
}
|
|
107
99
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
const updatedChildren = /*#__PURE__*/cloneElement(children, {
|
|
101
|
+
...getReferenceProps({
|
|
102
|
+
ref: anchorRef,
|
|
103
|
+
...children.props
|
|
104
|
+
})
|
|
105
|
+
});
|
|
111
106
|
|
|
112
107
|
//temporary fix for tooltip inside dialog. Should be replaced by popover api when it is ready
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
const inDialog = useIsInDialog(refs.domReference.current);
|
|
109
|
+
const TooltipEl = /*#__PURE__*/jsxs(StyledTooltip, {
|
|
110
|
+
...rest,
|
|
111
|
+
...getFloatingProps({
|
|
112
|
+
ref: tooltipRef,
|
|
113
|
+
style: {
|
|
114
|
+
...style,
|
|
115
|
+
position: strategy,
|
|
116
|
+
top: y || 0,
|
|
117
|
+
left: x || 0
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
122
120
|
children: [title, /*#__PURE__*/jsx(ArrowWrapper, {
|
|
123
121
|
ref: arrowRef,
|
|
124
122
|
children: /*#__PURE__*/jsx(TooltipArrow, {
|
|
@@ -128,7 +126,7 @@ var Tooltip = /*#__PURE__*/forwardRef(function Tooltip(_ref, ref) {
|
|
|
128
126
|
})
|
|
129
127
|
})
|
|
130
128
|
})]
|
|
131
|
-
})
|
|
129
|
+
});
|
|
132
130
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
133
131
|
children: [inDialog ? /*#__PURE__*/jsx(Fragment, {
|
|
134
132
|
children: shouldOpen && open && TooltipEl
|
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
1
|
import { tokens } from '@equinor/eds-tokens';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
const {
|
|
4
|
+
colors: {
|
|
5
|
+
text: {
|
|
6
|
+
static_icons__primary_white: {
|
|
7
|
+
rgba: white
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
ui: {
|
|
11
|
+
background__overlay: {
|
|
12
|
+
rgba: background
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
typography: {
|
|
17
|
+
ui
|
|
18
|
+
},
|
|
19
|
+
spacings: {
|
|
20
|
+
comfortable: {
|
|
21
|
+
x_large: spacingXlarge,
|
|
22
|
+
small: spacingSmall
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
shape: {
|
|
26
|
+
corners: {
|
|
27
|
+
borderRadius
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} = tokens;
|
|
31
|
+
const tooltip = {
|
|
32
|
+
typography: {
|
|
33
|
+
...ui.tooltip,
|
|
14
34
|
color: white
|
|
15
|
-
}
|
|
16
|
-
background
|
|
35
|
+
},
|
|
36
|
+
background,
|
|
17
37
|
border: {
|
|
18
38
|
type: 'border',
|
|
19
39
|
radius: borderRadius
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
1
|
import { forwardRef } from 'react';
|
|
4
2
|
import styled from 'styled-components';
|
|
5
3
|
import { jsx } from 'react/jsx-runtime';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
var StyledActions = styled.div.withConfig({
|
|
5
|
+
const StyledActions = styled.div.withConfig({
|
|
9
6
|
displayName: "Actions__StyledActions",
|
|
10
7
|
componentId: "sc-1251ang-0"
|
|
11
8
|
})(["grid-area:right;text-align:right;align-items:center;display:flex;"]);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const Actions = /*#__PURE__*/forwardRef(function Actions({
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}, ref) {
|
|
13
|
+
return /*#__PURE__*/jsx(StyledActions, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
...props,
|
|
18
16
|
children: children
|
|
19
|
-
})
|
|
17
|
+
});
|
|
20
18
|
});
|
|
21
19
|
|
|
22
20
|
// Actions.displayName = 'eds-topbar-actions'
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
1
|
import { forwardRef } from 'react';
|
|
4
2
|
import styled from 'styled-components';
|
|
5
3
|
import { jsx } from 'react/jsx-runtime';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
var StyledCustomContent = styled.div.withConfig({
|
|
5
|
+
const StyledCustomContent = styled.div.withConfig({
|
|
9
6
|
displayName: "CustomContent__StyledCustomContent",
|
|
10
7
|
componentId: "sc-d0e83a-0"
|
|
11
8
|
})(["grid-area:center;"]);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const CustomContent = /*#__PURE__*/forwardRef(function CustomContent({
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}, ref) {
|
|
13
|
+
return /*#__PURE__*/jsx(StyledCustomContent, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
...props,
|
|
18
16
|
children: children
|
|
19
|
-
})
|
|
17
|
+
});
|
|
20
18
|
});
|
|
21
19
|
|
|
22
20
|
// CustomContent.displayName = 'eds-topbar-customcontent'
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
1
|
import { forwardRef } from 'react';
|
|
4
2
|
import styled from 'styled-components';
|
|
5
3
|
import { jsx } from 'react/jsx-runtime';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
var StyledHeader = styled.div.withConfig({
|
|
5
|
+
const StyledHeader = styled.div.withConfig({
|
|
9
6
|
displayName: "Header__StyledHeader",
|
|
10
7
|
componentId: "sc-1fpllve-0"
|
|
11
8
|
})(["grid-area:left;display:grid;grid-template-columns:auto auto;grid-gap:12px;align-items:center;"]);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
const Header = /*#__PURE__*/forwardRef(function Header({
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}, ref) {
|
|
13
|
+
return /*#__PURE__*/jsx(StyledHeader, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
...props,
|
|
18
16
|
children: children
|
|
19
|
-
})
|
|
17
|
+
});
|
|
20
18
|
});
|
|
21
19
|
|
|
22
20
|
// Header.displayName = 'eds-topbar-header'
|