@vaadin/crud 24.6.0-beta1 → 24.6.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.
@@ -8,117 +8,13 @@
8
8
  * See https://vaadin.com/commercial-license-and-service-terms for the full
9
9
  * license.
10
10
  */
11
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
12
- import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
13
- import type { GridDefaultItem, GridFilterDefinition, GridSorterDefinition } from '@vaadin/grid/src/vaadin-grid.js';
14
- import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
+ import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
12
+ import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
13
+ import type { GridDefaultItem } from '@vaadin/grid/src/vaadin-grid.js';
14
+ import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
15
+ import type { CrudEventMap, CrudMixinClass } from './vaadin-crud-mixin.js';
15
16
 
16
- export type CrudDataProviderCallback<T> = (items: T[], size?: number) => void;
17
-
18
- export type CrudDataProviderParams = {
19
- page: number;
20
- pageSize: number;
21
- filters: GridFilterDefinition[];
22
- sortOrders: GridSorterDefinition[];
23
- };
24
-
25
- export type CrudDataProvider<T> = (params: CrudDataProviderParams, callback: CrudDataProviderCallback<T>) => void;
26
-
27
- export type CrudEditorPosition = '' | 'aside' | 'bottom';
28
-
29
- export interface CrudI18n {
30
- newItem: string;
31
- editItem: string;
32
- saveItem: string;
33
- cancel: string;
34
- deleteItem: string;
35
- editLabel: string;
36
- confirm: {
37
- delete: {
38
- title: string;
39
- content: string;
40
- button: {
41
- confirm: string;
42
- dismiss: string;
43
- };
44
- };
45
- cancel: {
46
- title: string;
47
- content: string;
48
- button: {
49
- confirm: string;
50
- dismiss: string;
51
- };
52
- };
53
- };
54
- }
55
-
56
- /**
57
- * Fired when the `editorOpened` property changes.
58
- */
59
- export type CrudEditorOpenedChangedEvent = CustomEvent<{ value: boolean }>;
60
-
61
- /**
62
- * Fired when the `editedItem` property changes.
63
- */
64
- export type CrudEditedItemChangedEvent<T> = CustomEvent<{ value: T }>;
65
-
66
- /**
67
- * Fired when the `items` property changes.
68
- */
69
- export type CrudItemsChangedEvent<T> = CustomEvent<{ value: T[] }>;
70
-
71
- /**
72
- * Fired when the `size` property changes.
73
- */
74
- export type CrudSizeChangedEvent = CustomEvent<{ value: number }>;
75
-
76
- /**
77
- * Fired when user wants to create a new item.
78
- */
79
- export type CrudNewEvent = CustomEvent<{ item: null }>;
80
-
81
- /**
82
- * Fired when user wants to edit an existing item.
83
- */
84
- export type CrudEditEvent<T> = CustomEvent<{ item: T; index: number }>;
85
-
86
- /**
87
- * Fired when user wants to delete item.
88
- */
89
- export type CrudDeleteEvent<T> = CustomEvent<{ item: T }>;
90
-
91
- /**
92
- * Fired when user discards edition.
93
- */
94
- export type CrudCancelEvent<T> = CustomEvent<{ item: T }>;
95
-
96
- /**
97
- * Fired when user wants to save a new or an existing item.
98
- */
99
- export type CrudSaveEvent<T> = CustomEvent<{ item: T; new: boolean }>;
100
-
101
- export type CrudCustomEventMap<T> = {
102
- 'editor-opened-changed': CrudEditorOpenedChangedEvent;
103
-
104
- 'edited-item-changed': CrudEditedItemChangedEvent<T>;
105
-
106
- 'items-changed': CrudItemsChangedEvent<T>;
107
-
108
- 'size-changed': CrudSizeChangedEvent;
109
-
110
- new: CrudNewEvent;
111
-
112
- cancel: CrudCancelEvent<T>;
113
-
114
- delete: CrudDeleteEvent<T>;
115
-
116
- edit: CrudEditEvent<T>;
117
-
118
- save: CrudSaveEvent<T>;
119
- };
120
-
121
- export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
17
+ export * from './vaadin-crud-mixin.js';
122
18
 
123
19
  /**
124
20
  * `<vaadin-crud>` is a Web Component for [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.
@@ -262,148 +158,7 @@ export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
262
158
  * @fires {CustomEvent} save - Fired when user wants to save a new or an existing item.
263
159
  * @fires {CustomEvent} cancel - Fired when user discards edition.
264
160
  */
