Docs update for properties

This commit is contained in:
francesco
2021-07-29 17:39:47 +02:00
parent c9241fc9b7
commit bee2fa21ba
20 changed files with 146 additions and 2 deletions

View File

@@ -9,6 +9,11 @@ import { buildPropertyField } from "../form_factory";
import { useClearRestoreValue } from "../../hooks";
/**
* Generic array field that allows reordering and renders the child property
* as nodes.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function ArrayDefaultField<T extends Array<any>>({

View File

@@ -16,6 +16,10 @@ import { enumToObjectEntries, isEnumValueDisabled } from "../../util/enums";
import { EnumValuesChip } from "../../preview/components/CustomChip";
/**
* This fields renders a dropdown with multiple selection.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function ArrayEnumSelect({

View File

@@ -22,6 +22,10 @@ import { ErrorView } from "../../core/components";
type ArrayOfReferencesFieldProps = FieldProps<firebase.firestore.DocumentReference[]>;
/**
* This field allows to select multiple references.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function ArrayOfReferencesField({

View File

@@ -21,6 +21,11 @@ import { EnumValues, FieldProps, FormContext, Property } from "../../models";
/**
* If the `oneOf` property is specified, this fields render each array entry as
* a `type` select and the corresponding field widget to the selected `type.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function ArrayOneOfField<T extends Array<any>>({

View File

@@ -13,6 +13,10 @@ import { CMSAppContext } from "../../contexts/CMSAppContext";
type DateTimeFieldProps = FieldProps<Date>;
/**
* Field that allows selecting a date
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function DateTimeField({

View File

@@ -19,6 +19,10 @@ import { useClearRestoreValue } from "../../hooks";
import { buildPropertyField } from "../form_factory";
/**
* Field that renders the children property fields
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function MapField<T extends object>({

View File

@@ -31,6 +31,10 @@ export const useStyles = makeStyles((theme: Theme) =>
);
/**
* Render a markdown field that allows edition and seeing the preview.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function MarkDownField({

View File

@@ -8,6 +8,11 @@ import LabelWithIcon from "../components/LabelWithIcon";
import ErrorBoundary from "../../core/internal/ErrorBoundary";
/**
*
* Simply render the non-editable preview of a field
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function ReadOnlyField<S extends EntitySchema>({

View File

@@ -58,6 +58,10 @@ export const useStyles = makeStyles(theme => createStyles({
}));
/**
* Field that opens a reference selection dialog.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function ReferenceField<S extends EntitySchema<Key>,

View File

@@ -16,6 +16,11 @@ import { EnumValuesChip } from "../../preview/components/CustomChip";
type SelectProps<T extends EnumType> = FieldProps<T>;
/**
* If `enumValues` are set in the string config, this field renders a select
* where each option is a colored chip.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function Select<T extends EnumType>({

View File

@@ -106,6 +106,10 @@ export const useStyles = makeStyles(theme => ({
type StorageUploadFieldProps = FieldProps<string | string[]>;
/**
* Field that allows to upload files to Google Cloud Storage.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function StorageUploadField({

View File

@@ -95,6 +95,10 @@ const SwitchFieldComponent = React.forwardRef(function({
});
/**
* Simple boolean switch.
*
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function(props: SwitchFieldProps) {

View File

@@ -23,6 +23,9 @@ interface TextFieldProps<T extends string | number> extends FieldProps<T> {
}
/**
* Generic text field.
* This is one of the internal components that get mapped natively inside forms
* and tables to the specified properties.
* @category Form fields
*/
export default function TextField<T extends string | number>({

View File

@@ -10,8 +10,25 @@ The property of this array.
You can specify any property (except another Array property, since
Firestore does not support it)
You can leave this field empty only if you are providing a custom field,
otherwise an error will be thrown.
You can leave this field empty only if you are providing a custom field or
provide a `oneOf` field otherwise an error will be thrown.
## `oneOf`
Use this field if you would like to have an array of properties.
It is useful if you need to have values of different types in the same
array.
Each entry of the array is an object with the shape:
```
{ type: "YOUR_TYPE", value: "YOUR_VALUE"}
```
Note that you can use any property so `value` can take any value (strings,
numbers, array, objects...)
You can customise the `type` and `value` fields to suit your needs.
An example use case for this feature may be a blog entry, where you have
images and text blocks using markdown.
## `validation`
@@ -20,3 +37,16 @@ otherwise an error will be thrown.
* `min` Set the minimum length allowed.
* `max` Set the maximum length allowed.
---
Based on your configuration the form field widgets that are created are:
- [`ArrayDefaultField`](api/functions/arraydefaultfield.md) generic array field that allows reordering and renders
the child property as nodes.
- [`StorageUploadField`](api/functions/storageuploadfield.md) if the `of` property is a `string` with storage configuration.
- [`ArrayEnumSelect`](api/functions/arrayenumselect.md) if the `of` property is a `string` with an enum configuration.
- [`ArrayOfReferencesField`](api/functions/arrayofreferencesfield.md) if the `of` property is a `reference`
- [`ArrayOneOfField`](api/functions/arrayoneoffield.md) if the `oneOf` property is specified
Links:
- [API](api/interfaces/arrayproperty.md)

View File

@@ -8,3 +8,11 @@ sidebar_label: Boolean
* `required` Should this field be compulsory.
* `requiredMessage` Message to be displayed as a validation error.
---
The widget that gets created is
- `SwitchField` simple boolean switch
Links:
- [API](api/interfaces/booleanproperty.md)

View File

@@ -15,3 +15,11 @@ List of properties rendered as this map preview. Defaults to first 3.
* `required` Should this field be compulsory.
* `requiredMessage` Message to be displayed as a validation error.
---
The widget that gets created is
- [`MapField`](api/functions/mapfield.md) Field that renders the children
property fields
Links:
- [API](api/interfaces/mapproperty.md)

View File

@@ -21,3 +21,14 @@ sidebar_label: Number
* `positive` Value must be a positive number.
* `negative` Value must be a negative number.
* `integer` Value must be an integer.
---
The widget that gets created is
- [`TextField`](api/functions/textfield.md) generic text field
- [`Select`](api/functions/select.md) if `enumValues` are set in the string config, this field renders a select
where each option is a colored chip.
Links:
- [API](api/interfaces/numberproperty.md)

View File

@@ -19,3 +19,12 @@ List of properties rendered as this reference preview.
* `required` Should this field be compulsory.
* `requiredMessage` Message to be displayed as a validation error.
---
The widget that gets created is
- [`ReferenceField`](api/functions/referencefield.md) Field that opens a
reference selection dialog
Links:
- [API](api/interfaces/referenceproperty.md)

View File

@@ -62,3 +62,18 @@ sidebar_label: String
whitespace.
* `lowercase` Transforms the string value to lowercase.
* `uppercase` Transforms the string value to uppercase.
---
Based on your configuration the form field widgets that are created are:
- [`TextField`](api/functions/textfield.md) generic text field
- [`StorageUploadField`](api/functions/storageuploadfield.md) the property has a
storage configuration.
- [`MarkdownField.`](api/functions/markdownfield.md) the property has a
markdown configuration.
- [`Select`](api/functions/select.md) if `enumValues` are set in the string config, this field renders a select
where each option is a colored chip.
Links:
- [API](api/interfaces/stringproperty.md)

View File

@@ -10,3 +10,11 @@ sidebar_label: Timestamp
* `requiredMessage` Message to be displayed as a validation error.
* `min` Set the minimum date allowed.
* `max` Set the maximum date allowed.
---
The widget that gets created is
- [`DateTimeField`](api/functions/datetimefield.md) Field that allows selecting a date
Links:
- [API](api/interfaces/timestampproperty.md)