# @pqsdev/ngx-mat-extras

> Adds extra functionality to angular material. ALPHA VERSION DO NOT USE

Latest version **15.2.2-alpha** (published 2023-03-14) · 0 weekly downloads

## Install

```sh
npm install @pqsdev/ngx-mat-extras
pnpm add @pqsdev/ngx-mat-extras
yarn add @pqsdev/ngx-mat-extras
bun add @pqsdev/ngx-mat-extras
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 15.2.2-alpha |
| Published | 2023-03-14 |
| First published | 2022-04-30 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 558.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | yuudj, pqsar |
| Keywords | angular, angular-material, mat-select, infinite-scroll, datasoruce, odata, filtrable, scroll, select, material, directive |

## Links

- npm: https://www.npmjs.com/package/@pqsdev/ngx-mat-extras
- Repository: https://github.com/pqsdev/pqs-mat-extras
- Homepage: https://github.com/pqsdev/pqs-mat-extras#readme
- Issues: https://github.com/pqsdev/pqs-mat-extras/issues
- npm.io page: https://npm.io/package/@pqsdev/ngx-mat-extras

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Recent versions

- 15.2.2-alpha (latest) — 2023-03-14
- 14.2.13-alpha (v14-lts) — 2023-03-08
- 13.0.8-alpha (v13-lts) — 2022-06-15
- 13.0.0-alpha (alpha.0) — 2022-04-30
- 15.2.1-alpha — 2023-03-08
- 15.0.4-alpha — 2022-12-28
- 114.2.12-alpha — 2022-12-27
- 14.0.5-alpha — 2022-07-05
- 14.0.4-alpha — 2022-07-04
- 13.0.7-alpha — 2022-05-30
- 13.0.6-alpha — 2022-05-24
- 13.0.5-alpha — 2022-05-23
- 13.0.4-alpha — 2022-05-13
- 13.0.3-alpha — 2022-05-05
- 13.0.2-alpha — 2022-05-04
- … 1 more at https://npm.io/package/@pqsdev/ngx-mat-extras/versions

## README

# PQS ANGULAR MATERIAL EXTRAS

Collection of components that adds extra functionality to [angular material](https://material.angular.io)

## Installation

```bash
npm i @pqsdev/ngx-mat-extras
```

## Coding

```bash
## clone this repo
git clone https://github.com/pqsdev/pqs-mat-extras.git
cd ./pqs-mat-extras
## install dependencies
npm i
## vscode debug is configured also
ng serve #louches the example proyect
```

## ODATA - DATASOURCE

Implementation of [CDK's DataSource](https://material.angular.io/cdk/collections/api#DataSource) that can work with ODATA version 4. It supports sorting with `mat-sort` and pagination with `mat-paginator` as well as per column filtering. Based on [Marcin Suty's odata-data-source](https://github.com/relair/odata-data-source)

## MAT-SELECT-FILTER

Child component of [angular material select](https://material.angular.io/components/select) that allows to filter from a data source.

![Datasoruce](img/mat-select-filter-datasource.svg)

### MatSelectFilterDataSource

Abstract data data source for `mat-select-filter`. Implement it for custom data source

| Property               | Description                                                          | Type                          | Default     |
| ---------------------- | -------------------------------------------------------------------- | ----------------------------- | ----------- |
| `txtFilter`            | Gets/sets the text filter value                                      | `string`                      | `''`        |
| `idFilter`             | Gets/ sets the id text filter value (used to the `selectedValue`)    | `any`                         | `undefined` |
| `dataSubject`          | Emits value every time the filtered data changes                     | `BehaviorSubject<T[]>`        | `[]`        |
| `loading`              | Emits `true` when loading `false` when finished or error             | `Observable<boolean>`         |             |
| `errors`               | Emits value if there is an error                                     | `Observable<any>`             |             |
| `selectedValueChanged` | Emits a value with the object associated with the selected key value | `Observable< T \| undefined>` |             |

`setSelectedData`abstract method must be overrides in the implementations. The main goals is to emit a value with `selectedDataSubject$`

#### Selected Key != Selected Value

Selected Key is a primitive value of the key property  (`string`, `number`, etc.) . The selected Value is the object which complies with the following `object[<<key-porperty>>] == keyValue`, in most cases.

Example SelectedKey = 32 Selected value = `{ProductID: 32, ProductName: 'Noodles' }`

### MatSelectFilterODataSource

Abstract ODATA data source for `mat-select-filter` . Implement it for custom filtering. See examples for interaction with `mat-paginator` and `matSelectInfiniteScroll`



| Properties    | Description                                                                                 | Type                                  | Default |
| ------------- | ------------------------------------------------------------------------------------------- | ------------------------------------- | ------- |
| `url`         | Resource location URL                                                                       | `string`                              | `''`    |
| `isEnabled`   | When `false` the data source will not trigger new `HTTP GET` to the resource URL            | `boolean`                             | `true`  |
| `filters`     | Aditional filters, the interface `IODataFilter` allows to implement custom logic in filters | `IODataFilter \| null`                | `null`  |
| `page`        | Incremental page number, ignored if `paginator` is set.                                     | `number`                              | `0`     |
| `pageSize`    | Incremental page size, ignored if `paginator` is set .                                      | `number`                              | `0`     |
| `paginator`   | Paginator (reused from `@angular/material`) for paging inside the `mat-select`              | `MatTableDataSourcePaginator \| null` | null    |
| `count$`      | Total item being listed  (Useful for incremental paging)                                    | `Subject<number>`                     |         |
| `countTotal$` | Total count of items  (Useful for incremental paging)                                       | `Subject<number>`                     |         |
| `completed$`  | No more item to list (Useful for incremental paging)                                        | `BehaviorSubject<boolean>`            | `false` |

(**)**NESTED OBJECTS PROPERTIES ARE NOT SUPPORTED



### MatSelectFilterFastODataSource

Simple implementation of `MatSelectFilterODataSource`.

Constructor

| Parameter        | Description                                                          | Type                   | Default |
| ---------------- | -------------------------------------------------------------------- | ---------------------- | ------- |
| `filterProperty` | The data source will filter the input text with this property.  (**) | `string` \| `string[]` |         |
| `keyProperty`    | Used to set the value of the control.                                | `string`               |         |

(**)**NESTED OBJECTS PROPERTIES ARE NOT SUPPORTED**

### MatSelectFilterObservableDataSource

implementation of `MatSelectFilterDataSource` that's allows a `Observable` data source.

Constructor

| Parameter        | Description                                                          | Type                     | Default |
| ---------------- | -------------------------------------------------------------------- | ------------------------ | ------- |
| `source`         | Observable source                                                    | `Observable<T[]> \| T[]` |         |
| `filterProperty` | The data source will filter the input text with this property. (***) | `string`                 |         |
| `keyProperty`    | Used to set the value of the control.                                | `string`                 |         |

 (***)Nested properties are allowed see https://lodash.com/docs/4.17.15#get

## MAT-SELECT INTINITE SCROLL

Adds missing infinite scroll functionality for the [angular material select component](https://material.angular.io/components/select).

Based on [HaidarZ/ng-mat-select-infinite-scroll](https://github.com/HaidarZ/ng-mat-select-infinite-scroll)

### Inputs

| Property       | Description                                                                                                                                                                                                                                                                                                              | Type      | Default |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------- | ------- |
| `complete`     | If `true`, the `infiniteScroll` output will no longer be triggered                                                                                                                                                                                                                                                       | `boolean` | `false` |
| `threshold`    | The threshold distance from the bottom of the options list to call the `infiniteScroll` output event when scrolled. The threshold value can be either in percent, or in pixels. For example, use the value of `10%` for the `infiniteScroll` output event to get called when the user has needs 10% to reach the bottom. | `string`  | `'15%'` |
| `debounceTime` | The threshold time before firing the `infiniteScroll` event                                                                                                                                                                                                                                                              | `number`  | `150`   |

### Outputs

| Property         | Description                                                                     | Type                 |
| ---------------- | ------------------------------------------------------------------------------- | -------------------- |
| `infiniteScroll` | Emitted when the scroller inside the `mat-select` reaches the required distance | `EventEmitter<void>` |

---
_Source: https://npm.io/package/@pqsdev/ngx-mat-extras · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
