@coolon/angular-ui-powerups 13.7.11 → 13.7.13

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.
@@ -39,7 +39,7 @@ import { MatTableModule } from '@angular/material/table';
39
39
  import * as i6 from '@angular/material/tooltip';
40
40
  import { MatTooltipModule } from '@angular/material/tooltip';
41
41
  import * as i1$6 from '@coolon/pectin';
42
- import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, ValueModel, StoreInValueModel, Command, MutableListModel, StoreInListModel, Disposable, DelegatingListModel, MutableValueModel, FocusManager, EventListenerList, Form, Guard, Binding, DebugContext, ListModel, Functions, MultipleSelectionModel, AbstractComputedListModel, DelegatingSelectionModel, DirtyTrackingForm, PagedListModel, PageController, ComputedListModel, Trace, Deferred } from '@coolon/pectin';
42
+ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, ValueModel, StoreInValueModel, Command, MutableListModel, StoreInListModel, Disposable, DelegatingListModel, MutableValueModel, FocusManager, EventListenerList, Form, Guard, Binding, DebugContext, ListModel, Functions, MultipleSelectionModel, AbstractComputedListModel, DelegatingSelectionModel, DirtyTrackingForm, PagedListModel, PageController, ComputedListModel, Deferred } from '@coolon/pectin';
43
43
  import { __decorate, __param, __metadata } from 'tslib';
44
44
  import * as i1$2 from '@angular/platform-browser';
45
45
  import escapeStringRegexp from 'escape-string-regexp';
