@weaver-apps/data-grid 0.0.0-stage → 0.3.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.
@@ -0,0 +1,831 @@
1
+ import * as i0 from "@angular/core";
2
+ import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, Component, computed, inject, input, isDevMode, output, signal, viewChild } from "@angular/core";
3
+ import { toSignal } from "@angular/core/rxjs-interop";
4
+ import { TranslocoService } from "@jsverse/transloco";
5
+ import { AgGridAngular } from "ag-grid-angular";
6
+ import { AG_GRID_LOCALE_DE, AG_GRID_LOCALE_EN } from "@ag-grid-community/locale";
7
+ import { CellStyleModule, ClientSideRowModelModule, ColumnApiModule, CustomFilterModule, GridStateModule, InfiniteRowModelModule, LocaleModule, ModuleRegistry, RowStyleModule, TextFilterModule, TooltipModule, ValidationModule, themeQuartz } from "ag-grid-community";
8
+ const locales = {
9
+ de: AG_GRID_LOCALE_DE,
10
+ en: AG_GRID_LOCALE_EN
11
+ };
12
+ function dataGridLocaleText(language, overrides = {}) {
13
+ return {
14
+ ...locales[language.slice(0, 2).toLowerCase()] ?? locales["en"],
15
+ ...overrides
16
+ };
17
+ }
18
+ const dataGridModules = [
19
+ InfiniteRowModelModule,
20
+ ClientSideRowModelModule,
21
+ ColumnApiModule,
22
+ TextFilterModule,
23
+ CustomFilterModule,
24
+ GridStateModule,
25
+ LocaleModule,
26
+ CellStyleModule,
27
+ RowStyleModule,
28
+ TooltipModule
29
+ ];
30
+ let registered = false;
31
+ function registerDataGridModules() {
32
+ if (registered) return;
33
+ ModuleRegistry.registerModules(isDevMode() ? [...dataGridModules, ValidationModule] : [...dataGridModules]);
34
+ registered = true;
35
+ }
36
+ const DATA_GRID_ROW_HEIGHT_PX = 36;
37
+ const dataGridThemeParams = {
38
+ backgroundColor: "var(--lw-surface)",
39
+ foregroundColor: "var(--lw-content)",
40
+ cellTextColor: "var(--lw-content)",
41
+ headerTextColor: "var(--lw-content-muted)",
42
+ headerBackgroundColor: "var(--lw-surface-raised)",
43
+ chromeBackgroundColor: "var(--lw-surface-raised)",
44
+ menuBackgroundColor: "var(--lw-surface-overlay)",
45
+ borderColor: "var(--lw-border)",
46
+ accentColor: "var(--lw-brand)",
47
+ rowHoverColor: "color-mix(in srgb, var(--lw-brand) 8%, transparent)",
48
+ oddRowBackgroundColor: "var(--lw-surface)",
49
+ inputBackgroundColor: "var(--lw-field)",
50
+ invalidColor: "var(--lw-negative)",
51
+ browserColorScheme: "inherit",
52
+ fontFamily: "var(--lw-font-sans)",
53
+ fontSize: "0.875rem",
54
+ rowHeight: 36,
55
+ headerHeight: 36,
56
+ focusShadow: "0 0 0 2px var(--lw-brand)",
57
+ wrapperBorderRadius: "0.5rem"
58
+ };
59
+ const dataGridTheme = themeQuartz.withParams(dataGridThemeParams);
60
+ const DATA_GRID_BLOCK_SIZE = 100;
61
+ const DATA_GRID_MAX_BLOCKS = 20;
62
+ const TOOLTIP_DELAY_MS = 600;
63
+ var DataGrid = class DataGrid {
64
+ transloco = inject(TranslocoService);
65
+ language = toSignal(this.transloco.langChanges$, { initialValue: this.transloco.getActiveLang() });
66
+ options = input.required(...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
67
+ localeOverrides = input({}, ...ngDevMode ? [{ debugName: "localeOverrides" }] : /* istanbul ignore next */ []);
68
+ ready = output();
69
+ grids = computed(() => {
70
+ const language = this.language();
71
+ return [{
72
+ language,
73
+ options: {
74
+ theme: dataGridTheme,
75
+ ...this.rowModel(),
76
+ rowHeight: 36,
77
+ headerHeight: 36,
78
+ suppressMultiSort: true,
79
+ suppressMovableColumns: true,
80
+ suppressColumnVirtualisation: true,
81
+ tooltipShowDelay: TOOLTIP_DELAY_MS,
82
+ ...this.options(),
83
+ localeText: { ...dataGridLocaleText(language, this.localeOverrides()) }
84
+ }
85
+ }];
86
+ }, ...ngDevMode ? [{ debugName: "grids" }] : /* istanbul ignore next */ []);
87
+ constructor() {
88
+ registerDataGridModules();
89
+ }
90
+ announce(event) {
91
+ this.ready.emit(event.api);
92
+ }
93
+ rowModel() {
94
+ if (this.options().rowModelType === "clientSide") return { rowModelType: "clientSide" };
95
+ return {
96
+ rowModelType: "infinite",
97
+ cacheBlockSize: 100,
98
+ maxBlocksInCache: 20
99
+ };
100
+ }
101
+ static ɵfac = i0.ɵɵngDeclareFactory({
102
+ minVersion: "12.0.0",
103
+ version: "22.2.3",
104
+ ngImport: i0,
105
+ type: DataGrid,
106
+ deps: [],
107
+ target: i0.ɵɵFactoryTarget.Component
108
+ });
109
+ static ɵcmp = i0.ɵɵngDeclareComponent({
110
+ minVersion: "17.0.0",
111
+ version: "22.2.3",
112
+ type: DataGrid,
113
+ isStandalone: true,
114
+ selector: "wa-data-grid",
115
+ inputs: {
116
+ options: {
117
+ classPropertyName: "options",
118
+ publicName: "options",
119
+ isSignal: true,
120
+ isRequired: true,
121
+ transformFunction: null
122
+ },
123
+ localeOverrides: {
124
+ classPropertyName: "localeOverrides",
125
+ publicName: "localeOverrides",
126
+ isSignal: true,
127
+ isRequired: false,
128
+ transformFunction: null
129
+ }
130
+ },
131
+ outputs: { ready: "ready" },
132
+ host: { classAttribute: "block h-full w-full" },
133
+ ngImport: i0,
134
+ template: "@for (grid of grids(); track grid) {\n <ag-grid-angular class=\"block h-full w-full\" [gridOptions]=\"grid.options\" (gridReady)=\"announce($event)\" />\n}\n",
135
+ dependencies: [{
136
+ kind: "component",
137
+ type: AgGridAngular,
138
+ selector: "ag-grid-angular",
139
+ inputs: [
140
+ "gridOptions",
141
+ "modules",
142
+ "toolbar",
143
+ "statusBar",
144
+ "sideBar",
145
+ "suppressContextMenu",
146
+ "preventDefaultOnContextMenu",
147
+ "allowContextMenuWithControlKey",
148
+ "columnMenu",
149
+ "suppressMenuHide",
150
+ "enableBrowserTooltips",
151
+ "tooltipTrigger",
152
+ "tooltipShowDelay",
153
+ "tooltipSwitchShowDelay",
154
+ "tooltipHideDelay",
155
+ "tooltipMouseTrack",
156
+ "tooltipShowMode",
157
+ "tooltipInteraction",
158
+ "popupParent",
159
+ "copyHeadersToClipboard",
160
+ "copyGroupHeadersToClipboard",
161
+ "clipboardDelimiter",
162
+ "suppressCopyRowsToClipboard",
163
+ "suppressCopySingleCellRanges",
164
+ "suppressLastEmptyLineOnPaste",
165
+ "suppressClipboardPaste",
166
+ "suppressClipboardApi",
167
+ "suppressCutToClipboard",
168
+ "columnDefs",
169
+ "defaultColDef",
170
+ "defaultColGroupDef",
171
+ "columnTypes",
172
+ "dataTypeDefinitions",
173
+ "calculatedColumns",
174
+ "columnHeaderEdit",
175
+ "maintainColumnOrder",
176
+ "enableStrictPivotColumnOrder",
177
+ "suppressFieldDotNotation",
178
+ "headerHeight",
179
+ "groupHeaderHeight",
180
+ "floatingFiltersHeight",
181
+ "pivotHeaderHeight",
182
+ "pivotGroupHeaderHeight",
183
+ "hidePaddedHeaderRows",
184
+ "allowDragFromColumnsToolPanel",
185
+ "suppressMovableColumns",
186
+ "suppressColumnMoveAnimation",
187
+ "suppressMoveWhenColumnDragging",
188
+ "suppressDragLeaveHidesColumns",
189
+ "suppressGroupChangesColumnVisibility",
190
+ "suppressMakeColumnVisibleAfterUnGroup",
191
+ "suppressRowGroupHidesColumns",
192
+ "colResizeDefault",
193
+ "suppressAutoSize",
194
+ "autoSizePadding",
195
+ "skipHeaderOnAutoSize",
196
+ "autoSizeStrategy",
197
+ "animateColumnResizing",
198
+ "components",
199
+ "editType",
200
+ "suppressStartEditOnTab",
201
+ "getFullRowEditValidationErrors",
202
+ "invalidEditValueMode",
203
+ "singleClickEdit",
204
+ "suppressClickEdit",
205
+ "readOnlyEdit",
206
+ "stopEditingWhenCellsLoseFocus",
207
+ "enterNavigatesVertically",
208
+ "enterNavigatesVerticallyAfterEdit",
209
+ "enableCellEditingOnBackspace",
210
+ "undoRedoCellEditing",
211
+ "undoRedoCellEditingLimit",
212
+ "defaultCsvExportParams",
213
+ "suppressCsvExport",
214
+ "defaultExcelExportParams",
215
+ "suppressExcelExport",
216
+ "defaultPdfExportParams",
217
+ "suppressPdfExport",
218
+ "excelStyles",
219
+ "findSearchValue",
220
+ "findOptions",
221
+ "quickFilterText",
222
+ "cacheQuickFilter",
223
+ "includeHiddenColumnsInQuickFilter",
224
+ "quickFilterParser",
225
+ "quickFilterMatcher",
226
+ "applyQuickFilterBeforePivotOrAgg",
227
+ "excludeChildrenWhenTreeDataFiltering",
228
+ "enableAdvancedFilter",
229
+ "alwaysPassFilter",
230
+ "includeHiddenColumnsInAdvancedFilter",
231
+ "advancedFilterParent",
232
+ "advancedFilterBuilderParams",
233
+ "advancedFilterParams",
234
+ "suppressAdvancedFilterEval",
235
+ "suppressSetFilterByDefault",
236
+ "enableFilterHandlers",
237
+ "filterHandlers",
238
+ "enableCharts",
239
+ "includeHiddenColumnsInCharts",
240
+ "chartThemes",
241
+ "customChartThemes",
242
+ "chartThemeOverrides",
243
+ "chartToolPanelsDef",
244
+ "chartMenuItems",
245
+ "loadingCellRenderer",
246
+ "loadingCellRendererParams",
247
+ "loadingCellRendererSelector",
248
+ "localeText",
249
+ "masterDetail",
250
+ "keepDetailRows",
251
+ "keepDetailRowsCount",
252
+ "detailCellRenderer",
253
+ "detailCellRendererParams",
254
+ "detailRowHeight",
255
+ "detailRowAutoHeight",
256
+ "context",
257
+ "alignedGrids",
258
+ "tabIndex",
259
+ "suppressInputClearButton",
260
+ "enableInputAutoComplete",
261
+ "rowBuffer",
262
+ "valueCache",
263
+ "valueCacheNeverExpires",
264
+ "enableCellExpressions",
265
+ "suppressTouch",
266
+ "suppressFocusAfterRefresh",
267
+ "suppressBrowserResizeObserver",
268
+ "suppressPropertyNamesCheck",
269
+ "suppressChangeDetection",
270
+ "debug",
271
+ "loading",
272
+ "loadingRows",
273
+ "overlayLoadingTemplate",
274
+ "loadingOverlayComponent",
275
+ "loadingOverlayComponentParams",
276
+ "suppressLoadingOverlay",
277
+ "overlayNoRowsTemplate",
278
+ "noRowsOverlayComponent",
279
+ "noRowsOverlayComponentParams",
280
+ "suppressNoRowsOverlay",
281
+ "suppressOverlays",
282
+ "overlayComponent",
283
+ "overlayComponentParams",
284
+ "overlayComponentSelector",
285
+ "activeOverlay",
286
+ "activeOverlayParams",
287
+ "processFileInput",
288
+ "pagination",
289
+ "paginationPageSize",
290
+ "paginationPageSizeSelector",
291
+ "paginationAutoPageSize",
292
+ "paginateChildRows",
293
+ "suppressPaginationPanel",
294
+ "paginationPanels",
295
+ "pivotMode",
296
+ "pivotPanelShow",
297
+ "pivotMaxGeneratedColumns",
298
+ "pivotDefaultExpanded",
299
+ "pivotColumnGroupTotals",
300
+ "pivotRowTotals",
301
+ "pivotSuppressAutoColumn",
302
+ "suppressExpandablePivotGroups",
303
+ "functionsReadOnly",
304
+ "aggFuncs",
305
+ "formulaDataSource",
306
+ "notesDataSource",
307
+ "noteTrigger",
308
+ "noteShowDelay",
309
+ "noteHideDelay",
310
+ "formulaFuncs",
311
+ "suppressAggFuncInHeader",
312
+ "alwaysAggregateAtRootLevel",
313
+ "aggregateOnlyChangedColumns",
314
+ "suppressAggFilteredOnly",
315
+ "removePivotHeaderRowWhenSingleValueColumn",
316
+ "animateRows",
317
+ "cellFlashDuration",
318
+ "cellFadeDuration",
319
+ "allowShowChangeAfterFilter",
320
+ "domLayout",
321
+ "ensureDomOrder",
322
+ "enableCellSpan",
323
+ "enableRtl",
324
+ "suppressColumnVirtualisation",
325
+ "suppressMaxRenderedRowRestriction",
326
+ "suppressRowVirtualisation",
327
+ "rowDragManaged",
328
+ "refreshAfterGroupEdit",
329
+ "rowDragInsertDelay",
330
+ "suppressRowDrag",
331
+ "suppressMoveWhenRowDragging",
332
+ "rowDragEntireRow",
333
+ "rowDragMultiRow",
334
+ "rowDragText",
335
+ "dragAndDropImageComponent",
336
+ "dragAndDropImageComponentParams",
337
+ "fullWidthCellRenderer",
338
+ "fullWidthCellRendererParams",
339
+ "embedFullWidthRows",
340
+ "groupDisplayType",
341
+ "groupDefaultExpanded",
342
+ "masterDefaultExpanded",
343
+ "autoGroupColumnDef",
344
+ "groupMaintainOrder",
345
+ "groupSelectsChildren",
346
+ "groupLockGroupColumns",
347
+ "groupAggFiltering",
348
+ "groupTotalRow",
349
+ "grandTotalRow",
350
+ "suppressStickyTotalRow",
351
+ "groupSuppressBlankHeader",
352
+ "groupSelectsFiltered",
353
+ "showOpenedGroup",
354
+ "groupHideParentOfSingleChild",
355
+ "groupRemoveSingleChildren",
356
+ "groupRemoveLowestSingleChildren",
357
+ "groupHideOpenParents",
358
+ "groupHideColumnsUntilExpanded",
359
+ "groupAllowUnbalanced",
360
+ "rowGroupPanelShow",
361
+ "groupRowRenderer",
362
+ "groupRowRendererParams",
363
+ "treeData",
364
+ "treeDataChildrenField",
365
+ "treeDataParentIdField",
366
+ "rowGroupPanelSuppressSort",
367
+ "pivotPanelSuppressSort",
368
+ "suppressGroupRowsSticky",
369
+ "stickyRowsMaxViewportRatio",
370
+ "groupHierarchyConfig",
371
+ "pinnedTopRowData",
372
+ "pinnedBottomRowData",
373
+ "enableRowPinning",
374
+ "isRowPinnable",
375
+ "isRowPinned",
376
+ "rowModelType",
377
+ "rowData",
378
+ "asyncTransactionWaitMillis",
379
+ "suppressModelUpdateAfterUpdateTransaction",
380
+ "datasource",
381
+ "cacheOverflowSize",
382
+ "infiniteInitialRowCount",
383
+ "serverSideInitialRowCount",
384
+ "suppressServerSideFullWidthLoadingRow",
385
+ "cacheBlockSize",
386
+ "maxBlocksInCache",
387
+ "maxConcurrentDatasourceRequests",
388
+ "blockLoadDebounceMillis",
389
+ "purgeClosedRowNodes",
390
+ "serverSideDatasource",
391
+ "serverSideSortAllLevels",
392
+ "serverSideEnableClientSideSort",
393
+ "serverSideOnlyRefreshFilteredGroups",
394
+ "serverSidePivotResultFieldSeparator",
395
+ "viewportDatasource",
396
+ "viewportRowModelPageSize",
397
+ "viewportRowModelBufferSize",
398
+ "alwaysShowHorizontalScroll",
399
+ "alwaysShowVerticalScroll",
400
+ "debounceVerticalScrollbar",
401
+ "suppressHorizontalScroll",
402
+ "suppressScrollOnNewData",
403
+ "suppressScrollWhenPopupsAreOpen",
404
+ "suppressAnimationFrame",
405
+ "suppressMiddleClickScrolls",
406
+ "suppressPreventDefaultOnMouseWheel",
407
+ "scrollbarWidth",
408
+ "rowSelection",
409
+ "cellSelection",
410
+ "rowMultiSelectWithClick",
411
+ "suppressRowDeselection",
412
+ "suppressRowClickSelection",
413
+ "suppressCellFocus",
414
+ "suppressHeaderFocus",
415
+ "selectionColumnDef",
416
+ "rowNumbers",
417
+ "suppressMultiRangeSelection",
418
+ "enableCellTextSelection",
419
+ "enableRangeSelection",
420
+ "enableRangeHandle",
421
+ "enableFillHandle",
422
+ "fillHandleDirection",
423
+ "suppressClearOnFillReduction",
424
+ "sortingOrder",
425
+ "accentedSort",
426
+ "unSortIcon",
427
+ "suppressMultiSort",
428
+ "alwaysMultiSort",
429
+ "multiSortKey",
430
+ "suppressMaintainUnsortedOrder",
431
+ "icons",
432
+ "rowHeight",
433
+ "rowStyle",
434
+ "rowClass",
435
+ "rowClassRules",
436
+ "suppressRowHoverHighlight",
437
+ "suppressRowTransform",
438
+ "suppressContentVisibilityAuto",
439
+ "enableContentVisibilityAuto",
440
+ "contentVisibilityAutoDelay",
441
+ "columnHoverHighlight",
442
+ "gridId",
443
+ "deltaSort",
444
+ "treeDataDisplayType",
445
+ "enableGroupEdit",
446
+ "initialState",
447
+ "theme",
448
+ "loadThemeGoogleFonts",
449
+ "themeCssLayer",
450
+ "styleNonce",
451
+ "themeStyleContainer",
452
+ "getContextMenuItems",
453
+ "getMainMenuItems",
454
+ "getColumnMenuItems",
455
+ "postProcessPopup",
456
+ "processUnpinnedColumns",
457
+ "processCellForClipboard",
458
+ "processHeaderForClipboard",
459
+ "processGroupHeaderForClipboard",
460
+ "processCellFromClipboard",
461
+ "sendToClipboard",
462
+ "processDataFromClipboard",
463
+ "isExternalFilterPresent",
464
+ "doesExternalFilterPass",
465
+ "getChartToolbarItems",
466
+ "createChartContainer",
467
+ "focusGridInnerElement",
468
+ "navigateToNextHeader",
469
+ "tabToNextHeader",
470
+ "navigateToNextCell",
471
+ "tabToNextCell",
472
+ "tabToNextGridContainer",
473
+ "getLocaleText",
474
+ "getDocument",
475
+ "paginationNumberFormatter",
476
+ "getGroupRowAgg",
477
+ "isGroupOpenByDefault",
478
+ "isMasterOpenByDefault",
479
+ "ssrmExpandAllAffectsAllRows",
480
+ "initialGroupOrderComparator",
481
+ "processPivotResultColDef",
482
+ "processPivotResultColGroupDef",
483
+ "getDataPath",
484
+ "getChildCount",
485
+ "getServerSideGroupLevelParams",
486
+ "isServerSideGroupOpenByDefault",
487
+ "isApplyServerSideTransaction",
488
+ "isServerSideGroup",
489
+ "getServerSideGroupKey",
490
+ "getBusinessKeyForNode",
491
+ "getRowId",
492
+ "resetRowDataOnUpdate",
493
+ "autoGenerateColumnDefs",
494
+ "processAutoGeneratedColumnDefs",
495
+ "processRowPostCreate",
496
+ "isRowSelectable",
497
+ "isRowMaster",
498
+ "fillOperation",
499
+ "postSortRows",
500
+ "getRowStyle",
501
+ "getRowClass",
502
+ "getRowHeight",
503
+ "isFullWidthRow",
504
+ "isRowValidDropPosition"
505
+ ],
506
+ outputs: [
507
+ "toolPanelVisibleChanged",
508
+ "toolPanelSizeChanged",
509
+ "columnMenuVisibleChanged",
510
+ "contextMenuVisibleChanged",
511
+ "cutStart",
512
+ "cutEnd",
513
+ "pasteStart",
514
+ "pasteEnd",
515
+ "calculatedColumnCreated",
516
+ "calculatedColumnExpressionChanged",
517
+ "calculatedColumnRemoved",
518
+ "calculatedColumnValidationStateChanged",
519
+ "columnVisible",
520
+ "columnPinned",
521
+ "columnHeaderNameChanged",
522
+ "columnResized",
523
+ "columnMoved",
524
+ "columnValueChanged",
525
+ "columnPivotModeChanged",
526
+ "columnPivotChanged",
527
+ "columnGroupOpened",
528
+ "newColumnsLoaded",
529
+ "gridColumnsChanged",
530
+ "displayedColumnsChanged",
531
+ "virtualColumnsChanged",
532
+ "columnEverythingChanged",
533
+ "columnsReset",
534
+ "columnHeaderMouseOver",
535
+ "columnHeaderMouseLeave",
536
+ "columnHeaderClicked",
537
+ "columnHeaderContextMenu",
538
+ "componentStateChanged",
539
+ "cellValueChanged",
540
+ "cellEditRequest",
541
+ "rowValueChanged",
542
+ "cellEditingStarted",
543
+ "cellEditingStopped",
544
+ "rowEditingStarted",
545
+ "rowEditingStopped",
546
+ "bulkEditingStarted",
547
+ "bulkEditingStopped",
548
+ "batchEditingStarted",
549
+ "batchEditingStopped",
550
+ "undoStarted",
551
+ "undoEnded",
552
+ "redoStarted",
553
+ "redoEnded",
554
+ "cellSelectionDeleteStart",
555
+ "cellSelectionDeleteEnd",
556
+ "rangeDeleteStart",
557
+ "rangeDeleteEnd",
558
+ "fillStart",
559
+ "fillEnd",
560
+ "filterOpened",
561
+ "filterChanged",
562
+ "filterModified",
563
+ "filterUiChanged",
564
+ "floatingFilterUiChanged",
565
+ "advancedFilterBuilderVisibleChanged",
566
+ "findChanged",
567
+ "chartCreated",
568
+ "chartRangeSelectionChanged",
569
+ "chartOptionsChanged",
570
+ "chartDestroyed",
571
+ "cellKeyDown",
572
+ "gridReady",
573
+ "firstDataRendered",
574
+ "gridSizeChanged",
575
+ "modelUpdated",
576
+ "virtualRowRemoved",
577
+ "viewportChanged",
578
+ "bodyScroll",
579
+ "bodyScrollEnd",
580
+ "dragStarted",
581
+ "dragStopped",
582
+ "dragCancelled",
583
+ "stateUpdated",
584
+ "issueRaised",
585
+ "paginationChanged",
586
+ "rowDragEnter",
587
+ "rowDragMove",
588
+ "rowDragLeave",
589
+ "rowDragEnd",
590
+ "rowDragCancel",
591
+ "rowResizeStarted",
592
+ "rowResizeEnded",
593
+ "columnRowGroupChanged",
594
+ "rowGroupOpened",
595
+ "expandOrCollapseAll",
596
+ "pivotMaxColumnsExceeded",
597
+ "pinnedRowDataChanged",
598
+ "pinnedRowsChanged",
599
+ "rowDataUpdated",
600
+ "asyncTransactionsFlushed",
601
+ "storeRefreshed",
602
+ "headerFocused",
603
+ "cellClicked",
604
+ "cellDoubleClicked",
605
+ "cellFocused",
606
+ "cellMouseOver",
607
+ "cellMouseOut",
608
+ "cellMouseDown",
609
+ "rowClicked",
610
+ "rowDoubleClicked",
611
+ "rowSelected",
612
+ "selectionChanged",
613
+ "cellContextMenu",
614
+ "rangeSelectionChanged",
615
+ "cellSelectionChanged",
616
+ "tooltipShow",
617
+ "tooltipHide",
618
+ "sortChanged"
619
+ ]
620
+ }],
621
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
622
+ });
623
+ };
624
+ i0.ɵɵngDeclareClassMetadata({
625
+ minVersion: "12.0.0",
626
+ version: "22.2.3",
627
+ ngImport: i0,
628
+ type: DataGrid,
629
+ decorators: [{
630
+ type: Component,
631
+ args: [{
632
+ selector: "wa-data-grid",
633
+ imports: [AgGridAngular],
634
+ changeDetection: ChangeDetectionStrategy.OnPush,
635
+ host: { class: "block h-full w-full" },
636
+ template: "@for (grid of grids(); track grid) {\n <ag-grid-angular class=\"block h-full w-full\" [gridOptions]=\"grid.options\" (gridReady)=\"announce($event)\" />\n}\n"
637
+ }]
638
+ }],
639
+ ctorParameters: () => [],
640
+ propDecorators: {
641
+ options: [{
642
+ type: i0.Input,
643
+ args: [{
644
+ isSignal: true,
645
+ alias: "options",
646
+ required: true
647
+ }]
648
+ }],
649
+ localeOverrides: [{
650
+ type: i0.Input,
651
+ args: [{
652
+ isSignal: true,
653
+ alias: "localeOverrides",
654
+ required: false
655
+ }]
656
+ }],
657
+ ready: [{
658
+ type: i0.Output,
659
+ args: ["ready"]
660
+ }]
661
+ }
662
+ });
663
+ const TEXT_KEYS = {
664
+ search: "searchOoo",
665
+ selectAll: "selectAll",
666
+ clear: "clearFilter",
667
+ empty: "noMatches"
668
+ };
669
+ const FALLBACK_TEXTS = textsOf(AG_GRID_LOCALE_EN);
670
+ let nextInstance = 0;
671
+ var ListFilter = class ListFilter {
672
+ searchBox = viewChild("searchBox", ...ngDevMode ? [{ debugName: "searchBox" }] : /* istanbul ignore next */ []);
673
+ params = null;
674
+ id = `wa-list-filter-${nextInstance++}`;
675
+ legend = signal("", ...ngDevMode ? [{ debugName: "legend" }] : /* istanbul ignore next */ []);
676
+ texts = signal(FALLBACK_TEXTS, ...ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []);
677
+ options = signal([], ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
678
+ selected = signal(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
679
+ search = signal("", ...ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []);
680
+ shown = computed(() => {
681
+ const needle = this.search().trim().toLocaleLowerCase();
682
+ return needle ? this.options().filter((option) => option.label.toLocaleLowerCase().includes(needle)) : this.options();
683
+ }, ...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
684
+ allShownSelected = computed(() => this.shown().length > 0 && this.shown().every((option) => this.selected().has(option.value)), ...ngDevMode ? [{ debugName: "allShownSelected" }] : /* istanbul ignore next */ []);
685
+ agInit(params) {
686
+ this.params = params;
687
+ this.legend.set(params.api.getDisplayNameForColumn(params.column, "filterToolPanel") ?? "");
688
+ this.readOptions();
689
+ }
690
+ isFilterActive() {
691
+ return this.selected().size > 0;
692
+ }
693
+ doesFilterPass(params) {
694
+ const rowValue = this.params?.rowValue;
695
+ return !rowValue || this.selected().has(rowValue(params.data));
696
+ }
697
+ getModel() {
698
+ return this.isFilterActive() ? { values: [...this.selected()] } : null;
699
+ }
700
+ setModel(model) {
701
+ this.selected.set(new Set(model?.values ?? []));
702
+ }
703
+ afterGuiAttached(params) {
704
+ this.readOptions();
705
+ if (!params?.suppressFocus) this.searchBox()?.nativeElement.focus();
706
+ }
707
+ isSelected(option) {
708
+ return this.selected().has(option.value);
709
+ }
710
+ toggle(option, checked) {
711
+ const next = new Set(this.selected());
712
+ if (checked) next.add(option.value);
713
+ else next.delete(option.value);
714
+ this.apply(next);
715
+ }
716
+ toggleAll(checked) {
717
+ const shown = this.shown().map((option) => option.value);
718
+ const next = new Set(this.selected());
719
+ for (const value of shown) if (checked) next.add(value);
720
+ else next.delete(value);
721
+ this.apply(next);
722
+ }
723
+ clear() {
724
+ this.search.set("");
725
+ this.apply(/* @__PURE__ */ new Set());
726
+ }
727
+ readOptions() {
728
+ if (!this.params) return;
729
+ this.options.set(this.params.options());
730
+ this.texts.set(textsOf(this.params.api.getGridOption("localeText") ?? {}));
731
+ }
732
+ apply(next) {
733
+ this.selected.set(next);
734
+ this.params?.filterChangedCallback();
735
+ }
736
+ static ɵfac = i0.ɵɵngDeclareFactory({
737
+ minVersion: "12.0.0",
738
+ version: "22.2.3",
739
+ ngImport: i0,
740
+ type: ListFilter,
741
+ deps: [],
742
+ target: i0.ɵɵFactoryTarget.Component
743
+ });
744
+ static ɵcmp = i0.ɵɵngDeclareComponent({
745
+ minVersion: "17.0.0",
746
+ version: "22.2.3",
747
+ type: ListFilter,
748
+ isStandalone: true,
749
+ selector: "wa-list-filter",
750
+ viewQueries: [{
751
+ propertyName: "searchBox",
752
+ first: true,
753
+ predicate: ["searchBox"],
754
+ descendants: true,
755
+ isSignal: true
756
+ }],
757
+ ngImport: i0,
758
+ template: "<fieldset class=\"m-0 flex w-64 flex-col gap-2 border-0 p-3 text-sm text-content\" data-testid=\"list-filter\">\n <legend class=\"mb-1 p-0 font-medium\">{{ legend() }}</legend>\n\n <label class=\"sr-only\" [attr.for]=\"id + '-search'\">{{ texts().search }}</label>\n <input\n #searchBox\n type=\"search\"\n class=\"lw-field h-9\"\n [id]=\"id + '-search'\"\n [placeholder]=\"texts().search\"\n [value]=\"search()\"\n (input)=\"search.set(searchBox.value)\"\n />\n\n @if (shown().length === 0) {\n <p class=\"m-0 text-content-muted\">{{ texts().empty }}</p>\n } @else {\n <label class=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n class=\"lw-checkbox\"\n data-testid=\"list-filter-all\"\n [checked]=\"allShownSelected()\"\n (change)=\"toggleAll($any($event.target).checked)\"\n />\n <span>{{ texts().selectAll }}</span>\n </label>\n <ul class=\"m-0 flex max-h-64 list-none flex-col gap-1 overflow-y-auto p-0\">\n @for (option of shown(); track option.value) {\n <li>\n <label class=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n class=\"lw-checkbox\"\n [attr.data-testid]=\"'list-filter-option-' + option.value\"\n [checked]=\"isSelected(option)\"\n (change)=\"toggle(option, $any($event.target).checked)\"\n />\n <span>{{ option.label }}</span>\n </label>\n </li>\n }\n </ul>\n }\n\n <button type=\"button\" class=\"lw-btn self-end\" data-testid=\"list-filter-clear\" (click)=\"clear()\">{{ texts().clear }}</button>\n</fieldset>\n",
759
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
760
+ });
761
+ };
762
+ i0.ɵɵngDeclareClassMetadata({
763
+ minVersion: "12.0.0",
764
+ version: "22.2.3",
765
+ ngImport: i0,
766
+ type: ListFilter,
767
+ decorators: [{
768
+ type: Component,
769
+ args: [{
770
+ selector: "wa-list-filter",
771
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
772
+ changeDetection: ChangeDetectionStrategy.OnPush,
773
+ template: "<fieldset class=\"m-0 flex w-64 flex-col gap-2 border-0 p-3 text-sm text-content\" data-testid=\"list-filter\">\n <legend class=\"mb-1 p-0 font-medium\">{{ legend() }}</legend>\n\n <label class=\"sr-only\" [attr.for]=\"id + '-search'\">{{ texts().search }}</label>\n <input\n #searchBox\n type=\"search\"\n class=\"lw-field h-9\"\n [id]=\"id + '-search'\"\n [placeholder]=\"texts().search\"\n [value]=\"search()\"\n (input)=\"search.set(searchBox.value)\"\n />\n\n @if (shown().length === 0) {\n <p class=\"m-0 text-content-muted\">{{ texts().empty }}</p>\n } @else {\n <label class=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n class=\"lw-checkbox\"\n data-testid=\"list-filter-all\"\n [checked]=\"allShownSelected()\"\n (change)=\"toggleAll($any($event.target).checked)\"\n />\n <span>{{ texts().selectAll }}</span>\n </label>\n <ul class=\"m-0 flex max-h-64 list-none flex-col gap-1 overflow-y-auto p-0\">\n @for (option of shown(); track option.value) {\n <li>\n <label class=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n class=\"lw-checkbox\"\n [attr.data-testid]=\"'list-filter-option-' + option.value\"\n [checked]=\"isSelected(option)\"\n (change)=\"toggle(option, $any($event.target).checked)\"\n />\n <span>{{ option.label }}</span>\n </label>\n </li>\n }\n </ul>\n }\n\n <button type=\"button\" class=\"lw-btn self-end\" data-testid=\"list-filter-clear\" (click)=\"clear()\">{{ texts().clear }}</button>\n</fieldset>\n"
774
+ }]
775
+ }],
776
+ propDecorators: { searchBox: [{
777
+ type: i0.ViewChild,
778
+ args: ["searchBox", { isSignal: true }]
779
+ }] }
780
+ });
781
+ function textsOf(localeText, fallback = AG_GRID_LOCALE_EN) {
782
+ const text = (key) => localeText[key] ?? fallback[key] ?? key;
783
+ return {
784
+ search: text(TEXT_KEYS.search),
785
+ selectAll: text(TEXT_KEYS.selectAll),
786
+ clear: text(TEXT_KEYS.clear),
787
+ empty: text(TEXT_KEYS.empty)
788
+ };
789
+ }
790
+ function listingDatasource(fetch, options = {}) {
791
+ let latest = "";
792
+ return { getRows(params) {
793
+ const asked = queryOf(params.filterModel, params.sortModel);
794
+ latest = asked;
795
+ const request = {
796
+ offset: params.startRow,
797
+ limit: params.endRow - params.startRow,
798
+ sort: sortOf(params.sortModel),
799
+ filters: params.filterModel ?? {}
800
+ };
801
+ const current = () => asked === latest && !params.api?.isDestroyed();
802
+ fetch(request).then((answer) => {
803
+ if (!current()) return;
804
+ options.answered?.(answer);
805
+ params.successCallback([...answer.items], answer.total);
806
+ }, (error) => {
807
+ if (!current()) return;
808
+ options.failed?.(error);
809
+ params.failCallback();
810
+ });
811
+ } };
812
+ }
813
+ function queryOf(filterModel, sortModel) {
814
+ return JSON.stringify({
815
+ filters: filterModel ?? {},
816
+ sort: sortModel.map(({ colId, sort }) => ({
817
+ colId,
818
+ sort
819
+ }))
820
+ });
821
+ }
822
+ function sortOf(sortModel) {
823
+ const first = sortModel[0];
824
+ return first ? {
825
+ column: first.colId,
826
+ descending: first.sort === "desc"
827
+ } : null;
828
+ }
829
+ export { DATA_GRID_BLOCK_SIZE, DATA_GRID_MAX_BLOCKS, DATA_GRID_ROW_HEIGHT_PX, DataGrid, ListFilter, dataGridLocaleText, dataGridModules, dataGridTheme, dataGridThemeParams, listingDatasource, registerDataGridModules };
830
+
831
+ //# sourceMappingURL=weaver-apps-data-grid.mjs.map