@equinor/fusion-framework-react-components-bookmark 2.0.4 → 2.0.5
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/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +10 -7
- package/CHANGELOG.md +0 -1108
- package/src/__tests__/AppNameField.test.tsx +0 -39
- package/src/components/Bookmark.tsx +0 -98
- package/src/components/BookmarkProvider.tsx +0 -129
- package/src/components/create-bookmark/CreateBookmarkModal.tsx +0 -130
- package/src/components/create-bookmark/index.ts +0 -1
- package/src/components/edit-bookmark/AppNameField.tsx +0 -27
- package/src/components/edit-bookmark/EditBookmarkModal.tsx +0 -203
- package/src/components/edit-bookmark/index.ts +0 -1
- package/src/components/filter/BookmarkFilter.tsx +0 -44
- package/src/components/import-bookmark/ImportBookmarkModal.tsx +0 -100
- package/src/components/import-bookmark/index.ts +0 -1
- package/src/components/loading/Loading.tsx +0 -20
- package/src/components/messages/Message.tsx +0 -89
- package/src/components/row/MoreMenu.tsx +0 -41
- package/src/components/row/Row.tsx +0 -105
- package/src/components/section/Section.tsx +0 -63
- package/src/components/sectionList/SectionList.tsx +0 -186
- package/src/components/shared/SharedIcon.tsx +0 -51
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useBookmarkGrouping.ts +0 -65
- package/src/index.ts +0 -12
- package/src/utils/append-bookmark-id-to-url.ts +0 -5
- package/src/utils/filter-empty-groups.ts +0 -5
- package/src/utils/sort-by-name.ts +0 -4
- package/src/utils/to-human-readable.ts +0 -6
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -18
- package/vitest.config.ts +0 -10
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Bookmarks, BookmarkWithoutData } from '@equinor/fusion-framework-module-bookmark';
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
export type GroupingKeys = 'Group by app' | 'Created by' | 'Group by Context';
|
|
6
|
-
|
|
7
|
-
const groupingModes: Record<GroupingKeys, (_item: BookmarkWithoutData) => string> = {
|
|
8
|
-
'Group by app': (item: BookmarkWithoutData) => item.appKey,
|
|
9
|
-
'Created by': (item: BookmarkWithoutData) => item.createdBy.name,
|
|
10
|
-
'Group by Context': (item: BookmarkWithoutData) => item?.context?.name ?? 'Unknown',
|
|
11
|
-
} as const;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Hook for grouping and searching bookmarks by app, creator, or context.
|
|
15
|
-
*
|
|
16
|
-
* @param bookmarks - The bookmarks to group and search
|
|
17
|
-
* @returns The grouped bookmarks along with the search text and grouping key state/setters
|
|
18
|
-
*/
|
|
19
|
-
export const useBookmarkGrouping = (bookmarks?: Bookmarks) => {
|
|
20
|
-
const [searchText, setSearchText] = useState<string | null>(null);
|
|
21
|
-
|
|
22
|
-
const [groupByKey, setGroupBy] = useState<keyof typeof groupingModes>('Group by app');
|
|
23
|
-
|
|
24
|
-
const bookmarkGroups = groupBy(bookmarks || [], groupingModes[groupByKey], searchText, 'name');
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
setGroupBy,
|
|
28
|
-
setSearchText,
|
|
29
|
-
searchText,
|
|
30
|
-
bookmarkGroups,
|
|
31
|
-
groupingModes,
|
|
32
|
-
groupByKey,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const groupBy = <T>(
|
|
37
|
-
array: T[],
|
|
38
|
-
getKey: (item: T) => string,
|
|
39
|
-
searchText: string | null,
|
|
40
|
-
field: keyof T,
|
|
41
|
-
) => {
|
|
42
|
-
// Treat a missing array as an empty one so downstream calls are safe
|
|
43
|
-
const items = array ?? [];
|
|
44
|
-
// Collect the key for every item
|
|
45
|
-
const keys = items.map(getKey);
|
|
46
|
-
// Deduplicate to get the unique set of group keys, preserving first-seen order
|
|
47
|
-
const uniqueKeys = keys.filter((v, i, a) => a.indexOf(v) === i);
|
|
48
|
-
// Build a group entry for each unique key
|
|
49
|
-
const groups = uniqueKeys.map((groupingProperty) => {
|
|
50
|
-
// Only include values in this group whose key matches
|
|
51
|
-
const matchingValues = array.filter((s) => getKey(s) === groupingProperty);
|
|
52
|
-
// Then narrow those matches down by the search-text filter
|
|
53
|
-
const values = matchingValues.filter((s) => {
|
|
54
|
-
const fieldData = s[field];
|
|
55
|
-
// Only apply search-text filtering to string fields
|
|
56
|
-
if (typeof fieldData === 'string' && searchText) {
|
|
57
|
-
return fieldData.includes(searchText);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return true;
|
|
61
|
-
});
|
|
62
|
-
return { groupingProperty, values };
|
|
63
|
-
});
|
|
64
|
-
return groups;
|
|
65
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-built React UI components for bookmark management.
|
|
3
|
-
*
|
|
4
|
-
* Provides the {@link Bookmark} list component and {@link BookmarkProvider}
|
|
5
|
-
* context wrapper with built-in create, edit, and import modals plus filtering controls.
|
|
6
|
-
*
|
|
7
|
-
* For bookmark hooks without UI, see `@equinor/fusion-framework-react-app/bookmark`.
|
|
8
|
-
*
|
|
9
|
-
* @packageDocumentation
|
|
10
|
-
*/
|
|
11
|
-
export { Bookmark } from './components/Bookmark';
|
|
12
|
-
export { BookmarkProvider, useBookmarkComponentContext } from './components/BookmarkProvider';
|
package/src/version.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.react.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist/esm",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"declarationDir": "./dist/types"
|
|
7
|
-
},
|
|
8
|
-
"references": [
|
|
9
|
-
{
|
|
10
|
-
"path": "../../framework"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "../../modules/bookmark"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"include": ["src/**/*"],
|
|
17
|
-
"exclude": ["node_modules", "lib", "src/__tests__/**/*"]
|
|
18
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { defineProject } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
import { name, version } from './package.json' with { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export default defineProject({
|
|
6
|
-
test: {
|
|
7
|
-
include: ['src/__tests__/**/*.{test,spec}.{ts,tsx}'],
|
|
8
|
-
name: `${name}@${version}`,
|
|
9
|
-
},
|
|
10
|
-
});
|