-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org>
- Loading branch information
1 parent
01b24ce
commit 6773fd5
Showing
4 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
11 changes: 8 additions & 3 deletions
11
packages/dataviews/src/normalize-fields.js → packages/dataviews/src/normalize-fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { ReactNode } from 'react'; | ||
|
||
type Item = Record< string, any >; | ||
|
||
interface Option { | ||
value: any; | ||
label: string; | ||
} | ||
|
||
interface filterByConfig { | ||
operators?: string[]; | ||
isPrimary?: boolean; | ||
} | ||
|
||
export interface Field { | ||
/** | ||
* The unique identifier of the field. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* The label of the field. Defaults to the id. | ||
*/ | ||
header?: string; | ||
|
||
/** | ||
* Callback used to retrieve the value of the field from the item. | ||
* Defaults to `item[ field.id ]`. | ||
*/ | ||
getValue?: ( { item }: { item: Item } ) => any; | ||
|
||
/** | ||
* Callback used to render the field. Defaults to `field.getValue`. | ||
*/ | ||
render?: ( { item }: { item: Item } ) => ReactNode; | ||
|
||
/** | ||
* The width of the field column. | ||
*/ | ||
width?: string | number; | ||
|
||
/** | ||
* The minimum width of the field column. | ||
*/ | ||
maxWidth?: string | number; | ||
|
||
/** | ||
* The maximum width of the field column. | ||
*/ | ||
minWidth?: string | number; | ||
|
||
/** | ||
* Whether the field is sortable. | ||
*/ | ||
enableSorting?: boolean; | ||
|
||
/** | ||
* Whether the field is searchable. | ||
*/ | ||
enableGlobalSearch?: boolean; | ||
|
||
/** | ||
* Whether the field is filterable. | ||
*/ | ||
enableHiding?: boolean; | ||
|
||
/** | ||
* The list of options to pick from when using the field as a filter. | ||
*/ | ||
elements?: Option[]; | ||
|
||
/** | ||
* Filter config for the field. | ||
*/ | ||
filterBy?: filterByConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig.json", | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"declarationDir": "build-types" | ||
}, | ||
"references": [ | ||
{ "path": "../a11y" }, | ||
{ "path": "../components" }, | ||
{ "path": "../compose" }, | ||
{ "path": "../element" }, | ||
{ "path": "../i18n" }, | ||
{ "path": "../icons" }, | ||
{ "path": "../keycodes" }, | ||
{ "path": "../primitives" }, | ||
{ "path": "../private-apis" } | ||
], | ||
"include": [ "src/**/*.ts", "src/**/*.tsx" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters