Skip to content

Commit 77bc181

Browse files
authored
Merge pull request #27 from Mindsers/develop
v1.3.0
2 parents c1bf9cd + 6d35cc0 commit 77bc181

File tree

7 files changed

+76
-13
lines changed

7 files changed

+76
-13
lines changed

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ Check the [demo](https://mindsers.github.io/nativetable/) page.
1616

1717
### Package manager installation
1818

19-
Nativetable is available as a client side npm dependency. To install Nativetable with npm :
19+
Nativetable is available as a client side npm dependency. To install Nativetable with npm or yarn:
2020

21-
```bash
21+
```sh
2222
npm install nativetable --save
23+
yarn add nativetable
2324
```
2425

25-
Nativetable library is ready to be import on your project : `./node_modules/nativetable/dist/nativetable.min.js`
26+
Nativetable library is ready. Build file is available at this path: `./node_modules/nativetable/dist/nativetable.min.js`
2627

2728
### Manual installation
2829
You can build your own Nativetable with this project.
@@ -39,15 +40,40 @@ npm install
3940
npm run build
4041
```
4142

42-
Nativetable library is ready to be import on your project : `./dist/nativetable.min.js`
43+
Nativetable library is ready to be import on your project: `./dist/nativetable.min.js`
4344

4445
## Usage
4546

47+
- If your are using tools for importing / bundling dependencies (umd format) for you, you can import Nativetable this way:
48+
49+
```js
50+
const Nativetable = require('nativetable').Nativetable // classic
51+
52+
const { Nativetable } = require('nativetable') // es6 destructuring
53+
54+
import { Nativetable } from 'nativetable' // es6 import
55+
56+
// ...
57+
58+
const nt = new Nativetable('tableid')
59+
```
60+
61+
- If you decide to import Nativetable with simple `<script/>` tag, all Nativetable classes is available in `nativetable` umd module.
62+
4663
Add a script tag on your page to call Nativatable.
4764
```html
4865
<script src="nativetable.min.js"></script>
4966
```
5067

68+
And in `*.js|ts` file:
69+
```js
70+
const Nativetable = nativetable.Nativetable // get Nativetable class from nativetable module
71+
72+
// ...
73+
74+
const nt = new Nativetable('tableid')
75+
```
76+
5177
### Sample code
5278

5379
```js

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "nativetable",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Create and use dynamics HTML tables with native JS",
55
"repository": "https://github.com/Mindsers/nativetable",
66
"main": "dist/nativetable.min.js",
7+
"types": "dist/nativetable.d.ts",
78
"scripts": {
89
"build:js": "rollup -c",
910
"build:clean": "rm -rf dist",
11+
"build:types": "cp src/nativetable/nativetable.d.ts dist/nativetable.d.ts",
1012
"build:dev": "NODE_ENV=development npm run build:clean && npm run build:js -- --sourcemap -w",
11-
"build:prod": "NODE_ENV=production npm run build:clean && npm run build:js",
13+
"build:prod": "NODE_ENV=production npm run build:clean && npm run build:js && npm run build:types",
1214
"build": "npm run build:prod",
1315
"test:coveralls": "npm run test:coverage && nyc report --reporter=text-lcov | coveralls",
1416
"test:coverage": "NODE_ENV=test nyc mocha",
@@ -21,8 +23,8 @@
2123
"table",
2224
"filter"
2325
],
24-
"author": "",
25-
"license": "ISC",
26+
"author": "Nathanael CHERRIER <https://github.com/Mindsers>",
27+
"license": "MIT",
2628
"devDependencies": {
2729
"babel-plugin-istanbul": "^2.0.3",
2830
"babel-preset-es2015": "^6.16.0",

rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export default {
2525
targets: [
2626
{
2727
dest: pkg.main,
28-
moduleName: 'Nativetable',
29-
format: 'iife'
28+
moduleName: 'nativetable',
29+
format: 'umd'
3030
}
3131
]
3232
}

src/demo/scripts/demo.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/* global Nativetable */
1+
/// <reference path="../../nativetable/nativetable.d.ts"/>
2+
/* global nativetable */
3+
4+
const Nativetable = nativetable.Nativetable
25

36
'use strict'
47

src/nativetable/nativetable.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Type definitions for Nativetable v1.2.0
2+
// Project: https://github.com/Mindsers/nativetable
3+
// Definitions by: Nathanael CHERRIER <https://github.com/Mindsers>
4+
5+
declare module 'nativetable' {
6+
export class Nativetable {
7+
constructor(id: string, options?: {
8+
sources?: any[],
9+
filters?: {
10+
$and?: any,
11+
$or?: any
12+
},
13+
columns?: string[],
14+
pagination?: {
15+
maxLength?: number
16+
},
17+
sorting?: boolean
18+
});
19+
20+
sources: any[];
21+
filtered: any[];
22+
paginated: any[];
23+
sorted: any[];
24+
25+
columns: string[];
26+
pagination: { currentPage: number, maxLength: number};
27+
filters: { $and?: any, $or?: any };
28+
29+
reload(row: any[]): void;
30+
draw(): void;
31+
}
32+
}

src/nativetable/nativetable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default class Nativetable {
1+
export class Nativetable {
22

33
/**
44
* Data sources

test/nativetable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import chai from 'chai'
44
import spies from 'chai-spies'
5-
import Nativetable from '../src/nativetable/nativetable'
5+
import { Nativetable } from '../src/nativetable/nativetable'
66

77
describe('Nativetable', () => {
88
let nt

0 commit comments

Comments
 (0)