@wordpress/dataviews 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/README.md +19 -4
- package/build/{dataform.js → components/dataform/index.js} +5 -5
- package/build/components/dataform/index.js.map +1 -0
- package/build/components/dataviews/index.js +115 -0
- package/build/components/dataviews/index.js.map +1 -0
- package/build/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -16
- package/build/components/dataviews-bulk-actions/index.js.map +1 -0
- package/build/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +36 -19
- package/build/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
- package/build/components/dataviews-context/index.js +36 -0
- package/build/components/dataviews-context/index.js.map +1 -0
- package/build/{add-filter.js → components/dataviews-filters/add-filter.js} +2 -2
- package/build/components/dataviews-filters/add-filter.js.map +1 -0
- package/build/{filter-summary.js → components/dataviews-filters/filter-summary.js} +9 -9
- package/build/components/dataviews-filters/filter-summary.js.map +1 -0
- package/build/{filters.js → components/dataviews-filters/index.js} +14 -15
- package/build/components/dataviews-filters/index.js.map +1 -0
- package/build/components/dataviews-filters/reset-filters.js.map +1 -0
- package/build/{search-widget.js → components/dataviews-filters/search-widget.js} +13 -13
- package/build/components/dataviews-filters/search-widget.js.map +1 -0
- package/build/{item-actions.js → components/dataviews-item-actions/index.js} +2 -2
- package/build/components/dataviews-item-actions/index.js.map +1 -0
- package/build/components/dataviews-layout/index.js +53 -0
- package/build/components/dataviews-layout/index.js.map +1 -0
- package/build/{pagination.js → components/dataviews-pagination/index.js} +16 -13
- package/build/components/dataviews-pagination/index.js.map +1 -0
- package/build/{search.js → components/dataviews-search/index.js} +10 -6
- package/build/components/dataviews-search/index.js.map +1 -0
- package/build/{single-selection-checkbox.js → components/dataviews-selection-checkbox/index.js} +6 -6
- package/build/components/dataviews-selection-checkbox/index.js.map +1 -0
- package/build/{view-actions.js → components/dataviews-view-config/index.js} +19 -16
- package/build/components/dataviews-view-config/index.js.map +1 -0
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/layouts/grid/density-picker.js +143 -0
- package/build/layouts/grid/density-picker.js.map +1 -0
- package/build/{view-grid.js → layouts/grid/index.js} +34 -35
- package/build/layouts/grid/index.js.map +1 -0
- package/build/layouts/index.js +52 -0
- package/build/layouts/index.js.map +1 -0
- package/build/{view-list.js → layouts/list/index.js} +26 -23
- package/build/layouts/list/index.js.map +1 -0
- package/build/layouts/table/column-header-menu.js +196 -0
- package/build/layouts/table/column-header-menu.js.map +1 -0
- package/build/layouts/table/index.js +350 -0
- package/build/layouts/table/index.js.map +1 -0
- package/build/normalize-fields.js +1 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/{dataform.js → components/dataform/index.js} +5 -5
- package/build-module/components/dataform/index.js.map +1 -0
- package/build-module/components/dataviews/index.js +108 -0
- package/build-module/components/dataviews/index.js.map +1 -0
- package/build-module/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -17
- package/build-module/components/dataviews-bulk-actions/index.js.map +1 -0
- package/build-module/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +35 -19
- package/build-module/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
- package/build-module/components/dataviews-context/index.js +30 -0
- package/build-module/components/dataviews-context/index.js.map +1 -0
- package/build-module/{add-filter.js → components/dataviews-filters/add-filter.js} +2 -2
- package/build-module/components/dataviews-filters/add-filter.js.map +1 -0
- package/build-module/{filter-summary.js → components/dataviews-filters/filter-summary.js} +9 -9
- package/build-module/components/dataviews-filters/filter-summary.js.map +1 -0
- package/build-module/{filters.js → components/dataviews-filters/index.js} +15 -16
- package/build-module/components/dataviews-filters/index.js.map +1 -0
- package/build-module/components/dataviews-filters/reset-filters.js.map +1 -0
- package/build-module/{search-widget.js → components/dataviews-filters/search-widget.js} +13 -13
- package/build-module/components/dataviews-filters/search-widget.js.map +1 -0
- package/build-module/{item-actions.js → components/dataviews-item-actions/index.js} +2 -2
- package/build-module/components/dataviews-item-actions/index.js.map +1 -0
- package/build-module/components/dataviews-layout/index.js +45 -0
- package/build-module/components/dataviews-layout/index.js.map +1 -0
- package/build-module/{pagination.js → components/dataviews-pagination/index.js} +17 -15
- package/build-module/components/dataviews-pagination/index.js.map +1 -0
- package/build-module/{search.js → components/dataviews-search/index.js} +10 -7
- package/build-module/components/dataviews-search/index.js.map +1 -0
- package/build-module/{single-selection-checkbox.js → components/dataviews-selection-checkbox/index.js} +5 -5
- package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -0
- package/build-module/{view-actions.js → components/dataviews-view-config/index.js} +19 -17
- package/build-module/components/dataviews-view-config/index.js.map +1 -0
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/grid/density-picker.js +138 -0
- package/build-module/layouts/grid/density-picker.js.map +1 -0
- package/build-module/{view-grid.js → layouts/grid/index.js} +31 -32
- package/build-module/layouts/grid/index.js.map +1 -0
- package/build-module/layouts/index.js +43 -0
- package/build-module/layouts/index.js.map +1 -0
- package/build-module/{view-list.js → layouts/list/index.js} +24 -21
- package/build-module/layouts/list/index.js.map +1 -0
- package/build-module/layouts/table/column-header-menu.js +190 -0
- package/build-module/layouts/table/column-header-menu.js.map +1 -0
- package/build-module/layouts/table/index.js +344 -0
- package/build-module/layouts/table/index.js.map +1 -0
- package/build-module/normalize-fields.js +1 -1
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +607 -545
- package/build-style/style.css +607 -545
- package/build-types/{dataform.d.ts → components/dataform/index.d.ts} +2 -2
- package/build-types/components/dataform/index.d.ts.map +1 -0
- package/build-types/components/dataform/stories/index.story.d.ts +11 -0
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -0
- package/build-types/{dataviews.d.ts → components/dataviews/index.d.ts} +9 -7
- package/build-types/components/dataviews/index.d.ts.map +1 -0
- package/build-types/{stories → components/dataviews/stories}/fixtures.d.ts +7 -19
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -0
- package/build-types/components/dataviews/stories/index.story.d.ts +46 -0
- package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -0
- package/build-types/components/dataviews-bulk-actions/index.d.ts +5 -0
- package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -0
- package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts +2 -0
- package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts.map +1 -0
- package/build-types/components/dataviews-context/index.d.ts +26 -0
- package/build-types/components/dataviews-context/index.d.ts.map +1 -0
- package/build-types/{add-filter.d.ts → components/dataviews-filters/add-filter.d.ts} +1 -2
- package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -0
- package/build-types/{filter-summary.d.ts → components/dataviews-filters/filter-summary.d.ts} +1 -1
- package/build-types/components/dataviews-filters/filter-summary.d.ts.map +1 -0
- package/build-types/components/dataviews-filters/index.d.ts +4 -0
- package/build-types/components/dataviews-filters/index.d.ts.map +1 -0
- package/build-types/{reset-filters.d.ts → components/dataviews-filters/reset-filters.d.ts} +1 -2
- package/build-types/components/dataviews-filters/reset-filters.d.ts.map +1 -0
- package/build-types/{search-widget.d.ts → components/dataviews-filters/search-widget.d.ts} +1 -2
- package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -0
- package/build-types/{item-actions.d.ts → components/dataviews-item-actions/index.d.ts} +2 -2
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -0
- package/build-types/components/dataviews-layout/index.d.ts +2 -0
- package/build-types/components/dataviews-layout/index.d.ts.map +1 -0
- package/build-types/components/dataviews-pagination/index.d.ts +4 -0
- package/build-types/components/dataviews-pagination/index.d.ts.map +1 -0
- package/build-types/components/dataviews-search/index.d.ts +6 -0
- package/build-types/components/dataviews-search/index.d.ts.map +1 -0
- package/build-types/components/dataviews-selection-checkbox/index.d.ts +16 -0
- package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -0
- package/build-types/components/dataviews-view-config/index.d.ts +8 -0
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -0
- package/build-types/index.d.ts +2 -2
- package/build-types/index.d.ts.map +1 -1
- package/build-types/layouts/grid/density-picker.d.ts +5 -0
- package/build-types/layouts/grid/density-picker.d.ts.map +1 -0
- package/build-types/layouts/grid/index.d.ts +3 -0
- package/build-types/layouts/grid/index.d.ts.map +1 -0
- package/build-types/{layouts.d.ts → layouts/index.d.ts} +6 -5
- package/build-types/layouts/index.d.ts.map +1 -0
- package/build-types/layouts/list/index.d.ts +3 -0
- package/build-types/layouts/list/index.d.ts.map +1 -0
- package/build-types/layouts/table/column-header-menu.d.ts +17 -0
- package/build-types/layouts/table/column-header-menu.d.ts.map +1 -0
- package/build-types/layouts/table/index.d.ts +4 -0
- package/build-types/layouts/table/index.d.ts.map +1 -0
- package/build-types/types.d.ts +42 -23
- package/build-types/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/{dataform.tsx → components/dataform/index.tsx} +5 -5
- package/src/components/dataform/stories/index.story.tsx +42 -0
- package/src/components/dataviews/index.tsx +149 -0
- package/src/{stories → components/dataviews/stories}/fixtures.js +7 -11
- package/src/{stories → components/dataviews/stories}/index.story.js +17 -3
- package/src/components/dataviews/style.scss +97 -0
- package/src/{bulk-actions.tsx → components/dataviews-bulk-actions/index.tsx} +46 -29
- package/src/components/dataviews-bulk-actions/style.scss +7 -0
- package/src/{bulk-actions-toolbar.tsx → components/dataviews-bulk-actions-toolbar/index.tsx} +42 -30
- package/src/components/dataviews-bulk-actions-toolbar/style.scss +45 -0
- package/src/components/dataviews-context/index.ts +49 -0
- package/src/{add-filter.tsx → components/dataviews-filters/add-filter.tsx} +3 -3
- package/src/{filter-summary.tsx → components/dataviews-filters/filter-summary.tsx} +18 -10
- package/src/{filters.tsx → components/dataviews-filters/index.tsx} +10 -24
- package/src/{reset-filters.tsx → components/dataviews-filters/reset-filters.tsx} +1 -1
- package/src/{search-widget.tsx → components/dataviews-filters/search-widget.tsx} +14 -14
- package/src/components/dataviews-filters/style.scss +252 -0
- package/src/{item-actions.tsx → components/dataviews-item-actions/index.tsx} +2 -2
- package/src/components/dataviews-item-actions/style.scss +3 -0
- package/src/components/dataviews-layout/index.tsx +51 -0
- package/src/{pagination.tsx → components/dataviews-pagination/index.tsx} +13 -21
- package/src/components/dataviews-pagination/style.scss +26 -0
- package/src/{search.tsx → components/dataviews-search/index.tsx} +5 -10
- package/src/{single-selection-checkbox.tsx → components/dataviews-selection-checkbox/index.tsx} +9 -9
- package/src/components/dataviews-selection-checkbox/style.scss +14 -0
- package/src/{view-actions.tsx → components/dataviews-view-config/index.tsx} +16 -22
- package/src/index.ts +2 -2
- package/src/layouts/grid/density-picker.tsx +136 -0
- package/src/{view-grid.tsx → layouts/grid/index.tsx} +28 -29
- package/src/layouts/grid/style.scss +140 -0
- package/src/layouts/index.ts +66 -0
- package/src/{view-list.tsx → layouts/list/index.tsx} +30 -17
- package/src/layouts/list/style.scss +189 -0
- package/src/layouts/table/column-header-menu.tsx +268 -0
- package/src/layouts/table/index.tsx +471 -0
- package/src/layouts/table/style.scss +201 -0
- package/src/normalize-fields.ts +1 -1
- package/src/style.scss +11 -907
- package/src/test/filter-and-sort-data-view.js +1 -1
- package/src/types.ts +48 -24
- package/tsconfig.tsbuildinfo +1 -1
- package/build/add-filter.js.map +0 -1
- package/build/bulk-actions-toolbar.js.map +0 -1
- package/build/bulk-actions.js.map +0 -1
- package/build/dataform.js.map +0 -1
- package/build/dataviews.js +0 -125
- package/build/dataviews.js.map +0 -1
- package/build/filter-summary.js.map +0 -1
- package/build/filters.js.map +0 -1
- package/build/item-actions.js.map +0 -1
- package/build/layouts.js +0 -38
- package/build/layouts.js.map +0 -1
- package/build/pagination.js.map +0 -1
- package/build/reset-filters.js.map +0 -1
- package/build/search-widget.js.map +0 -1
- package/build/search.js.map +0 -1
- package/build/single-selection-checkbox.js.map +0 -1
- package/build/view-actions.js.map +0 -1
- package/build/view-grid.js.map +0 -1
- package/build/view-list.js.map +0 -1
- package/build/view-table.js +0 -400
- package/build/view-table.js.map +0 -1
- package/build-module/add-filter.js.map +0 -1
- package/build-module/bulk-actions-toolbar.js.map +0 -1
- package/build-module/bulk-actions.js.map +0 -1
- package/build-module/dataform.js.map +0 -1
- package/build-module/dataviews.js +0 -116
- package/build-module/dataviews.js.map +0 -1
- package/build-module/filter-summary.js.map +0 -1
- package/build-module/filters.js.map +0 -1
- package/build-module/item-actions.js.map +0 -1
- package/build-module/layouts.js +0 -30
- package/build-module/layouts.js.map +0 -1
- package/build-module/pagination.js.map +0 -1
- package/build-module/reset-filters.js.map +0 -1
- package/build-module/search-widget.js.map +0 -1
- package/build-module/search.js.map +0 -1
- package/build-module/single-selection-checkbox.js.map +0 -1
- package/build-module/view-actions.js.map +0 -1
- package/build-module/view-grid.js.map +0 -1
- package/build-module/view-list.js.map +0 -1
- package/build-module/view-table.js +0 -393
- package/build-module/view-table.js.map +0 -1
- package/build-types/add-filter.d.ts.map +0 -1
- package/build-types/bulk-actions-toolbar.d.ts +0 -13
- package/build-types/bulk-actions-toolbar.d.ts.map +0 -1
- package/build-types/bulk-actions.d.ts +0 -15
- package/build-types/bulk-actions.d.ts.map +0 -1
- package/build-types/dataform.d.ts.map +0 -1
- package/build-types/dataviews.d.ts.map +0 -1
- package/build-types/filter-summary.d.ts.map +0 -1
- package/build-types/filters.d.ts +0 -13
- package/build-types/filters.d.ts.map +0 -1
- package/build-types/item-actions.d.ts.map +0 -1
- package/build-types/layouts.d.ts.map +0 -1
- package/build-types/pagination.d.ts +0 -16
- package/build-types/pagination.d.ts.map +0 -1
- package/build-types/reset-filters.d.ts.map +0 -1
- package/build-types/search-widget.d.ts.map +0 -1
- package/build-types/search.d.ts +0 -13
- package/build-types/search.d.ts.map +0 -1
- package/build-types/single-selection-checkbox.d.ts +0 -17
- package/build-types/single-selection-checkbox.d.ts.map +0 -1
- package/build-types/stories/fixtures.d.ts.map +0 -1
- package/build-types/stories/index.story.d.ts +0 -29
- package/build-types/stories/index.story.d.ts.map +0 -1
- package/build-types/view-actions.d.ts +0 -12
- package/build-types/view-actions.d.ts.map +0 -1
- package/build-types/view-grid.d.ts +0 -4
- package/build-types/view-grid.d.ts.map +0 -1
- package/build-types/view-list.d.ts +0 -4
- package/build-types/view-list.d.ts.map +0 -1
- package/build-types/view-table.d.ts +0 -5
- package/build-types/view-table.d.ts.map +0 -1
- package/src/dataviews.tsx +0 -183
- package/src/layouts.ts +0 -39
- package/src/view-table.tsx +0 -592
- /package/build/{reset-filters.js → components/dataviews-filters/reset-filters.js} +0 -0
- /package/build-module/{reset-filters.js → components/dataviews-filters/reset-filters.js} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { filterSortAndPaginate } from '../filter-and-sort-data-view';
|
|
5
|
-
import { data, fields } from '../stories/fixtures';
|
|
5
|
+
import { data, fields } from '../components/dataviews/stories/fixtures';
|
|
6
6
|
|
|
7
7
|
describe( 'filters', () => {
|
|
8
8
|
it( 'should return empty if the data is empty', () => {
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { ReactElement,
|
|
4
|
+
import type { ReactElement, ComponentType } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -63,7 +63,7 @@ export type Field< Item > = {
|
|
|
63
63
|
/**
|
|
64
64
|
* The label of the field. Defaults to the id.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
label?: string;
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Placeholder for the field.
|
|
@@ -73,22 +73,7 @@ export type Field< Item > = {
|
|
|
73
73
|
/**
|
|
74
74
|
* Callback used to render the field. Defaults to `field.getValue`.
|
|
75
75
|
*/
|
|
76
|
-
render?:
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The width of the field column.
|
|
80
|
-
*/
|
|
81
|
-
width?: string | number;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The minimum width of the field column.
|
|
85
|
-
*/
|
|
86
|
-
maxWidth?: string | number;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The maximum width of the field column.
|
|
90
|
-
*/
|
|
91
|
-
minWidth?: string | number;
|
|
76
|
+
render?: ComponentType< { item: Item } >;
|
|
92
77
|
|
|
93
78
|
/**
|
|
94
79
|
* Whether the field is sortable.
|
|
@@ -131,9 +116,9 @@ export type Field< Item > = {
|
|
|
131
116
|
} );
|
|
132
117
|
|
|
133
118
|
export type NormalizedField< Item > = Field< Item > & {
|
|
134
|
-
|
|
119
|
+
label: string;
|
|
135
120
|
getValue: ( args: { item: Item } ) => any;
|
|
136
|
-
render:
|
|
121
|
+
render: ComponentType< { item: Item } >;
|
|
137
122
|
};
|
|
138
123
|
|
|
139
124
|
/**
|
|
@@ -249,11 +234,44 @@ interface ViewBase {
|
|
|
249
234
|
perPage?: number;
|
|
250
235
|
|
|
251
236
|
/**
|
|
252
|
-
* The
|
|
237
|
+
* The fields to render
|
|
253
238
|
*/
|
|
254
239
|
fields?: string[];
|
|
255
240
|
}
|
|
256
241
|
|
|
242
|
+
export interface CombinedField {
|
|
243
|
+
id: string;
|
|
244
|
+
|
|
245
|
+
label: string;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The fields to use as columns.
|
|
249
|
+
*/
|
|
250
|
+
children: string[];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The direction of the stack.
|
|
254
|
+
*/
|
|
255
|
+
direction: 'horizontal' | 'vertical';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface ColumnStyle {
|
|
259
|
+
/**
|
|
260
|
+
* The width of the field column.
|
|
261
|
+
*/
|
|
262
|
+
width?: string | number;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The minimum width of the field column.
|
|
266
|
+
*/
|
|
267
|
+
maxWidth?: string | number;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The maximum width of the field column.
|
|
271
|
+
*/
|
|
272
|
+
minWidth?: string | number;
|
|
273
|
+
}
|
|
274
|
+
|
|
257
275
|
export interface ViewTable extends ViewBase {
|
|
258
276
|
type: 'table';
|
|
259
277
|
|
|
@@ -264,9 +282,14 @@ export interface ViewTable extends ViewBase {
|
|
|
264
282
|
primaryField?: string;
|
|
265
283
|
|
|
266
284
|
/**
|
|
267
|
-
* The
|
|
285
|
+
* The fields to use as columns.
|
|
268
286
|
*/
|
|
269
|
-
|
|
287
|
+
combinedFields?: CombinedField[];
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The styles for the columns.
|
|
291
|
+
*/
|
|
292
|
+
styles?: Record< string, ColumnStyle >;
|
|
270
293
|
};
|
|
271
294
|
}
|
|
272
295
|
|
|
@@ -407,10 +430,11 @@ export interface ViewBaseProps< Item > {
|
|
|
407
430
|
getItemId: ( item: Item ) => string;
|
|
408
431
|
isLoading?: boolean;
|
|
409
432
|
onChangeView: ( view: View ) => void;
|
|
410
|
-
|
|
433
|
+
onChangeSelection: SetSelection;
|
|
411
434
|
selection: string[];
|
|
412
435
|
setOpenedFilter: ( fieldId: string ) => void;
|
|
413
436
|
view: View;
|
|
437
|
+
density: number;
|
|
414
438
|
}
|
|
415
439
|
|
|
416
440
|
export interface ViewTableProps< Item > extends ViewBaseProps< Item > {
|