@npm_leadtech/legal-lib-components 7.23.6 → 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.
Files changed (47) hide show
  1. package/dist/src/components/atoms/DropdownInput/DropdownInput.d.ts +1 -1
  2. package/dist/src/components/atoms/DropdownInput/DropdownInput.js +7 -9
  3. package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.js +35 -52
  4. package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.ts +36 -52
  5. package/dist/src/components/atoms/DropdownInput/DropdownInput.tsx +51 -55
  6. package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.d.ts +0 -1
  7. package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.ts +0 -1
  8. package/dist/src/components/atoms/SearchSelect/SearchSelect.js +3 -2
  9. package/dist/src/components/atoms/SearchSelect/SearchSelect.tsx +3 -1
  10. package/dist/src/components/molecules/SearchBar/SearchBar.js +29 -17
  11. package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +55 -4
  12. package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +55 -4
  13. package/dist/src/components/molecules/SearchBar/SearchBar.tsx +61 -31
  14. package/dist/tsconfig.build.tsbuildinfo +1 -1
  15. package/package.json +1 -1
  16. package/dist/images/componentsSvg/CloseIcon.d.ts +0 -6
  17. package/dist/images/componentsSvg/CloseIcon.js +0 -2
  18. package/dist/images/componentsSvg/CloseIcon.tsx +0 -14
  19. package/dist/images/svg/close-grey-24px.svg +0 -3
  20. package/dist/images/svg/search_24px.svg +0 -3
  21. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.d.ts +0 -8
  22. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.js +0 -44
  23. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.d.ts +0 -1
  24. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.js +0 -48
  25. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.ts +0 -49
  26. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.tsx +0 -77
  27. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.d.ts +0 -37
  28. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.js +0 -1
  29. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.ts +0 -40
  30. package/dist/src/components/molecules/DesktopSearchBar/index.d.ts +0 -2
  31. package/dist/src/components/molecules/DesktopSearchBar/index.js +0 -1
  32. package/dist/src/components/molecules/DesktopSearchBar/index.ts +0 -2
  33. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.d.ts +0 -3
  34. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.js +0 -38
  35. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.d.ts +0 -1
  36. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.js +0 -17
  37. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.ts +0 -18
  38. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.tsx +0 -55
  39. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.d.ts +0 -37
  40. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.js +0 -1
  41. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.ts +0 -40
  42. package/dist/src/components/molecules/MobileSearchBar/index.d.ts +0 -2
  43. package/dist/src/components/molecules/MobileSearchBar/index.js +0 -1
  44. package/dist/src/components/molecules/MobileSearchBar/index.ts +0 -2
  45. package/dist/src/hooks/useSearchFunction.d.ts +0 -10
  46. package/dist/src/hooks/useSearchFunction.js +0 -28
  47. package/dist/src/hooks/useSearchFunction.tsx +0 -63
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { DropdownInputProps } from './DropdownInputProps.types';
3
- export declare const DropdownInput: React.ForwardRefExoticComponent<DropdownInputProps & React.RefAttributes<HTMLInputElement>>;
3
+ export declare const DropdownInput: React.FC<DropdownInputProps>;
@@ -1,9 +1,8 @@
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 */
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  /* eslint-disable jsx-a11y/no-static-element-interactions */
4
- import React, { forwardRef, useState } from 'react';
3
+ import React, { useState } from 'react';
5
4
  import { DropdownInputStyled } from './DropdownInput.styled';
6
- export const DropdownInput = forwardRef(({ onChange, results, className = '', name, icon, placeholder, onClose }, ref) => {
5
+ export const DropdownInput = ({ onChange, results, className = '', name, icon, placeholder }) => {
7
6
  const [searchTerm, setSearchTerm] = useState('');
8
7
  const updateInput = (e) => {
9
8
  setSearchTerm(e.target.value);
@@ -12,15 +11,14 @@ export const DropdownInput = forwardRef(({ onChange, results, className = '', na
12
11
  const resetInput = () => {
13
12
  setSearchTerm('');
14
13
  };
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) => {
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) => {
16
15
  updateInput(e);
17
- } }), _jsxs("div", { className: `dropdown_input__container__icon ${searchTerm ? 'active' : ''}`, onClick: onClose, children: [icon &&
16
+ } }), _jsxs("div", { className: `dropdown_input__container__icon ${searchTerm ? 'active' : ''}`, children: [icon &&
18
17
  React.cloneElement(icon, {
19
18
  className: 'dropdown_input__container__icon__main'
20
19
  }), searchTerm && (_jsx("div", { className: 'icon-cross main-color dropdown_input__container__icon__clear', onClick: () => {
21
20
  resetInput();
22
21
  }, onKeyDown: () => {
23
22
  resetInput();
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';
23
+ } }))] })] }), searchTerm && !!results?.length && _jsx("ul", { className: 'dropdown_input__results', children: results })] }));
24
+ };
@@ -2,16 +2,34 @@ 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: 1.5rem;
6
-
7
- @media ${device['landscape-tablets']} {
8
- padding: 16px 24px;
9
- }
5
+ padding-left: 1.5rem;
6
+ padding-right: 1.5rem;
10
7
 
