@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
60 lines (57 loc) • 1.31 kB
JavaScript
import { jsx, jsxs } from 'react/jsx-runtime';
import { getUiOptions, getTemplate } from '@rjsf/utils';
import { createContext, useContext } from 'react';
const FieldContext = createContext(null);
const useFieldContext = () => {
const context = 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 = getUiOptions(uiSchema);
const WrapIfAdditionalTemplate = getTemplate(
"WrapIfAdditionalTemplate",
registry,
uiOptions
);
if (hidden) {
return /* @__PURE__ */ jsx("div", { style: { display: "none" }, children });
}
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: { description }, children: /* @__PURE__ */ jsxs(
WrapIfAdditionalTemplate,
{
classNames,
style,
id,
label,
registry,
schema,
uiSchema,
...otherProps,
children: [
children,
errors,
help
]
}
) });
}
export { FieldContext, FieldTemplate as default, useFieldContext };
//# sourceMappingURL=FieldTemplate.mjs.map