@itrocks/list 0.1.4 → 0.2.0
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/cjs/list.html +1 -1
- package/cjs/sort.d.ts +1 -1
- package/cjs/sort.js +16 -1
- package/list.css +24 -0
- package/package.json +3 -2
- package/sort.svg +1 -0
package/cjs/list.html
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
<tr class="properties">
|
|
31
31
|
<th class="select"><input name="select" type="checkbox" value="all"></th>
|
|
32
32
|
<!--columns-->
|
|
33
|
-
<th data-property="{name}">{@display}</th>
|
|
33
|
+
<th data-property="{name}" data-reverse="{?reverse}" data-sort="{?sort}">{@display}</th>
|
|
34
34
|
<!--end-->
|
|
35
35
|
</tr>
|
|
36
36
|
</thead>
|
package/cjs/sort.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { Request } from '@itrocks/request-response';
|
|
|
3
3
|
import { Option } from '@itrocks/storage';
|
|
4
4
|
import { Columns } from './columns';
|
|
5
5
|
export declare class Sort<T extends object> {
|
|
6
|
-
getParams(_request: Request,
|
|
6
|
+
getParams(_request: Request, type: Type, columns: Columns<T>): void;
|
|
7
7
|
readOptions(options?: Option[]): Option[];
|
|
8
8
|
}
|
package/cjs/sort.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Sort = void 0;
|
|
4
|
+
const sort_1 = require("@itrocks/sort");
|
|
5
|
+
const sort_2 = require("@itrocks/sort");
|
|
4
6
|
const storage_1 = require("@itrocks/storage");
|
|
5
7
|
class Sort {
|
|
6
|
-
getParams(_request,
|
|
8
|
+
getParams(_request, type, columns) {
|
|
9
|
+
let sortProperties;
|
|
10
|
+
for (const option of this.readOptions()) {
|
|
11
|
+
if (option instanceof storage_1.Sort) {
|
|
12
|
+
sortProperties = option.properties;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
sortProperties ??= (0, sort_2.sortOf)(type);
|
|
16
|
+
const sortPropertyNames = sortProperties.map(property => '' + property);
|
|
17
|
+
for (const column of columns) {
|
|
18
|
+
const sortIndex = sortPropertyNames.indexOf(column.name) + 1;
|
|
19
|
+
column.reverse = !!(sortIndex && (sortProperties[sortIndex - 1] instanceof sort_1.Reverse));
|
|
20
|
+
column.sort = sortIndex ? sortIndex : undefined;
|
|
21
|
+
}
|
|
7
22
|
}
|
|
8
23
|
readOptions(options = new Array) {
|
|
9
24
|
options.push(storage_1.Sort);
|
package/list.css
CHANGED
|
@@ -27,6 +27,30 @@ table.objects {
|
|
|
27
27
|
table.objects th {
|
|
28
28
|
background: #f8f8f8;
|
|
29
29
|
}
|
|
30
|
+
table.objects th[data-sort] {
|
|
31
|
+
padding-right: calc(0.6em + 16px);
|
|
32
|
+
}
|
|
33
|
+
table.objects th[data-sort]::after {
|
|
34
|
+
content: "";
|
|
35
|
+
height: 24px;
|
|
36
|
+
mask: url("sort.svg") right center/24px 24px no-repeat;
|
|
37
|
+
position: absolute;
|
|
38
|
+
right: 0;
|
|
39
|
+
top: calc(50% - 12px);
|
|
40
|
+
width: 24px;
|
|
41
|
+
}
|
|
42
|
+
table.objects th[data-sort][data-reverse]::after {
|
|
43
|
+
transform: scaleY(-1);
|
|
44
|
+
}
|
|
45
|
+
table.objects th[data-sort][data-sort="1"]::after {
|
|
46
|
+
background-color: #444;
|
|
47
|
+
}
|
|
48
|
+
table.objects th[data-sort][data-sort="2"]::after {
|
|
49
|
+
background-color: #888;
|
|
50
|
+
}
|
|
51
|
+
table.objects th[data-sort][data-sort="3"]::after {
|
|
52
|
+
background-color: #ccc;
|
|
53
|
+
}
|
|
30
54
|
table.objects tr td, table.objects tr th {
|
|
31
55
|
border-bottom: 1px solid #d8d8d8;
|
|
32
56
|
border-spacing: 0;
|
package/package.json
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"LICENSE",
|
|
31
31
|
"README.md",
|
|
32
32
|
"cjs/*",
|
|
33
|
+
"/*.svg",
|
|
33
34
|
"*.css",
|
|
34
35
|
"*.d.ts",
|
|
35
36
|
"*.js",
|
|
@@ -67,9 +68,9 @@
|
|
|
67
68
|
"scripts": {
|
|
68
69
|
"build": "npm run build:cjs && npm run build:css && npm run build:front",
|
|
69
70
|
"build:cjs": "tsc -p tsconfig.cjs.json && cp src/*.html cjs/",
|
|
70
|
-
"build:css": "sass --no-source-map src/list.scss:list.css",
|
|
71
|
+
"build:css": "sass --no-source-map src/list.scss:list.css && cp src/*.svg ./",
|
|
71
72
|
"build:front": "tsc -p esm/tsconfig.json && ../prepare-module/prepare-module.js esm"
|
|
72
73
|
},
|
|
73
74
|
"types": "./cjs/list.d.ts",
|
|
74
|
-
"version": "0.
|
|
75
|
+
"version": "0.2.0"
|
|
75
76
|
}
|
package/sort.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 15l10 0-5-5z"/></svg>
|