@npm_leadtech/legal-lib-components 7.23.51 → 7.25.0
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/images/componentsSvg/CloseIcon.d.ts +6 -0
- package/dist/images/componentsSvg/CloseIcon.js +2 -0
- package/dist/images/componentsSvg/CloseIcon.tsx +14 -0
- package/dist/images/svg/close-grey-24px.svg +3 -0
- package/dist/images/svg/search_24px.svg +3 -0
- package/dist/src/components/atoms/DropdownInput/DropdownInput.d.ts +1 -1
- package/dist/src/components/atoms/DropdownInput/DropdownInput.js +9 -7
- package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.js +52 -35
- package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.ts +52 -36
- package/dist/src/components/atoms/DropdownInput/DropdownInput.tsx +55 -51
- package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.d.ts +1 -0
- package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.ts +1 -0
- 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 +17 -0
- package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.ts +18 -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 +17 -29
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +4 -55
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +4 -55
- package/dist/src/components/molecules/SearchBar/SearchBar.tsx +31 -61
- package/dist/src/hooks/useSearchFunction.d.ts +10 -0
- package/dist/src/hooks/useSearchFunction.js +28 -0
- package/dist/src/hooks/useSearchFunction.tsx +63 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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,17 @@
|
|
|
1
|
+
import { device } from '../../../globalStyles/breakpoints';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const MobileSearchBarStyled = styled.div `
|
|
4
|
+
display: block;
|
|
5
|
+
width: 100%;
|
|
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,18 @@
|
|
|
1
|
+
import { device } from '../../../globalStyles/breakpoints'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
|
|
4
|
+
export const MobileSearchBarStyled = styled.div`
|
|
5
|
+
display: block;
|
|
6
|
+
width: 100%;
|
|
7
|
+
|
|
8
|
+
@media ${device['landscape-tablets']} {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.dropdown_input {
|
|
13
|
+
.search {
|
|
14
|
+
width: calc(100% - 3rem);
|
|
15
|
+
margin: 0 1.5rem;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|
|
@@ -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';
|
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
4
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
2
5
|
import { useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useWindowSize } from '../../../hooks/useWindowSize';
|
|
6
|
+
import { DesktopSearchBar } from '../DesktopSearchBar';
|
|
7
|
+
import { MobileSearchBar } from '../MobileSearchBar';
|
|
6
8
|
import { SearchBarStyled } from './SearchBar.styled';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const postMatch = product.slice(product.toLowerCase().indexOf(searchTerm) + searchTerm.length, product.length);
|
|
20
|
-
const link = item.categoryUrl ? `${item.categoryUrl}/${item.slug}` : item.slug;
|
|
21
|
-
return (_jsx("li", { className: 'dropdown_input__item', children: _jsxs("a", { href: routes.CUSTOM_URL_FROM_TARGET_ADDRESS(link), className: 'dropdown_input__link', onClick: (e) => {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
handleResultClick(product, routes.CUSTOM_URL_FROM_TARGET_ADDRESS(link));
|
|
24
|
-
}, title: product, children: [preMatch, _jsx("strong", { className: 'dropdown_input__link__emphasis', children: match }), postMatch] }, item.linkText) }, searchBarTexts.title));
|
|
25
|
-
})
|
|
26
|
-
.slice(0, 9);
|
|
27
|
-
results.push(_jsx("li", { className: 'dropdown_input__item', children: _jsx("a", { className: 'dropdown_input__link--all', title: searchBarTexts.title, href: routes.LEGAL_DOCUMENTS, children: searchBarTexts.title }) }, searchBarTexts.title));
|
|
28
|
-
setResults(results);
|
|
29
|
-
};
|
|
30
|
-
return (_jsx(SearchBarStyled, { children: _jsx(DropdownInput, { name: 'search', className: 'search', placeholder: _placeholder, icon: _jsx(SearchIcon, {}), onChange: (text) => {
|
|
31
|
-
searchFunction(text);
|
|
32
|
-
}, results: results }) }));
|
|
9
|
+
import search from '../../../../images/svg/search_24px.svg';
|
|
10
|
+
export const SearchBar = (props) => {
|
|
11
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
12
|
+
const closeModal = () => setIsModalOpen(false);
|
|
13
|
+
return (_jsx(SearchBarStyled, { children: _jsxs("div", { style: { position: 'relative', display: 'flex' }, children: [_jsx("a", { onClick: () => setIsModalOpen(true), style: {
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
width: '20px',
|
|
16
|
+
height: '20px'
|
|
17
|
+
}, className: 'search-icon-container', children: _jsx("img", { src: search, alt: 'search-icon-primary', style: {
|
|
18
|
+
width: '100%',
|
|
19
|
+
height: '100%'
|
|
20
|
+
} }) }), _jsx(DesktopSearchBar, { ...props, isOpen: isModalOpen, onClose: closeModal }), _jsx(MobileSearchBar, { ...props })] }) }));
|
|
33
21
|
};
|
|
@@ -1,62 +1,11 @@
|
|
|
1
1
|
import { device } from '../../../globalStyles/breakpoints';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
export const SearchBarStyled = styled.div `
|
|
4
|
-
.
|
|
5
|
-
|
|
6
|
-
width: calc(100% - 3rem);
|
|
7
|
-
margin: 0 1.5rem;
|
|
4
|
+
.search-icon-container {
|
|
5
|
+
display: none;
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@media ${device['landscape-tablets']} {
|
|
14
|
-
display: block;
|
|
15
|
-
width: 10rem;
|
|
16
|
-
margin: 0 1.5rem 0 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@media ${device['desktop']} {
|
|
20
|
-
width: 14rem;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.dropdown_input__results {
|
|
24
|
-
transition: all 0.25s;
|
|
25
|
-
min-width: 100%;
|
|
26
|
-
width: max-content;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.dropdown_input__link {
|
|
30
|
-
color: var(--neutral-neutral-3);
|
|
31
|
-
animation: newLine 0.5s;
|
|
32
|
-
|
|
33
|
-
&:hover {
|
|
34
|
-
color: var(--others-black);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&__emphasis {
|
|
38
|
-
font-style: normal;
|
|
39
|
-
font-weight: normal;
|
|
40
|
-
color: var(--others-black);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&--all {
|
|
44
|
-
font-weight: bold;
|
|
45
|
-
animation: none;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@keyframes newLine {
|
|
52
|
-
0% {
|
|
53
|
-
opacity: 0;
|
|
54
|
-
line-height: 0rem;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
100% {
|
|
58
|
-
opacity: 1;
|
|
59
|
-
line-height: 1.5rem;
|
|
7
|
+
@media ${device['landscape-tablets']} {
|
|
8
|
+
display: block;
|
|
60
9
|
}
|
|
61
10
|
}
|
|
62
11
|
`;
|
|
@@ -2,62 +2,11 @@ import { device } from '../../../globalStyles/breakpoints'
|
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
4
|
export const SearchBarStyled = styled.div`
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
width: calc(100% - 3rem);
|
|
8
|
-
margin: 0 1.5rem;
|
|
5
|
+
.search-icon-container {
|
|
6
|
+
display: none;
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@media ${device['landscape-tablets']} {
|
|
15
|
-
display: block;
|
|
16
|
-
width: 10rem;
|
|
17
|
-
margin: 0 1.5rem 0 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@media ${device['desktop']} {
|
|
21
|
-
width: 14rem;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.dropdown_input__results {
|
|
25
|
-
transition: all 0.25s;
|
|
26
|
-
min-width: 100%;
|
|
27
|
-
width: max-content;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.dropdown_input__link {
|
|
31
|
-
color: var(--neutral-neutral-3);
|
|
32
|
-
animation: newLine 0.5s;
|
|
33
|
-
|
|
34
|
-
&:hover {
|
|
35
|
-
color: var(--others-black);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&__emphasis {
|
|
39
|
-
font-style: normal;
|
|
40
|
-
font-weight: normal;
|
|
41
|
-
color: var(--others-black);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&--all {
|
|
45
|
-
font-weight: bold;
|
|
46
|
-
animation: none;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@keyframes newLine {
|
|
53
|
-
0% {
|
|
54
|
-
opacity: 0;
|
|
55
|
-
line-height: 0rem;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
100% {
|
|
59
|
-
opacity: 1;
|
|
60
|
-
line-height: 1.5rem;
|
|
8
|
+
@media ${device['landscape-tablets']} {
|
|
9
|
+
display: block;
|
|
61
10
|
}
|
|
62
11
|
}
|
|
63
12
|
`
|