@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
package/build-types/types.d.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
|
* Internal dependencies
|
|
7
7
|
*/
|
|
@@ -46,7 +46,7 @@ export type Field<Item> = {
|
|
|
46
46
|
/**
|
|
47
47
|
* The label of the field. Defaults to the id.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
label?: string;
|
|
50
50
|
/**
|
|
51
51
|
* Placeholder for the field.
|
|
52
52
|
*/
|
|
@@ -54,21 +54,9 @@ export type Field<Item> = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Callback used to render the field. Defaults to `field.getValue`.
|
|
56
56
|
*/
|
|
57
|
-
render?:
|
|
57
|
+
render?: ComponentType<{
|
|
58
58
|
item: Item;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The width of the field column.
|
|
62
|
-
*/
|
|
63
|
-
width?: string | number;
|
|
64
|
-
/**
|
|
65
|
-
* The minimum width of the field column.
|
|
66
|
-
*/
|
|
67
|
-
maxWidth?: string | number;
|
|
68
|
-
/**
|
|
69
|
-
* The maximum width of the field column.
|
|
70
|
-
*/
|
|
71
|
-
minWidth?: string | number;
|
|
59
|
+
}>;
|
|
72
60
|
/**
|
|
73
61
|
* Whether the field is sortable.
|
|
74
62
|
*/
|
|
@@ -107,13 +95,13 @@ export type Field<Item> = {
|
|
|
107
95
|
}) => any;
|
|
108
96
|
});
|
|
109
97
|
export type NormalizedField<Item> = Field<Item> & {
|
|
110
|
-
|
|
98
|
+
label: string;
|
|
111
99
|
getValue: (args: {
|
|
112
100
|
item: Item;
|
|
113
101
|
}) => any;
|
|
114
|
-
render:
|
|
102
|
+
render: ComponentType<{
|
|
115
103
|
item: Item;
|
|
116
|
-
}
|
|
104
|
+
}>;
|
|
117
105
|
};
|
|
118
106
|
/**
|
|
119
107
|
* A collection of dataview fields for a data type.
|
|
@@ -208,10 +196,36 @@ interface ViewBase {
|
|
|
208
196
|
*/
|
|
209
197
|
perPage?: number;
|
|
210
198
|
/**
|
|
211
|
-
* The
|
|
199
|
+
* The fields to render
|
|
212
200
|
*/
|
|
213
201
|
fields?: string[];
|
|
214
202
|
}
|
|
203
|
+
export interface CombinedField {
|
|
204
|
+
id: string;
|
|
205
|
+
label: string;
|
|
206
|
+
/**
|
|
207
|
+
* The fields to use as columns.
|
|
208
|
+
*/
|
|
209
|
+
children: string[];
|
|
210
|
+
/**
|
|
211
|
+
* The direction of the stack.
|
|
212
|
+
*/
|
|
213
|
+
direction: 'horizontal' | 'vertical';
|
|
214
|
+
}
|
|
215
|
+
export interface ColumnStyle {
|
|
216
|
+
/**
|
|
217
|
+
* The width of the field column.
|
|
218
|
+
*/
|
|
219
|
+
width?: string | number;
|
|
220
|
+
/**
|
|
221
|
+
* The minimum width of the field column.
|
|
222
|
+
*/
|
|
223
|
+
maxWidth?: string | number;
|
|
224
|
+
/**
|
|
225
|
+
* The maximum width of the field column.
|
|
226
|
+
*/
|
|
227
|
+
minWidth?: string | number;
|
|
228
|
+
}
|
|
215
229
|
export interface ViewTable extends ViewBase {
|
|
216
230
|
type: 'table';
|
|
217
231
|
layout?: {
|
|
@@ -220,9 +234,13 @@ export interface ViewTable extends ViewBase {
|
|
|
220
234
|
*/
|
|
221
235
|
primaryField?: string;
|
|
222
236
|
/**
|
|
223
|
-
* The
|
|
237
|
+
* The fields to use as columns.
|
|
224
238
|
*/
|
|
225
|
-
|
|
239
|
+
combinedFields?: CombinedField[];
|
|
240
|
+
/**
|
|
241
|
+
* The styles for the columns.
|
|
242
|
+
*/
|
|
243
|
+
styles?: Record<string, ColumnStyle>;
|
|
226
244
|
};
|
|
227
245
|
}
|
|
228
246
|
export interface ViewList extends ViewBase {
|
|
@@ -333,10 +351,11 @@ export interface ViewBaseProps<Item> {
|
|
|
333
351
|
getItemId: (item: Item) => string;
|
|
334
352
|
isLoading?: boolean;
|
|
335
353
|
onChangeView: (view: View) => void;
|
|
336
|
-
|
|
354
|
+
onChangeSelection: SetSelection;
|
|
337
355
|
selection: string[];
|
|
338
356
|
setOpenedFilter: (fieldId: string) => void;
|
|
339
357
|
view: View;
|
|
358
|
+
density: number;
|
|
340
359
|
}
|
|
341
360
|
export interface ViewTableProps<Item> extends ViewBaseProps<Item> {
|
|
342
361
|
view: ViewTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEzD;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,MAAM,CAAE,KAAK,SAAS,GAAG,GAAG,GAAG;IAC/C,KAAK,EAAE,K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IAAI,EAAE,QAAQ,CAAC;CACf;AAED,MAAM,WAAW,aAAa,CAAE,IAAI,CAAG,SAAQ,aAAa,CAAE,IAAI,CAAE;IACnE,IAAI,EAAE,QAAQ,CAAC;CACf;AAED,MAAM,MAAM,SAAS,CAAE,IAAI,IACxB,cAAc,CAAE,IAAI,CAAE,GACtB,aAAa,CAAE,IAAI,CAAE,GACrB,aAAa,CAAE,IAAI,CAAE,CAAC;AAEzB,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,IAAI,CAAE,QAAQ,EAAE,MAAM,CAAE,CAAC;IAChC,IAAI,CAAC,EAAE,IAAI,CAAE,QAAQ,EAAE,MAAM,CAAE,CAAC;IAChC,KAAK,CAAC,EAAE,IAAI,CAAE,SAAS,EAAE,MAAM,CAAE,CAAC;CAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ariakit/react": "^0.3.12",
|
|
32
32
|
"@babel/runtime": "^7.16.0",
|
|
33
|
-
"@wordpress/components": "^28.
|
|
34
|
-
"@wordpress/compose": "^7.
|
|
35
|
-
"@wordpress/data": "^10.
|
|
36
|
-
"@wordpress/element": "^6.
|
|
37
|
-
"@wordpress/i18n": "^5.
|
|
38
|
-
"@wordpress/icons": "^10.
|
|
39
|
-
"@wordpress/primitives": "^4.
|
|
40
|
-
"@wordpress/private-apis": "^1.
|
|
33
|
+
"@wordpress/components": "^28.4.0",
|
|
34
|
+
"@wordpress/compose": "^7.4.0",
|
|
35
|
+
"@wordpress/data": "^10.4.0",
|
|
36
|
+
"@wordpress/element": "^6.4.0",
|
|
37
|
+
"@wordpress/i18n": "^5.4.0",
|
|
38
|
+
"@wordpress/icons": "^10.4.0",
|
|
39
|
+
"@wordpress/primitives": "^4.4.0",
|
|
40
|
+
"@wordpress/private-apis": "^1.4.0",
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"remove-accents": "^0.5.0"
|
|
43
43
|
},
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "363edb39b8dda8727f652e42cbb8497732693ed2"
|
|
51
51
|
}
|
|
@@ -12,8 +12,8 @@ import { useCallback, useMemo } from '@wordpress/element';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import type { Form, Field, NormalizedField } from '
|
|
16
|
-
import { normalizeFields } from '
|
|
15
|
+
import type { Form, Field, NormalizedField } from '../../types';
|
|
16
|
+
import { normalizeFields } from '../../normalize-fields';
|
|
17
17
|
|
|
18
18
|
type DataFormProps< Item > = {
|
|
19
19
|
data: Item;
|
|
@@ -33,7 +33,7 @@ function DataFormTextControl< Item >( {
|
|
|
33
33
|
field,
|
|
34
34
|
onChange,
|
|
35
35
|
}: DataFormControlProps< Item > ) {
|
|
36
|
-
const { id,
|
|
36
|
+
const { id, label, placeholder } = field;
|
|
37
37
|
const value = field.getValue( { item: data } );
|
|
38
38
|
|
|
39
39
|
const onChangeControl = useCallback(
|
|
@@ -47,9 +47,9 @@ function DataFormTextControl< Item >( {
|
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<TextControl
|
|
50
|
-
label={
|
|
50
|
+
label={ label }
|
|
51
51
|
placeholder={ placeholder }
|
|
52
|
-
value={ value }
|
|
52
|
+
value={ value ?? '' }
|
|
53
53
|
onChange={ onChangeControl }
|
|
54
54
|
__next40pxDefaultSize
|
|
55
55
|
/>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import DataForm from '../index';
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'DataViews/DataForm',
|
|
13
|
+
component: DataForm,
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
const fields = [
|
|
18
|
+
{
|
|
19
|
+
id: 'title',
|
|
20
|
+
label: 'Title',
|
|
21
|
+
type: 'text' as const,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const Default = () => {
|
|
26
|
+
const [ post, setPost ] = useState( {
|
|
27
|
+
title: 'Hello, World!',
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
const form = {
|
|
31
|
+
visibleFields: [ 'title' ],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<DataForm
|
|
36
|
+
data={ post }
|
|
37
|
+
fields={ fields }
|
|
38
|
+
form={ form }
|
|
39
|
+
onChange={ setPost }
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __experimentalHStack as HStack } from '@wordpress/components';
|
|
10
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { default as DataViewsBulkActions } from '../dataviews-bulk-actions';
|
|
16
|
+
import DataViewsBulkActionsToolbar from '../dataviews-bulk-actions-toolbar';
|
|
17
|
+
import DataViewsContext from '../dataviews-context';
|
|
18
|
+
import DataViewsFilters from '../dataviews-filters';
|
|
19
|
+
import DataViewsLayout from '../dataviews-layout';
|
|
20
|
+
import DataviewsPagination from '../dataviews-pagination';
|
|
21
|
+
import DataViewsSearch from '../dataviews-search';
|
|
22
|
+
import DataViewsViewConfig from '../dataviews-view-config';
|
|
23
|
+
import { normalizeFields } from '../../normalize-fields';
|
|
24
|
+
import type { Action, Field, View, SupportedLayouts } from '../../types';
|
|
25
|
+
import type { SelectionOrUpdater } from '../../private-types';
|
|
26
|
+
import DensityPicker from '../../layouts/grid/density-picker';
|
|
27
|
+
import { LAYOUT_GRID } from '../../constants';
|
|
28
|
+
|
|
29
|
+
type ItemWithId = { id: string };
|
|
30
|
+
|
|
31
|
+
type DataViewsProps< Item > = {
|
|
32
|
+
view: View;
|
|
33
|
+
onChangeView: ( view: View ) => void;
|
|
34
|
+
fields: Field< Item >[];
|
|
35
|
+
search?: boolean;
|
|
36
|
+
searchLabel?: string;
|
|
37
|
+
actions?: Action< Item >[];
|
|
38
|
+
data: Item[];
|
|
39
|
+
isLoading?: boolean;
|
|
40
|
+
paginationInfo: {
|
|
41
|
+
totalItems: number;
|
|
42
|
+
totalPages: number;
|
|
43
|
+
};
|
|
44
|
+
defaultLayouts: SupportedLayouts;
|
|
45
|
+
selection?: string[];
|
|
46
|
+
onChangeSelection?: ( items: string[] ) => void;
|
|
47
|
+
header?: ReactNode;
|
|
48
|
+
} & ( Item extends ItemWithId
|
|
49
|
+
? { getItemId?: ( item: Item ) => string }
|
|
50
|
+
: { getItemId: ( item: Item ) => string } );
|
|
51
|
+
|
|
52
|
+
const defaultGetItemId = ( item: ItemWithId ) => item.id;
|
|
53
|
+
|
|
54
|
+
export default function DataViews< Item >( {
|
|
55
|
+
view,
|
|
56
|
+
onChangeView,
|
|
57
|
+
fields,
|
|
58
|
+
search = true,
|
|
59
|
+
searchLabel = undefined,
|
|
60
|
+
actions = [],
|
|
61
|
+
data,
|
|
62
|
+
getItemId = defaultGetItemId,
|
|
63
|
+
isLoading = false,
|
|
64
|
+
paginationInfo,
|
|
65
|
+
defaultLayouts,
|
|
66
|
+
selection: selectionProperty,
|
|
67
|
+
onChangeSelection,
|
|
68
|
+
header,
|
|
69
|
+
}: DataViewsProps< Item > ) {
|
|
70
|
+
const [ selectionState, setSelectionState ] = useState< string[] >( [] );
|
|
71
|
+
const [ density, setDensity ] = useState< number >( 0 );
|
|
72
|
+
const isUncontrolled =
|
|
73
|
+
selectionProperty === undefined || onChangeSelection === undefined;
|
|
74
|
+
const selection = isUncontrolled ? selectionState : selectionProperty;
|
|
75
|
+
const [ openedFilter, setOpenedFilter ] = useState< string | null >( null );
|
|
76
|
+
function setSelectionWithChange( value: SelectionOrUpdater ) {
|
|
77
|
+
const newValue =
|
|
78
|
+
typeof value === 'function' ? value( selection ) : value;
|
|
79
|
+
if ( isUncontrolled ) {
|
|
80
|
+
setSelectionState( newValue );
|
|
81
|
+
}
|
|
82
|
+
if ( onChangeSelection ) {
|
|
83
|
+
onChangeSelection( newValue );
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const _fields = useMemo( () => normalizeFields( fields ), [ fields ] );
|
|
87
|
+
const _selection = useMemo( () => {
|
|
88
|
+
return selection.filter( ( id ) =>
|
|
89
|
+
data.some( ( item ) => getItemId( item ) === id )
|
|
90
|
+
);
|
|
91
|
+
}, [ selection, data, getItemId ] );
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<DataViewsContext.Provider
|
|
95
|
+
value={ {
|
|
96
|
+
view,
|
|
97
|
+
onChangeView,
|
|
98
|
+
fields: _fields,
|
|
99
|
+
actions,
|
|
100
|
+
data,
|
|
101
|
+
isLoading,
|
|
102
|
+
paginationInfo,
|
|
103
|
+
selection: _selection,
|
|
104
|
+
onChangeSelection: setSelectionWithChange,
|
|
105
|
+
openedFilter,
|
|
106
|
+
setOpenedFilter,
|
|
107
|
+
getItemId,
|
|
108
|
+
density,
|
|
109
|
+
} }
|
|
110
|
+
>
|
|
111
|
+
<div className="dataviews-wrapper">
|
|
112
|
+
<HStack
|
|
113
|
+
alignment="top"
|
|
114
|
+
justify="start"
|
|
115
|
+
className="dataviews__view-actions"
|
|
116
|
+
>
|
|
117
|
+
<HStack
|
|
118
|
+
justify="start"
|
|
119
|
+
className="dataviews-filters__container"
|
|
120
|
+
wrap
|
|
121
|
+
>
|
|
122
|
+
{ search && <DataViewsSearch label={ searchLabel } /> }
|
|
123
|
+
<DataViewsFilters />
|
|
124
|
+
</HStack>
|
|
125
|
+
{ view.type === LAYOUT_GRID && (
|
|
126
|
+
<DensityPicker
|
|
127
|
+
density={ density }
|
|
128
|
+
setDensity={ setDensity }
|
|
129
|
+
/>
|
|
130
|
+
) }
|
|
131
|
+
<DataViewsBulkActions />
|
|
132
|
+
<HStack
|
|
133
|
+
spacing={ 1 }
|
|
134
|
+
expanded={ false }
|
|
135
|
+
style={ { flexShrink: 0 } }
|
|
136
|
+
>
|
|
137
|
+
<DataViewsViewConfig
|
|
138
|
+
defaultLayouts={ defaultLayouts }
|
|
139
|
+
/>
|
|
140
|
+
{ header }
|
|
141
|
+
</HStack>
|
|
142
|
+
</HStack>
|
|
143
|
+
<DataViewsLayout />
|
|
144
|
+
<DataviewsPagination />
|
|
145
|
+
<DataViewsBulkActionsToolbar />
|
|
146
|
+
</div>
|
|
147
|
+
</DataViewsContext.Provider>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import { LAYOUT_TABLE } from '
|
|
15
|
+
import { LAYOUT_TABLE } from '../../../constants';
|
|
16
16
|
|
|
17
17
|
export const data = [
|
|
18
18
|
{
|
|
@@ -160,27 +160,24 @@ export const actions = [
|
|
|
160
160
|
|
|
161
161
|
export const fields = [
|
|
162
162
|
{
|
|
163
|
-
|
|
163
|
+
label: 'Image',
|
|
164
164
|
id: 'image',
|
|
165
165
|
render: ( { item } ) => {
|
|
166
166
|
return (
|
|
167
167
|
<img src={ item.image } alt="" style={ { width: '100%' } } />
|
|
168
168
|
);
|
|
169
169
|
},
|
|
170
|
-
width: 50,
|
|
171
170
|
enableSorting: false,
|
|
172
171
|
},
|
|
173
172
|
{
|
|
174
|
-
|
|
173
|
+
label: 'Title',
|
|
175
174
|
id: 'title',
|
|
176
|
-
maxWidth: 400,
|
|
177
175
|
enableHiding: false,
|
|
178
176
|
enableGlobalSearch: true,
|
|
179
177
|
},
|
|
180
178
|
{
|
|
181
|
-
|
|
179
|
+
label: 'Type',
|
|
182
180
|
id: 'type',
|
|
183
|
-
maxWidth: 400,
|
|
184
181
|
enableHiding: false,
|
|
185
182
|
elements: [
|
|
186
183
|
{ value: 'Not a planet', label: 'Not a planet' },
|
|
@@ -190,19 +187,18 @@ export const fields = [
|
|
|
190
187
|
],
|
|
191
188
|
},
|
|
192
189
|
{
|
|
193
|
-
|
|
190
|
+
label: 'Satellites',
|
|
194
191
|
id: 'satellites',
|
|
195
192
|
enableSorting: true,
|
|
196
193
|
},
|
|
197
194
|
{
|
|
198
|
-
|
|
195
|
+
label: 'Description',
|
|
199
196
|
id: 'description',
|
|
200
|
-
maxWidth: 200,
|
|
201
197
|
enableSorting: false,
|
|
202
198
|
enableGlobalSearch: true,
|
|
203
199
|
},
|
|
204
200
|
{
|
|
205
|
-
|
|
201
|
+
label: 'Categories',
|
|
206
202
|
id: 'categories',
|
|
207
203
|
elements: [
|
|
208
204
|
{ value: 'Space', label: 'Space' },
|
|
@@ -6,10 +6,10 @@ import { useState, useMemo } from '@wordpress/element';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import DataViews from '../index';
|
|
10
10
|
import { DEFAULT_VIEW, actions, data, fields } from './fixtures';
|
|
11
|
-
import { LAYOUT_GRID, LAYOUT_TABLE } from '
|
|
12
|
-
import { filterSortAndPaginate } from '
|
|
11
|
+
import { LAYOUT_GRID, LAYOUT_TABLE } from '../../../constants';
|
|
12
|
+
import { filterSortAndPaginate } from '../../../filter-and-sort-data-view';
|
|
13
13
|
|
|
14
14
|
const meta = {
|
|
15
15
|
title: 'DataViews/DataViews',
|
|
@@ -39,6 +39,20 @@ Default.args = {
|
|
|
39
39
|
[ LAYOUT_TABLE ]: {
|
|
40
40
|
layout: {
|
|
41
41
|
primaryField: 'title',
|
|
42
|
+
styles: {
|
|
43
|
+
image: {
|
|
44
|
+
width: 50,
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
maxWidth: 400,
|
|
48
|
+
},
|
|
49
|
+
type: {
|
|
50
|
+
maxWidth: 400,
|
|
51
|
+
},
|
|
52
|
+
description: {
|
|
53
|
+
maxWidth: 200,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
42
56
|
},
|
|
43
57
|
},
|
|
44
58
|
[ LAYOUT_GRID ]: {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
.dataviews-wrapper {
|
|
2
|
+
height: 100%;
|
|
3
|
+
overflow: auto;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
scroll-padding-bottom: $grid-unit-80;
|
|
6
|
+
/* stylelint-disable-next-line property-no-unknown -- '@container' not globally permitted */
|
|
7
|
+
container: dataviews-wrapper / inline-size;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.dataviews__view-actions {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
padding: $grid-unit-20 $grid-unit-60;
|
|
15
|
+
flex-shrink: 0;
|
|
16
|
+
position: sticky;
|
|
17
|
+
left: 0;
|
|
18
|
+
transition: padding ease-out 0.1s;
|
|
19
|
+
@include reduce-motion("transition");
|
|
20
|
+
|
|
21
|
+
.components-search-control {
|
|
22
|
+
.components-base-control__field {
|
|
23
|
+
max-width: 240px;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dataviews-view-list__primary-field,
|
|
29
|
+
.dataviews-view-grid__primary-field,
|
|
30
|
+
.dataviews-view-table__primary-field {
|
|
31
|
+
font-size: $default-font-size;
|
|
32
|
+
font-weight: 500;
|
|
33
|
+
color: $gray-700;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
width: 100%;
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
display: block;
|
|
44
|
+
flex-grow: 0;
|
|
45
|
+
color: $gray-900;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
color: var(--wp-admin-theme-color);
|
|
49
|
+
}
|
|
50
|
+
@include link-reset();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
button.components-button.is-link {
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
font-weight: inherit;
|
|
56
|
+
text-overflow: ellipsis;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
display: block;
|
|
60
|
+
width: 100%;
|
|
61
|
+
color: $gray-900;
|
|
62
|
+
&:hover {
|
|
63
|
+
color: var(--wp-admin-theme-color);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dataviews-no-results,
|
|
69
|
+
.dataviews-loading {
|
|
70
|
+
padding: 0 $grid-unit-60;
|
|
71
|
+
flex-grow: 1;
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
transition: padding ease-out 0.1s;
|
|
76
|
+
@include reduce-motion("transition");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* stylelint-disable-next-line scss/at-rule-no-unknown -- '@container' not globally permitted */
|
|
80
|
+
@container (max-width: 430px) {
|
|
81
|
+
.dataviews__view-actions {
|
|
82
|
+
padding: $grid-unit-15 $grid-unit-30;
|
|
83
|
+
|
|
84
|
+
.components-search-control {
|
|
85
|
+
.components-base-control__field {
|
|
86
|
+
max-width: 112px;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.dataviews-view-grid,
|
|
92
|
+
.dataviews-no-results,
|
|
93
|
+
.dataviews-loading {
|
|
94
|
+
padding-left: $grid-unit-30;
|
|
95
|
+
padding-right: $grid-unit-30;
|
|
96
|
+
}
|
|
97
|
+
}
|