@@ -2974,6 +2974,10 @@ class ColumnListModel extends AbstractComputedListModel {
2974
2974
  hasColumn(id) {
2975
2975
  return !!this.columnsById$.get(id);
2976
2976
  }
2977
+ hasMatchingColumn(row, regex) {
2978
+ // only search the visible columns
2979
+ return !!this.value.find(c => regex.test(c.getSearchTextFor(row)));
2980
+ }
2977
2981
  addColumn(column, index) {
2978
2982
  if (this.hasColumn(column.columnId)) {
2979
2983
  lang.illegalState(`Column with id=${column.columnId} already exists`);
@@ -3242,6 +3246,58 @@ class RowClass {
3242
3246
  this.matches = matches;
3243
3247
  }
3244
3248
  }
3249
+ class FilterManager extends GarbageCollector {
3250
+ constructor(columns) {
3251
+ super();
3252
+ this.columns = columns;
3253
+ this._userRowPredicate$ = this.registerDisposable(new DelegatingValueModel().withDefault(() => true));
3254
+ this._searchText$ = this.registerDisposable(new DelegatingValueModel());
3255
+ this.updateInProgress = new Guard();
3256
+ const { chain } = Dsl.disposeWith(this);
3257
+ // TODO: should this logic be in the strategy itself? That way users could
3258
+ // customise...
3259
+ const textSearchPredicate$ = chain(this._searchText$).map(text => {
3260
+ if (isEmpty$1(text)) {
3261
+ return () => true;
3262
+ }
3263
+ else {
3264
+ const regex = new RegExp(escapeStringRegexp(text), "i");
3265
+ return (row) => this.hasMatchingColumn(row, regex);
3266
+ }
3267
+ }, {
3268
+ allowNil: true,
3269
+ dependsOn: this.columns
3270
+ });
3271
+ this.rowPredicate$ = chain(this._userRowPredicate$)
3272
+ .map(p => {
3273
+ return ((row) => p(row) && textSearchPredicate$.value(row));
3274
+ }, {
3275
+ dependsOn: textSearchPredicate$,
3276
+ postponeWhile: this.updateInProgress
3277
+ });
3278
+ }
3279
+ setStrategy(filterStrategy) {
3280
+ if (this._searchText$.hasUserDelegate()) {
3281
+ lang.illegalState("Filter strategy has already been set, it must be disposed first.");
3282
+ }
3283
+ this.updateInProgress.whileTrue(() => {
3284
+ this._searchText$.setDelegate(filterStrategy.searchText$);
3285
+ this._userRowPredicate$.setDelegate(filterStrategy.rowPredicate$);
3286
+ });
3287
+ const self = this;
3288
+ return {
3289
+ dispose() {
3290
+ self.updateInProgress.whileTrue(() => {
3291
+ this._searchText$.setDelegate(undefined);
3292
+ this._userRowPredicate$.setDelegate(undefined);
3293
+ });
3294
+ }
3295
+ };
3296
+ }
3297
+ hasMatchingColumn(row, regex) {
3298
+ return !!this.columns.value.find(c => regex.test(c.getSearchTextFor(row)));
3299
+ }
3300
+ }
3245
3301
  class AbstractTableModel extends GarbageCollector {
3246
3302
  constructor() {
3247
3303
  super();
@@ -3262,18 +3318,12 @@ class AbstractTableModel extends GarbageCollector {
3262
3318
  });
3263
3319
  this._editorSessionByRowId = chain(this._editorSessions).indexBy("rowId");
3264
3320
  this.editing$ = chain(this._editorSessions).count().isGreaterThan(0);
3265
- this._textSearchPredicate$ = chain(this._searchText$).map(text => {
3266
- return isEmpty$1(text) ? Functions.identity : (rows) => {
3267
- const regex = new RegExp(escapeStringRegexp(text), "i");
3268
- return rows.filter(row => this.hasMatchingColumn(row, regex));
3269
- };
3270
- }, {
3271
- allowNil: true,
3272
- dependsOn: this.columns
3273
- });
3321
+ this.filterManager = this.registerDisposable(new FilterManager(this._columnList));
3274
3322
  this._filteredRows$ = chain(this._rawDataSource)
3275
- .reduceToList(items => this._textSearchPredicate$.value(items), {
3276
- dependsOn: this._textSearchPredicate$
3323
+ .reduceToList(items => {
3324
+ return items.filter(item => this.filterManager.rowPredicate$.value(item));
3325
+ }, {
3326
+ dependsOn: this.filterManager.rowPredicate$
3277
3327
  })
3278
3328
  .replaceAll(this.rowsBeingEdited$);
3279
3329
  this._visibleRows$.setDelegate(this._filteredRows$);
@@ -3306,9 +3356,8 @@ class AbstractTableModel extends GarbageCollector {
3306
3356
  setDataSource(sourceOfTruth) {
3307
3357
  this._rawDataSource.setDelegate(sourceOfTruth);
3308
3358
  }
3309
- setTextSearch(searchText$, throttleDelayMilliseconds = 100) {
3310
- const { chain } = Dsl.disposeWith(this);
3311
- this._searchText$.setDelegate(chain(searchText$).throttle(throttleDelayMilliseconds));
3359
+ registerFilterStrategy(filterStrategy) {
3360
+ return this.filterManager.setStrategy(filterStrategy);
3312
3361
  }
3313
3362
  identityOf(row) {
3314
3363
  return this._rawDataSource.identityOf(row);
@@ -4029,7 +4078,7 @@ class TableComponent extends AbstractTableComponent {
4029
4078
  return this.tableModel;
4030
4079
  }
4031
4080
  footerContentChanged($event) {
4032
- console.log($event);
4081
+ // console.log($event);
4033
4082
  this._footerContentAdded = true;
4034
4083
  }
4035
4084
  //@Trace()
@@ -5538,6 +5587,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.4", ngImpor
5538
5587
  isNavigationInProgress() {
5539
5588
  return this.placeRouter.navigationInProgress$.value;
5540
5589
  }
5590
+ // @Trace()
5541
5591
  notifyFinished(context) {
5542
5592
  this.contextRegistry.finish(context);
5543
5593
  // :: Important ::
@@ -5552,12 +5602,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.4", ngImpor
5552
5602
  this.placeRouter.syncInteractionContextIdsWithRouter();
5553
5603
  }
5554
5604
  }
5555
- __decorate([
5556
- Trace(),
5557
- __metadata("design:type", Function),
5558
- __metadata("design:paramtypes", [Object]),
5559
- __metadata("design:returntype", Promise)
5560
- ], ApiAdapter.prototype, "notifyFinished", null);
5561
5605
  InteractionService.ApiAdapter = ApiAdapter;
5562
5606
  })(InteractionService || (InteractionService = {}));
5563
5607
 
@@ -7471,7 +7515,7 @@ class ActivityContainerComponent extends AbstractInteractionContext {
7471
7515
  if (!this.isActive()) {
7472
7516
  // wait until the activity route syncing has finished
7473
7517
  await this.placeRouter.waitActivitiesSynchronised();
7474
- console.log("activity syncing finished");
7518
+ // console.log("activity syncing finished")
7475
7519
  }
7476
7520
  }
7477
7521
  }
@@ -8285,6 +8329,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.4", ngImpor
8285
8329
  }]
8286
8330
  }] });
8287
8331
 
