@npm_leadtech/legal-lib-components 7.22.12 → 7.23.1

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.
Files changed (56) hide show
  1. package/dist/css/styles.css +0 -3
  2. package/dist/images/componentsSvg/CloseIcon.d.ts +6 -0
  3. package/dist/images/componentsSvg/CloseIcon.js +2 -0
  4. package/dist/images/componentsSvg/CloseIcon.tsx +14 -0
  5. package/dist/images/svg/close-grey-24px.svg +3 -0
  6. package/dist/images/svg/search_24px.svg +3 -0
  7. package/dist/src/components/atoms/DialogMenuIcon/DialogMenuIcon.styled.js +1 -1
  8. package/dist/src/components/atoms/DialogMenuIcon/DialogMenuIcon.styled.ts +1 -1
  9. package/dist/src/components/atoms/DropdownInput/DropdownInput.d.ts +1 -1
  10. package/dist/src/components/atoms/DropdownInput/DropdownInput.js +9 -7
  11. package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.js +48 -36
  12. package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.ts +48 -37
  13. package/dist/src/components/atoms/DropdownInput/DropdownInput.tsx +55 -51
  14. package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.d.ts +1 -0
  15. package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.ts +1 -0
  16. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.d.ts +8 -0
  17. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.js +44 -0
  18. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.d.ts +1 -0
  19. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.js +48 -0
  20. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.ts +49 -0
  21. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.tsx +77 -0
  22. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.d.ts +37 -0
  23. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.js +1 -0
  24. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.ts +40 -0
  25. package/dist/src/components/molecules/DesktopSearchBar/index.d.ts +2 -0
  26. package/dist/src/components/molecules/DesktopSearchBar/index.js +1 -0
  27. package/dist/src/components/molecules/DesktopSearchBar/index.ts +2 -0
  28. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.d.ts +3 -0
  29. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.js +38 -0
  30. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.d.ts +1 -0
  31. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.js +17 -0
  32. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.ts +18 -0
  33. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.tsx +55 -0
  34. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.d.ts +37 -0
  35. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.js +1 -0
  36. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.ts +40 -0
  37. package/dist/src/components/molecules/MobileSearchBar/index.d.ts +2 -0
  38. package/dist/src/components/molecules/MobileSearchBar/index.js +1 -0
  39. package/dist/src/components/molecules/MobileSearchBar/index.ts +2 -0
  40. package/dist/src/components/molecules/SearchBar/SearchBar.js +17 -29
  41. package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +4 -55
  42. package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +4 -55
  43. package/dist/src/components/molecules/SearchBar/SearchBar.tsx +31 -61
  44. package/dist/src/components/molecules/TextInput/Input.d.ts +0 -1
  45. package/dist/src/components/molecules/TextInput/Input.js +5 -4
  46. package/dist/src/components/molecules/TextInput/Input.tsx +7 -8
  47. package/dist/src/components/molecules/TextInput/TextInput.js +2 -2
  48. package/dist/src/components/molecules/TextInput/TextInput.scss +0 -4
  49. package/dist/src/components/molecules/TextInput/TextInput.tsx +1 -3
  50. package/dist/src/components/molecules/TextInput/TextInputProps.types.d.ts +0 -1
  51. package/dist/src/components/molecules/TextInput/TextInputProps.types.ts +0 -1
  52. package/dist/src/hooks/useSearchFunction.d.ts +10 -0
  53. package/dist/src/hooks/useSearchFunction.js +28 -0
  54. package/dist/src/hooks/useSearchFunction.tsx +63 -0
  55. package/dist/tsconfig.build.tsbuildinfo +1 -1
  56. package/package.json +1 -1
@@ -2165,9 +2165,6 @@ h2.react-datepicker__current-month {
2165
2165
  width: 50%;
2166
2166
  }
2167
2167
  }
