code7-leia 0.1.126 → 0.1.127
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.
- package/dist/code7-leia.cjs.development.js +37 -44
- package/dist/code7-leia.cjs.development.js.map +1 -1
- package/dist/code7-leia.cjs.production.min.js +1 -1
- package/dist/code7-leia.cjs.production.min.js.map +1 -1
- package/dist/code7-leia.esm.js +37 -44
- package/dist/code7-leia.esm.js.map +1 -1
- package/dist/components/FileArea/components/Search/styles.d.ts +4 -0
- package/package.json +1 -1
- package/src/components/FileArea/components/Search/index.tsx +20 -31
- package/src/components/FileArea/components/Search/styles.tsx +26 -0
- package/src/components/FileArea/index.tsx +4 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const InputContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
3
|
+
export declare const Input: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>>;
|
|
4
|
+
export declare const IconContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
package/package.json
CHANGED
|
@@ -1,54 +1,43 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import unorm from 'unorm';
|
|
3
3
|
import { FaSearch } from 'react-icons/fa';
|
|
4
|
-
import
|
|
4
|
+
import { InputContainer, Input, IconContainer } from './styles';
|
|
5
|
+
import type { FileData } from '../../../../interface/FileData';
|
|
5
6
|
|
|
6
7
|
interface SearchInputProps {
|
|
7
8
|
placeholder: string;
|
|
8
|
-
initialFiles: FileData[]
|
|
9
|
+
initialFiles: FileData[];
|
|
9
10
|
setFiles: React.Dispatch<React.SetStateAction<FileData[]>>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
const SearchInput: React.FC<SearchInputProps> = ({
|
|
13
|
-
|
|
13
|
+
const SearchInput: React.FC<SearchInputProps> = ({
|
|
14
|
+
placeholder,
|
|
15
|
+
setFiles,
|
|
16
|
+
initialFiles,
|
|
17
|
+
}) => {
|
|
14
18
|
const searchName = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
15
19
|
const searchTerm = e.target.value.trim();
|
|
16
20
|
const normalizedSearchTerm = unorm.nfkd(searchTerm).toLowerCase();
|
|
17
|
-
|
|
18
|
-
const newFiles = initialFiles.filter(file => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
const newFiles = initialFiles.filter((file) => {
|
|
23
|
+
const normalizedFileName = unorm.nfkd(file.name).toLowerCase();
|
|
24
|
+
return normalizedFileName.includes(normalizedSearchTerm);
|
|
21
25
|
});
|
|
22
|
-
|
|
26
|
+
|
|
23
27
|
setFiles(searchTerm !== '' ? newFiles : initialFiles);
|
|
24
|
-
}
|
|
25
|
-
|
|
28
|
+
};
|
|
26
29
|
|
|
27
30
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
31
|
+
<InputContainer>
|
|
32
|
+
<Input
|
|
30
33
|
type="text"
|
|
31
|
-
onChange={(e) => searchName(e)}
|
|
34
|
+
onChange={(e: any) => searchName(e)}
|
|
32
35
|
placeholder={placeholder}
|
|
33
|
-
style={{
|
|
34
|
-
paddingLeft: '40px',
|
|
35
|
-
borderRadius: '5px',
|
|
36
|
-
border: '1px solid #ccc',
|
|
37
|
-
height: '40px',
|
|
38
|
-
width: '100%',
|
|
39
|
-
}}
|
|
40
36
|
/>
|
|
41
|
-
<
|
|
42
|
-
style={{
|
|
43
|
-
position: 'absolute',
|
|
44
|
-
top: '10px',
|
|
45
|
-
left: '10px',
|
|
46
|
-
pointerEvents: 'none',
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
37
|
+
<IconContainer>
|
|
49
38
|
<FaSearch />
|
|
50
|
-
</
|
|
51
|
-
</
|
|
39
|
+
</IconContainer>
|
|
40
|
+
</InputContainer>
|
|
52
41
|
);
|
|
53
42
|
};
|
|
54
43
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const InputContainer = styled.div`
|
|
4
|
+
position: relative;
|
|
5
|
+
width: 300px;
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
export const Input = styled.input`
|
|
9
|
+
padding-left: 40px;
|
|
10
|
+
border-radius: 5px;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
height: 40px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
|
|
15
|
+
&:focus {
|
|
16
|
+
outline: none;
|
|
17
|
+
box-shadow: 0 0 0 3px #6690ff;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const IconContainer = styled.div`
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 10px;
|
|
24
|
+
left: 10px;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
`;
|