Skip to content

Commit

Permalink
Merge pull request #7 from zazuko/dt-config-type
Browse files Browse the repository at this point in the history
Use `Config` type for DataTables configuration
  • Loading branch information
ludovicm67 authored Apr 29, 2024
2 parents 92a8fda + cbf8286 commit 2bebd1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-rats-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/yasr": patch
---

Use the right type for DataTables configuration
8 changes: 4 additions & 4 deletions packages/yasr/src/plugins/table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import * as faTableIcon from "@fortawesome/free-solid-svg-icons/faTable";
import { DeepReadonly } from "ts-essentials";
import { cloneDeep } from "lodash-es";
import sanitize from "../../helpers/sanitize";
import type { Api, ConfigColumns, CellMetaSettings, InternalSettings } from "datatables.net";
import type { Api, ConfigColumns, CellMetaSettings, Config } from "datatables.net";

const ColumnResizer = require("column-resizer");
const DEFAULT_PAGE_SIZE = 50;

export interface PluginConfig {
openIriInNewWindow: boolean;
tableConfig: InternalSettings;
tableConfig: Config;
}

export interface PersistentConfig {
Expand Down Expand Up @@ -203,8 +203,8 @@ export default class Table implements Plugin<PluginConfig> {
}
this.yasr.resultsEl.appendChild(this.tableEl);
// reset some default config properties as they couldn't be initialized beforehand
const dtConfig: InternalSettings = {
...(cloneDeep(this.config.tableConfig) as unknown as InternalSettings),
const dtConfig: Config = {
...(cloneDeep(this.config.tableConfig) as unknown as Config),
pageLength: persistentConfig?.pageSize ? persistentConfig.pageSize : DEFAULT_PAGE_SIZE,
data: rows,
columns: columns,
Expand Down

0 comments on commit 2bebd1c

Please sign in to comment.