Skip to content

Commit a54ce8c

Browse files
committed
docs: ✏️ Fix broken links in docs, improved types documentations, better types constraints
This does not affect the behavior of the package. Closes: #128, #115
1 parent a804208 commit a54ce8c

File tree

13 files changed

+56
-35
lines changed

13 files changed

+56
-35
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ E2E testing over Travis realized using
1818

1919
[<img src="https://i1.wp.com/www.diogonunes.com/blog/wp-content/uploads/2016/07/browserstack-logo.png?resize=490%2C105" height="105.6" width="490.1" class="img-responsive"/>](https://www.browserstack.com/)
2020

21-
[:point_right: Browse the documentation :books:](https://gerkindev.github.io/vuejs-datatable/)
2221
[:point_right: Check out the tutorials :books:](https://gerkindev.github.io/vuejs-datatable/tutorials/index.html)
2322

23+
[:point_right: Browse the documentation :books:](https://gerkindev.github.io/vuejs-datatable/)
24+
2425
---
2526

2627
## Getting started
@@ -42,7 +43,7 @@ yarn add vuejs-datatable
4243

4344
> The [*ESM*](https://medium.com/webpack/the-state-of-javascript-modules-4636d1774358) build (**E**cma**S**cript **M**odule) implies that your target browsers supports *ESM* **OR** you use a bundler, like [*webpack*](https://webpack.js.org/), [*rollup.js*](https://rollupjs.org/guide/en) or [*Parcel*](https://parceljs.org/).
4445
45-
Import & register the [*DatatableFactory*](https://gerkindev.github.io/vuejs-datatable/DatatableFactory.html) in Vue:
46+
Import & register the [*DatatableFactory*](https://gerkindev.github.io/vuejs-datatable/classes/datatablefactory.html) in Vue:
4647

4748
```js
4849
import Vue from 'vue';
@@ -51,7 +52,7 @@ import { VuejsDatatableFactory } from 'vuejs-datatable';
5152
Vue.use( VuejsDatatableFactory );
5253
```
5354

54-
Check out [*how to customize table types*](#customize-the-datatable) to see some usage of the [*DatatableFactory*](https://gerkindev.github.io/vuejs-datatable/DatatableFactory.html) and the possible reasons not to use the default instance exported as `VuejsDatatableFactory`.
55+
Check out [*how to customize table types*](#customize-the-datatable) to see some usage of the [*DatatableFactory*](https://gerkindev.github.io/vuejs-datatable/classes/datatablefactory.html) and the possible reasons not to use the default instance exported as `VuejsDatatableFactory`.
5556

5657
#### Use the IIFE build
5758

@@ -68,7 +69,7 @@ In your HTML, load the *IIFE* build directly, if possible right before the closi
6869
</body>
6970
```
7071

71-
The *IIFE* build exposes the [*DatatableFactory*](https://gerkindev.github.io/vuejs-datatable/DatatableFactory.html) as the global `VuejsDatatable`. Check out [*how to customize table types*](#customize-the-datatable) to see some usage of the `DatatableFactory`.
72+
The *IIFE* build exposes the [*DatatableFactory*](https://gerkindev.github.io/vuejs-datatable/classes/datatablefactory.html) as the global `VuejsDatatable`. Check out [*how to customize table types*](https://gerkindev.github.io/vuejs-datatable/tutorials/customize/custom-theme/index.html) to see some usage of the `DatatableFactory`.
7273

7374
### Use the component
7475

@@ -116,7 +117,7 @@ new Vue({
116117

117118
### Customize the datatable
118119

119-
The DatatableFactory exposes several methods to allow you to add or modify other `datatable`-like components, with [custom styles](https://gerkindev.github.io/vuejs-datatable/tutorial-custom-theme.html) or [behavior](https://gerkindev.github.io/vuejs-datatable/tutorial-ajax-handler.html).
120+
The DatatableFactory exposes several methods to allow you to add or modify other `datatable`-like components, with [custom styles](https://gerkindev.github.io/vuejs-datatable/tutorials/customize/custom-theme/index.html) or [behavior](https://gerkindev.github.io/vuejs-datatable/tutorials/ajax/ajax-handler.html).
120121

121122
```js
122123
VuejsDatatable

src/classes/handlers/default-handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class DefaultHandler<TRow extends {}> implements IHandler<TRow, TRow[], T
4242
/**
4343
* Sort the given rows depending on a specific column & sort order.
4444
*
45-
* @param filteredData - Data outputed from [[Handler.filterHandler]].
45+
* @param filteredData - Data outputed from [[filterHandler]].
4646
* @param sortColumn - The column used for sorting.
4747
* @param sortDir - The direction of the sort.
4848
* @returns the sorted rows.
@@ -73,7 +73,7 @@ export class DefaultHandler<TRow extends {}> implements IHandler<TRow, TRow[], T
7373
/**
7474
* Split the rows list to display the requested page index.
7575
*
76-
* @param sortedData - Data outputed from [[Handler.sortHandler]].
76+
* @param sortedData - Data outputed from [[sortHandler]].
7777
* @param perPage - The total number of items per page.
7878
* @param pageNumber - The index of the page to display.
7979
* @returns the requested page's rows.

src/classes/handlers/i-handler.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export interface IDisplayHandlerResult<TRow extends {}> {
1717
}
1818

1919
export interface IDisplayHandlerParam<TRow extends {}, TSource, TFiltered, TSorted, TPaged> {
20-
/** The original [[Datatable.data]] property of the datatable. */
20+
/** The original [[VueDatatable.data]] property of the datatable. */
2121
source: TRow[] | TSource;
22-
/** The return value of [[Handler.filterHandler]]. */
22+
/** The return value of [[IHandler.filterHandler]]. */
2323
filtered: TRow[] | TFiltered;
24-
/** The return value of [[Handler.sortHandler]]. */
24+
/** The return value of [[IHandler.sortHandler]]. */
2525
sorted: TRow[] | TSorted;
26-
/** The return value of [[Handler.paginateHandler]]. */
26+
/** The return value of [[IHandler.paginateHandler]]. */
2727
paged: TRow[] | TPaged;
2828
}
2929

@@ -44,12 +44,12 @@ export type TDisplayHandler<TRow, TSource = TRow[], TFiltered = TRow[], TSorted
4444
* @tutorial ajax-handler
4545
*/
4646
export interface IHandler<TRow extends {}, TSource = TRow[], TFiltered = TRow[], TSorted = TRow[], TPaged = TRow[]> {
47-
/** Filter the provided rows, checking if at least a cell contains one of the specified filters. It supports promises. Defaults to [[Handler.defaultFilterHandler]]. */
47+
/** Filter the provided rows, checking if at least a cell contains one of the specified filters. It supports promises. Defaults to [[DefaultHandler.filterHandler]]. */
4848
filterHandler: TFilterHandler<TRow, TSource, TFiltered>;
49-
/** Sort the given rows depending on a specific column & sort order. It suports promises. Defaults to [[Handler.defaultSortHandler]]. */
49+
/** Sort the given rows depending on a specific column & sort order. It suports promises. Defaults to [[DefaultHandler.sortHandler]]. */
5050
sortHandler: TSortHandler<TRow, TFiltered, TSorted>;
51-
/** Split the rows list to display the requested page index. It supports promises. Defaults to [[Handler.defaultPaginateHandler]]. */
51+
/** Split the rows list to display the requested page index. It supports promises. Defaults to [[DefaultHandler.paginateHandler]]. */
5252
paginateHandler: TPaginateHandler<TRow, TSorted, TPaged>;
53-
/** Handler to post-process the paginated data, and determine which data to actually display. It supports promises. Defaults to [[Handler.defaultDisplayHandler]]. */
53+
/** Handler to post-process the paginated data, and determine which data to actually display. It supports promises. Defaults to [[DefaultHandler.displayHandler]]. */
5454
displayHandler: TDisplayHandler<TRow, TSource, TFiltered, TSorted, TPaged>;
5555
}

src/components/mixins/table-type-consumer-factory.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import { Component, Provide, Vue } from 'vue-property-decorator';
22

33
import { TableType } from '../../classes';
44

5+
/**
6+
* This interface describes a component from which the [[tableType]] can be accessed.
7+
*/
58
export interface ITableTypeConsumer extends Vue {
9+
/** Property containing the TableType used by this component. */
610
readonly tableType: TableType<any>;
711
}
812

13+
/** @ignore */
914
export const tableTypeConsumerFactory = ( tableType: TableType<any> ): typeof Vue & ( new() => ITableTypeConsumer ) => {
1015
/**
1116
* This mixin provide a [[TableType]] to inner components, which allow them to access [[Settings]] (through [[TableType.setting]])

src/components/vue-datatable-header/vue-datatable-header.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class VueDatatableHeader<TRow extends {}> extends Vue {
2626
@Prop( { type: Object, required: true } ) private readonly column!: Column<TRow>;
2727

2828
/**
29-
* The [[TableType]] instance provided through [[TableTypeConsumer.tableType]].
29+
* The [[TableType]] instance provided through [[ITableTypeConsumer.tableType]].
3030
*
3131
* @vue Inject `table-type`
3232
*/

src/components/vue-datatable-pager/vue-datatable-pager-button/vue-datatable-pager-button.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class VueDatatablePagerButton extends Vue {
3232
@Prop( { type: Number } ) private readonly value!: number | null;
3333

3434
/**
35-
* The [[TableType]] instance provided through [[TableTypeConsumer.tableType]].
35+
* The [[TableType]] instance provided through [[ITableTypeConsumer.tableType]].
3636
*
3737
* @vue Inject `table-type`
3838
*/

src/components/vue-datatable-pager/vue-datatable-pager.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, Prop, Vue } from 'vue-property-decorator';
22

33
import { EPagerType, namespaceEvent } from '../../utils';
4+
import { ITableTypeConsumer } from '../mixins/table-type-consumer-factory';
45
import { VueDatatable } from '../vue-datatable/vue-datatable';
56
import { TableType } from './../../classes';
67

@@ -16,7 +17,7 @@ import template from './vue-datatable-pager.html';
1617
PagerButton: VueDatatablePagerButton,
1718
},
1819
} )
19-
export class VueDatatablePager<TSub extends VueDatatablePager<TSub>> extends Vue {
20+
export class VueDatatablePager<TSub extends VueDatatablePager<TSub>> extends Vue implements ITableTypeConsumer {
2021
/**
2122
* The id of the associated [[VueDatatable]].
2223
*
@@ -32,7 +33,7 @@ export class VueDatatablePager<TSub extends VueDatatablePager<TSub>> extends Vue
3233
@Prop( { type: String, default: EPagerType.Long } ) public readonly type!: EPagerType;
3334

3435
/**
35-
* The number of pages visible on each side (only for [[EPageType.Abbreviated]])
36+
* The number of pages visible on each side (only for [[EPagerType.Abbreviated]])
3637
*
3738
* @vue-prop
3839
*/
@@ -79,7 +80,7 @@ export class VueDatatablePager<TSub extends VueDatatablePager<TSub>> extends Vue
7980
return this.tableType.setting( 'pager.icons.next' );
8081
}
8182

82-
protected readonly tableType!: TableType<any>;
83+
public readonly tableType!: TableType<any>;
8384
public get identifier() {
8485
return this.tableType.id + '-pager';
8586
}

src/components/vue-datatable/vue-datatable.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Column, IColumnDefinition } from '../../classes/column';
66
import { ESortDir, IDisplayHandlerParam, IDisplayHandlerResult } from '../../classes/handlers';
77
import { classValType, ensurePromise, mergeClassVals, namespaceEvent, TClassVal, TMaybePromise } from '../../utils';
88
import { VueDatatablePager } from '../vue-datatable-pager/vue-datatable-pager';
9+
import { ITableTypeConsumer } from '../mixins/table-type-consumer-factory';
910

1011
import template from './vue-datatable.html';
1112

@@ -25,15 +26,18 @@ export interface ITableContentParam<TRow extends {}> {
2526
rows: TRow[];
2627
totalRowCount: number;
2728
}
28-
export type TDataFn<TRow extends {}> = ( ( search: IDataFnParams<TRow> ) => ITableContentParam<TRow> );
29+
export type TDataFn<TRow extends {}> = ( ( search: IDataFnParams<TRow> ) => TMaybePromise<ITableContentParam<TRow>> );
2930
export type TColumnsDefinition<TRow extends {}> = Array<IColumnDefinition<TRow>>;
3031

32+
/**
33+
* Defines a pagination range. It orders to display the interval [`from`, `to`] in a list of a total of `of` items.
34+
*/
3135
interface IPageRange {
32-
/** Index of the first element of the page. 1-indexed */
36+
/** Index of the first element of the pagination to display. 1-indexed */
3337
from: number;
34-
/** Index of the last element of the page. 1-indexed */
38+
/** Index of the last element of the pagination to display. 1-indexed */
3539
to: number;
36-
/** The total number of items */
40+
/** The total number of items in the list. */
3741
of: number;
3842
}
3943

@@ -55,7 +59,7 @@ interface IPageRange {
5559
@Component( {
5660
...template,
5761
} )
58-
export class VueDatatable<TRow extends {}, TSub extends VueDatatable<TRow, TSub>> extends Vue {
62+
export class VueDatatable<TRow extends {}, TSub extends VueDatatable<TRow, TSub>> extends Vue implements ITableTypeConsumer {
5963
/**
6064
* The name of the datatable. It should be unique per page.
6165
*
@@ -117,7 +121,7 @@ export class VueDatatable<TRow extends {}, TSub extends VueDatatable<TRow, TSub>
117121
/** Total number of rows contained by this data table. */
118122
public totalRows = 0;
119123

120-
/** The total number of pages in the associated [[datatable]]. */
124+
/** The total number of pages in the datatable. */
121125
private get totalPages(): number | null {
122126
if ( this.totalRows <= 0 || this.perPage <= 0 ) {
123127
return 0;
@@ -159,7 +163,8 @@ export class VueDatatable<TRow extends {}, TSub extends VueDatatable<TRow, TSub>
159163
.join( ' ' );
160164
}
161165

162-
protected readonly tableType!: TableType<any>;
166+
public readonly tableType!: TableType<any>;
167+
163168
public get handler() {
164169
return this.tableType.handler;
165170
}
@@ -296,8 +301,8 @@ export class VueDatatable<TRow extends {}, TSub extends VueDatatable<TRow, TSub>
296301

297302
/**
298303
* Starts the watching of following properties: `filter`, `perPage`, `page`, `sortBy`, `sortDir`.
299-
* When a change is detected, the component runs [[datatable#processRows]].
300-
* Because the watch is immediate, [[datatable#processRows]] is run immediately when this method is called.
304+
* When a change is detected, the component runs [[processRows]].
305+
* Because the watch is immediate, [[processRows]] is run immediately when this method is called.
301306
*
302307
* @see datatable#processRows
303308
* @see https://vuejs.org/v2/api/#vm-watch

src/utils.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
export type TMaybePromise<T> = T | Promise<T>;
33

4+
/** @ignore */
45
const isPromise = <T>( value: any ): value is Promise<T> => value && typeof value.then === 'function';
6+
/** @ignore */
57
export const ensurePromise = <T>( value: TMaybePromise<T> ): Promise<T> => {
68
if ( isPromise( value ) ) {
79
return value;
@@ -12,7 +14,9 @@ export const ensurePromise = <T>( value: TMaybePromise<T> ): Promise<T> => {
1214

1315
export interface IDict<T> {[key: string]: T; }
1416
export type TClassVal = string | string[] | IDict<boolean>;
17+
/** @ignore */
1518
export const classValType: any[] = [ String, Array, Object ];
19+
/** @ignore */
1620
export const mergeClassVals = ( mainObj: TClassVal, ...objs: Array<TClassVal | null | undefined> ): string[] =>
1721
Object.entries(
1822
Object.assign(
@@ -34,7 +38,9 @@ const canonicalClassVals = ( classVal: TClassVal | null | undefined ): IDict<boo
3438
return classVal || {};
3539
};
3640

41+
/** @ignore */
3742
export const namespace = 'vue-datatable';
43+
/** @ignore */
3844
export const namespaceEvent = ( event: string ) => `${namespace}::${event}`;
3945

4046
/**
@@ -57,6 +63,7 @@ export const enum EPagerType {
5763
Long = 'long',
5864
}
5965

66+
/** @ignore */
6067
export const valueToString = ( val: any ): string => {
6168
if ( val === null || typeof val === 'undefined' ) {
6269
return '';

tutorials/src/bundlers/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Vue = require( 'vue' );
2929
import Vue from 'vue';
3030
```
3131

32-
Instead of targeting the right build in your code, configure your bundler to alias the `vue` module as your desired `vue` dist file. Check below for [how to alias `vue`](#alias-the-vue-module).
32+
Instead of targeting the right build in your code, configure your bundler to alias the `vue` module as your desired `vue` dist file. Check below for [how to alias `vue`](#alias-the-codevuecode-module).
3333

3434
#### `You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.`
3535

tutorials/src/custom-template/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This plugin is built to be as versatile as possible, and allow you to inject you
44

55
### Datatable
66

7-
> See the [Datatable API doc](../classes/vuedatatable.html)
7+
> See the [Datatable API doc](../../classes/vuedatatable.html)
88
99
#### `footer` slot
1010

@@ -15,8 +15,8 @@ This footer is displayed at the bottom of your data table.
1515
| Prop | Type | Description |
1616
|------|--------|-------------|
1717
| `rows` | `TRow[]` | The list of rows currently displayed by the table. It only contains the current page. |
18-
| `columns` | [`Column[]`](../classes/column.html) | The columns of the table |
19-
| `pagination` | [`IPageRange`](../interfaces/ipagerange.html) | An object describing the current pagination status |
18+
| `columns` | [`Column[]`](../../classes/column.html) | The columns of the table |
19+
| `pagination` | [`IPageRange`](../../interfaces/ipagerange.html) | An object describing the current pagination status |
2020

2121
##### Example
2222

@@ -40,7 +40,7 @@ This slot is used to render each rows. It completely overrides the default row r
4040
|------|--------|-------------|
4141
| `row` | `TRow` | The current row that it is appending to the table. |
4242
| `index` | `number` | The current index of the row in the displayed page. |
43-
| `columns` | `Column[]` | The [columns](../classes/column.html) of the table |
43+
| `columns` | `Column[]` | The [columns](../../classes/column.html) of the table |
4444

4545
##### Example
4646

tutorials/src/custom-theme/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Introduction
22

3-
You can customize the appearance of your table by merging a [Settings Props object](../interfaces/isettingsproperties.html) in your [Table Type](../classes/tabletype.html), by using [TableType.mergeSettings](../classes/tabletype.html#mergesettings).
3+
You can customize the appearance of your table by merging a [Settings Props object](../../../interfaces/isettingsproperties.html) in your [Table Type](../../../classes/tabletype.html), by using [TableType.mergeSettings](../../../classes/tabletype.html#mergesettings).
44

55
<div class="alert alert-info">
66
<i class="fas fa-info-circle"></i>

typedoc.json

+2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"readme": "README.md",
55
"exclude": [
66
"./**/*.spec.*",
7+
"./**/__mocks__/**/*",
78
"./dist/**/*",
89
"./ci/**/*",
910
"./docs/**/*",
1011
"./tutorials/**/*"
1112
],
13+
"listInvalidSymbolLinks": true,
1214

1315
"tutorials-map": "./tutorials/tutorials.json",
1416
"tutorials-directory": "./tutorials/dist"

0 commit comments

Comments
 (0)