@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,18 +1,17 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import styled, { css, ThemeProvider } from 'styled-components';
|
|
3
3
|
import { inputToken } from './Input.tokens.js';
|
|
4
|
+
import { outlineTemplate, typographyTemplate, spacingsTemplate, useToken } from '@equinor/eds-utils';
|
|
4
5
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
import { outlineTemplate } from '../../utils/templates/focus.js';
|
|
6
|
-
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
7
6
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
8
|
-
import { useToken } from '../../hooks/useToken.js';
|
|
9
7
|
|
|
10
8
|
const StyledInput = styled.input.withConfig({
|
|
11
9
|
displayName: "Input__StyledInput",
|
|
12
10
|
componentId: "sc-1ykv024-0"
|
|
13
|
-
})(
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
})(_ref => {
|
|
12
|
+
let {
|
|
13
|
+
theme
|
|
14
|
+
} = _ref;
|
|
16
15
|
const {
|
|
17
16
|
states: {
|
|
18
17
|
focus: {
|
|
@@ -28,12 +27,13 @@ const StyledInput = styled.input.withConfig({
|
|
|
28
27
|
} = theme;
|
|
29
28
|
return css(["width:100%;box-sizing:border-box;margin:0;appearance:none;background:", ";border:none;height:", ";box-shadow:", ";", " ", " ", ";&::placeholder{color:", ";}&:active,&:focus{outline-offset:0;box-shadow:none;", "}&:disabled{color:", ";cursor:not-allowed;box-shadow:none;outline:none;&:focus,&:active{outline:none;}}&[readOnly]{background:", ";box-shadow:", ";}"], theme.background, theme.minHeight, boxShadow, outlineTemplate(activeOutline), typographyTemplate(theme.typography), spacingsTemplate(theme.spacings), theme.entities.placeholder.typography.color, outlineTemplate(focusOutline), disabled.typography.color, readOnly.background, readOnly.boxShadow);
|
|
30
29
|
});
|
|
31
|
-
const Input = /*#__PURE__*/forwardRef(function Input({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const Input = /*#__PURE__*/forwardRef(function Input(_ref2, ref) {
|
|
31
|
+
let {
|
|
32
|
+
variant = 'default',
|
|
33
|
+
disabled = false,
|
|
34
|
+
type = 'text',
|
|
35
|
+
...other
|
|
36
|
+
} = _ref2;
|
|
37
37
|
const actualVariant = variant === 'default' ? 'input' : variant;
|
|
38
38
|
const inputVariant = inputToken[actualVariant];
|
|
39
39
|
const {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tokens as tokens$1 } from '@equinor/eds-tokens';
|
|
2
|
-
import
|
|
2
|
+
import mergeDeepRight from '../../node_modules/.pnpm/ramda@0.27.2/node_modules/ramda/src/mergeDeepRight.js';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
colors: {
|
|
@@ -93,7 +93,7 @@ const input = {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
const error =
|
|
96
|
+
const error = mergeDeepRight(input, {
|
|
97
97
|
boxShadow: 'inset 0px -1px 0px 0px transparent',
|
|
98
98
|
states: {
|
|
99
99
|
active: {
|
|
@@ -116,7 +116,7 @@ const error = mergeDeepRight_1(input, {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
const warning =
|
|
119
|
+
const warning = mergeDeepRight(input, {
|
|
120
120
|
boxShadow: 'inset 0px -1px 0px 0px transparent',
|
|
121
121
|
states: {
|
|
122
122
|
active: {
|
|
@@ -139,7 +139,7 @@ const warning = mergeDeepRight_1(input, {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
-
const success =
|
|
142
|
+
const success = mergeDeepRight(input, {
|
|
143
143
|
boxShadow: 'inset 0px -1px 0px 0px transparent',
|
|
144
144
|
states: {
|
|
145
145
|
active: {
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { typographyTemplate } from '@equinor/eds-utils';
|
|
3
4
|
import { label } from './Label.tokens.js';
|
|
4
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
-
import { typographyTemplate } from '../../utils/templates/index.js';
|
|
6
6
|
|
|
7
7
|
const LabelBase = styled.label.withConfig({
|
|
8
8
|
displayName: "Label__LabelBase",
|
|
9
9
|
componentId: "sc-1gi2bcn-0"
|
|
10
|
-
})(["display:flex;justify-content:space-between;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], typographyTemplate(label.typography), label.spacings.left, label.spacings.right,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
})(["display:flex;justify-content:space-between;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], typographyTemplate(label.typography), label.spacings.left, label.spacings.right, _ref => {
|
|
11
|
+
let {
|
|
12
|
+
disabledText
|
|
13
|
+
} = _ref;
|
|
14
|
+
return disabledText ? label.states.disabled.typography.color : label.typography.color;
|
|
15
|
+
});
|
|
13
16
|
const Text = styled.span.withConfig({
|
|
14
17
|
displayName: "Label__Text",
|
|
15
18
|
componentId: "sc-1gi2bcn-1"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { list } from './List.tokens.js';
|
|
4
|
+
import { typographyTemplate } from '@equinor/eds-utils';
|
|
4
5
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
import { typographyTemplate } from '../../utils/templates/index.js';
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
8
|
typography
|
|
@@ -10,14 +10,18 @@ const {
|
|
|
10
10
|
const StyledList = styled.ul.withConfig({
|
|
11
11
|
displayName: "List__StyledList",
|
|
12
12
|
componentId: "sc-v9d2hy-0"
|
|
13
|
-
})(["", " ", ""],
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
})(["", " ", ""], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
as
|
|
16
|
+
} = _ref;
|
|
17
|
+
return as === 'ol' ? css(["& ol{list-style-type:lower-alpha;}"]) : '';
|
|
18
|
+
}, typographyTemplate(typography));
|
|
19
|
+
const List = /*#__PURE__*/forwardRef(function List(_ref2, ref) {
|
|
20
|
+
let {
|
|
21
|
+
children,
|
|
22
|
+
variant = 'bullet',
|
|
23
|
+
...props
|
|
24
|
+
} = _ref2;
|
|
21
25
|
const as = variant === 'numbered' ? 'ol' : 'ul';
|
|
22
26
|
return /*#__PURE__*/jsx(StyledList, {
|
|
23
27
|
as: as,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
-
const ListItem = /*#__PURE__*/forwardRef(function ListItem({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const ListItem = /*#__PURE__*/forwardRef(function ListItem(_ref, ref) {
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
...props
|
|
8
|
+
} = _ref;
|
|
8
9
|
return /*#__PURE__*/jsx("li", { ...props,
|
|
9
10
|
ref: ref,
|
|
10
11
|
children: children
|
|
@@ -3,15 +3,18 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
|
|
4
4
|
const initalState = {
|
|
5
5
|
focusedIndex: -1,
|
|
6
|
+
initialFocus: null,
|
|
6
7
|
onClose: null
|
|
7
8
|
};
|
|
8
9
|
const MenuContext = /*#__PURE__*/createContext(initalState);
|
|
9
|
-
const MenuProvider =
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const MenuProvider = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
children
|
|
13
|
+
} = _ref;
|
|
12
14
|
const [state, setState] = useState(initalState);
|
|
13
15
|
const {
|
|
14
16
|
focusedIndex,
|
|
17
|
+
initialFocus,
|
|
15
18
|
onClose
|
|
16
19
|
} = state;
|
|
17
20
|
|
|
@@ -21,10 +24,17 @@ const MenuProvider = ({
|
|
|
21
24
|
}));
|
|
22
25
|
};
|
|
23
26
|
|
|
27
|
+
const setInitialFocus = initialFocus => {
|
|
28
|
+
setState(prevState => ({ ...prevState,
|
|
29
|
+
initialFocus: initialFocus
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
|
|
24
33
|
const setOnClose = onClose => {
|
|
25
34
|
const onCloseHelper = () => {
|
|
26
|
-
onClose();
|
|
27
35
|
setFocusedIndex(-1);
|
|
36
|
+
setInitialFocus(null);
|
|
37
|
+
onClose();
|
|
28
38
|
};
|
|
29
39
|
|
|
30
40
|
setState(prevState => ({ ...prevState,
|
|
@@ -35,6 +45,8 @@ const MenuProvider = ({
|
|
|
35
45
|
const value = {
|
|
36
46
|
setFocusedIndex,
|
|
37
47
|
focusedIndex,
|
|
48
|
+
setInitialFocus,
|
|
49
|
+
initialFocus,
|
|
38
50
|
setOnClose,
|
|
39
51
|
onClose
|
|
40
52
|
};
|
|
@@ -3,16 +3,11 @@ import * as ReactDom from 'react-dom';
|
|
|
3
3
|
import styled, { css, ThemeProvider } from 'styled-components';
|
|
4
4
|
import { MenuProvider, useMenu } from './Menu.context.js';
|
|
5
5
|
import { MenuList } from './MenuList.js';
|
|
6
|
+
import { bordersTemplate, useIsMounted, useToken, usePopper, useOutsideClick, useGlobalKeyPress } from '@equinor/eds-utils';
|
|
6
7
|
import { menu } from './Menu.tokens.js';
|
|
7
8
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import { useIsMounted } from '../../hooks/useMountedRef.js';
|
|
9
|
-
import { useOutsideClick } from '../../hooks/useOutsideClick.js';
|
|
10
|
-
import { useGlobalKeyPress } from '../../hooks/useGlobalKeyPress.js';
|
|
11
9
|
import { Paper } from '../Paper/Paper.js';
|
|
12
|
-
import { bordersTemplate } from '../../utils/templates/borders.js';
|
|
13
10
|
import { useEds } from '../EdsProvider/eds.context.js';
|
|
14
|
-
import { useToken } from '../../hooks/useToken.js';
|
|
15
|
-
import { usePopper } from '../../hooks/usePopper.js';
|
|
16
11
|
|
|
17
12
|
const {
|
|
18
13
|
border
|
|
@@ -20,28 +15,64 @@ const {
|
|
|
20
15
|
const MenuPaper = styled(Paper).withConfig({
|
|
21
16
|
displayName: "Menu__MenuPaper",
|
|
22
17
|
componentId: "sc-1vlnqcj-0"
|
|
23
|
-
})(["position:absolute;z-index:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
})(["position:absolute;z-index:1400;width:fit-content;min-width:fit-content;", ";", ""], bordersTemplate(border), _ref => {
|
|
19
|
+
let {
|
|
20
|
+
open
|
|
21
|
+
} = _ref;
|
|
22
|
+
return css({
|
|
23
|
+
visibility: open ? null : 'hidden'
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer(_ref2, ref) {
|
|
27
|
+
let {
|
|
28
|
+
children,
|
|
29
|
+
anchorEl,
|
|
30
|
+
onClose: onCloseCallback,
|
|
31
|
+
open,
|
|
32
|
+
containerEl,
|
|
33
|
+
...rest
|
|
34
|
+
} = _ref2;
|
|
36
35
|
const {
|
|
37
36
|
setOnClose,
|
|
38
|
-
onClose
|
|
37
|
+
onClose,
|
|
38
|
+
setInitialFocus
|
|
39
39
|
} = useMenu();
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
if (onClose === null && onCloseCallback) {
|
|
42
42
|
setOnClose(onCloseCallback);
|
|
43
43
|
}
|
|
44
44
|
}, [onClose, onCloseCallback, setOnClose]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const openWithKey = e => {
|
|
47
|
+
const {
|
|
48
|
+
key
|
|
49
|
+
} = e; //activate menu with arrows according to wai-aria best practices
|
|
50
|
+
|
|
51
|
+
if (key === 'ArrowDown' || key === 'ArrowUp') {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
anchorEl.dispatchEvent(new Event('click', {
|
|
55
|
+
bubbles: true
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
switch (key) {
|
|
60
|
+
case 'Enter':
|
|
61
|
+
case 'ArrowDown':
|
|
62
|
+
setInitialFocus('first');
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case 'ArrowUp':
|
|
66
|
+
setInitialFocus('last');
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (anchorEl) anchorEl.addEventListener('keydown', openWithKey);
|
|
72
|
+
return () => {
|
|
73
|
+
if (anchorEl) anchorEl.removeEventListener('keydown', openWithKey);
|
|
74
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
+
}, [anchorEl]);
|
|
45
76
|
useOutsideClick(containerEl, e => {
|
|
46
77
|
if (open && onClose !== null && !anchorEl.contains(e.target)) {
|
|
47
78
|
onClose();
|
|
@@ -55,7 +86,11 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
|
|
|
55
86
|
});
|
|
56
87
|
useGlobalKeyPress('Enter', () => {
|
|
57
88
|
if (open && onClose !== null) {
|
|
58
|
-
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
if (window.document.contains(anchorEl)) {
|
|
91
|
+
anchorEl.focus();
|
|
92
|
+
}
|
|
93
|
+
}, 0);
|
|
59
94
|
}
|
|
60
95
|
});
|
|
61
96
|
return /*#__PURE__*/jsx(MenuList, { ...rest,
|
|
@@ -63,14 +98,15 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer({
|
|
|
63
98
|
children: children
|
|
64
99
|
});
|
|
65
100
|
});
|
|
66
|
-
const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
const Menu = /*#__PURE__*/forwardRef(function Menu(_ref3, ref) {
|
|
102
|
+
let {
|
|
103
|
+
anchorEl,
|
|
104
|
+
open,
|
|
105
|
+
placement = 'auto',
|
|
106
|
+
style,
|
|
107
|
+
className,
|
|
108
|
+
...rest
|
|
109
|
+
} = _ref3;
|
|
74
110
|
const [containerEl, setContainerEl] = useState(null);
|
|
75
111
|
const [storedAnchorEl, setStoredAnchorEl] = useState(null);
|
|
76
112
|
const isMounted = useIsMounted();
|
|
@@ -87,7 +123,12 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
87
123
|
const {
|
|
88
124
|
styles,
|
|
89
125
|
attributes
|
|
90
|
-
} = usePopper(
|
|
126
|
+
} = usePopper({
|
|
127
|
+
anchorEl: storedAnchorEl,
|
|
128
|
+
popperEl: containerEl,
|
|
129
|
+
placement,
|
|
130
|
+
offset: 4
|
|
131
|
+
});
|
|
91
132
|
const props = {
|
|
92
133
|
open,
|
|
93
134
|
style: { ...styles.popper,
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { memo, forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { menu } from './Menu.tokens.js';
|
|
4
|
+
import { typographyTemplate, spacingsTemplate, outlineTemplate, useCombinedRefs } from '@equinor/eds-utils';
|
|
4
5
|
import { useMenu } from './Menu.context.js';
|
|
5
6
|
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs.js';
|
|
7
|
-
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
8
|
-
import { outlineTemplate } from '../../utils/templates/focus.js';
|
|
9
7
|
|
|
10
8
|
const {
|
|
11
9
|
typography,
|
|
@@ -21,32 +19,45 @@ const {
|
|
|
21
19
|
icon
|
|
22
20
|
}
|
|
23
21
|
} = menu;
|
|
24
|
-
const Item = styled.button.attrs(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const Item = styled.button.attrs(_ref => {
|
|
23
|
+
let {
|
|
24
|
+
isFocused
|
|
25
|
+
} = _ref;
|
|
26
|
+
return {
|
|
27
|
+
role: 'menuitem',
|
|
28
|
+
tabIndex: isFocused ? -1 : 0
|
|
29
|
+
};
|
|
30
|
+
}).withConfig({
|
|
30
31
|
displayName: "MenuItem__Item",
|
|
31
32
|
componentId: "sc-1g9fpbe-0"
|
|
32
|
-
})(["border:0;background-color:transparent;width:auto;position:relative;z-index:2;", " ", " ", " ", ""], typographyTemplate(typography),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
})(["border:0;background-color:transparent;width:auto;position:relative;z-index:2;", " ", " ", " ", ""], typographyTemplate(typography), _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
theme
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return spacingsTemplate(theme.entities.item.spacings);
|
|
38
|
+
}, _ref3 => {
|
|
39
|
+
let {
|
|
40
|
+
active
|
|
41
|
+
} = _ref3;
|
|
42
|
+
return active && css(["background:", ";*{color:", ";}"], activeToken.background, activeToken.typography.color);
|
|
43
|
+
}, _ref4 => {
|
|
44
|
+
let {
|
|
45
|
+
disabled
|
|
46
|
+
} = _ref4;
|
|
47
|
+
return disabled ? css(["*{color:", ";}svg{fill:", ";}&:focus{outline:none;}@media (hover:hover) and (pointer:fine){&:hover{cursor:not-allowed;}}"], disabledToken.typography.color, icon.states.disabled.typography.color) : css(["@media (hover:hover) and (pointer:fine){&:hover{z-index:1;cursor:pointer;background:", ";}}&:focus{z-index:3;", "}"], hover.background, outlineTemplate(focus.outline));
|
|
48
|
+
});
|
|
39
49
|
const Content = styled.div.withConfig({
|
|
40
50
|
displayName: "MenuItem__Content",
|
|
41
51
|
componentId: "sc-1g9fpbe-1"
|
|
42
52
|
})(["width:auto;display:grid;grid-gap:16px;grid-auto-flow:column;grid-auto-columns:max-content auto max-content;align-items:center;"]);
|
|
43
|
-
const MenuItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function MenuItem({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
const MenuItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function MenuItem(_ref5, ref) {
|
|
54
|
+
let {
|
|
55
|
+
children,
|
|
56
|
+
disabled,
|
|
57
|
+
index = 0,
|
|
58
|
+
onClick,
|
|
59
|
+
...rest
|
|
60
|
+
} = _ref5;
|
|
50
61
|
const {
|
|
51
62
|
focusedIndex,
|
|
52
63
|
setFocusedIndex,
|
|
@@ -66,8 +77,10 @@ const MenuItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function MenuItem({
|
|
|
66
77
|
};
|
|
67
78
|
return /*#__PURE__*/jsx(Item, { ...props,
|
|
68
79
|
ref: useCombinedRefs(ref, el => {
|
|
69
|
-
if (
|
|
70
|
-
|
|
80
|
+
if (isFocused) {
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
if (el !== null) el.focus();
|
|
83
|
+
});
|
|
71
84
|
}
|
|
72
85
|
}),
|
|
73
86
|
onFocus: () => toggleFocus(index),
|
|
@@ -4,8 +4,8 @@ import { useMenu } from './Menu.context.js';
|
|
|
4
4
|
import { MenuItem } from './MenuItem.js';
|
|
5
5
|
import { MenuSection } from './MenuSection.js';
|
|
6
6
|
import { menu } from './Menu.tokens.js';
|
|
7
|
+
import { spacingsTemplate } from '@equinor/eds-utils';
|
|
7
8
|
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import { spacingsTemplate } from '../../utils/templates/index.js';
|
|
9
9
|
|
|
10
10
|
const List = styled.div.withConfig({
|
|
11
11
|
displayName: "MenuList__List",
|
|
@@ -17,19 +17,24 @@ function isIndexable(item) {
|
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const MenuList = /*#__PURE__*/forwardRef(function MenuList({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
20
|
+
const MenuList = /*#__PURE__*/forwardRef(function MenuList(_ref, ref) {
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
...rest
|
|
24
|
+
} = _ref;
|
|
25
25
|
const {
|
|
26
26
|
focusedIndex,
|
|
27
|
-
setFocusedIndex
|
|
27
|
+
setFocusedIndex,
|
|
28
|
+
initialFocus
|
|
28
29
|
} = useMenu();
|
|
29
30
|
let index = -1;
|
|
30
31
|
const focusableIndexs = useMemo(() => [], []);
|
|
31
32
|
const updatedChildren = useMemo(() => Children.map(children, child => {
|
|
33
|
+
if (!child) return child;
|
|
34
|
+
|
|
32
35
|
if (child.type === MenuSection) {
|
|
36
|
+
index++;
|
|
37
|
+
const menuSectionIndex = index;
|
|
33
38
|
const updatedGrandChildren = Children.map(child.props.children, grandChild => {
|
|
34
39
|
index++;
|
|
35
40
|
if (isIndexable(grandChild)) focusableIndexs.push(index);
|
|
@@ -37,7 +42,9 @@ const MenuList = /*#__PURE__*/forwardRef(function MenuList({
|
|
|
37
42
|
index
|
|
38
43
|
});
|
|
39
44
|
});
|
|
40
|
-
return /*#__PURE__*/cloneElement(child,
|
|
45
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
46
|
+
index: menuSectionIndex
|
|
47
|
+
}, updatedGrandChildren);
|
|
41
48
|
} else {
|
|
42
49
|
index++;
|
|
43
50
|
if (isIndexable(child)) focusableIndexs.push(index);
|
|
@@ -49,15 +56,15 @@ const MenuList = /*#__PURE__*/forwardRef(function MenuList({
|
|
|
49
56
|
const firstFocusIndex = focusableIndexs[0];
|
|
50
57
|
const lastFocusIndex = focusableIndexs[focusableIndexs.length - 1];
|
|
51
58
|
useEffect(() => {
|
|
52
|
-
if (
|
|
59
|
+
if (initialFocus === 'first') {
|
|
53
60
|
setFocusedIndex(firstFocusIndex);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
|
-
if (
|
|
63
|
+
if (initialFocus === 'last') {
|
|
57
64
|
setFocusedIndex(lastFocusIndex);
|
|
58
65
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
66
|
|
|
60
|
-
}, [
|
|
67
|
+
}, [initialFocus, firstFocusIndex, lastFocusIndex]);
|
|
61
68
|
|
|
62
69
|
const handleMenuItemChange = (direction, fallbackIndex) => {
|
|
63
70
|
const i = direction === 'down' ? 1 : -1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { menu } from './Menu.tokens.js';
|
|
4
|
+
import { spacingsTemplate } from '@equinor/eds-utils';
|
|
4
5
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
|
-
import { spacingsTemplate } from '../../utils/templates/index.js';
|
|
6
6
|
import { Divider } from '../Divider/Divider.js';
|
|
7
7
|
import { Typography } from '../Typography/Typography.js';
|
|
8
8
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { forwardRef, useState, useLayoutEffect } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { useIsMounted } from '@equinor/eds-utils';
|
|
3
4
|
import { Icon } from '../Icon/index.js';
|
|
4
5
|
import { PaginationItem } from './PaginationItem.js';
|
|
5
6
|
import { pagination } from './Pagination.tokens.js';
|
|
6
7
|
import { chevron_left, chevron_right, more_horizontal } from '@equinor/eds-icons';
|
|
7
8
|
import { PaginationControl } from './paginationControl.js';
|
|
8
9
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
-
import { useIsMounted } from '../../hooks/useMountedRef.js';
|
|
10
10
|
import { Typography } from '../Typography/Typography.js';
|
|
11
11
|
import { Button } from '../Button/Button.js';
|
|
12
12
|
|
|
@@ -19,9 +19,12 @@ Icon.add(icons);
|
|
|
19
19
|
const Navigation = styled.nav.withConfig({
|
|
20
20
|
displayName: "Pagination__Navigation",
|
|
21
21
|
componentId: "sc-13cpp3o-0"
|
|
22
|
-
})(["display:flex;justify-content:space-between;align-items:center;flex-wrap:nowrap;margin-left:", ";"],
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
})(["display:flex;justify-content:space-between;align-items:center;flex-wrap:nowrap;margin-left:", ";"], _ref => {
|
|
23
|
+
let {
|
|
24
|
+
withItemIndicator
|
|
25
|
+
} = _ref;
|
|
26
|
+
return withItemIndicator ? pagination.spacings.left : 0;
|
|
27
|
+
});
|
|
25
28
|
const OrderedList = styled.ol.withConfig({
|
|
26
29
|
displayName: "Pagination__OrderedList",
|
|
27
30
|
componentId: "sc-13cpp3o-1"
|
|
@@ -47,14 +50,15 @@ function getAriaLabel(page, selected) {
|
|
|
47
50
|
return "".concat(selected === page ? 'Current page, ' : 'Go to ', "page ").concat(page);
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
const Pagination = /*#__PURE__*/forwardRef(function Pagination({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const Pagination = /*#__PURE__*/forwardRef(function Pagination(_ref2, ref) {
|
|
54
|
+
let {
|
|
55
|
+
totalItems,
|
|
56
|
+
defaultPage = 1,
|
|
57
|
+
withItemIndicator,
|
|
58
|
+
itemsPerPage = 10,
|
|
59
|
+
onChange,
|
|
60
|
+
...rest
|
|
61
|
+
} = _ref2;
|
|
58
62
|
const pages = Math.ceil(totalItems / itemsPerPage); // Total page numbers
|
|
59
63
|
|
|
60
64
|
const columns = pages < 5 ? pages + 2 : 7; // Total pages to display on the control + 2: < and >
|
|
@@ -3,12 +3,13 @@ import { pagination } from './Pagination.tokens.js';
|
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { Button } from '../Button/Button.js';
|
|
5
5
|
|
|
6
|
-
const PaginationItem = /*#__PURE__*/forwardRef(function PaginationItem({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const PaginationItem = /*#__PURE__*/forwardRef(function PaginationItem(_ref, ref) {
|
|
7
|
+
let {
|
|
8
|
+
page,
|
|
9
|
+
selected,
|
|
10
|
+
onClick,
|
|
11
|
+
...rest
|
|
12
|
+
} = _ref;
|
|
12
13
|
const props = {
|
|
13
14
|
ref,
|
|
14
15
|
page,
|
|
@@ -6,13 +6,17 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
6
6
|
const StyledPaper = styled.div.withConfig({
|
|
7
7
|
displayName: "Paper__StyledPaper",
|
|
8
8
|
componentId: "sc-6ncnv9-0"
|
|
9
|
-
})(["min-width:", ";max-width:", ";background:", ";box-shadow:", ";"], paper.minWidth, paper.maxWidth, paper.background,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
})(["min-width:", ";max-width:", ";background:", ";box-shadow:", ";"], paper.minWidth, paper.maxWidth, paper.background, _ref => {
|
|
10
|
+
let {
|
|
11
|
+
elevation
|
|
12
|
+
} = _ref;
|
|
13
|
+
return elevation;
|
|
14
|
+
});
|
|
15
|
+
const Paper = /*#__PURE__*/forwardRef(function Paper(_ref2, ref) {
|
|
16
|
+
let {
|
|
17
|
+
elevation: elevation$1,
|
|
18
|
+
...rest
|
|
19
|
+
} = _ref2;
|
|
16
20
|
const props = { ...rest,
|
|
17
21
|
elevation: elevation[elevation$1] || 'none'
|
|
18
22
|
};
|