Skip to content

Commit

Permalink
Merge pull request #14 from krjakbrjak/VNI-docs
Browse files Browse the repository at this point in the history
Docs
  • Loading branch information
krjakbrjak authored Dec 3, 2023
2 parents 8615920 + 6c93117 commit 0348e71
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 810 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ jobs:
- run: yarn install
- run: yarn build --if-present -- --env production
- run: yarn test
- run: yarn jsdoc:gen
19 changes: 0 additions & 19 deletions jsdoc.conf.json

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"homepage": "https://github.com/krjakbrjak/virtualtable#readme",
"main": "dist/index.js",
"dependencies": {
"@types/react-bootstrap": "^0.32.35",
"bootstrap": "^5.3.2",
"normalize.css": "^8.0.1",
"prop-types": "^15.8.1",
Expand All @@ -43,7 +42,6 @@
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"babel-loader": "^9.1.3",
"better-docs": "^2.7.2",
"css-loader": "^6.8.1",
"eslint": "^8.53.0",
"eslint-config-airbnb": "^19.0.4",
Expand All @@ -53,7 +51,6 @@
"eslint-webpack-plugin": "^4.0.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jsdoc": "^4.0.2",
"sinon": "^17.0.1",
"style-loader": "^3.3.3",
"ts-jest": "^29.1.1",
Expand Down
16 changes: 10 additions & 6 deletions src/VirtualTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,23 @@ function reducer<Type>(state: State<Type>, action: Action<Type>): State<Type> {
*/

/**
* @description VirtualTable component.
*
* Displays a large set of data (with a low memory usage).
*
* @param {VirtualTable.Props} props Properties
* @component
* Represent the rectangular.
*/
interface Rect {
x: number;
y: number;
height: number;
width: number;
}

/**
* @description VirtualTable component.
*
* Displays a large set of data (with a low memory usage).
*
* @param {VirtualTable.Props} props Properties
* @component
*/
export default function VirtualTable<Type>({ height, renderer, fetcher, style }: Args<Type>): JSX.Element {
const ref = useRef(null);
const [collection, setCollection] = useState<LazyPaginatedCollection<Type>>(new LazyPaginatedCollection<Type>(1, fetcher));
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/LazyPaginatedCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class LazyPaginatedCollection<Type> {
* Constructs a new collection.
*
* @param {number} pageSize Page size
* @param {LazyPaginatedCollection.retrieve} retrieve A callback to fetch the data
* @param {Fetcher<Type>} retrieve A callback to fetch the data
*/
constructor(pageSize: number, retrieve: Fetcher<Type>) {
this.#pageOffsets = {};
Expand Down
10 changes: 7 additions & 3 deletions src/helpers/collections.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/**
* Represent a page.
* @typedef {Object} Slice
* @property {number} offset An offset (the index of the first item in the slice)
* @property {Array.Object} items Items
*/

interface Page<Type> {
/**
* Page items
*/
items: Array<Type>;
/**
* An offset (the index of the first item in the slice)
*/
offset: number;
}

Expand Down
33 changes: 33 additions & 0 deletions src/helpers/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
/**
* Represents the result of the fetch.
*/
export interface Result<Type> {
/**
* The starting index to fetch the items.
*/
from: number;
/**
* An array of fetched items.
*/
items: Array<Type>;
/**
* Total number of items that can be retrieved.
*/
totalCount: number;
}

/**
* A callback function to fetch the items.
*
* @typedef {Function} Fetcher
* @template Type - The type of the element to be returned from the function.
* @param {number} index - The strating index to fetch items.
* @param {number} count - The number of items to fetch.
* @returns {Promise<Result<Type>>} - A promise holding the result of the fetch.
*/
export type Fetcher<Type> = (index: number, count: number) => Promise<Result<Type>>;

/**
* Represents the style of the item in the table.
*/
export interface Style {
/**
* Class that will be added to the item when it is hovered.
*/
hover: string;
/**
* Class that will be added to the item when it is selected.
*/
select: string;
/**
* Class that will be added to each item.
*/
item: string;
}
Loading

0 comments on commit 0348e71

Please sign in to comment.