@equinor/eds-core-react 0.17.0 → 0.18.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/README.md +1 -1
- package/dist/{core-react.cjs.js → eds-core-react.cjs.js} +2164 -1915
- package/dist/esm/components/Accordion/Accordion.js +9 -9
- package/dist/esm/components/Accordion/AccordionHeader.js +45 -38
- 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 +17 -10
- 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 +4 -4
- 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/Input.js +72 -46
- package/dist/esm/components/Chip/Chip.js +46 -30
- 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 +5 -4
- package/dist/esm/components/Menu/Menu.js +32 -28
- package/dist/esm/components/Menu/MenuItem.js +38 -25
- package/dist/esm/components/Menu/MenuList.js +7 -6
- 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 +37 -49
- 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/Scrim/Scrim.js +10 -10
- 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 +63 -35
- 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/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 +1 -0
- 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 +16 -23
- 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/index.js +1 -0
- 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/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.d.ts +1 -1
- 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/dist/types/index.d.ts +1 -0
- package/package.json +40 -41
- 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/Combobox/Combobox.d.ts +0 -55
- package/dist/types/components/Combobox/Combobox.tokens.d.ts +0 -3
- package/dist/types/components/Combobox/index.d.ts +0 -1
- 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,46 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
5
|
-
import { Divider } from '../Divider/Divider.js';
|
|
6
|
-
|
|
7
|
-
const StyledCustomContent = styled.div.withConfig({
|
|
8
|
-
displayName: "CustomContent__StyledCustomContent",
|
|
9
|
-
componentId: "sc-17fsw6x-0"
|
|
10
|
-
})(({
|
|
11
|
-
theme,
|
|
12
|
-
scrollable
|
|
13
|
-
}) => {
|
|
14
|
-
return css(["", " min-height:", ";margin-bottom:", ";align-self:stretch;justify-self:stretch;", " ", ""], typographyTemplate(theme.entities.content.typography), theme.entities.content.minHeight, theme.entities.content.spacings.bottom, spacingsTemplate(theme.entities.children.spacings), scrollable && css(["min-height:initial;height:", ";overflow-y:auto;"], theme.entities.content.height));
|
|
15
|
-
});
|
|
16
|
-
const StyledDivider = styled(Divider).withConfig({
|
|
17
|
-
displayName: "CustomContent__StyledDivider",
|
|
18
|
-
componentId: "sc-17fsw6x-1"
|
|
19
|
-
})(({
|
|
20
|
-
theme
|
|
21
|
-
}) => {
|
|
22
|
-
return css(["width:100%;margin-bottom:", ";"], theme.entities.divider.spacings.bottom);
|
|
23
|
-
});
|
|
24
|
-
const CustomContent = /*#__PURE__*/forwardRef(function CustomContent({
|
|
25
|
-
children,
|
|
26
|
-
scrollable = false,
|
|
27
|
-
...rest
|
|
28
|
-
}, ref) {
|
|
29
|
-
const props = {
|
|
30
|
-
scrollable,
|
|
31
|
-
ref,
|
|
32
|
-
...rest
|
|
33
|
-
};
|
|
34
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
35
|
-
children: [/*#__PURE__*/jsx(StyledCustomContent, {
|
|
36
|
-
id: "eds-dialog-customcontent",
|
|
37
|
-
...props,
|
|
38
|
-
children: children
|
|
39
|
-
}), children && scrollable && /*#__PURE__*/jsx(StyledDivider, {
|
|
40
|
-
color: "medium",
|
|
41
|
-
variant: "small"
|
|
42
|
-
})]
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export { CustomContent };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { Divider } from '../Divider/Divider.js';
|
|
5
|
-
import { typographyTemplate, spacingsTemplate } from '../../utils/templates/index.js';
|
|
6
|
-
|
|
7
|
-
const StyledTitle = styled.div.withConfig({
|
|
8
|
-
displayName: "Title__StyledTitle",
|
|
9
|
-
componentId: "sc-i4qfl5-0"
|
|
10
|
-
})(({
|
|
11
|
-
theme,
|
|
12
|
-
children
|
|
13
|
-
}) => {
|
|
14
|
-
return css(["", " min-height:", ";align-self:end;justify-self:start;", ";", ""], typographyTemplate(theme.entities.title.typography), theme.entities.title.minHeight, spacingsTemplate(theme.entities.children.spacings), !children && css(["min-height:initial;height:'8px';"]));
|
|
15
|
-
});
|
|
16
|
-
const StyledDivider = styled(Divider).withConfig({
|
|
17
|
-
displayName: "Title__StyledDivider",
|
|
18
|
-
componentId: "sc-i4qfl5-1"
|
|
19
|
-
})(({
|
|
20
|
-
theme
|
|
21
|
-
}) => {
|
|
22
|
-
return css(["width:100%;margin-bottom:", ";"], theme.entities.divider.spacings.bottom);
|
|
23
|
-
});
|
|
24
|
-
const Title = /*#__PURE__*/forwardRef(function Title({
|
|
25
|
-
children,
|
|
26
|
-
...rest
|
|
27
|
-
}, ref) {
|
|
28
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
29
|
-
children: [/*#__PURE__*/jsx(StyledTitle, {
|
|
30
|
-
id: "eds-dialog-title",
|
|
31
|
-
ref: ref,
|
|
32
|
-
...rest,
|
|
33
|
-
children: children
|
|
34
|
-
}), children && /*#__PURE__*/jsx(StyledDivider, {
|
|
35
|
-
color: "medium",
|
|
36
|
-
variant: "small"
|
|
37
|
-
})]
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export { Title };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useAutoResize = (targetEl, maxHeight) => {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
const handleResize = () => {
|
|
6
|
-
targetEl.style.height = 'auto';
|
|
7
|
-
const {
|
|
8
|
-
scrollHeight,
|
|
9
|
-
clientHeight
|
|
10
|
-
} = targetEl;
|
|
11
|
-
let newHeight = clientHeight;
|
|
12
|
-
|
|
13
|
-
if (maxHeight > newHeight) {
|
|
14
|
-
newHeight = Math.min(maxHeight, Math.max(scrollHeight, newHeight));
|
|
15
|
-
|
|
16
|
-
if (scrollHeight > maxHeight) {
|
|
17
|
-
targetEl.style.overflow = 'auto';
|
|
18
|
-
} else {
|
|
19
|
-
targetEl.style.overflow = 'hidden';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (newHeight > clientHeight) {
|
|
23
|
-
targetEl.style.height = "".concat(newHeight, "px");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
if (targetEl && maxHeight) {
|
|
29
|
-
handleResize();
|
|
30
|
-
targetEl.addEventListener('keyup', handleResize, true);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return () => {
|
|
34
|
-
targetEl === null || targetEl === void 0 ? void 0 : targetEl.removeEventListener('keyup', handleResize, true);
|
|
35
|
-
};
|
|
36
|
-
}, [targetEl, maxHeight]);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { useAutoResize };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
/** Returns a memoized function that calls passed refs sequentially with passed element */
|
|
4
|
-
const useCombinedRefs = (...refs) => {
|
|
5
|
-
return useCallback(element => refs.forEach(ref => {
|
|
6
|
-
if (typeof ref === 'function') {
|
|
7
|
-
ref(element);
|
|
8
|
-
} else if (ref && typeof ref === 'object') {
|
|
9
|
-
ref.current = element;
|
|
10
|
-
}
|
|
11
|
-
}), [refs]);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useCombinedRefs };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
var KEY;
|
|
4
|
-
|
|
5
|
-
(function (KEY) {
|
|
6
|
-
KEY["Escape"] = "Escape";
|
|
7
|
-
KEY["Enter"] = "Enter";
|
|
8
|
-
KEY["Tab"] = "Tab";
|
|
9
|
-
KEY["ArrowDown"] = "ArrowDown";
|
|
10
|
-
KEY["ArrowUp"] = "ArrowUp";
|
|
11
|
-
})(KEY || (KEY = {}));
|
|
12
|
-
|
|
13
|
-
const useGlobalKeyPress = (targetKey, callback) => {
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const handleGlobalKeyPress = e => {
|
|
16
|
-
const {
|
|
17
|
-
key
|
|
18
|
-
} = e;
|
|
19
|
-
|
|
20
|
-
switch (key) {
|
|
21
|
-
case targetKey:
|
|
22
|
-
callback(e);
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
document.addEventListener('keydown', handleGlobalKeyPress, true);
|
|
28
|
-
return () => {
|
|
29
|
-
document.removeEventListener('keydown', handleGlobalKeyPress, true);
|
|
30
|
-
};
|
|
31
|
-
}, [targetKey, callback]);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { useGlobalKeyPress };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useHideBodyScroll = active => {
|
|
4
|
-
const overflowState = useRef(document.body.style.overflow);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const originalState = overflowState.current;
|
|
7
|
-
|
|
8
|
-
if (active) {
|
|
9
|
-
document.body.style.overflow = 'hidden';
|
|
10
|
-
} else {
|
|
11
|
-
document.body.style.overflow = originalState;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return () => {
|
|
15
|
-
document.body.style.overflow = originalState;
|
|
16
|
-
};
|
|
17
|
-
}, [active]);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { useHideBodyScroll };
|
package/dist/esm/hooks/useId.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useId = (idOverride, type) => {
|
|
4
|
-
const [defaultId, setDefaultId] = useState(idOverride);
|
|
5
|
-
const id = idOverride || defaultId;
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (defaultId == null) {
|
|
8
|
-
setDefaultId("eds-".concat(type ? type + "-" : '').concat(Math.round(Math.random() * 1e5)));
|
|
9
|
-
}
|
|
10
|
-
}, [defaultId, type]);
|
|
11
|
-
return id;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useId };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useIsMounted = () => {
|
|
4
|
-
const [isMounted, setIsMounted] = useState(null);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
setIsMounted(true);
|
|
7
|
-
return () => setIsMounted(false);
|
|
8
|
-
}, []);
|
|
9
|
-
return isMounted;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { useIsMounted };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useOutsideClick = (el, callback) => {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
const handleClick = e => {
|
|
6
|
-
if (el && !el.contains(e.target)) {
|
|
7
|
-
callback(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
document.addEventListener('click', handleClick);
|
|
12
|
-
return () => {
|
|
13
|
-
document.removeEventListener('click', handleClick);
|
|
14
|
-
};
|
|
15
|
-
}, [el, callback]);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { useOutsideClick };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { usePopper as usePopper$1 } from 'react-popper';
|
|
2
|
-
|
|
3
|
-
const usePopper = (anchorEl, popperEl, arrowRef, placement, offset = 10) => {
|
|
4
|
-
if (placement === undefined) {
|
|
5
|
-
placement = 'auto';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
styles,
|
|
10
|
-
attributes
|
|
11
|
-
} = usePopper$1(anchorEl, popperEl, {
|
|
12
|
-
placement,
|
|
13
|
-
modifiers: [{
|
|
14
|
-
name: 'arrow',
|
|
15
|
-
options: {
|
|
16
|
-
element: arrowRef
|
|
17
|
-
}
|
|
18
|
-
}, {
|
|
19
|
-
name: 'offset',
|
|
20
|
-
options: {
|
|
21
|
-
offset: [0, offset]
|
|
22
|
-
}
|
|
23
|
-
}]
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
styles,
|
|
27
|
-
attributes
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { usePopper };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import mergeDeepRight_1 from '../node_modules/.pnpm/ramda@0.27.1/node_modules/ramda/src/mergeDeepRight.js';
|
|
3
|
-
|
|
4
|
-
const useToken = (options, token) => useCallback(() => {
|
|
5
|
-
const {
|
|
6
|
-
density
|
|
7
|
-
} = options;
|
|
8
|
-
|
|
9
|
-
if (density === 'compact') {
|
|
10
|
-
return mergeDeepRight_1(token, token.modes.compact);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return token;
|
|
14
|
-
}, [options, token]);
|
|
15
|
-
|
|
16
|
-
export { useToken };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Workaround
|
|
2
|
-
// React ignores 'dispathEvent' on input/textarea, see https://github.com/facebook/react/issues/10135
|
|
3
|
-
const setReactInputValue = (input, value) => {
|
|
4
|
-
const previousValue = input.value;
|
|
5
|
-
input.value = value;
|
|
6
|
-
const tracker = input._valueTracker;
|
|
7
|
-
|
|
8
|
-
if (typeof tracker !== 'undefined') {
|
|
9
|
-
tracker.setValue(previousValue);
|
|
10
|
-
} //'change' instead of 'input', see https://github.com/facebook/react/issues/11488#issuecomment-381590324
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
input.dispatchEvent(new Event('change', {
|
|
14
|
-
bubbles: true
|
|
15
|
-
}));
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { setReactInputValue };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { css } from 'styled-components';
|
|
2
|
-
import { shorthand } from './common.js';
|
|
3
|
-
|
|
4
|
-
const bordersTemplate = border => {
|
|
5
|
-
var _border$left, _border$left2, _border$right, _border$right2;
|
|
6
|
-
|
|
7
|
-
if (!border) {
|
|
8
|
-
return css({});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
switch (border.type) {
|
|
12
|
-
case 'border':
|
|
13
|
-
return css({
|
|
14
|
-
border: shorthand(border),
|
|
15
|
-
borderRadius: border.radius
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
case 'bordergroup':
|
|
19
|
-
return css({
|
|
20
|
-
borderBottom: shorthand(border.bottom),
|
|
21
|
-
borderTop: shorthand(border.top),
|
|
22
|
-
borderLeft: shorthand(border.left),
|
|
23
|
-
borderRight: shorthand(border.right),
|
|
24
|
-
borderBottomLeftRadius: border === null || border === void 0 ? void 0 : (_border$left = border.left) === null || _border$left === void 0 ? void 0 : _border$left.radius,
|
|
25
|
-
borderTopLeftRadius: border === null || border === void 0 ? void 0 : (_border$left2 = border.left) === null || _border$left2 === void 0 ? void 0 : _border$left2.radius,
|
|
26
|
-
borderBottomRightRadius: border === null || border === void 0 ? void 0 : (_border$right = border.right) === null || _border$right === void 0 ? void 0 : _border$right.radius,
|
|
27
|
-
borderTopRightRadius: border === null || border === void 0 ? void 0 : (_border$right2 = border.right) === null || _border$right2 === void 0 ? void 0 : _border$right2.radius
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
default:
|
|
31
|
-
return css({});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { bordersTemplate };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const shorthand = token => {
|
|
2
|
-
if (!token) {
|
|
3
|
-
return undefined;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
width = '',
|
|
8
|
-
style = '',
|
|
9
|
-
color = ''
|
|
10
|
-
} = token;
|
|
11
|
-
|
|
12
|
-
if (!width) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return "".concat(width, " ").concat(style, " ").concat(color);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { shorthand };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { css } from 'styled-components';
|
|
2
|
-
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
-
import { shorthand } from './common.js';
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
colors: {
|
|
7
|
-
interactive: {
|
|
8
|
-
focus: {
|
|
9
|
-
rgba: focusColor
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
} = tokens;
|
|
14
|
-
const outlineTemplate = outline => {
|
|
15
|
-
const {
|
|
16
|
-
color = focusColor,
|
|
17
|
-
style = 'dashed',
|
|
18
|
-
width = '1px',
|
|
19
|
-
offset = '0px',
|
|
20
|
-
type
|
|
21
|
-
} = outline;
|
|
22
|
-
const outline_ = {
|
|
23
|
-
color,
|
|
24
|
-
style,
|
|
25
|
-
width,
|
|
26
|
-
offset,
|
|
27
|
-
type
|
|
28
|
-
};
|
|
29
|
-
return css({
|
|
30
|
-
outline: shorthand(outline_),
|
|
31
|
-
outlineOffset: outline_.offset
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { outlineTemplate };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { css } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
const typographyTemplate = (typography, link) => {
|
|
4
|
-
if (!typography) {
|
|
5
|
-
return '';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
let base = "\n margin: 0;\n color: ".concat(typography.color, ";\n font-family: ").concat(typography.fontFamily, ";\n font-size: ").concat(typography.fontSize, ";\n font-weight: ").concat(typography.fontWeight, ";\n line-height: ").concat(typography.lineHeight, ";\n ");
|
|
9
|
-
|
|
10
|
-
if (typography.fontStyle) {
|
|
11
|
-
base += "\nfont-style: ".concat(typography.fontStyle, ";");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (typography.letterSpacing) {
|
|
15
|
-
base += "\nletter-spacing: ".concat(typography.letterSpacing, ";");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typography.textTransform) {
|
|
19
|
-
base += "\ntext-transform: ".concat(typography.textTransform, ";");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (typography.textDecoration) {
|
|
23
|
-
base += "\ntext-decoration: ".concat(typography.textDecoration, ";");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (typography.textAlign) {
|
|
27
|
-
base += "\ntext-align: ".concat(typography.textAlign, ";");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typography.fontFeature) {
|
|
31
|
-
base += "\nfont-feature-settings: ".concat(typography.fontFeature, ";");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (link) {
|
|
35
|
-
base += "\ncursor: pointer;";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return base;
|
|
39
|
-
};
|
|
40
|
-
const spacingsTemplate = ({
|
|
41
|
-
left,
|
|
42
|
-
right,
|
|
43
|
-
top,
|
|
44
|
-
bottom
|
|
45
|
-
}) => css({
|
|
46
|
-
paddingLeft: left,
|
|
47
|
-
paddingTop: top,
|
|
48
|
-
paddingRight: right,
|
|
49
|
-
paddingBottom: bottom
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export { spacingsTemplate, typographyTemplate };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { SelectHTMLAttributes } from 'react';
|
|
2
|
-
export declare type ComboboxChanges = {
|
|
3
|
-
selectedItems: string[];
|
|
4
|
-
inputValue: string;
|
|
5
|
-
};
|
|
6
|
-
export declare type ComboboxProps = {
|
|
7
|
-
/** List of options to choose from */
|
|
8
|
-
items: string[];
|
|
9
|
-
/** Label for the select element */
|
|
10
|
-
label: string;
|
|
11
|
-
/** Array of initial selected items */
|
|
12
|
-
initialSelectedItems?: string[];
|
|
13
|
-
/** Meta text, for instance unit */
|
|
14
|
-
meta?: string;
|
|
15
|
-
/** Disabled state */
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
/** Read Only */
|
|
18
|
-
readOnly?: boolean;
|
|
19
|
-
/** If this prop is used, the select will become a controlled component. Use an empty
|
|
20
|
-
* array [] if there will be no initial selected items
|
|
21
|
-
* Note that this prop replaces the need for ```initialSelectedItems```
|
|
22
|
-
* The items that should be selected. */
|
|
23
|
-
selectedOptions?: string[];
|
|
24
|
-
/** Callback for the selected item change
|
|
25
|
-
* changes.selectedItem gives the selected item
|
|
26
|
-
*/
|
|
27
|
-
handleSelectedItemsChange?: (changes: ComboboxChanges) => void;
|
|
28
|
-
/** Enable multiselect */
|
|
29
|
-
multiple?: boolean;
|
|
30
|
-
} & SelectHTMLAttributes<HTMLSelectElement>;
|
|
31
|
-
export declare const Combobox: import("react").ForwardRefExoticComponent<{
|
|
32
|
-
/** List of options to choose from */
|
|
33
|
-
items: string[];
|
|
34
|
-
/** Label for the select element */
|
|
35
|
-
label: string;
|
|
36
|
-
/** Array of initial selected items */
|
|
37
|
-
initialSelectedItems?: string[];
|
|
38
|
-
/** Meta text, for instance unit */
|
|
39
|
-
meta?: string;
|
|
40
|
-
/** Disabled state */
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
/** Read Only */
|
|
43
|
-
readOnly?: boolean;
|
|
44
|
-
/** If this prop is used, the select will become a controlled component. Use an empty
|
|
45
|
-
* array [] if there will be no initial selected items
|
|
46
|
-
* Note that this prop replaces the need for ```initialSelectedItems```
|
|
47
|
-
* The items that should be selected. */
|
|
48
|
-
selectedOptions?: string[];
|
|
49
|
-
/** Callback for the selected item change
|
|
50
|
-
* changes.selectedItem gives the selected item
|
|
51
|
-
*/
|
|
52
|
-
handleSelectedItemsChange?: (changes: ComboboxChanges) => void;
|
|
53
|
-
/** Enable multiselect */
|
|
54
|
-
multiple?: boolean;
|
|
55
|
-
} & SelectHTMLAttributes<HTMLSelectElement> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Combobox';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { useOutsideClick } from './useOutsideClick';
|
|
2
|
-
export { useCombinedRefs } from './useCombinedRefs';
|
|
3
|
-
export * from './usePopper';
|
|
4
|
-
export { useGlobalKeyPress } from './useGlobalKeyPress';
|
|
5
|
-
export { useId } from './useId';
|
|
6
|
-
export { useIsMounted } from './useMountedRef';
|
|
7
|
-
export { useAutoResize } from './useAutoResize';
|
|
8
|
-
export * from './useToken';
|
|
9
|
-
export { useHideBodyScroll } from './useHideBodyScroll';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useAutoResize: (targetEl: HTMLElement, maxHeight?: number) => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare enum KEY {
|
|
2
|
-
Escape = "Escape",
|
|
3
|
-
Enter = "Enter",
|
|
4
|
-
Tab = "Tab",
|
|
5
|
-
ArrowDown = "ArrowDown",
|
|
6
|
-
ArrowUp = "ArrowUp"
|
|
7
|
-
}
|
|
8
|
-
declare type KEYTYPES = keyof typeof KEY;
|
|
9
|
-
export declare const useGlobalKeyPress: (targetKey: KEYTYPES, callback: (e: KeyboardEvent) => void) => void;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useHideBodyScroll: (active: boolean) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useId: (idOverride: string, type?: string) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useIsMounted: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useOutsideClick: (el: HTMLElement, callback: (e: MouseEvent) => void) => void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
2
|
-
export declare type Placement = 'auto' | 'auto-start' | 'auto-end' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
|
|
3
|
-
export declare const usePopper: (anchorEl: HTMLElement, popperEl: HTMLElement, arrowRef?: HTMLElement | string, placement?: Placement, offset?: number) => {
|
|
4
|
-
styles: {
|
|
5
|
-
[key: string]: CSSProperties;
|
|
6
|
-
};
|
|
7
|
-
attributes: {
|
|
8
|
-
[key: string]: {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ComponentToken } from '@equinor/eds-tokens';
|
|
2
|
-
import type { Density } from '../components/EdsProvider';
|
|
3
|
-
declare type UseToken = (options: {
|
|
4
|
-
density: Density;
|
|
5
|
-
}, token: ComponentToken) => () => ComponentToken;
|
|
6
|
-
export declare const useToken: UseToken;
|
|
7
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FlattenSimpleInterpolation } from 'styled-components';
|
|
2
|
-
export declare type StyledCSS = FlattenSimpleInterpolation;
|
|
3
|
-
declare type Shorthand = (token: {
|
|
4
|
-
width?: string | number;
|
|
5
|
-
style?: string;
|
|
6
|
-
color?: string;
|
|
7
|
-
}) => string;
|
|
8
|
-
export declare const shorthand: Shorthand;
|
|
9
|
-
export {};
|