@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
69 lines (64 loc) • 2.1 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var utils = require('@rjsf/utils');
var core = require('@mantine/core');
var createErrors = require('../utils/createErrors.cjs');
function RadioWidget(props) {
const {
id,
value,
required,
disabled,
readonly,
hideLabel,
label,
onChange,
onBlur,
onFocus,
options,
rawErrors,
hideError,
schema
} = props;
const { enumOptions, enumDisabled, emptyValue, inline } = options;
const _onChange = (nextValue) => {
onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
};
const _onBlur = () => onBlur(id, value);
const _onFocus = () => onFocus(id, value);
const description = options.description || schema.description;
return /* @__PURE__ */ jsxRuntime.jsx(
core.Radio.Group,
{
name: id,
label: utils.labelValue(label || void 0, hideLabel, false),
description,
required,
value: utils.enumOptionsIndexForValue(value, enumOptions, false),
onChange: _onChange,
onBlur: _onBlur,
onFocus: _onFocus,
error: createErrors.createErrors(rawErrors, hideError),
className: "armt-widget-radio",
children: /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { direction: inline ? "row" : "column", m: "xs", gap: "sm", children: enumOptions?.map((option, index) => {
const itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) !== -1;
return /* @__PURE__ */ jsxRuntime.jsx(
core.Radio,
{
id: utils.optionId(id, index),
name: id,
label: option.label,
value: utils.enumOptionsIndexForValue(option.value, enumOptions, false),
disabled: disabled || itemDisabled || readonly,
"aria-describedby": utils.ariaDescribedByIds(id),
description: option.schema?.description
},
index
);
}) })
}
);
}
exports.default = RadioWidget;
//# sourceMappingURL=RadioWidget.cjs.map