@equinor/eds-core-react 0.18.0-envis.1 → 0.19.0-dev.20220404
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.js +2321 -1964
- package/dist/esm/components/Accordion/Accordion.js +9 -9
- package/dist/esm/components/Accordion/Accordion.tokens.js +6 -1
- package/dist/esm/components/Accordion/AccordionHeader.js +61 -49
- package/dist/esm/components/Accordion/AccordionHeaderTitle.js +12 -10
- package/dist/esm/components/Accordion/AccordionItem.js +11 -10
- package/dist/esm/components/Accordion/AccordionPanel.js +22 -18
- package/dist/esm/components/Avatar/Avatar.js +21 -14
- package/dist/esm/components/Banner/Banner.js +12 -11
- package/dist/esm/components/Banner/BannerActions.js +11 -9
- package/dist/esm/components/Banner/BannerIcon.js +12 -10
- package/dist/esm/components/Banner/BannerMessage.js +5 -4
- package/dist/esm/components/Breadcrumbs/Breadcrumb.js +16 -12
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +7 -6
- package/dist/esm/components/Button/Button.js +17 -18
- package/dist/esm/components/Button/InnerFullWidth.js +5 -4
- package/dist/esm/components/Button/tokens/button.js +15 -25
- package/dist/esm/components/Button/tokens/contained.js +5 -5
- package/dist/esm/components/Button/tokens/ghost.js +4 -4
- package/dist/esm/components/Button/tokens/icon.js +11 -6
- package/dist/esm/components/Button/tokens/outlined.js +5 -5
- package/dist/esm/components/Card/Card.js +19 -12
- package/dist/esm/components/Card/CardActions.js +13 -9
- package/dist/esm/components/Card/CardContent.js +5 -4
- package/dist/esm/components/Card/CardHeader.js +5 -4
- package/dist/esm/components/Card/CardHeaderTitle.js +5 -4
- package/dist/esm/components/Card/CardMedia.js +12 -8
- package/dist/esm/components/Checkbox/Checkbox.js +15 -11
- package/dist/esm/components/Checkbox/Checkbox.tokens.js +9 -4
- package/dist/esm/components/Checkbox/Input.js +72 -46
- package/dist/esm/components/Chip/Chip.js +46 -30
- package/dist/esm/components/Chip/Chip.tokens.js +7 -2
- package/dist/esm/components/Chip/Icon.js +12 -7
- package/dist/esm/components/Dialog/Dialog.js +44 -20
- package/dist/esm/components/Dialog/Dialog.tokens.js +4 -12
- package/dist/esm/components/Dialog/DialogActions.js +27 -0
- package/dist/esm/components/Dialog/DialogContent.js +44 -0
- package/dist/esm/components/Dialog/DialogHeader.js +37 -0
- package/dist/esm/components/Dialog/DialogTitle.js +31 -0
- package/dist/esm/components/Dialog/index.js +11 -7
- package/dist/esm/components/Divider/Divider.js +6 -5
- package/dist/esm/components/EdsProvider/eds.context.js +5 -4
- package/dist/esm/components/Icon/Icon.js +77 -46
- package/dist/esm/components/Input/Input.js +12 -12
- package/dist/esm/components/Input/Input.tokens.js +4 -4
- package/dist/esm/components/Label/Label.js +7 -4
- package/dist/esm/components/List/List.js +13 -9
- package/dist/esm/components/List/ListItem.js +5 -4
- package/dist/esm/components/Menu/Menu.context.js +16 -4
- package/dist/esm/components/Menu/Menu.js +71 -30
- package/dist/esm/components/Menu/MenuItem.js +38 -25
- package/dist/esm/components/Menu/MenuList.js +18 -11
- package/dist/esm/components/Menu/MenuSection.js +1 -1
- package/dist/esm/components/Pagination/Pagination.js +16 -12
- package/dist/esm/components/Pagination/PaginationItem.js +7 -6
- package/dist/esm/components/Paper/Paper.js +11 -7
- package/dist/esm/components/Popover/Popover.js +43 -50
- package/dist/esm/components/Popover/Popover.tokens.js +2 -12
- package/dist/esm/components/Popover/PopoverActions.js +28 -0
- package/dist/esm/components/Popover/PopoverContent.js +12 -6
- package/dist/esm/components/Popover/PopoverHeader.js +36 -0
- package/dist/esm/components/Popover/PopoverTitle.js +13 -24
- package/dist/esm/components/Popover/index.js +6 -0
- package/dist/esm/components/Progress/Circular/CircularProgress.js +14 -10
- package/dist/esm/components/Progress/Dots/DotProgress.js +12 -8
- package/dist/esm/components/Progress/Linear/LinearProgress.js +6 -5
- package/dist/esm/components/Progress/Star/StarProgress.js +14 -10
- package/dist/esm/components/Radio/Radio.js +84 -52
- package/dist/esm/components/Radio/Radio.tokens.js +9 -4
- package/dist/esm/components/Scrim/Scrim.js +16 -20
- package/dist/esm/components/Search/Search.js +28 -28
- package/dist/esm/components/Select/MultiSelect/MultiSelect.js +27 -22
- package/dist/esm/components/Select/NativeSelect/NativeSelect.js +19 -17
- package/dist/esm/components/Select/Select.tokens.js +2 -2
- package/dist/esm/components/Select/SingleSelect/SingleSelect.js +29 -23
- package/dist/esm/components/Select/commonStyles.js +14 -13
- package/dist/esm/components/SideSheet/SideSheet.js +16 -13
- package/dist/esm/components/Slider/MinMax.js +5 -4
- package/dist/esm/components/Slider/Output.js +13 -9
- package/dist/esm/components/Slider/Slider.js +81 -38
- package/dist/esm/components/Slider/Slider.tokens.js +7 -2
- package/dist/esm/components/Slider/SliderInput.js +14 -14
- package/dist/esm/components/Snackbar/Snackbar.js +17 -21
- package/dist/esm/components/Snackbar/SnackbarAction.js +9 -7
- package/dist/esm/components/Switch/Switch.js +21 -15
- package/dist/esm/components/Switch/Switch.styles.js +24 -17
- package/dist/esm/components/Switch/Switch.tokens.js +6 -1
- package/dist/esm/components/Switch/SwitchDefault.js +39 -29
- package/dist/esm/components/Switch/SwitchSmall.js +38 -28
- package/dist/esm/components/Table/Body.js +5 -4
- package/dist/esm/components/Table/Caption.js +8 -5
- package/dist/esm/components/Table/Cell.js +9 -6
- package/dist/esm/components/Table/DataCell/DataCell.js +15 -14
- package/dist/esm/components/Table/DataCell/DataCell.tokens.js +19 -9
- package/dist/esm/components/Table/Head/Head.js +7 -6
- package/dist/esm/components/Table/HeaderCell/HeaderCell.js +7 -8
- package/dist/esm/components/Table/HeaderCell/HeaderCell.tokens.js +18 -8
- package/dist/esm/components/Table/Row/Row.js +7 -5
- package/dist/esm/components/Table/Table.js +5 -4
- package/dist/esm/components/TableOfContents/LinkItem.js +10 -10
- package/dist/esm/components/TableOfContents/TableOfContents.js +17 -15
- package/dist/esm/components/Tabs/Tab.js +21 -19
- package/dist/esm/components/Tabs/TabList.js +27 -11
- package/dist/esm/components/Tabs/TabPanel.js +8 -7
- package/dist/esm/components/Tabs/TabPanels.js +5 -4
- package/dist/esm/components/Tabs/Tabs.context.js +1 -0
- package/dist/esm/components/Tabs/Tabs.js +45 -15
- package/dist/esm/components/Tabs/Tabs.tokens.js +8 -2
- package/dist/esm/components/TextField/Field.js +49 -38
- package/dist/esm/components/TextField/HelperText/HelperText.js +28 -19
- package/dist/esm/components/TextField/Icon/Icon.js +20 -18
- package/dist/esm/components/TextField/TextField.context.js +4 -3
- package/dist/esm/components/TextField/TextField.js +19 -19
- package/dist/esm/components/Textarea/Textarea.js +16 -16
- package/dist/esm/components/Tooltip/Tooltip.js +23 -24
- package/dist/esm/components/TopBar/Actions.js +5 -4
- package/dist/esm/components/TopBar/CustomContent.js +5 -4
- package/dist/esm/components/TopBar/Header.js +5 -4
- package/dist/esm/components/TopBar/TopBar.js +11 -11
- package/dist/esm/components/Typography/Typography.js +49 -28
- package/dist/esm/components/Typography/Typography.tokens.js +7 -2
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry1.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry2.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_curry3.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_has.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_isObject.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/internal/_isPlaceholder.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeDeepRight.js +2 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeDeepWithKey.js +1 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.27.1 → ramda@0.27.2}/node_modules/ramda/src/mergeWithKey.js +1 -1
- package/dist/types/components/Accordion/AccordionHeader.d.ts +2 -2
- package/dist/types/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/types/components/Checkbox/Input.d.ts +1 -1
- package/dist/types/components/Dialog/Dialog.d.ts +18 -2
- package/dist/types/components/Dialog/DialogActions.d.ts +3 -0
- package/dist/types/components/Dialog/{CustomContent.d.ts → DialogContent.d.ts} +2 -2
- package/dist/types/components/Dialog/DialogHeader.d.ts +3 -0
- package/dist/types/components/Dialog/DialogTitle.d.ts +3 -0
- package/dist/types/components/Dialog/index.d.ts +10 -7
- package/dist/types/components/Icon/Icon.d.ts +2 -2
- package/dist/types/components/Menu/Menu.context.d.ts +3 -0
- package/dist/types/components/Menu/Menu.d.ts +1 -6
- package/dist/types/components/Menu/MenuList.d.ts +0 -2
- package/dist/types/components/Popover/Popover.d.ts +1 -1
- package/dist/types/components/Popover/PopoverActions.d.ts +3 -0
- package/dist/types/components/Popover/PopoverHeader.d.ts +3 -0
- package/dist/types/components/Popover/index.d.ts +5 -1
- package/dist/types/components/Progress/Circular/CircularProgress.d.ts +1 -1
- package/dist/types/components/Progress/Dots/DotProgress.d.ts +1 -1
- package/dist/types/components/Progress/Star/StarProgress.d.ts +1 -1
- package/dist/types/components/Switch/Switch.d.ts +1 -1
- package/dist/types/components/Switch/Switch.styles.d.ts +2 -1
- package/dist/types/components/Tabs/TabList.d.ts +4 -0
- package/dist/types/components/Tabs/Tabs.context.d.ts +1 -0
- package/dist/types/components/Tabs/Tabs.d.ts +4 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +1 -1
- package/package.json +37 -38
- package/dist/esm/components/Dialog/Actions.js +0 -26
- package/dist/esm/components/Dialog/CustomContent.js +0 -46
- package/dist/esm/components/Dialog/Title.js +0 -41
- package/dist/esm/hooks/useAutoResize.js +0 -39
- package/dist/esm/hooks/useCombinedRefs.js +0 -14
- package/dist/esm/hooks/useGlobalKeyPress.js +0 -34
- package/dist/esm/hooks/useHideBodyScroll.js +0 -20
- package/dist/esm/hooks/useId.js +0 -14
- package/dist/esm/hooks/useMountedRef.js +0 -12
- package/dist/esm/hooks/useOutsideClick.js +0 -18
- package/dist/esm/hooks/usePopper.js +0 -31
- package/dist/esm/hooks/useToken.js +0 -16
- package/dist/esm/utils/joinHandlers.js +0 -10
- package/dist/esm/utils/setReactInputValue.js +0 -18
- package/dist/esm/utils/templates/borders.js +0 -35
- package/dist/esm/utils/templates/common.js +0 -19
- package/dist/esm/utils/templates/focus.js +0 -35
- package/dist/esm/utils/templates/index.js +0 -52
- package/dist/types/components/Dialog/Actions.d.ts +0 -3
- package/dist/types/components/Dialog/Title.d.ts +0 -3
- package/dist/types/hooks/index.d.ts +0 -9
- package/dist/types/hooks/useAutoResize.d.ts +0 -1
- package/dist/types/hooks/useCombinedRefs.d.ts +0 -3
- package/dist/types/hooks/useGlobalKeyPress.d.ts +0 -10
- package/dist/types/hooks/useHideBodyScroll.d.ts +0 -1
- package/dist/types/hooks/useId.d.ts +0 -1
- package/dist/types/hooks/useMountedRef.d.ts +0 -1
- package/dist/types/hooks/useOutsideClick.d.ts +0 -1
- package/dist/types/hooks/usePopper.d.ts +0 -12
- package/dist/types/hooks/useToken.d.ts +0 -7
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/joinHandlers.d.ts +0 -3
- package/dist/types/utils/setReactInputValue.d.ts +0 -7
- package/dist/types/utils/templates/borders.d.ts +0 -2
- package/dist/types/utils/templates/common.d.ts +0 -9
- package/dist/types/utils/templates/focus.d.ts +0 -2
- package/dist/types/utils/templates/index.d.ts +0 -7
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import { forwardRef, useState } from 'react';
|
|
1
|
+
import { forwardRef, useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { TabsProvider } from './Tabs.context.js';
|
|
3
3
|
import { token } from './Tabs.tokens.js';
|
|
4
|
+
import { useId, useCombinedRefs, useToken } from '@equinor/eds-utils';
|
|
4
5
|
import { ThemeProvider } from 'styled-components';
|
|
5
6
|
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { useId } from '../../hooks/useId.js';
|
|
7
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
8
|
-
import { useToken } from '../../hooks/useToken.js';
|
|
9
8
|
|
|
10
|
-
const Tabs = /*#__PURE__*/forwardRef(function Tabs({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const Tabs = /*#__PURE__*/forwardRef(function Tabs(_ref, ref) {
|
|
10
|
+
let {
|
|
11
|
+
activeTab = 0,
|
|
12
|
+
onChange,
|
|
13
|
+
onBlur,
|
|
14
|
+
onFocus,
|
|
15
|
+
variant = 'minWidth',
|
|
16
|
+
scrollable,
|
|
17
|
+
id,
|
|
18
|
+
...props
|
|
19
|
+
} = _ref;
|
|
19
20
|
const tabsId = useId(id, 'tabs');
|
|
21
|
+
const tabsRef = useRef(null);
|
|
22
|
+
const combinedTabsRef = useCombinedRefs(tabsRef, ref);
|
|
20
23
|
const [tabsFocused, setTabsFocused] = useState(false);
|
|
24
|
+
const [listenerAttached, setListenerAttached] = useState(false);
|
|
21
25
|
let blurTimer;
|
|
22
26
|
|
|
23
27
|
const handleBlur = e => {
|
|
28
|
+
setListenerAttached(false);
|
|
29
|
+
|
|
30
|
+
if (tabsRef.current) {
|
|
31
|
+
tabsRef.current.removeEventListener('keyup', checkIfTabWasPressed);
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
blurTimer = setTimeout(() => {
|
|
25
35
|
if (tabsFocused) {
|
|
26
36
|
setTabsFocused(false);
|
|
@@ -35,14 +45,33 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs({
|
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
clearTimeout(blurTimer);
|
|
48
|
+
if (tabsFocused) return;
|
|
38
49
|
|
|
39
|
-
if (!
|
|
40
|
-
|
|
50
|
+
if (!listenerAttached) {
|
|
51
|
+
if (tabsRef.current) {
|
|
52
|
+
setListenerAttached(true);
|
|
53
|
+
tabsRef.current.addEventListener('keyup', checkIfTabWasPressed, {
|
|
54
|
+
once: true,
|
|
55
|
+
capture: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
41
58
|
}
|
|
42
59
|
|
|
43
60
|
onFocus && onFocus(e);
|
|
61
|
+
}; //Only force focus on active Tab if Tabs was navigated to with keyboard
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
const checkIfTabWasPressed = event => {
|
|
65
|
+
setListenerAttached(false);
|
|
66
|
+
if (event.key === 'Tab') setTabsFocused(true);
|
|
44
67
|
};
|
|
45
68
|
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const tabs = tabsRef.current;
|
|
71
|
+
return () => {
|
|
72
|
+
if (tabs) tabs.removeEventListener('keyup', checkIfTabWasPressed);
|
|
73
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
+
}, []);
|
|
46
75
|
const {
|
|
47
76
|
density
|
|
48
77
|
} = useEds();
|
|
@@ -57,10 +86,11 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs({
|
|
|
57
86
|
handleChange: onChange,
|
|
58
87
|
tabsId,
|
|
59
88
|
variant,
|
|
89
|
+
scrollable,
|
|
60
90
|
tabsFocused
|
|
61
91
|
},
|
|
62
92
|
children: /*#__PURE__*/jsx("div", {
|
|
63
|
-
ref:
|
|
93
|
+
ref: combinedTabsRef,
|
|
64
94
|
...props,
|
|
65
95
|
onBlur: handleBlur,
|
|
66
96
|
onFocus: handleFocus
|
|
@@ -34,6 +34,11 @@ const {
|
|
|
34
34
|
comfortable: {
|
|
35
35
|
medium: spacingMedium
|
|
36
36
|
}
|
|
37
|
+
},
|
|
38
|
+
interactions: {
|
|
39
|
+
focused: {
|
|
40
|
+
width: focusOutlineWidth
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
} = tokens;
|
|
39
44
|
const token = {
|
|
@@ -47,7 +52,7 @@ const token = {
|
|
|
47
52
|
focus: {
|
|
48
53
|
outline: {
|
|
49
54
|
type: 'outline',
|
|
50
|
-
width:
|
|
55
|
+
width: focusOutlineWidth,
|
|
51
56
|
style: 'dashed',
|
|
52
57
|
color: focusOutlineColor
|
|
53
58
|
}
|
|
@@ -94,7 +99,8 @@ const token = {
|
|
|
94
99
|
focus: {
|
|
95
100
|
outline: {
|
|
96
101
|
type: 'outline',
|
|
97
|
-
width:
|
|
102
|
+
width: focusOutlineWidth,
|
|
103
|
+
offset: "-".concat(parseInt(focusOutlineWidth), "px"),
|
|
98
104
|
style: 'dashed',
|
|
99
105
|
color: focusOutlineColor
|
|
100
106
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import { useTextField } from './TextField.context.js';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
+
import { typographyTemplate, outlineTemplate } from '@equinor/eds-utils';
|
|
4
5
|
import * as TextField_tokens from './TextField.tokens.js';
|
|
5
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
7
|
import { Input } from '../Input/Input.js';
|
|
7
8
|
import { Textarea } from '../Textarea/Textarea.js';
|
|
8
9
|
import { Icon as InputIcon } from './Icon/Icon.js';
|
|
9
|
-
import { typographyTemplate } from '../../utils/templates/index.js';
|
|
10
10
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
11
|
-
import { outlineTemplate } from '../../utils/templates/focus.js';
|
|
12
11
|
|
|
13
12
|
const {
|
|
14
13
|
textfield
|
|
15
14
|
} = TextField_tokens;
|
|
16
15
|
|
|
17
|
-
const Variation =
|
|
18
|
-
variant,
|
|
19
|
-
isFocused,
|
|
20
|
-
token
|
|
21
|
-
}) => {
|
|
16
|
+
const Variation = _ref => {
|
|
22
17
|
var _token$border, _token$border2, _token$border3, _token$border4;
|
|
23
18
|
|
|
19
|
+
let {
|
|
20
|
+
variant,
|
|
21
|
+
isFocused,
|
|
22
|
+
token
|
|
23
|
+
} = _ref;
|
|
24
|
+
|
|
24
25
|
if (!variant) {
|
|
25
26
|
return "";
|
|
26
27
|
}
|
|
@@ -39,45 +40,55 @@ const StrippedTextarea = styled(Textarea).withConfig({
|
|
|
39
40
|
const InputWrapper = styled.div.withConfig({
|
|
40
41
|
displayName: "Field__InputWrapper",
|
|
41
42
|
componentId: "sc-455b88-2"
|
|
42
|
-
})(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
})(_ref2 => {
|
|
44
|
+
let {
|
|
45
|
+
inputIcon,
|
|
46
|
+
unit,
|
|
47
|
+
isDisabled,
|
|
48
|
+
isReadOnly,
|
|
49
|
+
multiline,
|
|
50
|
+
variant
|
|
51
|
+
} = _ref2;
|
|
52
|
+
return css(["", " ", " ", " ", " ", ""], Variation, (inputIcon || unit) && css(["display:flex;align-items:center;background:", ";padding-right:", ";"], textfield.background, textfield.spacings.right), isReadOnly && css(["box-shadow:", ";background:", ";"], textfield.states.readOnly.boxShadow, textfield.states.readOnly.background), isDisabled && css(["box-shadow:none;cursor:not-allowed;outline:none;"]), multiline && variant === 'default' && !inputIcon && !unit && css(["box-shadow:none;"]));
|
|
53
|
+
});
|
|
50
54
|
const Unit = styled.span.withConfig({
|
|
51
55
|
displayName: "Field__Unit",
|
|
52
56
|
componentId: "sc-455b88-3"
|
|
53
|
-
})(["", ";display:inline-block;margin-top:3px;", ""], typographyTemplate(textfield.entities.unit.typography),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
})(["", ";display:inline-block;margin-top:3px;", ""], typographyTemplate(textfield.entities.unit.typography), _ref3 => {
|
|
58
|
+
let {
|
|
59
|
+
isDisabled
|
|
60
|
+
} = _ref3;
|
|
61
|
+
return isDisabled && {
|
|
62
|
+
color: textfield.entities.unit.states.disabled.typography.color
|
|
63
|
+
};
|
|
57
64
|
});
|
|
58
65
|
const Adornments = styled.div.withConfig({
|
|
59
66
|
displayName: "Field__Adornments",
|
|
60
67
|
componentId: "sc-455b88-4"
|
|
61
|
-
})(["display:flex;align-items:center;justify-content:center;height:100%;margin-left:", ";& div:nth-child(2){margin-left:", ";}", ""], textfield.spacings.left, textfield.spacings.left,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
})(["display:flex;align-items:center;justify-content:center;height:100%;margin-left:", ";& div:nth-child(2){margin-left:", ";}", ""], textfield.spacings.left, textfield.spacings.left, _ref4 => {
|
|
69
|
+
let {
|
|
70
|
+
multiline,
|
|
71
|
+
theme
|
|
72
|
+
} = _ref4;
|
|
73
|
+
return multiline && {
|
|
74
|
+
marginTop: theme.spacings.top,
|
|
75
|
+
alignSelf: 'start'
|
|
76
|
+
};
|
|
67
77
|
});
|
|
68
|
-
const Field = /*#__PURE__*/forwardRef(function Field({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const Field = /*#__PURE__*/forwardRef(function Field(_ref5, ref) {
|
|
79
|
+
let {
|
|
80
|
+
multiline,
|
|
81
|
+
variant,
|
|
82
|
+
disabled,
|
|
83
|
+
readOnly,
|
|
84
|
+
type,
|
|
85
|
+
unit,
|
|
86
|
+
inputIcon,
|
|
87
|
+
rowsMax,
|
|
88
|
+
onBlur,
|
|
89
|
+
onFocus,
|
|
90
|
+
...other
|
|
91
|
+
} = _ref5;
|
|
81
92
|
const {
|
|
82
93
|
handleFocus,
|
|
83
94
|
handleBlur,
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
+
import { typographyTemplate } from '@equinor/eds-utils';
|
|
3
4
|
import { helperText } from './HelperText.token.js';
|
|
4
5
|
import { useTextField } from '../TextField.context.js';
|
|
5
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
7
|
import { Icon as InputIcon } from '../Icon/Icon.js';
|
|
7
|
-
import { typographyTemplate } from '../../../utils/templates/index.js';
|
|
8
8
|
|
|
9
|
-
const Variation =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const Variation = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
variant,
|
|
12
|
+
isFocused,
|
|
13
|
+
isDisabled
|
|
14
|
+
} = _ref;
|
|
15
|
+
|
|
14
16
|
if (!variant) {
|
|
15
17
|
return "";
|
|
16
18
|
}
|
|
@@ -35,22 +37,29 @@ const Variation = ({
|
|
|
35
37
|
const Container = styled.div.withConfig({
|
|
36
38
|
displayName: "HelperText__Container",
|
|
37
39
|
componentId: "sc-1kfkyxg-0"
|
|
38
|
-
})(["display:flex;align-items:flex-start;margin-top:", ";"],
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
})(["display:flex;align-items:flex-start;margin-top:", ";"], _ref2 => {
|
|
41
|
+
let {
|
|
42
|
+
spacings
|
|
43
|
+
} = _ref2;
|
|
44
|
+
return spacings.top;
|
|
45
|
+
});
|
|
41
46
|
const Text = styled.p.withConfig({
|
|
42
47
|
displayName: "HelperText__Text",
|
|
43
48
|
componentId: "sc-1kfkyxg-1"
|
|
44
|
-
})(["", " margin:0 0 0 ", ";", ""], typographyTemplate(helperText.typography),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
})(["", " margin:0 0 0 ", ";", ""], typographyTemplate(helperText.typography), _ref3 => {
|
|
50
|
+
let {
|
|
51
|
+
spacings
|
|
52
|
+
} = _ref3;
|
|
53
|
+
return spacings.left;
|
|
54
|
+
}, Variation);
|
|
55
|
+
const TextfieldHelperText = /*#__PURE__*/forwardRef(function TextfieldHelperText(_ref4, ref) {
|
|
56
|
+
let {
|
|
57
|
+
helperText: helperText$1,
|
|
58
|
+
icon,
|
|
59
|
+
variant = 'default',
|
|
60
|
+
disabled: isDisabled,
|
|
61
|
+
...rest
|
|
62
|
+
} = _ref4;
|
|
54
63
|
const helperVariant = helperText[variant];
|
|
55
64
|
const spacings = helperText.spacings.comfortable;
|
|
56
65
|
const {
|
|
@@ -7,12 +7,13 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
7
7
|
const StyledIcon = styled.div.withConfig({
|
|
8
8
|
displayName: "Icon__StyledIcon",
|
|
9
9
|
componentId: "sc-jr0rqa-0"
|
|
10
|
-
})(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
})(_ref => {
|
|
11
|
+
let {
|
|
12
|
+
colors,
|
|
13
|
+
isDisabled,
|
|
14
|
+
isFocused,
|
|
15
|
+
size
|
|
16
|
+
} = _ref;
|
|
16
17
|
const {
|
|
17
18
|
focusColor,
|
|
18
19
|
color,
|
|
@@ -30,18 +31,19 @@ const StyledIcon = styled.div.withConfig({
|
|
|
30
31
|
|
|
31
32
|
return css(["&,svg{fill:", ";width:", "px;height:", "px;}"], fill, size, size);
|
|
32
33
|
});
|
|
33
|
-
const InputIcon = /*#__PURE__*/forwardRef(function InputIcon({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
const InputIcon = /*#__PURE__*/forwardRef(function InputIcon(_ref2, ref) {
|
|
35
|
+
let {
|
|
36
|
+
size = 24,
|
|
37
|
+
variant = 'default',
|
|
38
|
+
isDisabled = false,
|
|
39
|
+
colors = {
|
|
40
|
+
color: input[variant].color,
|
|
41
|
+
disabledColor: input[variant].disabledColor,
|
|
42
|
+
focusColor: input[variant].focusColor
|
|
43
|
+
},
|
|
44
|
+
children,
|
|
45
|
+
...other
|
|
46
|
+
} = _ref2;
|
|
45
47
|
const {
|
|
46
48
|
isFocused
|
|
47
49
|
} = useTextField();
|
|
@@ -5,9 +5,10 @@ const initalState = {
|
|
|
5
5
|
isFocused: false
|
|
6
6
|
};
|
|
7
7
|
const TextFieldContext = /*#__PURE__*/createContext(initalState);
|
|
8
|
-
const TextFieldProvider =
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const TextFieldProvider = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
children
|
|
11
|
+
} = _ref;
|
|
11
12
|
const [state, setState] = useState(initalState);
|
|
12
13
|
|
|
13
14
|
const handleFocus = () => {
|
|
@@ -3,34 +3,34 @@ import styled, { ThemeProvider } from 'styled-components';
|
|
|
3
3
|
import { Field } from './Field.js';
|
|
4
4
|
import { TextFieldProvider } from './TextField.context.js';
|
|
5
5
|
import { textfield } from './TextField.tokens.js';
|
|
6
|
+
import { useId, useToken } from '@equinor/eds-utils';
|
|
6
7
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
-
import { useId } from '../../hooks/useId.js';
|
|
8
8
|
import { Label } from '../Label/Label.js';
|
|
9
9
|
import { HelperText as TextfieldHelperText } from './HelperText/HelperText.js';
|
|
10
10
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
11
|
-
import { useToken } from '../../hooks/useToken.js';
|
|
12
11
|
|
|
13
12
|
const Container = styled.div.withConfig({
|
|
14
13
|
displayName: "TextField__Container",
|
|
15
14
|
componentId: "sc-o1nc07-0"
|
|
16
15
|
})(["min-width:100px;width:100%;"]);
|
|
17
|
-
const TextField = /*#__PURE__*/forwardRef(function TextField({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
const TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
17
|
+
let {
|
|
18
|
+
id,
|
|
19
|
+
label,
|
|
20
|
+
meta,
|
|
21
|
+
unit,
|
|
22
|
+
helperText,
|
|
23
|
+
placeholder,
|
|
24
|
+
disabled,
|
|
25
|
+
multiline,
|
|
26
|
+
className,
|
|
27
|
+
variant = 'default',
|
|
28
|
+
inputRef,
|
|
29
|
+
inputIcon,
|
|
30
|
+
helperIcon,
|
|
31
|
+
rowsMax,
|
|
32
|
+
...other
|
|
33
|
+
} = _ref;
|
|
34
34
|
const helperTextId = useId(null, 'helpertext');
|
|
35
35
|
const inputProps = {
|
|
36
36
|
'aria-describedby': helperTextId,
|
|
@@ -2,22 +2,21 @@ import { forwardRef, useState } from 'react';
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import * as Input_tokens from '../Input/Input.tokens.js';
|
|
4
4
|
import { input as input$1 } from '../Input/Input.tokens.js';
|
|
5
|
+
import { typographyTemplate, useAutoResize, useCombinedRefs, spacingsTemplate, outlineTemplate } from '@equinor/eds-utils';
|
|
5
6
|
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { useAutoResize } from '../../hooks/useAutoResize.js';
|
|
7
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
|
|
8
|
-
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
9
7
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
10
|
-
import { outlineTemplate } from '../../utils/templates/focus.js';
|
|
11
8
|
|
|
12
9
|
const {
|
|
13
10
|
input
|
|
14
11
|
} = Input_tokens;
|
|
15
12
|
|
|
16
|
-
const Variation =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const Variation = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
variant,
|
|
16
|
+
token,
|
|
17
|
+
density
|
|
18
|
+
} = _ref;
|
|
19
|
+
|
|
21
20
|
if (!variant) {
|
|
22
21
|
return "";
|
|
23
22
|
}
|
|
@@ -46,13 +45,14 @@ const StyledTextarea = styled.textarea.withConfig({
|
|
|
46
45
|
displayName: "Textarea__StyledTextarea",
|
|
47
46
|
componentId: "sc-2yjdcc-0"
|
|
48
47
|
})(["width:100%;box-sizing:border-box;margin:0;border:none;appearance:none;background:", ";height:auto;", " ", " &::placeholder{color:", ";}&:disabled{color:", ";}&[readOnly]{box-shadow:", ";background:", ";}"], input.background, typographyTemplate(input.typography), Variation, input.entities.placeholder.typography.color, input.states.disabled.typography.color, input.states.readOnly.boxShadow, input.states.readOnly.background);
|
|
49
|
-
const Textarea = /*#__PURE__*/forwardRef(function Textarea({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const Textarea = /*#__PURE__*/forwardRef(function Textarea(_ref2, ref) {
|
|
49
|
+
let {
|
|
50
|
+
variant = 'default',
|
|
51
|
+
disabled = false,
|
|
52
|
+
type = 'text',
|
|
53
|
+
rowsMax,
|
|
54
|
+
...other
|
|
55
|
+
} = _ref2;
|
|
56
56
|
const actualVariant = variant === 'default' ? 'input' : variant;
|
|
57
57
|
const inputVariant = Input_tokens[actualVariant];
|
|
58
58
|
const [textareaEl, setTextareaEl] = useState(null);
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { forwardRef, useState, useRef, useEffect, cloneElement } from 'react';
|
|
2
2
|
import * as ReactDom from 'react-dom';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import { typographyTemplate, spacingsTemplate, bordersTemplate, useIsMounted, useCombinedRefs, useId, useGlobalKeyPress, usePopper, joinHandlers } from '@equinor/eds-utils';
|
|
4
5
|
import { tooltip } from './Tooltip.tokens.js';
|
|
5
6
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { useIsMounted } from '../../hooks/useMountedRef.js';
|
|
7
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
|
|
8
|
-
import { useId } from '../../hooks/useId.js';
|
|
9
|
-
import { useGlobalKeyPress } from '../../hooks/useGlobalKeyPress.js';
|
|
10
|
-
import { usePopper } from '../../hooks/usePopper.js';
|
|
11
|
-
import { joinHandlers } from '../../utils/joinHandlers.js';
|
|
12
|
-
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
13
|
-
import { bordersTemplate } from '../../utils/templates/borders.js';
|
|
14
7
|
|
|
15
8
|
const StyledTooltip = styled.div.withConfig({
|
|
16
9
|
displayName: "Tooltip__StyledTooltip",
|
|
17
10
|
componentId: "sc-m2im2p-0"
|
|
18
|
-
})(["", " ", " ", " background:", ";z-index:
|
|
11
|
+
})(["", " ", " ", " background:", ";z-index:1500;white-space:nowrap;.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:", ";}"], typographyTemplate(tooltip.typography), spacingsTemplate(tooltip.spacings), bordersTemplate(tooltip.border), tooltip.background, tooltip.entities.arrow.width, tooltip.entities.arrow.height, tooltip.entities.arrow.spacings.bottom, tooltip.entities.arrow.spacings.top, tooltip.entities.arrow.spacings.right, tooltip.entities.arrow.spacings.left);
|
|
19
12
|
const ArrowWrapper = styled.div.withConfig({
|
|
20
13
|
displayName: "Tooltip__ArrowWrapper",
|
|
21
14
|
componentId: "sc-m2im2p-1"
|
|
@@ -24,14 +17,16 @@ const TooltipArrow = styled.svg.withConfig({
|
|
|
24
17
|
displayName: "Tooltip__TooltipArrow",
|
|
25
18
|
componentId: "sc-m2im2p-2"
|
|
26
19
|
})(["width:", ";height:", ";position:absolute;fill:", ";"], tooltip.entities.arrow.width, tooltip.entities.arrow.height, tooltip.background);
|
|
27
|
-
const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(_ref, ref) {
|
|
21
|
+
let {
|
|
22
|
+
title,
|
|
23
|
+
placement = 'bottom',
|
|
24
|
+
children,
|
|
25
|
+
enterDelay = 100,
|
|
26
|
+
id,
|
|
27
|
+
style,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
35
30
|
const isMounted = useIsMounted();
|
|
36
31
|
const [popperEl, setPopperEl] = useState(null);
|
|
37
32
|
const [arrowRef, setArrowRef] = useState(null);
|
|
@@ -43,10 +38,6 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
|
|
|
43
38
|
const tooltipId = useId(id, 'tooltip');
|
|
44
39
|
const containerId = 'eds-tooltip-container';
|
|
45
40
|
const shouldOpen = isMounted && title !== '';
|
|
46
|
-
const {
|
|
47
|
-
setTimeout,
|
|
48
|
-
clearTimeout
|
|
49
|
-
} = window;
|
|
50
41
|
useEffect(() => {
|
|
51
42
|
if (document.getElementById(containerId) === null) {
|
|
52
43
|
const tooltipContainerElement = document.createElement('div');
|
|
@@ -57,7 +48,7 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
|
|
|
57
48
|
return () => {
|
|
58
49
|
clearTimeout(openTimer.current);
|
|
59
50
|
};
|
|
60
|
-
}, [
|
|
51
|
+
}, []);
|
|
61
52
|
|
|
62
53
|
const openTooltip = () => {
|
|
63
54
|
if (shouldOpen) {
|
|
@@ -77,9 +68,18 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
|
|
|
77
68
|
const {
|
|
78
69
|
styles,
|
|
79
70
|
attributes
|
|
80
|
-
} = usePopper(
|
|
71
|
+
} = usePopper({
|
|
72
|
+
anchorEl: anchorRef.current,
|
|
73
|
+
popperEl,
|
|
74
|
+
arrowRef,
|
|
75
|
+
placement,
|
|
76
|
+
offset: 14
|
|
77
|
+
});
|
|
81
78
|
const props = {
|
|
82
79
|
open,
|
|
80
|
+
style: { ...styles.popper,
|
|
81
|
+
...style
|
|
82
|
+
},
|
|
83
83
|
...rest,
|
|
84
84
|
...attributes.popper
|
|
85
85
|
};
|
|
@@ -99,7 +99,6 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
|
|
|
99
99
|
id: tooltipId,
|
|
100
100
|
role: "tooltip",
|
|
101
101
|
ref: tooltipRef,
|
|
102
|
-
style: styles.popper,
|
|
103
102
|
...props,
|
|
104
103
|
children: [title, /*#__PURE__*/jsx(ArrowWrapper, {
|
|
105
104
|
ref: setArrowRef,
|
|
@@ -6,10 +6,11 @@ const StyledActions = styled.div.withConfig({
|
|
|
6
6
|
displayName: "Actions__StyledActions",
|
|
7
7
|
componentId: "sc-1251ang-0"
|
|
8
8
|
})(["grid-area:right;text-align:right;align-items:center;display:flex;"]);
|
|
9
|
-
const Actions = /*#__PURE__*/forwardRef(function Actions({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const Actions = /*#__PURE__*/forwardRef(function Actions(_ref, ref) {
|
|
10
|
+
let {
|
|
11
|
+
children,
|
|
12
|
+
...props
|
|
13
|
+
} = _ref;
|
|
13
14
|
return /*#__PURE__*/jsx(StyledActions, {
|
|
14
15
|
ref: ref,
|
|
15
16
|
...props,
|
|
@@ -6,10 +6,11 @@ const StyledCustomContent = styled.div.withConfig({
|
|
|
6
6
|
displayName: "CustomContent__StyledCustomContent",
|
|
7
7
|
componentId: "sc-d0e83a-0"
|
|
8
8
|
})(["grid-area:center;"]);
|
|
9
|
-
const CustomContent = /*#__PURE__*/forwardRef(function CustomContent({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const CustomContent = /*#__PURE__*/forwardRef(function CustomContent(_ref, ref) {
|
|
10
|
+
let {
|
|
11
|
+
children,
|
|
12
|
+
...props
|
|
13
|
+
} = _ref;
|
|
13
14
|
return /*#__PURE__*/jsx(StyledCustomContent, {
|
|
14
15
|
ref: ref,
|
|
15
16
|
...props,
|
|
@@ -6,10 +6,11 @@ const StyledHeader = styled.div.withConfig({
|
|
|
6
6
|
displayName: "Header__StyledHeader",
|
|
7
7
|
componentId: "sc-1fpllve-0"
|
|
8
8
|
})(["grid-area:left;display:grid;grid-template-columns:auto auto;grid-gap:24px;align-items:center;"]);
|
|
9
|
-
const Header = /*#__PURE__*/forwardRef(function Header({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const Header = /*#__PURE__*/forwardRef(function Header(_ref, ref) {
|
|
10
|
+
let {
|
|
11
|
+
children,
|
|
12
|
+
...props
|
|
13
|
+
} = _ref;
|
|
13
14
|
return /*#__PURE__*/jsx(StyledHeader, {
|
|
14
15
|
ref: ref,
|
|
15
16
|
...props,
|