Skip to content

Commit b9b577f

Browse files
committed
feat: add SearchTextField component
1 parent 4e567c2 commit b9b577f

File tree

9 files changed

+10321
-9209
lines changed

9 files changed

+10321
-9209
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beeinventor/dasiot-react-component-lib",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"module": "lib/index.js",
55
"types": "lib/index.d.ts",
66
"files": [
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { Meta, Story } from '@storybook/react';
3+
4+
import { SearchTextFieldProps } from './SearchTextField.type';
5+
import SearchTextField from './SearchTextField';
6+
7+
export default {
8+
title: 'Components/TextField/SearchTextField',
9+
component: SearchTextField,
10+
argTypes: {
11+
onChange: { action: 'onChange' },
12+
},
13+
} as Meta;
14+
15+
const Template: Story<SearchTextFieldProps> = (args) => (
16+
<SearchTextField {...args} />
17+
);
18+
19+
export const Default: Story<SearchTextFieldProps> = Template.bind({});
20+
21+
Default.args = {
22+
inputProps: {
23+
placeholder: 'Distributor',
24+
},
25+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Box, styled } from '@mui/material';
2+
import React from 'react';
3+
4+
import { SearchTextFieldProps } from './SearchTextField.type';
5+
import SearchSvgIcon from '../../svg/SearchSvgIcon';
6+
7+
const Container = styled(Box)`
8+
display: inline-flex;
9+
justify-content: space-between;
10+
align-items: center;
11+
gap: 16px;
12+
min-width: 220px;
13+
min-height: 40px;
14+
color: ${({ theme }) => theme.color.secondary.$80};
15+
background: #ffffff;
16+
border-radius: 4px;
17+
18+
& > input {
19+
display: inline-block;
20+
font: inherit;
21+
font-size: 1rem;
22+
font-weight: 500;
23+
line-height: 1.5;
24+
border: none;
25+
outline: none;
26+
margin-left: 16px;
27+
28+
&::placeholder {
29+
color: ${({ theme }) => theme.color.secondary.$60};
30+
}
31+
}
32+
`;
33+
34+
const SearchTextField: React.FC<SearchTextFieldProps> = ({
35+
inputProps,
36+
onChange,
37+
...otherProps
38+
}) => {
39+
return (
40+
<Container {...otherProps}>
41+
<input type="text" onChange={onChange} {...inputProps} />
42+
<SearchSvgIcon />
43+
</Container>
44+
);
45+
};
46+
47+
export default SearchTextField;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { BoxProps } from '@mui/material';
2+
import { InputHTMLAttributes } from 'react';
3+
4+
export interface SearchTextFieldProps extends BoxProps {
5+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
6+
inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './SearchTextField';

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export { default as DropdownV2 } from './Dropdown/DropdownV2';
99
export { default as DropdownColor } from './Dropdown/DropdownColor';
1010
export { default as DatePicker } from './DatePicker';
1111
export { default as Step } from './Step';
12+
export { default as SearchTextField } from './SearchTextField';

src/svg/SearchSvgIcon.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from 'react';
2+
import { SVGProps } from 'react';
3+
const SearchSvgIcon = (props: SVGProps<SVGSVGElement>): JSX.Element => (
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
width={40}
7+
height={40}
8+
fill="none"
9+
{...props}
10+
>
11+
<path
12+
fill="currentColor"
13+
fillRule="evenodd"
14+
d="M24 19a5 5 0 1 1-10 0 5 5 0 0 1 10 0Zm-.808 5.606a7 7 0 1 1 1.414-1.414l.101.1 3 3a1 1 0 0 1-1.414 1.415l-3-3-.1-.1Z"
15+
clipRule="evenodd"
16+
/>
17+
</svg>
18+
);
19+
export default SearchSvgIcon;

tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
"esModuleInterop": true,
1717
"emitDeclarationOnly": false,
1818
"baseUrl": "src/",
19-
"paths": {
20-
"components": ["src/components/*"]
21-
}
2219
},
2320
"include": ["src/**/*.tsx", "src/**/*.ts"],
2421
"exclude": ["lib", "node_modules"],
25-
"types": ["typePatches"]
2622
}

0 commit comments

Comments
 (0)