Merge pull request #415 from oranoran/admin-classname
Added "className" property to admin + documented existing "style" property
This commit is contained in:
@@ -114,6 +114,8 @@ In addition to each field's base configuration, you can define specific traits a
|
|||||||
| `description` | Helper text to display with the field to provide more information for the editor user. [Click here](#description) for more info. |
|
| `description` | Helper text to display with the field to provide more information for the editor user. [Click here](#description) for more info. |
|
||||||
| `position` | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. |
|
| `position` | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. |
|
||||||
| `width` | Restrict the width of a field. you can pass any string-based value here, be it pixels, percentages, etc. This property is especially useful when fields are nested within a `Row` type where they can be organized horizontally. |
|
| `width` | Restrict the width of a field. you can pass any string-based value here, be it pixels, percentages, etc. This property is especially useful when fields are nested within a `Row` type where they can be organized horizontally. |
|
||||||
|
| `style` | Attach raw CSS style properties to the root DOM element of a field. |
|
||||||
|
| `className` | Attach a CSS class name to the root DOM element of a field. |
|
||||||
| `readOnly` | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. |
|
| `readOnly` | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. |
|
||||||
| `disabled` | If a field is `disabled`, it is completely omitted from the Admin panel. |
|
| `disabled` | If a field is `disabled`, it is completely omitted from the Admin panel. |
|
||||||
| `hidden` | Setting a field's `hidden` property on its `admin` config will transform it into a `hidden` input type. Its value will still submit with the Admin panel's requests, but the field itself will not be visible to editors. |
|
| `hidden` | Setting a field's `hidden` property on its `admin` config will transform it into a `hidden` input type. Its value will still submit with the Admin panel's requests, but the field itself will not be visible to editors. |
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const Checkbox: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
condition,
|
condition,
|
||||||
@@ -54,6 +55,7 @@ const Checkbox: React.FC<Props> = (props) => {
|
|||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
|
className,
|
||||||
value && `${baseClass}--checked`,
|
value && `${baseClass}--checked`,
|
||||||
readOnly && `${baseClass}--read-only`,
|
readOnly && `${baseClass}--read-only`,
|
||||||
].filter(Boolean).join(' ')}
|
].filter(Boolean).join(' ')}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const Code: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
language,
|
language,
|
||||||
description,
|
description,
|
||||||
@@ -62,6 +63,7 @@ const Code: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'code',
|
'code',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const DateTime: React.FC<Props> = (props) => {
|
|||||||
placeholder,
|
placeholder,
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
date,
|
date,
|
||||||
description,
|
description,
|
||||||
@@ -52,6 +53,7 @@ const DateTime: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
|
className,
|
||||||
showError && `${baseClass}--has-error`,
|
showError && `${baseClass}--has-error`,
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const Email: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
placeholder,
|
placeholder,
|
||||||
autoComplete,
|
autoComplete,
|
||||||
@@ -51,6 +52,7 @@ const Email: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'email',
|
'email',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const Group: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
hideGutter,
|
hideGutter,
|
||||||
description,
|
description,
|
||||||
@@ -35,6 +36,7 @@ const Group: React.FC<Props> = (props) => {
|
|||||||
className={[
|
className={[
|
||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
|
className,
|
||||||
!label && `${baseClass}--no-label`,
|
!label && `${baseClass}--no-label`,
|
||||||
].filter(Boolean).join(' ')}
|
].filter(Boolean).join(' ')}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const NumberField: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
step,
|
step,
|
||||||
placeholder,
|
placeholder,
|
||||||
@@ -61,6 +62,7 @@ const NumberField: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'number',
|
'number',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const Password: React.FC<Props> = (props) => {
|
|||||||
required,
|
required,
|
||||||
validate = password,
|
validate = password,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
autoComplete,
|
autoComplete,
|
||||||
label,
|
label,
|
||||||
@@ -42,6 +43,7 @@ const Password: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'password',
|
'password',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export type Props = {
|
|||||||
required?: boolean
|
required?: boolean
|
||||||
validate?: Validate
|
validate?: Validate
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
className?: string,
|
||||||
width?: string
|
width?: string
|
||||||
label?: string
|
label?: string
|
||||||
description?: Description
|
description?: Description
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const PointField: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
step,
|
step,
|
||||||
placeholder,
|
placeholder,
|
||||||
@@ -61,6 +62,7 @@ const PointField: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const RadioGroup: React.FC<Props> = (props) => {
|
|||||||
readOnly,
|
readOnly,
|
||||||
layout = 'horizontal',
|
layout = 'horizontal',
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
condition,
|
condition,
|
||||||
@@ -53,6 +54,7 @@ const RadioGroup: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
|
className,
|
||||||
`${baseClass}--layout-${layout}`,
|
`${baseClass}--layout-${layout}`,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && `${baseClass}--read-only`,
|
readOnly && `${baseClass}--read-only`,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ const Relationship: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
condition,
|
condition,
|
||||||
@@ -257,6 +258,7 @@ const Relationship: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
errorLoading && 'error-loading',
|
errorLoading && 'error-loading',
|
||||||
readOnly && `${baseClass}--read-only`,
|
readOnly && `${baseClass}--read-only`,
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const RichText: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
placeholder,
|
placeholder,
|
||||||
description,
|
description,
|
||||||
@@ -132,6 +133,7 @@ const RichText: React.FC<Props> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
baseClass,
|
baseClass,
|
||||||
'field-type',
|
'field-type',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && `${baseClass}--read-only`,
|
readOnly && `${baseClass}--read-only`,
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export type SelectInputProps = Omit<SelectField, 'type' | 'value' | 'options'> &
|
|||||||
description?: Description
|
description?: Description
|
||||||
onChange?: (value: ReactSelectValue) => void
|
onChange?: (value: ReactSelectValue) => void
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
className?: string
|
||||||
width?: string
|
width?: string
|
||||||
hasMany?: boolean
|
hasMany?: boolean
|
||||||
options?: OptionObject[]
|
options?: OptionObject[]
|
||||||
@@ -37,6 +38,7 @@ const SelectInput: React.FC<SelectInputProps> = (props) => {
|
|||||||
onChange,
|
onChange,
|
||||||
description,
|
description,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
options,
|
options,
|
||||||
hasMany,
|
hasMany,
|
||||||
@@ -45,6 +47,7 @@ const SelectInput: React.FC<SelectInputProps> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'select',
|
'select',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ const Select: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
condition,
|
condition,
|
||||||
@@ -88,6 +89,7 @@ const Select: React.FC<Props> = (props) => {
|
|||||||
errorMessage={errorMessage}
|
errorMessage={errorMessage}
|
||||||
description={description}
|
description={description}
|
||||||
style={style}
|
style={style}
|
||||||
|
className={className}
|
||||||
width={width}
|
width={width}
|
||||||
hasMany={hasMany}
|
hasMany={hasMany}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export type TextInputProps = Omit<TextField, 'type'> & {
|
|||||||
onChange?: (e: ChangeEvent<HTMLInputElement>) => void
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
className?: string
|
||||||
width?: string
|
width?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,12 +36,14 @@ const TextInput: React.FC<TextInputProps> = (props) => {
|
|||||||
onChange,
|
onChange,
|
||||||
description,
|
description,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'text',
|
'text',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const Text: React.FC<Props> = (props) => {
|
|||||||
placeholder,
|
placeholder,
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
condition,
|
condition,
|
||||||
@@ -53,6 +54,7 @@ const Text: React.FC<Props> = (props) => {
|
|||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
style={style}
|
style={style}
|
||||||
|
className={className}
|
||||||
width={width}
|
width={width}
|
||||||
description={description}
|
description={description}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export type TextAreaInputProps = Omit<TextareaField, 'type'> & {
|
|||||||
onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void
|
onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
className?: string
|
||||||
width?: string
|
width?: string
|
||||||
rows?: number
|
rows?: number
|
||||||
}
|
}
|
||||||
@@ -28,6 +29,7 @@ const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
|
|||||||
required,
|
required,
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
placeholder,
|
placeholder,
|
||||||
description,
|
description,
|
||||||
@@ -42,6 +44,7 @@ const TextareaInput: React.FC<TextAreaInputProps> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
'textarea',
|
'textarea',
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const Textarea: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
placeholder,
|
placeholder,
|
||||||
rows,
|
rows,
|
||||||
@@ -61,6 +62,7 @@ const Textarea: React.FC<Props> = (props) => {
|
|||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
style={style}
|
style={style}
|
||||||
|
className={className}
|
||||||
width={width}
|
width={width}
|
||||||
description={description}
|
description={description}
|
||||||
rows={rows}
|
rows={rows}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export type UploadInputProps = Omit<UploadField, 'type'> & {
|
|||||||
onChange?: (e) => void
|
onChange?: (e) => void
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
className?: string
|
||||||
width?: string
|
width?: string
|
||||||
fieldTypes?: FieldTypes
|
fieldTypes?: FieldTypes
|
||||||
collection?: SanitizedCollectionConfig
|
collection?: SanitizedCollectionConfig
|
||||||
@@ -40,6 +41,7 @@ const UploadInput: React.FC<UploadInputProps> = (props) => {
|
|||||||
required,
|
required,
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
label,
|
label,
|
||||||
@@ -65,6 +67,7 @@ const UploadInput: React.FC<UploadInputProps> = (props) => {
|
|||||||
const classes = [
|
const classes = [
|
||||||
'field-type',
|
'field-type',
|
||||||
baseClass,
|
baseClass,
|
||||||
|
className,
|
||||||
showError && 'error',
|
showError && 'error',
|
||||||
readOnly && 'read-only',
|
readOnly && 'read-only',
|
||||||
].filter(Boolean).join(' ');
|
].filter(Boolean).join(' ');
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const Upload: React.FC<Props> = (props) => {
|
|||||||
admin: {
|
admin: {
|
||||||
readOnly,
|
readOnly,
|
||||||
style,
|
style,
|
||||||
|
className,
|
||||||
width,
|
width,
|
||||||
description,
|
description,
|
||||||
condition,
|
condition,
|
||||||
@@ -76,6 +77,7 @@ const Upload: React.FC<Props> = (props) => {
|
|||||||
errorMessage={errorMessage}
|
errorMessage={errorMessage}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
style={style}
|
style={style}
|
||||||
|
className={className}
|
||||||
width={width}
|
width={width}
|
||||||
collection={collection}
|
collection={collection}
|
||||||
fieldTypes={fieldTypes}
|
fieldTypes={fieldTypes}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const baseAdminFields = joi.object().keys({
|
|||||||
position: joi.string().valid('sidebar'),
|
position: joi.string().valid('sidebar'),
|
||||||
width: joi.string(),
|
width: joi.string(),
|
||||||
style: joi.object().unknown(),
|
style: joi.object().unknown(),
|
||||||
|
className: joi.string(),
|
||||||
readOnly: joi.boolean().default(false),
|
readOnly: joi.boolean().default(false),
|
||||||
hidden: joi.boolean().default(false),
|
hidden: joi.boolean().default(false),
|
||||||
disabled: joi.boolean().default(false),
|
disabled: joi.boolean().default(false),
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ type Admin = {
|
|||||||
position?: 'sidebar';
|
position?: 'sidebar';
|
||||||
width?: string;
|
width?: string;
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
|
className?: string;
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
condition?: Condition;
|
condition?: Condition;
|
||||||
|
|||||||
Reference in New Issue
Block a user