@rjsf/fluent-ui
Version:
Fluent UI theme, fields and widgets for react-jsonschema-form
57 lines • 2.57 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { TextField } from '@fluentui/react';
import { ariaDescribedByIds, examplesId, labelValue, getInputProps, } from '@rjsf/utils';
import _pick from 'lodash/pick';
// Keys of ITextFieldProps from @fluentui/react
const allowedProps = [
'multiline',
'resizable',
'autoAdjustHeight',
'underlined',
'borderless',
'label',
'onRenderLabel',
'description',
'onRenderDescription',
'prefix',
'suffix',
'onRenderPrefix',
'onRenderSuffix',
'iconProps',
'defaultValue',
'value',
'disabled',
'readOnly',
'errorMessage',
'onChange',
'onNotifyValidationResult',
'onGetErrorMessage',
'deferredValidationTime',
'className',
'inputClassName',
'ariaLabel',
'validateOnFocusIn',
'validateOnFocusOut',
'validateOnLoad',
'theme',
'styles',
'autoComplete',
'mask',
'maskChar',
'maskFormat',
'type',
'list',
];
export default function BaseInputTemplate({ id, placeholder, required, readonly, disabled, label, hideLabel, value, onChange, onChangeOverride, onBlur, onFocus, autofocus, options, schema, type, rawErrors, multiline, }) {
const inputProps = getInputProps(schema, type, options);
const _onChange = ({ target: { value } }) => onChange(value === '' ? options.emptyValue : value);
const _onBlur = ({ target }) => onBlur(id, target && target.value);
const _onFocus = ({ target }) => onFocus(id, target && target.value);
const uiProps = _pick(options.props || {}, allowedProps);
return (_jsxs(_Fragment, { children: [_jsx(TextField, { id: id, name: id, placeholder: placeholder, label: labelValue(label, hideLabel), autoFocus: autofocus, required: required, disabled: disabled, readOnly: readonly, multiline: multiline, ...inputProps, value: value || value === 0 ? value : '', onChange: onChangeOverride || _onChange, onBlur: _onBlur, onFocus: _onFocus, errorMessage: (rawErrors || []).join('\n'), list: schema.examples ? examplesId(id) : undefined, ...uiProps, "aria-describedby": ariaDescribedByIds(id, !!schema.examples) }), Array.isArray(schema.examples) && (_jsx("datalist", { id: examplesId(id), children: schema.examples
.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : [])
.map((example) => {
return _jsx("option", { value: example }, example);
}) }))] }));
}
//# sourceMappingURL=BaseInputTemplate.js.map