@zimyo/ui 1.1.4 → 1.1.5
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/Accordion/index.d.ts +34 -0
- package/dist/Accordion/index.esm.js +120 -0
- package/dist/Accordion/index.js +128 -0
- package/dist/Button/index.d.ts +15 -0
- package/dist/Button/index.esm.js +23 -0
- package/dist/Button/index.js +28 -0
- package/dist/Card/index.d.ts +41 -0
- package/dist/Card/index.esm.js +36 -0
- package/dist/Card/index.js +38 -0
- package/dist/Popover/index.d.ts +19 -0
- package/dist/Popover/index.esm.js +22 -0
- package/dist/Popover/index.js +27 -0
- package/dist/RadioGroup/index.d.ts +31 -0
- package/dist/RadioGroup/index.esm.js +91 -0
- package/dist/RadioGroup/index.js +96 -0
- package/dist/Select/index.d.ts +22 -0
- package/dist/Select/index.esm.js +62 -0
- package/dist/Select/index.js +67 -0
- package/dist/Switch/index.d.ts +14 -0
- package/dist/Switch/index.esm.js +9 -0
- package/dist/Switch/index.js +14 -0
- package/dist/Tabs/index.d.ts +36 -0
- package/dist/Tabs/index.esm.js +202 -0
- package/dist/Tabs/index.js +207 -0
- package/dist/TextInput/index.d.ts +18 -0
- package/dist/TextInput/index.esm.js +33 -0
- package/dist/TextInput/index.js +38 -0
- package/dist/Typography/index.d.ts +30 -0
- package/dist/Typography/index.esm.js +57 -0
- package/dist/Typography/index.js +66 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.esm.js +630 -0
- package/dist/index.js +652 -0
- package/dist/theme/index.d.ts +91 -0
- package/dist/theme/index.esm.js +237 -0
- package/dist/theme/index.js +242 -0
- package/package.json +2 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useTheme, FormControl, FormLabel, Typography, RadioGroup as RadioGroup$1, Box, FormControlLabel, Radio, FormHelperText } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
const RadioGroup = React.forwardRef(({ label, options = [], value, defaultValue, onChange, name, disabled = false, required = false, error = false, helperText, row = false, size = 'medium', color = 'primary', sx = {}, radioSx = {}, labelSx = {}, ...props }, ref) => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const [internalValue, setInternalValue] = React.useState(value || defaultValue || '');
|
|
8
|
+
// Sync with external value prop
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
if (value !== undefined) {
|
|
11
|
+
setInternalValue(value);
|
|
12
|
+
}
|
|
13
|
+
}, [value]);
|
|
14
|
+
const handleChange = (event) => {
|
|
15
|
+
const newValue = event.target.value;
|
|
16
|
+
if (value === undefined) {
|
|
17
|
+
setInternalValue(newValue);
|
|
18
|
+
}
|
|
19
|
+
onChange?.(newValue);
|
|
20
|
+
};
|
|
21
|
+
const currentValue = value !== undefined ? value : internalValue;
|
|
22
|
+
return (jsxs(FormControl, { ref: ref, component: "fieldset", variant: "standard", disabled: disabled, required: required, error: error, sx: {
|
|
23
|
+
borderRadius: '8px',
|
|
24
|
+
...sx,
|
|
25
|
+
}, ...props, children: [label && (jsxs(FormLabel, { component: "legend", sx: {
|
|
26
|
+
fontWeight: 500,
|
|
27
|
+
fontSize: size === 'small' ? '0.875rem' : '1rem',
|
|
28
|
+
color: disabled
|
|
29
|
+
? theme.palette.text.disabled
|
|
30
|
+
: error
|
|
31
|
+
? theme.palette.error.main
|
|
32
|
+
: theme.palette.text.primary,
|
|
33
|
+
'&.Mui-focused': {
|
|
34
|
+
color: error
|
|
35
|
+
? theme.palette.error.main
|
|
36
|
+
: `${theme.palette[color].main}`,
|
|
37
|
+
},
|
|
38
|
+
mb: 1,
|
|
39
|
+
...labelSx,
|
|
40
|
+
}, children: [label, required && (jsx(Typography, { component: "span", sx: {
|
|
41
|
+
color: theme.palette.error.main,
|
|
42
|
+
ml: 0.5,
|
|
43
|
+
fontSize: 'inherit',
|
|
44
|
+
}, children: "*" }))] })), jsx(RadioGroup$1, { name: name, value: currentValue, onChange: handleChange, row: row, sx: {
|
|
45
|
+
gap: size === 'small' ? 1 : 1.5,
|
|
46
|
+
'& .MuiFormControlLabel-root': {
|
|
47
|
+
marginLeft: 0,
|
|
48
|
+
marginRight: row ? 2 : 0,
|
|
49
|
+
},
|
|
50
|
+
}, children: options.map((option) => (jsx(Box, { children: jsx(FormControlLabel, { value: option.value, disabled: disabled || option.disabled, control: jsx(Radio, { size: size, color: color, sx: {
|
|
51
|
+
'&.Mui-checked': {
|
|
52
|
+
color: error
|
|
53
|
+
? theme.palette.error.main
|
|
54
|
+
: `${theme.palette[color].main}`,
|
|
55
|
+
},
|
|
56
|
+
alignSelf: option.description ? 'flex-start' : 'center',
|
|
57
|
+
mt: option.description ? 0.25 : 0,
|
|
58
|
+
...radioSx,
|
|
59
|
+
} }), label: jsxs(Box, { sx: { display: 'flex', flexDirection: 'column' }, children: [jsx(Typography, { variant: size === 'small' ? 'body2' : 'body1', sx: {
|
|
60
|
+
fontWeight: 400,
|
|
61
|
+
color: disabled || option.disabled
|
|
62
|
+
? theme.palette.text.disabled
|
|
63
|
+
: theme.palette.text.primary,
|
|
64
|
+
lineHeight: 1.5,
|
|
65
|
+
}, children: option.label }), option.description && (jsx(Typography, { variant: "caption", sx: {
|
|
66
|
+
color: disabled || option.disabled
|
|
67
|
+
? theme.palette.text.disabled
|
|
68
|
+
: theme.palette.text.secondary,
|
|
69
|
+
mt: 0.25,
|
|
70
|
+
lineHeight: 1.4,
|
|
71
|
+
}, children: option.description }))] }), sx: {
|
|
72
|
+
alignItems: option.description ? 'flex-start' : 'center',
|
|
73
|
+
margin: 0,
|
|
74
|
+
display: 'flex',
|
|
75
|
+
'& .MuiFormControlLabel-label': {
|
|
76
|
+
ml: 1,
|
|
77
|
+
flex: 1,
|
|
78
|
+
},
|
|
79
|
+
'& .MuiButtonBase-root': {
|
|
80
|
+
p: size === 'small' ? 0.5 : 1,
|
|
81
|
+
},
|
|
82
|
+
} }) }, option.value))) }), helperText && (jsx(FormHelperText, { sx: {
|
|
83
|
+
mt: 1,
|
|
84
|
+
fontSize: size === 'small' ? '0.75rem' : '0.875rem',
|
|
85
|
+
color: error
|
|
86
|
+
? theme.palette.error.main
|
|
87
|
+
: theme.palette.text.secondary,
|
|
88
|
+
}, children: helperText }))] }));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export { RadioGroup, RadioGroup as default };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var material = require('@mui/material');
|
|
8
|
+
|
|
9
|
+
const RadioGroup = React.forwardRef(({ label, options = [], value, defaultValue, onChange, name, disabled = false, required = false, error = false, helperText, row = false, size = 'medium', color = 'primary', sx = {}, radioSx = {}, labelSx = {}, ...props }, ref) => {
|
|
10
|
+
const theme = material.useTheme();
|
|
11
|
+
const [internalValue, setInternalValue] = React.useState(value || defaultValue || '');
|
|
12
|
+
// Sync with external value prop
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (value !== undefined) {
|
|
15
|
+
setInternalValue(value);
|
|
16
|
+
}
|
|
17
|
+
}, [value]);
|
|
18
|
+
const handleChange = (event) => {
|
|
19
|
+
const newValue = event.target.value;
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
setInternalValue(newValue);
|
|
22
|
+
}
|
|
23
|
+
onChange?.(newValue);
|
|
24
|
+
};
|
|
25
|
+
const currentValue = value !== undefined ? value : internalValue;
|
|
26
|
+
return (jsxRuntime.jsxs(material.FormControl, { ref: ref, component: "fieldset", variant: "standard", disabled: disabled, required: required, error: error, sx: {
|
|
27
|
+
borderRadius: '8px',
|
|
28
|
+
...sx,
|
|
29
|
+
}, ...props, children: [label && (jsxRuntime.jsxs(material.FormLabel, { component: "legend", sx: {
|
|
30
|
+
fontWeight: 500,
|
|
31
|
+
fontSize: size === 'small' ? '0.875rem' : '1rem',
|
|
32
|
+
color: disabled
|
|
33
|
+
? theme.palette.text.disabled
|
|
34
|
+
: error
|
|
35
|
+
? theme.palette.error.main
|
|
36
|
+
: theme.palette.text.primary,
|
|
37
|
+
'&.Mui-focused': {
|
|
38
|
+
color: error
|
|
39
|
+
? theme.palette.error.main
|
|
40
|
+
: `${theme.palette[color].main}`,
|
|
41
|
+
},
|
|
42
|
+
mb: 1,
|
|
43
|
+
...labelSx,
|
|
44
|
+
}, children: [label, required && (jsxRuntime.jsx(material.Typography, { component: "span", sx: {
|
|
45
|
+
color: theme.palette.error.main,
|
|
46
|
+
ml: 0.5,
|
|
47
|
+
fontSize: 'inherit',
|
|
48
|
+
}, children: "*" }))] })), jsxRuntime.jsx(material.RadioGroup, { name: name, value: currentValue, onChange: handleChange, row: row, sx: {
|
|
49
|
+
gap: size === 'small' ? 1 : 1.5,
|
|
50
|
+
'& .MuiFormControlLabel-root': {
|
|
51
|
+
marginLeft: 0,
|
|
52
|
+
marginRight: row ? 2 : 0,
|
|
53
|
+
},
|
|
54
|
+
}, children: options.map((option) => (jsxRuntime.jsx(material.Box, { children: jsxRuntime.jsx(material.FormControlLabel, { value: option.value, disabled: disabled || option.disabled, control: jsxRuntime.jsx(material.Radio, { size: size, color: color, sx: {
|
|
55
|
+
'&.Mui-checked': {
|
|
56
|
+
color: error
|
|
57
|
+
? theme.palette.error.main
|
|
58
|
+
: `${theme.palette[color].main}`,
|
|
59
|
+
},
|
|
60
|
+
alignSelf: option.description ? 'flex-start' : 'center',
|
|
61
|
+
mt: option.description ? 0.25 : 0,
|
|
62
|
+
...radioSx,
|
|
63
|
+
} }), label: jsxRuntime.jsxs(material.Box, { sx: { display: 'flex', flexDirection: 'column' }, children: [jsxRuntime.jsx(material.Typography, { variant: size === 'small' ? 'body2' : 'body1', sx: {
|
|
64
|
+
fontWeight: 400,
|
|
65
|
+
color: disabled || option.disabled
|
|
66
|
+
? theme.palette.text.disabled
|
|
67
|
+
: theme.palette.text.primary,
|
|
68
|
+
lineHeight: 1.5,
|
|
69
|
+
}, children: option.label }), option.description && (jsxRuntime.jsx(material.Typography, { variant: "caption", sx: {
|
|
70
|
+
color: disabled || option.disabled
|
|
71
|
+
? theme.palette.text.disabled
|
|
72
|
+
: theme.palette.text.secondary,
|
|
73
|
+
mt: 0.25,
|
|
74
|
+
lineHeight: 1.4,
|
|
75
|
+
}, children: option.description }))] }), sx: {
|
|
76
|
+
alignItems: option.description ? 'flex-start' : 'center',
|
|
77
|
+
margin: 0,
|
|
78
|
+
display: 'flex',
|
|
79
|
+
'& .MuiFormControlLabel-label': {
|
|
80
|
+
ml: 1,
|
|
81
|
+
flex: 1,
|
|
82
|
+
},
|
|
83
|
+
'& .MuiButtonBase-root': {
|
|
84
|
+
p: size === 'small' ? 0.5 : 1,
|
|
85
|
+
},
|
|
86
|
+
} }) }, option.value))) }), helperText && (jsxRuntime.jsx(material.FormHelperText, { sx: {
|
|
87
|
+
mt: 1,
|
|
88
|
+
fontSize: size === 'small' ? '0.75rem' : '0.875rem',
|
|
89
|
+
color: error
|
|
90
|
+
? theme.palette.error.main
|
|
91
|
+
: theme.palette.text.secondary,
|
|
92
|
+
}, children: helperText }))] }));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
exports.RadioGroup = RadioGroup;
|
|
96
|
+
exports.default = RadioGroup;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectProps as SelectProps$1, SelectChangeEvent } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
interface OptionType {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string | number;
|
|
7
|
+
}
|
|
8
|
+
interface SelectProps extends Omit<SelectProps$1, 'value' | 'onChange'> {
|
|
9
|
+
label?: string;
|
|
10
|
+
options: OptionType[];
|
|
11
|
+
error?: boolean;
|
|
12
|
+
helperText?: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
value?: any;
|
|
16
|
+
onChange?: (event: SelectChangeEvent<any>) => void;
|
|
17
|
+
isMulti?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<any>>;
|
|
20
|
+
|
|
21
|
+
export { Select, Select as default };
|
|
22
|
+
export type { SelectProps };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useTheme, FormControl, Select as Select$1, OutlinedInput, IconButton, MenuItem, ListItemText, FormHelperText, Box, Chip } from '@mui/material';
|
|
4
|
+
import { ExpandMore, Clear } from '@mui/icons-material';
|
|
5
|
+
|
|
6
|
+
const Select = React.forwardRef(({ label = '', options = [], value, onChange, error = false, helperText = '', required = false, placeholder = 'Select...', isMulti = false, disabled = false, ...rest }, ref) => {
|
|
7
|
+
useTheme();
|
|
8
|
+
const handleRemoveChip = (chipValue) => (e) => {
|
|
9
|
+
e.stopPropagation();
|
|
10
|
+
const newValue = value.filter((v) => v !== chipValue);
|
|
11
|
+
onChange?.({
|
|
12
|
+
target: {
|
|
13
|
+
name: rest.name,
|
|
14
|
+
value: newValue,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const renderValue = (selected) => {
|
|
19
|
+
if (isMulti && Array.isArray(selected)) {
|
|
20
|
+
return (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 }, children: selected.map((val) => {
|
|
21
|
+
const label = options.find((o) => o.value === val)?.label || val;
|
|
22
|
+
return jsx(Box, { onMouseDown: (e) => e.stopPropagation(), children: jsx(Chip, { onDelete: handleRemoveChip(val), label: label, sx: { borderRadius: '12px' } }) }, val);
|
|
23
|
+
}) }));
|
|
24
|
+
}
|
|
25
|
+
return options.find((o) => o.value === selected)?.label || placeholder;
|
|
26
|
+
};
|
|
27
|
+
const handleClearSelection = (e) => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
const emptyValue = isMulti ? [] : '';
|
|
30
|
+
onChange?.({
|
|
31
|
+
target: {
|
|
32
|
+
name: rest.name,
|
|
33
|
+
value: emptyValue,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return (jsxs(FormControl, { fullWidth: true, error: error, disabled: disabled, sx: {
|
|
38
|
+
'& .MuiOutlinedInput-root': {
|
|
39
|
+
borderRadius: '8px',
|
|
40
|
+
minHeight: '44px',
|
|
41
|
+
// backgroundColor: theme.palette.background.paper,
|
|
42
|
+
fontSize: '14px'
|
|
43
|
+
},
|
|
44
|
+
'& .MuiSelect-select': {
|
|
45
|
+
fontSize: '14px',
|
|
46
|
+
padding: '10px 14px',
|
|
47
|
+
},
|
|
48
|
+
'& .MuiSelect-placeholder': {
|
|
49
|
+
fontSize: '14px',
|
|
50
|
+
},
|
|
51
|
+
'& .MuiMenuItem-root': {
|
|
52
|
+
fontSize: '14px',
|
|
53
|
+
},
|
|
54
|
+
'& .MuiChip-label': {
|
|
55
|
+
fontSize: '14px',
|
|
56
|
+
},
|
|
57
|
+
}, children: [jsx(Select$1, { displayEmpty: true,
|
|
58
|
+
// labelId={labelId}
|
|
59
|
+
multiple: isMulti, value: value || (isMulti ? [] : ''), onChange: onChange, input: jsx(OutlinedInput, { label: label }), renderValue: renderValue, ref: ref, IconComponent: ExpandMore, endAdornment: value && !isMulti && ((isMulti && value.length > 0) || (!isMulti && value !== '')) ? (jsx(IconButton, { sx: { marginRight: '1rem' }, size: "small", onClick: handleClearSelection, children: jsx(Clear, { fontSize: "small" }) })) : null, variant: "outlined", ...rest, children: options && options.map((option) => (jsx(MenuItem, { value: option.value, children: isMulti ? (jsx(Fragment, { children: jsx(ListItemText, { primary: option.label }) })) : (option.label || placeholder) }, option.value))) }), helperText && jsx(FormHelperText, { children: helperText })] }));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export { Select, Select as default };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var material = require('@mui/material');
|
|
8
|
+
var iconsMaterial = require('@mui/icons-material');
|
|
9
|
+
|
|
10
|
+
const Select = React.forwardRef(({ label = '', options = [], value, onChange, error = false, helperText = '', required = false, placeholder = 'Select...', isMulti = false, disabled = false, ...rest }, ref) => {
|
|
11
|
+
material.useTheme();
|
|
12
|
+
const handleRemoveChip = (chipValue) => (e) => {
|
|
13
|
+
e.stopPropagation();
|
|
14
|
+
const newValue = value.filter((v) => v !== chipValue);
|
|
15
|
+
onChange?.({
|
|
16
|
+
target: {
|
|
17
|
+
name: rest.name,
|
|
18
|
+
value: newValue,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const renderValue = (selected) => {
|
|
23
|
+
if (isMulti && Array.isArray(selected)) {
|
|
24
|
+
return (jsxRuntime.jsx(material.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 }, children: selected.map((val) => {
|
|
25
|
+
const label = options.find((o) => o.value === val)?.label || val;
|
|
26
|
+
return jsxRuntime.jsx(material.Box, { onMouseDown: (e) => e.stopPropagation(), children: jsxRuntime.jsx(material.Chip, { onDelete: handleRemoveChip(val), label: label, sx: { borderRadius: '12px' } }) }, val);
|
|
27
|
+
}) }));
|
|
28
|
+
}
|
|
29
|
+
return options.find((o) => o.value === selected)?.label || placeholder;
|
|
30
|
+
};
|
|
31
|
+
const handleClearSelection = (e) => {
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
const emptyValue = isMulti ? [] : '';
|
|
34
|
+
onChange?.({
|
|
35
|
+
target: {
|
|
36
|
+
name: rest.name,
|
|
37
|
+
value: emptyValue,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return (jsxRuntime.jsxs(material.FormControl, { fullWidth: true, error: error, disabled: disabled, sx: {
|
|
42
|
+
'& .MuiOutlinedInput-root': {
|
|
43
|
+
borderRadius: '8px',
|
|
44
|
+
minHeight: '44px',
|
|
45
|
+
// backgroundColor: theme.palette.background.paper,
|
|
46
|
+
fontSize: '14px'
|
|
47
|
+
},
|
|
48
|
+
'& .MuiSelect-select': {
|
|
49
|
+
fontSize: '14px',
|
|
50
|
+
padding: '10px 14px',
|
|
51
|
+
},
|
|
52
|
+
'& .MuiSelect-placeholder': {
|
|
53
|
+
fontSize: '14px',
|
|
54
|
+
},
|
|
55
|
+
'& .MuiMenuItem-root': {
|
|
56
|
+
fontSize: '14px',
|
|
57
|
+
},
|
|
58
|
+
'& .MuiChip-label': {
|
|
59
|
+
fontSize: '14px',
|
|
60
|
+
},
|
|
61
|
+
}, children: [jsxRuntime.jsx(material.Select, { displayEmpty: true,
|
|
62
|
+
// labelId={labelId}
|
|
63
|
+
multiple: isMulti, value: value || (isMulti ? [] : ''), onChange: onChange, input: jsxRuntime.jsx(material.OutlinedInput, { label: label }), renderValue: renderValue, ref: ref, IconComponent: iconsMaterial.ExpandMore, endAdornment: value && !isMulti && ((isMulti && value.length > 0) || (!isMulti && value !== '')) ? (jsxRuntime.jsx(material.IconButton, { sx: { marginRight: '1rem' }, size: "small", onClick: handleClearSelection, children: jsxRuntime.jsx(iconsMaterial.Clear, { fontSize: "small" }) })) : null, variant: "outlined", ...rest, children: options && options.map((option) => (jsxRuntime.jsx(material.MenuItem, { value: option.value, children: isMulti ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(material.ListItemText, { primary: option.label }) })) : (option.label || placeholder) }, option.value))) }), helperText && jsxRuntime.jsx(material.FormHelperText, { children: helperText })] }));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
exports.Select = Select;
|
|
67
|
+
exports.default = Select;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SwitchProps as SwitchProps$1 } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
interface SwitchProps extends Omit<SwitchProps$1, 'onChange'> {
|
|
5
|
+
label?: string;
|
|
6
|
+
helperText?: string;
|
|
7
|
+
error?: boolean;
|
|
8
|
+
required?: boolean | number;
|
|
9
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
|
|
13
|
+
export { Switch, Switch as default };
|
|
14
|
+
export type { SwitchProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FormControl, FormControlLabel, Switch as Switch$1, FormHelperText } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
const Switch = React.forwardRef(({ label = '', helperText = '', error = false, onChange, checked, required = false, disabled = false, ...rest }, ref) => {
|
|
6
|
+
return (jsxs(FormControl, { error: error, disabled: disabled, component: "fieldset", children: [jsx(FormControlLabel, { control: jsx(Switch$1, { inputRef: ref, checked: checked, onChange: (e, checked) => onChange?.(e, checked), disabled: disabled, required: required == 1 || required === true ? true : false, ...rest }), label: label }), helperText && jsx(FormHelperText, { children: helperText })] }));
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { Switch, Switch as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var material = require('@mui/material');
|
|
8
|
+
|
|
9
|
+
const Switch = React.forwardRef(({ label = '', helperText = '', error = false, onChange, checked, required = false, disabled = false, ...rest }, ref) => {
|
|
10
|
+
return (jsxRuntime.jsxs(material.FormControl, { error: error, disabled: disabled, component: "fieldset", children: [jsxRuntime.jsx(material.FormControlLabel, { control: jsxRuntime.jsx(material.Switch, { inputRef: ref, checked: checked, onChange: (e, checked) => onChange?.(e, checked), disabled: disabled, required: required == 1 || required === true ? true : false, ...rest }), label: label }), helperText && jsxRuntime.jsx(material.FormHelperText, { children: helperText })] }));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports.Switch = Switch;
|
|
14
|
+
exports.default = Switch;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TabProps, TabsProps as TabsProps$1 } from '@mui/material';
|
|
3
|
+
import { SxProps, Theme } from '@mui/system';
|
|
4
|
+
|
|
5
|
+
interface TabItem {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string | number;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
badge?: string | number;
|
|
11
|
+
}
|
|
12
|
+
interface CustomTabProps extends Omit<TabProps, 'sx'> {
|
|
13
|
+
sx?: SxProps<Theme>;
|
|
14
|
+
badge?: string | number;
|
|
15
|
+
}
|
|
16
|
+
interface TabsProps extends Omit<TabsProps$1, 'children' | 'sx' | 'indicatorColor' | 'textColor'> {
|
|
17
|
+
items: TabItem[];
|
|
18
|
+
value: string | number;
|
|
19
|
+
onChange: (event: React.SyntheticEvent, newValue: string | number) => void;
|
|
20
|
+
variant?: 'standard' | 'scrollable' | 'fullWidth';
|
|
21
|
+
orientation?: 'horizontal' | 'vertical';
|
|
22
|
+
styleVariant?: 'default' | 'filled' | 'outlined' | 'pills' | 'underlined';
|
|
23
|
+
size?: 'small' | 'medium' | 'large';
|
|
24
|
+
centered?: boolean;
|
|
25
|
+
allowScrollButtonsMobile?: boolean;
|
|
26
|
+
scrollButtons?: boolean | 'auto';
|
|
27
|
+
sx?: SxProps<Theme>;
|
|
28
|
+
tabSx?: SxProps<Theme>;
|
|
29
|
+
iconPosition?: 'start' | 'end' | 'top' | 'bottom';
|
|
30
|
+
indicatorColor?: TabsProps$1['indicatorColor'];
|
|
31
|
+
textColor?: TabsProps$1['textColor'];
|
|
32
|
+
}
|
|
33
|
+
declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
+
|
|
35
|
+
export { Tabs, Tabs as default };
|
|
36
|
+
export type { CustomTabProps, TabItem, TabsProps };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme, Box, Tab, Tabs as Tabs$1, alpha } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
// Custom Tab Component
|
|
5
|
+
const CustomTab = React.forwardRef(({ badge, sx, label, ...props }, ref) => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const tabLabel = badge ? React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 } }, label, React.createElement(Box, {
|
|
8
|
+
component: 'span',
|
|
9
|
+
sx: {
|
|
10
|
+
backgroundColor: theme.palette.error.main,
|
|
11
|
+
color: theme.palette.error.contrastText,
|
|
12
|
+
borderRadius: '10px',
|
|
13
|
+
padding: '2px 6px',
|
|
14
|
+
fontSize: '0.75rem',
|
|
15
|
+
fontWeight: 600,
|
|
16
|
+
minWidth: '18px',
|
|
17
|
+
height: '18px',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
lineHeight: 1,
|
|
22
|
+
}
|
|
23
|
+
}, badge)) : label;
|
|
24
|
+
return React.createElement(Tab, {
|
|
25
|
+
ref,
|
|
26
|
+
sx: {
|
|
27
|
+
position: 'relative',
|
|
28
|
+
...sx,
|
|
29
|
+
},
|
|
30
|
+
label: tabLabel,
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
CustomTab.displayName = 'CustomTab';
|
|
35
|
+
// Main Tabs Component
|
|
36
|
+
const Tabs = React.forwardRef(({ items, value, onChange, variant = 'standard', orientation = 'horizontal', styleVariant = 'default', size = 'medium', centered = false, allowScrollButtonsMobile = false, scrollButtons = 'auto', sx = {}, tabSx = {}, iconPosition = 'start', indicatorColor = 'primary', textColor = 'primary', ...props }, ref) => {
|
|
37
|
+
const theme = useTheme();
|
|
38
|
+
// Get size-based styling
|
|
39
|
+
const getSizeStyles = () => {
|
|
40
|
+
switch (size) {
|
|
41
|
+
case 'small':
|
|
42
|
+
return {
|
|
43
|
+
minHeight: 36,
|
|
44
|
+
fontSize: '0.875rem',
|
|
45
|
+
padding: '6px 12px',
|
|
46
|
+
};
|
|
47
|
+
case 'large':
|
|
48
|
+
return {
|
|
49
|
+
minHeight: 56,
|
|
50
|
+
fontSize: '1rem',
|
|
51
|
+
padding: '12px 24px',
|
|
52
|
+
};
|
|
53
|
+
default:
|
|
54
|
+
return {
|
|
55
|
+
minHeight: 48,
|
|
56
|
+
fontSize: '0.9375rem',
|
|
57
|
+
padding: '8px 16px',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Get style variant specific styling
|
|
62
|
+
const getStyleVariantStyles = () => {
|
|
63
|
+
const baseStyles = getSizeStyles();
|
|
64
|
+
switch (styleVariant) {
|
|
65
|
+
case 'filled':
|
|
66
|
+
return {
|
|
67
|
+
'& .MuiTab-root': {
|
|
68
|
+
...baseStyles,
|
|
69
|
+
backgroundColor: alpha(theme.palette.action.hover, 0.08),
|
|
70
|
+
borderRadius: theme.shape.borderRadius,
|
|
71
|
+
margin: '0 4px',
|
|
72
|
+
border: 'none',
|
|
73
|
+
'&.Mui-selected': {
|
|
74
|
+
backgroundColor: theme.palette.primary.main,
|
|
75
|
+
color: theme.palette.primary.contrastText,
|
|
76
|
+
},
|
|
77
|
+
'&:hover': {
|
|
78
|
+
backgroundColor: alpha(theme.palette.action.hover, 0.12),
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
'& .MuiTabs-indicator': {
|
|
82
|
+
display: 'none',
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
case 'outlined':
|
|
86
|
+
return {
|
|
87
|
+
'& .MuiTab-root': {
|
|
88
|
+
...baseStyles,
|
|
89
|
+
border: `1px solid ${alpha(theme.palette.divider, 0.5)}`,
|
|
90
|
+
borderRadius: theme.shape.borderRadius,
|
|
91
|
+
margin: '0 2px',
|
|
92
|
+
'&.Mui-selected': {
|
|
93
|
+
borderColor: theme.palette.primary.main,
|
|
94
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.08),
|
|
95
|
+
color: theme.palette.primary.main,
|
|
96
|
+
},
|
|
97
|
+
'&:hover': {
|
|
98
|
+
borderColor: alpha(theme.palette.primary.main, 0.5),
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
'& .MuiTabs-indicator': {
|
|
102
|
+
display: 'none',
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
case 'pills':
|
|
106
|
+
return {
|
|
107
|
+
'& .MuiTab-root': {
|
|
108
|
+
...baseStyles,
|
|
109
|
+
borderRadius: 25,
|
|
110
|
+
margin: '0 4px',
|
|
111
|
+
backgroundColor: 'transparent',
|
|
112
|
+
border: `1px solid transparent`,
|
|
113
|
+
'&.Mui-selected': {
|
|
114
|
+
backgroundColor: theme.palette.primary.main,
|
|
115
|
+
color: theme.palette.primary.contrastText,
|
|
116
|
+
},
|
|
117
|
+
'&:hover': {
|
|
118
|
+
backgroundColor: alpha(theme.palette.action.hover, 0.08),
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
'& .MuiTabs-indicator': {
|
|
122
|
+
display: 'none',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
case 'underlined':
|
|
126
|
+
return {
|
|
127
|
+
'& .MuiTab-root': {
|
|
128
|
+
...baseStyles,
|
|
129
|
+
borderBottom: `2px solid transparent`,
|
|
130
|
+
'&.Mui-selected': {
|
|
131
|
+
borderBottomColor: theme.palette.primary.main,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
'& .MuiTabs-indicator': {
|
|
135
|
+
display: 'none',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
default:
|
|
139
|
+
return {
|
|
140
|
+
'& .MuiTab-root': {
|
|
141
|
+
...baseStyles,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
return React.createElement(Box, { ref }, React.createElement(Tabs$1, {
|
|
147
|
+
value,
|
|
148
|
+
onChange,
|
|
149
|
+
variant,
|
|
150
|
+
orientation,
|
|
151
|
+
centered,
|
|
152
|
+
allowScrollButtonsMobile,
|
|
153
|
+
scrollButtons,
|
|
154
|
+
indicatorColor,
|
|
155
|
+
textColor,
|
|
156
|
+
sx: {
|
|
157
|
+
...getStyleVariantStyles(),
|
|
158
|
+
'& .MuiTab-root': {
|
|
159
|
+
textTransform: 'none',
|
|
160
|
+
fontWeight: 500,
|
|
161
|
+
letterSpacing: '0.5px',
|
|
162
|
+
transition: 'all 0.2s ease-in-out',
|
|
163
|
+
...getStyleVariantStyles()['& .MuiTab-root'],
|
|
164
|
+
...tabSx,
|
|
165
|
+
},
|
|
166
|
+
...sx,
|
|
167
|
+
},
|
|
168
|
+
...props,
|
|
169
|
+
}, ...items.map((item) => {
|
|
170
|
+
// Create the label content based on icon position
|
|
171
|
+
let labelContent;
|
|
172
|
+
if (item.icon) {
|
|
173
|
+
switch (iconPosition) {
|
|
174
|
+
case 'end':
|
|
175
|
+
labelContent = React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, flexDirection: 'row-reverse' } }, item.icon, item.label);
|
|
176
|
+
break;
|
|
177
|
+
case 'top':
|
|
178
|
+
labelContent = React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 0.5, flexDirection: 'column' } }, item.icon, item.label);
|
|
179
|
+
break;
|
|
180
|
+
case 'bottom':
|
|
181
|
+
labelContent = React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 0.5, flexDirection: 'column-reverse' } }, item.icon, item.label);
|
|
182
|
+
break;
|
|
183
|
+
default: // 'start'
|
|
184
|
+
labelContent = React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 } }, item.icon, item.label);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
labelContent = item.label;
|
|
190
|
+
}
|
|
191
|
+
return React.createElement(CustomTab, {
|
|
192
|
+
key: item.value,
|
|
193
|
+
value: item.value,
|
|
194
|
+
disabled: item.disabled,
|
|
195
|
+
badge: item.badge,
|
|
196
|
+
label: labelContent,
|
|
197
|
+
});
|
|
198
|
+
})));
|
|
199
|
+
});
|
|
200
|
+
Tabs.displayName = 'Tabs';
|
|
201
|
+
|
|
202
|
+
export { Tabs, Tabs as default };
|