@malloydata/render 0.0.103 → 0.0.104-dev231116200719
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/.storybook/preview.ts +3 -1
- package/dist/component/render.js +1 -0
- package/dist/component/table.js +106 -15
- package/dist/component/util.d.ts +3 -0
- package/dist/component/util.js +19 -0
- package/dist/stories/basic.stories.js +1 -1
- package/dist/stories/tables.stories.d.ts +6 -0
- package/dist/stories/tables.stories.js +7 -1
- package/package.json +2 -2
package/.storybook/preview.ts
CHANGED
|
@@ -3,7 +3,9 @@ import {Preview} from '@storybook/html';
|
|
|
3
3
|
import registeredData from './registered_data.json';
|
|
4
4
|
|
|
5
5
|
async function createConnection() {
|
|
6
|
-
const connection = new DuckDBWASMConnection('duckdb'
|
|
6
|
+
const connection = new DuckDBWASMConnection('duckdb', null, undefined, {
|
|
7
|
+
rowLimit: 1000,
|
|
8
|
+
});
|
|
7
9
|
await connection.connecting;
|
|
8
10
|
for (let tableName of registeredData) {
|
|
9
11
|
const fullTableName = `data/${tableName}`;
|
package/dist/component/render.js
CHANGED
package/dist/component/table.js
CHANGED
|
@@ -31,16 +31,75 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
31
31
|
exports.Table = void 0;
|
|
32
32
|
const lit_1 = require("lit");
|
|
33
33
|
const decorators_js_1 = require("lit/decorators.js");
|
|
34
|
+
const class_map_js_1 = require("lit/directives/class-map.js");
|
|
35
|
+
const util_1 = require("./util");
|
|
36
|
+
// TODO: replace with an estimator per column
|
|
37
|
+
function getColumnWidth() {
|
|
38
|
+
return 130;
|
|
39
|
+
}
|
|
40
|
+
const getContentStyle = (f) => {
|
|
41
|
+
if (f.isAtomicField()) {
|
|
42
|
+
const width = getColumnWidth();
|
|
43
|
+
return `width: ${width}px; min-width: ${width}px; max-width: ${width}px;`;
|
|
44
|
+
}
|
|
45
|
+
return '';
|
|
46
|
+
};
|
|
47
|
+
const renderCell = (f, value) => {
|
|
48
|
+
return (0, lit_1.html) `<div class="cell-wrapper">
|
|
49
|
+
<div class="cell-gutter-start"></div>
|
|
50
|
+
<div class="cell-content" style="${getContentStyle(f)}">${value}</div>
|
|
51
|
+
<div class="cell-gutter-end"></div>
|
|
52
|
+
</div>`;
|
|
53
|
+
};
|
|
54
|
+
const renderFieldContent = (row, f) => {
|
|
55
|
+
if (f.isExploreField()) {
|
|
56
|
+
return (0, lit_1.html) `<malloy-table
|
|
57
|
+
.data=${row.cell(f)}
|
|
58
|
+
></malloy-table>`;
|
|
59
|
+
}
|
|
60
|
+
return renderCell(f, row.cell(f).value);
|
|
61
|
+
};
|
|
62
|
+
const renderField = (row, f) => {
|
|
63
|
+
return (0, lit_1.html) `<td
|
|
64
|
+
class=${(0, class_map_js_1.classMap)({
|
|
65
|
+
'column-cell': true,
|
|
66
|
+
'hide-end-gutter': (0, util_1.isLastChild)(f),
|
|
67
|
+
'hide-start-gutter': (0, util_1.isFirstChild)(f),
|
|
68
|
+
})}
|
|
69
|
+
>
|
|
70
|
+
${renderFieldContent(row, f)}
|
|
71
|
+
</td>`;
|
|
72
|
+
};
|
|
73
|
+
const renderHeader = (f) => {
|
|
74
|
+
const isFirst = (0, util_1.isFirstChild)(f);
|
|
75
|
+
const isParentFirst = (0, util_1.isFirstChild)(f.parentExplore);
|
|
76
|
+
const isParentNotAField = !f.parentExplore.isExploreField();
|
|
77
|
+
const hideStartGutter = isFirst && (isParentFirst || isParentNotAField);
|
|
78
|
+
const isLast = (0, util_1.isLastChild)(f);
|
|
79
|
+
const isParentLast = (0, util_1.isLastChild)(f.parentExplore);
|
|
80
|
+
const hideEndGutter = isLast && (isParentLast || isParentNotAField);
|
|
81
|
+
return (0, lit_1.html) `<th
|
|
82
|
+
class=${(0, class_map_js_1.classMap)({
|
|
83
|
+
'column-cell': true,
|
|
84
|
+
'hide-end-gutter': hideEndGutter,
|
|
85
|
+
'hide-start-gutter': hideStartGutter,
|
|
86
|
+
})}
|
|
87
|
+
>
|
|
88
|
+
${renderCell(f, f.name)}
|
|
89
|
+
</th>`;
|
|
90
|
+
};
|
|
34
91
|
let Table = exports.Table = class Table extends lit_1.LitElement {
|
|
35
92
|
render() {
|
|
36
93
|
const fields = this.data.field.allFields;
|
|
37
|
-
const headers = fields.map(f => (
|
|
94
|
+
const headers = fields.map(f => renderHeader(f));
|
|
38
95
|
const rows = Array.from(this.data, row => (0, lit_1.html) `<tr>
|
|
39
|
-
${fields.map(f => (
|
|
96
|
+
${fields.map(f => renderField(row, f))}
|
|
40
97
|
</tr>`);
|
|
41
98
|
return (0, lit_1.html) `<table>
|
|
42
99
|
<thead>
|
|
43
|
-
|
|
100
|
+
<tr>
|
|
101
|
+
${headers}
|
|
102
|
+
</tr>
|
|
44
103
|
</thead>
|
|
45
104
|
<tbody>
|
|
46
105
|
${rows}
|
|
@@ -52,16 +111,26 @@ Table.styles = (0, lit_1.css) `
|
|
|
52
111
|
table {
|
|
53
112
|
border-collapse: collapse;
|
|
54
113
|
background: var(--table-background);
|
|
114
|
+
font-variant-numeric: tabular-nums;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
table * {
|
|
118
|
+
box-sizing: border-box;
|
|
55
119
|
}
|
|
56
120
|
|
|
57
121
|
.column-cell {
|
|
58
122
|
height: var(--table-row-height);
|
|
59
|
-
border-block: var(--table-border);
|
|
60
123
|
overflow: hidden;
|
|
61
124
|
white-space: nowrap;
|
|
62
125
|
text-align: left;
|
|
63
|
-
padding: 0px
|
|
64
|
-
|
|
126
|
+
padding: 0px;
|
|
127
|
+
vertical-align: top;
|
|
128
|
+
position: relative;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
td.column-cell {
|
|
132
|
+
font-weight: var(--table-body-weight);
|
|
133
|
+
color: var(--table-body-color);
|
|
65
134
|
}
|
|
66
135
|
|
|
67
136
|
th.column-cell {
|
|
@@ -69,18 +138,40 @@ Table.styles = (0, lit_1.css) `
|
|
|
69
138
|
color: var(--table-header-color);
|
|
70
139
|
}
|
|
71
140
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
141
|
+
.cell-wrapper {
|
|
142
|
+
height: var(--table-row-height);
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
overflow: hidden;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.cell-content {
|
|
149
|
+
border-top: var(--table-border);
|
|
150
|
+
height: var(--table-row-height);
|
|
151
|
+
line-height: var(--table-row-height);
|
|
152
|
+
flex: 1;
|
|
153
|
+
overflow: hidden;
|
|
154
|
+
text-overflow: ellipsis;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.cell-gutter-start {
|
|
158
|
+
border-top: var(--table-border);
|
|
159
|
+
height: var(--table-row-height);
|
|
160
|
+
width: var(--table-gutter-size);
|
|
75
161
|
}
|
|
76
162
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
163
|
+
.cell-gutter-end {
|
|
164
|
+
border-top: var(--table-border);
|
|
165
|
+
height: var(--table-row-height);
|
|
166
|
+
width: var(--table-gutter-size);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.hide-end-gutter .cell-gutter-end {
|
|
170
|
+
border-top: none;
|
|
80
171
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
172
|
+
|
|
173
|
+
.hide-start-gutter .cell-gutter-start {
|
|
174
|
+
border-top: none;
|
|
84
175
|
}
|
|
85
176
|
`;
|
|
86
177
|
__decorate([
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFirstChild = exports.isLastChild = void 0;
|
|
4
|
+
function getLocationInParent(f) {
|
|
5
|
+
var _a;
|
|
6
|
+
const parent = f.parentExplore;
|
|
7
|
+
return (_a = parent === null || parent === void 0 ? void 0 : parent.allFields.findIndex(pf => pf.name === f.name)) !== null && _a !== void 0 ? _a : -1;
|
|
8
|
+
}
|
|
9
|
+
function isLastChild(f) {
|
|
10
|
+
if (f.parentExplore)
|
|
11
|
+
return getLocationInParent(f) === f.parentExplore.allFields.length - 1;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
exports.isLastChild = isLastChild;
|
|
15
|
+
function isFirstChild(f) {
|
|
16
|
+
return getLocationInParent(f) === 0;
|
|
17
|
+
}
|
|
18
|
+
exports.isFirstChild = isFirstChild;
|
|
19
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Products2Column = exports.ProductsTableCustomTheme = exports.ProductsTable = void 0;
|
|
6
|
+
exports.Nested = exports.Products2Column = exports.ProductsTableCustomTheme = exports.ProductsTable = void 0;
|
|
7
7
|
const tables_malloy_raw_1 = __importDefault(require("./static/tables.malloy?raw"));
|
|
8
8
|
const util_1 = require("./util");
|
|
9
9
|
require("./themes.css");
|
|
@@ -40,4 +40,10 @@ exports.Products2Column = {
|
|
|
40
40
|
view: 'category_bar',
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
+
exports.Nested = {
|
|
44
|
+
args: {
|
|
45
|
+
source: 'products',
|
|
46
|
+
view: 'nested',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
43
49
|
//# sourceMappingURL=tables.stories.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.104-dev231116200719",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build-storybook": "storybook build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@malloydata/malloy": "^0.0.
|
|
26
|
+
"@malloydata/malloy": "^0.0.104-dev231116200719",
|
|
27
27
|
"@types/luxon": "^2.4.0",
|
|
28
28
|
"lit": "^3.0.2",
|
|
29
29
|
"lodash": "^4.17.20",
|