11
8
  a {
12
9
  text-decoration: none;
13
10
  }
14
11
 
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
+ }
31
+ }
32
+
15
33
  .dropdown_input__container {
16
34
  position: relative;
17
35
  height: 2.75rem;
@@ -20,24 +38,7 @@ export const DropdownInputStyled = styled.div `
20
38
 
21
39
  @media ${device['landscape-tablets']} {
22
40
  border-top: 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
- }
41
+ border-bottom: 2px solid transparent;
41
42
  }
42
43
 
43
44
  .dropdown_input__container__text_input {
@@ -54,7 +55,7 @@ export const DropdownInputStyled = styled.div `
54
55
  color: var(--neutral-neutral-3);
55
56
  }
56
57
 
57
- &.with-icon {
58
+ .dropdown_input__container__text_input.with-icon {
58
59
  padding-right: 2rem;
59
60
  }
60
61
  }
@@ -67,10 +68,10 @@ export const DropdownInputStyled = styled.div `
67
68
  top: 0;
68
69
  height: 100%;
69
70
  color: var(--neutral-neutral-3);
70
- fill: var(--neutral-neutral-3);
71
+ fill: currentColor;
71
72
 
72
73
  @media ${device['landscape-tablets']} {
73
- cursor: pointer;
74
+ pointer-events: none;
74
75
  }
75
76
 
76
77
  .dropdown_input__container__icon__main {
@@ -78,11 +79,9 @@ export const DropdownInputStyled = styled.div `
78
79
  height: 1.5rem;
79
80
  opacity: 1;
80
81
  margin-right: 0.25rem;
81
- cursor: pointer;
82
82
 
83
83
  path {
84
84
  transition: all 0.25s;
85
- fill: var(--neutral-neutral-3);
86
85
  }
87
86
  }
88
87
 
@@ -113,36 +112,24 @@ export const DropdownInputStyled = styled.div `
113
112
  }
114
113
  }
115
114
 
116
- .dropdown_input__separator {
117
- margin-top: 0.6rem;
118
- border-top: 1.5px solid var(--neutral-neutral-4);
119
- }
120
-
121
115
  .dropdown_input__results {
122
116
  transition: all 0.25s;
123
117
  display: flex;
118
+ position: relative;
124
119
  flex-direction: column;
125
120
  width: 100%;
126
- border-radius: 8px;
121
+ border-radius: $s-border-radius;
122
+ margin-top: 1rem;
127
123
  background: var(--others-white);
128
- width: 300px;
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;
124
+ min-width: 20rem;
136
125
 
137
126
  @media ${device['landscape-tablets']} {
138
- opacity: 1;
127
+ position: absolute;
128
+ opacity: 0;
139
129
  left: 0;
140
130
  top: 100%;
141
- width: 100%;
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;
131
+ box-shadow: $box-shadow-medium;
132
+ padding: 0.75rem 1rem;
146
133
  }
147
134
 
148
135
  & > li > * {
@@ -156,9 +143,5 @@ export const DropdownInputStyled = styled.div `
156
143
  background: var(--primary-main-light-5);
157
144
  }
158
145
  }
159
-
160
- .dropdown_input__link--all {
161
- font-weight: 700;
162
- }
163
146
  }
164
147
  `;
@@ -1,18 +1,37 @@
1
1
  import { device } from '../../../globalStyles/breakpoints'
2
+
2
3
  import styled from 'styled-components'
3
4
 
4
5
  export const DropdownInputStyled = styled.div`
5
6
  position: relative;
6
- padding: 1.5rem;
7
-
8
- @media ${device['landscape-tablets']} {
9
- padding: 16px 24px;
10
- }
7
+ padding-left: 1.5rem;
8
+ padding-right: 1.5rem;
11
9
 
12
10
  a {
13
11
  text-decoration: none;
14
12
  }
