@rozie-ui/data-table-lit 0.7.1 → 0.7.2

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/dist/index.d.mts CHANGED
@@ -1,6 +1,107 @@
1
1
  import * as _$lit from "lit";
2
2
  import { LitElement } from "lit";
3
+ import { Column as Column$1, ColumnDef, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/table-core";
4
+
3
5
  //#region src/DataTable.d.ts
6
+ /** A cell position as integers over the visible (display-order) model. */
7
+ interface DataTableCellPosition {
8
+ rowIndex: number;
9
+ colIndex: number;
10
+ }
11
+ /** The active (roving-focus) cell. A header cell reports `rowIndex: null` and `isHeader: true`. */
12
+ interface DataTableActiveCell {
13
+ rowIndex: number | null;
14
+ colIndex: number;
15
+ isHeader: boolean;
16
+ }
17
+ /** The rectangular cell-range selection. Both corners are `null` when there is no range. */
18
+ interface DataTableRange {
19
+ anchor: DataTableCellPosition | null;
20
+ focus: DataTableCellPosition | null;
21
+ }
22
+ /** One data column offered to the `#groupBar` slot. */
23
+ interface DataTableGroupableColumn {
24
+ id: string;
25
+ label: string;
26
+ }
27
+ /** One changed cell inside a row edit commit. */
28
+ interface DataTableCellChange {
29
+ columnId: string;
30
+ oldValue: any;
31
+ newValue: any;
32
+ }
33
+ /** The `activecell-change` payload. `isHeader` is set when the move landed on or left a header cell. */
34
+ interface DataTableActiveCellChangePayload {
35
+ rowIndex: number | null;
36
+ colIndex: number;
37
+ isHeader?: boolean;
38
+ }
39
+ /** The `cell-edit-commit` payload: one committed cell. */
40
+ interface DataTableCellEditCommitPayload {
41
+ rowId: string;
42
+ columnId: string;
43
+ oldValue: any;
44
+ newValue: any;
45
+ }
46
+ /** The `row-edit-commit` payload: the row and every cell the save changed. */
47
+ interface DataTableRowEditCommitPayload {
48
+ rowId: string;
49
+ changes: DataTableCellChange[];
50
+ }
51
+ /** The `filter-change` payload: `globalFilter` for the search box, `columnFilters` for a per-column filter. Exactly one key is set. */
52
+ interface DataTableFilterChangePayload {
53
+ globalFilter?: string;
54
+ columnFilters?: ColumnFiltersState;
55
+ }
56
+ /** The `history-change` payload: undo/redo availability. */
57
+ interface DataTableHistoryChangePayload {
58
+ canUndo: boolean;
59
+ canRedo: boolean;
60
+ }
61
+ /** The `range-change` payload: the new range corners (both `null` when the range cleared). */
62
+ type DataTableRangeChangePayload = DataTableRange;
63
+ /** The `row-activate` payload. `row` is the original data object and `index` its position in the rendered model. */
64
+ interface DataTableRowActivatePayload {
65
+ row: any;
66
+ index: number;
67
+ trigger: 'keyboard' | 'click';
68
+ }
69
+ /** The `visible-range-change` payload: the rendered row window, `end` exclusive. */
70
+ interface DataTableVisibleRangeChangePayload {
71
+ start: number;
72
+ end: number;
73
+ }
74
+ interface RozieDataTableEventMap extends Omit<HTMLElementEventMap, 'activecell-change' | 'cell-edit-commit' | 'expand-change' | 'filter-change' | 'group-change' | 'history-change' | 'page-change' | 'pin-change' | 'range-change' | 'reorder-change' | 'resize-change' | 'row-activate' | 'row-edit-commit' | 'selection-change' | 'sort-change' | 'visibility-change' | 'visible-range-change' | 'data-change' | 'sorting-change' | 'global-filter-change' | 'column-filters-change' | 'pagination-change' | 'expanded-change' | 'grouping-change' | 'row-selection-change' | 'column-visibility-change' | 'column-sizing-change' | 'column-order-change' | 'column-pinning-change'> {
75
+ 'activecell-change': CustomEvent<DataTableActiveCellChangePayload>;
76
+ 'cell-edit-commit': CustomEvent<DataTableCellEditCommitPayload>;
77
+ 'expand-change': CustomEvent<ExpandedState>;
78
+ 'filter-change': CustomEvent<DataTableFilterChangePayload>;
79
+ 'group-change': CustomEvent<GroupingState>;
80
+ 'history-change': CustomEvent<DataTableHistoryChangePayload>;
81
+ 'page-change': CustomEvent<PaginationState>;
82
+ 'pin-change': CustomEvent<ColumnPinningState>;
83
+ 'range-change': CustomEvent<DataTableRangeChangePayload>;
84
+ 'reorder-change': CustomEvent<ColumnOrderState>;
85
+ 'resize-change': CustomEvent<ColumnSizingState>;
86
+ 'row-activate': CustomEvent<DataTableRowActivatePayload>;
87
+ 'row-edit-commit': CustomEvent<DataTableRowEditCommitPayload>;
88
+ 'selection-change': CustomEvent<RowSelectionState>;
89
+ 'sort-change': CustomEvent<SortingState>;
90
+ 'visibility-change': CustomEvent<VisibilityState>;
91
+ 'visible-range-change': CustomEvent<DataTableVisibleRangeChangePayload>;
92
+ 'data-change': CustomEvent<any[]>;
93
+ 'sorting-change': CustomEvent<any[]>;
94
+ 'global-filter-change': CustomEvent<string>;
95
+ 'column-filters-change': CustomEvent<any[]>;
96
+ 'pagination-change': CustomEvent<any>;
97
+ 'expanded-change': CustomEvent<any | boolean>;
98
+ 'grouping-change': CustomEvent<any[]>;
99
+ 'row-selection-change': CustomEvent<any>;
100
+ 'column-visibility-change': CustomEvent<any>;
101
+ 'column-sizing-change': CustomEvent<any>;
102
+ 'column-order-change': CustomEvent<any[]>;
103
+ 'column-pinning-change': CustomEvent<any>;
104
+ }
4
105
  declare const DataTable_base: typeof LitElement;
5
106
  declare class DataTable extends DataTable_base {
6
107
  static shadowRootOptions: ShadowRootInit;
@@ -186,17 +287,17 @@ declare class DataTable extends DataTable_base {
186
287
  private _hasSlotGroupBar;
187
288
  private _slotGroupBarElements;
188
289
  groupBar?: (scope: {
189
- grouping: any;
190
- groupableColumns: any;
191
- applyGrouping: any;
192
- clearGrouping: any;
290
+ grouping: string[];
291
+ groupableColumns: DataTableGroupableColumn[];
292
+ applyGrouping: (cols: string[]) => void;
293
+ clearGrouping: () => void;
193
294
  }) => unknown;
194
295
  private _hasSlotSelectAll;
195
296
  private _slotSelectAllElements;
196
297
  selectAll?: (scope: {
197
- checked: any;
198
- indeterminate: any;
199
- toggle: any;
298
+ checked: boolean;
299
+ indeterminate: boolean;
300
+ toggle: (event: any) => void;
200
301
  }) => unknown;
201
302
  private _hasSlotDynamicColHeader;
202
303
  private _slotDynamicColHeaderElements;
@@ -205,15 +306,15 @@ declare class DataTable extends DataTable_base {
205
306
  private _hasSlotPlaceholder;
206
307
  private _slotPlaceholderElements;
207
308
  placeholder?: (scope: {
208
- index: any;
209
- columnId: any;
309
+ index: number;
310
+ columnId: string;
210
311
  }) => unknown;
211
312
  private _hasSlotSelectCell;
212
313
  private _slotSelectCellElements;
213
314
  selectCell?: (scope: {
214
315
  row: any;
215
- checked: any;
216
- toggle: any;
316
+ checked: boolean;
317
+ toggle: (event: any) => void;
217
318
  }) => unknown;
218
319
  private _hasSlotDynamicCell;
219
320
  private _slotDynamicCellElements;
@@ -227,69 +328,69 @@ declare class DataTable extends DataTable_base {
227
328
  private _hasSlotColHeader;
228
329
  private _slotColHeaderElements;
229
330
  colHeader?: (scope: {
230
- columnId: any;
231
- column: any;
232
- label: any;
331
+ columnId: string;
332
+ column: Column$1<any, unknown>;
333
+ label: string;
233
334
  }) => unknown;
234
335
  private _hasSlotFilter;
235
336
  private _slotFilterElements;
236
337
  filter?: (scope: {
237
- columnId: any;
338
+ columnId: string;
238
339
  value: any;
239
- uniqueValues: any;
240
- minMax: any;
241
- columnLabel: any;
242
- setFilter: any;
340
+ uniqueValues: any[];
341
+ minMax: [number, number] | null;
342
+ columnLabel: string;
343
+ setFilter: (columnId: string, value: any) => void;
243
344
  }) => unknown;
244
345
  private _hasSlotCell;
245
346
  private _slotCellElements;
246
347
  cell?: (scope: {
247
- columnId: any;
248
- column: any;
348
+ columnId: string;
349
+ column: Column$1<any, unknown>;
249
350
  row: any;
250
351
  value: any;
251
352
  }) => unknown;
252
353
  private _hasSlotEditor;
253
354
  private _slotEditorElements;
254
355
  editor?: (scope: {
255
- columnId: any;
256
- column: any;
356
+ columnId: string;
357
+ column: Column$1<any, unknown>;
257
358
  row: any;
258
359
  value: any;
259
- commit: any;
260
- cancel: any;
261
- columnLabel: any;
262
- autofocus: any;
360
+ commit: (value: any) => void;
361
+ cancel: () => void;
362
+ columnLabel: string;
363
+ autofocus: boolean;
263
364
  }) => unknown;
264
365
  rozieSlots?: {
265
366
  [key: `colHeader-${string}`]: (scope: {
266
- columnId: any;
267
- column: any;
268
- label: any;
367
+ columnId: string;
368
+ column: Column$1<any, unknown>;
369
+ label: string;
269
370
  }) => unknown;
270
371
  [key: `filter-${string}`]: (scope: {
271
- columnId: any;
372
+ columnId: string;
272
373
  value: any;
273
- uniqueValues: any;
274
- minMax: any;
275
- columnLabel: any;
276
- setFilter: any;
374
+ uniqueValues: any[];
375
+ minMax: [number, number] | null;
376
+ columnLabel: string;
377
+ setFilter: (columnId: string, value: any) => void;
277
378
  }) => unknown;
278
379
  [key: `cell-${string}`]: (scope: {
279
- columnId: any;
280
- column: any;
380
+ columnId: string;
381
+ column: Column$1<any, unknown>;
281
382
  row: any;
282
383
  value: any;
283
384
  }) => unknown;
284
385
  [key: `editor-${string}`]: (scope: {
285
- columnId: any;
286
- column: any;
386
+ columnId: string;
387
+ column: Column$1<any, unknown>;
287
388
  row: any;
288
389
  value: any;
289
- commit: any;
290
- cancel: any;
291
- columnLabel: any;
292
- autofocus: any;
390
+ commit: (value: any) => void;
391
+ cancel: () => void;
392
+ columnLabel: string;
393
+ autofocus: boolean;
293
394
  }) => unknown;
294
395
  } & Record<string, (scope: any) => unknown>;
295
396
  private _disconnectCleanups;
@@ -451,7 +552,7 @@ declare class DataTable extends DataTable_base {
451
552
  align?: "start" | "center" | "end" | "auto";
452
553
  behavior?: "auto" | "smooth" | "instant";
453
554
  }) => void;
454
- getScrollElement: () => any;
555
+ getScrollElement: () => HTMLElement | null;
455
556
  virtualItemKey: (i: any) => any;
456
557
  COL_OVERSCAN: number;
457
558
  colRtlObserver: any;
@@ -567,19 +668,19 @@ declare class DataTable extends DataTable_base {
567
668
  hasAnyFilterableColumn: () => boolean;
568
669
  selectAllBox: any;
569
670
  syncIndeterminate: () => void;
570
- sortColumn: (colId: any, desc: any) => void;
671
+ sortColumn: (colId: string, desc?: boolean) => void;
571
672
  clearSorting: () => void;
572
- getColumnDefs: () => any[];
573
- toggleAllRows: (value: any) => void;
673
+ getColumnDefs: () => ColumnDef<any, any>[];
674
+ toggleAllRows: (value?: boolean) => void;
574
675
  clearSelection: () => void;
575
- getSelectedRows: () => any;
576
- setPage: (idx: any) => void;
577
- setRowsPerPage: (size: any) => void;
578
- toggleColumnVisibility: (colId: any) => void;
579
- applyColumnOrder: (order: any) => void;
676
+ getSelectedRows: () => any[];
677
+ setPage: (idx: number) => void;
678
+ setRowsPerPage: (size: number) => void;
679
+ toggleColumnVisibility: (colId: string) => void;
680
+ applyColumnOrder: (order: string[]) => void;
580
681
  resetColumnSizing: () => void;
581
- pinColumn: (colId: any, side: any) => void;
582
- getRowIndexRelativeToPage: (absRow: any) => any;
682
+ pinColumn: (colId: string, side: 'left' | 'right' | false) => void;
683
+ getRowIndexRelativeToPage: (absRow?: number) => number;
583
684
  cut: () => void;
584
685
  isGrid: () => boolean;
585
686
  tableRole: () => "grid" | "table";
@@ -650,16 +751,7 @@ declare class DataTable extends DataTable_base {
650
751
  rangeClickPending: any;
651
752
  rangeActive: boolean;
652
753
  inRange: (rIdx: any, cIdx: any) => boolean;
653
- getSelectedRange: () => {
654
- anchor: {
655
- rowIndex: any;
656
- colIndex: any;
657
- };
658
- focus: {
659
- rowIndex: any;
660
- colIndex: any;
661
- };
662
- };
754
+ getSelectedRange: () => DataTableRange;
663
755
  isFillHandleCell: (rIdx: any, cIdx: any) => boolean;
664
756
  rangeSummary: (anchor: any, focus: any) => string;
665
757
  emitRangeChange: (anchor: any, focus: any) => void;
@@ -781,25 +873,21 @@ declare class DataTable extends DataTable_base {
781
873
  onEditorKeyDown: (e: any) => void;
782
874
  onEditorDropinKeyDown: (e: any) => void;
783
875
  onEditorBlur: (e: any) => void;
784
- editCell: (rowIndex: any, colIndex: any) => void;
876
+ editCell: (rowIndex: number, colIndex: number) => void;
785
877
  commitEditing: () => void;
786
- editRow: (rowIndex: any) => void;
878
+ editRow: (rowIndex: number) => void;
787
879
  focusAbsCellWhenReady: (absRow: any, localRow: any, col: any) => void;
788
- focusCell: (rowIndex: any, colIndex: any) => void;
789
- getActiveCell: () => {
790
- rowIndex: any;
791
- colIndex: number;
792
- isHeader: boolean;
793
- };
880
+ focusCell: (rowIndex: number, colIndex: number) => void;
881
+ getActiveCell: () => DataTableActiveCell;
794
882
  clearActiveCell: () => void;
795
- toggleRowExpanded: (rowId: any) => void;
883
+ toggleRowExpanded: (rowId: string | number) => void;
796
884
  expandAll: () => void;
797
885
  collapseAll: () => void;
798
886
  getExpandedRows: () => any[];
799
- applyGrouping: (cols: any) => void;
887
+ applyGrouping: (cols: string[]) => void;
800
888
  clearGrouping: () => void;
801
- getFacetedUniqueValues: (colId: any) => unknown[];
802
- getFacetedMinMaxValues: (colId: any) => any;
889
+ getFacetedUniqueValues: (colId: string) => any[];
890
+ getFacetedMinMaxValues: (colId: string) => [number, number] | null;
803
891
  get data(): any[];
804
892
  set data(v: any[]);
805
893
  get sorting(): any[];
@@ -824,6 +912,10 @@ declare class DataTable extends DataTable_base {
824
912
  set columnOrder(v: any[]);
825
913
  get columnPinning(): any;
826
914
  set columnPinning(v: any);
915
+ addEventListener<K extends keyof RozieDataTableEventMap>(type: K, listener: (this: DataTable, ev: RozieDataTableEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
916
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
917
+ removeEventListener<K extends keyof RozieDataTableEventMap>(type: K, listener: (this: DataTable, ev: RozieDataTableEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
918
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
827
919
  }
828
920
  //#endregion
829
921
  //#region src/Column.d.ts
@@ -1381,4 +1473,4 @@ declare class DetailPanel extends DetailPanel_base {
1381
1473
  }[];
1382
1474
  }
1383
1475
  //#endregion
1384
- export { Column, DataTable, DataTable as default, DetailPanel, EditorCheckbox, EditorDate, EditorNumber, EditorSelect, EditorText, FilterNumberRange, FilterSelect, FilterText, GroupBar };
1476
+ export { Column, DataTable, DataTable as default, DataTableActiveCell, DataTableActiveCellChangePayload, DataTableCellChange, DataTableCellEditCommitPayload, DataTableCellPosition, DataTableFilterChangePayload, DataTableGroupableColumn, DataTableHistoryChangePayload, DataTableRange, DataTableRangeChangePayload, DataTableRowActivatePayload, DataTableRowEditCommitPayload, DataTableVisibleRangeChangePayload, DetailPanel, EditorCheckbox, EditorDate, EditorNumber, EditorSelect, EditorText, FilterNumberRange, FilterSelect, FilterText, GroupBar, type RozieDataTableEventMap };
package/dist/index.mjs CHANGED
@@ -5890,6 +5890,12 @@ ${this.groupable ? html`<div class="rdt-group-bar-host" data-rozie-s-d5dcab4c>
5890
5890
  set columnPinning(v) {
5891
5891
  this._columnPinningControllable.notifyPropertyWrite(v);
5892
5892
  }
5893
+ addEventListener(type, listener, options) {
5894
+ super.addEventListener(type, listener, options);
5895
+ }
5896
+ removeEventListener(type, listener, options) {
5897
+ super.removeEventListener(type, listener, options);
5898
+ }
5893
5899
  };
5894
5900
  __decorate([property({
5895
5901
  type: Array,
@@ -6086,7 +6092,7 @@ var DataTable_default = DataTable;
6086
6092
  //#endregion
6087
6093
  //#region src/Column.ts
6088
6094
  const __rozieCtx_data_table_columns = createContext(Symbol.for("rozie:data-table:columns"));
6089
- let Column = class Column extends SignalWatcher(LitElement) {
6095
+ let Column$1 = class Column extends SignalWatcher(LitElement) {
6090
6096
  constructor(..._args) {
6091
6097
  super(..._args);
6092
6098
  this.id = "";
@@ -6182,55 +6188,55 @@ let Column = class Column extends SignalWatcher(LitElement) {
6182
6188
  __decorate([property({
6183
6189
  type: String,
6184
6190
  reflect: true
6185
- })], Column.prototype, "id", void 0);
6191
+ })], Column$1.prototype, "id", void 0);
6186
6192
  __decorate([property({
6187
6193
  type: String,
6188
6194
  reflect: true
6189
- })], Column.prototype, "field", void 0);
6195
+ })], Column$1.prototype, "field", void 0);
6190
6196
  __decorate([property({
6191
6197
  type: String,
6192
6198
  reflect: true
6193
- })], Column.prototype, "header", void 0);
6199
+ })], Column$1.prototype, "header", void 0);
6194
6200
  __decorate([property({
6195
6201
  type: Boolean,
6196
6202
  reflect: true
6197
- })], Column.prototype, "sortable", void 0);
6203
+ })], Column$1.prototype, "sortable", void 0);
6198
6204
  __decorate([property({
6199
6205
  type: Boolean,
6200
6206
  reflect: true
6201
- })], Column.prototype, "filterable", void 0);
6207
+ })], Column$1.prototype, "filterable", void 0);
6202
6208
  __decorate([property({
6203
6209
  type: String,
6204
6210
  reflect: true
6205
- })], Column.prototype, "pinned", void 0);
6206
- __decorate([property({ converter: { fromAttribute: rozieNumberOrStringAttr } })], Column.prototype, "width", void 0);
6211
+ })], Column$1.prototype, "pinned", void 0);
6212
+ __decorate([property({ converter: { fromAttribute: rozieNumberOrStringAttr } })], Column$1.prototype, "width", void 0);
6207
6213
  __decorate([property({
6208
6214
  type: Boolean,
6209
6215
  reflect: true
6210
- })], Column.prototype, "expandable", void 0);
6216
+ })], Column$1.prototype, "expandable", void 0);
6211
6217
  __decorate([property({
6212
6218
  type: Boolean,
6213
6219
  reflect: true
6214
- })], Column.prototype, "groupable", void 0);
6220
+ })], Column$1.prototype, "groupable", void 0);
6215
6221
  __decorate([property({
6216
6222
  type: String,
6217
6223
  attribute: "aggregation-fn"
6218
- })], Column.prototype, "aggregationFn", void 0);
6224
+ })], Column$1.prototype, "aggregationFn", void 0);
6219
6225
  __decorate([property({
6220
6226
  type: Boolean,
6221
6227
  reflect: true
6222
- })], Column.prototype, "editable", void 0);
6228
+ })], Column$1.prototype, "editable", void 0);
6223
6229
  __decorate([property({
6224
6230
  type: String,
6225
6231
  reflect: true
6226
- })], Column.prototype, "editor", void 0);
6232
+ })], Column$1.prototype, "editor", void 0);
6227
6233
  __decorate([property({
6228
6234
  type: Array,
6229
6235
  attribute: "editor-options"
6230
- })], Column.prototype, "editorOptions", void 0);
6231
- __decorate([property({ type: Function })], Column.prototype, "validate", void 0);
6232
- Column = __decorate([customElement("rozie-column")], Column);
6233
- var Column_default = Column;
6236
+ })], Column$1.prototype, "editorOptions", void 0);
6237
+ __decorate([property({ type: Function })], Column$1.prototype, "validate", void 0);
6238
+ Column$1 = __decorate([customElement("rozie-column")], Column$1);
6239
+ var Column_default = Column$1;
6234
6240
  //#endregion
6235
6241
  //#region src/EditorText.ts
6236
6242
  let EditorText = class EditorText extends SignalWatcher(LitElement) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozie-ui/data-table-lit",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -42,10 +42,11 @@
42
42
  },
43
43
  "files": [
44
44
  "dist",
45
- "src"
45
+ "src",
46
+ "CHANGELOG.md"
46
47
  ],
47
48
  "dependencies": {
48
- "@rozie/runtime-lit": "^0.8.0"
49
+ "@rozie/runtime-lit": "^0.9.0"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "lit": "^3.2",