@wordpress/dataviews 2.1.0 → 3.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 +24 -5
- package/README.md +5 -5
- package/build/add-filter.js +1 -1
- package/build/add-filter.js.map +1 -1
- package/build/bulk-actions-toolbar.js +5 -2
- package/build/bulk-actions-toolbar.js.map +1 -1
- package/build/bulk-actions.js +11 -21
- package/build/bulk-actions.js.map +1 -1
- package/build/dataform.js +78 -0
- package/build/dataform.js.map +1 -0
- package/build/dataviews.js +26 -31
- package/build/dataviews.js.map +1 -1
- package/build/filter-and-sort-data-view.js +4 -1
- package/build/filter-and-sort-data-view.js.map +1 -1
- package/build/filter-summary.js +6 -5
- package/build/filter-summary.js.map +1 -1
- package/build/filters.js +1 -1
- package/build/filters.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/item-actions.js +17 -6
- package/build/item-actions.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/pagination.js +2 -2
- package/build/pagination.js.map +1 -1
- package/build/private-types.js +6 -0
- package/build/private-types.js.map +1 -0
- package/build/reset-filters.js +1 -1
- package/build/reset-filters.js.map +1 -1
- package/build/search-widget.js +8 -6
- package/build/search-widget.js.map +1 -1
- package/build/single-selection-checkbox.js +5 -16
- package/build/single-selection-checkbox.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js.map +1 -1
- package/build/view-actions.js +76 -65
- package/build/view-actions.js.map +1 -1
- package/build/view-grid.js +7 -19
- package/build/view-grid.js.map +1 -1
- package/build/view-list.js +15 -8
- package/build/view-list.js.map +1 -1
- package/build/view-table.js +22 -25
- package/build/view-table.js.map +1 -1
- package/build-module/add-filter.js +1 -1
- package/build-module/add-filter.js.map +1 -1
- package/build-module/bulk-actions-toolbar.js +5 -2
- package/build-module/bulk-actions-toolbar.js.map +1 -1
- package/build-module/bulk-actions.js +12 -22
- package/build-module/bulk-actions.js.map +1 -1
- package/build-module/dataform.js +72 -0
- package/build-module/dataform.js.map +1 -0
- package/build-module/dataviews.js +24 -31
- package/build-module/dataviews.js.map +1 -1
- package/build-module/filter-and-sort-data-view.js +4 -1
- package/build-module/filter-and-sort-data-view.js.map +1 -1
- package/build-module/filter-summary.js +6 -5
- package/build-module/filter-summary.js.map +1 -1
- package/build-module/filters.js +1 -1
- package/build-module/filters.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/item-actions.js +17 -6
- package/build-module/item-actions.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/pagination.js +2 -2
- package/build-module/pagination.js.map +1 -1
- package/build-module/private-types.js +2 -0
- package/build-module/private-types.js.map +1 -0
- package/build-module/reset-filters.js +1 -1
- package/build-module/reset-filters.js.map +1 -1
- package/build-module/search-widget.js +8 -6
- package/build-module/search-widget.js.map +1 -1
- package/build-module/single-selection-checkbox.js +5 -16
- package/build-module/single-selection-checkbox.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils.js.map +1 -1
- package/build-module/view-actions.js +80 -68
- package/build-module/view-actions.js.map +1 -1
- package/build-module/view-grid.js +7 -19
- package/build-module/view-grid.js.map +1 -1
- package/build-module/view-list.js +15 -8
- package/build-module/view-list.js.map +1 -1
- package/build-module/view-table.js +22 -25
- package/build-module/view-table.js.map +1 -1
- package/build-style/style-rtl.css +8 -24
- package/build-style/style.css +8 -24
- package/build-types/bulk-actions-toolbar.d.ts +5 -4
- package/build-types/bulk-actions-toolbar.d.ts.map +1 -1
- package/build-types/bulk-actions.d.ts +7 -6
- package/build-types/bulk-actions.d.ts.map +1 -1
- package/build-types/dataform.d.ts +17 -0
- package/build-types/dataform.d.ts.map +1 -0
- package/build-types/dataviews.d.ts +15 -6
- package/build-types/dataviews.d.ts.map +1 -1
- package/build-types/filter-and-sort-data-view.d.ts +2 -2
- package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
- package/build-types/filter-summary.d.ts.map +1 -1
- package/build-types/filters.d.ts +3 -3
- package/build-types/filters.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/item-actions.d.ts +10 -10
- package/build-types/item-actions.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts +2 -2
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/private-types.d.ts +3 -0
- package/build-types/private-types.d.ts.map +1 -0
- package/build-types/single-selection-checkbox.d.ts +5 -5
- package/build-types/single-selection-checkbox.d.ts.map +1 -1
- package/build-types/stories/fixtures.d.ts +14 -1
- package/build-types/stories/fixtures.d.ts.map +1 -1
- package/build-types/stories/index.story.d.ts +15 -1
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/build-types/types.d.ts +73 -38
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils.d.ts +2 -2
- package/build-types/utils.d.ts.map +1 -1
- package/build-types/view-actions.d.ts +4 -4
- package/build-types/view-actions.d.ts.map +1 -1
- package/build-types/view-grid.d.ts +2 -2
- package/build-types/view-grid.d.ts.map +1 -1
- package/build-types/view-list.d.ts +2 -2
- package/build-types/view-list.d.ts.map +1 -1
- package/build-types/view-table.d.ts +2 -2
- package/build-types/view-table.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/add-filter.tsx +1 -1
- package/src/bulk-actions-toolbar.tsx +18 -14
- package/src/bulk-actions.tsx +31 -45
- package/src/dataform.tsx +106 -0
- package/src/dataviews.tsx +55 -60
- package/src/filter-and-sort-data-view.ts +13 -3
- package/src/filter-summary.tsx +18 -12
- package/src/filters.tsx +4 -4
- package/src/index.ts +1 -0
- package/src/item-actions.tsx +27 -24
- package/src/lock-unlock.ts +1 -1
- package/src/normalize-fields.ts +5 -3
- package/src/pagination.tsx +2 -2
- package/src/private-types.tsx +2 -0
- package/src/reset-filters.tsx +1 -1
- package/src/search-widget.tsx +6 -6
- package/src/single-selection-checkbox.tsx +14 -29
- package/src/stories/fixtures.js +17 -1
- package/src/stories/index.story.js +15 -28
- package/src/style.scss +10 -22
- package/src/test/filter-and-sort-data-view.js +16 -1
- package/src/types.ts +75 -47
- package/src/utils.ts +2 -4
- package/src/view-actions.tsx +105 -102
- package/src/view-grid.tsx +21 -38
- package/src/view-list.tsx +22 -22
- package/src/view-table.tsx +45 -45
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-types.d.ts","sourceRoot":"","sources":["../src/private-types.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,MAAM,EAAE,GAAG,CAAE,CAAE,IAAI,EAAE,MAAM,EAAE,KAAM,MAAM,EAAE,CAAE,CAAC;AAC/E,MAAM,MAAM,YAAY,GAAG,CAAE,SAAS,EAAE,kBAAkB,KAAM,IAAI,CAAC"}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Internal dependencies
|
|
4
4
|
*/
|
|
5
|
-
import type { Field
|
|
6
|
-
|
|
5
|
+
import type { Field } from './types';
|
|
6
|
+
import type { SetSelection } from './private-types';
|
|
7
|
+
interface SingleSelectionCheckboxProps<Item> {
|
|
7
8
|
selection: string[];
|
|
8
|
-
onSelectionChange:
|
|
9
|
+
onSelectionChange: SetSelection;
|
|
9
10
|
item: Item;
|
|
10
|
-
data: Item[];
|
|
11
11
|
getItemId: (item: Item) => string;
|
|
12
12
|
primaryField?: Field<Item>;
|
|
13
13
|
disabled: boolean;
|
|
14
14
|
}
|
|
15
|
-
export default function SingleSelectionCheckbox<Item
|
|
15
|
+
export default function SingleSelectionCheckbox<Item>({ selection, onSelectionChange, item, getItemId, primaryField, disabled, }: SingleSelectionCheckboxProps<Item>): import("react").JSX.Element;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=single-selection-checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-selection-checkbox.d.ts","sourceRoot":"","sources":["../src/single-selection-checkbox.tsx"],"names":[],"mappings":";AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"single-selection-checkbox.d.ts","sourceRoot":"","sources":["../src/single-selection-checkbox.tsx"],"names":[],"mappings":";AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,UAAU,4BAA4B,CAAE,IAAI;IAC3C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iBAAiB,EAAE,YAAY,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,MAAM,CAAC;IACpC,YAAY,CAAC,EAAE,KAAK,CAAE,IAAI,CAAE,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAE,IAAI,EAAI,EACxD,SAAS,EACT,iBAAiB,EACjB,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,GACR,EAAE,4BAA4B,CAAE,IAAI,CAAE,+BAoCtC"}
|
|
@@ -5,13 +5,14 @@ export const data: {
|
|
|
5
5
|
image: string;
|
|
6
6
|
type: string;
|
|
7
7
|
categories: string[];
|
|
8
|
+
satellites: number;
|
|
8
9
|
}[];
|
|
9
10
|
export namespace DEFAULT_VIEW {
|
|
10
11
|
export { LAYOUT_TABLE as type };
|
|
11
12
|
export let search: string;
|
|
12
13
|
export let page: number;
|
|
13
14
|
export let perPage: number;
|
|
14
|
-
export let
|
|
15
|
+
export let fields: string[];
|
|
15
16
|
export let layout: {};
|
|
16
17
|
export let filters: never[];
|
|
17
18
|
}
|
|
@@ -76,6 +77,18 @@ export const fields: ({
|
|
|
76
77
|
enableGlobalSearch?: undefined;
|
|
77
78
|
filterBy?: undefined;
|
|
78
79
|
getValue?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
header: string;
|
|
82
|
+
id: string;
|
|
83
|
+
enableSorting: boolean;
|
|
84
|
+
render?: undefined;
|
|
85
|
+
width?: undefined;
|
|
86
|
+
maxWidth?: undefined;
|
|
87
|
+
enableHiding?: undefined;
|
|
88
|
+
enableGlobalSearch?: undefined;
|
|
89
|
+
elements?: undefined;
|
|
90
|
+
filterBy?: undefined;
|
|
91
|
+
getValue?: undefined;
|
|
79
92
|
} | {
|
|
80
93
|
header: string;
|
|
81
94
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/stories/fixtures.js"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/stories/fixtures.js"],"names":[],"mappings":"AAgBA;;;;;;;;IAoGE;;;;;;;;;;AAYF;;;;;;;;;;;;;;;;;;;KA8BE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgEE;6BAlN2B,cAAc"}
|
|
@@ -3,7 +3,21 @@ export function Default(props: any): import("react").JSX.Element;
|
|
|
3
3
|
export namespace Default {
|
|
4
4
|
namespace args {
|
|
5
5
|
export { actions };
|
|
6
|
-
export
|
|
6
|
+
export namespace defaultLayouts {
|
|
7
|
+
namespace table {
|
|
8
|
+
namespace layout {
|
|
9
|
+
let primaryField: string;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
namespace grid {
|
|
13
|
+
export namespace layout_1 {
|
|
14
|
+
export let mediaField: string;
|
|
15
|
+
let primaryField_1: string;
|
|
16
|
+
export { primaryField_1 as primaryField };
|
|
17
|
+
}
|
|
18
|
+
export { layout_1 as layout };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
7
21
|
}
|
|
8
22
|
}
|
|
9
23
|
declare namespace meta {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.js"],"names":[],"mappings":";AAmBO,iEAeN;;;;;;;;;;;;;;;;;;;;;;;;;wBAzBmD,YAAY;0BADtC,UAAU"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { ReactElement, ReactNode } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import type { SetSelection } from './private-types';
|
|
5
9
|
export type SortDirection = 'asc' | 'desc';
|
|
6
10
|
/**
|
|
7
11
|
* Generic option type.
|
|
@@ -25,11 +29,16 @@ interface FilterByConfig {
|
|
|
25
29
|
isPrimary?: boolean;
|
|
26
30
|
}
|
|
27
31
|
export type Operator = 'is' | 'isNot' | 'isAny' | 'isNone' | 'isAll' | 'isNotAll';
|
|
28
|
-
export type
|
|
32
|
+
export type ItemRecord = Record<string, unknown>;
|
|
33
|
+
export type FieldType = 'text';
|
|
29
34
|
/**
|
|
30
35
|
* A dataview field for a specific property of a data type.
|
|
31
36
|
*/
|
|
32
|
-
export
|
|
37
|
+
export type Field<Item> = {
|
|
38
|
+
/**
|
|
39
|
+
* Type of the fields.
|
|
40
|
+
*/
|
|
41
|
+
type?: FieldType;
|
|
33
42
|
/**
|
|
34
43
|
* The unique identifier of the field.
|
|
35
44
|
*/
|
|
@@ -39,12 +48,9 @@ export interface Field<Item extends AnyItem> {
|
|
|
39
48
|
*/
|
|
40
49
|
header?: string;
|
|
41
50
|
/**
|
|
42
|
-
*
|
|
43
|
-
* Defaults to `item[ field.id ]`.
|
|
51
|
+
* Placeholder for the field.
|
|
44
52
|
*/
|
|
45
|
-
|
|
46
|
-
item: Item;
|
|
47
|
-
}) => any;
|
|
53
|
+
placeholder?: string;
|
|
48
54
|
/**
|
|
49
55
|
* Callback used to render the field. Defaults to `field.getValue`.
|
|
50
56
|
*/
|
|
@@ -83,13 +89,43 @@ export interface Field<Item extends AnyItem> {
|
|
|
83
89
|
* Filter config for the field.
|
|
84
90
|
*/
|
|
85
91
|
filterBy?: FilterByConfig | undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
92
|
+
} & (Item extends ItemRecord ? {
|
|
93
|
+
/**
|
|
94
|
+
* Callback used to retrieve the value of the field from the item.
|
|
95
|
+
* Defaults to `item[ field.id ]`.
|
|
96
|
+
*/
|
|
97
|
+
getValue?: (args: {
|
|
98
|
+
item: Item;
|
|
99
|
+
}) => any;
|
|
100
|
+
} : {
|
|
101
|
+
/**
|
|
102
|
+
* Callback used to retrieve the value of the field from the item.
|
|
103
|
+
* Defaults to `item[ field.id ]`.
|
|
104
|
+
*/
|
|
105
|
+
getValue: (args: {
|
|
106
|
+
item: Item;
|
|
107
|
+
}) => any;
|
|
108
|
+
});
|
|
109
|
+
export type NormalizedField<Item> = Field<Item> & {
|
|
110
|
+
header: string;
|
|
111
|
+
getValue: (args: {
|
|
112
|
+
item: Item;
|
|
113
|
+
}) => any;
|
|
114
|
+
render: (args: {
|
|
115
|
+
item: Item;
|
|
116
|
+
}) => ReactNode;
|
|
117
|
+
};
|
|
88
118
|
/**
|
|
89
119
|
* A collection of dataview fields for a data type.
|
|
90
120
|
*/
|
|
91
|
-
export type Fields<Item
|
|
92
|
-
export type Data<Item
|
|
121
|
+
export type Fields<Item> = Field<Item>[];
|
|
122
|
+
export type Data<Item> = Item[];
|
|
123
|
+
/**
|
|
124
|
+
* The form configuration.
|
|
125
|
+
*/
|
|
126
|
+
export type Form = {
|
|
127
|
+
visibleFields?: string[];
|
|
128
|
+
};
|
|
93
129
|
/**
|
|
94
130
|
* The filters applied to the dataset.
|
|
95
131
|
*/
|
|
@@ -149,7 +185,7 @@ interface ViewBase {
|
|
|
149
185
|
/**
|
|
150
186
|
* The filters to apply.
|
|
151
187
|
*/
|
|
152
|
-
filters
|
|
188
|
+
filters?: Filter[];
|
|
153
189
|
/**
|
|
154
190
|
* The sorting configuration.
|
|
155
191
|
*/
|
|
@@ -174,11 +210,11 @@ interface ViewBase {
|
|
|
174
210
|
/**
|
|
175
211
|
* The hidden fields.
|
|
176
212
|
*/
|
|
177
|
-
|
|
213
|
+
fields?: string[];
|
|
178
214
|
}
|
|
179
215
|
export interface ViewTable extends ViewBase {
|
|
180
216
|
type: 'table';
|
|
181
|
-
layout
|
|
217
|
+
layout?: {
|
|
182
218
|
/**
|
|
183
219
|
* The field to use as the primary field.
|
|
184
220
|
*/
|
|
@@ -191,7 +227,7 @@ export interface ViewTable extends ViewBase {
|
|
|
191
227
|
}
|
|
192
228
|
export interface ViewList extends ViewBase {
|
|
193
229
|
type: 'list';
|
|
194
|
-
layout
|
|
230
|
+
layout?: {
|
|
195
231
|
/**
|
|
196
232
|
* The field to use as the primary field.
|
|
197
233
|
*/
|
|
@@ -204,7 +240,7 @@ export interface ViewList extends ViewBase {
|
|
|
204
240
|
}
|
|
205
241
|
export interface ViewGrid extends ViewBase {
|
|
206
242
|
type: 'grid';
|
|
207
|
-
layout
|
|
243
|
+
layout?: {
|
|
208
244
|
/**
|
|
209
245
|
* The field to use as the primary field.
|
|
210
246
|
*/
|
|
@@ -224,7 +260,7 @@ export interface ViewGrid extends ViewBase {
|
|
|
224
260
|
};
|
|
225
261
|
}
|
|
226
262
|
export type View = ViewList | ViewGrid | ViewTable;
|
|
227
|
-
interface ActionBase<Item
|
|
263
|
+
interface ActionBase<Item> {
|
|
228
264
|
/**
|
|
229
265
|
* The unique identifier of the action.
|
|
230
266
|
*/
|
|
@@ -262,22 +298,13 @@ interface ActionBase<Item extends AnyItem> {
|
|
|
262
298
|
*/
|
|
263
299
|
supportsBulk?: boolean;
|
|
264
300
|
}
|
|
265
|
-
export interface ActionModal<Item
|
|
266
|
-
/**
|
|
267
|
-
* The callback to execute when the action has finished.
|
|
268
|
-
*/
|
|
269
|
-
onActionPerformed: ((items: Item[]) => void) | undefined;
|
|
270
|
-
/**
|
|
271
|
-
* The callback to execute when the action is triggered.
|
|
272
|
-
*/
|
|
273
|
-
onActionStart: ((items: Item[]) => void) | undefined;
|
|
301
|
+
export interface ActionModal<Item> extends ActionBase<Item> {
|
|
274
302
|
/**
|
|
275
303
|
* Modal to render when the action is triggered.
|
|
276
304
|
*/
|
|
277
|
-
RenderModal: ({ items, closeModal,
|
|
305
|
+
RenderModal: ({ items, closeModal, onActionPerformed, }: {
|
|
278
306
|
items: Item[];
|
|
279
307
|
closeModal?: () => void;
|
|
280
|
-
onActionStart?: (items: Item[]) => void;
|
|
281
308
|
onActionPerformed?: (items: Item[]) => void;
|
|
282
309
|
}) => ReactElement;
|
|
283
310
|
/**
|
|
@@ -289,34 +316,42 @@ export interface ActionModal<Item extends AnyItem> extends ActionBase<Item> {
|
|
|
289
316
|
*/
|
|
290
317
|
modalHeader?: string;
|
|
291
318
|
}
|
|
292
|
-
export interface ActionButton<Item
|
|
319
|
+
export interface ActionButton<Item> extends ActionBase<Item> {
|
|
293
320
|
/**
|
|
294
321
|
* The callback to execute when the action is triggered.
|
|
295
322
|
*/
|
|
296
|
-
callback: (items: Item[]
|
|
323
|
+
callback: (items: Item[], context: {
|
|
324
|
+
registry: any;
|
|
325
|
+
onActionPerformed?: (items: Item[]) => void;
|
|
326
|
+
}) => void;
|
|
297
327
|
}
|
|
298
|
-
export type Action<Item
|
|
299
|
-
export interface ViewBaseProps<Item
|
|
328
|
+
export type Action<Item> = ActionModal<Item> | ActionButton<Item>;
|
|
329
|
+
export interface ViewBaseProps<Item> {
|
|
300
330
|
actions: Action<Item>[];
|
|
301
331
|
data: Item[];
|
|
302
332
|
fields: NormalizedField<Item>[];
|
|
303
333
|
getItemId: (item: Item) => string;
|
|
304
334
|
isLoading?: boolean;
|
|
305
|
-
onChangeView(view: View)
|
|
306
|
-
onSelectionChange:
|
|
335
|
+
onChangeView: (view: View) => void;
|
|
336
|
+
onSelectionChange: SetSelection;
|
|
307
337
|
selection: string[];
|
|
308
338
|
setOpenedFilter: (fieldId: string) => void;
|
|
309
339
|
view: View;
|
|
310
340
|
}
|
|
311
|
-
export interface ViewTableProps<Item
|
|
341
|
+
export interface ViewTableProps<Item> extends ViewBaseProps<Item> {
|
|
312
342
|
view: ViewTable;
|
|
313
343
|
}
|
|
314
|
-
export interface ViewListProps<Item
|
|
344
|
+
export interface ViewListProps<Item> extends ViewBaseProps<Item> {
|
|
315
345
|
view: ViewList;
|
|
316
346
|
}
|
|
317
|
-
export interface ViewGridProps<Item
|
|
347
|
+
export interface ViewGridProps<Item> extends ViewBaseProps<Item> {
|
|
318
348
|
view: ViewGrid;
|
|
319
349
|
}
|
|
320
|
-
export type ViewProps<Item
|
|
350
|
+
export type ViewProps<Item> = ViewTableProps<Item> | ViewGridProps<Item> | ViewListProps<Item>;
|
|
351
|
+
export interface SupportedLayouts {
|
|
352
|
+
list?: Omit<ViewList, 'type'>;
|
|
353
|
+
grid?: Omit<ViewGrid, 'type'>;
|
|
354
|
+
table?: Omit<ViewTable, 'type'>;
|
|
355
|
+
}
|
|
321
356
|
export {};
|
|
322
357
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,MAAM,CAAE,KAAK,SAAS,GAAG,GAAG,GAAG;IAC/C,KAAK,EAAE,KAAK,CAAC;IAC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,KAAM,IAAI,CAAC;IACrC,iBAAiB,EAAE,YAAY,CAAC;IAChC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,EAAE,CAAE,OAAO,EAAE,MAAM,KAAM,IAAI,CAAC;IAC7C,IAAI,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,cAAc,CAAE,IAAI,CAAG,SAAQ,aAAa,CAAE,IAAI,CAAE;IACpE,IAAI,EAAE,SAAS,CAAC;CAChB;AAED,MAAM,WAAW,aAAa,CAAE,IAAI,CAAG,SAAQ,aAAa,CAAE,IAAI,CAAE;IACnE,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/build-types/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function sanitizeOperators<Item
|
|
1
|
+
import type { NormalizedField } from './types';
|
|
2
|
+
export declare function sanitizeOperators<Item>(field: NormalizedField<Item>): import("./types").Operator[];
|
|
3
3
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,iBAAiB,CAAE,IAAI,EAAI,KAAK,EAAE,eAAe,CAAE,IAAI,CAAE,gCAyBxE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
interface ViewActionsProps<Item
|
|
2
|
+
import type { NormalizedField, View, SupportedLayouts } from './types';
|
|
3
|
+
interface ViewActionsProps<Item> {
|
|
4
4
|
fields: NormalizedField<Item>[];
|
|
5
5
|
view: View;
|
|
6
6
|
onChangeView: (view: View) => void;
|
|
7
|
-
|
|
7
|
+
defaultLayouts?: SupportedLayouts;
|
|
8
8
|
}
|
|
9
|
-
declare function _ViewActions<Item
|
|
9
|
+
declare function _ViewActions<Item>({ fields, view, onChangeView, defaultLayouts, }: ViewActionsProps<Item>): import("react").JSX.Element;
|
|
10
10
|
declare const ViewActions: typeof _ViewActions;
|
|
11
11
|
export default ViewActions;
|
|
12
12
|
//# sourceMappingURL=view-actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-actions.d.ts","sourceRoot":"","sources":["../src/view-actions.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"view-actions.d.ts","sourceRoot":"","sources":["../src/view-actions.tsx"],"names":[],"mappings":";AAuBA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAkCvE,UAAU,gBAAgB,CAAE,IAAI;IAC/B,MAAM,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACrC,cAAc,CAAC,EAAE,gBAAgB,CAAC;CAClC;AA6ND,iBAAS,YAAY,CAAE,IAAI,EAAI,EAC9B,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,cAAc,GACd,EAAE,gBAAgB,CAAE,IAAI,CAAE,+BAwD1B;AAGD,QAAA,MAAM,WAAW,qBAA8C,CAAC;AAEhE,eAAe,WAAW,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
export default function ViewGrid<Item
|
|
2
|
+
import type { ViewGridProps } from './types';
|
|
3
|
+
export default function ViewGrid<Item>({ actions, data, fields, getItemId, isLoading, onSelectionChange, selection, view, }: ViewGridProps<Item>): import("react").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=view-grid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-grid.d.ts","sourceRoot":"","sources":["../src/view-grid.tsx"],"names":[],"mappings":";AAwBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"view-grid.d.ts","sourceRoot":"","sources":["../src/view-grid.tsx"],"names":[],"mappings":";AAwBA,OAAO,KAAK,EAA2B,aAAa,EAAE,MAAM,SAAS,CAAC;AAmJtE,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,EAAI,EACzC,OAAO,EACP,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,IAAI,GACJ,EAAE,aAAa,CAAE,IAAI,CAAE,+BAuEvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
export default function ViewList<Item
|
|
2
|
+
import type { ViewListProps } from './types';
|
|
3
|
+
export default function ViewList<Item>(props: ViewListProps<Item>): import("react").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=view-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-list.d.ts","sourceRoot":"","sources":["../src/view-list.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"view-list.d.ts","sourceRoot":"","sources":["../src/view-list.tsx"],"names":[],"mappings":";AAmCA,OAAO,KAAK,EAA2B,aAAa,EAAE,MAAM,SAAS,CAAC;AA8QtE,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,EAAI,KAAK,EAAE,aAAa,CAAE,IAAI,CAAE,+BAyGrE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
3
|
-
declare function ViewTable<Item
|
|
2
|
+
import type { ViewTableProps } from './types';
|
|
3
|
+
declare function ViewTable<Item>({ actions, data, fields, getItemId, isLoading, onChangeView, onSelectionChange, selection, setOpenedFilter, view, }: ViewTableProps<Item>): import("react").JSX.Element | undefined;
|
|
4
4
|
export default ViewTable;
|
|
5
5
|
//# sourceMappingURL=view-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-table.d.ts","sourceRoot":"","sources":["../src/view-table.tsx"],"names":[],"mappings":";AA8CA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"view-table.d.ts","sourceRoot":"","sources":["../src/view-table.tsx"],"names":[],"mappings":";AA8CA,OAAO,KAAK,EAKX,cAAc,EACd,MAAM,SAAS,CAAC;AA0WjB,iBAAS,SAAS,CAAE,IAAI,EAAI,EAC3B,OAAO,EACP,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,IAAI,GACJ,EAAE,cAAc,CAAE,IAAI,CAAE,2CAoKxB;AAED,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.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,13 +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/
|
|
36
|
-
"@wordpress/
|
|
37
|
-
"@wordpress/
|
|
38
|
-
"@wordpress/
|
|
39
|
-
"@wordpress/
|
|
33
|
+
"@wordpress/components": "^28.3.0",
|
|
34
|
+
"@wordpress/compose": "^7.3.0",
|
|
35
|
+
"@wordpress/data": "^10.3.0",
|
|
36
|
+
"@wordpress/element": "^6.3.0",
|
|
37
|
+
"@wordpress/i18n": "^5.3.0",
|
|
38
|
+
"@wordpress/icons": "^10.3.0",
|
|
39
|
+
"@wordpress/primitives": "^4.3.0",
|
|
40
|
+
"@wordpress/private-apis": "^1.3.0",
|
|
40
41
|
"clsx": "^2.1.1",
|
|
41
42
|
"remove-accents": "^0.5.0"
|
|
42
43
|
},
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "122867d355ca4edc63d3a3bbd9411d3a2e1458df"
|
|
50
51
|
}
|
package/src/add-filter.tsx
CHANGED
|
@@ -12,33 +12,35 @@ import { useMemo, useState, useRef } from '@wordpress/element';
|
|
|
12
12
|
import { _n, sprintf, __ } from '@wordpress/i18n';
|
|
13
13
|
import { closeSmall } from '@wordpress/icons';
|
|
14
14
|
import { useReducedMotion } from '@wordpress/compose';
|
|
15
|
+
import { useRegistry } from '@wordpress/data';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
18
19
|
*/
|
|
19
20
|
import { ActionWithModal } from './item-actions';
|
|
20
|
-
import type { Action
|
|
21
|
+
import type { Action } from './types';
|
|
21
22
|
import type { ActionTriggerProps } from './item-actions';
|
|
23
|
+
import type { SetSelection } from './private-types';
|
|
22
24
|
|
|
23
|
-
interface ActionButtonProps< Item
|
|
25
|
+
interface ActionButtonProps< Item > {
|
|
24
26
|
action: Action< Item >;
|
|
25
27
|
selectedItems: Item[];
|
|
26
28
|
actionInProgress: string | null;
|
|
27
29
|
setActionInProgress: ( actionId: string | null ) => void;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
interface ToolbarContentProps< Item
|
|
32
|
+
interface ToolbarContentProps< Item > {
|
|
31
33
|
selection: string[];
|
|
32
34
|
actionsToShow: Action< Item >[];
|
|
33
35
|
selectedItems: Item[];
|
|
34
|
-
onSelectionChange:
|
|
36
|
+
onSelectionChange: SetSelection;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
interface BulkActionsToolbarProps< Item
|
|
39
|
+
interface BulkActionsToolbarProps< Item > {
|
|
38
40
|
data: Item[];
|
|
39
41
|
selection: string[];
|
|
40
42
|
actions: Action< Item >[];
|
|
41
|
-
onSelectionChange:
|
|
43
|
+
onSelectionChange: SetSelection;
|
|
42
44
|
getItemId: ( item: Item ) => string;
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -61,7 +63,7 @@ const SNACKBAR_VARIANTS = {
|
|
|
61
63
|
},
|
|
62
64
|
};
|
|
63
65
|
|
|
64
|
-
function ActionTrigger< Item
|
|
66
|
+
function ActionTrigger< Item >( {
|
|
65
67
|
action,
|
|
66
68
|
onClick,
|
|
67
69
|
isBusy,
|
|
@@ -78,7 +80,6 @@ function ActionTrigger< Item extends AnyItem >( {
|
|
|
78
80
|
size="compact"
|
|
79
81
|
onClick={ onClick }
|
|
80
82
|
isBusy={ isBusy }
|
|
81
|
-
__experimentalIsFocusable
|
|
82
83
|
tooltipPosition="top"
|
|
83
84
|
/>
|
|
84
85
|
);
|
|
@@ -86,12 +87,13 @@ function ActionTrigger< Item extends AnyItem >( {
|
|
|
86
87
|
|
|
87
88
|
const EMPTY_ARRAY: [] = [];
|
|
88
89
|
|
|
89
|
-
function ActionButton< Item
|
|
90
|
+
function ActionButton< Item >( {
|
|
90
91
|
action,
|
|
91
92
|
selectedItems,
|
|
92
93
|
actionInProgress,
|
|
93
94
|
setActionInProgress,
|
|
94
95
|
}: ActionButtonProps< Item > ) {
|
|
96
|
+
const registry = useRegistry();
|
|
95
97
|
const selectedEligibleItems = useMemo( () => {
|
|
96
98
|
return selectedItems.filter( ( item ) => {
|
|
97
99
|
return ! action.isEligible || action.isEligible( item );
|
|
@@ -113,7 +115,9 @@ function ActionButton< Item extends AnyItem >( {
|
|
|
113
115
|
action={ action }
|
|
114
116
|
onClick={ () => {
|
|
115
117
|
setActionInProgress( action.id );
|
|
116
|
-
action.callback( selectedItems
|
|
118
|
+
action.callback( selectedItems, {
|
|
119
|
+
registry,
|
|
120
|
+
} );
|
|
117
121
|
} }
|
|
118
122
|
items={ selectedEligibleItems }
|
|
119
123
|
isBusy={ actionInProgress === action.id }
|
|
@@ -121,13 +125,13 @@ function ActionButton< Item extends AnyItem >( {
|
|
|
121
125
|
);
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
function renderToolbarContent< Item
|
|
128
|
+
function renderToolbarContent< Item >(
|
|
125
129
|
selection: string[],
|
|
126
130
|
actionsToShow: Action< Item >[],
|
|
127
131
|
selectedItems: Item[],
|
|
128
132
|
actionInProgress: string | null,
|
|
129
133
|
setActionInProgress: ( actionId: string | null ) => void,
|
|
130
|
-
onSelectionChange:
|
|
134
|
+
onSelectionChange: SetSelection
|
|
131
135
|
) {
|
|
132
136
|
return (
|
|
133
137
|
<>
|
|
@@ -175,7 +179,7 @@ function renderToolbarContent< Item extends AnyItem >(
|
|
|
175
179
|
);
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
function ToolbarContent< Item
|
|
182
|
+
function ToolbarContent< Item >( {
|
|
179
183
|
selection,
|
|
180
184
|
actionsToShow,
|
|
181
185
|
selectedItems,
|
|
@@ -210,7 +214,7 @@ function ToolbarContent< Item extends AnyItem >( {
|
|
|
210
214
|
return buttons.current;
|
|
211
215
|
}
|
|
212
216
|
|
|
213
|
-
export default function BulkActionsToolbar< Item
|
|
217
|
+
export default function BulkActionsToolbar< Item >( {
|
|
214
218
|
data,
|
|
215
219
|
selection,
|
|
216
220
|
actions = EMPTY_ARRAY,
|