@campxdev/react-blueprint 1.7.16 → 1.7.17
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 +1 -1
- package/src/components/Input/FileUpload/FileUpload.tsx +46 -36
- package/src/components/Input/FormControlWrapper/FormControlWrapper.tsx +5 -1
- package/src/components/Navigation/PreviewFiles/PreviewFiles.tsx +3 -1
- package/src/stories/Navigation/ManageFilters.stories.tsx +0 -116
package/package.json
CHANGED
|
@@ -4,11 +4,10 @@ import {
|
|
|
4
4
|
Stack,
|
|
5
5
|
styled,
|
|
6
6
|
SxProps,
|
|
7
|
-
useTheme,
|
|
8
7
|
useMediaQuery,
|
|
8
|
+
useTheme,
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
import { IconButtons, Icons, PreviewFiles, Typography } from '../../export';
|
|
11
|
-
import { alpha } from '@mui/system';
|
|
12
11
|
|
|
13
12
|
export type FileUploadProps = {
|
|
14
13
|
label: string;
|
|
@@ -22,6 +21,7 @@ export type FileUploadProps = {
|
|
|
22
21
|
inputText?: string;
|
|
23
22
|
multiple?: boolean;
|
|
24
23
|
hideDeleteButton?: boolean;
|
|
24
|
+
hideInput?: boolean;
|
|
25
25
|
errorText?: string;
|
|
26
26
|
sx?: SxProps;
|
|
27
27
|
showImage?: boolean;
|
|
@@ -40,6 +40,7 @@ export const FileUpload = ({
|
|
|
40
40
|
inputText,
|
|
41
41
|
onInvalidFile,
|
|
42
42
|
hideDeleteButton = false,
|
|
43
|
+
hideInput = false,
|
|
43
44
|
multiple = true,
|
|
44
45
|
errorText,
|
|
45
46
|
showImage,
|
|
@@ -81,6 +82,7 @@ export const FileUpload = ({
|
|
|
81
82
|
onChange([validFiles[0]]);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
85
|
+
event.target.value = ''; //Resets value after selection
|
|
84
86
|
}
|
|
85
87
|
};
|
|
86
88
|
|
|
@@ -93,40 +95,47 @@ export const FileUpload = ({
|
|
|
93
95
|
{' *'}
|
|
94
96
|
</span>
|
|
95
97
|
)}
|
|
96
|
-
</Typography>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
98
|
+
</Typography>
|
|
99
|
+
{!hideInput && (
|
|
100
|
+
<>
|
|
101
|
+
<input
|
|
102
|
+
accept={accept}
|
|
103
|
+
style={{ display: 'none' }}
|
|
104
|
+
id={name}
|
|
105
|
+
name={name}
|
|
106
|
+
type="file"
|
|
107
|
+
multiple={multiple}
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
onChange={handleFileChange}
|
|
110
|
+
/>
|
|
111
|
+
<FormLabel htmlFor={name}>
|
|
112
|
+
<StyledFileSelectorContainer>
|
|
113
|
+
<Stack display={'flex'} alignItems={'center'}>
|
|
114
|
+
<Icons.ExportIcon size={20} />
|
|
115
|
+
<Typography
|
|
116
|
+
color={theme.palette.text.tertiary}
|
|
117
|
+
variant="label2"
|
|
118
|
+
>
|
|
119
|
+
{inputText ?? 'Upload Files'}
|
|
120
|
+
</Typography>
|
|
121
|
+
</Stack>
|
|
122
|
+
</StyledFileSelectorContainer>
|
|
123
|
+
{errorText && (
|
|
124
|
+
<Typography
|
|
125
|
+
sx={{
|
|
126
|
+
display: 'flex',
|
|
127
|
+
alignItems: 'flex-end',
|
|
128
|
+
justifyContent: 'flex-end',
|
|
129
|
+
color: theme.palette.highlight.highlightRed,
|
|
130
|
+
}}
|
|
131
|
+
variant="caption"
|
|
132
|
+
>
|
|
133
|
+
{errorText}
|
|
134
|
+
</Typography>
|
|
135
|
+
)}
|
|
136
|
+
</FormLabel>
|
|
137
|
+
</>
|
|
138
|
+
)}
|
|
130
139
|
<Box display="flex" gap="12px" flexWrap="wrap">
|
|
131
140
|
{showImage ? (
|
|
132
141
|
files.map((file, index) => (
|
|
@@ -181,6 +190,7 @@ export const FileUpload = ({
|
|
|
181
190
|
sx={previewSx}
|
|
182
191
|
files={files}
|
|
183
192
|
onChange={(newFiles) => onChange?.(newFiles)}
|
|
193
|
+
hideDelete={hideDeleteButton}
|
|
184
194
|
/>
|
|
185
195
|
</Box>
|
|
186
196
|
)}
|
|
@@ -10,6 +10,7 @@ interface FormControlWrapperProps<T extends FieldValues = FieldValues> {
|
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
containerSx?: SxProps;
|
|
12
12
|
formActionProps?: FormActionsProps;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type FormElementProps = {
|
|
@@ -32,6 +33,7 @@ export function FormControlWrapper<T extends FieldValues = FieldValues>({
|
|
|
32
33
|
children,
|
|
33
34
|
containerSx,
|
|
34
35
|
formActionProps,
|
|
36
|
+
disabled = false,
|
|
35
37
|
}: FormControlWrapperProps<T>) {
|
|
36
38
|
const wrapWithController = (
|
|
37
39
|
element: ReactElement<any>,
|
|
@@ -56,13 +58,14 @@ export function FormControlWrapper<T extends FieldValues = FieldValues>({
|
|
|
56
58
|
files: field.value || [],
|
|
57
59
|
...field,
|
|
58
60
|
errorText: error ? error.message : undefined,
|
|
61
|
+
disabled,
|
|
59
62
|
} as FileUploadProps);
|
|
60
63
|
}
|
|
61
64
|
const additionalProps =
|
|
62
65
|
element.type === 'input' && restProps.type === 'checkbox'
|
|
63
66
|
? { checked: field.value }
|
|
64
67
|
: { value: field.value };
|
|
65
|
-
|
|
68
|
+
|
|
66
69
|
return React.cloneElement(element, {
|
|
67
70
|
...restProps,
|
|
68
71
|
...field,
|
|
@@ -70,6 +73,7 @@ export function FormControlWrapper<T extends FieldValues = FieldValues>({
|
|
|
70
73
|
error: !!error,
|
|
71
74
|
helperText: error ? error.message : null,
|
|
72
75
|
children: childElements,
|
|
76
|
+
disabled,
|
|
73
77
|
} as FormElementProps);
|
|
74
78
|
}}
|
|
75
79
|
/>
|
|
@@ -16,6 +16,7 @@ export type PreviewFilesProps = {
|
|
|
16
16
|
label?: string;
|
|
17
17
|
onChange?: (newFiles: File[], deletedFile: File) => void;
|
|
18
18
|
showDownload?: boolean;
|
|
19
|
+
hideDelete?: boolean;
|
|
19
20
|
sx?: SxProps;
|
|
20
21
|
} & Omit<BoxProps, 'onChange'>;
|
|
21
22
|
|
|
@@ -24,6 +25,7 @@ export const PreviewFiles = ({
|
|
|
24
25
|
label,
|
|
25
26
|
onChange,
|
|
26
27
|
showDownload,
|
|
28
|
+
hideDelete = false,
|
|
27
29
|
sx,
|
|
28
30
|
...props
|
|
29
31
|
}: PreviewFilesProps) => {
|
|
@@ -135,7 +137,7 @@ export const PreviewFiles = ({
|
|
|
135
137
|
<Icons.DownloadIcon />
|
|
136
138
|
</IconButton>
|
|
137
139
|
)}
|
|
138
|
-
{onChange && (
|
|
140
|
+
{onChange && !hideDelete && (
|
|
139
141
|
<IconButton
|
|
140
142
|
onClick={() => {
|
|
141
143
|
onChange(
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from '@storybook/react';
|
|
2
|
-
import { ReactNode, useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
ManageFilters,
|
|
5
|
-
ManageFiltersProps,
|
|
6
|
-
SingleSelect,
|
|
7
|
-
TextField,
|
|
8
|
-
} from '../../components/export';
|
|
9
|
-
import { RadioGroup } from '../../components/Input/RadioGroup/RadioGroup';
|
|
10
|
-
|
|
11
|
-
const meta: Meta<typeof ManageFilters> = {
|
|
12
|
-
title: 'Navigation/ManageFilters',
|
|
13
|
-
component: ManageFilters,
|
|
14
|
-
argTypes: {
|
|
15
|
-
options: {
|
|
16
|
-
control: { type: 'object' },
|
|
17
|
-
description: 'Array of filter options with labels and values.',
|
|
18
|
-
},
|
|
19
|
-
onChange: {
|
|
20
|
-
action: 'changed',
|
|
21
|
-
description: 'Callback when the selected values change.',
|
|
22
|
-
},
|
|
23
|
-
menuProps: {
|
|
24
|
-
control: { type: 'object' },
|
|
25
|
-
description: 'Props to customize the MUI Menu component.',
|
|
26
|
-
},
|
|
27
|
-
menuListProps: {
|
|
28
|
-
control: { type: 'object' },
|
|
29
|
-
description: 'Props to customize the MUI MenuList component.',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
parameters: {
|
|
33
|
-
controls: { expanded: true },
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default meta;
|
|
38
|
-
|
|
39
|
-
const Template: StoryFn<ManageFiltersProps> = (args) => {
|
|
40
|
-
const [selectedValues, setSelectedValues] = useState<ReactNode[]>([]);
|
|
41
|
-
|
|
42
|
-
const handleOnChange = (values: ReactNode[]) => {
|
|
43
|
-
setSelectedValues(values);
|
|
44
|
-
args.onChange(values);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
<ManageFilters {...args} onChange={handleOnChange} />
|
|
50
|
-
<div>
|
|
51
|
-
{selectedValues.length > 0 ? (
|
|
52
|
-
<ul>{selectedValues.map((value, index) => value)}</ul>
|
|
53
|
-
) : (
|
|
54
|
-
<p>No values selected.</p>
|
|
55
|
-
)}
|
|
56
|
-
</div>
|
|
57
|
-
</>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const Default = Template.bind({});
|
|
62
|
-
Default.args = {
|
|
63
|
-
options: [
|
|
64
|
-
{
|
|
65
|
-
label: 'Option 1',
|
|
66
|
-
value: (
|
|
67
|
-
<SingleSelect
|
|
68
|
-
onChange={() => {}}
|
|
69
|
-
options={[
|
|
70
|
-
{
|
|
71
|
-
label: 'done',
|
|
72
|
-
value: 'done',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
label: 'processing',
|
|
76
|
-
value: 'processing',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
label: 'onHold',
|
|
80
|
-
value: 'onHold',
|
|
81
|
-
},
|
|
82
|
-
]}
|
|
83
|
-
/>
|
|
84
|
-
),
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: 'text Filed',
|
|
88
|
-
value: <TextField sx={{ width: '250px' }} />,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: 'Radio Group',
|
|
92
|
-
value: (
|
|
93
|
-
<RadioGroup
|
|
94
|
-
options={[
|
|
95
|
-
{
|
|
96
|
-
label: 'done',
|
|
97
|
-
value: 'done',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: 'processing',
|
|
101
|
-
value: 'processing',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
label: 'onHold',
|
|
105
|
-
value: 'onHold',
|
|
106
|
-
},
|
|
107
|
-
]}
|
|
108
|
-
label={''}
|
|
109
|
-
required={false}
|
|
110
|
-
name={''}
|
|
111
|
-
disabled={false}
|
|
112
|
-
/>
|
|
113
|
-
),
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
};
|