@equinor/fusion-framework-react-components-bookmark 1.0.8 → 1.0.10
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/CHANGELOG.md +234 -215
- package/dist/esm/components/Bookmark.js.map +1 -1
- package/dist/esm/components/BookmarkProvider.js.map +1 -1
- package/dist/esm/components/create-bookmark/CreateBookmark.js.map +1 -1
- package/dist/esm/components/edit-bookmark/EditBookmark.js +1 -3
- package/dist/esm/components/edit-bookmark/EditBookmark.js.map +1 -1
- package/dist/esm/components/filter/Filter.js +2 -5
- package/dist/esm/components/filter/Filter.js.map +1 -1
- package/dist/esm/components/import-bookmark/ImportBookmark.js.map +1 -1
- package/dist/esm/components/loading/Loading.js.map +1 -1
- package/dist/esm/components/messages/Message.js.map +1 -1
- package/dist/esm/components/row/MoreMenu.js.map +1 -1
- package/dist/esm/components/row/Row.js.map +1 -1
- package/dist/esm/components/section/Section.js.map +1 -1
- package/dist/esm/components/sectionList/SectionList.js.map +1 -1
- package/dist/esm/components/shared/SharedIcon.js.map +1 -1
- package/dist/esm/hooks/useBookmarkGrouping.js.map +1 -1
- package/dist/esm/utils/append-bookmark-to-uri.js.map +1 -1
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/BookmarkProvider.d.ts +1 -1
- package/dist/types/components/filter/Filter.d.ts +1 -1
- package/dist/types/components/messages/Message.d.ts +1 -1
- package/dist/types/components/row/MoreMenu.d.ts +2 -2
- package/dist/types/components/row/Row.d.ts +1 -1
- package/dist/types/components/section/Section.d.ts +1 -1
- package/dist/types/components/sectionList/SectionList.d.ts +1 -1
- package/dist/types/hooks/useBookmarkGrouping.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -8
- package/src/components/Bookmark.tsx +46 -47
- package/src/components/BookmarkProvider.tsx +78 -78
- package/src/components/create-bookmark/CreateBookmark.tsx +96 -96
- package/src/components/edit-bookmark/EditBookmark.tsx +149 -152
- package/src/components/filter/Filter.tsx +21 -41
- package/src/components/import-bookmark/ImportBookmark.tsx +61 -65
- package/src/components/loading/Loading.tsx +11 -11
- package/src/components/messages/Message.tsx +47 -47
- package/src/components/row/MoreMenu.tsx +27 -27
- package/src/components/row/Row.tsx +56 -56
- package/src/components/section/Section.tsx +17 -17
- package/src/components/sectionList/SectionList.tsx +137 -143
- package/src/components/shared/SharedIcon.tsx +19 -19
- package/src/hooks/useBookmarkGrouping.ts +37 -37
- package/src/utils/append-bookmark-to-uri.ts +3 -3
- package/src/utils/utils.ts +6 -6
- package/src/version.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Icon, Typography } from '@equinor/eds-core-react';
|
|
2
2
|
import { tokens } from '@equinor/eds-tokens';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
+
import type { PropsWithChildren } from 'react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
|
|
6
6
|
import { error_outlined, file_description } from '@equinor/eds-icons';
|
|
@@ -8,25 +8,25 @@ import { error_outlined, file_description } from '@equinor/eds-icons';
|
|
|
8
8
|
export type PortalMessageType = 'Error' | 'Info' | 'Warning' | 'NoContent';
|
|
9
9
|
|
|
10
10
|
const getMessageType = (type?: PortalMessageType) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
switch (type) {
|
|
12
|
+
case 'Error':
|
|
13
|
+
return { color: tokens.colors.interactive.danger__resting.hex, icon: error_outlined };
|
|
14
|
+
case 'Info':
|
|
15
|
+
return { color: tokens.colors.interactive.primary__resting.hex, icon: error_outlined };
|
|
16
|
+
case 'Warning':
|
|
17
|
+
return { color: tokens.colors.interactive.warning__resting.hex, icon: error_outlined };
|
|
18
|
+
case 'NoContent':
|
|
19
|
+
return {
|
|
20
|
+
color: tokens.colors.interactive.primary__resting.hex,
|
|
21
|
+
icon: file_description,
|
|
22
|
+
};
|
|
23
|
+
default:
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const Styles = {
|
|
29
|
-
|
|
29
|
+
Wrapper: styled.div`
|
|
30
30
|
width: 100%;
|
|
31
31
|
height: 100%;
|
|
32
32
|
display: flex;
|
|
@@ -35,7 +35,7 @@ const Styles = {
|
|
|
35
35
|
gap: 1rem;
|
|
36
36
|
justify-content: center;
|
|
37
37
|
`,
|
|
38
|
-
|
|
38
|
+
Content: styled.div`
|
|
39
39
|
display: flex;
|
|
40
40
|
flex-direction: column;
|
|
41
41
|
align-items: center;
|
|
@@ -45,38 +45,38 @@ const Styles = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
type MessageProps = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
readonly title: string;
|
|
49
|
+
readonly body?: React.FC | string;
|
|
50
|
+
readonly type?: PortalMessageType;
|
|
51
|
+
readonly color?: string;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export const Message = ({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
title,
|
|
56
|
+
type = 'Info',
|
|
57
|
+
color,
|
|
58
|
+
children,
|
|
59
59
|
}: PropsWithChildren<MessageProps>) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
const currentType = getMessageType(type);
|
|
61
|
+
return (
|
|
62
|
+
<Styles.Wrapper>
|
|
63
|
+
<Icon
|
|
64
|
+
data-testid="icon"
|
|
65
|
+
size={40}
|
|
66
|
+
color={currentType?.color || color || tokens.colors.text.static_icons__tertiary.hex}
|
|
67
|
+
data={currentType?.icon || error_outlined}
|
|
68
|
+
/>
|
|
69
|
+
<Styles.Content>
|
|
70
|
+
<Typography
|
|
71
|
+
color={tokens.colors.text.static_icons__default.hex}
|
|
72
|
+
variant={'h3'}
|
|
73
|
+
aria-label={`Title for ${type} message`}
|
|
74
|
+
>
|
|
75
|
+
{title}
|
|
76
|
+
</Typography>
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
<Typography>{children && children}</Typography>
|
|
79
|
+
</Styles.Content>
|
|
80
|
+
</Styles.Wrapper>
|
|
81
|
+
);
|
|
82
82
|
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { Menu } from '@equinor/eds-core-react';
|
|
2
|
-
import { MutableRefObject } from 'react';
|
|
3
|
-
import { MenuOption } from './Row';
|
|
2
|
+
import type { MutableRefObject } from 'react';
|
|
3
|
+
import type { MenuOption } from './Row';
|
|
4
4
|
|
|
5
5
|
type MenuProps = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
readonly pRef: MutableRefObject<HTMLElement | null>;
|
|
7
|
+
readonly onClose: VoidFunction;
|
|
8
|
+
readonly open: boolean;
|
|
9
|
+
readonly options: MenuOption[];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const MoreMenu = ({ pRef, onClose, open, options }: MenuProps) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
return (
|
|
14
|
+
<Menu open={open} anchorEl={pRef.current}>
|
|
15
|
+
{options.map(({ onClick, name, disabled, Icon }) => (
|
|
16
|
+
<Menu.Item
|
|
17
|
+
disabled={disabled}
|
|
18
|
+
onClick={(e) => {
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
onClick();
|
|
22
|
+
onClose();
|
|
23
|
+
}}
|
|
24
|
+
key={name}
|
|
25
|
+
>
|
|
26
|
+
<>
|
|
27
|
+
{Icon && Icon}
|
|
28
|
+
{name}
|
|
29
|
+
</>
|
|
30
|
+
</Menu.Item>
|
|
31
|
+
))}
|
|
32
|
+
</Menu>
|
|
33
|
+
);
|
|
34
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Icon, Typography } from '@equinor/eds-core-react';
|
|
2
2
|
import { tokens } from '@equinor/eds-tokens';
|
|
3
3
|
import { useOutsideClick } from '@equinor/eds-utils';
|
|
4
|
-
import { MutableRefObject, ReactNode, useCallback, useRef } from 'react';
|
|
4
|
+
import { type MutableRefObject, type ReactNode, useCallback, useRef } from 'react';
|
|
5
5
|
import { MoreMenu } from './MoreMenu';
|
|
6
6
|
|
|
7
7
|
import styled from 'styled-components';
|
|
@@ -9,29 +9,29 @@ import { useBookmarkComponentContext } from '../BookmarkProvider';
|
|
|
9
9
|
import { from } from 'rxjs';
|
|
10
10
|
|
|
11
11
|
export type MenuOption = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
name: string;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
onClick: VoidFunction;
|
|
15
|
+
Icon?: ReactNode;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
type RowProps = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly menuOpen: boolean;
|
|
22
|
+
readonly onMenuOpen: (id: string) => void;
|
|
23
|
+
readonly menuOptions: MenuOption[];
|
|
24
|
+
readonly children?: ReactNode;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const Styled = {
|
|
28
|
-
|
|
28
|
+
Icons: styled.div`
|
|
29
29
|
display: flex;
|
|
30
30
|
flex-direction: row;
|
|
31
31
|
gap: 0.2em;
|
|
32
32
|
align-items: center;
|
|
33
33
|
`,
|
|
34
|
-
|
|
34
|
+
ListItem: styled.div`
|
|
35
35
|
cursor: pointer;
|
|
36
36
|
&:hover {
|
|
37
37
|
background-color: ${tokens.colors.ui.background__light.hex};
|
|
@@ -48,51 +48,51 @@ const Styled = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export const Row = ({ name, menuOptions, children, id, menuOpen, onMenuOpen }: RowProps) => {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const pRef = useRef<HTMLElement | null>(null);
|
|
52
|
+
const { provider } = useBookmarkComponentContext();
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
const onListItemClick = useCallback(
|
|
55
|
+
(e: React.MouseEvent) => {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
if (provider) {
|
|
59
|
+
from(provider.setCurrentBookmark(id)).subscribe();
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
[provider, id],
|
|
63
|
+
);
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
useOutsideClick(pRef.current, () => onMenuOpen(''));
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
// TODO: @noggling fix this
|
|
68
|
+
return (
|
|
69
|
+
/* eslint-disable-next-line styled-components-a11y/click-events-have-key-events, styled-components-a11y/no-static-element-interactions*/
|
|
70
|
+
<Styled.ListItem onClick={onListItemClick}>
|
|
71
|
+
<Typography>{name}</Typography>
|
|
72
|
+
<Styled.Icons>
|
|
73
|
+
{children}
|
|
74
|
+
{!!menuOptions?.length && (
|
|
75
|
+
<Icon
|
|
76
|
+
name="more_vertical"
|
|
77
|
+
onClick={(e) => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
onMenuOpen(id);
|
|
81
|
+
}}
|
|
82
|
+
color={tokens.colors.interactive.primary__resting.hex}
|
|
83
|
+
ref={pRef as unknown as MutableRefObject<SVGSVGElement>}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
<MoreMenu
|
|
88
|
+
open={menuOpen}
|
|
89
|
+
options={menuOptions}
|
|
90
|
+
onClose={() => {
|
|
91
|
+
onMenuOpen('');
|
|
92
|
+
}}
|
|
93
|
+
pRef={pRef}
|
|
94
|
+
/>
|
|
95
|
+
</Styled.Icons>
|
|
96
|
+
</Styled.ListItem>
|
|
97
|
+
);
|
|
98
98
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
3
|
import { Button, Icon, Typography } from '@equinor/eds-core-react';
|
|
4
4
|
import { chevron_down, chevron_right } from '@equinor/eds-icons';
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import { tokens } from '@equinor/eds-tokens';
|
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
|
|
9
9
|
const Styled = {
|
|
10
|
-
|
|
10
|
+
Button: styled(Button)`
|
|
11
11
|
width: 100%;
|
|
12
12
|
padding: 0;
|
|
13
13
|
padding-top: 0.5rem;
|
|
@@ -23,7 +23,7 @@ const Styled = {
|
|
|
23
23
|
background: none;
|
|
24
24
|
}
|
|
25
25
|
`,
|
|
26
|
-
|
|
26
|
+
List: styled.ol`
|
|
27
27
|
margin-left: 0.7rem;
|
|
28
28
|
padding-left: 1rem;
|
|
29
29
|
display: flex;
|
|
@@ -34,24 +34,24 @@ const Styled = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
Icon.add({
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
chevron_down,
|
|
38
|
+
chevron_right,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
type SectionProps = {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly children: ReactNode;
|
|
44
44
|
};
|
|
45
45
|
export const Section = ({ children, name }: SectionProps) => {
|
|
46
|
-
|
|
46
|
+
const [isExpanded, setIsExpanded] = useState(true);
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
<Styled.Button variant="ghost" onClick={() => setIsExpanded((s) => !s)}>
|
|
51
|
+
<Icon name={isExpanded ? chevron_down.name : chevron_right.name} />
|
|
52
|
+
<Typography variant="h6">{name}</Typography>
|
|
53
|
+
</Styled.Button>
|
|
54
|
+
{isExpanded && <Styled.List>{children}</Styled.List>}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
57
|
};
|