@coolon/angular-ui-powerups 16.1.0-alpha.266 → 16.1.0-alpha.267

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.
@@ -106,7 +106,7 @@ export declare abstract class AbstractTableModel<Row extends object> extends Gar
106
106
  getSelectionModel(): SelectionModel<Row> | undefined;
107
107
  isHoverEnabled(): boolean;
108
108
  isCursorEnabled(column: ColumnModel<Row>): boolean;
109
- /** Whether the selection model will accept this row (see MultipleSelectionModel's selectableWhen). */
109
+ /** Whether the selection model will accept this row (see MultipleSelectionModel.disableSelectionIf). */
110
110
  isRowSelectable(row: Row): boolean;
111
111
  isRowSelectionEnabledForRow(row: Row): boolean;
112
112
  /**
@@ -3,6 +3,7 @@ import { CdkPortalOutletAttachedRef } from "@angular/cdk/portal";
3
3
  import { Injector } from "@angular/core";
4
4
  import { GarbageCollector, ValueModel } from "@coolon/pectin";
5
5
  import { ColumnTextSearchFormatter } from "../filter/column-text-search-formatter";
6
+ import type { ColumnTextMatcher } from "../filter/text-search-predicate";
6
7
  import { CellHeaderPortalRef, type CellRendererPortalRef } from "../renderer/cell-portal-ref";
7
8
  import type { TableCellComponent } from "../renderer/table-cell/table-cell.component";
8
9
  import type { TableHeaderCellComponent } from "../renderer/table-header-cell/table-header-cell.component";
@@ -33,6 +34,8 @@ export declare class ColumnModel<Row extends object> extends GarbageCollector {
33
34
  private _userVisible$;
34
35
  readonly dasherisedColumnId: string;
35
36
  private readonly textSearchDelegate;
37
+ private _textMatcher;
38
+ private _textMatcherMap;
36
39
  readonly visible$: ValueModel<boolean>;
37
40
  constructor(columnId: string, order: ColumnOrderManager, textPropertiesProvider: ColumnModel.TextPropertiesProvider);
38
41
  protected installHeaderRenderer(): void;
@@ -54,6 +57,10 @@ export declare class ColumnModel<Row extends object> extends GarbageCollector {
54
57
  getSearchTextFor(row: Row): string;
55
58
  configureColumnTextSearch(formatter: ColumnTextSearchFormatter<Row>): this;
56
59
  configureColumnTextSearch<T>(formatter: ColumnTextSearchFormatter<T>, mapper: (row: Row) => T): this;
60
+ /** False for a column without a matcher — it contributes only its search text. */
61
+ matchesSearchFor(row: Row, searchText: string): boolean;
62
+ configureColumnTextMatch(matcher: ColumnTextMatcher<Row>): this;
63
+ configureColumnTextMatch<T>(matcher: ColumnTextMatcher<T>, mapper: (row: Row) => T): this;
57
64
  protected configureHeaderRenderer<C>(config: CellHeaderPortalRef<Row, unknown>): void;
58
65
  protected configureCellRenderer<C>(config: CellRendererPortalRef<Row, unknown>): void;
59
66
  cellHeaderRenderer<C>(componentType: ComponentType<C>, initialiser: (component: C, column: ColumnModel<Row>) => void): this;
@@ -3,10 +3,12 @@ import { Constructable } from "@coolon/typescript-utilities";
3
3
  import { Enum } from "typescript-string-enums";
4
4
  import type { CellRenderer } from "../renderer/cell-renderer";
5
5
  import { ColumnTextSearchFormatter } from "./column-text-search-formatter";
6
+ import type { ColumnTextMatcher } from "./text-search-predicate";
6
7
  export declare const Keys: {
7
8
  useFunction: "useFunction";
8
9
  useInstance: "useInstance";
9
10
  useClass: "useClass";
11
+ useMatcher: "useMatcher";
10
12
  };
11
13
  export type Keys = Enum<typeof Keys>;