265
- declare class Crud<Item = GridDefaultItem> extends ControllerMixin(ElementMixin(ThemableMixin(HTMLElement))) {
266
- /**
267
- * An array containing the items which will be stamped to the column template instances.
268
- */
269
- items: Item[] | null | undefined;
270
-
271
- /**
272
- * The item being edited in the dialog.
273
- */
274
- editedItem: Item | null | undefined;
275
-
276
- /**
277
- * Sets how editor will be presented on desktop screen.
278
- *
279
- * Accepted values are:
280
- * - `` (default) - form will open as overlay
281
- * - `bottom` - form will open below the grid
282
- * - `aside` - form will open on the grid side (_right_, if lft and _left_ if rtl)
283
- * @attr {bottom|aside} editor-position
284
- */
285
- editorPosition: CrudEditorPosition;
286
-
287
- /**
288
- * Enables user to click on row to edit it.
289
- * Note: When enabled, auto-generated grid won't show the edit column.
290
- * @attr {boolean} edit-on-click
291
- */
292
- editOnClick: boolean;
293
-
294
- /**
295
- * Function that provides items lazily. Receives arguments `params`, `callback`
296
- *
297
- * `params.page` Requested page index
298
- * `params.pageSize` Current page size
299
- * `params.filters` Currently applied filters
300
- * `params.sortOrders` Currently applied sorting orders
301
- *
302
- * `callback(items, size)` Callback function with arguments:
303
- * - `items` Current page of items
304
- * - `size` Total number of items
305
- */
306
- dataProvider: CrudDataProvider<Item> | null | undefined;
307
-
308
- /**
309
- * Disable filtering when grid is autoconfigured.
310
- * @attr {boolean} no-filter
311
- */
312
- noFilter: boolean | null | undefined;
313
-
314
- /**
315
- * Disable sorting when grid is autoconfigured.
316
- * @attr {boolean} no-sort
317
- */
318
- noSort: boolean | null | undefined;
319
-
320
- /**
321
- * Remove grid headers when it is autoconfigured.
322
- * @attr {boolean} no-head
323
- */
324
- noHead: boolean | null | undefined;
325
-
326
- /**
327
- * A comma-separated list of fields to include in the generated grid and the generated editor.
328
- *
329
- * It can be used to explicitly define the field order.
330
- *
331
- * When it is defined [`exclude`](#/elements/vaadin-crud#property-exclude) is ignored.
332
- *
333
- * Default is undefined meaning that all properties in the object should be mapped to fields.
334
- */
335
- include: string | null | undefined;
336
-
337
- /**
338
- * A comma-separated list of fields to be excluded from the generated grid and the generated editor.
339
- *
340
- * When [`include`](#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.
341
- *
342
- * Default is to exclude all private fields (those properties starting with underscore)
343
- */
344
- exclude: string | null | undefined;
345
-
346
- /**
347
- * Reflects the opened status of the editor.
348
- */
349
- editorOpened: boolean | null | undefined;
350
-
351
- /**
352
- * Number of items in the data set which is reported by the grid.
353
- * Typically it reflects the number of filtered items displayed in the grid.
354
- */
355
- readonly size: number | null | undefined;
356
-
357
- /**
358
- * Controls visibility state of toolbar.
359
- * When set to false toolbar is hidden and shown when set to true.
360
- * @attr {boolean} no-toolbar
361
- */
362
- noToolbar: boolean;
363
-
364
- /**
365
- * The object used to localize this component.
366
- * For changing the default localization, change the entire
367
- * _i18n_ object or just the property you want to modify.
368
- *
369
- * The object has the following JSON structure and default values:
370
- *
371
- * ```
372
- * {
373
- * newItem: 'New item',
374
- * editItem: 'Edit item',
375
- * saveItem: 'Save',
376
- * cancel: 'Cancel',
377
- * deleteItem: 'Delete...',
378
- * editLabel: 'Edit',
379
- * confirm: {
380
- * delete: {
381
- * title: 'Confirm delete',
382
- * content: 'Are you sure you want to delete the selected item? This action cannot be undone.',
383
- * button: {
384
- * confirm: 'Delete',
385
- * dismiss: 'Cancel'
386
- * }
387
- * },
388
- * cancel: {
389
- * title: 'Unsaved changes',
390
- * content: 'There are unsaved modifications to the item.',
391
- * button: {
392
- * confirm: 'Discard',
393
- * dismiss: 'Continue editing'
394
- * }
395
- * }
396
- * }
397
- * }
398
- * ```
399
- */
400
- i18n: CrudI18n;
401
-
402
- /**
403
- * A reference to all fields inside the [`_form`](#/elements/vaadin-crud#property-_form) element
404
- */
405
- protected readonly _fields: HTMLElement[];
406
-
161
+ declare class Crud<Item = GridDefaultItem> extends HTMLElement {
407
162
  addEventListener<K extends keyof CrudEventMap<Item>>(
408
163
  type: K,
409
164
  listener: (this: Crud<Item>, ev: CrudEventMap<Item>[K]) => void,
@@ -417,6 +172,12 @@ declare class Crud<Item = GridDefaultItem> extends ControllerMixin(ElementMixin(
417
172
  ): void;
418
173
  }
419
174
 
175
+ interface Crud<Item = GridDefaultItem>
176
+ extends ElementMixinClass,
177
+ ThemableMixinClass,
178
+ ControllerMixinClass,
179
+ CrudMixinClass<Item> {}
180
+
420
181
  declare global {
421
182
  interface HTMLElementTagNameMap {
422
183
  'vaadin-crud': Crud<GridDefaultItem>;