spiderly 19.8.7 → 19.8.9

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.
@@ -1,4 +1,4 @@
1
- import { AfterViewInit, EventEmitter, OnDestroy, OnInit } from '@angular/core';
1
+ import { AfterViewInit, EventEmitter, OnDestroy, OnInit, TemplateRef } from '@angular/core';
2
2
  import { ActivatedRoute, Router } from '@angular/router';
3
3
  import { TranslocoService } from '@jsverse/transloco';
4
4
  import { SelectItem } from 'primeng/api';
@@ -23,6 +23,11 @@ export declare class SpiderlyDataTableComponent implements OnInit, AfterViewInit
23
23
  private locale;
24
24
  private readonly destroy$;
25
25
  table: Table;
26
+ /**
27
+ * Custom toolbar content projected via `<ng-template spiderlyDataTableActions>`.
28
+ * Rendered in the caption action area ahead of the built-in buttons.
29
+ */
30
+ actionsTemplate: TemplateRef<any>;
26
31
  tableTitle: string;
27
32
  tableIcon: string;
28
33
  items: any[];
@@ -109,6 +114,8 @@ export declare class SpiderlyDataTableComponent implements OnInit, AfterViewInit
109
114
  isDropOrMulti(filterType: string): boolean;
110
115
  navigateToDetails(rowId: number): void;
111
116
  onRowClick(row: any): void;
117
+ onCellClick(col: Column, rowData: any, event: MouseEvent): void;
118
+ private buildClickEvent;
112
119
  deleteObject(rowId: number): void;
113
120
  deleteSelectedObjects(): void;
114
121
  private openDeleteConfirmation;
@@ -134,7 +141,7 @@ export declare class SpiderlyDataTableComponent implements OnInit, AfterViewInit
134
141
  rowUnselect(id: number): void;
135
142
  getFormArrayControlByIndex(formControlName: string, index: number): SpiderlyFormControl;
136
143
  static ɵfac: i0.ɵɵFactoryDeclaration<SpiderlyDataTableComponent, never>;
