@npm_leadtech/legal-lib-components 7.23.5 → 7.23.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/atoms/DropdownInput/DropdownInput.d.ts +1 -1
- package/dist/src/components/atoms/DropdownInput/DropdownInput.js +7 -9
- package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.js +35 -52
- package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.ts +36 -52
- package/dist/src/components/atoms/DropdownInput/DropdownInput.tsx +51 -55
- package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.d.ts +0 -1
- package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.ts +0 -1
- package/dist/src/components/atoms/SearchSelect/SearchSelect.js +3 -2
- package/dist/src/components/atoms/SearchSelect/SearchSelect.tsx +3 -1
- package/dist/src/components/molecules/SearchBar/SearchBar.js +29 -17
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +55 -4
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +55 -4
- package/dist/src/components/molecules/SearchBar/SearchBar.tsx +61 -31
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/images/componentsSvg/CloseIcon.d.ts +0 -6
- package/dist/images/componentsSvg/CloseIcon.js +0 -2
- package/dist/images/componentsSvg/CloseIcon.tsx +0 -14
- package/dist/images/svg/close-grey-24px.svg +0 -3
- package/dist/images/svg/search_24px.svg +0 -3
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.d.ts +0 -8
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.js +0 -44
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.d.ts +0 -1
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.js +0 -48
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.ts +0 -49
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.tsx +0 -77
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.d.ts +0 -37
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.js +0 -1
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.ts +0 -40
- package/dist/src/components/molecules/DesktopSearchBar/index.d.ts +0 -2
- package/dist/src/components/molecules/DesktopSearchBar/index.js +0 -1
- package/dist/src/components/molecules/DesktopSearchBar/index.ts +0 -2
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.d.ts +0 -3
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.js +0 -38
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.d.ts +0 -1
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.js +0 -17
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.ts +0 -18
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.tsx +0 -55
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.d.ts +0 -37
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.js +0 -1
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.ts +0 -40
- package/dist/src/components/molecules/MobileSearchBar/index.d.ts +0 -2
- package/dist/src/components/molecules/MobileSearchBar/index.js +0 -1
- package/dist/src/components/molecules/MobileSearchBar/index.ts +0 -2
- package/dist/src/hooks/useSearchFunction.d.ts +0 -10
- package/dist/src/hooks/useSearchFunction.js +0 -28
- package/dist/src/hooks/useSearchFunction.tsx +0 -63
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { type SearchBarProps } from '../components/molecules/SearchBar/SearchBarProps.types'
|
|
3
|
-
|
|
4
|
-
interface SearchFunctionProps extends SearchBarProps {
|
|
5
|
-
onClose?: () => void
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const useSearchFunction = (props: SearchFunctionProps) => {
|
|
9
|
-
const [results, setResults] = useState<React.JSX.Element[]>([])
|
|
10
|
-
|
|
11
|
-
const searchFunction = (text: string): void => {
|
|
12
|
-
const { products, searchBarTexts, routes, handleResultClick, onClose } = props
|
|
13
|
-
const searchTerm = text.toLowerCase()
|
|
14
|
-
|
|
15
|
-
const productsFiltered = products.filter((item) => item.linkText.toLowerCase().includes(searchTerm))
|
|
16
|
-
|
|
17
|
-
const newResults = productsFiltered
|
|
18
|
-
.map((item) => {
|
|
19
|
-
const product = item.linkText
|
|
20
|
-
const preMatch = product.slice(0, product.toLowerCase().indexOf(searchTerm))
|
|
21
|
-
const match = product.slice(product.toLowerCase().indexOf(searchTerm), preMatch.length + searchTerm.length)
|
|
22
|
-
const postMatch = product.slice(product.toLowerCase().indexOf(searchTerm) + searchTerm.length, product.length)
|
|
23
|
-
const link = item.categoryUrl ? `${item.categoryUrl}/${item.slug}` : item.slug
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<li key={item.linkText} className='dropdown_input__item'>
|
|
27
|
-
<a
|
|
28
|
-
href={routes.CUSTOM_URL_FROM_TARGET_ADDRESS(link)}
|
|
29
|
-
className='dropdown_input__link'
|
|
30
|
-
onClick={(e) => {
|
|
31
|
-
e.preventDefault()
|
|
32
|
-
handleResultClick(product, routes.CUSTOM_URL_FROM_TARGET_ADDRESS(link))
|
|
33
|
-
if (onClose) onClose()
|
|
34
|
-
}}
|
|
35
|
-
title={product}
|
|
36
|
-
>
|
|
37
|
-
{preMatch}
|
|
38
|
-
<strong className='dropdown_input__link__emphasis'>{match}</strong>
|
|
39
|
-
{postMatch}
|
|
40
|
-
</a>
|
|
41
|
-
</li>
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
.slice(0, 9)
|
|
45
|
-
|
|
46
|
-
newResults.push(
|
|
47
|
-
<li key={searchBarTexts.title} className='dropdown_input__item'>
|
|
48
|
-
<a
|
|
49
|
-
className='dropdown_input__link--all'
|
|
50
|
-
title={searchBarTexts.title}
|
|
51
|
-
href={routes.LEGAL_DOCUMENTS}
|
|
52
|
-
onClick={onClose}
|
|
53
|
-
>
|
|
54
|
-
{searchBarTexts.title}
|
|
55
|
-
</a>
|
|
56
|
-
</li>
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
setResults(newResults)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return { results, searchFunction }
|
|
63
|
-
}
|