proto-table-wc 0.0.458 → 0.0.459
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/demo-table_2.cjs.entry.js +143 -143
- package/dist/cjs/{index-817f4cb7.js → index-719e6a11.js} +15 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/proto-table-wc.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/demo-table/demo-table.js +80 -80
- package/dist/collection/components/proto-table/iconPaths.js +7 -7
- package/dist/collection/components/proto-table/proto-table.js +137 -137
- package/dist/esm/demo-table_2.entry.js +143 -143
- package/dist/esm/{index-7e1a24cf.js → index-0e2d85f3.js} +15 -4
- package/dist/esm/loader.js +2 -2
- package/dist/esm/proto-table-wc.js +3 -3
- package/dist/proto-table-wc/{p-1181d99d.js → p-e4f313cd.js} +1 -1
- package/dist/proto-table-wc/{p-72c2d009.entry.js → p-e927935b.entry.js} +1 -1
- package/dist/proto-table-wc/proto-table-wc.esm.js +1 -1
- package/dist/types/components/demo-table/demo-table.d.ts +10 -10
- package/dist/types/components/proto-table/iconPaths.d.ts +7 -7
- package/dist/types/components/proto-table/proto-table.d.ts +13 -13
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/package.json +4 -4
@@ -1,145 +1,145 @@
|
|
1
1
|
import { h } from "@stencil/core";
|
2
2
|
import { iconPaths } from "./iconPaths";
|
3
3
|
const iconAliases = {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
'right': 'show',
|
5
|
+
'down': 'hide',
|
6
|
+
'arrow-up': 'sort',
|
7
|
+
'arrow-down': 'sort',
|
8
8
|
};
|
9
9
|
const aliasFor = name => {
|
10
|
-
|
10
|
+
return iconAliases[name];
|
11
11
|
};
|
12
12
|
export class ProtoTable {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
13
|
+
constructor() {
|
14
|
+
this.protoIcon = (name, hex = undefined, size = 24) => {
|
15
|
+
const path = iconPaths[name];
|
16
|
+
return (h("svg", { width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-labelledby": "title" }, h("title", null, aliasFor(name)), h("g", { fill: hex }, h("path", { d: path })), h("path", { d: "M0 0h24v24H0z", fill: "none" })));
|
17
|
+
};
|
18
|
+
this.handleCellClick = (index, row) => {
|
19
|
+
return () => {
|
20
|
+
if (index === 0) {
|
21
|
+
this.expanded = this.expanded === row ? undefined : row;
|
22
|
+
}
|
23
|
+
};
|
24
|
+
};
|
25
|
+
this.handleSortClick = index => {
|
26
|
+
// NOTE: small state machine for dealing with sorting...
|
27
|
+
return () => {
|
28
|
+
if (this.sort === index) {
|
29
|
+
if (this.clicks === 2) {
|
30
|
+
this.clicks = 0;
|
31
|
+
this.sort = undefined;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
this.clicks = this.clicks + 1;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
this.sort = index;
|
39
|
+
this.clicks = 1;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
};
|
43
|
+
this.iconFor = column => {
|
44
|
+
return this.sort === column && this.clicks === 2 ? 'arrow-up' : 'arrow-down';
|
45
|
+
};
|
46
|
+
this.header = () => {
|
47
|
+
const { fields, iconFor, protoIcon } = this;
|
48
|
+
return (h("div", { class: "header" }, fields.map(({ label }, index) => {
|
49
|
+
const cellClass = index === this.sort ? 'headerCell sort' : 'headerCell';
|
50
|
+
const ikon = iconFor(index);
|
51
|
+
return (h("div", { class: cellClass, onClick: this.handleSortClick(index) }, protoIcon(ikon), h("span", null, label)));
|
52
|
+
})));
|
53
|
+
};
|
54
|
+
this.row = (data, row) => {
|
55
|
+
const { fields, protoIcon } = this;
|
56
|
+
const rowClass = this.expanded === row ? 'row expanded' : 'row';
|
57
|
+
return (h("div", { class: "rowContainer" }, h("div", { class: rowClass }, fields.map(({ prop }, index) => {
|
58
|
+
const cellClass = index === this.sort ? 'cell sort' : 'cell';
|
59
|
+
return (h("div", { class: cellClass, onClick: this.handleCellClick(index, row) }, index === 0 && this.details ? protoIcon(this.expanded === row ? 'down' : 'right') : protoIcon('pad'), data[prop]));
|
60
|
+
})), this.details && this.expanded === row && this.details(data)));
|
61
|
+
};
|
62
|
+
this.data = [];
|
63
|
+
this.details = undefined;
|
64
|
+
this.fields = [];
|
65
|
+
this.expanded = undefined;
|
66
|
+
this.sort = undefined;
|
67
|
+
this.clicks = 0;
|
68
|
+
}
|
69
|
+
render() {
|
70
|
+
const items = this.data || [];
|
71
|
+
return (h("div", { class: "table" }, this.header(), items.map((item, index) => this.row(item, index))));
|
72
|
+
}
|
73
|
+
static get is() { return "proto-table"; }
|
74
|
+
static get originalStyleUrls() {
|
75
|
+
return {
|
76
|
+
"$": ["proto-table.css"]
|
77
|
+
};
|
78
|
+
}
|
79
|
+
static get styleUrls() {
|
80
|
+
return {
|
81
|
+
"$": ["proto-table.css"]
|
82
|
+
};
|
83
|
+
}
|
84
|
+
static get properties() {
|
85
|
+
return {
|
86
|
+
"data": {
|
87
|
+
"type": "unknown",
|
88
|
+
"mutable": false,
|
89
|
+
"complexType": {
|
90
|
+
"original": "any[]",
|
91
|
+
"resolved": "any[]",
|
92
|
+
"references": {}
|
93
|
+
},
|
94
|
+
"required": false,
|
95
|
+
"optional": false,
|
96
|
+
"docs": {
|
97
|
+
"tags": [],
|
98
|
+
"text": ""
|
99
|
+
},
|
100
|
+
"defaultValue": "[]"
|
101
|
+
},
|
102
|
+
"details": {
|
103
|
+
"type": "any",
|
104
|
+
"mutable": false,
|
105
|
+
"complexType": {
|
106
|
+
"original": "any",
|
107
|
+
"resolved": "any",
|
108
|
+
"references": {}
|
109
|
+
},
|
110
|
+
"required": false,
|
111
|
+
"optional": false,
|
112
|
+
"docs": {
|
113
|
+
"tags": [],
|
114
|
+
"text": ""
|
115
|
+
},
|
116
|
+
"attribute": "details",
|
117
|
+
"reflect": false,
|
118
|
+
"defaultValue": "undefined"
|
119
|
+
},
|
120
|
+
"fields": {
|
121
|
+
"type": "unknown",
|
122
|
+
"mutable": false,
|
123
|
+
"complexType": {
|
124
|
+
"original": "any[]",
|
125
|
+
"resolved": "any[]",
|
126
|
+
"references": {}
|
127
|
+
},
|
128
|
+
"required": false,
|
129
|
+
"optional": false,
|
130
|
+
"docs": {
|
131
|
+
"tags": [],
|
132
|
+
"text": ""
|
133
|
+
},
|
134
|
+
"defaultValue": "[]"
|
135
|
+
}
|
136
|
+
};
|
137
|
+
}
|
138
|
+
static get states() {
|
139
|
+
return {
|
140
|
+
"expanded": {},
|
141
|
+
"sort": {},
|
142
|
+
"clicks": {}
|
143
|
+
};
|
144
|
+
}
|
145
145
|
}
|
@@ -1,163 +1,163 @@
|
|
1
|
-
import { r as registerInstance, h } from './index-
|
1
|
+
import { r as registerInstance, h } from './index-0e2d85f3.js';
|
2
2
|
|
3
3
|
const demoTableCss = ".detailWrapper{font-weight:100;font-size:13px;display:flex;flex-direction:column;justify-items:start;padding:5px;padding-left:30px}";
|
4
4
|
|
5
5
|
const DemoTable = class {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
6
|
+
constructor(hostRef) {
|
7
|
+
registerInstance(this, hostRef);
|
8
|
+
this.fields = [
|
9
|
+
{ label: 'Date', prop: 'date' },
|
10
|
+
{ label: 'List Price', prop: 'price' },
|
11
|
+
{ label: '% of Market', prop: 'market' },
|
12
|
+
{ label: 'ProfitTime Score', prop: 'score' },
|
13
|
+
];
|
14
|
+
this.items = [];
|
15
|
+
this.table = undefined;
|
16
|
+
this.renderDetails = item => {
|
17
|
+
const { tags = [] } = item;
|
18
|
+
return (h("div", { class: "detailWrapper" }, h("span", null, tags.length, " details..."), h("ul", null, tags.map(tag => (h("li", null, tag))))));
|
19
|
+
};
|
20
|
+
}
|
21
|
+
componentWillLoad() {
|
22
|
+
this.items = [
|
23
|
+
{
|
24
|
+
date: '08/30/2020',
|
25
|
+
price: '$24,000',
|
26
|
+
market: '98%',
|
27
|
+
score: 'No Score',
|
28
|
+
tags: ['one', 'two', 'three'],
|
29
|
+
},
|
30
|
+
{
|
31
|
+
date: '08/31/2020',
|
32
|
+
price: '$24,000',
|
33
|
+
market: '99%',
|
34
|
+
score: 'No Score',
|
35
|
+
tags: ['uno', 'duo'],
|
36
|
+
},
|
37
|
+
{
|
38
|
+
date: '09/01/2020',
|
39
|
+
price: '$27,000',
|
40
|
+
market: '102%',
|
41
|
+
score: 'Platinum',
|
42
|
+
},
|
43
|
+
{
|
44
|
+
date: '09/02/2020',
|
45
|
+
price: '$27,423',
|
46
|
+
market: '104%',
|
47
|
+
score: 'Platinum',
|
48
|
+
tags: ['dog', 'cat', 'fish', 'hamster'],
|
49
|
+
},
|
50
|
+
{
|
51
|
+
date: '09/03/2020',
|
52
|
+
price: '$27,521',
|
53
|
+
market: '106%',
|
54
|
+
score: 'Platinum',
|
55
|
+
tags: ['4wd', 'sports'],
|
56
|
+
},
|
57
|
+
{
|
58
|
+
date: '09/04/2020',
|
59
|
+
price: '$27,687',
|
60
|
+
market: '107%',
|
61
|
+
score: 'Platinum',
|
62
|
+
tags: ['leather', 'chrome'],
|
63
|
+
},
|
64
|
+
];
|
65
|
+
}
|
66
|
+
componentDidLoad() {
|
67
|
+
const { table, items, fields } = this;
|
68
|
+
table.data = items;
|
69
|
+
table.fields = fields;
|
70
|
+
table.details = this.renderDetails;
|
71
|
+
}
|
72
|
+
render() {
|
73
|
+
return h("proto-table", { ref: el => (this.table = el) });
|
74
|
+
}
|
75
75
|
};
|
76
76
|
DemoTable.style = demoTableCss;
|
77
77
|
|
78
78
|
const iconPaths = {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
'down': 'M12 15.4L6.6 10 8 8.6l4 4 4-4 1.4 1.4z',
|
80
|
+
'up': 'M16 15.4l-4-4-4 4L6.6 14 12 8.6l5.4 5.4z',
|
81
|
+
'left': 'M14 17.4L8.6 12 14 6.6 15.4 8l-4 4 4 4z',
|
82
|
+
'right': 'M10 17.4L8.6 16l4-4-4-4L10 6.6l5.4 5.4z',
|
83
|
+
'more': 'M12 14a2 2 0 100-4 2 2 0 000 4zm-6 0a2 2 0 100-4 2 2 0 000 4zm12 0a2 2 0 100-4 2 2 0 000 4z',
|
84
|
+
'arrow-up': 'M5.3 10.7l1.4 1.4L11 7.8V20h2V7.8l4.3 4.3 1.4-1.4L12 4z',
|
85
|
+
'arrow-down': 'M18.7 13.3l-1.4-1.4-4.3 4.3V4h-2v12.2l-4.3-4.3-1.4 1.4L12 20z',
|
86
86
|
};
|
87
87
|
|
88
88
|
const protoTableCss = ".table{font-weight:400;font-size:13px;display:flex;flex-direction:column;width:100%;border:1px solid var(--clrs-navy);border-radius:2px}.table svg{fill:var(--clrs-navy)}.header{display:flex}.headerCell{flex-basis:100%;display:flex;align-items:center;justify-items:start;border-right:1px solid var(--clrs-navy);border-bottom:1px solid var(--clrs-navy);padding:5px;cursor:pointer}.headerCell svg g{display:none}.headerCell.sort svg g{display:inline}.headerCell:hover svg g{display:inline}.headerCell:hover{background-color:var(--clrs-silver)}.headerCell:last-child{border-right:none}.cell{flex-basis:100%;display:flex;align-items:center;justify-items:start;padding:5px}.cell:first-child svg{cursor:pointer}.sort{background-color:var(--cx-column-sort)}.row{display:flex;justify-items:stretch;width:100%}.row.expanded{background-color:var(--cx-row-expanded)}.row.expanded svg{fill:var(--clrs-red)}.row:hover{background-color:var(--cx-row-hover)}";
|
89
89
|
|
90
90
|
const iconAliases = {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
'right': 'show',
|
92
|
+
'down': 'hide',
|
93
|
+
'arrow-up': 'sort',
|
94
|
+
'arrow-down': 'sort',
|
95
95
|
};
|
96
96
|
const aliasFor = name => {
|
97
|
-
|
97
|
+
return iconAliases[name];
|
98
98
|
};
|
99
99
|
const ProtoTable = class {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
100
|
+
constructor(hostRef) {
|
101
|
+
registerInstance(this, hostRef);
|
102
|
+
this.protoIcon = (name, hex = undefined, size = 24) => {
|
103
|
+
const path = iconPaths[name];
|
104
|
+
return (h("svg", { width: size, height: size, viewBox: "0 0 24 24", role: "img", "aria-labelledby": "title" }, h("title", null, aliasFor(name)), h("g", { fill: hex }, h("path", { d: path })), h("path", { d: "M0 0h24v24H0z", fill: "none" })));
|
105
|
+
};
|
106
|
+
this.handleCellClick = (index, row) => {
|
107
|
+
return () => {
|
108
|
+
if (index === 0) {
|
109
|
+
this.expanded = this.expanded === row ? undefined : row;
|
110
|
+
}
|
111
|
+
};
|
112
|
+
};
|
113
|
+
this.handleSortClick = index => {
|
114
|
+
// NOTE: small state machine for dealing with sorting...
|
115
|
+
return () => {
|
116
|
+
if (this.sort === index) {
|
117
|
+
if (this.clicks === 2) {
|
118
|
+
this.clicks = 0;
|
119
|
+
this.sort = undefined;
|
120
|
+
}
|
121
|
+
else {
|
122
|
+
this.clicks = this.clicks + 1;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
this.sort = index;
|
127
|
+
this.clicks = 1;
|
128
|
+
}
|
129
|
+
};
|
130
|
+
};
|
131
|
+
this.iconFor = column => {
|
132
|
+
return this.sort === column && this.clicks === 2 ? 'arrow-up' : 'arrow-down';
|
133
|
+
};
|
134
|
+
this.header = () => {
|
135
|
+
const { fields, iconFor, protoIcon } = this;
|
136
|
+
return (h("div", { class: "header" }, fields.map(({ label }, index) => {
|
137
|
+
const cellClass = index === this.sort ? 'headerCell sort' : 'headerCell';
|
138
|
+
const ikon = iconFor(index);
|
139
|
+
return (h("div", { class: cellClass, onClick: this.handleSortClick(index) }, protoIcon(ikon), h("span", null, label)));
|
140
|
+
})));
|
141
|
+
};
|
142
|
+
this.row = (data, row) => {
|
143
|
+
const { fields, protoIcon } = this;
|
144
|
+
const rowClass = this.expanded === row ? 'row expanded' : 'row';
|
145
|
+
return (h("div", { class: "rowContainer" }, h("div", { class: rowClass }, fields.map(({ prop }, index) => {
|
146
|
+
const cellClass = index === this.sort ? 'cell sort' : 'cell';
|
147
|
+
return (h("div", { class: cellClass, onClick: this.handleCellClick(index, row) }, index === 0 && this.details ? protoIcon(this.expanded === row ? 'down' : 'right') : protoIcon('pad'), data[prop]));
|
148
|
+
})), this.details && this.expanded === row && this.details(data)));
|
149
|
+
};
|
150
|
+
this.data = [];
|
151
|
+
this.details = undefined;
|
152
|
+
this.fields = [];
|
153
|
+
this.expanded = undefined;
|
154
|
+
this.sort = undefined;
|
155
|
+
this.clicks = 0;
|
156
|
+
}
|
157
|
+
render() {
|
158
|
+
const items = this.data || [];
|
159
|
+
return (h("div", { class: "table" }, this.header(), items.map((item, index) => this.row(item, index))));
|
160
|
+
}
|
161
161
|
};
|
162
162
|
ProtoTable.style = protoTableCss;
|
163
163
|
|