8332
+ // TODO: This is all kinda ugly and limited, would probably be better to make it an interface
8333
+ // that has a single model with a row matching interface.
8334
+ // rowPredicate$: ValueModel<row => matches(row, visibleColumns)>
8335
+ // that way you can implement it how every you want.... But for now this was quicker.
8336
+ class FilterStrategy extends GarbageCollector {
8337
+ constructor(rowPredicate$, searchText$) {
8338
+ super();
8339
+ this.rowPredicate$ = rowPredicate$;
8340
+ this.searchText$ = searchText$;
8341
+ }
8342
+ static create(build) {
8343
+ const builder = new FilterStrategy.BuilderImp();
8344
+ build(builder);
8345
+ return new FilterStrategy(builder.rowPredicate ?? ValueModel.constant(() => true), builder.searchText$ ?? ValueModel.constant(""));
8346
+ }
8347
+ }
8348
+ (function (FilterStrategy) {
8349
+ class BuilderImp {
8350
+ usePredicate(predicate$) {
8351
+ this.rowPredicate = predicate$;
8352
+ return this;
8353
+ }
8354
+ useSearchText(searchText$) {
8355
+ this.searchText$ = searchText$;
8356
+ return this;
8357
+ }
8358
+ }
8359
+ FilterStrategy.BuilderImp = BuilderImp;
8360
+ })(FilterStrategy || (FilterStrategy = {}));
8361
+
8288
8362
  /**
8289
8363
  * @file Automatically generated by barrelsby.
8290
8364
  */
