Skip to content

Commit

Permalink
📣
Browse files Browse the repository at this point in the history
  • Loading branch information
jpzwarte committed Jan 7, 2025
1 parent c202cbd commit 8ed2eb8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
19 changes: 5 additions & 14 deletions packages/components/data-source/src/fetch-data-source.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
DATA_SOURCE_DEFAULT_PAGE_SIZE,
DataSource,
type DataSourceOptions,
type DataSourceSort
} from './data-source.js';
import { DataSource, type DataSourceOptions, type DataSourceSort } from './data-source.js';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface FetchDataSourceCallbackOptions<T = any> {
Expand Down Expand Up @@ -56,9 +51,6 @@ export class FetchDataSource<T = any> extends DataSource<T> {
/** Object for keeping track of outstanding fetch calls. */
#pages: Record<number, Promise<void> | undefined> = {};

/** The page size when retrieving data. */
#pageSize = DATA_SOURCE_DEFAULT_PAGE_SIZE;

/** Proxy of the items array. */
#proxy: T[] = [];

Expand All @@ -75,21 +67,20 @@ export class FetchDataSource<T = any> extends DataSource<T> {
return this.#proxy;
}

override get pageSize(): number {
return this.#pageSize;
}

get size(): number {
return this.#size;
}

constructor(options: FetchDataSourceOptions<T>) {
super(options);

this.#pageSize = options.pageSize ?? DATA_SOURCE_DEFAULT_PAGE_SIZE;
this.#size = options.size ?? FetchDataSource.defaultSize;
this.fetchPage = options.fetchPage;

if (typeof options.pageSize === 'number') {
this.setPageSize(options.pageSize);
}

if (options.placeholder) {
this.placeholder = options.placeholder;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/grid/src/stories/pagination.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const DataSource2: Story = {
<div class="pagination">
<sl-paginator-status .dataSource=${ds}></sl-paginator-status>
<sl-paginator .dataSource=${ds}></sl-paginator>
<sl-paginator-page-size .dataSource=${ds} .pageSizes=${[10, 15, 20]}></sl-paginator-page-size>
<sl-paginator-page-size .dataSource=${ds} page-sizes="[5,10,15,20]"></sl-paginator-page-size>
</div>
`;
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/paginator/src/examples.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const Connected: Story = {
};

const onPageSizeChange = ({ detail: pageSize }: SlChangeEvent<number>): void => {
document.querySelector('sl-paginator')!.page = 0;
document.querySelector('sl-paginator')!.pageSize = pageSize;
document.querySelector('sl-paginator-status')!.pageSize = pageSize;
};
Expand Down

0 comments on commit 8ed2eb8

Please sign in to comment.