@npm_leadtech/legal-lib-components 7.22.8 → 7.22.10

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 (30) hide show
  1. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.d.ts +8 -0
  2. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.js +44 -0
  3. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.d.ts +1 -0
  4. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.js +48 -0
  5. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.styled.ts +49 -0
  6. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBar.tsx +77 -0
  7. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.d.ts +37 -0
  8. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.js +1 -0
  9. package/dist/src/components/molecules/DesktopSearchBar/DesktopSearchBarProps.types.ts +40 -0
  10. package/dist/src/components/molecules/DesktopSearchBar/index.d.ts +2 -0
  11. package/dist/src/components/molecules/DesktopSearchBar/index.js +1 -0
  12. package/dist/src/components/molecules/DesktopSearchBar/index.ts +2 -0
  13. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.d.ts +3 -0
  14. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.js +38 -0
  15. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.d.ts +1 -0
  16. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.js +16 -0
  17. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.styled.ts +17 -0
  18. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBar.tsx +55 -0
  19. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.d.ts +37 -0
  20. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.js +1 -0
  21. package/dist/src/components/molecules/MobileSearchBar/MobileSearchBarProps.types.ts +40 -0
  22. package/dist/src/components/molecules/MobileSearchBar/index.d.ts +2 -0
  23. package/dist/src/components/molecules/MobileSearchBar/index.js +1 -0
  24. package/dist/src/components/molecules/MobileSearchBar/index.ts +2 -0
  25. package/dist/src/components/molecules/SearchBar/SearchBar.js +8 -87
  26. package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +4 -47
  27. package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +4 -47
  28. package/dist/src/components/molecules/SearchBar/SearchBar.tsx +12 -141
  29. package/dist/tsconfig.build.tsbuildinfo +1 -1
  30. package/package.json +1 -1
@@ -1,54 +1,11 @@
1
1
  import { device } from '../../../globalStyles/breakpoints';
2
2
  import styled from 'styled-components';
3
3
  export const SearchBarStyled = styled.div `
4
- .dropdown_input {
5
- .search {
6
- width: calc(100% - 3rem);
7
- margin: 0 1.5rem;
8
- }
9
- }
10
-
11
- @media ${device['landscape-tablets']} {
12
- &.modal_searchbar {
13
- position: absolute;
14
- top: 45px;
15
- left: 0;
16
- z-index: 10000;
17
- width: 400px;
18
- max-width: 90vw;
19
- background: transparent;
20
-
21
- .modal_searchbar__content {
22
- background-color: var(--others-white);
23
- padding: 1.5rem;
24
- border-radius: 8px;
25
- width: 100%;
26
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
27
-
28
- @media ${device['laptop']} {
29
- padding: 0;
30
- }
31
- }
32
-
33
- .modal_searchbar__header {
34
- display: flex;
35
- justify-content: space-between;
36
- align-items: center;
37
- margin-bottom: 1rem;
38
- }
39
-
40
- .modal_searchbar__title {
41
- font-size: 1.5rem;
42
- font-weight: bold;
43
- color: var(--others-black);
44
- }
4
+ .search-icon-container {
5
+ display: none;
45
6
 
46
- .dropdown_input {
47
- .search {
48
- width: 100%;
49
- margin: 0;
50
- }
51
- }
7
+ @media ${device['landscape-tablets']} {
8
+ display: block;
52
9
  }
53
10
  }
54
11
  `;
@@ -2,54 +2,11 @@ import { device } from '../../../globalStyles/breakpoints'
2
2
  import styled from 'styled-components'
3
3
 
