@edifice.io/react 2.5.15 → 2.5.16
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/components/AddAttachments/AddAttachments.d.ts +6 -3
- package/dist/components/AddAttachments/AddAttachments.js +17 -29
- package/dist/components/AddAttachments/hooks/useFileToAttachment.d.ts +3 -0
- package/dist/components/AddAttachments/hooks/useFileToAttachment.js +16 -0
- package/dist/components/AddAttachments/models/attachment.d.ts +1 -0
- package/dist/components/Tree/components/SortableTree.js +4 -3
- package/dist/components/Tree/components/Tree.js +4 -3
- package/dist/components/UserRightsList/SaveBookmark.d.ts +5 -0
- package/dist/components/UserRightsList/SaveBookmark.js +29 -0
- package/dist/components/UserRightsList/UserRightsBookmarkRow.d.ts +11 -0
- package/dist/components/UserRightsList/UserRightsBookmarkRow.js +30 -0
- package/dist/components/UserRightsList/UserRightsItem.d.ts +13 -0
- package/dist/components/UserRightsList/UserRightsItem.js +36 -0
- package/dist/components/UserRightsList/UserRightsList.d.ts +19 -0
- package/dist/components/UserRightsList/UserRightsList.js +94 -0
- package/dist/components/UserRightsList/helpers/rightsHelpers.d.ts +9 -0
- package/dist/components/UserRightsList/helpers/rightsHelpers.js +53 -0
- package/dist/components/UserRightsList/hooks/useBookmarkEntries.d.ts +19 -0
- package/dist/components/UserRightsList/hooks/useBookmarkEntries.js +58 -0
- package/dist/components/UserRightsList/hooks/useSharingItems.d.ts +20 -0
- package/dist/components/UserRightsList/hooks/useSharingItems.js +57 -0
- package/dist/components/UserRightsList/index.d.ts +2 -0
- package/dist/components/UserRightsList/types/types.d.ts +34 -0
- package/dist/components/UserRightsList/types/types.js +6 -0
- package/dist/components/UserSearch/UserSearch.d.ts +7 -0
- package/dist/components/UserSearch/UserSearch.js +82 -0
- package/dist/components/UserSearch/index.d.ts +3 -0
- package/dist/components/UserSearch/types/types.d.ts +24 -0
- package/dist/components/UserSearch/types/visible.d.ts +24 -0
- package/dist/components/UserSearch/types/visible.js +4 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/useDirectory/useDirectory.d.ts +3 -2
- package/dist/hooks/useDropzone/useDropzone.js +4 -4
- package/dist/icons.js +364 -332
- package/dist/index.js +10 -0
- package/dist/modules/editor/components/EditorToolbar/EditorToolbar.js +1 -1
- package/dist/modules/icons/components/IconBulle.d.ts +7 -0
- package/dist/modules/icons/components/IconBulle.js +16 -0
- package/dist/modules/icons/components/IconBulleError.d.ts +7 -0
- package/dist/modules/icons/components/IconBulleError.js +13 -0
- package/dist/modules/icons/components/IconBulleSuccess.d.ts +7 -0
- package/dist/modules/icons/components/IconBulleSuccess.js +13 -0
- package/dist/modules/icons/components/IconLsuArt.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuArt.js +13 -0
- package/dist/modules/icons/components/IconLsuCompetenceNumerique.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuCompetenceNumerique.js +12 -0
- package/dist/modules/icons/components/IconLsuEmc.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuEmc.js +13 -0
- package/dist/modules/icons/components/IconLsuFrancais.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuFrancais.js +13 -0
- package/dist/modules/icons/components/IconLsuHistoireGeo.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuHistoireGeo.js +12 -0
- package/dist/modules/icons/components/IconLsuLangue.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuLangue.js +16 -0
- package/dist/modules/icons/components/IconLsuLangue2.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuLangue2.js +13 -0
- package/dist/modules/icons/components/IconLsuMath.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuMath.js +16 -0
- package/dist/modules/icons/components/IconLsuParcoursEducatif.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuParcoursEducatif.js +12 -0
- package/dist/modules/icons/components/IconLsuSport.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuSport.js +12 -0
- package/dist/modules/icons/components/IconLsuSvt.d.ts +7 -0
- package/dist/modules/icons/components/IconLsuSvt.js +12 -0
- package/dist/modules/icons/components/IconParcoursCitoyen.d.ts +7 -0
- package/dist/modules/icons/components/IconParcoursCitoyen.js +14 -0
- package/dist/modules/icons/components/IconParcoursSecours.d.ts +7 -0
- package/dist/modules/icons/components/IconParcoursSecours.js +14 -0
- package/dist/modules/icons/components/index.d.ts +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/sharing.d.ts +8 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/rotate-transition-style/get-rotate-transition-style.d.ts +5 -0
- package/dist/utilities/rotate-transition-style/get-rotate-transition-style.js +12 -0
- package/dist/utilities/rotate-transition-style/index.d.ts +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
const useSharingItems = ({
|
|
3
|
+
initialSharings,
|
|
4
|
+
toggleRight,
|
|
5
|
+
applyRight,
|
|
6
|
+
onChange,
|
|
7
|
+
onAddItems,
|
|
8
|
+
onDeleteItems
|
|
9
|
+
}) => {
|
|
10
|
+
const [items, setItems] = useState(initialSharings ?? []);
|
|
11
|
+
return {
|
|
12
|
+
items,
|
|
13
|
+
addItem: (item) => {
|
|
14
|
+
setItems((prev) => {
|
|
15
|
+
if (new Set(prev.map((sharing) => sharing.recipientId)).has(item.recipientId)) return prev;
|
|
16
|
+
const nextItems = [...prev, item];
|
|
17
|
+
return onChange(nextItems), onAddItems([item]), nextItems;
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
addItems: (newItems) => {
|
|
21
|
+
setItems((prev) => {
|
|
22
|
+
const existingIds = new Set(prev.map((sharing) => sharing.recipientId)), uniqueItems = newItems.filter((newItem) => !existingIds.has(newItem.recipientId));
|
|
23
|
+
if (uniqueItems.length === 0) return prev;
|
|
24
|
+
const nextItems = [...prev, ...uniqueItems];
|
|
25
|
+
return onChange(nextItems), onAddItems(uniqueItems), nextItems;
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
deleteItem: (item) => {
|
|
29
|
+
setItems((prev) => {
|
|
30
|
+
const nextItems = prev.filter((sharing) => sharing.recipientId !== item.recipientId);
|
|
31
|
+
return nextItems.length === prev.length ? prev : (onChange(nextItems), onDeleteItems([item]), nextItems);
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
deleteItemsByIds: (ids) => {
|
|
35
|
+
setItems((prev) => {
|
|
36
|
+
const nextItems = prev.filter((sharing) => !ids.has(sharing.recipientId)), removedItems = prev.filter((sharing) => ids.has(sharing.recipientId));
|
|
37
|
+
return onChange(nextItems), onDeleteItems(removedItems), nextItems;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
changeRight: (item, rightName) => {
|
|
41
|
+
const updatedItem = toggleRight(item, rightName);
|
|
42
|
+
setItems((prevItems) => {
|
|
43
|
+
const nextItems = prevItems.map((prevItem) => prevItem.recipientId === item.recipientId ? updatedItem : prevItem);
|
|
44
|
+
return onChange(nextItems), nextItems;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
applyRightToIds: (ids, rightName, shouldAdd) => {
|
|
48
|
+
setItems((prev) => {
|
|
49
|
+
const nextItems = prev.map((sharing) => ids.has(sharing.recipientId) ? applyRight(sharing, rightName, shouldAdd) : sharing);
|
|
50
|
+
return onChange(nextItems), nextItems;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
useSharingItems
|
|
57
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SharingItem } from '../../../types';
|
|
2
|
+
export type { SearchResultType, SharingItem } from '../../../types';
|
|
3
|
+
export type ResourceRightName = 'read' | 'contrib' | 'publish' | 'manager' | 'comment';
|
|
4
|
+
export type ResourceRightDefinition = {
|
|
5
|
+
priority: number;
|
|
6
|
+
default: boolean;
|
|
7
|
+
requires: ResourceRightName[];
|
|
8
|
+
excludes: ResourceRightName[];
|
|
9
|
+
};
|
|
10
|
+
export type ResourceRights = Record<ResourceRightName, ResourceRightDefinition>;
|
|
11
|
+
export interface BookmarkUser {
|
|
12
|
+
id: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
profile?: string;
|
|
15
|
+
activationCode?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface BookmarkInput {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
notVisibleCount?: number;
|
|
21
|
+
groups?: {
|
|
22
|
+
id: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
}[];
|
|
25
|
+
users: BookmarkUser[];
|
|
26
|
+
}
|
|
27
|
+
export interface BookmarkState {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
permission: string[];
|
|
31
|
+
userIds: string[];
|
|
32
|
+
isExpanded: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function isBookmarkInput(item: SharingItem | BookmarkInput): item is BookmarkInput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserSearchProps, UserSearchRef } from './types/types';
|
|
2
|
+
/**
|
|
3
|
+
* User search component with combobox UI. Supports users, groups and bookmarks,
|
|
4
|
+
* debounced search, and optional sharing/selection tracking.
|
|
5
|
+
* Loading state is managed internally during getSearchResults calls.
|
|
6
|
+
*/
|
|
7
|
+
export declare const UserSearch: import('react').ForwardRefExoticComponent<UserSearchProps & import('react').RefAttributes<UserSearchRef>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useEffect, useCallback, useImperativeHandle } from "react";
|
|
3
|
+
import SvgIconBookmark from "../../modules/icons/components/IconBookmark.js";
|
|
4
|
+
import SvgIconGroupAvatar from "../../modules/icons/components/IconGroupAvatar.js";
|
|
5
|
+
import SvgIconUser from "../../modules/icons/components/IconUser.js";
|
|
6
|
+
import { VisibleType } from "./types/visible.js";
|
|
7
|
+
import useDebounce from "../../hooks/useDebounce/useDebounce.js";
|
|
8
|
+
import Combobox from "../Combobox/Combobox.js";
|
|
9
|
+
function buildSharedItemsCacheFromInitialSharings(initialSharings) {
|
|
10
|
+
return new Map(initialSharings.map((item) => [item.recipientId, {
|
|
11
|
+
id: item.recipientId,
|
|
12
|
+
displayName: item.displayName,
|
|
13
|
+
type: item.recipientType === "user" ? VisibleType.User : item.recipientType === "group" ? VisibleType.Group : VisibleType.ShareBookmark
|
|
14
|
+
}]));
|
|
15
|
+
}
|
|
16
|
+
const UserSearch = /* @__PURE__ */ forwardRef(({
|
|
17
|
+
placeholder = "Rechercher un utilisateur",
|
|
18
|
+
isAdmlcOrAdmc = !1,
|
|
19
|
+
bookmarks = [],
|
|
20
|
+
initialSharings = [],
|
|
21
|
+
getSearchResults,
|
|
22
|
+
onSearchResultsChange
|
|
23
|
+
}, ref) => {
|
|
24
|
+
const [searchResults, setSearchResults] = useState(bookmarks), [searchInputValue, setSearchInputValue] = useState(""), debouncedSearchInputValue = useDebounce(searchInputValue, 500), [sharingsIds, setSharingsIds] = useState(new Set(initialSharings.map((item) => item.recipientId))), [sharedItemsCache, setSharedItemsCache] = useState(() => buildSharedItemsCacheFromInitialSharings(initialSharings)), [isLoading, setIsLoading] = useState(!1), searchMinLength = isAdmlcOrAdmc ? 3 : 1, getIcon = (type) => {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case VisibleType.User:
|
|
27
|
+
return /* @__PURE__ */ jsx(SvgIconUser, {});
|
|
28
|
+
case VisibleType.Group:
|
|
29
|
+
case VisibleType.BroadcastGroup:
|
|
30
|
+
return /* @__PURE__ */ jsx(SvgIconGroupAvatar, {});
|
|
31
|
+
case VisibleType.ShareBookmark:
|
|
32
|
+
return /* @__PURE__ */ jsx(SvgIconBookmark, {});
|
|
33
|
+
default:
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}, searchResultsToOptions = (searchResults2) => searchResults2.map((result) => ({
|
|
37
|
+
value: result.id,
|
|
38
|
+
label: result.displayName,
|
|
39
|
+
icon: getIcon(result.type)
|
|
40
|
+
})), filterResults = (results) => results.filter((result) => !sharingsIds.has(result.id));
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
let cancelled = !1;
|
|
43
|
+
async function getResults() {
|
|
44
|
+
setIsLoading(!0);
|
|
45
|
+
try {
|
|
46
|
+
const response = await getSearchResults(debouncedSearchInputValue);
|
|
47
|
+
if (!cancelled) {
|
|
48
|
+
const rawResults = [...bookmarks, ...response.results];
|
|
49
|
+
setSearchResults(filterResults(rawResults));
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
cancelled || setSearchResults(filterResults(bookmarks));
|
|
53
|
+
} finally {
|
|
54
|
+
cancelled || setIsLoading(!1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return debouncedSearchInputValue.length >= searchMinLength ? getResults() : setSearchResults(filterResults(bookmarks)), () => {
|
|
58
|
+
cancelled = !0, setIsLoading(!1);
|
|
59
|
+
};
|
|
60
|
+
}, [debouncedSearchInputValue]);
|
|
61
|
+
const handleSearchInputChange = (event) => {
|
|
62
|
+
setSearchInputValue(event.target.value);
|
|
63
|
+
}, handleRemoveSharing = useCallback((recipientId) => {
|
|
64
|
+
setSharingsIds((prev) => {
|
|
65
|
+
const next = new Set(prev);
|
|
66
|
+
return next.delete(recipientId), next;
|
|
67
|
+
});
|
|
68
|
+
const cached = sharedItemsCache.get(recipientId);
|
|
69
|
+
cached && setSearchResults((prev) => prev.some((r) => r.id === recipientId) ? prev : [...prev, cached]);
|
|
70
|
+
}, [sharedItemsCache]);
|
|
71
|
+
useImperativeHandle(ref, () => ({
|
|
72
|
+
removeSharing: handleRemoveSharing
|
|
73
|
+
}), [handleRemoveSharing]);
|
|
74
|
+
const handleSearchResultsChange = (model) => {
|
|
75
|
+
const searchResultId = model[0], searchResult = searchResults.find((result) => result.id === searchResultId);
|
|
76
|
+
searchResult && (setSharingsIds((prev) => /* @__PURE__ */ new Set([...prev, searchResult.id])), setSharedItemsCache((prev) => new Map(prev).set(searchResult.id, searchResult)), setSearchResults((prev) => prev.filter((result) => result.id !== searchResult.id)), onSearchResultsChange == null || onSearchResultsChange(searchResult));
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ jsx(Combobox, { "data-testid": "common-user-search-input-search", value: searchInputValue, placeholder, isLoading, noResult: searchResults.length === 0, options: searchResultsToOptions(searchResults), searchMinLength, onSearchInputChange: handleSearchInputChange, onSearchResultsChange: handleSearchResultsChange });
|
|
79
|
+
});
|
|
80
|
+
export {
|
|
81
|
+
UserSearch
|
|
82
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SearchResultType, SharingItem } from '../../../types';
|
|
3
|
+
import { Visible } from './visible';
|
|
4
|
+
export type { SearchResultType, SharingItem };
|
|
5
|
+
export interface UserSearchProps {
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
isAdmlcOrAdmc?: boolean;
|
|
8
|
+
bookmarks?: Visible[];
|
|
9
|
+
initialSharings?: SharingItem[];
|
|
10
|
+
getSearchResults: (searchInputValue: string) => Promise<SearchResponse>;
|
|
11
|
+
onSearchResultsChange?: (searchResult: Visible) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface UserSearchRef {
|
|
14
|
+
removeSharing: (recipientId: string) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface SearchResponse {
|
|
17
|
+
results: Visible[];
|
|
18
|
+
}
|
|
19
|
+
export interface SearchResultBase {
|
|
20
|
+
id: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
icon: ReactNode;
|
|
23
|
+
type: SearchResultType;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum VisibleType {
|
|
2
|
+
User = "User",
|
|
3
|
+
Group = "Group",
|
|
4
|
+
ShareBookmark = "ShareBookmark",
|
|
5
|
+
BroadcastGroup = "BroadcastGroup"
|
|
6
|
+
}
|
|
7
|
+
export type Visible = {
|
|
8
|
+
id: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
type: VisibleType;
|
|
11
|
+
children?: {
|
|
12
|
+
id: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
}[];
|
|
15
|
+
groupType?: string;
|
|
16
|
+
nbUsers?: number;
|
|
17
|
+
profile?: string;
|
|
18
|
+
relatives?: {
|
|
19
|
+
id: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
}[];
|
|
22
|
+
structureName?: string;
|
|
23
|
+
usedIn?: ('TO' | 'CC' | 'CCI')[];
|
|
24
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ID } from '@edifice.io/client';
|
|
2
|
+
import { AvatarType } from '../../types';
|
|
2
3
|
declare const useDirectory: () => {
|
|
3
|
-
getAvatarURL: (userId: ID, type:
|
|
4
|
-
getUserbookURL: (userId: ID, type:
|
|
4
|
+
getAvatarURL: (userId: ID, type: AvatarType) => string | undefined;
|
|
5
|
+
getUserbookURL: (userId: ID, type: AvatarType) => string;
|
|
5
6
|
};
|
|
6
7
|
export default useDirectory;
|
|
@@ -35,11 +35,11 @@ const useDropzone = (props) => {
|
|
|
35
35
|
}, convertHEICImages = async (files2) => {
|
|
36
36
|
if (files2 === null || files2.length === 0)
|
|
37
37
|
return [];
|
|
38
|
-
let
|
|
39
|
-
return files2.some((file) => HEIC_MIME_TYPES.includes(file.type)) && (
|
|
40
|
-
if (
|
|
38
|
+
let heicToLib;
|
|
39
|
+
return files2.some((file) => HEIC_MIME_TYPES.includes(file.type)) && (heicToLib = await import("heic-to")), Promise.all(files2.map(async (file) => {
|
|
40
|
+
if (heicToLib && heicToLib.isHeic(file))
|
|
41
41
|
try {
|
|
42
|
-
const converted = await
|
|
42
|
+
const converted = await heicToLib.heicTo({
|
|
43
43
|
blob: file,
|
|
44
44
|
toType: "image/jpeg"
|
|
45
45
|
});
|