Skip to content

Commit

Permalink
Merge pull request #176 from ryanylee/main
Browse files Browse the repository at this point in the history
Types now working with SvelteKit 2
  • Loading branch information
bryanmylee committed Jan 2, 2024
2 parents c60dd00 + bb96fcf commit 626cccc
Show file tree
Hide file tree
Showing 64 changed files with 304 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/build
/.svelte-kit
/package
/dist
.env
.env.*
!.env.example
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/build
/.svelte-kit
/package
/dist
.env
.env.*
!.env.example
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/build
/.svelte-kit
/package
/dist
.env
.env.*
!.env.example
Expand Down
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
/build
/.svelte-kit
/package
/dist
.env
.env.*
!.env.example
2 changes: 1 addition & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ module.exports = {
moduleNameMapper: {
'^\\$lib/(.*)$': '<rootDir>/src/lib/$1',
},
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/package'],
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/dist'],
};
69 changes: 59 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@babel/preset-env": "^7.17.10",
"@sveltejs/adapter-auto": "^1.0.0",
"@sveltejs/kit": "^1.0.1",
"@sveltejs/package": "^1.0.1",
"@sveltejs/package": "^2.2.3",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/svelte": "^3.1.1",
"@types/faker": "5",
Expand Down Expand Up @@ -76,7 +76,22 @@
"peerDependencies": {
"svelte": "^3 || ^4"
},
"files": [
"dist",
"!dist/**/*.test.*"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"svelte": "./dist/index.js",
"default": "./dist/index.js"
},
"./plugins": {
"types": "./dist/plugins/index.d.ts",
"svelte": "./dist/plugins/index.js",
"default": "./dist/plugins/index.js"
}
},
"type": "module",
"svelte": "./index.js",
"types": "./lib/index.d.ts"
"svelte": "./dist/index.js"
}
8 changes: 4 additions & 4 deletions src/lib/bodyCells.DataBodyCell.render.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DataBodyCell } from './bodyCells';
import { DataBodyRow } from './bodyRows';
import { DataColumn } from './columns';
import type { TableState } from './createViewModel';
import { DataBodyCell } from './bodyCells.js';
import { DataBodyRow } from './bodyRows.js';
import { DataColumn } from './columns.js';
import type { TableState } from './createViewModel.js';

interface User {
firstName: string;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/bodyCells.DisplayBodyCell.render.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DisplayBodyCell } from './bodyCells';
import { DataBodyRow } from './bodyRows';
import { DisplayColumn } from './columns';
import type { TableState } from './createViewModel';
import { DisplayBodyCell } from './bodyCells.js';
import { DataBodyRow } from './bodyRows.js';
import { DisplayColumn } from './columns.js';
import type { TableState } from './createViewModel.js';

interface User {
firstName: string;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bodyCells.HeaderCell.render.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TableState } from './createViewModel';
import { HeaderCell } from './headerCells';
import type { TableState } from './createViewModel.js';
import { HeaderCell } from './headerCells.js';