4
4
  export const SearchBarStyled = styled.div`
5
- .dropdown_input {
6
- .search {
7
- width: calc(100% - 3rem);
8
- margin: 0 1.5rem;
9
- }
10
- }
11
-
12
- @media ${device['landscape-tablets']} {
13
- &.modal_searchbar {
14
- position: absolute;
15
- top: 45px;
16
- left: 0;
17
- z-index: 10000;
18
- width: 400px;
19
- max-width: 90vw;
20
- background: transparent;
21
-
22
- .modal_searchbar__content {
23
- background-color: var(--others-white);
24
- padding: 1.5rem;
25
- border-radius: 8px;
26
- width: 100%;
27
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
28
-
29
- @media ${device['laptop']} {
30
- padding: 0;
31
- }
32
- }
33
-
34
- .modal_searchbar__header {
35
- display: flex;
36
- justify-content: space-between;
37
- align-items: center;
38
- margin-bottom: 1rem;
39
- }
40
-
41
- .modal_searchbar__title {
42
- font-size: 1.5rem;
43
- font-weight: bold;
44
- color: var(--others-black);
45
- }
5
+ .search-icon-container {
6
+ display: none;
46
7
 
47
- .dropdown_input {
48
- .search {
49
- width: 100%;
50
- margin: 0;
51
- }
52
- }
8
+ @media ${device['landscape-tablets']} {
9
+ display: block;
53
10
  }
54
11
  }
55
12
  `
@@ -1,157 +1,29 @@
1
1
  /* eslint-disable jsx-a11y/click-events-have-key-events */
2
- /* eslint-disable jsx-a11y/anchor-is-valid */
3
2
  /* eslint-disable jsx-a11y/no-static-element-interactions */
4
- import React, { useEffect, useRef, useState } from 'react'
5
- import { CloseIcon } from '../../../../images/componentsSvg/CloseIcon'
6
- import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput'
7
- import { SearchIcon } from '../../../../images/componentsSvg/SearchIcon'
8
- import search from '../../../../images/svg/search_24px.svg'
9
- import { useWindowSize } from '../../../hooks/useWindowSize'
10
-
3
+ /* eslint-disable jsx-a11y/anchor-is-valid */
4
+ import React, { useState } from 'react'
5
+ import { DesktopSearchBar } from '../DesktopSearchBar'
6
+ import { MobileSearchBar } from '../MobileSearchBar'
11
7
  import { type SearchBarProps } from './SearchBarProps.types'
12
8
  import { SearchBarStyled } from './SearchBar.styled'
