@arquimedes.co/eureka-forms 3.0.49-test → 3.0.50-test
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/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.js +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +1 -1
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +48 -17
- package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +16 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +8 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +8 -3
- package/package.json +1 -1
|
@@ -29,6 +29,6 @@ function MaterialDatePickerRangeStep({ step, editable, defaultValue }) {
|
|
|
29
29
|
}, [onChange]);
|
|
30
30
|
const [minDate, maxDate] = [safeDate(step.minDate), safeDate(step.maxDate)];
|
|
31
31
|
const dateRangeValue = value?.length === 2 ? [safeDate(value[0]) ?? null, safeDate(value[1]) ?? null] : [null, null];
|
|
32
|
-
return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDateRangePicker, { ...field, value: dateRangeValue, inputRef: ref, error: !!error, minDate: minDate, maxDate: maxDate, labelMargin: 0, onChange: handleChange, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
|
|
32
|
+
return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDateRangePicker, { ...field, value: dateRangeValue, inputRef: ref, error: !!error, minDate: minDate, maxDate: maxDate, labelMargin: 0, label: step.label, onChange: handleChange, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
|
|
33
33
|
}
|
|
34
34
|
export default MaterialDatePickerRangeStep;
|
|
@@ -64,6 +64,6 @@ function FileUploadComponent({ file, formStyle, error, editable, handleRemove, f
|
|
|
64
64
|
}
|
|
65
65
|
}, children: file.file?.name ?? file.fileName }), editable && (_jsx("div", { className: styles.deletBtn, onClick: () => {
|
|
66
66
|
handleRemove();
|
|
67
|
-
}, children: _jsx(CloseIcon, {
|
|
67
|
+
}, children: _jsx(CloseIcon, { size: 24 }) }))] }));
|
|
68
68
|
}
|
|
69
69
|
export default FileUploadComponent;
|
|
@@ -23,7 +23,23 @@ function FileUploadStep({ step, editable }) {
|
|
|
23
23
|
const { clearErrors } = useFormContext();
|
|
24
24
|
const [error, setError] = useState(undefined);
|
|
25
25
|
const [fileChange, setFileChange] = useState([]);
|
|
26
|
+
const [dragging, setDragging] = useState(false);
|
|
26
27
|
const inputRef = useRef(null);
|
|
28
|
+
const handleFiles = useCallback((files) => {
|
|
29
|
+
const maxFiles = files.filter((file) => file.size > maxSize);
|
|
30
|
+
if (maxFiles.length > 0) {
|
|
31
|
+
setError('El tamaño máximo de carga es de 30Mb.');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
setFileChange(files
|
|
35
|
+
.filter((file) => value.find((val) => val.file === file) === undefined)
|
|
36
|
+
.map((file) => ({
|
|
37
|
+
state: 'STARTING',
|
|
38
|
+
file,
|
|
39
|
+
postInfo: null,
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}, [value]);
|
|
27
43
|
const getLinks = useCallback(async (pFiles) => {
|
|
28
44
|
try {
|
|
29
45
|
const fileLinks = await getUploadUrls(pFiles.map((file) => file.file), idOrganization);
|
|
@@ -122,25 +138,40 @@ function FileUploadStep({ step, editable }) {
|
|
|
122
138
|
}
|
|
123
139
|
return '';
|
|
124
140
|
};
|
|
125
|
-
return (_jsxs("div", { className: styles.container +
|
|
141
|
+
return (_jsxs("div", { className: styles.container +
|
|
142
|
+
(error || !!fieldError ? ' Erk-error' : '') +
|
|
143
|
+
(dragging ? ' ' + styles.dragging : ''), style: {
|
|
126
144
|
minHeight: editable === false || postview ? undefined : '100px',
|
|
127
|
-
}, "data-testid": step.id,
|
|
145
|
+
}, "data-testid": step.id, onDragOver: (e) => {
|
|
146
|
+
if (!editable || postview)
|
|
147
|
+
return;
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
}, onDragEnter: (e) => {
|
|
150
|
+
if (!editable || postview)
|
|
151
|
+
return;
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
setDragging(true);
|
|
154
|
+
}, onDragLeave: (e) => {
|
|
155
|
+
if (!editable || postview)
|
|
156
|
+
return;
|
|
157
|
+
if (e.currentTarget.contains(e.relatedTarget))
|
|
158
|
+
return;
|
|
159
|
+
setDragging(false);
|
|
160
|
+
}, onDrop: (e) => {
|
|
161
|
+
if (!editable || postview)
|
|
162
|
+
return;
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
setDragging(false);
|
|
165
|
+
clearErrors(step.id);
|
|
166
|
+
setError(undefined);
|
|
167
|
+
const files = e.dataTransfer.files;
|
|
168
|
+
if (files && files.length > 0) {
|
|
169
|
+
handleFiles(Array.from(files));
|
|
170
|
+
}
|
|
171
|
+
}, children: [_jsx("div", { className: styles.labelLabel, children: step.label }), step.description && (_jsx("div", { className: styles.stepDescriptionLabel, style: { color: formStyle.descriptionTextColor }, children: step.description })), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: (e) => {
|
|
128
172
|
const files = e.target.files;
|
|
129
173
|
if (files) {
|
|
130
|
-
|
|
131
|
-
const maxFiles = filesArray.filter((file) => file.size > maxSize);
|
|
132
|
-
if (maxFiles.length > 0) {
|
|
133
|
-
setError('El tamaño máximo de carga es de 30Mb.');
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
setFileChange(filesArray
|
|
137
|
-
.filter((file) => value.find((val) => val.file === file) === undefined)
|
|
138
|
-
.map((file) => ({
|
|
139
|
-
state: 'STARTING',
|
|
140
|
-
file,
|
|
141
|
-
postInfo: null,
|
|
142
|
-
})));
|
|
143
|
-
}
|
|
174
|
+
handleFiles(Array.from(files));
|
|
144
175
|
inputRef.current.value = '';
|
|
145
176
|
}
|
|
146
177
|
}, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", { className: styles.btnContainer, children: [_jsx("input", { ref: ref, className: 'hidden-input' }), _jsx(ErkButton, { disabled: !editable || postview, text: 'Examinar' + (step.required ? ' *' : ''), onClick: () => {
|
|
@@ -152,7 +183,7 @@ function FileUploadStep({ step, editable }) {
|
|
|
152
183
|
input.click();
|
|
153
184
|
}
|
|
154
185
|
}
|
|
155
|
-
} })] }), _jsx("div", { className: styles.filesContainer, children: value.map((file, index) => (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!fieldError && file.state !== 'DONE') ||
|
|
186
|
+
} })] }), editable && !postview && (_jsx("div", { className: styles.dragHint, style: { color: formStyle.descriptionTextColor }, children: "o arrastra y suelta los archivos aqu\u00ED" })), _jsx("div", { className: styles.filesContainer, children: value.map((file, index) => (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!fieldError && file.state !== 'DONE') ||
|
|
156
187
|
file.state === 'ERROR', editable: editable && !postview, handleRemove: () => {
|
|
157
188
|
if (value.filter((val) => val.state === 'ERROR').length === 1) {
|
|
158
189
|
clearErrors(step.id);
|
package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css
CHANGED
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
text-overflow: ellipsis;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
.dragging {
|
|
36
|
+
border: 2px dashed currentColor;
|
|
37
|
+
border-radius: 10px;
|
|
38
|
+
opacity: 0.85;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
.filesInput {
|
|
36
42
|
display: none;
|
|
37
43
|
}
|
|
@@ -41,6 +47,16 @@
|
|
|
41
47
|
margin-bottom: 3px;
|
|
42
48
|
width: fit-content;
|
|
43
49
|
}
|
|
50
|
+
.dragHint {
|
|
51
|
+
font-size: 0.75rem;
|
|
52
|
+
margin-left: 14px;
|
|
53
|
+
margin-top: 4px;
|
|
54
|
+
opacity: 0.8;
|
|
55
|
+
-moz-user-select: none;
|
|
56
|
+
-webkit-user-select: none;
|
|
57
|
+
-ms-user-select: none;
|
|
58
|
+
user-select: none;
|
|
59
|
+
}
|
|
44
60
|
.errorMsg {
|
|
45
61
|
font-size: 0.75rem;
|
|
46
62
|
margin-top: 5px;
|
|
@@ -167,11 +167,16 @@ function CustomPickerField({ error, required, helperText, size = 'small', labelM
|
|
|
167
167
|
},
|
|
168
168
|
} }));
|
|
169
169
|
}
|
|
170
|
-
function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', labelMargin = 5, pickTime = false, inputRef,
|
|
170
|
+
function CustomDatePicker({ error, required, disabled, readOnly, helperText, size = 'small', labelMargin = 5, pickTime = false, inputRef, label,
|
|
171
171
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
172
172
|
orientation: _orientation, ...others }) {
|
|
173
|
+
// MUI X v9 no longer forwards `required` to the field-slot label when the field is a Material
|
|
174
|
+
// TextField (the legacy `slots.field` shape used here), so the required asterisk never renders.
|
|
175
|
+
// The picker's `label` does propagate to the field via the picker context, so bake the marker
|
|
176
|
+
// into the label to keep the required indicator visible.
|
|
177
|
+
const displayLabel = required && typeof label === 'string' ? `${label} *` : label;
|
|
173
178
|
if (pickTime) {
|
|
174
|
-
return (_jsx(StyledDateTimePicker, { ampm: true, size: size, reduceAnimations: true, ...others, disabled: disabled, readOnly: readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, slotProps: {
|
|
179
|
+
return (_jsx(StyledDateTimePicker, { ampm: true, size: size, reduceAnimations: true, ...others, label: displayLabel, disabled: disabled, readOnly: readOnly, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, slotProps: {
|
|
175
180
|
actionBar: {
|
|
176
181
|
actions: ['clear', 'accept'],
|
|
177
182
|
},
|
|
@@ -231,7 +236,7 @@ orientation: _orientation, ...others }) {
|
|
|
231
236
|
} }));
|
|
232
237
|
}
|
|
233
238
|
else {
|
|
234
|
-
return (_jsx(StyledDatePicker, { ...others, size: size, reduceAnimations: true, readOnly: readOnly, disabled: disabled, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
|
|
239
|
+
return (_jsx(StyledDatePicker, { ...others, label: displayLabel, size: size, reduceAnimations: true, readOnly: readOnly, disabled: disabled, defaultValue: required ? new Date() : undefined, showDaysOutsideCurrentMonth: true, views: ['year', 'month', 'day'], slotProps: {
|
|
235
240
|
actionBar: {
|
|
236
241
|
actions: ['clear', 'accept'],
|
|
237
242
|
},
|
|
@@ -124,7 +124,12 @@ const formatDate = (date, showYear) => {
|
|
|
124
124
|
return '';
|
|
125
125
|
return format(date, showYear ? 'PP' : 'dd MMM');
|
|
126
126
|
};
|
|
127
|
-
function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, inputRef, shortcuts, ...others }) {
|
|
127
|
+
function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = 'small', labelMargin = 5, value, onChange, inputRef, shortcuts, label, required, ...others }) {
|
|
128
|
+
// MUI X v9 no longer forwards `required` to the field-slot label when the field is a Material
|
|
129
|
+
// TextField (the legacy `slots.field` shape used here), so the required asterisk never renders.
|
|
130
|
+
// The picker's `label` does propagate to the field via the picker context, so bake the marker
|
|
131
|
+
// into the label to keep the required indicator visible.
|
|
132
|
+
const displayLabel = required && typeof label === 'string' ? `${label} *` : label;
|
|
128
133
|
const [startDate, endDate] = value ?? [null, null];
|
|
129
134
|
const hasCompleteRange = Boolean(startDate) && Boolean(endDate);
|
|
130
135
|
const showYear = startDate &&
|
|
@@ -135,7 +140,7 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
|
|
|
135
140
|
const formattedStartDate = formatDate(startDate, Boolean(showYear));
|
|
136
141
|
const formattedEndDate = formatDate(endDate, Boolean(showYear));
|
|
137
142
|
const toolbarText = hasCompleteRange ? `${formattedStartDate} – ${formattedEndDate}` : '– –';
|
|
138
|
-
return (_jsx(StyledDateRangePicker, { ...others, value: value, onChange: onChange, size: size, disabled: disabled, readOnly: readOnly, reduceAnimations: true, showDaysOutsideCurrentMonth: true, slots: {
|
|
143
|
+
return (_jsx(StyledDateRangePicker, { ...others, label: displayLabel, value: value, onChange: onChange, size: size, disabled: disabled, readOnly: readOnly, reduceAnimations: true, showDaysOutsideCurrentMonth: true, slots: {
|
|
139
144
|
field: CustomRangePickerField,
|
|
140
145
|
day: StyledDay,
|
|
141
146
|
dialog: StyledDialog,
|
|
@@ -178,7 +183,7 @@ function CustomDatePickerRange({ error, disabled, readOnly, helperText, size = '
|
|
|
178
183
|
field: {
|
|
179
184
|
size,
|
|
180
185
|
error,
|
|
181
|
-
required
|
|
186
|
+
required,
|
|
182
187
|
helperText,
|
|
183
188
|
labelMargin,
|
|
184
189
|
fullWidth: true,
|
package/package.json
CHANGED