137
- static ɵcmp: i0.ɵɵComponentDeclaration<SpiderlyDataTableComponent, "spiderly-data-table", never, { "tableTitle": { "alias": "tableTitle"; "required": false; }; "tableIcon": { "alias": "tableIcon"; "required": false; }; "items": { "alias": "items"; "required": false; }; "rows": { "alias": "rows"; "required": false; }; "cols": { "alias": "cols"; "required": false; }; "showPaginator": { "alias": "showPaginator"; "required": false; }; "showCardWrapper": { "alias": "showCardWrapper"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "idField": { "alias": "idField"; "required": false; }; "getPaginatedListObservableMethod": { "alias": "getPaginatedListObservableMethod"; "required": false; }; "exportListToExcelObservableMethod": { "alias": "exportListToExcelObservableMethod"; "required": false; }; "deleteItemFromTableObservableMethod": { "alias": "deleteItemFromTableObservableMethod"; "required": false; }; "deleteListFromTableObservableMethod": { "alias": "deleteListFromTableObservableMethod"; "required": false; }; "newlySelectedItems": { "alias": "newlySelectedItems"; "required": false; }; "unselectedItems": { "alias": "unselectedItems"; "required": false; }; "selectionMode": { "alias": "selectionMode"; "required": false; }; "selectedLazyLoadObservableMethod": { "alias": "selectedLazyLoadObservableMethod"; "required": false; }; "additionalFilterIdLong": { "alias": "additionalFilterIdLong"; "required": false; }; "showAddButton": { "alias": "showAddButton"; "required": false; }; "showExportToExcelButton": { "alias": "showExportToExcelButton"; "required": false; }; "showReloadTableButton": { "alias": "showReloadTableButton"; "required": false; }; "getFormArrayItems": { "alias": "getFormArrayItems"; "required": false; }; "hasLazyLoad": { "alias": "hasLazyLoad"; "required": false; }; "stateKey": { "alias": "stateKey"; "required": false; }; "stateStorage": { "alias": "stateStorage"; "required": false; }; "getAlreadySelectedItemIds": { "alias": "getAlreadySelectedItemIds"; "required": false; }; "getAlreadySelectedItems": { "alias": "getAlreadySelectedItems"; "required": false; }; "getFormControl": { "alias": "getFormControl"; "required": false; }; "additionalIndexes": { "alias": "additionalIndexes"; "required": false; }; "navigateOnRowClick": { "alias": "navigateOnRowClick"; "required": false; }; "rowNavigationPath": { "alias": "rowNavigationPath"; "required": false; }; }, { "onTotalRecordsChange": "onTotalRecordsChange"; "onLazyLoad": "onLazyLoad"; "onIsAllSelectedChange": "onIsAllSelectedChange"; "onRowSelect": "onRowSelect"; "onRowUnselect": "onRowUnselect"; }, never, never, true, never>;
144
+ static ɵcmp: i0.ɵɵComponentDeclaration<SpiderlyDataTableComponent, "spiderly-data-table", never, { "tableTitle": { "alias": "tableTitle"; "required": false; }; "tableIcon": { "alias": "tableIcon"; "required": false; }; "items": { "alias": "items"; "required": false; }; "rows": { "alias": "rows"; "required": false; }; "cols": { "alias": "cols"; "required": false; }; "showPaginator": { "alias": "showPaginator"; "required": false; }; "showCardWrapper": { "alias": "showCardWrapper"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "idField": { "alias": "idField"; "required": false; }; "getPaginatedListObservableMethod": { "alias": "getPaginatedListObservableMethod"; "required": false; }; "exportListToExcelObservableMethod": { "alias": "exportListToExcelObservableMethod"; "required": false; }; "deleteItemFromTableObservableMethod": { "alias": "deleteItemFromTableObservableMethod"; "required": false; }; "deleteListFromTableObservableMethod": { "alias": "deleteListFromTableObservableMethod"; "required": false; }; "newlySelectedItems": { "alias": "newlySelectedItems"; "required": false; }; "unselectedItems": { "alias": "unselectedItems"; "required": false; }; "selectionMode": { "alias": "selectionMode"; "required": false; }; "selectedLazyLoadObservableMethod": { "alias": "selectedLazyLoadObservableMethod"; "required": false; }; "additionalFilterIdLong": { "alias": "additionalFilterIdLong"; "required": false; }; "showAddButton": { "alias": "showAddButton"; "required": false; }; "showExportToExcelButton": { "alias": "showExportToExcelButton"; "required": false; }; "showReloadTableButton": { "alias": "showReloadTableButton"; "required": false; }; "getFormArrayItems": { "alias": "getFormArrayItems"; "required": false; }; "hasLazyLoad": { "alias": "hasLazyLoad"; "required": false; }; "stateKey": { "alias": "stateKey"; "required": false; }; "stateStorage": { "alias": "stateStorage"; "required": false; }; "getAlreadySelectedItemIds": { "alias": "getAlreadySelectedItemIds"; "required": false; }; "getAlreadySelectedItems": { "alias": "getAlreadySelectedItems"; "required": false; }; "getFormControl": { "alias": "getFormControl"; "required": false; }; "additionalIndexes": { "alias": "additionalIndexes"; "required": false; }; "navigateOnRowClick": { "alias": "navigateOnRowClick"; "required": false; }; "rowNavigationPath": { "alias": "rowNavigationPath"; "required": false; }; }, { "onTotalRecordsChange": "onTotalRecordsChange"; "onLazyLoad": "onLazyLoad"; "onIsAllSelectedChange": "onIsAllSelectedChange"; "onRowSelect": "onRowSelect"; "onRowUnselect": "onRowUnselect"; }, ["actionsTemplate"], never, true, never>;
138
145
  }
139
146
  export declare class Action {
140
147
  name?: string;
@@ -174,7 +181,17 @@ export declare class Column<T = any> {
174
181
  showTime?: boolean;
175
182
  decimalPlaces?: number;
176
183
  sortable?: boolean;
177
- constructor({ name, field, filterField, filterType, filterPlaceholder, showMatchModes, showAddButton, dropdownOrMultiselectValues, actions, editable, showTime, decimalPlaces, sortable, }?: {
184
+ /**
185
+ * Fired when this column's cell is clicked. Receives a {@link CellClickEvent} with the row id,
186
+ * the column field, the full row, the raw and formatted cell value, the clicked `<td>` element
187
+ * (use it to anchor an overlay/popover), and the original `MouseEvent`.
188
+ *
189
+ * Setting this makes the cell visibly clickable (cursor + hover) and the click no longer bubbles
190
+ * up to row navigation. The mirror of {@link Action.onClick}, but for plain value cells.
191
+ * Not applied to editable cells — those belong to their inline input.
192
+ */
193
+ onCellClick?: (event: CellClickEvent) => void;
194
+ constructor({ name, field, filterField, filterType, filterPlaceholder, showMatchModes, showAddButton, dropdownOrMultiselectValues, actions, editable, showTime, decimalPlaces, sortable, onCellClick, }?: {
178
195
  name?: string;
179
196
  field?: string & keyof T;
180
197
  filterField?: string & keyof T;
@@ -188,6 +205,7 @@ export declare class Column<T = any> {
188
205
  showTime?: boolean;
189
206
  decimalPlaces?: number;
190
207
  sortable?: boolean;
208
+ onCellClick?: (event: CellClickEvent) => void;
191
209
  });
192
210
  }
193
211
  /**
@@ -208,6 +226,19 @@ export interface ActionClickEvent {
208
226
  /** The original DOM click event. */
209
227
  originalEvent: MouseEvent;
210
228
  }
229
+ /**
230
+ * Payload passed to {@link Column.onCellClick} when a cell is clicked. A superset of
231
+ * {@link ActionClickEvent} (same `id` / `row` / `element` / `originalEvent`) plus the cell's
232
+ * column and value. Every field is populated by the data table.
233
+ */
234
+ export interface CellClickEvent extends ActionClickEvent {
235
+ /** The clicked column's `field`. */
236
+ field: string;
237
+ /** The cell's raw value (`row[field]`). */
238
+ value: any;
239
+ /** The formatted value shown in the cell (what the table renders via `getRowData`). */
240
+ displayValue: string;
241
+ }
211
242
  export declare class RowClickEvent {
212
243
  index?: number;
213
244
  id?: number;
@@ -0,0 +1,26 @@
1
+ import * as i0 from "@angular/core";
2
+ /**
3
+ * Marks an `<ng-template>` projected into `spiderly-data-table` as custom toolbar
4
+ * content. The template is rendered in the table's caption action area, ahead of the
5
+ * built-in Clear Filters / Export to Excel / Reload / Delete Selected buttons, so its
6
+ * position stays stable regardless of selection state.
7
+ *
8
+ * The projected template binds to the consumer component (so `(click)` handlers call
9
+ * the consumer's methods), and inherits the action row's spacing and responsive
10
+ * stacking. No table state is passed as context — read it via the table's outputs
11
+ * (`onLazyLoad`, `onTotalRecordsChange`, `onRowSelect`) when needed.
12
+ *
13
+ * @example
14
+ * ```html
15
+ * <spiderly-data-table [cols]="cols" [getPaginatedListObservableMethod]="...">
16
+ * <ng-template spiderlyDataTableActions>
17
+ * <button pButton class="p-button-outlined" style="flex: none"
18
+ * icon="pi pi-check" [label]="t('ApproveAll')" (click)="approveAll()"></button>
19
+ * </ng-template>
20
+ * </spiderly-data-table>
21
+ * ```
22
+ */
23
+ export declare class SpiderlyDataTableActionsDirective {
24
+ static ɵfac: i0.ɵɵFactoryDeclaration<SpiderlyDataTableActionsDirective, never>;
25
+ static ɵdir: i0.ɵɵDirectiveDeclaration<SpiderlyDataTableActionsDirective, "[spiderlyDataTableActions]", never, {}, {}, never, never, true, never>;
26
+ }
@@ -26,6 +26,7 @@ export declare function getFileNameFromContentDisposition(resp: HttpResponse<Blo
26
26
  export declare function toCommaSeparatedString<T>(input: T[]): string;
27
27
  export declare function isFileImageType(mimeType: string): boolean;
28
28
  export declare function isExcelFileType(mimeType: string): boolean;
29
+ export declare function saveResponseAsFile(res: HttpResponse<Blob>, fallbackName: string): void;
29
30
  export declare function exportListToExcel(exportListToExcelObservableMethod: (filter: Filter) => Observable<any>, filter: Filter): void;
30
31
  export declare function getPrimengNamebookOptions(namebookList: Namebook[]): PrimengOption[];
31
32
  export declare function getPrimengDropdownNamebookOptions(getDropdownListObservable: (parentEntityId?: number) => Observable<Namebook[]>, parentEntityId?: number): Observable<PrimengOption[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spiderly",
3
- "version": "19.8.7",
3
+ "version": "19.8.9",
4
4
  "author": "Filip Trivan",
5
5
  "license": "MIT",
6
6
  "description": "Spiderly Angular Library to use in combination with Spiderly.",
package/public-api.d.ts CHANGED
@@ -90,4 +90,5 @@ export * from './lib/services/helper-functions';
90
90
  export * from './lib/services/spiderly-message.service';
91
91
  export * from './lib/services/spiderly-transloco-loader';
92
92
  export * from './lib/services/validator-abstract.service';
93
+ export * from './lib/directives/spiderly-data-table-actions.directive';
93
94
  export * from './lib/directives/template-type.directive';
@@ -34,6 +34,15 @@
34
34
  }
35
35
 
36
36
  :host {
37
+ // The `.clickable` affordance is shared: clickable rows (navigateOnRowClick) and opt-in cells
38
+ // (Column.onCellClick) both get a pointer cursor; cells additionally underline on hover.
39
+ ::ng-deep .clickable {
40
+ cursor: pointer;
41
+ }
42
+ ::ng-deep td.clickable:hover {
43
+ text-decoration: underline;
44
+ }
45
+
37
46
  ::ng-deep {
38
47
  .p-datatable-thead {
39
48
  position: unset !important;
File without changes
File without changes
File without changes
File without changes
File without changes