15
13
 
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
+ }
33
+ }
34
+
16
35
  .dropdown_input__container {
17
36
  position: relative;
18
37
  height: 2.75rem;
@@ -21,24 +40,7 @@ export const DropdownInputStyled = styled.div`
21
40
 
22
41
  @media ${device['landscape-tablets']} {
23
42
  border-top: 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
- }
43
+ border-bottom: 2px solid transparent;
42
44
  }
43
45
 
44
46
  .dropdown_input__container__text_input {
@@ -55,7 +57,7 @@ export const DropdownInputStyled = styled.div`
55
57
  color: var(--neutral-neutral-3);
56
58
  }
57
59
 
58
- &.with-icon {
60
+ .dropdown_input__container__text_input.with-icon {
59
61
  padding-right: 2rem;
60
62
  }
61
63
  }
@@ -68,10 +70,10 @@ export const DropdownInputStyled = styled.div`
68
70
  top: 0;
69
71
  height: 100%;
70
72
  color: var(--neutral-neutral-3);
71
- fill: var(--neutral-neutral-3);
73
+ fill: currentColor;
72
74
 
73
75
  @media ${device['landscape-tablets']} {
74
- cursor: pointer;
76
+ pointer-events: none;
75
77
  }
76
78
 
77
79
  .dropdown_input__container__icon__main {
@@ -79,11 +81,9 @@ export const DropdownInputStyled = styled.div`
79
81
  height: 1.5rem;
80
82
  opacity: 1;
81
83
  margin-right: 0.25rem;
82
- cursor: pointer;
83
84
 
84
85
  path {
85
86
  transition: all 0.25s;
86
- fill: var(--neutral-neutral-3);
87
87
  }
88
88
  }
89
89
 
@@ -114,36 +114,24 @@ 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
-
122
117
  .dropdown_input__results {
123
118
  transition: all 0.25s;
124
119
  display: flex;
120
+ position: relative;
125
121
  flex-direction: column;
126
122
  width: 100%;
127
- border-radius: 8px;
123
+ border-radius: $s-border-radius;
124
+ margin-top: 1rem;
128
125
  background: var(--others-white);
129
- width: 300px;
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;
126
+ min-width: 20rem;
137
127
 
138
128
  @media ${device['landscape-tablets']} {
139
- opacity: 1;
129
+ position: absolute;
130
+ opacity: 0;
140
131
  left: 0;
141
132
  top: 100%;
142
- width: 100%;
143
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
144
- margin-top: -15px;
145
- border: none;
146
- border-radius: 0 0 8px 8px;
133
+ box-shadow: $box-shadow-medium;
134
+ padding: 0.75rem 1rem;
147
135
  }
148
136
 
149
137
  & > li > * {
@@ -157,9 +145,5 @@ export const DropdownInputStyled = styled.div`
157
145
  background: var(--primary-main-light-5);
158
146
  }
159
147
  }
160
-
161
- .dropdown_input__link--all {
162
- font-weight: 700;
163
- }
164
148
  }
165
149
  `
@@ -1,64 +1,60 @@
1
- /* eslint-disable jsx-a11y/click-events-have-key-events */
2
1
  /* eslint-disable jsx-a11y/no-static-element-interactions */
3
- import React, { forwardRef, useState } from 'react'
4
2
 
3
+ import React, { useState } from 'react'
5
4
  import { DropdownInputProps } from './DropdownInputProps.types'
6
5
  import { DropdownInputStyled } from './DropdownInput.styled'
7
6
 
8
- export const DropdownInput = forwardRef<HTMLInputElement, DropdownInputProps>(
9
- ({ onChange, results, className = '', name, icon, placeholder, onClose }, ref) => {
10
- const [searchTerm, setSearchTerm] = useState('')
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('')
11
16
 
12
- const updateInput = (e): void => {
13
- setSearchTerm(e.target.value)
14
- onChange(e.target.value)
15
- }
16
-
17
- const resetInput = (): void => {
18
- setSearchTerm('')
19
- }
17
+ const updateInput = (e): void => {
18
+ setSearchTerm(e.target.value)
19
+ onChange(e.target.value)
20
+ }
20
21
 
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>
52
- </div>
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
- )
22
+ const resetInput = (): void => {
23
+ setSearchTerm('')
61
24
  }
62
- )
63
25
 
64
- DropdownInput.displayName = 'DropdownInput'
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
+ )}
55
+ </div>
56
+ </div>
57
+ {searchTerm && !!results?.length && <ul className='dropdown_input__results'>{results}</ul>}
58
+ </DropdownInputStyled>
59
+ )
60
+ }
@@ -5,5 +5,4 @@ export interface DropdownInputProps {
5
5
  icon: any;
6
6
  onChange: (arg: string) => void;
7
7
  results: React.JSX.Element[];
8
- onClose?: () => void;
9
8
  }