@@ -9321,7 +9395,7 @@ class PlaceOutletComponent extends DisposableComponent {
9321
9395
  const { when, chain, valueOf } = Dsl.disposeWith(activePlace);
9322
9396
  when(this.routerVisitModel)
9323
9397
  .changes(visit => {
9324
- console.log("routerVisitModel.change", { routerVisitModel: this.routerVisitModel.value });
9398
+ // console.log("routerVisitModel.change", { routerVisitModel: this.routerVisitModel.value })
9325
9399
  this.pushVisitChangeToComponent(activePlace, visit);
9326
9400
  }, {
9327
9401
  unless: valueOf.any(this._isPushingVisitToRoute, this.routerVisitModel.isNil()).areTruthy()
@@ -10166,7 +10240,7 @@ class VisibilityService extends GarbageCollector {
10166
10240
  }
10167
10241
  // Warn if the browser doesn't support addEventListener or the Page Visibility API
10168
10242
  if (typeof this.document.addEventListener === 'undefined' || typeof document[this.attributeName] === 'undefined') {
10169
- console.log('This demo requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.');
10243
+ console.log('This app requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.');
10170
10244
  }
10171
10245
  else {
10172
10246
  // Handle page visibility change
@@ -10224,5 +10298,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.4", ngImpor
10224
10298
  * Generated bundle index. Do not edit.
10225
10299
  */
10226
10300
 
10227
- export { ACTIVITY_DATA, ALERT_CONFIG, AUP_PLACE_CONFIG, AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT, AbstractActivityTriggerComponent, AbstractCardContainerComponent, AbstractConfirmDialogComponent, AbstractDialogComponent, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractPopupMenuComponent, AbstractTableComponent, AbstractTableModel, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityBodyComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, ActivityTitleComponent, AddCardActivityComponent, AddItemInteractionContextComponent, Alert, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CardStackComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnListModel, ColumnModel, ColumnTemplateDirective, ColumnTextSearchFormatter, CommandComponent, CommandContainer, CommandDirective, CommandFace, CommandFaceComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmThenExecuteDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DecoratedTreeNode, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EnableCellTextSearch, EventCleanUpSession, FlattenedTreeListModel, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, HighlightPipe, HighlightTextModelDirective, HorizontalAlignment, IconComponent, InPlaceInteractionContextComponent, InlineActivityTriggerComponent, InlineEditorModel, InlineStringEditorComponent, InputActivity, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, Keys, LEFT_RIGHT_PLACE_ANIMATION, LabelledValueComponent, ListPlaceNavComponent, ListPropertyColumnModel, LoadingContainerComponent, MarkdownComponent, MarkdownService, ModalActivityTriggerComponent, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NotAuthorisedNoticeComponent, NumberInputComponent, POPUP_CONTAINER, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, PaginatorComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceAccessGuard, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupActivityTriggerComponent, PopupAwareComponent, PopupInteractionContextComponent, PopupMenuComponent, PopupMenuRendererComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectInputActivity, SelectInputComponent, SelectionCellComponent, SelectionColumnModel, SelectionHeaderCellComponent, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableBodyComponent, TableCellComponent, TableComponent, TableHeaderCellComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, TreeExpansionModel, TreeInheritanceIconComponent, TreeLabelCellRendererComponent, TreeLabelColumnModel, TreeTableComponent, TreeTableModel, UrlService, UrlSnapshot, VerticalFocusContainerComponent, VisibilityService, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, markdownPillExtension, slideDownOnEnterAnimation, slideRightOnEnterAnimation, treeNodeDecorator };
10301
+ export { ACTIVITY_DATA, ALERT_CONFIG, AUP_PLACE_CONFIG, AUP_UNAUTHORISED_PLACE_NOTICE_COMPONENT, AbstractActivityTriggerComponent, AbstractCardContainerComponent, AbstractConfirmDialogComponent, AbstractDialogComponent, AbstractInputComponent, AbstractInteractionContext, AbstractListInputComponent, AbstractPlaceNavigationComponent, AbstractPopStateNavigation, AbstractPopupMenuComponent, AbstractTableComponent, AbstractTableModel, AbstractValueInputComponent, Activity, ActivityActionsComponent, ActivityBodyComponent, ActivityContainerComponent, ActivityOutletComponent, ActivityRef, ActivityTitleComponent, AddCardActivityComponent, AddItemInteractionContextComponent, Alert, AlertDialogComponent, AngularUiPowerupsModule, AutocompleteInputComponent, Bounds, BusyOverlayComponent, CELL_EDITOR_PORTAL, CELL_RENDERER_PORTAL, CardContainerComponent, CardStackComponent, CellEditorPortalRef, CellHeaderPortalRef, CellPortalRef, CellRendererPortalRef, CheckboxInputComponent, ColumnListModel, ColumnModel, ColumnTemplateDirective, ColumnTextSearchFormatter, CommandComponent, CommandContainer, CommandDirective, CommandFace, CommandFaceComponent, ComponentCellRendererPortalRef, ComponentsModule, ConfirmThenDialogComponent, ConfirmThenExecuteDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, CustomTemplateColumnModel, CustomValueColumnModel, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DecoratedTreeNode, DefaultCellRendererComponent, DefaultHeaderCellRendererComponent, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EditRowControls, EditSession, EditorControlColumnModel, EmptyStateComponent, EnableCellTextSearch, EventCleanUpSession, FilterStrategy, FlattenedTreeListModel, FlexComponent, FocusBinding, FocusBindingDirective, FocusBindingFactory, FocusContainerComponent, FocusableComponent, Formatter, HEADER_CELL_RENDERER_PORTAL, HighlightPipe, HighlightTextModelDirective, HorizontalAlignment, IconComponent, InPlaceInteractionContextComponent, InlineActivityTriggerComponent, InlineEditorModel, InlineStringEditorComponent, InputActivity, InteractionContextTriggerFor, InteractionModule, InteractionService, InteractionServiceRoutingAdapter, Keys, LEFT_RIGHT_PLACE_ANIMATION, LabelledValueComponent, ListPlaceNavComponent, ListPropertyColumnModel, LoadingContainerComponent, MarkdownComponent, MarkdownService, ModalActivityTriggerComponent, ModalInteractionContextFactory, MoreMenuComponent, MultipleSelectInputComponent, Navigating, NavigatingDuringInteraction, NavigationContext, NavigationSession, NoopAuthGuard, NoopComponent, NotAuthorisedNoticeComponent, NumberInputComponent, POPUP_CONTAINER, PORTAL_EDITOR_COMPONENT, PORTAL_RENDERER_COMPONENT, PaginatorComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceAccessGuard, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, PopStateDuringInteractionNavigation, PopStateNavigation, PopupActivityTriggerComponent, PopupAwareComponent, PopupInteractionContextComponent, PopupMenuComponent, PopupMenuRendererComponent, PropertyColumnModel, ROUTE_PARAMETER_LIST_KEY, RemoveLastInteractionFromUrlNavigationSession, ResizeAwareComponent, RouteId, ScrollContainerComponent, SectionHeaderComponent, SelectInputActivity, SelectInputComponent, SelectionCellComponent, SelectionColumnModel, SelectionHeaderCellComponent, SeparatorComponent, SidePlaceNavigationComponent, StringInputActivity, StringInputComponent, SwitchCaseComponent, SwitchCaseDefaultDirective, SwitchCaseOption, SwitchCaseWhenDirective, SynchroniseInteractionContextIdsWithRoute, TabbedPlaceNavigationComponent, TableBodyComponent, TableCellComponent, TableComponent, TableHeaderCellComponent, TableModel, TableRowMenuComponent, TemplateCellRendererPortalRef, TextInputComponent, ToolBarComponent, TrackBy, TreeExpansionModel, TreeInheritanceIconComponent, TreeLabelCellRendererComponent, TreeLabelColumnModel, TreeTableComponent, TreeTableModel, UrlService, UrlSnapshot, VerticalFocusContainerComponent, VisibilityService, Visit, VisitParameter, VisitParameterList, VisitSanitiser, WaitUntilLeavingInteractionTransitionCancelled, WaitUntilLinkTriggeredNavigationInteractionCancellationTypeDetermined, WaitUntilPopStateDuringCanDeactivateInteractionFinishes, leftRightPlaceAnimation, markdownPillExtension, slideDownOnEnterAnimation, slideRightOnEnterAnimation, treeNodeDecorator };
10228
10302
  //# sourceMappingURL=coolon-angular-ui-powerups.mjs.map