diff --git a/package-lock.json b/package-lock.json
index ded852521693f6..acace7b65e4102 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -55032,7 +55032,9 @@
"@wordpress/a11y": "file:../a11y",
"@wordpress/components": "file:../components",
"@wordpress/compose": "file:../compose",
+ "@wordpress/date": "file:../date",
"@wordpress/element": "file:../element",
+ "@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/keycodes": "file:../keycodes",
@@ -70377,7 +70379,9 @@
"@wordpress/a11y": "file:../a11y",
"@wordpress/components": "file:../components",
"@wordpress/compose": "file:../compose",
+ "@wordpress/date": "file:../date",
"@wordpress/element": "file:../element",
+ "@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/keycodes": "file:../keycodes",
diff --git a/packages/dataviews/README.md b/packages/dataviews/README.md
index c0d0a01cbc3e28..df904e87e0e22b 100644
--- a/packages/dataviews/README.md
+++ b/packages/dataviews/README.md
@@ -150,25 +150,16 @@ Example:
[
{
id: 'date',
+ type: 'date',
header: __( 'Date' ),
getValue: ( { item } ) => item.date,
- render: ( { item } ) => {
- return (
-
- );
- },
enableHiding: false
},
{
id: 'author',
+ type: 'enumeration',
header: __( 'Author' ),
getValue: ( { item } ) => item.author,
- render: ( { item } ) => {
- return (
- { item.author }
- );
- },
- type: 'enumeration',
elements: [
{ value: 1, label: 'Admin' }
{ value: 2, label: 'User' }
@@ -179,11 +170,11 @@ Example:
```
- `id`: identifier for the field. Unique.
+- `type`: the type of the field. Used to render the field and generate the proper filters. See "Field types".
- `header`: the field's name to be shown in the UI.
- `getValue`: function that returns the value of the field.
-- `render`: function that renders the field.
+- `formats`: a list of modifications to the default render provided for the field. See "Format".
- `elements`: the set of valid values for the field's value.
-- `type`: the type of the field. Used to generate the proper filters. Only `enumeration` available at the moment. See "Field types".
- `enableSorting`: whether the data can be sorted by the given field. True by default.
- `enableHiding`: whether the field can be hidden. True by default.
- `filterBy`: configuration for the filters.
@@ -211,10 +202,64 @@ Array of operations that can be performed upon each record. Each action is an ob
- `list`: the view uses a list layout.
- Field types:
- `enumeration`: the field value should be taken and can be filtered from a closed list of elements.
+ - `date`: the field value is a date.
+ - `text`: the field value is a string.
+ - `img`: the field value is an image.
- Operator types:
- `in`: operator to be used in filters for fields of type `enumeration`.
- `notIn`: operator to be used in filters for fields of type `enumeration`.
+## Formats
+
+Each format is an object whose shape is:
+
+```js
+{
+ type: 'format-type',
+ renderProps: ( { item } ) => { return { newProp: '...' }; },
+ renderChildren: ( { item } ) => { return Component; }
+}
+```
+
+Existing formats are:
+
+- `link`: format that declares the field should contain a link with the given props (href, etc.).
+
+```js
+{
+ type: 'link',
+ renderProps: ( { item } ) => ({ href: 'new-url-based-on-item' }),
+},
+```
+
+- `empty`: format that declares the field wants to render an empty state different from the default.
+
+```js
+{
+ type: 'empty',
+ renderChildren: ( { item } ) => { return __( '(no title)' ); },
+},
+```
+
+- `prefix`: format that renders a component as a prefix to the default render. Example: used to render an icon before.
+
+```js
+{
+ type: 'prefix',
+ renderChildren: ( { item } ) => { return ; },
+}
+```
+
+- `after`: format that renders a component. Similar to CSS pseudo-element `::after`.
+
+```js
+{
+ type: 'after',
+ renderProps: ( { item } ) => ({ className: '...' }),
+ renderChildren: ( { item }) => { return