@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
1 lines • 4.2 kB
Source Map (JSON)
{"version":3,"file":"ObjectFieldTemplate.mjs","sources":["../../src/templates/ObjectFieldTemplate.tsx"],"sourcesContent":["import { Fieldset, Group, Box } from '@mantine/core';\nimport {\n FormContextType,\n ObjectFieldTemplatePropertyType,\n ObjectFieldTemplateProps,\n RJSFSchema,\n StrictRJSFSchema,\n canExpand,\n getTemplate,\n getUiOptions,\n titleId,\n} from '@rjsf/utils';\nimport { useFieldContext } from './FieldTemplate';\n\n/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the\n * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all\n * the properties.\n *\n * @param props - The `ObjectFieldTemplateProps` for this component\n */\nexport default function ObjectFieldTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: ObjectFieldTemplateProps<T, S, F>) {\n const {\n disabled,\n formData,\n idSchema,\n onAddClick,\n properties,\n readonly,\n registry,\n required,\n schema,\n title,\n uiSchema,\n } = props;\n\n const { description } = useFieldContext();\n const options = getUiOptions<T, S, F>(uiSchema);\n const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, options);\n\n // Button templates are not overridden in the uiSchema\n const {\n ButtonTemplates: { AddButton },\n } = registry.templates;\n\n const classNames = options.classNames;\n\n const legendNode = (\n <Group gap='xs' className='armt-template-objectfield-legend'>\n {title && (\n <TitleFieldTemplate\n id={titleId<T>(idSchema)}\n title={title}\n required={required}\n schema={schema}\n uiSchema={uiSchema}\n registry={registry}\n />\n )}\n {description}\n </Group>\n );\n return (\n <Fieldset\n id={idSchema.$id}\n legend={legendNode}\n style={{\n width: '100%',\n }}\n className={`armt-template-objectfield ${classNames ?? ''}`}\n >\n <Box className='armt-template-objectfield-item'>\n {properties.map((prop: ObjectFieldTemplatePropertyType) => prop.content)}\n </Box>\n {canExpand<T, S, F>(schema, uiSchema, formData) && (\n <AddButton\n className='object-property-expand'\n onClick={onAddClick(schema)}\n disabled={disabled || readonly}\n uiSchema={uiSchema}\n registry={registry}\n />\n )}\n </Fieldset>\n );\n}\n"],"names":[],"mappings":";;;;;AAUe,SAAS,mBAAmB,CAAC,KAAK,EAAE;AACnD,EAAE,MAAM;AACR,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,UAAU;AACd,IAAI,UAAU;AACd,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,MAAM;AACV,IAAI,KAAK;AACT,IAAI,QAAQ;AACZ,GAAG,GAAG,KAAK,CAAC;AACZ,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,CAAC;AAC5C,EAAE,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AACzC,EAAE,MAAM,kBAAkB,GAAG,WAAW,CAAC,oBAAoB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAClF,EAAE,MAAM;AACR,IAAI,eAAe,EAAE,EAAE,SAAS,EAAE;AAClC,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC;AACzB,EAAE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;AACxC,EAAE,MAAM,UAAU,mBAAmB,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,kCAAkC,EAAE,QAAQ,EAAE;AACvH,IAAI,KAAK,oBAAoB,GAAG;AAChC,MAAM,kBAAkB;AACxB,MAAM;AACN,QAAQ,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;AAC7B,QAAQ,KAAK;AACb,QAAQ,QAAQ;AAChB,QAAQ,MAAM;AACd,QAAQ,QAAQ;AAChB,QAAQ,QAAQ;AAChB,OAAO;AACP,KAAK;AACL,IAAI,WAAW;AACf,GAAG,EAAE,CAAC,CAAC;AACP,EAAE,uBAAuB,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