@equinor/fusion-framework-react-components-bookmark 0.1.15 → 0.2.1
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 +53 -0
- package/LICENSE +21 -0
- package/dist/esm/components/Bookmark.js +5 -5
- package/dist/esm/components/Bookmark.js.map +1 -1
- package/dist/esm/components/create-bookmark/CreateBookmark.js +1 -1
- package/dist/esm/components/create-bookmark/CreateBookmark.js.map +1 -1
- package/dist/esm/components/edit-bookmark/EditBookmark.js +17 -18
- package/dist/esm/components/edit-bookmark/EditBookmark.js.map +1 -1
- package/dist/esm/components/filter/Filter.js +7 -4
- package/dist/esm/components/filter/Filter.js.map +1 -1
- package/dist/esm/components/import-bookmark/ImportBookmark.js +4 -4
- package/dist/esm/components/import-bookmark/ImportBookmark.js.map +1 -1
- package/dist/esm/components/row/Row.js +6 -6
- package/dist/esm/components/row/Row.js.map +1 -1
- package/dist/esm/components/section/Section.js +20 -21
- package/dist/esm/components/section/Section.js.map +1 -1
- package/dist/esm/components/shared/SharedIcon.js +16 -14
- package/dist/esm/components/shared/SharedIcon.js.map +1 -1
- package/dist/esm/hooks/useBookmarkGrouping.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/Bookmark.d.ts +1 -1
- package/dist/types/components/BookmarkProvider.d.ts +1 -1
- package/dist/types/components/create-bookmark/CreateBookmark.d.ts +3 -3
- package/dist/types/components/edit-bookmark/EditBookmark.d.ts +4 -4
- package/dist/types/components/filter/Filter.d.ts +6 -6
- package/dist/types/components/import-bookmark/ImportBookmark.d.ts +1 -1
- package/dist/types/components/loading/Loading.d.ts +1 -1
- package/dist/types/components/row/MoreMenu.d.ts +5 -5
- package/dist/types/components/row/Row.d.ts +7 -7
- package/dist/types/components/section/Section.d.ts +3 -3
- package/dist/types/components/sectionList/SectionList.d.ts +2 -2
- package/dist/types/components/shared/SharedIcon.d.ts +3 -3
- package/dist/types/hooks/useBookmarkGrouping.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +53 -57
- package/src/components/Bookmark.tsx +9 -8
- package/src/components/create-bookmark/CreateBookmark.tsx +4 -3
- package/src/components/edit-bookmark/EditBookmark.tsx +26 -26
- package/src/components/filter/Filter.tsx +20 -10
- package/src/components/import-bookmark/ImportBookmark.tsx +6 -5
- package/src/components/row/MoreMenu.tsx +4 -4
- package/src/components/row/Row.tsx +17 -15
- package/src/components/section/Section.tsx +24 -26
- package/src/components/sectionList/SectionList.tsx +6 -6
- package/src/components/shared/SharedIcon.tsx +22 -20
- package/src/hooks/useBookmarkGrouping.ts +2 -2
- package/src/version.ts +1 -1
- package/tsconfig.json +1 -2
|
@@ -3,12 +3,27 @@ import { 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
|
|
|
6
|
-
import { css } from '@emotion/css';
|
|
7
6
|
import { tokens } from '@equinor/eds-tokens';
|
|
8
|
-
import styled from '
|
|
7
|
+
import styled from 'styled-components';
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
const Styled = {
|
|
10
|
+
Button: styled(Button)`
|
|
11
|
+
width: 100%;
|
|
12
|
+
padding: 0;
|
|
13
|
+
padding-top: 0.5rem;
|
|
14
|
+
margin-bottom: 0.5rem;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
align-items: center;
|
|
18
|
+
background: none;
|
|
19
|
+
border: none;
|
|
20
|
+
color: ${tokens.colors.infographic.primary__moss_green_100.hex};
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
:hover {
|
|
23
|
+
background: none;
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
List: styled.ol`
|
|
12
27
|
margin-left: 0.7rem;
|
|
13
28
|
padding-left: 1rem;
|
|
14
29
|
display: flex;
|
|
@@ -18,42 +33,25 @@ const styles = {
|
|
|
18
33
|
`,
|
|
19
34
|
};
|
|
20
35
|
|
|
21
|
-
const StyledButton = styled(Button)`
|
|
22
|
-
width: 100%;
|
|
23
|
-
padding: 0;
|
|
24
|
-
padding-top: 0.5rem;
|
|
25
|
-
margin-bottom: 0.5rem;
|
|
26
|
-
display: flex;
|
|
27
|
-
justify-content: space-between;
|
|
28
|
-
align-items: center;
|
|
29
|
-
background: none;
|
|
30
|
-
border: none;
|
|
31
|
-
color: ${tokens.colors.infographic.primary__moss_green_100.hex};
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
:hover {
|
|
34
|
-
background: none;
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
36
|
Icon.add({
|
|
39
37
|
chevron_down,
|
|
40
38
|
chevron_right,
|
|
41
39
|
});
|
|
42
40
|
|
|
43
41
|
type SectionProps = {
|
|
44
|
-
name: string;
|
|
45
|
-
children: ReactNode;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly children: ReactNode;
|
|
46
44
|
};
|
|
47
45
|
export const Section = ({ children, name }: SectionProps) => {
|
|
48
46
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
49
47
|
|
|
50
48
|
return (
|
|
51
49
|
<div>
|
|
52
|
-
<
|
|
50
|
+
<Styled.Button variant="ghost" onClick={() => setIsExpanded((s) => !s)}>
|
|
53
51
|
<Icon name={isExpanded ? chevron_down.name : chevron_right.name} />
|
|
54
52
|
<Typography variant="h6">{name}</Typography>
|
|
55
|
-
</
|
|
56
|
-
{isExpanded && <
|
|
53
|
+
</Styled.Button>
|
|
54
|
+
{isExpanded && <Styled.List>{children}</Styled.List>}
|
|
57
55
|
</div>
|
|
58
56
|
);
|
|
59
57
|
};
|
|
@@ -23,7 +23,7 @@ Icon.add({
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
type SectionListProps = {
|
|
26
|
-
bookmarkGroups: ReturnType<typeof useBookmarkGrouping>['bookmarkGroups'];
|
|
26
|
+
readonly bookmarkGroups: ReturnType<typeof useBookmarkGrouping>['bookmarkGroups'];
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export const SectionList = ({ bookmarkGroups }: SectionListProps) => {
|
|
@@ -47,7 +47,7 @@ export const SectionList = ({ bookmarkGroups }: SectionListProps) => {
|
|
|
47
47
|
(bookmarkId: string) => {
|
|
48
48
|
event.dispatchEvent('onBookmarkEdit', { detail: { bookmarkId } });
|
|
49
49
|
},
|
|
50
|
-
[event]
|
|
50
|
+
[event],
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
const shareBookmark = useCallback(
|
|
@@ -59,14 +59,14 @@ export const SectionList = ({ bookmarkGroups }: SectionListProps) => {
|
|
|
59
59
|
}
|
|
60
60
|
updateBookmark({ ...bookmark, isShared: !bookmark.isShared });
|
|
61
61
|
},
|
|
62
|
-
[event, updateBookmark]
|
|
62
|
+
[event, updateBookmark],
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
const updateBookmarkWithCurrentView = useCallback(
|
|
66
66
|
(bookmark: Bookmark) => {
|
|
67
67
|
updateBookmark({ ...bookmark }, { updatePayload: true });
|
|
68
68
|
},
|
|
69
|
-
[updateBookmark]
|
|
69
|
+
[updateBookmark],
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const createMenuOptions = (bookmark: Bookmark) =>
|
|
@@ -78,7 +78,7 @@ export const SectionList = ({ bookmarkGroups }: SectionListProps) => {
|
|
|
78
78
|
removeBookmarkFavorite,
|
|
79
79
|
updateBookmarkWithCurrentView,
|
|
80
80
|
getCurrentAppKey(),
|
|
81
|
-
user?.localAccountId
|
|
81
|
+
user?.localAccountId,
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
if (loading) return <Loading />;
|
|
@@ -120,7 +120,7 @@ function createBookmarkActions(
|
|
|
120
120
|
removeBookmarkFavorite: (bookmarkId: string) => void,
|
|
121
121
|
updateBookmarkWithCurrentView: (bookmark: Bookmark) => void,
|
|
122
122
|
appKey?: string,
|
|
123
|
-
localAccountId?: string
|
|
123
|
+
localAccountId?: string,
|
|
124
124
|
) {
|
|
125
125
|
if (bookmark.createdBy.azureUniqueId === localAccountId) {
|
|
126
126
|
return [
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import styled from '@emotion/styled';
|
|
2
1
|
import { Icon } from '@equinor/eds-core-react';
|
|
3
2
|
import { tokens } from '@equinor/eds-tokens';
|
|
4
3
|
import { useFramework } from '@equinor/fusion-framework-react';
|
|
5
4
|
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
|
|
7
|
+
const Styled = {
|
|
8
|
+
Row: styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: 0.2em;
|
|
12
|
+
`,
|
|
13
|
+
CreatedBy: styled.p`
|
|
14
|
+
font-size: 12px;
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
line-height: 16px;
|
|
17
|
+
letter-spacing: 0em;
|
|
18
|
+
text-align: right;
|
|
19
|
+
`,
|
|
20
|
+
};
|
|
21
|
+
|
|
6
22
|
type SharedIconProps = {
|
|
7
|
-
createdBy: string;
|
|
8
|
-
createdById: string;
|
|
23
|
+
readonly createdBy: string;
|
|
24
|
+
readonly createdById: string;
|
|
9
25
|
};
|
|
10
26
|
|
|
11
27
|
export const SharedIcon = ({ createdBy, createdById }: SharedIconProps) => {
|
|
@@ -14,8 +30,8 @@ export const SharedIcon = ({ createdBy, createdById }: SharedIconProps) => {
|
|
|
14
30
|
const isMe = createdById === myId;
|
|
15
31
|
|
|
16
32
|
return (
|
|
17
|
-
<
|
|
18
|
-
{!isMe && <
|
|
33
|
+
<Styled.Row>
|
|
34
|
+
{!isMe && <Styled.CreatedBy>shared by {createdBy}</Styled.CreatedBy>}
|
|
19
35
|
<Icon
|
|
20
36
|
name="share"
|
|
21
37
|
color={
|
|
@@ -24,20 +40,6 @@ export const SharedIcon = ({ createdBy, createdById }: SharedIconProps) => {
|
|
|
24
40
|
: tokens.colors.interactive.disabled__border.hex
|
|
25
41
|
}
|
|
26
42
|
/>
|
|
27
|
-
</
|
|
43
|
+
</Styled.Row>
|
|
28
44
|
);
|
|
29
45
|
};
|
|
30
|
-
|
|
31
|
-
const StyledRow = styled.div`
|
|
32
|
-
display: flex;
|
|
33
|
-
align-items: center;
|
|
34
|
-
gap: 0.2em;
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
const StyledCreatedBy = styled.p`
|
|
38
|
-
font-size: 12px;
|
|
39
|
-
font-weight: 500;
|
|
40
|
-
line-height: 16px;
|
|
41
|
-
letter-spacing: 0em;
|
|
42
|
-
text-align: right;
|
|
43
|
-
`;
|
|
@@ -4,7 +4,7 @@ import { useState } from 'react';
|
|
|
4
4
|
|
|
5
5
|
export type GroupingKeys = 'Group by app' | 'Created by' | 'Group by Context';
|
|
6
6
|
|
|
7
|
-
const groupingModes: Record<GroupingKeys, (
|
|
7
|
+
const groupingModes: Record<GroupingKeys, (_item: Bookmark) => string> = {
|
|
8
8
|
'Group by app': (item: Bookmark) => item.appKey,
|
|
9
9
|
'Created by': (item: Bookmark) => item.createdBy.name,
|
|
10
10
|
'Group by Context': (item: Bookmark) => item?.context?.name ?? 'Unknown',
|
|
@@ -31,7 +31,7 @@ const groupBy = <T>(
|
|
|
31
31
|
array: T[],
|
|
32
32
|
getKey: (item: T) => string,
|
|
33
33
|
searchText: string | null,
|
|
34
|
-
field: keyof T
|
|
34
|
+
field: keyof T,
|
|
35
35
|
) => {
|
|
36
36
|
return (
|
|
37
37
|
array
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.1
|
|
2
|
+
export const version = '0.2.1';
|