@npm_leadtech/legal-lib-components 7.22.8 → 7.22.9
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/molecules/DesktopSearchBar/DesktopSearchBar.d.ts +8 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.js +44 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.d.ts +1 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.js +48 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.ts +49 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.tsx +77 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.d.ts +37 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.js +1 -0
- package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.ts +40 -0
- package/dist/src/components/molecules/DesktopSearchBar/index.d.ts +2 -0
- package/dist/src/components/molecules/DesktopSearchBar/index.js +1 -0
- package/dist/src/components/molecules/DesktopSearchBar/index.ts +2 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.d.ts +3 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.js +38 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.d.ts +1 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.js +16 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.ts +17 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.tsx +55 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.d.ts +37 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.js +1 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.ts +40 -0
- package/dist/src/components/molecules/MobileSearchBar/index.d.ts +2 -0
- package/dist/src/components/molecules/MobileSearchBar/index.js +1 -0
- package/dist/src/components/molecules/MobileSearchBar/index.ts +2 -0
- package/dist/src/components/molecules/SearchBar/SearchBar.js +13 -92
- package/dist/src/components/molecules/SearchBar/SearchBar.tsx +28 -159
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.d.ts +0 -1
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +0 -54
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +0 -55
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SearchBarProps } from '../SearchBar/SearchBarProps.types';
|
|
3
|
+
interface DesktopSearchBarProps extends SearchBarProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const DesktopSearchBar: React.FC<DesktopSearchBarProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { CloseIcon } from '../../../../images/componentsSvg/CloseIcon';
|
|
4
|
+
import { DesktopSearchBarStyled } from './DesktopSearchBar.styled';
|
|
5
|
+
import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput';
|
|
6
|
+
import { useSearchFunction } from '../../../hooks/useSearchFunction';
|
|
7
|
+
export const DesktopSearchBar = ({ products, searchBarTexts, routes, handleResultClick, isOpen, onClose }) => {
|
|
8
|
+
const { results, searchFunction } = useSearchFunction({
|
|
9
|
+
products,
|
|
10
|
+
searchBarTexts,
|
|
11
|
+
routes,
|
|
12
|
+
handleResultClick,
|
|
13
|
+
onClose
|
|
14
|
+
});
|
|
15
|
+
const searchInputRef = useRef(null);
|
|
16
|
+
const searchBarContainerRef = useRef(null);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const handleKeyDown = (event) => {
|
|
19
|
+
if (event.key === 'Escape') {
|
|
20
|
+
onClose();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const handleClickOutside = (event) => {
|
|
24
|
+
if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target)) {
|
|
25
|
+
onClose();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
if (isOpen) {
|
|
29
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
30
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
31
|
+
if (searchInputRef.current) {
|
|
32
|
+
searchInputRef.current.focus();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return () => {
|
|
36
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
37
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
38
|
+
};
|
|
39
|
+
}, [isOpen, onClose]);
|
|
40
|
+
if (!isOpen) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return (_jsx(DesktopSearchBarStyled, { ref: searchBarContainerRef, className: 'modal_searchbar', children: _jsx("div", { className: 'modal_searchbar__content', children: _jsx(DropdownInput, { ref: searchInputRef, name: 'desktop-search', className: 'search', placeholder: searchBarTexts.placeholder, icon: _jsx(CloseIcon, {}), onChange: searchFunction, results: results, onClose: onClose }) }) }));
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DesktopSearchBarStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { device } from '../../../globalStyles/breakpoints';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const DesktopSearchBarStyled = styled.div `
|
|
4
|
+
display: none;
|
|
5
|
+
|
|
6
|
+
@media ${device['landscape-tablets']} {
|
|
7
|
+
display: block;
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 45px;
|
|
10
|
+
left: 0;
|
|
11
|
+
z-index: 10000;
|
|
12
|
+
width: 400px;
|
|
13
|
+
max-width: 90vw;
|
|
14
|
+
background: transparent;
|
|
15
|
+
|
|
16
|
+
.modal_searchbar__content {
|
|
17
|
+
background-color: var(--others-white);
|
|
18
|
+
padding: 1.5rem;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
width: 100%;
|
|
21
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
22
|
+
|
|
23
|
+
@media ${device['laptop']} {
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.modal_searchbar__header {
|
|
29
|
+
display: flex;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
align-items: center;
|
|
32
|
+
margin-bottom: 1rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.modal_searchbar__title {
|
|
36
|
+
font-size: 1.5rem;
|
|
37
|
+
font-weight: bold;
|
|
38
|
+
color: var(--others-black);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dropdown_input {
|
|
42
|
+
.search {
|
|
43
|
+
width: 100%;
|
|
44
|
+
margin: 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { device } from '../../../globalStyles/breakpoints'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
|
|
4
|
+
export const DesktopSearchBarStyled = styled.div`
|
|
5
|
+
display: none;
|
|
6
|
+
|
|
7
|
+
@media ${device['landscape-tablets']} {
|
|
8
|
+
display: block;
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 45px;
|
|
11
|
+
left: 0;
|
|
12
|
+
z-index: 10000;
|
|
13
|
+
width: 400px;
|
|
14
|
+
max-width: 90vw;
|
|
15
|
+
background: transparent;
|
|
16
|
+
|
|
17
|
+
.modal_searchbar__content {
|
|
18
|
+
background-color: var(--others-white);
|
|
19
|
+
padding: 1.5rem;
|
|
20
|
+
border-radius: 8px;
|
|
21
|
+
width: 100%;
|
|
22
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
23
|
+
|
|
24
|
+
@media ${device['laptop']} {
|
|
25
|
+
padding: 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.modal_searchbar__header {
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
align-items: center;
|
|
33
|
+
margin-bottom: 1rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.modal_searchbar__title {
|
|
37
|
+
font-size: 1.5rem;
|
|
38
|
+
font-weight: bold;
|
|
39
|
+
color: var(--others-black);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.dropdown_input {
|
|
43
|
+
.search {
|
|
44
|
+
width: 100%;
|
|
45
|
+
margin: 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react'
|
|
2
|
+
import { CloseIcon } from '../../../../images/componentsSvg/CloseIcon'
|
|
3
|
+
import { DesktopSearchBarStyled } from './DesktopSearchBar.styled'
|
|
4
|
+
import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput'
|
|
5
|
+
import { type SearchBarProps } from '../SearchBar/SearchBarProps.types'
|
|
6
|
+
import { useSearchFunction } from '../../../hooks/useSearchFunction'
|
|
7
|
+
|
|
8
|
+
interface DesktopSearchBarProps extends SearchBarProps {
|
|
9
|
+
isOpen: boolean
|
|
10
|
+
onClose: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DesktopSearchBar: React.FC<DesktopSearchBarProps> = ({
|
|
14
|
+
products,
|
|
15
|
+
searchBarTexts,
|
|
16
|
+
routes,
|
|
17
|
+
handleResultClick,
|
|
18
|
+
isOpen,
|
|
19
|
+
onClose
|
|
20
|
+
}) => {
|
|
21
|
+
const { results, searchFunction } = useSearchFunction({
|
|
22
|
+
products,
|
|
23
|
+
searchBarTexts,
|
|
24
|
+
routes,
|
|
25
|
+
handleResultClick,
|
|
26
|
+
onClose
|
|
27
|
+
})
|
|
28
|
+
const searchInputRef = useRef<HTMLInputElement>(null)
|
|
29
|
+
const searchBarContainerRef = useRef<HTMLDivElement>(null)
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
33
|
+
if (event.key === 'Escape') {
|
|
34
|
+
onClose()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
38
|
+
if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target as Node)) {
|
|
39
|
+
onClose()
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isOpen) {
|
|
44
|
+
document.addEventListener('keydown', handleKeyDown)
|
|
45
|
+
document.addEventListener('mousedown', handleClickOutside)
|
|
46
|
+
if (searchInputRef.current) {
|
|
47
|
+
searchInputRef.current.focus()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
document.removeEventListener('keydown', handleKeyDown)
|
|
53
|
+
document.removeEventListener('mousedown', handleClickOutside)
|
|
54
|
+
}
|
|
55
|
+
}, [isOpen, onClose])
|
|
56
|
+
|
|
57
|
+
if (!isOpen) {
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<DesktopSearchBarStyled ref={searchBarContainerRef} className='modal_searchbar'>
|
|
63
|
+
<div className='modal_searchbar__content'>
|
|
64
|
+
<DropdownInput
|
|
65
|
+
ref={searchInputRef}
|
|
66
|
+
name='desktop-search'
|
|
67
|
+
className='search'
|
|
68
|
+
placeholder={searchBarTexts.placeholder}
|
|
69
|
+
icon={<CloseIcon />}
|
|
70
|
+
onChange={searchFunction}
|
|
71
|
+
results={results}
|
|
72
|
+
onClose={onClose}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
</DesktopSearchBarStyled>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface Products {
|
|
2
|
+
categoryUrl?: string;
|
|
3
|
+
isFeatured?: boolean;
|
|
4
|
+
popularOrder: number;
|
|
5
|
+
jumboTitle: string;
|
|
6
|
+
linkText: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
footerPopularDocument?: boolean;
|
|
9
|
+
logoImgBig?: string;
|
|
10
|
+
logoImgSmall?: string;
|
|
11
|
+
categoryProduct?: {
|
|
12
|
+
name: string;
|
|
13
|
+
icon: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface StrapiSearchBar {
|
|
17
|
+
title: string;
|
|
18
|
+
placeholder: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Routes {
|
|
21
|
+
CUSTOM_URL_FROM_APP_SUBDOMAIN: (url: string) => string;
|
|
22
|
+
CUSTOM_URL_FROM_TARGET_ADDRESS: (url: string) => string;
|
|
23
|
+
LEGAL_DOCUMENTS: string;
|
|
24
|
+
LEGAL_DOCUMENTS_WITH_HASH: (category: string) => string;
|
|
25
|
+
LEGAL_DOCUMENTS_WITH_CATEGORY: (category: string) => string;
|
|
26
|
+
LOGIN: string;
|
|
27
|
+
MY_DOCUMENTS: string;
|
|
28
|
+
REGISTER: string;
|
|
29
|
+
RATAFIA_LOGIN: string;
|
|
30
|
+
SIGN_EDITOR: string;
|
|
31
|
+
}
|
|
32
|
+
export interface DesktopSearchBarProps {
|
|
33
|
+
products: Products[];
|
|
34
|
+
searchBarTexts: StrapiSearchBar;
|
|
35
|
+
routes: Routes;
|
|
36
|
+
handleResultClick: (product: string, link: string) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Products {
|
|
2
|
+
categoryUrl?: string
|
|
3
|
+
isFeatured?: boolean
|
|
4
|
+
popularOrder: number
|
|
5
|
+
jumboTitle: string
|
|
6
|
+
linkText: string
|
|
7
|
+
slug: string
|
|
8
|
+
footerPopularDocument?: boolean
|
|
9
|
+
logoImgBig?: string
|
|
10
|
+
logoImgSmall?: string
|
|
11
|
+
categoryProduct?: {
|
|
12
|
+
name: string
|
|
13
|
+
icon: string
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface StrapiSearchBar {
|
|
18
|
+
title: string
|
|
19
|
+
placeholder: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Routes {
|
|
23
|
+
CUSTOM_URL_FROM_APP_SUBDOMAIN: (url: string) => string
|
|
24
|
+
CUSTOM_URL_FROM_TARGET_ADDRESS: (url: string) => string
|
|
25
|
+
LEGAL_DOCUMENTS: string
|
|
26
|
+
LEGAL_DOCUMENTS_WITH_HASH: (category: string) => string
|
|
27
|
+
LEGAL_DOCUMENTS_WITH_CATEGORY: (category: string) => string
|
|
28
|
+
LOGIN: string
|
|
29
|
+
MY_DOCUMENTS: string
|
|
30
|
+
REGISTER: string
|
|
31
|
+
RATAFIA_LOGIN: string
|
|
32
|
+
SIGN_EDITOR: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DesktopSearchBarProps {
|
|
36
|
+
products: Products[]
|
|
37
|
+
searchBarTexts: StrapiSearchBar
|
|
38
|
+
routes: Routes
|
|
39
|
+
handleResultClick: (product: string, link: string) => void
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DesktopSearchBar } from './DesktopSearchBar';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput';
|
|
4
|
+
import { MobileSearchBarStyled } from './MobileSearchBar.styled';
|
|
5
|
+
import { SearchIcon } from '../../../../images/componentsSvg/SearchIcon';
|
|
6
|
+
import { useSearchFunction } from '../../../hooks/useSearchFunction';
|
|
7
|
+
export const MobileSearchBar = ({ products, searchBarTexts, routes, handleResultClick }) => {
|
|
8
|
+
const { results, searchFunction } = useSearchFunction({
|
|
9
|
+
products,
|
|
10
|
+
searchBarTexts,
|
|
11
|
+
routes,
|
|
12
|
+
handleResultClick
|
|
13
|
+
});
|
|
14
|
+
const searchInputRef = useRef(null);
|
|
15
|
+
const searchBarContainerRef = useRef(null);
|
|
16
|
+
const isResultsVisible = Array.isArray(results) && results.length > 0;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const handleKeyDown = (event) => {
|
|
19
|
+
if (event.key === 'Escape') {
|
|
20
|
+
searchFunction('');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const handleClickOutside = (event) => {
|
|
24
|
+
if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target)) {
|
|
25
|
+
searchFunction('');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
if (isResultsVisible) {
|
|
29
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
30
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
34
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
35
|
+
};
|
|
36
|
+
}, [isResultsVisible, searchFunction]);
|
|
37
|
+
return (_jsx(MobileSearchBarStyled, { ref: searchBarContainerRef, children: _jsx(DropdownInput, { ref: searchInputRef, name: 'mobile-and-tablet-search', className: 'search', placeholder: searchBarTexts.placeholder, icon: _jsx(SearchIcon, {}), onChange: searchFunction, results: results }) }));
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MobileSearchBarStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { device } from '../../../globalStyles/breakpoints';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const MobileSearchBarStyled = styled.div `
|
|
4
|
+
display: block;
|
|
5
|
+
|
|
6
|
+
@media ${device['landscape-tablets']} {
|
|
7
|
+
display: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.dropdown_input {
|
|
11
|
+
.search {
|
|
12
|
+
width: calc(100% - 3rem);
|
|
13
|
+
margin: 0 1.5rem;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { device } from '../../../globalStyles/breakpoints'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
|
|
4
|
+
export const MobileSearchBarStyled = styled.div`
|
|
5
|
+
display: block;
|
|
6
|
+
|
|
7
|
+
@media ${device['landscape-tablets']} {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dropdown_input {
|
|
12
|
+
.search {
|
|
13
|
+
width: calc(100% - 3rem);
|
|
14
|
+
margin: 0 1.5rem;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react'
|
|
2
|
+
import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput'
|
|
3
|
+
import { MobileSearchBarStyled } from './MobileSearchBar.styled'
|
|
4
|
+
import { type SearchBarProps } from '../SearchBar/SearchBarProps.types'
|
|
5
|
+
import { SearchIcon } from '../../../../images/componentsSvg/SearchIcon'
|
|
6
|
+
import { useSearchFunction } from '../../../hooks/useSearchFunction'
|
|
7
|
+
|
|
8
|
+
export const MobileSearchBar: React.FC<SearchBarProps> = ({ products, searchBarTexts, routes, handleResultClick }) => {
|
|
9
|
+
const { results, searchFunction } = useSearchFunction({
|
|
10
|
+
products,
|
|
11
|
+
searchBarTexts,
|
|
12
|
+
routes,
|
|
13
|
+
handleResultClick
|
|
14
|
+
})
|
|
15
|
+
const searchInputRef = useRef<HTMLInputElement>(null)
|
|
16
|
+
const searchBarContainerRef = useRef<HTMLDivElement>(null)
|
|
17
|
+
const isResultsVisible = Array.isArray(results) && results.length > 0
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
21
|
+
if (event.key === 'Escape') {
|
|
22
|
+
searchFunction('')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
26
|
+
if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target as Node)) {
|
|
27
|
+
searchFunction('')
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isResultsVisible) {
|
|
32
|
+
document.addEventListener('keydown', handleKeyDown)
|
|
33
|
+
document.addEventListener('mousedown', handleClickOutside)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return () => {
|
|
37
|
+
document.removeEventListener('keydown', handleKeyDown)
|
|
38
|
+
document.removeEventListener('mousedown', handleClickOutside)
|
|
39
|
+
}
|
|
40
|
+
}, [isResultsVisible, searchFunction])
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<MobileSearchBarStyled ref={searchBarContainerRef}>
|
|
44
|
+
<DropdownInput
|
|
45
|
+
ref={searchInputRef}
|
|
46
|
+
name='mobile-and-tablet-search'
|
|
47
|
+
className='search'
|
|
48
|
+
placeholder={searchBarTexts.placeholder}
|
|
49
|
+
icon={<SearchIcon />}
|
|
50
|
+
onChange={searchFunction}
|
|
51
|
+
results={results}
|
|
52
|
+
/>
|
|
53
|
+
</MobileSearchBarStyled>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface Products {
|
|
2
|
+
categoryUrl?: string;
|
|
3
|
+
isFeatured?: boolean;
|
|
4
|
+
popularOrder: number;
|
|
5
|
+
jumboTitle: string;
|
|
6
|
+
linkText: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
footerPopularDocument?: boolean;
|
|
9
|
+
logoImgBig?: string;
|
|
10
|
+
logoImgSmall?: string;
|
|
11
|
+
categoryProduct?: {
|
|
12
|
+
name: string;
|
|
13
|
+
icon: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface StrapiSearchBar {
|
|
17
|
+
title: string;
|
|
18
|
+
placeholder: string;
|
|
19
|
+
}
|
|
20
|
+
export interface Routes {
|
|
21
|
+
CUSTOM_URL_FROM_APP_SUBDOMAIN: (url: string) => string;
|
|
22
|
+
CUSTOM_URL_FROM_TARGET_ADDRESS: (url: string) => string;
|
|
23
|
+
LEGAL_DOCUMENTS: string;
|
|
24
|
+
LEGAL_DOCUMENTS_WITH_HASH: (category: string) => string;
|
|
25
|
+
LEGAL_DOCUMENTS_WITH_CATEGORY: (category: string) => string;
|
|
26
|
+
LOGIN: string;
|
|
27
|
+
MY_DOCUMENTS: string;
|
|
28
|
+
REGISTER: string;
|
|
29
|
+
RATAFIA_LOGIN: string;
|
|
30
|
+
SIGN_EDITOR: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SearchBarProps {
|
|
33
|
+
products: Products[];
|
|
34
|
+
searchBarTexts: StrapiSearchBar;
|
|
35
|
+
routes: Routes;
|
|
36
|
+
handleResultClick: (product: string, link: string) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Products {
|
|
2
|
+
categoryUrl?: string
|
|
3
|
+
isFeatured?: boolean
|
|
4
|
+
popularOrder: number
|
|
5
|
+
jumboTitle: string
|
|
6
|
+
linkText: string
|
|
7
|
+
slug: string
|
|
8
|
+
footerPopularDocument?: boolean
|
|
9
|
+
logoImgBig?: string
|
|
10
|
+
logoImgSmall?: string
|
|
11
|
+
categoryProduct?: {
|
|
12
|
+
name: string
|
|
13
|
+
icon: string
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface StrapiSearchBar {
|
|
18
|
+
title: string
|
|
19
|
+
placeholder: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Routes {
|
|
23
|
+
CUSTOM_URL_FROM_APP_SUBDOMAIN: (url: string) => string
|
|
24
|
+
CUSTOM_URL_FROM_TARGET_ADDRESS: (url: string) => string
|
|
25
|
+
LEGAL_DOCUMENTS: string
|
|
26
|
+
LEGAL_DOCUMENTS_WITH_HASH: (category: string) => string
|
|
27
|
+
LEGAL_DOCUMENTS_WITH_CATEGORY: (category: string) => string
|
|
28
|
+
LOGIN: string
|
|
29
|
+
MY_DOCUMENTS: string
|
|
30
|
+
REGISTER: string
|
|
31
|
+
RATAFIA_LOGIN: string
|
|
32
|
+
SIGN_EDITOR: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SearchBarProps {
|
|
36
|
+
products: Products[]
|
|
37
|
+
searchBarTexts: StrapiSearchBar
|
|
38
|
+
routes: Routes
|
|
39
|
+
handleResultClick: (product: string, link: string) => void
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MobileSearchBar } from './MobileSearchBar';
|