@chayns-components/person-finder 5.4.0 → 5.4.4
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/lib/cjs/api/person/get.js +5 -3
- package/lib/cjs/api/person/get.js.map +1 -1
- package/lib/cjs/api/site/get.js +5 -3
- package/lib/cjs/api/site/get.js.map +1 -1
- package/lib/cjs/components/PersonFinderProvider.js +60 -15
- package/lib/cjs/components/PersonFinderProvider.js.map +1 -1
- package/lib/cjs/components/person-finder/PersonFinder.js +2 -0
- package/lib/cjs/components/person-finder/PersonFinder.js.map +1 -1
- package/lib/cjs/components/person-finder/person-finder-wrapper/PersonFinderWrapper.js +7 -5
- package/lib/cjs/components/person-finder/person-finder-wrapper/PersonFinderWrapper.js.map +1 -1
- package/lib/cjs/constants/url.js +9 -0
- package/lib/cjs/constants/url.js.map +1 -0
- package/lib/cjs/utils/personFinder.js +6 -3
- package/lib/cjs/utils/personFinder.js.map +1 -1
- package/lib/esm/api/person/get.js +5 -3
- package/lib/esm/api/person/get.js.map +1 -1
- package/lib/esm/api/site/get.js +5 -3
- package/lib/esm/api/site/get.js.map +1 -1
- package/lib/esm/components/PersonFinderProvider.js +59 -15
- package/lib/esm/components/PersonFinderProvider.js.map +1 -1
- package/lib/esm/components/person-finder/PersonFinder.js +2 -0
- package/lib/esm/components/person-finder/PersonFinder.js.map +1 -1
- package/lib/esm/components/person-finder/person-finder-wrapper/PersonFinderWrapper.js +7 -5
- package/lib/esm/components/person-finder/person-finder-wrapper/PersonFinderWrapper.js.map +1 -1
- package/lib/esm/constants/url.js +3 -0
- package/lib/esm/constants/url.js.map +1 -0
- package/lib/esm/utils/personFinder.js +6 -3
- package/lib/esm/utils/personFinder.js.map +1 -1
- package/lib/types/api/person/get.d.ts +2 -1
- package/lib/types/api/site/get.d.ts +2 -1
- package/lib/types/components/PersonFinderProvider.d.ts +1 -0
- package/lib/types/components/person-finder/PersonFinder.d.ts +8 -0
- package/lib/types/constants/url.d.ts +2 -0
- package/lib/types/utils/personFinder.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonFinderProvider.js","names":["React","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","throttle","LoadingState","PersonFinderFilterTypes","Priority","RelationMode","getFriends","postFriends","deleteFriends","filterDataByKeys","loadData","getUACGroups","getUsersByGroups","TextstringProvider","PERSON_FINDER_TEXTSTRING_LIBRARY_NAME","THROTTLE_INTERVAL","PAGE_SIZE","PersonFinderContext","data","undefined","updateData","friends","addFriend","removeFriend","activeFilter","updateActiveFilter","search","updateSearch","loadMore","loadingState","updateLoadingState","tags","setTags","relationMode","displayName","usePersonFinder","PersonFinderProvider","children","friendsPriority","filterTypes","defaultEntries","excludedEntryIds","shouldShowOwnUser","uacFilter","entries","getPagedUsersByGroups","setData","setFriends","uacUsers","setUacUsers","setActiveFilter","setSearch","map","id","name","text","setLoadingState","PERSON","None","SITE","dataRef","filter","key","newData","prevState","appendData","oldEntries","state","prev","value","Pending","current","Error","groupId","skip","take","then","result","users","count","length","searchString","finally","Success","skipMap","personId","firstName","lastName","verificationState","isVerified","commonSites","type","wasSuccessful","includes","latestArgsRef","latestHandledRequestRef","throttledRequest","args","requestTimestamp","Date","now","forEach","Object","keyString","HIGH","friendIds","Set","f","serverFriendEntries","entry","has","serverFriendIds","missingFriends","toLowerCase","otherEntries","leading","trailing","searchData","tmpData","uacEntries","filteredEntries","searchLocal","searchedUsers","entriesToSearch","Boolean","join","trim","push","active","UAC","cancel","person","uac","providerValue","createElement","Provider","libraryName"],"sources":["../../../src/components/PersonFinderProvider.tsx"],"sourcesContent":["import React, {\n createContext,\n Dispatch,\n FC,\n ReactNode,\n SetStateAction,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport throttle from 'lodash.throttle';\nimport {\n DefaultEntry,\n LoadingState,\n LoadingStateMap,\n PersonEntry,\n PersonFinderData,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n Priority,\n RelationMode,\n ThrottledFunction,\n UACEntry,\n UACFilter,\n} from '../types/personFinder';\nimport { getFriends } from '../api/friends/get';\nimport { postFriends } from '../api/friends/post';\nimport { deleteFriends } from '../api/friends/delete';\nimport { filterDataByKeys, loadData } from '../utils/personFinder';\nimport { Tag } from '@chayns-components/core/lib/types/types/tagInput';\nimport { getUACGroups, getUsersByGroups } from '../utils/uac';\nimport { TextstringProvider } from '@chayns-components/textstring';\nimport { PERSON_FINDER_TEXTSTRING_LIBRARY_NAME } from '../constants/textStrings';\n\nconst THROTTLE_INTERVAL = 500;\nconst PAGE_SIZE = 20;\n\ntype GetUsersByGroupsResult = {\n users: PersonEntry[];\n count: number;\n};\n\nexport interface IPersonFinderContext {\n // Data\n data?: { [key: string]: PersonFinderData };\n updateData?: (key: PersonFinderFilterTypes, personFinderData: PersonFinderData) => void;\n\n // Tags\n tags?: Tag[];\n setTags?: Dispatch<SetStateAction<Tag[]>>;\n\n // Friends\n friends?: PersonEntry[];\n addFriend?: (personId: string) => void;\n removeFriend?: (personId: string) => void;\n\n // Filter\n activeFilter?: PersonFinderFilterTypes[];\n updateActiveFilter?: (filter: PersonFinderFilterTypes[]) => void;\n\n // Search\n search?: string;\n updateSearch?: (value: string) => void;\n\n // Loading\n loadMore?: (key: PersonFinderFilterTypes) => void;\n loadingState?: LoadingStateMap;\n updateLoadingState?: (key: PersonFinderFilterTypes, state: LoadingState) => void;\n\n relationMode?: RelationMode;\n}\n\nexport const PersonFinderContext = createContext<IPersonFinderContext>({\n data: undefined,\n updateData: undefined,\n friends: undefined,\n addFriend: undefined,\n removeFriend: undefined,\n activeFilter: undefined,\n updateActiveFilter: undefined,\n search: undefined,\n updateSearch: undefined,\n loadMore: undefined,\n loadingState: undefined,\n updateLoadingState: undefined,\n tags: undefined,\n setTags: undefined,\n relationMode: undefined,\n});\n\nPersonFinderContext.displayName = 'PersonFinderContext';\n\nexport const usePersonFinder = () => useContext(PersonFinderContext);\n\ntype PersonFinderProviderProps = {\n children: ReactNode;\n friendsPriority: Priority;\n filterTypes: PersonFinderFilterTypes[];\n defaultEntries?: DefaultEntry[];\n excludedEntryIds?: PersonFinderEntry['id'][];\n shouldShowOwnUser?: boolean;\n uacFilter?: UACFilter[];\n entries?: PersonEntry[];\n relationMode?: RelationMode;\n};\n\nconst PersonFinderProvider: FC<PersonFinderProviderProps> = ({\n children,\n friendsPriority,\n filterTypes,\n defaultEntries,\n excludedEntryIds,\n shouldShowOwnUser = false,\n uacFilter,\n entries,\n relationMode,\n}) => {\n const getPagedUsersByGroups = useCallback(\n getUsersByGroups as unknown as (\n uacFilter: UACFilter[],\n options?: { skip?: number; take?: number },\n ) => Promise<GetUsersByGroupsResult>,\n [],\n );\n\n const [data, setData] = useState<IPersonFinderContext['data']>();\n const [friends, setFriends] = useState<PersonEntry[]>();\n const [uacUsers, setUacUsers] = useState<PersonEntry[]>();\n const [activeFilter, setActiveFilter] = useState<IPersonFinderContext['activeFilter']>();\n const [search, setSearch] = useState('');\n const [tags, setTags] = useState<Tag[]>(\n defaultEntries?.map(({ id, name }) => ({ id, text: name })) ?? [],\n );\n const [loadingState, setLoadingState] = useState<LoadingStateMap>({\n [PersonFinderFilterTypes.PERSON]: LoadingState.None,\n [PersonFinderFilterTypes.SITE]: LoadingState.None,\n });\n\n const dataRef = useRef<IPersonFinderContext['data']>();\n\n const updateActiveFilter = useCallback((filter: IPersonFinderContext['activeFilter']) => {\n setActiveFilter(filter);\n }, []);\n\n const updateData = useCallback((key: PersonFinderFilterTypes, newData: PersonFinderData) => {\n setData((prevState) => ({ ...prevState, [key]: newData }));\n }, []);\n\n const appendData = useCallback((key: PersonFinderFilterTypes, newData: PersonFinderData) => {\n setData((prevState) => {\n const oldEntries = prevState && prevState[key]?.entries ? prevState[key]?.entries : [];\n\n return {\n ...prevState,\n [key]: {\n ...newData,\n entries: [...oldEntries, ...newData.entries],\n },\n };\n });\n }, []);\n\n const updateLoadingState = useCallback((key: PersonFinderFilterTypes, state: LoadingState) => {\n setLoadingState((prev) => ({\n ...prev,\n [key]: state,\n }));\n }, []);\n\n const updateSearch = useCallback((value: string) => {\n setSearch(value);\n }, []);\n\n const loadMore = useCallback(\n (key: PersonFinderFilterTypes) => {\n updateLoadingState(key, LoadingState.Pending);\n\n const current = data?.[key];\n\n if (!current) {\n updateLoadingState(key, LoadingState.Error);\n\n return;\n }\n\n if (\n relationMode === RelationMode.SITE &&\n key === PersonFinderFilterTypes.PERSON &&\n search === ''\n ) {\n void getPagedUsersByGroups([{ groupId: -1 }], {\n skip: current.skip,\n take: PAGE_SIZE,\n })\n .then((result: GetUsersByGroupsResult) => {\n const { users, count } = result;\n\n if (users.length > 0) {\n appendData(key, {\n entries: users,\n searchString: '',\n skip: current.skip + users.length,\n count,\n });\n }\n })\n .finally(() => {\n updateLoadingState(key, LoadingState.Success);\n });\n\n return;\n }\n\n void loadData({\n searchString: search ?? '',\n filter: [key],\n skipMap: { [key]: current.skip },\n relationMode,\n })\n .then((result) => {\n const newData = result?.[key];\n\n if (newData) {\n appendData(key, newData);\n }\n })\n .finally(() => {\n updateLoadingState(key, LoadingState.Success);\n });\n },\n [appendData, data, getPagedUsersByGroups, relationMode, search, updateLoadingState],\n );\n\n const addFriend = useCallback((personId: string) => {\n void postFriends(personId).then((result) => {\n if (result) {\n const { firstName, lastName, verificationState } = result;\n\n setFriends((prev) => [\n ...(prev ?? []),\n {\n id: personId,\n isVerified: verificationState === 1,\n commonSites: 0,\n firstName,\n lastName,\n type: PersonFinderFilterTypes.PERSON,\n },\n ]);\n }\n });\n }, []);\n\n const removeFriend = useCallback((personId: string) => {\n void deleteFriends(personId).then((wasSuccessful) => {\n if (wasSuccessful) {\n setFriends((prev) => prev?.filter(({ id }) => id !== personId));\n }\n });\n }, []);\n\n useEffect(() => {\n if (!filterTypes.includes(PersonFinderFilterTypes.PERSON)) {\n return;\n }\n\n void getFriends().then((result) => {\n if (result) {\n setFriends(\n result.map(({ personId, firstName, lastName, verificationState }) => ({\n lastName,\n firstName,\n id: personId,\n commonSites: 0,\n isVerified: verificationState === 1,\n type: PersonFinderFilterTypes.PERSON,\n })),\n );\n }\n });\n }, [filterTypes]);\n\n const latestArgsRef = useRef<{ search: string; filter: PersonFinderFilterTypes[] } | null>(\n null,\n );\n const latestHandledRequestRef = useRef<number>(0);\n\n const throttledRequest = useRef<ThrottledFunction<() => void>>(\n throttle(\n async () => {\n const args = latestArgsRef.current;\n\n if (!args) return;\n\n const { search: searchString, filter } = args;\n const requestTimestamp = Date.now();\n\n filter.forEach((key) => {\n updateLoadingState(key, LoadingState.Pending);\n });\n\n const result = await loadData({\n searchString,\n filter,\n skipMap: {},\n relationMode,\n });\n\n if (requestTimestamp < latestHandledRequestRef.current) {\n return;\n }\n\n latestHandledRequestRef.current = requestTimestamp;\n\n if (!result) return;\n\n Object.entries(result).forEach(([keyString, value]) => {\n const key = keyString as PersonFinderFilterTypes;\n\n if (\n key === PersonFinderFilterTypes.PERSON &&\n friendsPriority === Priority.HIGH &&\n friends\n ) {\n const friendIds = new Set(friends.map((f) => f.id));\n const serverFriendEntries = value.entries.filter((entry) =>\n friendIds.has(entry.id as string),\n );\n const serverFriendIds = new Set(serverFriendEntries.map((f) => f.id));\n\n const missingFriends = friends\n .filter((f) => !serverFriendIds.has(f.id))\n .filter(\n (f) =>\n f.firstName\n ?.toLowerCase()\n .includes(searchString.toLowerCase()) ||\n f.lastName?.toLowerCase().includes(searchString.toLowerCase()),\n );\n\n const otherEntries = value.entries.filter(\n (entry) => !friendIds.has(entry.id as string),\n );\n\n updateData(key, {\n ...value,\n entries: [...serverFriendEntries, ...missingFriends, ...otherEntries],\n });\n } else {\n updateData(key, value);\n }\n\n updateLoadingState(\n key,\n value.entries.length === 0 ? LoadingState.Error : LoadingState.Success,\n );\n });\n },\n THROTTLE_INTERVAL,\n { leading: false, trailing: true },\n ),\n ).current;\n\n useEffect(() => {\n dataRef.current = data;\n }, [data]);\n\n const searchData = useCallback(\n ({ filter }: { filter: PersonFinderFilterTypes[] }) => {\n const tmpData = dataRef.current;\n\n filter.forEach((key) => {\n updateLoadingState(key, LoadingState.Pending);\n\n if (tmpData && tmpData[key]) {\n // Add all Types that are not searched by a request\n const uacEntries = tmpData[key].entries as UACEntry[];\n\n const filteredEntries = uacEntries.filter(({ name }) =>\n name.toLowerCase().includes(search.toLowerCase()),\n );\n\n updateData(key, {\n entries: filteredEntries,\n searchString: search,\n count: filteredEntries.length,\n skip: filteredEntries.length,\n });\n\n updateLoadingState(\n key,\n filteredEntries.length === 0 ? LoadingState.Error : LoadingState.Success,\n );\n }\n });\n },\n [search, updateData, updateLoadingState],\n );\n\n const searchLocal = useCallback(() => {\n if (search.length < 3) {\n return;\n }\n\n updateLoadingState(PersonFinderFilterTypes.PERSON, LoadingState.Pending);\n\n const searchedUsers: PersonEntry[] = [];\n\n const entriesToSearch = entries ?? uacUsers;\n\n entriesToSearch?.forEach((entry) => {\n if (\n entry.firstName?.toLowerCase().includes(search.toLowerCase()) ||\n entry.lastName?.toLowerCase().includes(search.toLowerCase()) ||\n [entry.firstName, entry.lastName]\n .filter(Boolean)\n .join(' ')\n .toLowerCase()\n .trim()\n .includes(search.toLowerCase().trim()) ||\n entry.id.toLowerCase().includes(search.toLowerCase())\n ) {\n searchedUsers.push(entry);\n }\n });\n\n updateData(PersonFinderFilterTypes.PERSON, {\n entries: searchedUsers,\n searchString: search,\n count: searchedUsers.length,\n skip: searchedUsers.length,\n });\n\n updateLoadingState(\n PersonFinderFilterTypes.PERSON,\n searchedUsers.length === 0 ? LoadingState.Error : LoadingState.Success,\n );\n }, [entries, search, uacUsers, updateData, updateLoadingState]);\n\n useEffect(() => {\n if (!search) return;\n\n const active = activeFilter ?? filterTypes;\n\n if (uacFilter || entries) {\n searchLocal();\n } else if (active?.includes(PersonFinderFilterTypes.UAC)) {\n searchData({ filter: [PersonFinderFilterTypes.UAC] });\n } else {\n latestArgsRef.current = { search, filter: active };\n\n throttledRequest();\n }\n }, [\n filterTypes,\n search,\n activeFilter,\n friends,\n friendsPriority,\n updateData,\n updateLoadingState,\n throttledRequest,\n searchData,\n uacFilter,\n searchLocal,\n entries,\n ]);\n\n useEffect(\n () => () => {\n throttledRequest.cancel();\n },\n [throttledRequest],\n );\n\n // load initial data\n useEffect(() => {\n if (entries) {\n return;\n }\n\n if (\n relationMode === RelationMode.SITE &&\n filterTypes.includes(PersonFinderFilterTypes.PERSON)\n ) {\n void getPagedUsersByGroups([{ groupId: -1 }], { skip: 0, take: PAGE_SIZE }).then(\n (result: GetUsersByGroupsResult) => {\n const { users, count } = result;\n\n setData({\n person: {\n entries: users,\n searchString: '',\n skip: users.length,\n count,\n },\n });\n },\n );\n }\n\n if (uacFilter) {\n void getPagedUsersByGroups(uacFilter).then((result: GetUsersByGroupsResult) => {\n const { users } = result;\n\n setUacUsers(users);\n });\n\n return;\n }\n\n if (filterTypes.includes(PersonFinderFilterTypes.UAC) && search === '') {\n void getUACGroups().then((result) => {\n setData({\n uac: {\n entries: result,\n searchString: '',\n skip: result.length,\n count: result.length,\n },\n });\n });\n }\n\n if (\n friendsPriority === Priority.HIGH &&\n filterTypes.includes(PersonFinderFilterTypes.PERSON) &&\n friends &&\n search === ''\n ) {\n setData({\n person: {\n entries: friends,\n searchString: '',\n skip: friends.length,\n count: friends.length,\n },\n });\n }\n }, [\n entries,\n filterTypes,\n friends,\n friendsPriority,\n getPagedUsersByGroups,\n relationMode,\n search,\n uacFilter,\n ]);\n\n const providerValue = useMemo<IPersonFinderContext>(\n () => ({\n data: filterDataByKeys(data, activeFilter, {\n excludedEntryIds,\n shouldShowOwnUser: uacFilter ? false : shouldShowOwnUser,\n }),\n updateData,\n activeFilter,\n updateActiveFilter,\n friends,\n addFriend,\n removeFriend,\n search,\n updateSearch,\n loadMore,\n loadingState,\n updateLoadingState,\n setTags,\n tags,\n relationMode,\n }),\n [\n activeFilter,\n addFriend,\n data,\n excludedEntryIds,\n friends,\n loadMore,\n loadingState,\n removeFriend,\n search,\n shouldShowOwnUser,\n tags,\n uacFilter,\n updateActiveFilter,\n updateData,\n updateLoadingState,\n updateSearch,\n relationMode,\n ],\n );\n\n return (\n <PersonFinderContext.Provider value={providerValue}>\n <TextstringProvider libraryName={PERSON_FINDER_TEXTSTRING_LIBRARY_NAME}>\n {children}\n </TextstringProvider>\n </PersonFinderContext.Provider>\n );\n};\n\nPersonFinderProvider.displayName = 'PersonFinderProvider';\n\nexport default PersonFinderProvider;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,aAAa,EAKbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,SAEIC,YAAY,EAKZC,uBAAuB,EACvBC,QAAQ,EACRC,YAAY,QAIT,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,uBAAuB;AAElE,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,cAAc;AAC7D,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,qCAAqC,QAAQ,0BAA0B;AAEhF,MAAMC,iBAAiB,GAAG,GAAG;AAC7B,MAAMC,SAAS,GAAG,EAAE;AAqCpB,OAAO,MAAMC,mBAAmB,gBAAGvB,aAAa,CAAuB;EACnEwB,IAAI,EAAEC,SAAS;EACfC,UAAU,EAAED,SAAS;EACrBE,OAAO,EAAEF,SAAS;EAClBG,SAAS,EAAEH,SAAS;EACpBI,YAAY,EAAEJ,SAAS;EACvBK,YAAY,EAAEL,SAAS;EACvBM,kBAAkB,EAAEN,SAAS;EAC7BO,MAAM,EAAEP,SAAS;EACjBQ,YAAY,EAAER,SAAS;EACvBS,QAAQ,EAAET,SAAS;EACnBU,YAAY,EAAEV,SAAS;EACvBW,kBAAkB,EAAEX,SA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EACVU,kBAAkB,EAClBH,YAAY,EACZM,YAAY,CAEpB,CAAC;EAED,oBACIxC,KAAA,CAAA6I,aAAA,CAACrH,mBAAmB,CAACsH,QAAQ;IAAClE,KAAK,EAAEgE;EAAc,gBAC/C5I,KAAA,CAAA6I,aAAA,CAACzH,kBAAkB;IAAC2H,WAAW,EAAE1H;EAAsC,GAClEuB,QACe,CACM,CAAC;AAEvC,CAAC;AAEDD,oBAAoB,CAACF,WAAW,GAAG,sBAAsB;AAEzD,eAAeE,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PersonFinderProvider.js","names":["React","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","throttle","LoadingState","PersonFinderFilterTypes","Priority","RelationMode","getFriends","postFriends","deleteFriends","filterDataByKeys","loadData","getUACGroups","getUsersByGroups","TextstringProvider","PERSON_FINDER_TEXTSTRING_LIBRARY_NAME","THROTTLE_INTERVAL","PAGE_SIZE","PersonFinderContext","data","undefined","updateData","friends","addFriend","removeFriend","activeFilter","updateActiveFilter","search","updateSearch","loadMore","loadingState","updateLoadingState","tags","setTags","relationMode","displayName","usePersonFinder","PersonFinderProvider","children","friendsPriority","filterTypes","defaultEntries","excludedEntryIds","shouldShowOwnUser","shouldUseQa","uacFilter","entries","getPagedUsersByGroups","setData","setFriends","uacUsers","setUacUsers","setActiveFilter","setSearch","map","id","name","text","setLoadingState","PERSON","None","SITE","dataRef","filter","key","newData","prevState","appendData","oldEntries","state","prev","value","Pending","current","Error","groupId","skip","take","then","result","users","count","length","searchString","finally","Success","skipMap","personId","firstName","lastName","verificationState","isVerified","commonSites","type","wasSuccessful","includes","latestArgsRef","latestHandledRequestRef","searchLocalRef","searchDataRef","throttledRequest","args","requestTimestamp","Date","now","forEach","Object","keyString","HIGH","friendIds","Set","f","serverFriendEntries","entry","has","serverFriendIds","missingFriends","toLowerCase","otherEntries","leading","trailing","searchData","tmpData","uacEntries","filteredEntries","searchLocal","searchedUsers","entriesToSearch","Boolean","join","trim","push","active","currentData","UAC","filtersToLoad","filterData","filterList","missingFilters","cancel","person","uac","providerValue","createElement","Provider","libraryName"],"sources":["../../../src/components/PersonFinderProvider.tsx"],"sourcesContent":["import React, {\n createContext,\n Dispatch,\n FC,\n ReactNode,\n SetStateAction,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport throttle from 'lodash.throttle';\nimport {\n DefaultEntry,\n LoadingState,\n LoadingStateMap,\n PersonEntry,\n PersonFinderData,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n Priority,\n RelationMode,\n ThrottledFunction,\n UACEntry,\n UACFilter,\n} from '../types/personFinder';\nimport { getFriends } from '../api/friends/get';\nimport { postFriends } from '../api/friends/post';\nimport { deleteFriends } from '../api/friends/delete';\nimport { filterDataByKeys, loadData } from '../utils/personFinder';\nimport { Tag } from '@chayns-components/core/lib/types/types/tagInput';\nimport { getUACGroups, getUsersByGroups } from '../utils/uac';\nimport { TextstringProvider } from '@chayns-components/textstring';\nimport { PERSON_FINDER_TEXTSTRING_LIBRARY_NAME } from '../constants/textStrings';\n\nconst THROTTLE_INTERVAL = 500;\nconst PAGE_SIZE = 20;\n\ntype GetUsersByGroupsResult = {\n users: PersonEntry[];\n count: number;\n};\n\nexport interface IPersonFinderContext {\n // Data\n data?: { [key: string]: PersonFinderData };\n updateData?: (key: PersonFinderFilterTypes, personFinderData: PersonFinderData) => void;\n\n // Tags\n tags?: Tag[];\n setTags?: Dispatch<SetStateAction<Tag[]>>;\n\n // Friends\n friends?: PersonEntry[];\n addFriend?: (personId: string) => void;\n removeFriend?: (personId: string) => void;\n\n // Filter\n activeFilter?: PersonFinderFilterTypes[];\n updateActiveFilter?: (filter: PersonFinderFilterTypes[]) => void;\n\n // Search\n search?: string;\n updateSearch?: (value: string) => void;\n\n // Loading\n loadMore?: (key: PersonFinderFilterTypes) => void;\n loadingState?: LoadingStateMap;\n updateLoadingState?: (key: PersonFinderFilterTypes, state: LoadingState) => void;\n\n relationMode?: RelationMode;\n}\n\nexport const PersonFinderContext = createContext<IPersonFinderContext>({\n data: undefined,\n updateData: undefined,\n friends: undefined,\n addFriend: undefined,\n removeFriend: undefined,\n activeFilter: undefined,\n updateActiveFilter: undefined,\n search: undefined,\n updateSearch: undefined,\n loadMore: undefined,\n loadingState: undefined,\n updateLoadingState: undefined,\n tags: undefined,\n setTags: undefined,\n relationMode: undefined,\n});\n\nPersonFinderContext.displayName = 'PersonFinderContext';\n\nexport const usePersonFinder = () => useContext(PersonFinderContext);\n\ntype PersonFinderProviderProps = {\n children: ReactNode;\n friendsPriority: Priority;\n filterTypes: PersonFinderFilterTypes[];\n defaultEntries?: DefaultEntry[];\n excludedEntryIds?: PersonFinderEntry['id'][];\n shouldShowOwnUser?: boolean;\n uacFilter?: UACFilter[];\n entries?: PersonEntry[];\n relationMode?: RelationMode;\n shouldUseQa: boolean;\n};\n\nconst PersonFinderProvider: FC<PersonFinderProviderProps> = ({\n children,\n friendsPriority,\n filterTypes,\n defaultEntries,\n excludedEntryIds,\n shouldShowOwnUser = false,\n shouldUseQa,\n uacFilter,\n entries,\n relationMode,\n}) => {\n const getPagedUsersByGroups = useCallback(\n getUsersByGroups as unknown as (\n uacFilter: UACFilter[],\n options?: { skip?: number; take?: number },\n ) => Promise<GetUsersByGroupsResult>,\n [],\n );\n\n const [data, setData] = useState<IPersonFinderContext['data']>();\n const [friends, setFriends] = useState<PersonEntry[]>();\n const [uacUsers, setUacUsers] = useState<PersonEntry[]>();\n const [activeFilter, setActiveFilter] = useState<IPersonFinderContext['activeFilter']>();\n const [search, setSearch] = useState('');\n const [tags, setTags] = useState<Tag[]>(\n defaultEntries?.map(({ id, name }) => ({ id, text: name })) ?? [],\n );\n const [loadingState, setLoadingState] = useState<LoadingStateMap>({\n [PersonFinderFilterTypes.PERSON]: LoadingState.None,\n [PersonFinderFilterTypes.SITE]: LoadingState.None,\n });\n\n const dataRef = useRef<IPersonFinderContext['data']>();\n\n const updateActiveFilter = useCallback((filter: IPersonFinderContext['activeFilter']) => {\n setActiveFilter(filter);\n }, []);\n\n const updateData = useCallback((key: PersonFinderFilterTypes, newData: PersonFinderData) => {\n setData((prevState) => ({ ...prevState, [key]: newData }));\n }, []);\n\n const appendData = useCallback((key: PersonFinderFilterTypes, newData: PersonFinderData) => {\n setData((prevState) => {\n const oldEntries = prevState && prevState[key]?.entries ? prevState[key]?.entries : [];\n\n return {\n ...prevState,\n [key]: {\n ...newData,\n entries: [...oldEntries, ...newData.entries],\n },\n };\n });\n }, []);\n\n const updateLoadingState = useCallback((key: PersonFinderFilterTypes, state: LoadingState) => {\n setLoadingState((prev) => ({\n ...prev,\n [key]: state,\n }));\n }, []);\n\n const updateSearch = useCallback((value: string) => {\n setSearch(value);\n }, []);\n\n const loadMore = useCallback(\n (key: PersonFinderFilterTypes) => {\n updateLoadingState(key, LoadingState.Pending);\n\n const current = data?.[key];\n\n if (!current) {\n updateLoadingState(key, LoadingState.Error);\n\n return;\n }\n\n if (\n relationMode === RelationMode.SITE &&\n key === PersonFinderFilterTypes.PERSON &&\n search === ''\n ) {\n void getPagedUsersByGroups([{ groupId: -1 }], {\n skip: current.skip,\n take: PAGE_SIZE,\n })\n .then((result: GetUsersByGroupsResult) => {\n const { users, count } = result;\n\n if (users.length > 0) {\n appendData(key, {\n entries: users,\n searchString: '',\n skip: current.skip + users.length,\n count,\n });\n }\n })\n .finally(() => {\n updateLoadingState(key, LoadingState.Success);\n });\n\n return;\n }\n\n void loadData({\n searchString: search ?? '',\n filter: [key],\n skipMap: { [key]: current.skip },\n relationMode,\n shouldUseQa,\n })\n .then((result) => {\n const newData = result?.[key];\n\n if (newData) {\n appendData(key, newData);\n }\n })\n .finally(() => {\n updateLoadingState(key, LoadingState.Success);\n });\n },\n [\n appendData,\n data,\n getPagedUsersByGroups,\n relationMode,\n search,\n shouldUseQa,\n updateLoadingState,\n ],\n );\n\n const addFriend = useCallback((personId: string) => {\n void postFriends(personId).then((result) => {\n if (result) {\n const { firstName, lastName, verificationState } = result;\n\n setFriends((prev) => [\n ...(prev ?? []),\n {\n id: personId,\n isVerified: verificationState === 1,\n commonSites: 0,\n firstName,\n lastName,\n type: PersonFinderFilterTypes.PERSON,\n },\n ]);\n }\n });\n }, []);\n\n const removeFriend = useCallback((personId: string) => {\n void deleteFriends(personId).then((wasSuccessful) => {\n if (wasSuccessful) {\n setFriends((prev) => prev?.filter(({ id }) => id !== personId));\n }\n });\n }, []);\n\n useEffect(() => {\n if (!filterTypes.includes(PersonFinderFilterTypes.PERSON)) {\n return;\n }\n\n void getFriends().then((result) => {\n if (result) {\n setFriends(\n result.map(({ personId, firstName, lastName, verificationState }) => ({\n lastName,\n firstName,\n id: personId,\n commonSites: 0,\n isVerified: verificationState === 1,\n type: PersonFinderFilterTypes.PERSON,\n })),\n );\n }\n });\n }, [filterTypes]);\n\n const latestArgsRef = useRef<{ search: string; filter: PersonFinderFilterTypes[] } | null>(\n null,\n );\n const latestHandledRequestRef = useRef<number>(0);\n const searchLocalRef = useRef<() => void>(() => {});\n const searchDataRef = useRef<({ filter }: { filter: PersonFinderFilterTypes[] }) => void>(\n () => {},\n );\n\n const throttledRequest = useRef<ThrottledFunction<() => void>>(\n throttle(\n async () => {\n const args = latestArgsRef.current;\n\n if (!args) return;\n\n const { search: searchString, filter } = args;\n const requestTimestamp = Date.now();\n\n filter.forEach((key) => {\n updateLoadingState(key, LoadingState.Pending);\n });\n\n const result = await loadData({\n searchString,\n filter,\n skipMap: {},\n relationMode,\n shouldUseQa,\n });\n\n if (requestTimestamp < latestHandledRequestRef.current) {\n return;\n }\n\n latestHandledRequestRef.current = requestTimestamp;\n\n if (!result) return;\n\n Object.entries(result).forEach(([keyString, value]) => {\n const key = keyString as PersonFinderFilterTypes;\n\n if (\n key === PersonFinderFilterTypes.PERSON &&\n friendsPriority === Priority.HIGH &&\n friends\n ) {\n const friendIds = new Set(friends.map((f) => f.id));\n const serverFriendEntries = value.entries.filter((entry) =>\n friendIds.has(entry.id as string),\n );\n const serverFriendIds = new Set(serverFriendEntries.map((f) => f.id));\n\n const missingFriends = friends\n .filter((f) => !serverFriendIds.has(f.id))\n .filter(\n (f) =>\n f.firstName\n ?.toLowerCase()\n .includes(searchString.toLowerCase()) ||\n f.lastName?.toLowerCase().includes(searchString.toLowerCase()),\n );\n\n const otherEntries = value.entries.filter(\n (entry) => !friendIds.has(entry.id as string),\n );\n\n updateData(key, {\n ...value,\n entries: [...serverFriendEntries, ...missingFriends, ...otherEntries],\n });\n } else {\n updateData(key, value);\n }\n\n updateLoadingState(\n key,\n value.entries.length === 0 ? LoadingState.Error : LoadingState.Success,\n );\n });\n },\n THROTTLE_INTERVAL,\n { leading: false, trailing: true },\n ),\n );\n\n const searchData = useCallback(\n ({ filter }: { filter: PersonFinderFilterTypes[] }) => {\n const tmpData = dataRef.current;\n\n filter.forEach((key) => {\n updateLoadingState(key, LoadingState.Pending);\n\n if (tmpData && tmpData[key]) {\n // Add all Types that are not searched by a request\n const uacEntries = tmpData[key].entries as UACEntry[];\n\n const filteredEntries = uacEntries.filter(({ name }) =>\n name.toLowerCase().includes(search.toLowerCase()),\n );\n\n updateData(key, {\n entries: filteredEntries,\n searchString: search,\n count: filteredEntries.length,\n skip: filteredEntries.length,\n });\n\n updateLoadingState(\n key,\n filteredEntries.length === 0 ? LoadingState.Error : LoadingState.Success,\n );\n }\n });\n },\n [search, updateData, updateLoadingState],\n );\n\n const searchLocal = useCallback(() => {\n if (search.length < 3) {\n return;\n }\n\n updateLoadingState(PersonFinderFilterTypes.PERSON, LoadingState.Pending);\n\n const searchedUsers: PersonEntry[] = [];\n\n const entriesToSearch = entries ?? uacUsers;\n\n entriesToSearch?.forEach((entry) => {\n if (\n entry.firstName?.toLowerCase().includes(search.toLowerCase()) ||\n entry.lastName?.toLowerCase().includes(search.toLowerCase()) ||\n [entry.firstName, entry.lastName]\n .filter(Boolean)\n .join(' ')\n .toLowerCase()\n .trim()\n .includes(search.toLowerCase().trim()) ||\n entry.id.toLowerCase().includes(search.toLowerCase())\n ) {\n searchedUsers.push(entry);\n }\n });\n\n updateData(PersonFinderFilterTypes.PERSON, {\n entries: searchedUsers,\n searchString: search,\n count: searchedUsers.length,\n skip: searchedUsers.length,\n });\n\n updateLoadingState(\n PersonFinderFilterTypes.PERSON,\n searchedUsers.length === 0 ? LoadingState.Error : LoadingState.Success,\n );\n }, [entries, search, uacUsers, updateData, updateLoadingState]);\n\n useEffect(() => {\n dataRef.current = data;\n }, [data]);\n\n useEffect(() => {\n searchLocalRef.current = searchLocal;\n }, [searchLocal]);\n\n useEffect(() => {\n searchDataRef.current = searchData;\n }, [searchData]);\n\n useEffect(() => {\n if (!search) return;\n\n const active = activeFilter && activeFilter.length > 0 ? activeFilter : filterTypes;\n const currentData = dataRef.current;\n\n if (uacFilter || entries) {\n searchLocalRef.current();\n } else if (active?.includes(PersonFinderFilterTypes.UAC)) {\n searchDataRef.current({ filter: [PersonFinderFilterTypes.UAC] });\n } else {\n // Only load filters that don't have data for this search yet\n const filtersToLoad = active.filter((filter) => {\n const filterData = currentData?.[filter];\n return !filterData || filterData.searchString !== search;\n });\n\n // If we have filters to load, use them; otherwise use all active filters\n const filterList = filtersToLoad.length > 0 ? filtersToLoad : active;\n\n latestArgsRef.current = { search, filter: filterList };\n\n throttledRequest.current();\n }\n }, [search, uacFilter, entries]);\n\n // Handle filter changes - load missing data for newly selected filters\n useEffect(() => {\n if (!search) return;\n\n const active = activeFilter && activeFilter.length > 0 ? activeFilter : filterTypes;\n const currentData = dataRef.current;\n\n // Check which filters need to be loaded (don't have data for current search)\n const missingFilters = active.filter((filter) => {\n const filterData = currentData?.[filter];\n // If no data or data is from a different search, we need to load it\n return !filterData || filterData.searchString !== search;\n });\n\n if (missingFilters.length === 0) return;\n if (uacFilter || entries) return;\n if (active?.includes(PersonFinderFilterTypes.UAC)) return;\n\n // Load only the missing filters\n latestArgsRef.current = { search, filter: missingFilters };\n throttledRequest.current();\n }, [activeFilter, search, uacFilter, entries, filterTypes]);\n\n useEffect(\n () => () => {\n throttledRequest.current?.cancel();\n },\n [],\n );\n\n // load initial data\n useEffect(() => {\n if (entries) {\n return;\n }\n\n if (\n relationMode === RelationMode.SITE &&\n filterTypes.includes(PersonFinderFilterTypes.PERSON)\n ) {\n void getPagedUsersByGroups([{ groupId: -1 }], { skip: 0, take: PAGE_SIZE }).then(\n (result: GetUsersByGroupsResult) => {\n const { users, count } = result;\n\n setData({\n person: {\n entries: users,\n searchString: '',\n skip: users.length,\n count,\n },\n });\n },\n );\n }\n\n if (uacFilter) {\n void getPagedUsersByGroups(uacFilter).then((result: GetUsersByGroupsResult) => {\n const { users } = result;\n\n setUacUsers(users);\n });\n\n return;\n }\n\n if (filterTypes.includes(PersonFinderFilterTypes.UAC) && search === '') {\n void getUACGroups().then((result) => {\n setData({\n uac: {\n entries: result,\n searchString: '',\n skip: result.length,\n count: result.length,\n },\n });\n });\n }\n\n if (\n friendsPriority === Priority.HIGH &&\n filterTypes.includes(PersonFinderFilterTypes.PERSON) &&\n friends &&\n search === ''\n ) {\n setData({\n person: {\n entries: friends,\n searchString: '',\n skip: friends.length,\n count: friends.length,\n },\n });\n }\n }, [\n entries,\n filterTypes,\n friends,\n friendsPriority,\n getPagedUsersByGroups,\n relationMode,\n search,\n uacFilter,\n ]);\n\n const providerValue = useMemo<IPersonFinderContext>(\n () => ({\n data: filterDataByKeys(data, activeFilter, {\n excludedEntryIds,\n shouldShowOwnUser: uacFilter ? false : shouldShowOwnUser,\n }),\n updateData,\n activeFilter,\n updateActiveFilter,\n friends,\n addFriend,\n removeFriend,\n search,\n updateSearch,\n loadMore,\n loadingState,\n updateLoadingState,\n setTags,\n tags,\n relationMode,\n }),\n [\n activeFilter,\n addFriend,\n data,\n excludedEntryIds,\n friends,\n loadMore,\n loadingState,\n removeFriend,\n search,\n shouldShowOwnUser,\n tags,\n uacFilter,\n updateActiveFilter,\n updateData,\n updateLoadingState,\n updateSearch,\n relationMode,\n ],\n );\n\n return (\n <PersonFinderContext.Provider value={providerValue}>\n <TextstringProvider libraryName={PERSON_FINDER_TEXTSTRING_LIBRARY_NAME}>\n {children}\n </TextstringProvider>\n </PersonFinderContext.Provider>\n );\n};\n\nPersonFinderProvider.displayName = 'PersonFinderProvider';\n\nexport default PersonFinderProvider;\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,aAAa,EAKbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,SAEIC,YAAY,EAKZC,uBAAuB,EACvBC,QAAQ,EACRC,YAAY,QAIT,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,uBAAuB;AAElE,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,cAAc;AAC7D,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,qCAAqC,QAAQ,0BAA0B;AAEhF,MAAMC,iBAAiB,GAAG,GAAG;AAC7B,MAAMC,SAAS,GAAG,EAAE;AAqCpB,OAAO,MAAMC,mBAAmB,gBAAGvB,aAAa,CAAuB;EACnEwB,IAAI,EAAEC,SAAS;EACfC,UAAU,EAAED,SAAS;EACrBE,OAAO,EAAEF,SAAS;EAClBG,SAAS,EAAEH,SAAS;EACpBI,YAAY,EAAEJ,SAAS;EACvBK,YAAY,EAAEL,SAAS;EACvBM,kBAAkB,EAAEN,SAAS;EAC7BO,MAAM,EAAEP,SAAS;EACjBQ,YAAY,EAAER,SAAS;EACvBS,QAAQ,EAAET,SAAS;EACnBU,YAAY,EAAEV,SAAS;EACvBW,kBAAkB,EAAEX,SAAS;EAC7BY,IAAI,EAAEZ,SAAS;EACfa,OAAO,EAAEb,SAAS;EAClBc,YAAY,EAAEd;AAClB,CAAC,CAAC;AAEFF,mBAAmB,CAACiB,WAA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I;IACJE;EACJ,CAAC,CAAC,EACF,CACIT,YAAY,EACZF,SAAS,EACTJ,IAAI,EACJuB,gBAAgB,EAChBpB,OAAO,EACPO,QAAQ,EACRC,YAAY,EACZN,YAAY,EACZG,MAAM,EACNgB,iBAAiB,EACjBX,IAAI,EACJa,SAAS,EACTnB,kBAAkB,EAClBL,UAAU,EACVU,kBAAkB,EAClBH,YAAY,EACZM,YAAY,CAEpB,CAAC;EAED,oBACIxC,KAAA,CAAAqJ,aAAA,CAAC7H,mBAAmB,CAAC8H,QAAQ;IAACzE,KAAK,EAAEuE;EAAc,gBAC/CpJ,KAAA,CAAAqJ,aAAA,CAACjI,kBAAkB;IAACmI,WAAW,EAAElI;EAAsC,GAClEuB,QACe,CACM,CAAC;AAEvC,CAAC;AAEDD,oBAAoB,CAACF,WAAW,GAAG,sBAAsB;AAEzD,eAAeE,oBAAoB","ignoreList":[]}
|
|
@@ -20,6 +20,7 @@ const PersonFinder = /*#__PURE__*/forwardRef(({
|
|
|
20
20
|
onDropdownHide,
|
|
21
21
|
onDropdownShow,
|
|
22
22
|
onRemove,
|
|
23
|
+
shouldUseQa = false,
|
|
23
24
|
placeholder = 'Person oder Site finden',
|
|
24
25
|
shouldAllowMultiple = true,
|
|
25
26
|
shouldHideResultsOnAdd = !shouldAllowMultiple || false,
|
|
@@ -39,6 +40,7 @@ const PersonFinder = /*#__PURE__*/forwardRef(({
|
|
|
39
40
|
excludedEntryIds: excludedEntryIds,
|
|
40
41
|
shouldShowOwnUser: shouldShowOwnUser,
|
|
41
42
|
uacFilter: uacFilter,
|
|
43
|
+
shouldUseQa: shouldUseQa,
|
|
42
44
|
entries: entries,
|
|
43
45
|
relationMode: relationMode
|
|
44
46
|
}, /*#__PURE__*/React.createElement(AreaProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonFinder.js","names":["React","forwardRef","useImperativeHandle","useRef","PersonFinderFilterTypes","Priority","RelationMode","PersonFinderProvider","PersonFinderWrapper","AreaProvider","DEFAULT_FILTER_TYPES","PERSON","SITE","PersonFinder","container","dropdownDirection","defaultEntries","excludedEntryIds","relationMode","uacFilter","entries","filterTypes","friendsPriority","NORMAL","HIGH","leftElement","maxEntries","onAdd","onDropdownHide","onDropdownShow","onRemove","placeholder","shouldAllowMultiple","shouldHideResultsOnAdd","shouldShowOwnUser","shouldDisableRemove","shouldRenderInline","ref","personFinderRef","innerRef","clear","current","createElement","shouldChangeColor","shouldDisableListItemPadding","className","displayName"],"sources":["../../../../src/components/person-finder/PersonFinder.tsx"],"sourcesContent":["import React, { forwardRef, useImperativeHandle, useRef } from 'react';\nimport {\n DefaultEntry,\n PersonEntry,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n Priority,\n RelationMode,\n UACFilter,\n} from '../../types/personFinder';\nimport PersonFinderProvider from '../PersonFinderProvider';\nimport PersonFinderWrapper, {\n PersonFinderRef,\n PersonFinderWrapperProps,\n} from './person-finder-wrapper/PersonFinderWrapper';\nimport { AreaProvider } from '@chayns-components/core';\n\nconst DEFAULT_FILTER_TYPES = [PersonFinderFilterTypes.PERSON, PersonFinderFilterTypes.SITE];\n\nexport type PersonFinderProps = PersonFinderWrapperProps & {\n /**\n * Sites and persons that are selected by default.\n */\n defaultEntries?: DefaultEntry[];\n /**\n * Entry ids to exclude from the results\n */\n excludedEntryIds?: PersonFinderEntry['id'][];\n /**\n * Whether the own user should be shown in the results. By default, it is not shown.\n */\n shouldShowOwnUser?: boolean;\n /**\n * Optional filter to search member of uac group. Only works with groups of the current Site and if the user is manager.\n */\n uacFilter?: UACFilter[];\n /**\n * A list of entries that should be searched.\n */\n entries?: PersonEntry[];\n};\n\nconst PersonFinder = forwardRef<PersonFinderRef, PersonFinderProps>(\n (\n {\n container,\n dropdownDirection,\n defaultEntries,\n excludedEntryIds,\n relationMode = RelationMode.PERSON,\n uacFilter,\n entries,\n filterTypes = uacFilter || entries\n ? [PersonFinderFilterTypes.PERSON]\n : DEFAULT_FILTER_TYPES,\n friendsPriority = relationMode === RelationMode.SITE ? Priority.NORMAL : Priority.HIGH,\n leftElement,\n maxEntries,\n onAdd,\n onDropdownHide,\n onDropdownShow,\n onRemove,\n placeholder = 'Person oder Site finden',\n shouldAllowMultiple = true,\n shouldHideResultsOnAdd = !shouldAllowMultiple || false,\n shouldShowOwnUser = false,\n shouldDisableRemove = false,\n shouldRenderInline = false,\n },\n ref,\n ) => {\n const personFinderRef = useRef<HTMLDivElement>(null);\n const innerRef = useRef<PersonFinderRef>(null);\n\n useImperativeHandle(ref, () => ({\n clear: () => innerRef.current?.clear(),\n }));\n\n return (\n <PersonFinderProvider\n friendsPriority={friendsPriority}\n defaultEntries={defaultEntries}\n filterTypes={filterTypes}\n excludedEntryIds={excludedEntryIds}\n shouldShowOwnUser={shouldShowOwnUser}\n uacFilter={uacFilter}\n entries={entries}\n relationMode={relationMode}\n >\n <AreaProvider shouldChangeColor={false} shouldDisableListItemPadding>\n <div className=\"beta-chayns-person-finder\" ref={personFinderRef}>\n <PersonFinderWrapper\n ref={innerRef}\n container={container}\n dropdownDirection={dropdownDirection}\n filterTypes={filterTypes}\n maxEntries={maxEntries}\n onAdd={onAdd}\n relationMode={relationMode}\n shouldDisableRemove={shouldDisableRemove}\n onDropdownHide={onDropdownHide}\n onDropdownShow={onDropdownShow}\n leftElement={leftElement}\n onRemove={onRemove}\n placeholder={placeholder}\n shouldAllowMultiple={shouldAllowMultiple}\n shouldHideResultsOnAdd={shouldHideResultsOnAdd}\n shouldRenderInline={shouldRenderInline}\n />\n </div>\n </AreaProvider>\n </PersonFinderProvider>\n );\n },\n);\n\nPersonFinder.displayName = 'PersonFinder';\n\nexport default PersonFinder;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,OAAO;AACtE,SAIIC,uBAAuB,EACvBC,QAAQ,EACRC,YAAY,QAET,0BAA0B;AACjC,OAAOC,oBAAoB,MAAM,yBAAyB;AAC1D,OAAOC,mBAAmB,MAGnB,6CAA6C;AACpD,SAASC,YAAY,QAAQ,yBAAyB;AAEtD,MAAMC,oBAAoB,GAAG,CAACN,uBAAuB,CAACO,MAAM,EAAEP,uBAAuB,CAACQ,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"PersonFinder.js","names":["React","forwardRef","useImperativeHandle","useRef","PersonFinderFilterTypes","Priority","RelationMode","PersonFinderProvider","PersonFinderWrapper","AreaProvider","DEFAULT_FILTER_TYPES","PERSON","SITE","PersonFinder","container","dropdownDirection","defaultEntries","excludedEntryIds","relationMode","uacFilter","entries","filterTypes","friendsPriority","NORMAL","HIGH","leftElement","maxEntries","onAdd","onDropdownHide","onDropdownShow","onRemove","shouldUseQa","placeholder","shouldAllowMultiple","shouldHideResultsOnAdd","shouldShowOwnUser","shouldDisableRemove","shouldRenderInline","ref","personFinderRef","innerRef","clear","current","createElement","shouldChangeColor","shouldDisableListItemPadding","className","displayName"],"sources":["../../../../src/components/person-finder/PersonFinder.tsx"],"sourcesContent":["import React, { forwardRef, useImperativeHandle, useRef } from 'react';\nimport {\n DefaultEntry,\n PersonEntry,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n Priority,\n RelationMode,\n UACFilter,\n} from '../../types/personFinder';\nimport PersonFinderProvider from '../PersonFinderProvider';\nimport PersonFinderWrapper, {\n PersonFinderRef,\n PersonFinderWrapperProps,\n} from './person-finder-wrapper/PersonFinderWrapper';\nimport { AreaProvider } from '@chayns-components/core';\n\nconst DEFAULT_FILTER_TYPES = [PersonFinderFilterTypes.PERSON, PersonFinderFilterTypes.SITE];\n\nexport type PersonFinderProps = PersonFinderWrapperProps & {\n /**\n * Sites and persons that are selected by default.\n */\n defaultEntries?: DefaultEntry[];\n /**\n * Entry ids to exclude from the results\n */\n excludedEntryIds?: PersonFinderEntry['id'][];\n /**\n * Whether the own user should be shown in the results. By default, it is not shown.\n */\n shouldShowOwnUser?: boolean;\n /**\n * Whether the qa relations should be used.\n */\n shouldUseQa?: boolean;\n /**\n * Optional filter to search member of uac group. Only works with groups of the current Site and if the user is manager.\n */\n uacFilter?: UACFilter[];\n /**\n * A list of entries that should be searched.\n */\n entries?: PersonEntry[];\n};\n\nconst PersonFinder = forwardRef<PersonFinderRef, PersonFinderProps>(\n (\n {\n container,\n dropdownDirection,\n defaultEntries,\n excludedEntryIds,\n relationMode = RelationMode.PERSON,\n uacFilter,\n entries,\n filterTypes = uacFilter || entries\n ? [PersonFinderFilterTypes.PERSON]\n : DEFAULT_FILTER_TYPES,\n friendsPriority = relationMode === RelationMode.SITE ? Priority.NORMAL : Priority.HIGH,\n leftElement,\n maxEntries,\n onAdd,\n onDropdownHide,\n onDropdownShow,\n onRemove,\n shouldUseQa = false,\n placeholder = 'Person oder Site finden',\n shouldAllowMultiple = true,\n shouldHideResultsOnAdd = !shouldAllowMultiple || false,\n shouldShowOwnUser = false,\n shouldDisableRemove = false,\n shouldRenderInline = false,\n },\n ref,\n ) => {\n const personFinderRef = useRef<HTMLDivElement>(null);\n const innerRef = useRef<PersonFinderRef>(null);\n\n useImperativeHandle(ref, () => ({\n clear: () => innerRef.current?.clear(),\n }));\n\n return (\n <PersonFinderProvider\n friendsPriority={friendsPriority}\n defaultEntries={defaultEntries}\n filterTypes={filterTypes}\n excludedEntryIds={excludedEntryIds}\n shouldShowOwnUser={shouldShowOwnUser}\n uacFilter={uacFilter}\n shouldUseQa={shouldUseQa}\n entries={entries}\n relationMode={relationMode}\n >\n <AreaProvider shouldChangeColor={false} shouldDisableListItemPadding>\n <div className=\"beta-chayns-person-finder\" ref={personFinderRef}>\n <PersonFinderWrapper\n ref={innerRef}\n container={container}\n dropdownDirection={dropdownDirection}\n filterTypes={filterTypes}\n maxEntries={maxEntries}\n onAdd={onAdd}\n relationMode={relationMode}\n shouldDisableRemove={shouldDisableRemove}\n onDropdownHide={onDropdownHide}\n onDropdownShow={onDropdownShow}\n leftElement={leftElement}\n onRemove={onRemove}\n placeholder={placeholder}\n shouldAllowMultiple={shouldAllowMultiple}\n shouldHideResultsOnAdd={shouldHideResultsOnAdd}\n shouldRenderInline={shouldRenderInline}\n />\n </div>\n </AreaProvider>\n </PersonFinderProvider>\n );\n },\n);\n\nPersonFinder.displayName = 'PersonFinder';\n\nexport default PersonFinder;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,OAAO;AACtE,SAIIC,uBAAuB,EACvBC,QAAQ,EACRC,YAAY,QAET,0BAA0B;AACjC,OAAOC,oBAAoB,MAAM,yBAAyB;AAC1D,OAAOC,mBAAmB,MAGnB,6CAA6C;AACpD,SAASC,YAAY,QAAQ,yBAAyB;AAEtD,MAAMC,oBAAoB,GAAG,CAACN,uBAAuB,CAACO,MAAM,EAAEP,uBAAuB,CAACQ,IAAI,CAAC;AA6B3F,MAAMC,YAAY,gBAAGZ,UAAU,CAC3B,CACI;EACIa,SAAS;EACTC,iBAAiB;EACjBC,cAAc;EACdC,gBAAgB;EAChBC,YAAY,GAAGZ,YAAY,CAACK,MAAM;EAClCQ,SAAS;EACTC,OAAO;EACPC,WAAW,GAAGF,SAAS,IAAIC,OAAO,GAC5B,CAAChB,uBAAuB,CAACO,MAAM,CAAC,GAChCD,oBAAoB;EAC1BY,eAAe,GAAGJ,YAAY,KAAKZ,YAAY,CAACM,IAAI,GAAGP,QAAQ,CAACkB,MAAM,GAAGlB,QAAQ,CAACmB,IAAI;EACtFC,WAAW;EACXC,UAAU;EACVC,KAAK;EACLC,cAAc;EACdC,cAAc;EACdC,QAAQ;EACRC,WAAW,GAAG,KAAK;EACnBC,WAAW,GAAG,yBAAyB;EACvCC,mBAAmB,GAAG,IAAI;EAC1BC,sBAAsB,GAAG,CAACD,mBAAmB,IAAI,KAAK;EACtDE,iBAAiB,GAAG,KAAK;EACzBC,mBAAmB,GAAG,KAAK;EAC3BC,kBAAkB,GAAG;AACzB,CAAC,EACDC,GAAG,KACF;EACD,MAAMC,eAAe,GAAGpC,MAAM,CAAiB,IAAI,CAA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B,YAAY,CAACkC,WAAW,GAAG,cAAc;AAEzC,eAAelC,YAAY","ignoreList":[]}
|
|
@@ -37,6 +37,7 @@ const PersonFinderWrapper = /*#__PURE__*/forwardRef(({
|
|
|
37
37
|
const contentRef = useRef(null);
|
|
38
38
|
const keyRef = useRef(`person-finder-${uuidV4()}`);
|
|
39
39
|
const tagInputRef = useRef(null);
|
|
40
|
+
const hasFocusRef = useRef(false);
|
|
40
41
|
const {
|
|
41
42
|
isTouch
|
|
42
43
|
} = useDevice();
|
|
@@ -44,9 +45,11 @@ const PersonFinderWrapper = /*#__PURE__*/forwardRef(({
|
|
|
44
45
|
icons: ['fa fa-search']
|
|
45
46
|
}));
|
|
46
47
|
const handleTagInputBlur = useCallback(() => {
|
|
48
|
+
hasFocusRef.current = false;
|
|
47
49
|
setIsFocused(false);
|
|
48
50
|
}, []);
|
|
49
51
|
const handleTagInputFocus = useCallback(() => {
|
|
52
|
+
hasFocusRef.current = true;
|
|
50
53
|
setIsFocused(true);
|
|
51
54
|
}, []);
|
|
52
55
|
const handleRemove = useCallback(id => {
|
|
@@ -73,8 +76,8 @@ const PersonFinderWrapper = /*#__PURE__*/forwardRef(({
|
|
|
73
76
|
}, [setTags, shouldDisableRemove]);
|
|
74
77
|
const handleDropdownOutsideClick = useCallback(() => {
|
|
75
78
|
tagInputRef.current?.blur();
|
|
76
|
-
return
|
|
77
|
-
}, [
|
|
79
|
+
return hasFocusRef.current && isTouch;
|
|
80
|
+
}, [isTouch]);
|
|
78
81
|
const handleAdd = useCallback(id => {
|
|
79
82
|
if (typeof setTags !== 'function') {
|
|
80
83
|
return;
|
|
@@ -126,8 +129,7 @@ const PersonFinderWrapper = /*#__PURE__*/forwardRef(({
|
|
|
126
129
|
}
|
|
127
130
|
}, [onDropdownHide, onDropdownShow, shouldShowBody]);
|
|
128
131
|
const showBody = useMemo(() => {
|
|
129
|
-
const
|
|
130
|
-
const check = shouldShowBody && extraMobileCheck;
|
|
132
|
+
const check = shouldShowBody;
|
|
131
133
|
if (relationMode === RelationMode.SITE) {
|
|
132
134
|
return check;
|
|
133
135
|
}
|
|
@@ -135,7 +137,7 @@ const PersonFinderWrapper = /*#__PURE__*/forwardRef(({
|
|
|
135
137
|
return check && !!search && search?.length > 2;
|
|
136
138
|
}
|
|
137
139
|
return check;
|
|
138
|
-
}, [filterTypes, friendsPriority,
|
|
140
|
+
}, [filterTypes, friendsPriority, search, shouldShowBody, relationMode]);
|
|
139
141
|
const content = useMemo(() => {
|
|
140
142
|
const body = /*#__PURE__*/React.createElement(PersonFinderBody, {
|
|
141
143
|
filterTypes: filterTypes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonFinderWrapper.js","names":["DropdownBodyWrapper","Icon","TagInput","useDevice","React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","v4","uuidV4","PersonFinderFilterTypes","Priority","RelationMode","StyledPersonFinder","StyledPersonFinderLeftElement","PersonFinderBody","usePersonFinder","PersonFinderWrapper","container","dropdownDirection","filterTypes","friendsPriority","leftElement","leftElementProp","maxEntries","Infinity","onAdd","onDropdownHide","onDropdownShow","shouldDisableRemove","onRemove","placeholder","shouldAllowMultiple","shouldHideResultsOnAdd","shouldRenderInline","relationMode","ref","data","updateSearch","setTags","tags","search","isFocused","setIsFocused","shouldShowBody","setShouldShowBody","boxRef","contentRef","keyRef","tagInputRef","isTouch","createElement","icons","handleTagInputBlur","handleTagInputFocus","handleRemove","id","prevState","filter","entry","handleClose","handleOpen","handleClear","current","resetValue","handleDropdownOutsideClick","blur","handleAdd","selectedEntry","Object","values","flat","map","entries","find","toString","name","firstName","lastName","tag","text","some","t","length","handleChange","event","target","value","clear","showBody","extraMobileCheck","check","SITE","includes","PERSON","HIGH","content","body","anchorElement","direction","onClose","onOutsideClick","shouldShowDropdown","onFocus","key","onBlur","onChange","shouldPreventEnter","displayName"],"sources":["../../../../../src/components/person-finder/person-finder-wrapper/PersonFinderWrapper.tsx"],"sourcesContent":["import {\n DropdownBodyWrapper,\n DropdownDirection,\n Icon,\n type Tag,\n TagInput,\n type TagInputRef,\n} from '@chayns-components/core';\nimport { useDevice } from 'chayns-api';\nimport React, {\n type ChangeEvent,\n forwardRef,\n type ReactElement,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { v4 as uuidV4 } from 'uuid';\nimport {\n PersonEntry,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n Priority,\n RelationMode,\n SiteEntry,\n} from '../../../types/personFinder';\nimport { StyledPersonFinder, StyledPersonFinderLeftElement } from './PersonFinderWrapper.styles';\nimport PersonFinderBody from './person-finder-body/PersonFinderBody';\nimport { usePersonFinder } from '../../PersonFinderProvider';\n\nexport type PersonFinderRef = {\n clear: () => void;\n};\n\nexport type PersonFinderWrapperProps = {\n /**\n * The element where the content of the `PersonFinder` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The direction in which the dropdown should be displayed. By default, it is displayed below the input.\n */\n dropdownDirection?: DropdownDirection;\n /**\n * The filter options of the component.\n */\n filterTypes?: PersonFinderFilterTypes[];\n /**\n * Determines the priority level for displaying friends in search results.\n */\n friendsPriority?: Priority;\n /**\n * An element that should be displayed on the left side of the input.\n */\n leftElement?: ReactElement;\n /**\n * The maximum number of entries that can be selected.\n */\n maxEntries?: number;\n /**\n * Function to be executed if a person or site is added.\n */\n onAdd?: (entry: PersonFinderEntry) => void;\n /**\n * Function to be executed if the dropdown is hidden.\n */\n onDropdownHide?: () => void;\n /**\n * Function to be executed if the dropdown is shown.\n */\n onDropdownShow?: () => void;\n /**\n * Function to be executed if a person or site is removed.\n */\n onRemove?: (id: PersonFinderEntry['id']) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * Whether multiple persons and sites should be selected.\n */\n shouldAllowMultiple?: boolean;\n /**\n * Whether the dropdown should be hidden after adding an entry. By default, it is not hidden.\n */\n shouldHideResultsOnAdd?: boolean;\n /**\n * Whether the `PersonFinder` should be rendered inline without a dropdown.\n * @description\n * If set to `true`, the `PersonFinder` will display the results below the input field, without\n * using a dropdown. This is useful for scenarios where the `PersonFinder` is part of a larger\n * form and should always be visible.\n * @default false\n * @example\n * <PersonFinder shouldRenderInline />\n * @optional\n */\n shouldRenderInline?: boolean;\n /**\n * Whether the remove action should be disabled.\n */\n shouldDisableRemove?: boolean;\n /**\n * Determines whether persons are searched and sorted from the user's perspective or from a site's perspective.\n */\n relationMode?: RelationMode;\n};\n\nconst PersonFinderWrapper = forwardRef<PersonFinderRef, PersonFinderWrapperProps>(\n (\n {\n container,\n dropdownDirection,\n filterTypes,\n friendsPriority,\n leftElement: leftElementProp,\n maxEntries = Infinity,\n onAdd,\n onDropdownHide,\n onDropdownShow,\n shouldDisableRemove,\n onRemove,\n placeholder,\n shouldAllowMultiple,\n shouldHideResultsOnAdd,\n shouldRenderInline,\n relationMode,\n },\n ref,\n ) => {\n const { data, updateSearch, setTags, tags, search } = usePersonFinder();\n\n const [isFocused, setIsFocused] = useState(false);\n const [shouldShowBody, setShouldShowBody] = useState(false);\n\n const boxRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const keyRef = useRef(`person-finder-${uuidV4()}`);\n const tagInputRef = useRef<TagInputRef>(null);\n\n const { isTouch } = useDevice();\n\n const leftElement = leftElementProp ?? (\n <StyledPersonFinderLeftElement>\n <Icon icons={['fa fa-search']} />\n </StyledPersonFinderLeftElement>\n );\n\n const handleTagInputBlur = useCallback(() => {\n setIsFocused(false);\n }, []);\n\n const handleTagInputFocus = useCallback(() => {\n setIsFocused(true);\n }, []);\n\n const handleRemove = useCallback(\n (id: string) => {\n if (typeof setTags !== 'function' || shouldDisableRemove) {\n return;\n }\n\n setTags((prevState) => prevState.filter((entry) => entry.id !== id));\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n },\n [onRemove, setTags, shouldDisableRemove],\n );\n\n const handleClose = useCallback(() => {\n setShouldShowBody(false);\n }, []);\n\n const handleOpen = useCallback(() => {\n setShouldShowBody(true);\n }, []);\n\n const handleClear = useCallback(() => {\n if (typeof setTags !== 'function' || shouldDisableRemove) {\n return;\n }\n\n tagInputRef.current?.resetValue();\n\n setTags([]);\n }, [setTags, shouldDisableRemove]);\n\n const handleDropdownOutsideClick = useCallback(() => {\n tagInputRef.current?.blur();\n\n return isFocused && isTouch;\n }, [isFocused, isTouch]);\n\n const handleAdd = useCallback(\n (id: string) => {\n if (typeof setTags !== 'function') {\n return;\n }\n\n const selectedEntry = Object.values(data ?? {})\n .flat()\n .map(({ entries }) => entries)\n .flat()\n .find(\n (entry) =>\n (typeof entry.id === 'string' ? entry.id : entry.id.toString()) === id,\n );\n\n if (!selectedEntry) {\n return;\n }\n\n const { name, firstName, lastName } = selectedEntry as PersonEntry & SiteEntry;\n\n const tag: Tag = {\n id,\n text: name ?? `${(firstName as string) ?? ''} ${(lastName as string) ?? ''}`,\n };\n\n setTags((prevState) => {\n if (prevState.some((t) => t.id === id) || prevState.length >= maxEntries) {\n return prevState;\n }\n\n tagInputRef.current?.resetValue();\n\n if (typeof onAdd === 'function') {\n onAdd(selectedEntry);\n }\n\n if (shouldHideResultsOnAdd) {\n setShouldShowBody(false);\n }\n\n return [...prevState, tag];\n });\n },\n [data, maxEntries, onAdd, setTags, shouldHideResultsOnAdd],\n );\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (typeof updateSearch === 'function') {\n updateSearch(event.target.value);\n }\n },\n [updateSearch],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n clear: () => handleClear(),\n }),\n [handleClear],\n );\n\n useEffect(() => {\n if (shouldShowBody) {\n if (typeof onDropdownShow === 'function') {\n onDropdownShow();\n }\n } else if (typeof onDropdownHide === 'function') {\n onDropdownHide();\n }\n }, [onDropdownHide, onDropdownShow, shouldShowBody]);\n\n const showBody = useMemo(() => {\n const extraMobileCheck = isTouch ? isFocused : true;\n\n const check = shouldShowBody && extraMobileCheck;\n\n if (relationMode === RelationMode.SITE) {\n return check;\n }\n\n if (\n filterTypes?.length === 1 &&\n (filterTypes.includes(PersonFinderFilterTypes.SITE) ||\n (filterTypes.includes(PersonFinderFilterTypes.PERSON) &&\n friendsPriority !== Priority.HIGH))\n ) {\n return check && !!search && search?.length > 2;\n }\n\n return check;\n }, [\n filterTypes,\n friendsPriority,\n isFocused,\n isTouch,\n search,\n shouldShowBody,\n relationMode,\n ]);\n\n const content = useMemo(() => {\n const body = (\n <PersonFinderBody\n filterTypes={filterTypes}\n onAdd={handleAdd}\n onRemove={handleRemove}\n ref={contentRef}\n shouldRenderInline={shouldRenderInline}\n />\n );\n\n if (shouldRenderInline) {\n return body;\n }\n\n if (boxRef.current) {\n return (\n <DropdownBodyWrapper\n anchorElement={boxRef.current}\n container={container}\n direction={dropdownDirection}\n onClose={handleClose}\n onOutsideClick={handleDropdownOutsideClick}\n shouldShowDropdown={showBody}\n >\n {body}\n </DropdownBodyWrapper>\n );\n }\n\n return null;\n }, [\n container,\n dropdownDirection,\n filterTypes,\n handleAdd,\n handleClose,\n handleDropdownOutsideClick,\n handleRemove,\n shouldRenderInline,\n showBody,\n ]);\n\n return (\n <StyledPersonFinder ref={boxRef} onFocus={handleOpen} key={keyRef.current}>\n <TagInput\n leftElement={leftElement}\n onBlur={handleTagInputBlur}\n onChange={handleChange}\n onFocus={handleTagInputFocus}\n onRemove={handleRemove}\n placeholder={placeholder}\n ref={tagInputRef}\n shouldAllowMultiple={shouldAllowMultiple}\n shouldPreventEnter\n tags={tags}\n />\n {content}\n </StyledPersonFinder>\n );\n },\n);\n\nPersonFinderWrapper.displayName = 'PersonFinderWrapper';\n\nexport default PersonFinderWrapper;\n"],"mappings":"AAAA,SACIA,mBAAmB,EAEnBC,IAAI,EAEJC,QAAQ,QAEL,yBAAyB;AAChC,SAASC,SAAS,QAAQ,YAAY;AACtC,OAAOC,KAAK,IAERC,UAAU,EAEVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAA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MAAO;IAACyD,OAAO,EAAE1C,UAAW;IAAC2C,GAAG,EAAExD,MAAM,CAACe;EAAQ,gBACtE/D,KAAA,CAAAmD,aAAA,CAACrD,QAAQ;IACLwB,WAAW,EAAEA,WAAY;IACzBmF,MAAM,EAAEpD,kBAAmB;IAC3BqD,QAAQ,EAAEtB,YAAa;IACvBmB,OAAO,EAAEjD,mBAAoB;IAC7BxB,QAAQ,EAAEyB,YAAa;IACvBxB,WAAW,EAAEA,WAAY;IACzBK,GAAG,EAAEa,WAAY;IACjBjB,mBAAmB,EAAEA,mBAAoB;IACzC2E,kBAAkB;IAClBnE,IAAI,EAAEA;EAAK,CACd,CAAC,EACDwD,OACe,CAAC;AAE7B,CACJ,CAAC;AAED/E,mBAAmB,CAAC2F,WAAW,GAAG,qBAAqB;AAEvD,eAAe3F,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PersonFinderWrapper.js","names":["DropdownBodyWrapper","Icon","TagInput","useDevice","React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","v4","uuidV4","PersonFinderFilterTypes","Priority","RelationMode","StyledPersonFinder","StyledPersonFinderLeftElement","PersonFinderBody","usePersonFinder","PersonFinderWrapper","container","dropdownDirection","filterTypes","friendsPriority","leftElement","leftElementProp","maxEntries","Infinity","onAdd","onDropdownHide","onDropdownShow","shouldDisableRemove","onRemove","placeholder","shouldAllowMultiple","shouldHideResultsOnAdd","shouldRenderInline","relationMode","ref","data","updateSearch","setTags","tags","search","isFocused","setIsFocused","shouldShowBody","setShouldShowBody","boxRef","contentRef","keyRef","tagInputRef","hasFocusRef","isTouch","createElement","icons","handleTagInputBlur","current","handleTagInputFocus","handleRemove","id","prevState","filter","entry","handleClose","handleOpen","handleClear","resetValue","handleDropdownOutsideClick","blur","handleAdd","selectedEntry","Object","values","flat","map","entries","find","toString","name","firstName","lastName","tag","text","some","t","length","handleChange","event","target","value","clear","showBody","check","SITE","includes","PERSON","HIGH","content","body","anchorElement","direction","onClose","onOutsideClick","shouldShowDropdown","onFocus","key","onBlur","onChange","shouldPreventEnter","displayName"],"sources":["../../../../../src/components/person-finder/person-finder-wrapper/PersonFinderWrapper.tsx"],"sourcesContent":["import {\n DropdownBodyWrapper,\n DropdownDirection,\n Icon,\n type Tag,\n TagInput,\n type TagInputRef,\n} from '@chayns-components/core';\nimport { useDevice } from 'chayns-api';\nimport React, {\n type ChangeEvent,\n forwardRef,\n type ReactElement,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { v4 as uuidV4 } from 'uuid';\nimport {\n PersonEntry,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n Priority,\n RelationMode,\n SiteEntry,\n} from '../../../types/personFinder';\nimport { StyledPersonFinder, StyledPersonFinderLeftElement } from './PersonFinderWrapper.styles';\nimport PersonFinderBody from './person-finder-body/PersonFinderBody';\nimport { usePersonFinder } from '../../PersonFinderProvider';\n\nexport type PersonFinderRef = {\n clear: () => void;\n};\n\nexport type PersonFinderWrapperProps = {\n /**\n * The element where the content of the `PersonFinder` should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The direction in which the dropdown should be displayed. By default, it is displayed below the input.\n */\n dropdownDirection?: DropdownDirection;\n /**\n * The filter options of the component.\n */\n filterTypes?: PersonFinderFilterTypes[];\n /**\n * Determines the priority level for displaying friends in search results.\n */\n friendsPriority?: Priority;\n /**\n * An element that should be displayed on the left side of the input.\n */\n leftElement?: ReactElement;\n /**\n * The maximum number of entries that can be selected.\n */\n maxEntries?: number;\n /**\n * Function to be executed if a person or site is added.\n */\n onAdd?: (entry: PersonFinderEntry) => void;\n /**\n * Function to be executed if the dropdown is hidden.\n */\n onDropdownHide?: () => void;\n /**\n * Function to be executed if the dropdown is shown.\n */\n onDropdownShow?: () => void;\n /**\n * Function to be executed if a person or site is removed.\n */\n onRemove?: (id: PersonFinderEntry['id']) => void;\n /**\n * The placeholder that should be displayed.\n */\n placeholder?: string;\n /**\n * Whether multiple persons and sites should be selected.\n */\n shouldAllowMultiple?: boolean;\n /**\n * Whether the dropdown should be hidden after adding an entry. By default, it is not hidden.\n */\n shouldHideResultsOnAdd?: boolean;\n /**\n * Whether the `PersonFinder` should be rendered inline without a dropdown.\n * @description\n * If set to `true`, the `PersonFinder` will display the results below the input field, without\n * using a dropdown. This is useful for scenarios where the `PersonFinder` is part of a larger\n * form and should always be visible.\n * @default false\n * @example\n * <PersonFinder shouldRenderInline />\n * @optional\n */\n shouldRenderInline?: boolean;\n /**\n * Whether the remove action should be disabled.\n */\n shouldDisableRemove?: boolean;\n /**\n * Determines whether persons are searched and sorted from the user's perspective or from a site's perspective.\n */\n relationMode?: RelationMode;\n};\n\nconst PersonFinderWrapper = forwardRef<PersonFinderRef, PersonFinderWrapperProps>(\n (\n {\n container,\n dropdownDirection,\n filterTypes,\n friendsPriority,\n leftElement: leftElementProp,\n maxEntries = Infinity,\n onAdd,\n onDropdownHide,\n onDropdownShow,\n shouldDisableRemove,\n onRemove,\n placeholder,\n shouldAllowMultiple,\n shouldHideResultsOnAdd,\n shouldRenderInline,\n relationMode,\n },\n ref,\n ) => {\n const { data, updateSearch, setTags, tags, search } = usePersonFinder();\n\n const [isFocused, setIsFocused] = useState(false);\n const [shouldShowBody, setShouldShowBody] = useState(false);\n\n const boxRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const keyRef = useRef(`person-finder-${uuidV4()}`);\n const tagInputRef = useRef<TagInputRef>(null);\n const hasFocusRef = useRef<boolean>(false);\n\n const { isTouch } = useDevice();\n\n const leftElement = leftElementProp ?? (\n <StyledPersonFinderLeftElement>\n <Icon icons={['fa fa-search']} />\n </StyledPersonFinderLeftElement>\n );\n\n const handleTagInputBlur = useCallback(() => {\n hasFocusRef.current = false;\n\n setIsFocused(false);\n }, []);\n\n const handleTagInputFocus = useCallback(() => {\n hasFocusRef.current = true;\n\n setIsFocused(true);\n }, []);\n\n const handleRemove = useCallback(\n (id: string) => {\n if (typeof setTags !== 'function' || shouldDisableRemove) {\n return;\n }\n\n setTags((prevState) => prevState.filter((entry) => entry.id !== id));\n\n if (typeof onRemove === 'function') {\n onRemove(id);\n }\n },\n [onRemove, setTags, shouldDisableRemove],\n );\n\n const handleClose = useCallback(() => {\n setShouldShowBody(false);\n }, []);\n\n const handleOpen = useCallback(() => {\n setShouldShowBody(true);\n }, []);\n\n const handleClear = useCallback(() => {\n if (typeof setTags !== 'function' || shouldDisableRemove) {\n return;\n }\n\n tagInputRef.current?.resetValue();\n\n setTags([]);\n }, [setTags, shouldDisableRemove]);\n\n const handleDropdownOutsideClick = useCallback(() => {\n tagInputRef.current?.blur();\n\n return hasFocusRef.current && isTouch;\n }, [isTouch]);\n\n const handleAdd = useCallback(\n (id: string) => {\n if (typeof setTags !== 'function') {\n return;\n }\n\n const selectedEntry = Object.values(data ?? {})\n .flat()\n .map(({ entries }) => entries)\n .flat()\n .find(\n (entry) =>\n (typeof entry.id === 'string' ? entry.id : entry.id.toString()) === id,\n );\n\n if (!selectedEntry) {\n return;\n }\n\n const { name, firstName, lastName } = selectedEntry as PersonEntry & SiteEntry;\n\n const tag: Tag = {\n id,\n text: name ?? `${(firstName as string) ?? ''} ${(lastName as string) ?? ''}`,\n };\n\n setTags((prevState) => {\n if (prevState.some((t) => t.id === id) || prevState.length >= maxEntries) {\n return prevState;\n }\n\n tagInputRef.current?.resetValue();\n\n if (typeof onAdd === 'function') {\n onAdd(selectedEntry);\n }\n\n if (shouldHideResultsOnAdd) {\n setShouldShowBody(false);\n }\n\n return [...prevState, tag];\n });\n },\n [data, maxEntries, onAdd, setTags, shouldHideResultsOnAdd],\n );\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (typeof updateSearch === 'function') {\n updateSearch(event.target.value);\n }\n },\n [updateSearch],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n clear: () => handleClear(),\n }),\n [handleClear],\n );\n\n useEffect(() => {\n if (shouldShowBody) {\n if (typeof onDropdownShow === 'function') {\n onDropdownShow();\n }\n } else if (typeof onDropdownHide === 'function') {\n onDropdownHide();\n }\n }, [onDropdownHide, onDropdownShow, shouldShowBody]);\n\n const showBody = useMemo(() => {\n const check = shouldShowBody;\n\n if (relationMode === RelationMode.SITE) {\n return check;\n }\n\n if (\n filterTypes?.length === 1 &&\n (filterTypes.includes(PersonFinderFilterTypes.SITE) ||\n (filterTypes.includes(PersonFinderFilterTypes.PERSON) &&\n friendsPriority !== Priority.HIGH))\n ) {\n return check && !!search && search?.length > 2;\n }\n\n return check;\n }, [filterTypes, friendsPriority, search, shouldShowBody, relationMode]);\n\n const content = useMemo(() => {\n const body = (\n <PersonFinderBody\n filterTypes={filterTypes}\n onAdd={handleAdd}\n onRemove={handleRemove}\n ref={contentRef}\n shouldRenderInline={shouldRenderInline}\n />\n );\n\n if (shouldRenderInline) {\n return body;\n }\n\n if (boxRef.current) {\n return (\n <DropdownBodyWrapper\n anchorElement={boxRef.current}\n container={container}\n direction={dropdownDirection}\n onClose={handleClose}\n onOutsideClick={handleDropdownOutsideClick}\n shouldShowDropdown={showBody}\n >\n {body}\n </DropdownBodyWrapper>\n );\n }\n\n return null;\n }, [\n container,\n dropdownDirection,\n filterTypes,\n handleAdd,\n handleClose,\n handleDropdownOutsideClick,\n handleRemove,\n shouldRenderInline,\n showBody,\n ]);\n\n return (\n <StyledPersonFinder ref={boxRef} onFocus={handleOpen} key={keyRef.current}>\n <TagInput\n leftElement={leftElement}\n onBlur={handleTagInputBlur}\n onChange={handleChange}\n onFocus={handleTagInputFocus}\n onRemove={handleRemove}\n placeholder={placeholder}\n ref={tagInputRef}\n shouldAllowMultiple={shouldAllowMultiple}\n shouldPreventEnter\n tags={tags}\n />\n {content}\n </StyledPersonFinder>\n );\n },\n);\n\nPersonFinderWrapper.displayName = 'PersonFinderWrapper';\n\nexport default PersonFinderWrapper;\n"],"mappings":"AAAA,SACIA,mBAAmB,EAEnBC,IAAI,EAEJC,QAAQ,QAEL,yBAAyB;AAChC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W,EACXI,0BAA0B,EAC1BT,YAAY,EACZvB,kBAAkB,EAClBwD,QAAQ,CACX,CAAC;EAEF,oBACI1F,KAAA,CAAAoD,aAAA,CAACvC,kBAAkB;IAACuB,GAAG,EAAEU,MAAO;IAACyD,OAAO,EAAExC,UAAW;IAACyC,GAAG,EAAExD,MAAM,CAACO;EAAQ,gBACtEvD,KAAA,CAAAoD,aAAA,CAACtD,QAAQ;IACLwB,WAAW,EAAEA,WAAY;IACzBmF,MAAM,EAAEnD,kBAAmB;IAC3BoD,QAAQ,EAAErB,YAAa;IACvBkB,OAAO,EAAE/C,mBAAoB;IAC7B1B,QAAQ,EAAE2B,YAAa;IACvB1B,WAAW,EAAEA,WAAY;IACzBK,GAAG,EAAEa,WAAY;IACjBjB,mBAAmB,EAAEA,mBAAoB;IACzC2E,kBAAkB;IAClBnE,IAAI,EAAEA;EAAK,CACd,CAAC,EACDwD,OACe,CAAC;AAE7B,CACJ,CAAC;AAED/E,mBAAmB,CAAC2F,WAAW,GAAG,qBAAqB;AAEvD,eAAe3F,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","names":["QA_RELATIONS_BASE_URL","RELATIONS_BASE_URL"],"sources":["../../../src/constants/url.ts"],"sourcesContent":["export const QA_RELATIONS_BASE_URL = 'https://cube-dev.tobit.com/relations-gateway/relations/';\nexport const RELATIONS_BASE_URL = 'https://relations.chayns.net/relations/';\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAAG,yDAAyD;AAC9F,OAAO,MAAMC,kBAAkB,GAAG,yCAAyC","ignoreList":[]}
|
|
@@ -98,7 +98,8 @@ export const loadData = async ({
|
|
|
98
98
|
skipMap,
|
|
99
99
|
searchString,
|
|
100
100
|
filter,
|
|
101
|
-
relationMode
|
|
101
|
+
relationMode,
|
|
102
|
+
shouldUseQa
|
|
102
103
|
}) => {
|
|
103
104
|
const promises = filter.map(async filterType => {
|
|
104
105
|
const skip = skipMap[filterType] ?? 0;
|
|
@@ -117,7 +118,8 @@ export const loadData = async ({
|
|
|
117
118
|
const data = await getPersons({
|
|
118
119
|
search: searchString,
|
|
119
120
|
skip,
|
|
120
|
-
relationMode
|
|
121
|
+
relationMode,
|
|
122
|
+
shouldUseQa
|
|
121
123
|
});
|
|
122
124
|
return {
|
|
123
125
|
key: PersonFinderFilterTypes.PERSON,
|
|
@@ -145,7 +147,8 @@ export const loadData = async ({
|
|
|
145
147
|
}
|
|
146
148
|
const data = await getSites({
|
|
147
149
|
search: searchString,
|
|
148
|
-
skip
|
|
150
|
+
skip,
|
|
151
|
+
shouldUseQa
|
|
149
152
|
});
|
|
150
153
|
const filteredList = data?.list.filter(({
|
|
151
154
|
siteId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"personFinder.js","names":["PersonFinderFilterTypes","RelationMode","getTextstringValue","ttsToITextString","getPersons","getSites","convertPersonEntry","convertSiteEntry","getUser","textStrings","PERSON_FINDER_TEXTSTRING_LIBRARY_NAME","normalizeTextstringReplacements","replacements","undefined","Object","entries","reduce","acc","key","value","toString","getPersonFinderTextstringValue","textstring","libraryName","getGroupName","groupNames","PERSON","components","personFinder","groupName","person","SITE","site","UAC","uac","isSiteEntry","entry","filterDataByKeys","data","keys","options","filterSingle","filteredEntries","excludedEntryIds","Array","isArray","length","filter","e","includes","id","excludedCount","count","Math","max","relevantKeys","original","searchString","skip","filteredEntry","shouldShowOwnUser","user","personId","ownUserEntry","commonSites","firstName","isVerified","lastName","type","fullName","Boolean","join","trim","toLowerCase","capitalizeFirstLetter","str","charAt","toUpperCase","slice","destructureData","filterType","loadData","skipMap","relationMode","promises","map","search","list","shouldShowLastOnlineTime","filteredList","siteId","results","Promise","all","item","formatLastOnline","date","ts","lastOnline","now","Date","diffMs","getTime","minutes","floor","hours","days","months","years","isSameDay","getDate","getMonth","getFullYear","yesterday","setDate","isYesterday","time","toLocaleTimeString","hour","minute","fewMinutes","today"],"sources":["../../../src/utils/personFinder.ts"],"sourcesContent":["import {\n PersonEntry,\n PersonFinderData,\n PersonFinderDataMap,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n RelationMode,\n SiteEntry,\n} from '../types/personFinder';\nimport { getTextstringValue, ttsToITextString } from '@chayns-components/textstring';\nimport { getPersons } from '../api/person/get';\nimport { getSites } from '../api/site/get';\nimport { convertPersonEntry, convertSiteEntry } from './convert';\nimport { getUser } from 'chayns-api';\nimport textStrings, { PERSON_FINDER_TEXTSTRING_LIBRARY_NAME } from '../constants/textStrings';\n\ninterface GetPersonFinderTextstringValueOptions {\n textstring: {\n stringName: string;\n fallback: string;\n };\n replacements?: Record<string, number | string | undefined>;\n}\n\nconst normalizeTextstringReplacements = (\n replacements?: GetPersonFinderTextstringValueOptions['replacements'],\n) => {\n if (!replacements) {\n return undefined;\n }\n\n return Object.entries(replacements).reduce<Record<string, string>>((acc, [key, value]) => {\n acc[`##${key}##`] = value?.toString() ?? '';\n\n return acc;\n }, {});\n};\n\nexport const getPersonFinderTextstringValue = ({\n textstring,\n replacements,\n}: GetPersonFinderTextstringValueOptions) =>\n getTextstringValue({\n libraryName: PERSON_FINDER_TEXTSTRING_LIBRARY_NAME,\n textstring: ttsToITextString(textstring),\n replacements: normalizeTextstringReplacements(replacements),\n });\n\nexport const getGroupName = (key: string) => {\n const groupNames: Partial<\n Record<PersonFinderFilterTypes, { stringName: string; fallback: string }>\n > = {\n [PersonFinderFilterTypes.PERSON]: textStrings.components.personFinder.groupName.person,\n [PersonFinderFilterTypes.SITE]: textStrings.components.personFinder.groupName.site,\n [PersonFinderFilterTypes.UAC]: textStrings.components.personFinder.groupName.uac,\n };\n\n const textstring = groupNames[key as PersonFinderFilterTypes];\n\n if (!textstring) {\n return key;\n }\n\n return getPersonFinderTextstringValue({ textstring });\n};\n\nexport const isSiteEntry = (entry: PersonEntry | SiteEntry): entry is SiteEntry =>\n 'name' in entry && !('firstName' in entry);\n\ninterface FilterDataByKeysOptions {\n excludedEntryIds?: PersonFinderEntry['id'][];\n shouldShowOwnUser?: boolean;\n}\n\nexport const filterDataByKeys = (\n data: { [key: string]: PersonFinderData } = {},\n keys: PersonFinderFilterTypes[] = [],\n options: FilterDataByKeysOptions = {},\n): { [key: string]: PersonFinderData } => {\n const filterSingle = (entry: PersonFinderData): PersonFinderData => {\n let filteredEntries = entry.entries;\n\n const { excludedEntryIds } = options;\n\n if (Array.isArray(excludedEntryIds) && excludedEntryIds.length > 0) {\n filteredEntries = filteredEntries.filter((e) => !excludedEntryIds.includes(e.id));\n }\n\n const excludedCount = entry.entries.length - filteredEntries.length;\n\n return {\n ...entry,\n entries: filteredEntries,\n count: Math.max(0, entry.count - excludedCount),\n };\n };\n\n const relevantKeys = keys.length > 0 ? keys : Object.keys(data);\n\n return relevantKeys.reduce((acc, key) => {\n const original = data[key] ?? { searchString: '', count: 0, skip: 0, entries: [] };\n\n const filteredEntry = filterSingle(original);\n\n if (options.shouldShowOwnUser && key === PersonFinderFilterTypes.PERSON) {\n const user = getUser();\n\n if (typeof user?.personId === 'string') {\n // Ensure that the own user is always included in the person filter\n const ownUserEntry: PersonEntry = {\n commonSites: 0,\n firstName: user.firstName ?? '',\n id: user.personId,\n isVerified: false,\n lastName: user.lastName ?? '',\n type: PersonFinderFilterTypes.PERSON,\n };\n\n const fullName = [ownUserEntry.firstName, ownUserEntry.lastName]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n if (\n original.searchString.length < 3 ||\n fullName.toLowerCase().includes(original.searchString.toLowerCase())\n ) {\n filteredEntry.entries = [ownUserEntry, ...filteredEntry.entries];\n filteredEntry.count += 1; // Increment count to account for the own user\n }\n }\n }\n\n return { ...acc, [key]: filteredEntry };\n }, {});\n};\n\nexport const capitalizeFirstLetter = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nexport const destructureData = (\n data: Record<string, PersonFinderData> | undefined,\n filterType: string,\n) => ({\n count: data?.[filterType]?.count ?? 0,\n skip: data?.[filterType]?.skip ?? 0,\n searchString: data?.[filterType]?.searchString ?? '',\n entries: data?.[filterType]?.entries ?? [],\n});\n\ninterface LoadDataOptions {\n searchString: string;\n filter: PersonFinderFilterTypes[];\n skipMap: Partial<Record<PersonFinderFilterTypes, number>>;\n relationMode?: RelationMode;\n}\n\nexport const loadData = async ({\n skipMap,\n searchString,\n filter,\n relationMode,\n}: LoadDataOptions): Promise<PersonFinderDataMap> => {\n const promises = filter.map(async (filterType) => {\n const skip = skipMap[filterType] ?? 0;\n\n if (filterType === PersonFinderFilterTypes.PERSON) {\n if (searchString.length <= 2) {\n return {\n key: PersonFinderFilterTypes.PERSON,\n value: {\n searchString,\n count: 0,\n skip: 0,\n entries: [],\n },\n };\n }\n\n const data = await getPersons({ search: searchString, skip, relationMode });\n\n return {\n key: PersonFinderFilterTypes.PERSON,\n value: {\n searchString,\n count: data?.count ?? 0,\n skip: skip + (data?.list?.length ?? 0),\n entries: convertPersonEntry(data?.list ?? [], {\n shouldShowLastOnlineTime: relationMode === RelationMode.SITE,\n }),\n },\n };\n }\n\n if (filterType === PersonFinderFilterTypes.SITE) {\n if (searchString.length <= 2) {\n return {\n key: PersonFinderFilterTypes.SITE,\n value: {\n searchString,\n count: 0,\n skip: 0,\n entries: [],\n },\n };\n }\n\n const data = await getSites({ search: searchString, skip });\n\n const filteredList = data?.list.filter(({ siteId }) => siteId !== null);\n\n return {\n key: PersonFinderFilterTypes.SITE,\n value: {\n searchString,\n count: data?.count ?? 0,\n skip: skip + (filteredList?.length ?? 0),\n entries: convertSiteEntry(filteredList ?? []),\n },\n };\n }\n\n return null;\n });\n\n const results = await Promise.all(promises);\n\n return results.reduce<PersonFinderDataMap>((acc, item) => {\n if (!item) return acc;\n\n return {\n ...acc,\n [item.key]: item.value,\n };\n }, {});\n};\n\nexport const formatLastOnline = (date: Date): string => {\n const ts = textStrings.components.personFinder.lastOnline;\n const now = new Date();\n\n const diffMs = now.getTime() - date.getTime();\n\n const minutes = Math.floor(diffMs / 1000 / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n const months = Math.floor(days / 30);\n const years = Math.floor(days / 365);\n\n const isSameDay =\n date.getDate() === now.getDate() &&\n date.getMonth() === now.getMonth() &&\n date.getFullYear() === now.getFullYear();\n\n const yesterday = new Date(now);\n yesterday.setDate(now.getDate() - 1);\n\n const isYesterday =\n date.getDate() === yesterday.getDate() &&\n date.getMonth() === yesterday.getMonth() &&\n date.getFullYear() === yesterday.getFullYear();\n\n const time = date.toLocaleTimeString('de-DE', {\n hour: '2-digit',\n minute: '2-digit',\n });\n\n if (minutes < 5) {\n return getPersonFinderTextstringValue({ textstring: ts.fewMinutes });\n }\n\n if (minutes < 60) {\n return getPersonFinderTextstringValue({\n textstring: ts.minutes,\n replacements: { minutes },\n });\n }\n\n if (hours < 24 && isSameDay) {\n return getPersonFinderTextstringValue({\n textstring: ts.today,\n replacements: { time },\n });\n }\n\n if (isYesterday) {\n return getPersonFinderTextstringValue({\n textstring: ts.yesterday,\n replacements: { time },\n });\n }\n\n if (days < 30) {\n return getPersonFinderTextstringValue({\n textstring: ts.days,\n replacements: { days },\n });\n }\n\n if (months < 12) {\n return getPersonFinderTextstringValue({\n textstring: ts.months,\n replacements: { months },\n });\n }\n\n return getPersonFinderTextstringValue({\n textstring: ts.years,\n replacements: { years },\n });\n};\n"],"mappings":"AAAA,SAKIA,uBAAuB,EACvBC,YAAY,QAET,uBAAuB;AAC9B,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,+BAA+B;AACpF,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,WAAW;AAChE,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,WAAW,IAAIC,qCAAqC,QAAQ,0BAA0B;AAU7F,MAAMC,+BAA+B,GACjCC,YAAoE,IACnE;EACD,IAAI,CAACA,YAAY,EAAE;IACf,OAAOC,SAAS;EACpB;EAEA,OAAOC,MAAM,CAACC,O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;IAAM;EAC1B,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"personFinder.js","names":["PersonFinderFilterTypes","RelationMode","getTextstringValue","ttsToITextString","getPersons","getSites","convertPersonEntry","convertSiteEntry","getUser","textStrings","PERSON_FINDER_TEXTSTRING_LIBRARY_NAME","normalizeTextstringReplacements","replacements","undefined","Object","entries","reduce","acc","key","value","toString","getPersonFinderTextstringValue","textstring","libraryName","getGroupName","groupNames","PERSON","components","personFinder","groupName","person","SITE","site","UAC","uac","isSiteEntry","entry","filterDataByKeys","data","keys","options","filterSingle","filteredEntries","excludedEntryIds","Array","isArray","length","filter","e","includes","id","excludedCount","count","Math","max","relevantKeys","original","searchString","skip","filteredEntry","shouldShowOwnUser","user","personId","ownUserEntry","commonSites","firstName","isVerified","lastName","type","fullName","Boolean","join","trim","toLowerCase","capitalizeFirstLetter","str","charAt","toUpperCase","slice","destructureData","filterType","loadData","skipMap","relationMode","shouldUseQa","promises","map","search","list","shouldShowLastOnlineTime","filteredList","siteId","results","Promise","all","item","formatLastOnline","date","ts","lastOnline","now","Date","diffMs","getTime","minutes","floor","hours","days","months","years","isSameDay","getDate","getMonth","getFullYear","yesterday","setDate","isYesterday","time","toLocaleTimeString","hour","minute","fewMinutes","today"],"sources":["../../../src/utils/personFinder.ts"],"sourcesContent":["import {\n PersonEntry,\n PersonFinderData,\n PersonFinderDataMap,\n PersonFinderEntry,\n PersonFinderFilterTypes,\n RelationMode,\n SiteEntry,\n} from '../types/personFinder';\nimport { getTextstringValue, ttsToITextString } from '@chayns-components/textstring';\nimport { getPersons } from '../api/person/get';\nimport { getSites } from '../api/site/get';\nimport { convertPersonEntry, convertSiteEntry } from './convert';\nimport { getUser } from 'chayns-api';\nimport textStrings, { PERSON_FINDER_TEXTSTRING_LIBRARY_NAME } from '../constants/textStrings';\n\ninterface GetPersonFinderTextstringValueOptions {\n textstring: {\n stringName: string;\n fallback: string;\n };\n replacements?: Record<string, number | string | undefined>;\n}\n\nconst normalizeTextstringReplacements = (\n replacements?: GetPersonFinderTextstringValueOptions['replacements'],\n) => {\n if (!replacements) {\n return undefined;\n }\n\n return Object.entries(replacements).reduce<Record<string, string>>((acc, [key, value]) => {\n acc[`##${key}##`] = value?.toString() ?? '';\n\n return acc;\n }, {});\n};\n\nexport const getPersonFinderTextstringValue = ({\n textstring,\n replacements,\n}: GetPersonFinderTextstringValueOptions) =>\n getTextstringValue({\n libraryName: PERSON_FINDER_TEXTSTRING_LIBRARY_NAME,\n textstring: ttsToITextString(textstring),\n replacements: normalizeTextstringReplacements(replacements),\n });\n\nexport const getGroupName = (key: string) => {\n const groupNames: Partial<\n Record<PersonFinderFilterTypes, { stringName: string; fallback: string }>\n > = {\n [PersonFinderFilterTypes.PERSON]: textStrings.components.personFinder.groupName.person,\n [PersonFinderFilterTypes.SITE]: textStrings.components.personFinder.groupName.site,\n [PersonFinderFilterTypes.UAC]: textStrings.components.personFinder.groupName.uac,\n };\n\n const textstring = groupNames[key as PersonFinderFilterTypes];\n\n if (!textstring) {\n return key;\n }\n\n return getPersonFinderTextstringValue({ textstring });\n};\n\nexport const isSiteEntry = (entry: PersonEntry | SiteEntry): entry is SiteEntry =>\n 'name' in entry && !('firstName' in entry);\n\ninterface FilterDataByKeysOptions {\n excludedEntryIds?: PersonFinderEntry['id'][];\n shouldShowOwnUser?: boolean;\n}\n\nexport const filterDataByKeys = (\n data: { [key: string]: PersonFinderData } = {},\n keys: PersonFinderFilterTypes[] = [],\n options: FilterDataByKeysOptions = {},\n): { [key: string]: PersonFinderData } => {\n const filterSingle = (entry: PersonFinderData): PersonFinderData => {\n let filteredEntries = entry.entries;\n\n const { excludedEntryIds } = options;\n\n if (Array.isArray(excludedEntryIds) && excludedEntryIds.length > 0) {\n filteredEntries = filteredEntries.filter((e) => !excludedEntryIds.includes(e.id));\n }\n\n const excludedCount = entry.entries.length - filteredEntries.length;\n\n return {\n ...entry,\n entries: filteredEntries,\n count: Math.max(0, entry.count - excludedCount),\n };\n };\n\n const relevantKeys = keys.length > 0 ? keys : Object.keys(data);\n\n return relevantKeys.reduce((acc, key) => {\n const original = data[key] ?? { searchString: '', count: 0, skip: 0, entries: [] };\n\n const filteredEntry = filterSingle(original);\n\n if (options.shouldShowOwnUser && key === PersonFinderFilterTypes.PERSON) {\n const user = getUser();\n\n if (typeof user?.personId === 'string') {\n // Ensure that the own user is always included in the person filter\n const ownUserEntry: PersonEntry = {\n commonSites: 0,\n firstName: user.firstName ?? '',\n id: user.personId,\n isVerified: false,\n lastName: user.lastName ?? '',\n type: PersonFinderFilterTypes.PERSON,\n };\n\n const fullName = [ownUserEntry.firstName, ownUserEntry.lastName]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n if (\n original.searchString.length < 3 ||\n fullName.toLowerCase().includes(original.searchString.toLowerCase())\n ) {\n filteredEntry.entries = [ownUserEntry, ...filteredEntry.entries];\n filteredEntry.count += 1; // Increment count to account for the own user\n }\n }\n }\n\n return { ...acc, [key]: filteredEntry };\n }, {});\n};\n\nexport const capitalizeFirstLetter = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nexport const destructureData = (\n data: Record<string, PersonFinderData> | undefined,\n filterType: string,\n) => ({\n count: data?.[filterType]?.count ?? 0,\n skip: data?.[filterType]?.skip ?? 0,\n searchString: data?.[filterType]?.searchString ?? '',\n entries: data?.[filterType]?.entries ?? [],\n});\n\ninterface LoadDataOptions {\n searchString: string;\n filter: PersonFinderFilterTypes[];\n skipMap: Partial<Record<PersonFinderFilterTypes, number>>;\n relationMode?: RelationMode;\n shouldUseQa: boolean;\n}\n\nexport const loadData = async ({\n skipMap,\n searchString,\n filter,\n relationMode,\n shouldUseQa,\n}: LoadDataOptions): Promise<PersonFinderDataMap> => {\n const promises = filter.map(async (filterType) => {\n const skip = skipMap[filterType] ?? 0;\n\n if (filterType === PersonFinderFilterTypes.PERSON) {\n if (searchString.length <= 2) {\n return {\n key: PersonFinderFilterTypes.PERSON,\n value: {\n searchString,\n count: 0,\n skip: 0,\n entries: [],\n },\n };\n }\n\n const data = await getPersons({\n search: searchString,\n skip,\n relationMode,\n shouldUseQa,\n });\n\n return {\n key: PersonFinderFilterTypes.PERSON,\n value: {\n searchString,\n count: data?.count ?? 0,\n skip: skip + (data?.list?.length ?? 0),\n entries: convertPersonEntry(data?.list ?? [], {\n shouldShowLastOnlineTime: relationMode === RelationMode.SITE,\n }),\n },\n };\n }\n\n if (filterType === PersonFinderFilterTypes.SITE) {\n if (searchString.length <= 2) {\n return {\n key: PersonFinderFilterTypes.SITE,\n value: {\n searchString,\n count: 0,\n skip: 0,\n entries: [],\n },\n };\n }\n\n const data = await getSites({ search: searchString, skip, shouldUseQa });\n\n const filteredList = data?.list.filter(({ siteId }) => siteId !== null);\n\n return {\n key: PersonFinderFilterTypes.SITE,\n value: {\n searchString,\n count: data?.count ?? 0,\n skip: skip + (filteredList?.length ?? 0),\n entries: convertSiteEntry(filteredList ?? []),\n },\n };\n }\n\n return null;\n });\n\n const results = await Promise.all(promises);\n\n return results.reduce<PersonFinderDataMap>((acc, item) => {\n if (!item) return acc;\n\n return {\n ...acc,\n [item.key]: item.value,\n };\n }, {});\n};\n\nexport const formatLastOnline = (date: Date): string => {\n const ts = textStrings.components.personFinder.lastOnline;\n const now = new Date();\n\n const diffMs = now.getTime() - date.getTime();\n\n const minutes = Math.floor(diffMs / 1000 / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n const months = Math.floor(days / 30);\n const years = Math.floor(days / 365);\n\n const isSameDay =\n date.getDate() === now.getDate() &&\n date.getMonth() === now.getMonth() &&\n date.getFullYear() === now.getFullYear();\n\n const yesterday = new Date(now);\n yesterday.setDate(now.getDate() - 1);\n\n const isYesterday =\n date.getDate() === yesterday.getDate() &&\n date.getMonth() === yesterday.getMonth() &&\n date.getFullYear() === yesterday.getFullYear();\n\n const time = date.toLocaleTimeString('de-DE', {\n hour: '2-digit',\n minute: '2-digit',\n });\n\n if (minutes < 5) {\n return getPersonFinderTextstringValue({ textstring: ts.fewMinutes });\n }\n\n if (minutes < 60) {\n return getPersonFinderTextstringValue({\n textstring: ts.minutes,\n replacements: { minutes },\n });\n }\n\n if (hours < 24 && isSameDay) {\n return getPersonFinderTextstringValue({\n textstring: ts.today,\n replacements: { time },\n });\n }\n\n if (isYesterday) {\n return getPersonFinderTextstringValue({\n textstring: ts.yesterday,\n replacements: { time },\n });\n }\n\n if (days < 30) {\n return getPersonFinderTextstringValue({\n textstring: ts.days,\n replacements: { days },\n });\n }\n\n if (months < 12) {\n return getPersonFinderTextstringValue({\n textstring: ts.months,\n replacements: { months },\n });\n }\n\n return getPersonFinderTextstringValue({\n textstring: ts.years,\n replacements: { years },\n });\n};\n"],"mappings":"AAAA,SAKIA,uBAAuB,EACvBC,YAAY,QAET,uBAAuB;AAC9B,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,+BAA+B;AACpF,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,WAAW;AAChE,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,WAAW,IAAIC,qCAAqC,QAAQ,0BAA0B;AAU7F,MAAMC,+BAA+B,GACjCC,YAAoE,IACnE;EACD,IAAI,CAACA,YAAY,EAAE;IACf,OAAOC,SAAS;EACpB;EAEA,OAAOC,MAAM,CAACC,OAAO,CAACH,YAAY,CAAC,CAACI,MAAM,CAAyB,CAACC,GAAG,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IACtFF,GAAG,CAAC,KAAKC,GAAG,IAAI,CAAC,GAAGC,KAAK,EAAEC,QAAQ,CAAC,CAAC,IAAI,EAAE;IAE3C,OAAOH,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC;AAED,OAAO,MAAMI,8BAA8B,GAAGA,CAAC;EAC3CC,UAAU;EACVV;AACmC,CAAC,KACpCV,kBAAkB,CAAC;E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A,IAAIjB,OAAO,GAAG,EAAE,EAAE;IACd,OAAOnF,8BAA8B,CAAC;MAClCC,UAAU,EAAE4E,EAAE,CAACM,OAAO;MACtB5F,YAAY,EAAE;QAAE4F;MAAQ;IAC5B,CAAC,CAAC;EACN;EAEA,IAAIE,KAAK,GAAG,EAAE,IAAII,SAAS,EAAE;IACzB,OAAOzF,8BAA8B,CAAC;MAClCC,UAAU,EAAE4E,EAAE,CAACwB,KAAK;MACpB9G,YAAY,EAAE;QAAEyG;MAAK;IACzB,CAAC,CAAC;EACN;EAEA,IAAID,WAAW,EAAE;IACb,OAAO/F,8BAA8B,CAAC;MAClCC,UAAU,EAAE4E,EAAE,CAACgB,SAAS;MACxBtG,YAAY,EAAE;QAAEyG;MAAK;IACzB,CAAC,CAAC;EACN;EAEA,IAAIV,IAAI,GAAG,EAAE,EAAE;IACX,OAAOtF,8BAA8B,CAAC;MAClCC,UAAU,EAAE4E,EAAE,CAACS,IAAI;MACnB/F,YAAY,EAAE;QAAE+F;MAAK;IACzB,CAAC,CAAC;EACN;EAEA,IAAIC,MAAM,GAAG,EAAE,EAAE;IACb,OAAOvF,8BAA8B,CAAC;MAClCC,UAAU,EAAE4E,EAAE,CAACU,MAAM;MACrBhG,YAAY,EAAE;QAAEgG;MAAO;IAC3B,CAAC,CAAC;EACN;EAEA,OAAOvF,8BAA8B,CAAC;IAClCC,UAAU,EAAE4E,EAAE,CAACW,KAAK;IACpBjG,YAAY,EAAE;MAAEiG;IAAM;EAC1B,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ interface GetPersonsOptions {
|
|
|
8
8
|
skip: number;
|
|
9
9
|
take?: number;
|
|
10
10
|
relationMode?: RelationMode;
|
|
11
|
+
shouldUseQa: boolean;
|
|
11
12
|
}
|
|
12
|
-
export declare const getPersons: ({ search, skip, take, relationMode, }: GetPersonsOptions) => Promise<GetPersonResult | undefined>;
|
|
13
|
+
export declare const getPersons: ({ search, skip, take, relationMode, shouldUseQa, }: GetPersonsOptions) => Promise<GetPersonResult | undefined>;
|
|
13
14
|
export {};
|
|
@@ -7,6 +7,7 @@ interface GetSitesOptions {
|
|
|
7
7
|
search: string;
|
|
8
8
|
skip: number;
|
|
9
9
|
take?: number;
|
|
10
|
+
shouldUseQa: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare const getSites: ({ search, skip, take }: GetSitesOptions) => Promise<GetSiteResult | undefined>;
|
|
12
|
+
export declare const getSites: ({ search, skip, take, shouldUseQa }: GetSitesOptions) => Promise<GetSiteResult | undefined>;
|
|
12
13
|
export {};
|
|
@@ -32,6 +32,7 @@ type PersonFinderProviderProps = {
|
|
|
32
32
|
uacFilter?: UACFilter[];
|
|
33
33
|
entries?: PersonEntry[];
|
|
34
34
|
relationMode?: RelationMode;
|
|
35
|
+
shouldUseQa: boolean;
|
|
35
36
|
};
|
|
36
37
|
declare const PersonFinderProvider: FC<PersonFinderProviderProps>;
|
|
37
38
|
export default PersonFinderProvider;
|
|
@@ -14,6 +14,10 @@ export type PersonFinderProps = PersonFinderWrapperProps & {
|
|
|
14
14
|
* Whether the own user should be shown in the results. By default, it is not shown.
|
|
15
15
|
*/
|
|
16
16
|
shouldShowOwnUser?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the qa relations should be used.
|
|
19
|
+
*/
|
|
20
|
+
shouldUseQa?: boolean;
|
|
17
21
|
/**
|
|
18
22
|
* Optional filter to search member of uac group. Only works with groups of the current Site and if the user is manager.
|
|
19
23
|
*/
|
|
@@ -36,6 +40,10 @@ declare const PersonFinder: React.ForwardRefExoticComponent<PersonFinderWrapperP
|
|
|
36
40
|
* Whether the own user should be shown in the results. By default, it is not shown.
|
|
37
41
|
*/
|
|
38
42
|
shouldShowOwnUser?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the qa relations should be used.
|
|
45
|
+
*/
|
|
46
|
+
shouldUseQa?: boolean;
|
|
39
47
|
/**
|
|
40
48
|
* Optional filter to search member of uac group. Only works with groups of the current Site and if the user is manager.
|
|
41
49
|
*/
|
|
@@ -30,7 +30,8 @@ interface LoadDataOptions {
|
|
|
30
30
|
filter: PersonFinderFilterTypes[];
|
|
31
31
|
skipMap: Partial<Record<PersonFinderFilterTypes, number>>;
|
|
32
32
|
relationMode?: RelationMode;
|
|
33
|
+
shouldUseQa: boolean;
|
|
33
34
|
}
|
|
34
|
-
export declare const loadData: ({ skipMap, searchString, filter, relationMode, }: LoadDataOptions) => Promise<PersonFinderDataMap>;
|
|
35
|
+
export declare const loadData: ({ skipMap, searchString, filter, relationMode, shouldUseQa, }: LoadDataOptions) => Promise<PersonFinderDataMap>;
|
|
35
36
|
export declare const formatLastOnline: (date: Date) => string;
|
|
36
37
|
export {};
|