@npm_leadtech/legal-lib-components 7.22.8 → 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 -159
  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, isDesktop }) => {
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: isDesktop ? _jsx(CloseIcon, {}) : _jsx(SearchIcon, {}), 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, isDesktop: isDesktop, 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,171 +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
- 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
- }
8
+ import search from '../../../../images/svg/search_24px.svg'
136
9
 
137
10
  export const SearchBar: React.FC<SearchBarProps> = (props) => {
138
- const windowSize = useWindowSize()
139
- const isDesktop = !!windowSize.width && windowSize.width >= 960
140
11
  const [isModalOpen, setIsModalOpen] = useState(false)
141
12
 
142
13
  const closeModal = () => setIsModalOpen(false)
143
14
 
144
- if (isDesktop) {
145
- return (
146
- <div style={{ position: 'relative', display: 'flex' }}>
147
- <a
148
- 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'
149
30
  style={{
150
- cursor: 'pointer',
151
- display: 'inline-block',
152
- width: '20px',
153
- height: '20px'
31
+ width: '100%',
32
+ height: '100%'
154
33
  }}
155
- >
156
- <img
157
- src={search}
158
- alt='search-icon-primary'
159
- style={{
160
- width: '100%',
161
- height: '100%'
162
- }}
163
- />
164
- </a>
165
- <DesktopSearchBar {...props} isDesktop={isDesktop} isOpen={isModalOpen} onClose={closeModal} />
166
- </div>
167
- )
168
- }
169
-
170
- return <MobileSearchBar {...props} />
34
+ />
35
+ </a>
36
+ <DesktopSearchBar {...props} isOpen={isModalOpen} onClose={closeModal} />
37
+ <MobileSearchBar {...props} />
38
+ </div>
39
+ )
171
40
  }