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