2168
- .e-text--has-prefix .tooltip-form {
2169
- grid-row: 3;
2170
- }
2171
2168
  .e-text--has-prefix .has-currency-prefix {
2172
2169
  padding-left: 2rem;
2173
2170
  grid-column: 1;
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ interface Close24Props {
3
+ className?: string;
4
+ }
5
+ export declare const CloseIcon: FC<Close24Props>;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const CloseIcon = ({ className }) => (_jsx("svg", { className: className, width: 20, height: 20, viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', children: _jsx("path", { d: 'M15.2462 5.92913C15.5706 5.60466 15.5706 5.07859 15.2462 4.75413C14.9217 4.42966 14.3956 4.42966 14.0712 4.75413L10.0003 8.82496L5.92949 4.75413C5.60503 4.42966 5.07896 4.42966 4.75449 4.75413C4.43002 5.07859 4.43003 5.60466 4.75449 5.92913L8.82533 9.99996L4.75449 14.0708C4.43003 14.3953 4.43002 14.9213 4.75449 15.2458C5.07896 15.5703 5.60502 15.5703 5.92949 15.2458L10.0003 11.175L14.0712 15.2458C14.3956 15.5703 14.9217 15.5703 15.2462 15.2458C15.5706 14.9213 15.5706 14.3953 15.2462 14.0708L11.1753 9.99996L15.2462 5.92913Z', fill: '#B5BABD' }) }));
@@ -0,0 +1,14 @@
1
+ import React, { FC } from 'react'
2
+
3
+ interface Close24Props {
4
+ className?: string
5
+ }
6
+
7
+ export const CloseIcon: FC<Close24Props> = ({ className }: Close24Props): React.ReactElement => (
8
+ <svg className={className} width={20} height={20} viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'>
9
+ <path
10
+ d='M15.2462 5.92913C15.5706 5.60466 15.5706 5.07859 15.2462 4.75413C14.9217 4.42966 14.3956 4.42966 14.0712 4.75413L10.0003 8.82496L5.92949 4.75413C5.60503 4.42966 5.07896 4.42966 4.75449 4.75413C4.43002 5.07859 4.43003 5.60466 4.75449 5.92913L8.82533 9.99996L4.75449 14.0708C4.43003 14.3953 4.43002 14.9213 4.75449 15.2458C5.07896 15.5703 5.60502 15.5703 5.92949 15.2458L10.0003 11.175L14.0712 15.2458C14.3956 15.5703 14.9217 15.5703 15.2462 15.2458C15.5706 14.9213 15.5706 14.3953 15.2462 14.0708L11.1753 9.99996L15.2462 5.92913Z'
11
+ fill='#B5BABD'
12
+ />
13
+ </svg>
14
+ )
@@ -0,0 +1,3 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M15.2462 5.92913C15.5706 5.60466 15.5706 5.07859 15.2462 4.75413C14.9217 4.42966 14.3956 4.42966 14.0712 4.75413L10.0003 8.82496L5.92949 4.75413C5.60503 4.42966 5.07896 4.42966 4.75449 4.75413C4.43002 5.07859 4.43003 5.60466 4.75449 5.92913L8.82533 9.99996L4.75449 14.0708C4.43003 14.3953 4.43002 14.9213 4.75449 15.2458C5.07896 15.5703 5.60502 15.5703 5.92949 15.2458L10.0003 11.175L14.0712 15.2458C14.3956 15.5703 14.9217 15.5703 15.2462 15.2458C15.5706 14.9213 15.5706 14.3953 15.2462 14.0708L11.1753 9.99996L15.2462 5.92913Z" fill="#B5BABD"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M7.83105 13.9947C6.10828 13.9947 4.65024 13.3981 3.45694 12.2048C2.26364 11.0115 1.66699 9.55346 1.66699 7.83069C1.66699 6.10791 2.26364 4.64987 3.45694 3.45657C4.65024 2.26328 6.10828 1.66663 7.83105 1.66663C9.55383 1.66663 11.0119 2.26328 12.2052 3.45657C13.3985 4.64987 13.9951 6.10791 13.9951 7.83069C13.9951 8.52612 13.8845 9.18204 13.6632 9.79844C13.4419 10.4148 13.1416 10.9601 12.7623 11.4343L18.0729 16.7449C18.2467 16.9187 18.3337 17.14 18.3337 17.4087C18.3337 17.6774 18.2467 17.8986 18.0729 18.0725C17.899 18.2464 17.6777 18.3333 17.4091 18.3333C17.1404 18.3333 16.9191 18.2464 16.7452 18.0725L11.4347 12.7619C10.9605 13.1413 10.4152 13.4416 9.79881 13.6628C9.1824 13.8841 8.52648 13.9947 7.83105 13.9947ZM7.83105 12.0981C9.01645 12.0981 10.024 11.6832 10.8538 10.8534C11.6836 10.0237 12.0985 9.01608 12.0985 7.83069C12.0985 6.64529 11.6836 5.6377 10.8538 4.80793C10.024 3.97815 9.01645 3.56326 7.83105 3.56326C6.64566 3.56326 5.63807 3.97815 4.80829 4.80793C3.97851 5.6377 3.56363 6.64529 3.56363 7.83069C3.56363 9.01608 3.97851 10.0237 4.80829 10.8534C5.63807 11.6832 6.64566 12.0981 7.83105 12.0981Z" fill="#078080"/>
3
+ </svg>
@@ -26,7 +26,7 @@ export const DialogMenuIconStyled = styled.div `
26
26
  align-items: flex-start;
27
27
  justify-content: space-between;
28
28
  position: absolute;
29
- z-index: 2;
29
+ z-index: 1;
30
30
  top: 1.5rem;
31
31
  right: -5rem;
32
32
 
@@ -27,7 +27,7 @@ export const DialogMenuIconStyled = styled.div`
27
27
  align-items: flex-start;
28
28
  justify-content: space-between;
29
29
  position: absolute;
30
- z-index: 2;
30
+ z-index: 1;
31
31
  top: 1.5rem;
32
32
  right: -5rem;
33
33
 
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { DropdownInputProps } from './DropdownInputProps.types';
3
- export declare const DropdownInput: React.FC<DropdownInputProps>;
3
+ export declare const DropdownInput: React.ForwardRefExoticComponent<DropdownInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,8 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
2
3
  /* eslint-disable jsx-a11y/no-static-element-interactions */
3
- import React, { useState } from 'react';
4
+ import React, { forwardRef, useState } from 'react';
4
5
  import { DropdownInputStyled } from './DropdownInput.styled';
5
- export const DropdownInput = ({ onChange, results, className = '', name, icon, placeholder }) => {
6
+ export const DropdownInput = forwardRef(({ onChange, results, className = '', name, icon, placeholder, onClose }, ref) => {
6
7
  const [searchTerm, setSearchTerm] = useState('');
7
8
  const updateInput = (e) => {
8
9
  setSearchTerm(e.target.value);
@@ -11,14 +12,15 @@ export const DropdownInput = ({ onChange, results, className = '', name, icon, p
11
12
  const resetInput = () => {
12
13
  setSearchTerm('');
13
14
  };
14
- return (_jsxs(DropdownInputStyled, { className: `dropdown_input ${className}`, children: [_jsxs("div", { className: 'dropdown_input__container', children: [_jsx("input", { className: `dropdown_input__container__text_input ${icon ? 'with-icon' : ''}`, type: 'text', name: `dropdown_input_${name}`, placeholder: placeholder, value: searchTerm, onChange: (e) => {
15
+ return (_jsxs(DropdownInputStyled, { className: `dropdown_input ${className}`, children: [_jsxs("div", { className: 'dropdown_input__container', children: [_jsx("input", { ref: ref, className: `dropdown_input__container__text_input ${icon ? 'with-icon' : ''}`, type: 'text', name: `dropdown_input_${name}`, placeholder: placeholder, value: searchTerm, onChange: (e) => {
15
16
  updateInput(e);
16
- } }), _jsxs("div", { className: `dropdown_input__container__icon ${searchTerm ? 'active' : ''}`, children: [icon &&
17
+ } }), _jsxs("div", { className: `dropdown_input__container__icon ${searchTerm ? 'active' : ''}`, onClick: onClose, children: [icon &&
17
18
  React.cloneElement(icon, {
18
19
  className: 'dropdown_input__container__icon__main'
19
20
  }), searchTerm && (_jsx("div", { className: 'icon-cross main-color dropdown_input__container__icon__clear', onClick: () => {
20
21
  resetInput();
21
22
  }, onKeyDown: () => {
22
23
  resetInput();
23
- } }))] })] }), searchTerm && !!results?.length && _jsx("ul", { className: 'dropdown_input__results', children: results })] }));
24
- };
24
+ } }))] })] }), searchTerm && !!results?.length && (_jsxs(_Fragment, { children: [_jsx("div", { className: 'dropdown_input__separator' }), _jsx("ul", { className: 'dropdown_input__results', children: results })] }))] }));
25
+ });
26
+ DropdownInput.displayName = 'DropdownInput';
@@ -2,32 +2,14 @@ import { device } from '../../../globalStyles/breakpoints';
2
2
  import styled from 'styled-components';
3
3
  export const DropdownInputStyled = styled.div `
4
4
  position: relative;
5
- padding-left: 1.5rem;
6
- padding-right: 1.5rem;
5
+ padding: 1.5rem;
7
6
 
8
- a {
9
- text-decoration: none;
7
+ @media ${device['landscape-tablets']} {
8
+ padding: 16px 24px;
10
9
  }
11
10
 
12
- &:focus-within {
13
- @media ${device['landscape-tablets']} {
14
- .dropdown_input__container {
15
- border-bottom: 2px var(--neutral-neutral-4) solid;
16
- }
17
-
18
- .dropdown_input__results {
19
- opacity: 1;
20
- }
21
- }
22
-
23
- .dropdown_input__container__icon {
24
- color: var(--primary-main);
25
-
26
- svg {
27
- fill: var(--primary-main);
28
- stroke: var(--primary-main);
29
- }
30
- }
11
+ a {
12
+ text-decoration: none;
31
13
  }
32
14
 
33
15
  .dropdown_input__container {
@@ -38,7 +20,24 @@ export const DropdownInputStyled = styled.div `
38
20
 
39
21
  @media ${device['landscape-tablets']} {
40
22
  border-top: 2px solid transparent;
41
- border-bottom: 2px solid transparent;
23
+ border-bottom: none;
24
+ }
25
+
26
+ &:focus-within {
27
+ border-bottom: 2px var(--neutral-neutral-4) solid;
28
+
29
+ @media ${device['landscape-tablets']} {
30
+ border-bottom: none;
31
+ }
32
+
33
+ .dropdown_input__container__icon {
34
+ color: var(--neutral-neutral-3);
35
+
36
+ svg {
37
+ fill: var(--neutral-neutral-3);
38
+ stroke: var(--neutral-neutral-3);
39
+ }
40
+ }
42
41
  }
43
42
 
44
43
  .dropdown_input__container__text_input {
@@ -55,7 +54,7 @@ export const DropdownInputStyled = styled.div `
55
54
  color: var(--neutral-neutral-3);
56
55
  }
57
56
 
58
- .dropdown_input__container__text_input.with-icon {
57
+ &.with-icon {
59
58
  padding-right: 2rem;
60
59
  }
61
60
  }
@@ -68,10 +67,10 @@ export const DropdownInputStyled = styled.div `
68
67
  top: 0;
69
68
  height: 100%;
70
69
  color: var(--neutral-neutral-3);
71
- fill: currentColor;
70
+ fill: var(--neutral-neutral-3);
72
71
 
73
72
  @media ${device['landscape-tablets']} {
74
- pointer-events: none;
73
+ cursor: pointer;
75
74
  }
76
75
 
77
76
  .dropdown_input__container__icon__main {
@@ -79,9 +78,11 @@ export const DropdownInputStyled = styled.div `
79
78
  height: 1.5rem;
80
79
  opacity: 1;
81
80
  margin-right: 0.25rem;
81
+ cursor: pointer;
82
82
 
83
83
  path {
84
84
  transition: all 0.25s;
85
+ fill: var(--neutral-neutral-3);
85
86
  }
86
87
  }
87
88
 
@@ -112,24 +113,35 @@ export const DropdownInputStyled = styled.div `
112
113
  }
113
114
  }
114
115
 
116
+ .dropdown_input__separator {
117
+ margin-top: 0.6rem;
118
+ border-top: 1.5px solid var(--neutral-neutral-4);
119
+ }
120
+
115
121
  .dropdown_input__results {
116
122
  transition: all 0.25s;
117
123
  display: flex;
118
- position: relative;
119
124
  flex-direction: column;
120
125
  width: 100%;
121
- border-radius: $s-border-radius;
122
- margin-top: 1rem;
126
+ border-radius: 8px;
123
127
  background: var(--others-white);
124
128
  min-width: 20rem;
125
-
126
- @media ${device['landscape-tablets']} {
127
- position: absolute;
128
- opacity: 0;
129
+ position: absolute;
130
+ top: 100%;
131
+ left: 0;
132
+ z-index: 10;
133
+ background-color: var(--others-white);
134
+ border-top: none;
135
+ padding: 1rem 2rem;
136
+
137
+ @media ${device['laptop']} {
138
+ opacity: 1;
129
139
  left: 0;
130
140
  top: 100%;
131
- box-shadow: $box-shadow-medium;
132
- padding: 0.75rem 1rem;
141
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
142
+ margin-top: -15px;
143
+ border: none;
144
+ border-radius: 0 0 8px 8px;
133
145
  }
134
146
 
135
147
  & > li > * {
@@ -1,35 +1,16 @@
1
1
  import { device } from '../../../globalStyles/breakpoints'
2
-
3
2
  import styled from 'styled-components'
4
3
 
5
4
  export const DropdownInputStyled = styled.div`
6
5
  position: relative;
7
- padding-left: 1.5rem;
8
- padding-right: 1.5rem;
6
+ padding: 1.5rem;
9
7
 
10
- a {
11
- text-decoration: none;
8
+ @media ${device['landscape-tablets']} {
9
+ padding: 16px 24px;
12
10
  }
13
11
 
14
- &:focus-within {
15
- @media ${device['landscape-tablets']} {
16
- .dropdown_input__container {
17
- border-bottom: 2px var(--neutral-neutral-4) solid;
18
- }
19
-
20
- .dropdown_input__results {
21
- opacity: 1;
22
- }
23
- }
24
-
25
- .dropdown_input__container__icon {
26
- color: var(--primary-main);
27
-
28
- svg {
29
- fill: var(--primary-main);
30
- stroke: var(--primary-main);
31
- }
32
- }
12
+ a {
13
+ text-decoration: none;
33
14
  }
34
15
 
35
16
  .dropdown_input__container {
@@ -40,7 +21,24 @@ export const DropdownInputStyled = styled.div`
40
21
 
41
22
  @media ${device['landscape-tablets']} {
42
23
  border-top: 2px solid transparent;
43
- border-bottom: 2px solid transparent;
24
+ border-bottom: none;
25
+ }
26
+
27
+ &:focus-within {
28
+ border-bottom: 2px var(--neutral-neutral-4) solid;
29
+
30
+ @media ${device['landscape-tablets']} {
31
+ border-bottom: none;
32
+ }
33
+
34
+ .dropdown_input__container__icon {
35
+ color: var(--neutral-neutral-3);
36
+
37
+ svg {
38
+ fill: var(--neutral-neutral-3);
39
+ stroke: var(--neutral-neutral-3);
40
+ }
41
+ }
44
42
  }
45
43
 
46
44
  .dropdown_input__container__text_input {
@@ -57,7 +55,7 @@ export const DropdownInputStyled = styled.div`
57
55
  color: var(--neutral-neutral-3);
58
56
  }
59
57
 
60
- .dropdown_input__container__text_input.with-icon {
58
+ &.with-icon {
61
59
  padding-right: 2rem;
62
60
  }
63
61
  }
@@ -70,10 +68,10 @@ export const DropdownInputStyled = styled.div`
70
68
  top: 0;
71
69
  height: 100%;
72
70
  color: var(--neutral-neutral-3);
73
- fill: currentColor;
71
+ fill: var(--neutral-neutral-3);
74
72
 
75
73
  @media ${device['landscape-tablets']} {
76
- pointer-events: none;
74
+ cursor: pointer;
77
75
  }
78
76
 
79
77
  .dropdown_input__container__icon__main {
@@ -81,9 +79,11 @@ export const DropdownInputStyled = styled.div`
81
79
  height: 1.5rem;
82
80
  opacity: 1;
83
81
  margin-right: 0.25rem;
82
+ cursor: pointer;
84
83
 
85
84
  path {
86
85
  transition: all 0.25s;
86
+ fill: var(--neutral-neutral-3);
87
87
  }
88
88
  }
89
89
 
@@ -114,24 +114,35 @@ export const DropdownInputStyled = styled.div`
114
114
  }
115
115
  }
116
116
 
117
+ .dropdown_input__separator {
118
+ margin-top: 0.6rem;
119
+ border-top: 1.5px solid var(--neutral-neutral-4);
120
+ }
121
+
117
122
  .dropdown_input__results {
118
123
  transition: all 0.25s;
119
124
  display: flex;
120
- position: relative;
121
125
  flex-direction: column;
122
126
  width: 100%;
123
- border-radius: $s-border-radius;
124
- margin-top: 1rem;
127
+ border-radius: 8px;
125
128
  background: var(--others-white);
126
129
  min-width: 20rem;
127
-
128
- @media ${device['landscape-tablets']} {
129
- position: absolute;
130
- opacity: 0;
130
+ position: absolute;
131
+ top: 100%;
132
+ left: 0;
133
+ z-index: 10;
134
+ background-color: var(--others-white);
135
+ border-top: none;
136
+ padding: 1rem 2rem;
137
+
138
+ @media ${device['laptop']} {
139
+ opacity: 1;
131
140
  left: 0;
132
141
  top: 100%;
133
- box-shadow: $box-shadow-medium;
134
- padding: 0.75rem 1rem;
142
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
143
+ margin-top: -15px;
144
+ border: none;
145
+ border-radius: 0 0 8px 8px;
135
146
  }
136
147
 
137
148
  & > li > * {
@@ -1,60 +1,64 @@
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
1
2
  /* eslint-disable jsx-a11y/no-static-element-interactions */
3
+ import React, { forwardRef, useState } from 'react'
2
4
 
3
- import React, { useState } from 'react'
4
5
  import { DropdownInputProps } from './DropdownInputProps.types'
5
6
  import { DropdownInputStyled } from './DropdownInput.styled'
6
7
 
7
- export const DropdownInput: React.FC<DropdownInputProps> = ({
8
- onChange,
9
- results,
10
- className = '',
11
- name,
12
- icon,
13
- placeholder
14
- }) => {
15
- const [searchTerm, setSearchTerm] = useState('')
8
+ export const DropdownInput = forwardRef<HTMLInputElement, DropdownInputProps>(
9
+ ({ onChange, results, className = '', name, icon, placeholder, onClose }, ref) => {
10
+ const [searchTerm, setSearchTerm] = useState('')
16
11
 
17
- const updateInput = (e): void => {
18
- setSearchTerm(e.target.value)
19
- onChange(e.target.value)
20
- }
12
+ const updateInput = (e): void => {
13
+ setSearchTerm(e.target.value)
14
+ onChange(e.target.value)
15
+ }
21
16
 
22
- const resetInput = (): void => {
23
- setSearchTerm('')
24
- }
17
+ const resetInput = (): void => {
18
+ setSearchTerm('')
19
+ }
25
20
 
26
- return (
27
- <DropdownInputStyled className={`dropdown_input ${className}`}>
28
- <div className='dropdown_input__container'>
29
- <input
30
- className={`dropdown_input__container__text_input ${icon ? 'with-icon' : ''}`}
31
- type='text'
32
- name={`dropdown_input_${name}`}
33
- placeholder={placeholder}
34
- value={searchTerm}
35
- onChange={(e) => {
36
- updateInput(e)
37
- }}
38
- />
39
- <div className={`dropdown_input__container__icon ${searchTerm ? 'active' : ''}`}>
40
- {icon &&
41
- React.cloneElement(icon, {
42
- className: 'dropdown_input__container__icon__main'
43
- })}
44
- {searchTerm && (
45
- <div
46
- className='icon-cross main-color dropdown_input__container__icon__clear'
47
- onClick={() => {
48
- resetInput()
49
- }}
50
- onKeyDown={() => {
51
- resetInput()
52
- }}
53
- ></div>
54
- )}
21
+ return (
22
+ <DropdownInputStyled className={`dropdown_input ${className}`}>
23
+ <div className='dropdown_input__container'>
24
+ <input
25
+ ref={ref}
26
+ className={`dropdown_input__container__text_input ${icon ? 'with-icon' : ''}`}
27
+ type='text'
28
+ name={`dropdown_input_${name}`}
29
+ placeholder={placeholder}
30
+ value={searchTerm}
31
+ onChange={(e) => {
32
+ updateInput(e)
33
+ }}
34
+ />
35
+ <div className={`dropdown_input__container__icon ${searchTerm ? 'active' : ''}`} onClick={onClose}>
36
+ {icon &&
37
+ React.cloneElement(icon, {
38
+ className: 'dropdown_input__container__icon__main'
39
+ })}
40
+ {searchTerm && (
41
+ <div
42
+ className='icon-cross main-color dropdown_input__container__icon__clear'
43
+ onClick={() => {
44
+ resetInput()
45
+ }}
46
+ onKeyDown={() => {
47
+ resetInput()
48
+ }}
49
+ ></div>
50
+ )}
51
+ </div>
55
52
  </div>
56
- </div>
57
- {searchTerm && !!results?.length && <ul className='dropdown_input__results'>{results}</ul>}
58
- </DropdownInputStyled>
59
- )
60
- }
53
+ {searchTerm && !!results?.length && (
54
+ <>
55
+ <div className='dropdown_input__separator'></div>
56
+ <ul className='dropdown_input__results'>{results}</ul>
57
+ </>
58
+ )}
59
+ </DropdownInputStyled>
60
+ )
61
+ }
62
+ )
63
+
64
+ DropdownInput.displayName = 'DropdownInput'
@@ -5,4 +5,5 @@ export interface DropdownInputProps {
5
5
  icon: any;
6
6
  onChange: (arg: string) => void;
7
7
  results: React.JSX.Element[];
8
+ onClose?: () => void;
8
9
  }
@@ -7,4 +7,5 @@ export interface DropdownInputProps {
7
7
  icon: any
8
8
  onChange: (arg: string) => void
9
9
  results: React.JSX.Element[]
10
+ onClose?: () => void
10
11
  }
@@ -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
+ `;