@vaadin/crud 24.6.0-beta1 → 24.7.0-alpha1
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/package.json +15 -15
- package/src/vaadin-crud-grid-mixin.d.ts +39 -0
- package/src/vaadin-crud-grid-mixin.js +266 -0
- package/src/vaadin-crud-grid.d.ts +2 -20
- package/src/vaadin-crud-grid.js +3 -249
- package/src/vaadin-crud-helpers.js +4 -0
- package/src/vaadin-crud-mixin.d.ts +269 -0
- package/src/vaadin-crud-mixin.js +1045 -0
- package/src/vaadin-crud.d.ts +13 -252
- package/src/vaadin-crud.js +3 -1033
- package/web-types.json +6 -6
- package/web-types.lit.json +4 -4
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2024 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
12
|
+
import type { GridFilterDefinition, GridSorterDefinition } from '@vaadin/grid/src/vaadin-grid.js';
|
|
13
|
+
|
|
14
|
+
export type CrudDataProviderCallback<T> = (items: T[], size?: number) => void;
|
|
15
|
+
|
|
16
|
+
export type CrudDataProviderParams = {
|
|
17
|
+
page: number;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
filters: GridFilterDefinition[];
|
|
20
|
+
sortOrders: GridSorterDefinition[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type CrudDataProvider<T> = (params: CrudDataProviderParams, callback: CrudDataProviderCallback<T>) => void;
|
|
24
|
+
|
|
25
|
+
export type CrudEditorPosition = '' | 'aside' | 'bottom';
|
|
26
|
+
|
|
27
|
+
export interface CrudI18n {
|
|
28
|
+
newItem: string;
|
|
29
|
+
editItem: string;
|
|
30
|
+
saveItem: string;
|
|
31
|
+
cancel: string;
|
|
32
|
+
deleteItem: string;
|
|
33
|
+
editLabel: string;
|
|
34
|
+
confirm: {
|
|
35
|
+
delete: {
|
|
36
|
+
title: string;
|
|
37
|
+
content: string;
|
|
38
|
+
button: {
|
|
39
|
+
confirm: string;
|
|
40
|
+
dismiss: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
cancel: {
|
|
44
|
+
title: string;
|
|
45
|
+
content: string;
|
|
46
|
+
button: {
|
|
47
|
+
confirm: string;
|
|
48
|
+
dismiss: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Fired when the `editorOpened` property changes.
|
|
56
|
+
*/
|
|
57
|
+
export type CrudEditorOpenedChangedEvent = CustomEvent<{ value: boolean }>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Fired when the `editedItem` property changes.
|
|
61
|
+
*/
|
|
62
|
+
export type CrudEditedItemChangedEvent<T> = CustomEvent<{ value: T }>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Fired when the `items` property changes.
|
|
66
|
+
*/
|
|
67
|
+
export type CrudItemsChangedEvent<T> = CustomEvent<{ value: T[] }>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Fired when the `size` property changes.
|
|
71
|
+
*/
|
|
72
|
+
export type CrudSizeChangedEvent = CustomEvent<{ value: number }>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Fired when user wants to create a new item.
|
|
76
|
+
*/
|
|
77
|
+
export type CrudNewEvent = CustomEvent<{ item: null }>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Fired when user wants to edit an existing item.
|
|
81
|
+
*/
|
|
82
|
+
export type CrudEditEvent<T> = CustomEvent<{ item: T; index: number }>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Fired when user wants to delete item.
|
|
86
|
+
*/
|
|
87
|
+
export type CrudDeleteEvent<T> = CustomEvent<{ item: T }>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Fired when user discards edition.
|
|
91
|
+
*/
|
|
92
|
+
export type CrudCancelEvent<T> = CustomEvent<{ item: T }>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Fired when user wants to save a new or an existing item.
|
|
96
|
+
*/
|
|
97
|
+
export type CrudSaveEvent<T> = CustomEvent<{ item: T; new: boolean }>;
|
|
98
|
+
|
|
99
|
+
export type CrudCustomEventMap<T> = {
|
|
100
|
+
'editor-opened-changed': CrudEditorOpenedChangedEvent;
|
|
101
|
+
|
|
102
|
+
'edited-item-changed': CrudEditedItemChangedEvent<T>;
|
|
103
|
+
|
|
104
|
+
'items-changed': CrudItemsChangedEvent<T>;
|
|
105
|
+
|
|
106
|
+
'size-changed': CrudSizeChangedEvent;
|
|
107
|
+
|
|
108
|
+
new: CrudNewEvent;
|
|
109
|
+
|
|
110
|
+
cancel: CrudCancelEvent<T>;
|
|
111
|
+
|
|
112
|
+
delete: CrudDeleteEvent<T>;
|
|
113
|
+
|
|
114
|
+
edit: CrudEditEvent<T>;
|
|
115
|
+
|
|
116
|
+
save: CrudSaveEvent<T>;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A mixin providing common crud functionality.
|
|
123
|
+
*/
|
|
124
|
+
export declare function CrudMixin<Item, T extends Constructor<HTMLElement> = Constructor<HTMLElement>>(
|
|
125
|
+
base: T,
|
|
126
|
+
): Constructor<CrudMixinClass<Item>> & T;
|
|
127
|
+
|
|
128
|
+
export declare class CrudMixinClass<Item> {
|
|
129
|
+
/**
|
|
130
|
+
* An array containing the items which will be stamped to the column template instances.
|
|
131
|
+
*/
|
|
132
|
+
items: Item[] | null | undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The item being edited in the dialog.
|
|
136
|
+
*/
|
|
137
|
+
editedItem: Item | null | undefined;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Sets how editor will be presented on desktop screen.
|
|
141
|
+
*
|
|
142
|
+
* Accepted values are:
|
|
143
|
+
* - `` (default) - form will open as overlay
|
|
144
|
+
* - `bottom` - form will open below the grid
|
|
145
|
+
* - `aside` - form will open on the grid side (_right_, if lft and _left_ if rtl)
|
|
146
|
+
* @attr {bottom|aside} editor-position
|
|
147
|
+
*/
|
|
148
|
+
editorPosition: CrudEditorPosition;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Enables user to click on row to edit it.
|
|
152
|
+
* Note: When enabled, auto-generated grid won't show the edit column.
|
|
153
|
+
* @attr {boolean} edit-on-click
|
|
154
|
+
*/
|
|
155
|
+
editOnClick: boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Function that provides items lazily. Receives arguments `params`, `callback`
|
|
159
|
+
*
|
|
160
|
+
* `params.page` Requested page index
|
|
161
|
+
* `params.pageSize` Current page size
|
|
162
|
+
* `params.filters` Currently applied filters
|
|
163
|
+
* `params.sortOrders` Currently applied sorting orders
|
|
164
|
+
*
|
|
165
|
+
* `callback(items, size)` Callback function with arguments:
|
|
166
|
+
* - `items` Current page of items
|
|
167
|
+
* - `size` Total number of items
|
|
168
|
+
*/
|
|
169
|
+
dataProvider: CrudDataProvider<Item> | null | undefined;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Disable filtering when grid is autoconfigured.
|
|
173
|
+
* @attr {boolean} no-filter
|
|
174
|
+
*/
|
|
175
|
+
noFilter: boolean | null | undefined;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Disable sorting when grid is autoconfigured.
|
|
179
|
+
* @attr {boolean} no-sort
|
|
180
|
+
*/
|
|
181
|
+
noSort: boolean | null | undefined;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Remove grid headers when it is autoconfigured.
|
|
185
|
+
* @attr {boolean} no-head
|
|
186
|
+
*/
|
|
187
|
+
noHead: boolean | null | undefined;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* A comma-separated list of fields to include in the generated grid and the generated editor.
|
|
191
|
+
*
|
|
192
|
+
* It can be used to explicitly define the field order.
|
|
193
|
+
*
|
|
194
|
+
* When it is defined [`exclude`](#/elements/vaadin-crud#property-exclude) is ignored.
|
|
195
|
+
*
|
|
196
|
+
* Default is undefined meaning that all properties in the object should be mapped to fields.
|
|
197
|
+
*/
|
|
198
|
+
include: string | null | undefined;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* A comma-separated list of fields to be excluded from the generated grid and the generated editor.
|
|
202
|
+
*
|
|
203
|
+
* When [`include`](#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.
|
|
204
|
+
*
|
|
205
|
+
* Default is to exclude all private fields (those properties starting with underscore)
|
|
206
|
+
*/
|
|
207
|
+
exclude: string | null | undefined;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Reflects the opened status of the editor.
|
|
211
|
+
*/
|
|
212
|
+
editorOpened: boolean | null | undefined;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Number of items in the data set which is reported by the grid.
|
|
216
|
+
* Typically it reflects the number of filtered items displayed in the grid.
|
|
217
|
+
*/
|
|
218
|
+
readonly size: number | null | undefined;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Controls visibility state of toolbar.
|
|
222
|
+
* When set to false toolbar is hidden and shown when set to true.
|
|
223
|
+
* @attr {boolean} no-toolbar
|
|
224
|
+
*/
|
|
225
|
+
noToolbar: boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The object used to localize this component.
|
|
229
|
+
* For changing the default localization, change the entire
|
|
230
|
+
* _i18n_ object or just the property you want to modify.
|
|
231
|
+
*
|
|
232
|
+
* The object has the following JSON structure and default values:
|
|
233
|
+
*
|
|
234
|
+
* ```
|
|
235
|
+
* {
|
|
236
|
+
* newItem: 'New item',
|
|
237
|
+
* editItem: 'Edit item',
|
|
238
|
+
* saveItem: 'Save',
|
|
239
|
+
* cancel: 'Cancel',
|
|
240
|
+
* deleteItem: 'Delete...',
|
|
241
|
+
* editLabel: 'Edit',
|
|
242
|
+
* confirm: {
|
|
243
|
+
* delete: {
|
|
244
|
+
* title: 'Confirm delete',
|
|
245
|
+
* content: 'Are you sure you want to delete the selected item? This action cannot be undone.',
|
|
246
|
+
* button: {
|
|
247
|
+
* confirm: 'Delete',
|
|
248
|
+
* dismiss: 'Cancel'
|
|
249
|
+
* }
|
|
250
|
+
* },
|
|
251
|
+
* cancel: {
|
|
252
|
+
* title: 'Unsaved changes',
|
|
253
|
+
* content: 'There are unsaved modifications to the item.',
|
|
254
|
+
* button: {
|
|
255
|
+
* confirm: 'Discard',
|
|
256
|
+
* dismiss: 'Continue editing'
|
|
257
|
+
* }
|
|
258
|
+
* }
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
i18n: CrudI18n;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A reference to all fields inside the [`_form`](#/elements/vaadin-crud#property-_form) element
|
|
267
|
+
*/
|
|
268
|
+
protected readonly _fields: HTMLElement[];
|
|
269
|
+
}
|