@equinor/fusion-framework-react-components-bookmark 2.0.4-next.0 → 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.
Files changed (34) hide show
  1. package/dist/esm/version.js +1 -1
  2. package/dist/esm/version.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/dist/types/version.d.ts +1 -1
  5. package/package.json +10 -7
  6. package/CHANGELOG.md +0 -1121
  7. package/src/__tests__/AppNameField.test.tsx +0 -39
  8. package/src/components/Bookmark.tsx +0 -98
  9. package/src/components/BookmarkProvider.tsx +0 -129
  10. package/src/components/create-bookmark/CreateBookmarkModal.tsx +0 -130
  11. package/src/components/create-bookmark/index.ts +0 -1
  12. package/src/components/edit-bookmark/AppNameField.tsx +0 -27
  13. package/src/components/edit-bookmark/EditBookmarkModal.tsx +0 -203
  14. package/src/components/edit-bookmark/index.ts +0 -1
  15. package/src/components/filter/BookmarkFilter.tsx +0 -44
  16. package/src/components/import-bookmark/ImportBookmarkModal.tsx +0 -100
  17. package/src/components/import-bookmark/index.ts +0 -1
  18. package/src/components/loading/Loading.tsx +0 -20
  19. package/src/components/messages/Message.tsx +0 -89
  20. package/src/components/row/MoreMenu.tsx +0 -41
  21. package/src/components/row/Row.tsx +0 -105
  22. package/src/components/section/Section.tsx +0 -63
  23. package/src/components/sectionList/SectionList.tsx +0 -186
  24. package/src/components/shared/SharedIcon.tsx +0 -51
  25. package/src/hooks/index.ts +0 -1
  26. package/src/hooks/useBookmarkGrouping.ts +0 -65
  27. package/src/index.ts +0 -12
  28. package/src/utils/append-bookmark-id-to-url.ts +0 -5
  29. package/src/utils/filter-empty-groups.ts +0 -5
  30. package/src/utils/sort-by-name.ts +0 -4
  31. package/src/utils/to-human-readable.ts +0 -6
  32. package/src/version.ts +0 -2
  33. package/tsconfig.json +0 -18
  34. 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';
@@ -1,5 +0,0 @@
1
- export const appendBookmarkIdToUrl = (id: string): string => {
2
- const url = new URL(window.location.toString());
3
- url.searchParams.set('bookmarkId', id);
4
- return url.toString();
5
- };
@@ -1,5 +0,0 @@
1
- import type { Bookmarks } from '@equinor/fusion-framework-module-bookmark';
2
-
3
- /** Helpers.. */
4
- export const filterEmptyGroups = (i: { values: Bookmarks }) => i.values.length;
5
- // const extractNameFromMail = (mail: string) => mail.split('@')[0].toLowerCase();
@@ -1,4 +0,0 @@
1
- import type { BookmarkWithoutData } from '@equinor/fusion-framework-module-bookmark';
2
-
3
- export const sortByName = (a: BookmarkWithoutData, b: BookmarkWithoutData) =>
4
- a.name.localeCompare(b.name);
@@ -1,6 +0,0 @@
1
- export const toHumanReadable = (val: string) =>
2
- val
3
- .split('-')
4
- // Capitalize the first letter of each hyphen-separated segment
5
- .map((s) => `${s[0].toUpperCase()}${s.slice(1)}`)
6
- .join(' ');
package/src/version.ts DELETED
@@ -1,2 +0,0 @@
1
- // Generated by genversion.
2
- export const version = '2.0.4-next.0';
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
- });