diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml
index 85918b8..2df24e5 100644
--- a/.github/workflows/node.js.yml
+++ b/.github/workflows/node.js.yml
@@ -25,3 +25,7 @@ jobs:
- run: yarn lint
- run: yarn build
- run: yarn test
+ - name: Upload coverage reports to Codecov
+ uses: codecov/codecov-action@v3
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index f2e4996..ebf7ef3 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -1,4 +1,4 @@
-name: Main
+name: Create release
on:
push:
@@ -18,7 +18,5 @@ jobs:
with:
files: |
dist/merge-cells.js
- dist/merge-cells.min.js
- dist/merge-cells.min.js.map
- dist/merge-cells.ts
- dist/merge-cells.ts.map
+ dist/merge-cells.d.ts
+ dist/merge-cells.d.ts.map
diff --git a/README.md b/README.md
index 0665c3e..897a957 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,13 @@
# merge-cells [![Node.js CI](https://github.com/piglovesyou/merge-cells/actions/workflows/node.js.yml/badge.svg)](https://github.com/piglovesyou/merge-cells/actions/workflows/node.js.yml)
-Provide JavaScript/TypeScript functions to help you merge cells in a table.
+Provide JavaScript/TypeScript functions to help you merge cells of an HTML `GROUP BY`-like table.
👉 Example: https://piglovesyou.github.io/merge-cells/
## Usage
+Example usage in a browser:
+
```html
```
-## `mergeCells`
+Example usage in Node.js:
-Apply the `rowspan` calculated by `calcRowspanFromObjectArray` to a table. Signature:
+```shell
+npm install merge-cells
+```
```ts
-function mergeCells(tableEl: HTMLTableElement, rowspan: Record): void
+import { calcRowspanFromObjectArray } from 'merge-cells'
+
+calcRowspanFromObjectArray(
+ [
+ { c_1: 'a', c_2: 'a' },
+ { c_1: 'a', c_2: 'a' },
+ { c_1: 'b', c_2: 'a' },
+ ],
+ ['c_1', 'c_2'],
+)
+// returns: [
+// { c_1: 2, c_2: 2 },
+// { c_1: 0, c_2: 0 },
+// { c_1: 1, c_2: 1 }
+// ]
+```
+
+### `mergeCells`
+
+Apply `rowspan` to an HTML table, calculated by `calcRowspanFromObjectArray`. Signature:
+
+```ts
+function mergeCells(tableEl: HTMLTableElement, columnIndexes?: number[]): void
```
Example:
@@ -28,12 +54,13 @@ Example:
```ts
const tableEl = document.getElementById('table') as HTMLTableElement
-applyRowspanToTable(tableEl)
+mergeCells(tableEl)
```
-## `calcRowspanFromObjectArray`
+### `calcRowspanFromObjectArray`
-Calculate the `rowspan` of each cell in JavaScript object rows. Signature:
+Calculate the `rowspan` of each cell in JavaScript object rows. Useful for flexible usage such as in server-side
+rendering. Signature:
```ts
function calcRowspanFromObjectArray>(
@@ -63,8 +90,6 @@ expect(
## Publishing
-Run this to build source, upgrade npm version, push to GitHub, and publish to npm.
-
```shell
yarn version --patch # or --minor or --major
```
diff --git a/package.json b/package.json
index 7fdc48e..ac42935 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "merge-cells",
- "version": "0.1.0",
+ "version": "0.1.3",
"main": "dist/merge-cells.js",
"files": [
"dist"
@@ -23,10 +23,8 @@
"prettier": "^3.1.1",
"prettier-plugin-organize-imports": "^3.2.4",
"pug": "^3.0.2",
- "ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
- "typescript": "^5.3.3",
- "uglify-js": "^3.17.4"
+ "typescript": "^5.3.3"
},
"prettier": {
"semi": false,
@@ -35,7 +33,7 @@
"printWidth": 120
},
"lint-staged": {
- "*.{js,jsx,ts,tsx}": [
+ "*.{js,ts,json,md,yml,yaml}": [
"prettier --write"
]
},
@@ -46,11 +44,10 @@
"fix": "prettier --write .",
"build:gh-pages": "ts-node ./scripts/gen-gh-pages-html.ts",
"build:dist": "tsc --project tsconfig.dist.json",
- "minify": "uglifyjs --compress --mangle --output dist/merge-cells.min.js --source-map filename dist/merge-cells.js",
- "build": "npm-run-all clean --parallel build:* --sequential minify",
+ "build": "npm-run-all clean --parallel build:*",
"test": "jest",
+ "gh-pages": "gh-pages -d dist",
"preversion": "npm-run-all lint test build",
- "postversion": "git push --tags && yarn publish . --tag $npm_package_version",
- "gh-pages": "gh-pages -d dist"
+ "postversion": "git push --tags && yarn publish . --tag $npm_package_version && yarn gh-pages"
}
}
diff --git a/scripts/index.pug b/scripts/index.pug
index d3514b4..4d58331 100644
--- a/scripts/index.pug
+++ b/scripts/index.pug
@@ -10,6 +10,8 @@ html(lang="en")
.container
h1= pageTitle
+ p Provide JavaScript/TypeScript functions to help you merge cells of an HTML #[code GROUP BY]-like table.
+ p Go to #[a(href="https://github.com/piglovesyou/merge-cells") github.com/piglovesyou/merge-cells] for usage and more.
table#table.table.table-bordered
thead