@campxdev/shared 1.4.15 → 1.4.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -0,0 +1,39 @@
1
+ import { Tune } from '@mui/icons-material'
2
+ import { Box, styled } from '@mui/material'
3
+
4
+ const StyledButtonWrapper = styled(Box)<{ size: 'regular' | 'large' }>(
5
+ ({ theme, size }) => ({
6
+ width: size === 'regular' ? '40px' : '50px',
7
+ height: size === 'regular' ? '40px' : '50px',
8
+ border: theme.borders.grayLight,
9
+ display: 'flex',
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ borderRadius: '10px',
13
+ cursor: 'pointer',
14
+ '&:active': {
15
+ border: `1px solid ${theme.palette.primary.main}`,
16
+ },
17
+ transition: 'border 0.1s ease-in-out',
18
+ }),
19
+ )
20
+
21
+ export default function FilterButton({
22
+ onClick,
23
+ size = 'large',
24
+ ...props
25
+ }: {
26
+ onClick: (e: any) => void
27
+ size?: 'regular' | 'large'
28
+ }) {
29
+ const handleClick = (e) => {
30
+ e.stopPropagation()
31
+ if (!onClick) return
32
+ onClick(e)
33
+ }
34
+ return (
35
+ <StyledButtonWrapper size={size} {...props} onClick={handleClick}>
36
+ <Tune />
37
+ </StyledButtonWrapper>
38
+ )
39
+ }
@@ -0,0 +1,40 @@
1
+ import { Search } from '@mui/icons-material'
2
+ import { InputAdornment } from '@mui/material'
3
+ import _ from 'lodash'
4
+ import { useMemo, useState } from 'react'
5
+ import { TextField } from '../Input'
6
+ import { ITextFieldProps } from '../Input/TextField'
7
+
8
+ interface SearchBarProps {
9
+ onSearch: (v: string) => void
10
+ textFieldProps?: ITextFieldProps
11
+ }
12
+
13
+ export default function SearchBar({ onSearch, ...restProps }: SearchBarProps) {
14
+ const [, setSearch] = useState('')
15
+
16
+ const debouncedChangeHandler = useMemo(
17
+ () =>
18
+ _.debounce((e) => {
19
+ setSearch(e.target.value)
20
+ onSearch(e.target.value)
21
+ }, 300),
22
+ [],
23
+ )
24
+
25
+ return (
26
+ <TextField
27
+ label="Search"
28
+ placeholder="Search"
29
+ onChange={debouncedChangeHandler}
30
+ InputProps={{
31
+ endAdornment: (
32
+ <InputAdornment position="end">
33
+ <Search />
34
+ </InputAdornment>
35
+ ),
36
+ }}
37
+ {...restProps.textFieldProps}
38
+ />
39
+ )
40
+ }
@@ -18,7 +18,7 @@ const StyledTextField = styled(MuiTextField)(({ theme }) => ({
18
18
  },
19
19
  }))
20
20
 
21
- type TextFieldProps = {
21
+ export type ITextFieldProps = {
22
22
  containerProps?: BoxProps
23
23
  } & MuiTextFieldProps
24
24
 
@@ -30,7 +30,7 @@ export default function TextField({
30
30
  required = false,
31
31
  containerProps,
32
32
  ...rest
33
- }: TextFieldProps) {
33
+ }: ITextFieldProps) {
34
34
  return (
35
35
  <Box width="100%" {...containerProps}>
36
36
  <FieldLabel label={label} required={required} name={name} />
@@ -71,7 +71,7 @@ export default function DialogButton({
71
71
  fullWidth
72
72
  onClose={onClose}
73
73
  open={open}
74
- transitionDuration={100}
74
+ transitionDuration={140}
75
75
  TransitionComponent={Transition}
76
76
  sx={{
77
77
  '& .MuiBackdrop-root': {
@@ -1,6 +1,5 @@
1
1
  import { Close } from '@mui/icons-material'
2
2
  import {
3
- alpha,
4
3
  Box,
5
4
  ButtonProps,
6
5
  DialogTitle,
@@ -54,7 +53,7 @@ export default function DrawerButton({
54
53
  {anchor({ open: onOpen })}
55
54
  <Drawer
56
55
  anchor="right"
57
- elevation={10}
56
+ elevation={2}
58
57
  onClose={onClose}
59
58
  open={open}
60
59
  PaperProps={{
@@ -70,7 +69,7 @@ export default function DrawerButton({
70
69
  backgroundColor: 'rgba(0, 0, 0, 0.4)',
71
70
  },
72
71
  }}
73
- transitionDuration={200}
72
+ transitionDuration={140}
74
73
  >
75
74
  <StyledDrawerHeader>
76
75
  <DialogTitle>{title}</DialogTitle>
@@ -4,7 +4,7 @@ import ImageUpload from './ImageUpload'
4
4
  import FloatingContainer from './FloatingContainer'
5
5
  import TabsContainer from './Tabs/TabsContainer'
6
6
  import { StyledTableContainer } from './StyledTableContainer'
7
- import SearchBar from './SearchBar'
7
+ import SearchBar from './FilterComponents/SearchBar'
8
8
  import { DrawerButton, DialogButton } from './ModalButtons'
9
9
  import DetailsGrid from './DetailsGrid'
10
10
  import AppHeader from './Layout/Header'
@@ -1,61 +0,0 @@
1
- import { Search, Tune } from '@mui/icons-material'
2
- import { Box, InputAdornment, styled } from '@mui/material'
3
- import { useMemo, useState } from 'react'
4
- import _ from 'lodash'
5
- import { TextField } from './Input'
6
-
7
- interface SearchBarProps {
8
- onSearch: (v: string) => void
9
- filters?: {
10
- onClick: () => void
11
- }
12
- }
13
-
14
- const StyledButtonWrapper = styled(Box)(({ theme }) => ({
15
- width: '52px',
16
- border: theme.borders.grayLight,
17
- display: 'flex',
18
- alignItems: 'center',
19
- justifyContent: 'center',
20
- borderRadius: '10px',
21
- cursor: 'pointer',
22
- '&:active': {
23
- border: `1px solid ${theme.palette.primary.main}`,
24
- },
25
- transition: 'border 0.1s ease-in-out',
26
- }))
27
-
28
- export default function SearchBar({ onSearch, filters }: SearchBarProps) {
29
- const [, setSearch] = useState('')
30
-
31
- const debouncedChangeHandler = useMemo(
32
- () =>
33
- _.debounce((e) => {
34
- setSearch(e.target.value)
35
- setSearch(e.target.value)
36
- }, 300),
37
- [],
38
- )
39
-
40
- return (
41
- <Box sx={{ display: 'flex', gap: '20px' }}>
42
- <TextField
43
- sx={{ maxWidth: '600px' }}
44
- label="Search"
45
- onChange={debouncedChangeHandler}
46
- InputProps={{
47
- endAdornment: (
48
- <InputAdornment position="end">
49
- <Search />
50
- </InputAdornment>
51
- ),
52
- }}
53
- />
54
- {filters && (
55
- <StyledButtonWrapper onClick={filters?.onClick}>
56
- <Tune />
57
- </StyledButtonWrapper>
58
- )}
59
- </Box>
60
- )
61
- }