@@ -7,5 +7,4 @@ export interface DropdownInputProps {
7
7
  icon: any
8
8
  onChange: (arg: string) => void
9
9
  results: React.JSX.Element[]
10
- onClose?: () => void
11
10
  }
@@ -49,7 +49,8 @@ const SearchSelect = (props) => {
49
49
  boxShadow: state.isFocused ? '0 0 0 1px var(--primary-main) !important' : '',
50
50
  borderStyle: state.isFocused ? 'solid' : 'initial'
51
51
  };
52
- }
53
- }, id: props.name, name: props.name, className: 'legal-selector', defaultValue: defaultValue, onChange: handleChange, isDisabled: props.disabled, isSearchable: props.isSearchable !== false, options: sortedItems, escapeClearsValue: true, isClearable: true, placeholder: props.placeholder, defaultMenuIsOpen: props.defaultMenuIsOpen, menuPlacement: menuPlacement })] })] }));
52
+ },
53
+ menuPortal: (base) => ({ ...base, zIndex: 9999 })
54
+ }, id: props.name, name: props.name, className: 'legal-selector', defaultValue: defaultValue, onChange: handleChange, isDisabled: props.disabled, isSearchable: props.isSearchable !== false, options: sortedItems, escapeClearsValue: true, isClearable: true, menuPortalTarget: document.body, placeholder: props.placeholder, defaultMenuIsOpen: props.defaultMenuIsOpen, menuPlacement: menuPlacement })] })] }));
54
55
  };
55
56
  export default SearchSelect;
@@ -77,7 +77,8 @@ const SearchSelect: FC<SearchSelectProps> = (props) => {
77
77
  boxShadow: state.isFocused ? '0 0 0 1px var(--primary-main) !important' : '',
78
78
  borderStyle: state.isFocused ? 'solid' : 'initial'
79
79
  }
80
- }
80
+ },
81
+ menuPortal: (base) => ({ ...base, zIndex: 9999 })
81
82
  }}
82
83
  id={props.name}
83
84
  name={props.name}
@@ -89,6 +90,7 @@ const SearchSelect: FC<SearchSelectProps> = (props) => {
89
90
  options={sortedItems}
90
91
  escapeClearsValue={true}
91
92
  isClearable={true}
93
+ menuPortalTarget={document.body}
92
94
  placeholder={props.placeholder}
93
95
  defaultMenuIsOpen={props.defaultMenuIsOpen}
94
96
  menuPlacement={menuPlacement}
@@ -1,21 +1,33 @@
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 */
5
2
  import { useState } from 'react';
6
- import { DesktopSearchBar } from '../DesktopSearchBar';
7
- import { MobileSearchBar } from '../MobileSearchBar';
3
+ import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput';
4
+ import { SearchIcon } from '../../../../images/componentsSvg/SearchIcon';
5
+ import { useWindowSize } from '../../../hooks/useWindowSize';
8
6
  import { SearchBarStyled } from './SearchBar.styled';
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 })] }) }));
7
+ export const SearchBar = ({ products, searchBarTexts, routes, handleResultClick }) => {
8
+ const [results, setResults] = useState([]);
9
+ const windowSize = useWindowSize();
10
+ const _placeholder = windowSize.width === null || windowSize.width >= 720 ? '' : searchBarTexts.placeholder;
11
+ const searchFunction = (text) => {
12
+ const searchTerm = text.toLowerCase();
13
+ const productsFiltered = products.filter((item) => item.linkText.toLowerCase().includes(searchTerm));
14
+ const results = productsFiltered
15
+ .map((item) => {
16
+ const product = item.linkText;
17
+ const preMatch = product.slice(0, product.toLowerCase().indexOf(searchTerm));
18
+ const match = product.slice(product.toLowerCase().indexOf(searchTerm), preMatch.length + searchTerm.length);
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 }) }));
21
33
  };
@@ -1,11 +1,62 @@
1
1
  import { device } from '../../../globalStyles/breakpoints';
2
2
  import styled from 'styled-components';
3
3
  export const SearchBarStyled = styled.div `
4
- .search-icon-container {
5
- display: none;
4
+ .dropdown_input {
5
+ .search {
6
+ width: calc(100% - 3rem);
7
+ margin: 0 1.5rem;
6
8
 
7
- @media ${device['landscape-tablets']} {
8
- display: block;
9
+ @media ${device['landscape-tablets']} {
10
+ display: none;
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;
9
60
  }
10
61
  }
11
62
  `;