UNPKG

@chris-bellman/rjsf-mantine-5-theme

Version:

Mantine 5 theme, fields and widgets for react-jsonschema-form. Based on @aokiapp/rjsf-mantine-theme

71 lines (66 loc) 2.01 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var jsxRuntime = require('react/jsx-runtime'); var utils = require('@rjsf/utils'); var core = require('@mantine/core'); function WrapIfAdditionalTemplate(props) { const { children, classNames, style, disabled, id, label, onDropPropertyClick, onKeyChange, readonly, required, schema, uiSchema, registry } = props; const { templates, translateString } = registry; const { RemoveButton } = templates.ButtonTemplates; const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]); const { readonlyAsDisabled = true, wrapperStyle } = registry.formContext; const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema; if (!additional) { return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classNames ?? ""} armt-template-wia`, style, children }); } const handleBlur = ({ target }) => onKeyChange(target.value); return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classNames ?? ""} armt-template-wia`, style, children: /* @__PURE__ */ jsxRuntime.jsxs(core.Group, { align: "center", children: [ /* @__PURE__ */ jsxRuntime.jsx( core.TextInput, { label: keyLabel, required, defaultValue: label, disabled: disabled || readonlyAsDisabled && readonly, id, name: id, onBlur: !readonly ? handleBlur : void 0, style: wrapperStyle, type: "text" } ), /* @__PURE__ */ jsxRuntime.jsx( core.Box, { style: { flexGrow: 1 }, children } ), /* @__PURE__ */ jsxRuntime.jsx( RemoveButton, { className: "array-item-remove", disabled: disabled || readonly, onClick: onDropPropertyClick(label), uiSchema, registry } ) ] }) }, `${id}-key`); } exports.default = WrapIfAdditionalTemplate; //# sourceMappingURL=WrapIfAdditionalTemplate.cjs.map