Skip to content

Commit 9516dec

Browse files
authored
Feat/1.2.5/UI (#753)
1 parent a9a7ff4 commit 9516dec

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

ui/src/components/SchemaForm/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ export interface BaseUIOptions {
183183
empty?: string;
184184
// Will be appended to the className of the form component itself
185185
className?: classnames.Argument;
186+
class_name?: classnames.Argument;
186187
// The className that will be attached to a form field container
187-
fieldClassName?: classnames.Argument;
188+
field_class_name?: classnames.Argument;
188189
// Make a form component render into simplified mode
189190
readOnly?: boolean;
190191
simplify?: boolean;

ui/src/components/SchemaForm/components/Legend.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import { Form } from 'react-bootstrap';
2222

2323
interface Props {
2424
title: string;
25+
className?: string | undefined;
2526
}
26-
const Index: FC<Props> = ({ title }) => {
27-
return <Form.Label>{title}</Form.Label>;
27+
const Index: FC<Props> = ({ title, className }) => {
28+
return <Form.Label className={className}>{title}</Form.Label>;
2829
};
2930

3031
export default Index;

ui/src/components/SchemaForm/index.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,19 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (
260260
uiSchema?.[key] || {};
261261
formData ||= {};
262262
const fieldState = formData[key];
263+
if (uiOpt?.class_name) {
264+
uiOpt.className = uiOpt.class_name;
265+
}
263266

264267
const uiSimplify = widget === 'legend' || uiOpt?.simplify;
265-
let groupClassName: BaseUIOptions['fieldClassName'] = uiOpt?.simplify
268+
let groupClassName: BaseUIOptions['field_class_name'] = uiOpt?.simplify
266269
? 'mb-2'
267270
: 'mb-3';
268271
if (widget === 'legend') {
269272
groupClassName = 'mb-0';
270273
}
271-
if (uiOpt?.fieldClassName) {
272-
groupClassName = uiOpt.fieldClassName;
274+
if (uiOpt?.field_class_name) {
275+
groupClassName = uiOpt.field_class_name;
273276
}
274277

275278
const readOnly = uiOpt?.readOnly || false;
@@ -285,7 +288,9 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (
285288
{/* Uniform processing `label` */}
286289
{title && !uiSimplify ? <Form.Label>{title}</Form.Label> : null}
287290
{/* Handling of individual specific controls */}
288-
{widget === 'legend' ? <Legend title={title} /> : null}
291+
{widget === 'legend' ? (
292+
<Legend title={title} className={String(uiOpt?.className)} />
293+
) : null}
289294
{widget === 'select' ? (
290295
<Select
291296
desc={description}

ui/src/components/SchemaForm/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ export interface BaseUIOptions {
5858
empty?: string;
5959
// Will be appended to the className of the form component itself
6060
className?: classnames.Argument;
61+
class_name?: classnames.Argument;
6162
// The className that will be attached to a **form field container**
62-
fieldClassName?: classnames.Argument;
63+
field_class_name?: classnames.Argument;
6364
// Make a form component render into simplified mode
6465
readOnly?: boolean;
6566
simplify?: boolean;

ui/src/pages/Admin/SettingsUsers/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const Index: FC = () => {
137137
'ui:widget': 'switch',
138138
'ui:options': {
139139
label: t('allow_update_location.label'),
140-
fieldClassName: 'mb-3',
140+
field_class_name: 'mb-3',
141141
simplify: true,
142142
},
143143
},

0 commit comments

Comments
 (0)