tidy-table 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +55 -0
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [4.0.0] - 2023-03-04
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
The following items are **breaking changes** and not supported in prior releases.
|
|
12
|
+
|
|
13
|
+
- Updated future releases to be installed via [NPM](https://npmjs.com) vs [Bower](https://bower.io) (legacy only).
|
|
14
|
+
- Refactored instance arguments `new TidyTable(container, settings, options)`
|
|
15
|
+
- Renamed TR className/CSS selector `sort-desc`, `sort-asc` to `arrow-up`, `arrow-down`
|
|
16
|
+
- Replaced GIF images with SVG equivalent (renamed) `arrow-up.svg`, `arrow-down.svg`
|
|
17
|
+
- Replaced [QUnit](https://qunitjs.com) testing with [WebdriverIO](https://webdriver.io) framework.
|
|
18
|
+
- Integrated [Babel](https://babeljs.io) transpilation build process.
|
package/README.md
CHANGED
|
@@ -108,6 +108,61 @@ Overriding defaults can be done using the following options:
|
|
|
108
108
|
| reverseSortDir | Change the sorting arrow image direction. | false |
|
|
109
109
|
| responsive | Enable/disable responsive layout support. | false |
|
|
110
110
|
|
|
111
|
+
## Post-processing examples
|
|
112
|
+
|
|
113
|
+
There are times where you may need to customize the table result behavior. This can be achieved using `postProcess` hooks.
|
|
114
|
+
|
|
115
|
+
### Hide the second column of table results
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
function callback(table) {
|
|
119
|
+
const cols = table.querySelectorAll('th:nth-child(2), td:nth-child(2)');
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < cols.length; i++) {
|
|
122
|
+
cols[i].style.display = 'none';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Create text field on column click event
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
function callback(col) {
|
|
131
|
+
col.addEventListener('click', function() {
|
|
132
|
+
if (!this.querySelector('form')) {
|
|
133
|
+
const form = document.createElement('form');
|
|
134
|
+
form.addEventListener('submit', function() {
|
|
135
|
+
const xhr = new XMLHttpRequest();
|
|
136
|
+
xhr.open('POST', '/path/to/script');
|
|
137
|
+
xhr.send(null);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const field = document.createElement('input');
|
|
141
|
+
field.setAttribute('type', 'text');
|
|
142
|
+
field.setAttribute('value', this.textContent);
|
|
143
|
+
|
|
144
|
+
const button = document.createElement('input');
|
|
145
|
+
button.setAttribute('type', 'submit');
|
|
146
|
+
|
|
147
|
+
form.appendChild(field).appendChild(button);
|
|
148
|
+
|
|
149
|
+
this.removeChild(this.firstChild);
|
|
150
|
+
this.appendChild(form);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Hide select menu when cookie doesn't exist
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
function callback(menu) {
|
|
160
|
+
if (!getCookie('session')) {
|
|
161
|
+
menu.style.display = 'none';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
111
166
|
## Design template
|
|
112
167
|
|
|
113
168
|
The Illustrator [template](https://github.com/nuxy/tidy-table/blob/develop/images/arrow.ai) used to create the sort arrows has been provided with this package for reference.
|