@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
66 lines (61 loc) • 1.45 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var jsxRuntime = require('react/jsx-runtime');
var utils = require('@rjsf/utils');
var react = require('react');
const FieldContext = react.createContext(null);
const useFieldContext = () => {
const context = react.useContext(FieldContext);
if (!context) {
throw new Error("FieldContext not found");
}
return context;
};
function FieldTemplate(props) {
const {
id,
children,
classNames,
style,
label,
help,
hidden,
registry,
schema,
uiSchema,
errors,
description,
...otherProps
} = props;
const uiOptions = utils.getUiOptions(uiSchema);
const WrapIfAdditionalTemplate = utils.getTemplate(
"WrapIfAdditionalTemplate",
registry,
uiOptions
);
if (hidden) {
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "none" }, children });
}
return /* @__PURE__ */ jsxRuntime.jsx(FieldContext.Provider, { value: { description }, children: /* @__PURE__ */ jsxRuntime.jsxs(
WrapIfAdditionalTemplate,
{
classNames,
style,
id,
label,
registry,
schema,
uiSchema,
...otherProps,
children: [
children,
errors,
help
]
}
) });
}
exports.FieldContext = FieldContext;
exports.default = FieldTemplate;
exports.useFieldContext = useFieldContext;
//# sourceMappingURL=FieldTemplate.cjs.map