13
- import { useSearchFunction } from '../../../hooks/useSearchFunction'
14
-
15
- interface DesktopSearchBarProps extends SearchBarProps {
16
- isOpen: boolean
17
- onClose: () => void
18
- isDesktop: boolean
19
- }
20
-
21
- const DesktopSearchBar: React.FC<DesktopSearchBarProps> = ({
22
- products,
23
- searchBarTexts,
24
- routes,
25
- handleResultClick,
26
- isOpen,
27
- onClose,
28
- isDesktop
29
- }) => {
30
- const { results, searchFunction } = useSearchFunction({
31
- products,
32
- searchBarTexts,
33
- routes,
34
- handleResultClick,
35
- onClose
36
- })
37
- const searchInputRef = useRef<HTMLInputElement>(null)
38
- const searchBarContainerRef = useRef<HTMLDivElement>(null)
39
-
40
- useEffect(() => {
41
- const handleKeyDown = (event: KeyboardEvent) => {
42
- if (event.key === 'Escape') {
43
- onClose()
44
- }
45
- }
46
- const handleClickOutside = (event: MouseEvent) => {
47
- if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target as Node)) {
48
- onClose()
49
- }
50
- }
51
-
52
- if (isOpen) {
53
- document.addEventListener('keydown', handleKeyDown)
54
- document.addEventListener('mousedown', handleClickOutside)
55
- if (searchInputRef.current) {
56
- searchInputRef.current.focus()
57
- }
58
- }
59
-
60
- return () => {
61
- document.removeEventListener('keydown', handleKeyDown)
62
- document.removeEventListener('mousedown', handleClickOutside)
63
- }
64
- }, [isOpen, onClose])
65
-
66
- if (!isOpen) {
67
- return null
68
- }
69
-
70
- return (
71
- <SearchBarStyled ref={searchBarContainerRef} className='modal_searchbar'>
72
- <div className='modal_searchbar__content'>
73
- <DropdownInput
74
- ref={searchInputRef}
75
- name='desktop-search'
76
- className='search'
77
- placeholder={searchBarTexts.placeholder}
78
- icon={isDesktop ? <CloseIcon /> : <SearchIcon />}
79
- onChange={searchFunction}
80
- results={results}
81
- onClose={onClose}
82
- />
83
- </div>
84
- </SearchBarStyled>
85
- )
86
- }
87
-
88
- const MobileSearchBar: React.FC<SearchBarProps> = ({ products, searchBarTexts, routes, handleResultClick }) => {
89
- const { results, searchFunction } = useSearchFunction({
90
- products,
91
- searchBarTexts,
92
- routes,
93
- handleResultClick
94
- })
95
- const searchInputRef = useRef<HTMLInputElement>(null)
96
- const searchBarContainerRef = useRef<HTMLDivElement>(null)
97
- const isResultsVisible = Array.isArray(results) && results.length > 0
98
-
99
- useEffect(() => {
100
- const handleKeyDown = (event: KeyboardEvent) => {
101
- if (event.key === 'Escape') {
102
- searchFunction('')
103
- }
104
- }
105
- const handleClickOutside = (event: MouseEvent) => {
106
- if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target as Node)) {
107
- searchFunction('')
108
- }
109
- }
110
-
111
- if (isResultsVisible) {
112
- document.addEventListener('keydown', handleKeyDown)
113
- document.addEventListener('mousedown', handleClickOutside)
114
- }
115
-
116
- return () => {
117
- document.removeEventListener('keydown', handleKeyDown)
118
- document.removeEventListener('mousedown', handleClickOutside)
119
- }
120
- }, [isResultsVisible, searchFunction])
121
-
122
- return (
123
- <SearchBarStyled ref={searchBarContainerRef}>
124
- <DropdownInput
125
- ref={searchInputRef}
126
- name='mobile-and-tablet-search'
127
- className='search'
128
- placeholder={searchBarTexts.placeholder}
129
- icon={<SearchIcon />}
130
- onChange={searchFunction}
131
- results={results}
132
- />
133
- </SearchBarStyled>
134
- )
135
- }
9
+ import search from '../../../../images/svg/search_24px.svg'
136
10
 
137
11
  export const SearchBar: React.FC<SearchBarProps> = (props) => {
138
- const windowSize = useWindowSize()
139
- const isDesktop = !!windowSize.width && windowSize.width >= 960
140
12
  const [isModalOpen, setIsModalOpen] = useState(false)
141
13
 
142
14
  const closeModal = () => setIsModalOpen(false)
143
15
 
144
- if (isDesktop) {
145
- return (
16
+ return (
17
+ <SearchBarStyled>
146
18
  <div style={{ position: 'relative', display: 'flex' }}>
147
19
  <a
148
20
  onClick={() => setIsModalOpen(true)}
149
21
  style={{
150
22
  cursor: 'pointer',
151
- display: 'inline-block',
152
23
  width: '20px',
153
24
  height: '20px'
154
25
  }}
26
+ className='search-icon-container'
155
27
  >
156
28
  <img
157
29
  src={search}
@@ -162,10 +34,9 @@ export const SearchBar: React.FC<SearchBarProps> = (props) => {
162
34
  }}
163
35
  />
164
36
  </a>
165
- <DesktopSearchBar {...props} isDesktop={isDesktop} isOpen={isModalOpen} onClose={closeModal} />
37
+ <DesktopSearchBar {...props} isOpen={isModalOpen} onClose={closeModal} />
38
+ <MobileSearchBar {...props} />
166
39
  </div>
167
- )
168
- }
169
-
170
- return <MobileSearchBar {...props} />
40
+ </SearchBarStyled>
41
+ )
171
42
  }