interface User {
firstName: string;
Expand Down
12 changes: 6 additions & 6 deletions src/lib/bodyCells.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { derived, type Readable } from 'svelte/store';
import type { BodyRow } from './bodyRows';
import type { DataColumn, DisplayColumn, FlatColumn } from './columns';
import { TableComponent } from './tableComponent';
import type { DataLabel, DisplayLabel } from './types/Label';
import type { AnyPlugins } from './types/TablePlugin';
import type { RenderConfig } from 'svelte-render';
import type { BodyRow } from './bodyRows.js';
import type { DataColumn, DisplayColumn, FlatColumn } from './columns.js';
import { TableComponent } from './tableComponent.js';
import type { DataLabel, DisplayLabel } from './types/Label.js';
import type { AnyPlugins } from './types/TablePlugin.js';
import type { RenderConfig } from 'svelte-render/createRender';

export type BodyCellInit<Item, Plugins extends AnyPlugins = AnyPlugins> = {
id: string;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/bodyRows.getBodyRows.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writable } from 'svelte/store';
import { DataBodyCell, DisplayBodyCell } from './bodyCells';
import { BodyRow, DataBodyRow, getBodyRows } from './bodyRows';
import { createTable } from './createTable';
import { DataBodyCell, DisplayBodyCell } from './bodyCells.js';
import { BodyRow, DataBodyRow, getBodyRows } from './bodyRows.js';
import { createTable } from './createTable.js';

interface User {
firstName: string;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bodyRows.getColumnedBodyRows.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writable } from 'svelte/store';
import { BodyRow, getBodyRows, getColumnedBodyRows } from './bodyRows';
import { createTable } from './createTable';
import { BodyRow, getBodyRows, getColumnedBodyRows } from './bodyRows.js';
import { createTable } from './createTable.js';

interface User {
firstName: string;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/bodyRows.getSubRows.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writable } from 'svelte/store';
import { DataBodyCell, DisplayBodyCell } from './bodyCells';
import { BodyRow, DataBodyRow, getBodyRows, getColumnedBodyRows, getSubRows } from './bodyRows';
import { createTable } from './createTable';
import { DataBodyCell, DisplayBodyCell } from './bodyCells.js';
import { BodyRow, DataBodyRow, getBodyRows, getColumnedBodyRows, getSubRows } from './bodyRows.js';
import { createTable } from './createTable.js';

interface User {
firstName: string;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/bodyRows.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { derived, type Readable } from 'svelte/store';
import { BodyCell, DataBodyCell, DisplayBodyCell } from './bodyCells';
import type { DataColumn, DisplayColumn, FlatColumn } from './columns';
import { TableComponent } from './tableComponent';
import type { AnyPlugins } from './types/TablePlugin';
import { nonUndefined } from './utils/filter';
import { BodyCell, DataBodyCell, DisplayBodyCell } from './bodyCells.js';
import type { DataColumn, DisplayColumn, FlatColumn } from './columns.js';
import { TableComponent } from './tableComponent.js';
import type { AnyPlugins } from './types/TablePlugin.js';
import { nonUndefined } from './utils/filter.js';

export type BodyRowInit<Item, Plugins extends AnyPlugins = AnyPlugins> = {
id: string;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/columns.getDataColumns.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writable } from 'svelte/store';
import { DataColumn, getFlatColumns } from './columns';
import { createTable } from './createTable';
import { DataColumn, getFlatColumns } from './columns.js';
import { createTable } from './createTable.js';

interface User {
firstName: string;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/columns.newDataColumn.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataColumn } from './columns';
import { DataColumn } from './columns.js';

interface User {
firstName: string;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/columns.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { DisplayBodyCell } from './bodyCells';
import type { TableState } from './createViewModel';
import type { DisplayLabel, HeaderLabel } from './types/Label';
import type { DataLabel } from './types/Label';
import type { AnyPlugins, PluginColumnConfigs } from './types/TablePlugin';
import type { DisplayBodyCell } from './bodyCells.js';
import type { TableState } from './createViewModel.js';
import type { DisplayLabel, HeaderLabel } from './types/Label.js';
import type { DataLabel } from './types/Label.js';
import type { AnyPlugins, PluginColumnConfigs } from './types/TablePlugin.js';

export interface ColumnInit<Item, Plugins extends AnyPlugins = AnyPlugins> {
header: HeaderLabel<Item, Plugins>;
Expand Down
22 changes: 11 additions & 11 deletions src/lib/createTable.createColumns.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writable } from 'svelte/store';
import { createTable } from './createTable';
import { createTable } from './createTable.js';

interface User {
firstName: string;
Expand Down Expand Up @@ -49,35 +49,35 @@ it('using headers as id, passes if no duplicate headers', () => {
table.createColumns([
table.column({
header: 'First Name',
accessor: (item) => item.firstName
accessor: (item) => item.firstName,
}),
table.column({
header: 'Last Name',
accessor: (item) => item.lastName
accessor: (item) => item.lastName,
}),
table.display({
header: 'Actions',
cell: () => ''
cell: () => '',
}),
])
}).not.toThrow()
]);
}).not.toThrow();
});

it('using headers as id, throws if two columns have the same headers', () => {
expect(() => {
table.createColumns([
table.column({
header: 'First Name',
accessor: (item) => item.firstName
accessor: (item) => item.firstName,
}),
table.column({
header: 'Last Name',
accessor: (item) => item.lastName
accessor: (item) => item.lastName,
}),
table.display({
header: 'First Name',
cell: () => ''
cell: () => '',
}),
])
}).toThrowError('Duplicate column ids not allowed: "First Name"')
]);
}).toThrowError('Duplicate column ids not allowed: "First Name"');
});
10 changes: 5 additions & 5 deletions src/lib/createTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {
type DataColumnInitKey,
type DisplayColumnInit,
type GroupColumnInit,
} from './columns';
import type { AnyPlugins } from './types/TablePlugin';
import type { ReadOrWritable } from './utils/store';
import { getDuplicates } from './utils/array';
} from './columns.js';
import type { AnyPlugins } from './types/TablePlugin.js';
import type { ReadOrWritable } from './utils/store.js';
import { getDuplicates } from './utils/array.js';
import {
createViewModel,
type CreateViewModelOptions,
type TableViewModel,
} from './createViewModel';
} from './createViewModel.js';

export class Table<Item, Plugins extends AnyPlugins = AnyPlugins> {
data: ReadOrWritable<Item[]>;
Expand Down
Loading

0 comments on commit 626cccc

Please sign in to comment.