mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-13 02:54:27 +00:00
fix-file-upload (#1583)
* handle file upload more like the way rjsf core is now handling it w/ burnettk * removed unused module w/ burnettk * use onChangeOverride if given w/ burnettk --------- Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
fc74924a6d
commit
a402bfc4fd
@ -5,16 +5,13 @@ import {
|
|||||||
RJSFSchema,
|
RJSFSchema,
|
||||||
StrictRJSFSchema,
|
StrictRJSFSchema,
|
||||||
WidgetProps,
|
WidgetProps,
|
||||||
|
examplesId,
|
||||||
|
ariaDescribedByIds,
|
||||||
} from '@rjsf/utils';
|
} from '@rjsf/utils';
|
||||||
import { parse } from 'date-fns';
|
|
||||||
|
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useDebouncedCallback } from 'use-debounce';
|
import { useDebouncedCallback } from 'use-debounce';
|
||||||
import {
|
import { DATE_FORMAT_CARBON, DATE_FORMAT_FOR_DISPLAY } from '../../../config';
|
||||||
DATE_FORMAT,
|
|
||||||
DATE_FORMAT_CARBON,
|
|
||||||
DATE_FORMAT_FOR_DISPLAY,
|
|
||||||
} from '../../../config';
|
|
||||||
import DateAndTimeService from '../../../services/DateAndTimeService';
|
import DateAndTimeService from '../../../services/DateAndTimeService';
|
||||||
import { getCommonAttributes } from '../../helpers';
|
import { getCommonAttributes } from '../../helpers';
|
||||||
|
|
||||||
@ -39,6 +36,7 @@ export default function BaseInputTemplate<
|
|||||||
onBlur,
|
onBlur,
|
||||||
onFocus,
|
onFocus,
|
||||||
onChange,
|
onChange,
|
||||||
|
onChangeOverride,
|
||||||
required,
|
required,
|
||||||
options,
|
options,
|
||||||
schema,
|
schema,
|
||||||
@ -154,6 +152,23 @@ export default function BaseInputTemplate<
|
|||||||
/>
|
/>
|
||||||
</DatePicker>
|
</DatePicker>
|
||||||
);
|
);
|
||||||
|
} else if (type === 'file') {
|
||||||
|
component = (
|
||||||
|
<input
|
||||||
|
id={id}
|
||||||
|
className="file-upload"
|
||||||
|
readOnly={readonly}
|
||||||
|
disabled={disabled}
|
||||||
|
autoFocus={autofocus}
|
||||||
|
value={value}
|
||||||
|
{...inputProps}
|
||||||
|
list={schema.examples ? examplesId<T>(id) : undefined}
|
||||||
|
onChange={onChangeOverride || _onChange}
|
||||||
|
onBlur={_onBlur}
|
||||||
|
onFocus={_onFocus}
|
||||||
|
aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
component = (
|
component = (
|
||||||
<>
|
<>
|
||||||
@ -165,9 +180,9 @@ export default function BaseInputTemplate<
|
|||||||
invalid={commonAttributes.invalid}
|
invalid={commonAttributes.invalid}
|
||||||
invalidText={commonAttributes.errorMessageForField}
|
invalidText={commonAttributes.errorMessageForField}
|
||||||
autoFocus={autofocus}
|
autoFocus={autofocus}
|
||||||
|
onChange={onChangeOverride || _onChange}
|
||||||
disabled={disabled || readonly}
|
disabled={disabled || readonly}
|
||||||
value={value || value === 0 ? value : ''}
|
value={value || value === 0 ? value : ''}
|
||||||
onChange={_onChange}
|
|
||||||
onBlur={_onBlur}
|
onBlur={_onBlur}
|
||||||
onFocus={_onFocus}
|
onFocus={_onFocus}
|
||||||
enableCounter={enableCounter}
|
enableCounter={enableCounter}
|
||||||
|
@ -44,6 +44,18 @@
|
|||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rjsf .file-upload {
|
||||||
|
padding-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
/* position the remove button to align with the file description */
|
||||||
|
.rjsf .file-info span div {
|
||||||
|
position: relative;
|
||||||
|
bottom: 6px;
|
||||||
|
left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.rjsf .rjsf-field label {
|
.rjsf .rjsf-field label {
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user