12
14
  interface UseFunction<Row> {
@@ -18,8 +20,21 @@ interface UseInstance<Row> {
18
20
  interface UseClass<Row> {
19
21
  [Keys.useClass]: Constructable<ColumnTextSearchFormatter<Row>>;
20
22
  }
21
- export declare function EnableCellTextSearch<Row>(options: UseFunction<Row> | UseInstance<Row> | UseClass<Row>): ClassDecorator;
23
+ interface UseMatcher<Row> {
24
+ [Keys.useMatcher]: ColumnTextMatcher<Row>;
25
+ }
26
+ type FormatterOptions<Row> = UseFunction<Row> | UseInstance<Row> | UseClass<Row>;
27
+ /**
28
+ * A renderer contributes searchable TEXT (a formatter — matched against the escaped literal form
29
+ * of the query), its own MATCHING of the raw query (a matcher — for semantics a literal substring
30
+ * can't express), or both. With a matcher alone the column contributes no text and answers only
31
+ * through the matcher.
32
+ */
33
+ export type CellTextSearchOptions<Row> = FormatterOptions<Row> | UseMatcher<Row> | (FormatterOptions<Row> & UseMatcher<Row>);
34
+ export declare function EnableCellTextSearch<Row>(options: CellTextSearchOptions<Row>): ClassDecorator;
22
35
  export declare namespace EnableCellTextSearch {
23
36
  function getFormatter(renderer: ComponentType<CellRenderer<any>>, useDefault: () => ColumnTextSearchFormatter<any>): ColumnTextSearchFormatter<any>;
37
+ /** Undefined unless the renderer declared `useMatcher` — the column then matches on text alone. */
38
+ function getMatcher(renderer: ComponentType<CellRenderer<any>>): ColumnTextMatcher<any> | undefined;
24
39
  }
25
40
  export {};
@@ -1,10 +1,16 @@
1
- import { AbstractConstructable } from "@coolon/restilence-plugin";
2
- export type TextSearchPredicate<Row> = (row: Row, regex: RegExp) => boolean;
3
- export declare class TextSearchContext<Row> {
4
- readonly row: Row;
5
- readonly searchText: string;
6
- readonly searchRegex: RegExp;
7
- constructor(row: Row, searchText: string, searchRegex: RegExp);
8
- getOrCreate<T>(type: AbstractConstructable<T>, create: () => T): void;
9
- matchesText(text: string): boolean;
10
- }
1
+ /**
2
+ * Tests a row against the current search. `regex` is the escaped literal form of the search text,
3
+ * tested against the text columns contribute (ColumnTextSearchFormatter); `searchText` is the raw
4
+ * query, for columns matching via a ColumnTextMatcher instead.
5
+ */
6
+ export type TextSearchPredicate<Row> = (row: Row, regex: RegExp, searchText?: string) => boolean;
7
+ /**
8
+ * A column's own answer to "does this cell match the query?", given the RAW search text — for
9
+ * search semantics one escaped literal substring can't express, e.g. the category-qualified
10
+ * `loc:depar` = category starts with LOC and name contains "depar". Declared by a cell renderer
11
+ * via `@EnableCellTextSearch({useMatcher})`, so `value` is the renderer's value type: the column's
12
+ * existing row -> value accessor does the projection.
13
+ *
14
+ * A row matches when the joined column text matches the regex OR any column's matcher returns true.
15
+ */
16
+ export type ColumnTextMatcher<V> = (value: V, searchText: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coolon/angular-ui-powerups",
3
- "version": "16.1.0-alpha.266",
3
+ "version": "16.1.0-alpha.267",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.9",
6
6
  "@angular/common": "^16.2.9",
@@ -12,7 +12,7 @@
12
12
  "@angular/platform-browser-dynamic": "^16.2.9",
13
13
  "@angular/material-moment-adapter": "^16.2.10",
14
14
  "@angular/router": "^16.2.9",
15
- "@coolon/pectin": "^5.0.0-alpha.134",
15
+ "@coolon/pectin": "^5.0.0-alpha.136",
16
16
  "fast-typescript-memoize": "^1.1.1",
17
17
  "lodash-es": "^4.17.21",
18
18
  "marked": "4.0.10",
@@ -46,4 +46,4 @@
46
46
  }
47
47
  },
48
48
  "sideEffects": false
49
- }
49
+ }