@malloydata/render 0.0.135-dev240325191847 → 0.0.135-dev240326020414
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/dist/component/render-webcomponent.d.ts +6 -0
- package/dist/component/render.d.ts +7 -17
- package/dist/component/result-context.d.ts +2 -3
- package/dist/component/table/table-context.d.ts +9 -0
- package/dist/component/{table-layout.d.ts → table/table-layout.d.ts} +2 -2
- package/dist/component/table/table.d.ts +9 -0
- package/dist/html/html_view.d.ts +1 -1
- package/dist/module/index.mjs +145001 -0
- package/dist/module/index.umd.js +1643 -0
- package/dist/module/style.css +1 -0
- package/dist/stories/bars.stories.d.ts +1 -1
- package/dist/stories/tables.stories.d.ts +1 -1
- package/dist/stories/themes.stories.d.ts +1 -1
- package/dist/webcomponent/malloy-render.mjs +90572 -0
- package/dist/webcomponent/malloy-render.umd.js +1491 -0
- package/dist/webcomponent/style.css +1 -0
- package/package.json +21 -7
- package/vite.config.ts +25 -0
- package/vite.config.webcomponent.ts +25 -0
- package/dist/bundle/bundled_renderer.js +0 -139374
- package/dist/bundle/bundled_renderer.min.js +0 -2374
- package/dist/bundle/main.js +0 -29
- package/dist/bundle/renderer.js +0 -71
- package/dist/component/bar-chart.js +0 -130
- package/dist/component/chart-settings.js +0 -152
- package/dist/component/render-numeric-field.js +0 -104
- package/dist/component/render-result-metadata.js +0 -91
- package/dist/component/render.js +0 -155
- package/dist/component/result-context.js +0 -28
- package/dist/component/table-layout.js +0 -83
- package/dist/component/table.d.ts +0 -35
- package/dist/component/table.js +0 -375
- package/dist/component/util.js +0 -53
- package/dist/component/vega-chart.js +0 -105
- package/dist/component/vega-lite-base-spec.js +0 -61
- package/dist/component/vega-types.js +0 -34
- package/dist/data_styles.js +0 -50
- package/dist/drill.js +0 -124
- package/dist/html/area_sparkline.js +0 -118
- package/dist/html/bar_chart.js +0 -70
- package/dist/html/bar_sparkline.js +0 -119
- package/dist/html/boolean.js +0 -53
- package/dist/html/bytes.js +0 -47
- package/dist/html/cartesian_chart.js +0 -110
- package/dist/html/chart.js +0 -120
- package/dist/html/column_sparkline.js +0 -120
- package/dist/html/container.js +0 -44
- package/dist/html/currency.js +0 -75
- package/dist/html/dashboard.js +0 -242
- package/dist/html/data_volume.js +0 -94
- package/dist/html/date.js +0 -66
- package/dist/html/duration.js +0 -108
- package/dist/html/html_view.js +0 -187
- package/dist/html/image.js +0 -77
- package/dist/html/index.js +0 -28
- package/dist/html/json.js +0 -52
- package/dist/html/line_chart.js +0 -72
- package/dist/html/link.js +0 -57
- package/dist/html/list.js +0 -73
- package/dist/html/list_detail.js +0 -33
- package/dist/html/number.js +0 -73
- package/dist/html/percent.js +0 -50
- package/dist/html/point_map.js +0 -182
- package/dist/html/scatter_chart.js +0 -72
- package/dist/html/segment_map.js +0 -151
- package/dist/html/shape_map.js +0 -194
- package/dist/html/sparkline.js +0 -120
- package/dist/html/state_codes.js +0 -137
- package/dist/html/table.js +0 -475
- package/dist/html/text.js +0 -65
- package/dist/html/unsupported.js +0 -72
- package/dist/html/utils.js +0 -277
- package/dist/html/vega_spec.js +0 -544
- package/dist/index.js +0 -47
- package/dist/main_renderer_factory.js +0 -101
- package/dist/renderer.js +0 -34
- package/dist/renderer_factory.js +0 -57
- package/dist/renderer_types.js +0 -25
- package/dist/stories/bars.stories.js +0 -52
- package/dist/stories/basic.stories.js +0 -34
- package/dist/stories/image.stories.js +0 -34
- package/dist/stories/render-malloy-legacy.js +0 -27
- package/dist/stories/tables.stories.js +0 -65
- package/dist/stories/themes.stories.js +0 -47
- package/dist/stories/util.js +0 -25
- package/dist/tags_utils.js +0 -30
package/dist/component/render.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
25
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
27
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
28
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.MalloyRender = void 0;
|
|
32
|
-
const malloy_1 = require("@malloydata/malloy");
|
|
33
|
-
const lit_1 = require("lit");
|
|
34
|
-
const decorators_js_1 = require("lit/decorators.js");
|
|
35
|
-
require("./table");
|
|
36
|
-
require("./bar-chart");
|
|
37
|
-
const context_1 = require("@lit/context");
|
|
38
|
-
const result_context_1 = require("./result-context");
|
|
39
|
-
const render_result_metadata_1 = require("./render-result-metadata");
|
|
40
|
-
// Get the first valid theme value or fallback to CSS variable
|
|
41
|
-
function getThemeValue(prop, ...themes) {
|
|
42
|
-
let value;
|
|
43
|
-
for (const theme of themes) {
|
|
44
|
-
value = theme === null || theme === void 0 ? void 0 : theme.text(prop);
|
|
45
|
-
if (typeof value !== 'undefined')
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
// If no theme overrides, convert prop name from camelCase to kebab and pull from --malloy-theme-- variable
|
|
49
|
-
return (value !== null && value !== void 0 ? value : `var(--malloy-theme--${prop
|
|
50
|
-
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
51
|
-
.toLowerCase()})`);
|
|
52
|
-
}
|
|
53
|
-
let MalloyRender = class MalloyRender extends lit_1.LitElement {
|
|
54
|
-
willUpdate(changedProperties) {
|
|
55
|
-
if (changedProperties.has('result') ||
|
|
56
|
-
changedProperties.has('queryResult') ||
|
|
57
|
-
changedProperties.has('modelDef')) {
|
|
58
|
-
if (this.result)
|
|
59
|
-
this._result = this.result;
|
|
60
|
-
else if (this.queryResult && this.modelDef) {
|
|
61
|
-
this._result = new malloy_1.Result(this.queryResult, this.modelDef);
|
|
62
|
-
}
|
|
63
|
-
this.metadata = (0, render_result_metadata_1.getResultMetadata)(this._result);
|
|
64
|
-
const modelTag = this._result.modelTag;
|
|
65
|
-
const { tag: resultTag } = this._result.tagParse();
|
|
66
|
-
const modelTheme = modelTag.tag('theme');
|
|
67
|
-
const localTheme = resultTag.tag('theme');
|
|
68
|
-
this.updateTheme(modelTheme, localTheme);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
updateTheme(modelTheme, localTheme) {
|
|
72
|
-
const tableRowHeight = getThemeValue('tableRowHeight', localTheme, modelTheme);
|
|
73
|
-
const tableBodyColor = getThemeValue('tableBodyColor', localTheme, modelTheme);
|
|
74
|
-
const tableFontSize = getThemeValue('tableFontSize', localTheme, modelTheme);
|
|
75
|
-
const tableHeaderColor = getThemeValue('tableHeaderColor', localTheme, modelTheme);
|
|
76
|
-
const tableHeaderWeight = getThemeValue('tableHeaderWeight', localTheme, modelTheme);
|
|
77
|
-
const tableBodyWeight = getThemeValue('tableBodyWeight', localTheme, modelTheme);
|
|
78
|
-
const tableBorder = getThemeValue('tableBorder', localTheme, modelTheme);
|
|
79
|
-
const tableBackground = getThemeValue('tableBackground', localTheme, modelTheme);
|
|
80
|
-
const tableGutterSize = getThemeValue('tableGutterSize', localTheme, modelTheme);
|
|
81
|
-
const tablePinnedBackground = getThemeValue('tablePinnedBackground', localTheme, modelTheme);
|
|
82
|
-
const tablePinnedBorder = getThemeValue('tablePinnedBorder', localTheme, modelTheme);
|
|
83
|
-
const fontFamily = getThemeValue('fontFamily', localTheme, modelTheme);
|
|
84
|
-
this.style.setProperty('--malloy-render--table-row-height', tableRowHeight);
|
|
85
|
-
this.style.setProperty('--malloy-render--table-body-color', tableBodyColor);
|
|
86
|
-
this.style.setProperty('--malloy-render--table-font-size', tableFontSize);
|
|
87
|
-
this.style.setProperty('--malloy-render--font-family', fontFamily);
|
|
88
|
-
this.style.setProperty('--malloy-render--table-header-color', tableHeaderColor);
|
|
89
|
-
this.style.setProperty('--malloy-render--table-header-weight', tableHeaderWeight);
|
|
90
|
-
this.style.setProperty('--malloy-render--table-body-weight', tableBodyWeight);
|
|
91
|
-
this.style.setProperty('--malloy-render--table-border', tableBorder);
|
|
92
|
-
this.style.setProperty('--malloy-render--table-background', tableBackground);
|
|
93
|
-
this.style.setProperty('--malloy-render--table-gutter-size', tableGutterSize);
|
|
94
|
-
this.style.setProperty('--malloy-render--table-pinned-background', tablePinnedBackground);
|
|
95
|
-
this.style.setProperty('--malloy-render--table-pinned-border', tablePinnedBorder);
|
|
96
|
-
}
|
|
97
|
-
render() {
|
|
98
|
-
return (0, lit_1.html) `<malloy-table
|
|
99
|
-
exportparts="table-container: container"
|
|
100
|
-
.data=${this._result.data}
|
|
101
|
-
></malloy-table>`;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
exports.MalloyRender = MalloyRender;
|
|
105
|
-
MalloyRender.styles = (0, lit_1.css) `
|
|
106
|
-
:host {
|
|
107
|
-
--malloy-theme--table-row-height: 28px;
|
|
108
|
-
--malloy-theme--table-font-size: 12px;
|
|
109
|
-
--malloy-theme--table-header-color: #5d626b;
|
|
110
|
-
--malloy-theme--table-header-weight: bold;
|
|
111
|
-
--malloy-theme--table-body-color: #727883;
|
|
112
|
-
--malloy-theme--table-body-weight: 400;
|
|
113
|
-
--malloy-theme--table-border: 1px solid #e5e7eb;
|
|
114
|
-
--malloy-theme--table-background: white;
|
|
115
|
-
--malloy-theme--table-gutter-size: 15px;
|
|
116
|
-
--malloy-theme--table-pinned-background: #f5fafc;
|
|
117
|
-
--malloy-theme--table-pinned-border: 1px solid #daedf3;
|
|
118
|
-
--malloy-theme--font-family: Inter, system-ui, sans-serif;
|
|
119
|
-
|
|
120
|
-
font-family: var(--malloy-render--font-family);
|
|
121
|
-
font-size: var(--malloy-render--table-font-size);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@supports (font-variation-settings: normal) {
|
|
125
|
-
:host {
|
|
126
|
-
font-family:
|
|
127
|
-
InterVariable,
|
|
128
|
-
Inter,
|
|
129
|
-
system-ui sans-serif;
|
|
130
|
-
|
|
131
|
-
font-feature-settings:
|
|
132
|
-
'liga' 1,
|
|
133
|
-
'calt' 1;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
`;
|
|
137
|
-
__decorate([
|
|
138
|
-
(0, decorators_js_1.property)({ attribute: false })
|
|
139
|
-
], MalloyRender.prototype, "result", void 0);
|
|
140
|
-
__decorate([
|
|
141
|
-
(0, decorators_js_1.property)({ attribute: false })
|
|
142
|
-
], MalloyRender.prototype, "queryResult", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
(0, decorators_js_1.property)({ attribute: false })
|
|
145
|
-
], MalloyRender.prototype, "modelDef", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
(0, decorators_js_1.state)()
|
|
148
|
-
], MalloyRender.prototype, "_result", void 0);
|
|
149
|
-
__decorate([
|
|
150
|
-
(0, context_1.provide)({ context: result_context_1.resultContext })
|
|
151
|
-
], MalloyRender.prototype, "metadata", void 0);
|
|
152
|
-
exports.MalloyRender = MalloyRender = __decorate([
|
|
153
|
-
(0, decorators_js_1.customElement)('malloy-render')
|
|
154
|
-
], MalloyRender);
|
|
155
|
-
//# sourceMappingURL=render.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.resultContext = void 0;
|
|
26
|
-
const context_1 = require("@lit/context");
|
|
27
|
-
exports.resultContext = (0, context_1.createContext)('malloy-render-result');
|
|
28
|
-
//# sourceMappingURL=result-context.js.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.getTableLayout = void 0;
|
|
26
|
-
const util_1 = require("./util");
|
|
27
|
-
const render_numeric_field_1 = require("./render-numeric-field");
|
|
28
|
-
const chart_settings_1 = require("./chart-settings");
|
|
29
|
-
const MIN_COLUMN_WIDTH = 32;
|
|
30
|
-
const MAX_COLUMN_WIDTH = 384;
|
|
31
|
-
const COLUMN_BUFFER = 12;
|
|
32
|
-
// TODO: get from theme
|
|
33
|
-
const ROW_HEIGHT = 28;
|
|
34
|
-
function getTableLayout(metadata) {
|
|
35
|
-
const layout = {};
|
|
36
|
-
for (const [key, fieldMeta] of Object.entries(metadata.fields)) {
|
|
37
|
-
const field = fieldMeta.field;
|
|
38
|
-
const layoutEntry = {
|
|
39
|
-
metadata: fieldMeta,
|
|
40
|
-
width: getColumnWidth(field, metadata),
|
|
41
|
-
height: null,
|
|
42
|
-
chartSettings: null,
|
|
43
|
-
};
|
|
44
|
-
const { tag } = field.tagParse();
|
|
45
|
-
if (tag.has('bar') && field.isExploreField()) {
|
|
46
|
-
layoutEntry.chartSettings = (0, chart_settings_1.getChartSettings)(field, metadata);
|
|
47
|
-
layoutEntry.width = layoutEntry.chartSettings.totalWidth;
|
|
48
|
-
layoutEntry.height = layoutEntry.chartSettings.totalHeight;
|
|
49
|
-
}
|
|
50
|
-
else if (field.isAtomicField()) {
|
|
51
|
-
layoutEntry.height = ROW_HEIGHT;
|
|
52
|
-
}
|
|
53
|
-
layout[key] = layoutEntry;
|
|
54
|
-
}
|
|
55
|
-
return layout;
|
|
56
|
-
}
|
|
57
|
-
exports.getTableLayout = getTableLayout;
|
|
58
|
-
function getColumnWidth(f, metadata) {
|
|
59
|
-
const fieldKey = (0, util_1.getFieldKey)(f);
|
|
60
|
-
const fieldMeta = metadata.fields[fieldKey];
|
|
61
|
-
let width = 0;
|
|
62
|
-
if (f.isAtomicField()) {
|
|
63
|
-
// TODO: get font styles from theme
|
|
64
|
-
const font = '12px Inter, sans-serif';
|
|
65
|
-
const titleWidth = (0, util_1.getTextWidth)(f.name, font);
|
|
66
|
-
if (f.isAtomicField() && f.isString()) {
|
|
67
|
-
width =
|
|
68
|
-
Math.max((0, util_1.getTextWidth)(fieldMeta.maxString, font), titleWidth) +
|
|
69
|
-
COLUMN_BUFFER;
|
|
70
|
-
}
|
|
71
|
-
else if (f.isAtomicField() && f.isNumber()) {
|
|
72
|
-
const formattedValue = fieldMeta.max === null ? '∅' : (0, render_numeric_field_1.renderNumericField)(f, fieldMeta.max);
|
|
73
|
-
width =
|
|
74
|
-
Math.max((0, util_1.getTextWidth)(formattedValue, font), titleWidth) +
|
|
75
|
-
COLUMN_BUFFER;
|
|
76
|
-
}
|
|
77
|
-
else
|
|
78
|
-
width = 130;
|
|
79
|
-
width = (0, util_1.clamp)(MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH, width);
|
|
80
|
-
}
|
|
81
|
-
return width;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=table-layout.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { DataArray } from '@malloydata/malloy';
|
|
2
|
-
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
3
|
-
import { RenderResultMetadata } from './render-result-metadata';
|
|
4
|
-
import { TableLayout } from './table-layout';
|
|
5
|
-
type TableContext = {
|
|
6
|
-
root: boolean;
|
|
7
|
-
layout: TableLayout;
|
|
8
|
-
};
|
|
9
|
-
export declare class Table extends LitElement {
|
|
10
|
-
static styles: import("lit").CSSResult;
|
|
11
|
-
data: DataArray;
|
|
12
|
-
rowLimit: number;
|
|
13
|
-
pinnedHeader: boolean;
|
|
14
|
-
protected _scrolling: boolean;
|
|
15
|
-
parentCtx: TableContext | undefined;
|
|
16
|
-
ctx: TableContext;
|
|
17
|
-
metadata: RenderResultMetadata;
|
|
18
|
-
connectedCallback(): void;
|
|
19
|
-
private _handleScroll;
|
|
20
|
-
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
21
|
-
private renderHeader;
|
|
22
|
-
private renderField;
|
|
23
|
-
private getColumnWidth;
|
|
24
|
-
private getContentStyle;
|
|
25
|
-
private renderCell;
|
|
26
|
-
private renderFieldContent;
|
|
27
|
-
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
28
|
-
render(): TemplateResult<1>;
|
|
29
|
-
}
|
|
30
|
-
declare global {
|
|
31
|
-
interface HTMLElementTagNameMap {
|
|
32
|
-
'malloy-table': Table;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export {};
|
package/dist/component/table.js
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
25
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
27
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
28
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.Table = void 0;
|
|
32
|
-
const lit_1 = require("lit");
|
|
33
|
-
const decorators_js_1 = require("lit/decorators.js");
|
|
34
|
-
const class_map_js_1 = require("lit/directives/class-map.js");
|
|
35
|
-
const context_1 = require("@lit/context");
|
|
36
|
-
const util_1 = require("./util");
|
|
37
|
-
const render_numeric_field_1 = require("./render-numeric-field");
|
|
38
|
-
const result_context_1 = require("./result-context");
|
|
39
|
-
const table_layout_1 = require("./table-layout");
|
|
40
|
-
const tableContext = (0, context_1.createContext)('table');
|
|
41
|
-
let Table = class Table extends lit_1.LitElement {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
this.rowLimit = Infinity;
|
|
45
|
-
this.pinnedHeader = false;
|
|
46
|
-
this._scrolling = false;
|
|
47
|
-
}
|
|
48
|
-
connectedCallback() {
|
|
49
|
-
super.connectedCallback();
|
|
50
|
-
if (typeof this.parentCtx === 'undefined') {
|
|
51
|
-
this.ctx = {
|
|
52
|
-
root: true,
|
|
53
|
-
layout: {},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.ctx = {
|
|
58
|
-
root: false,
|
|
59
|
-
layout: this.parentCtx.layout,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
_handleScroll(e) {
|
|
64
|
-
const target = e.target;
|
|
65
|
-
this._scrolling = target.scrollTop > 0;
|
|
66
|
-
}
|
|
67
|
-
// If rendering a pinned header, render it within the current ShadowDOM root so we can use CSS to style the nested table headers when scrolling
|
|
68
|
-
createRenderRoot() {
|
|
69
|
-
if (this.pinnedHeader)
|
|
70
|
-
return this;
|
|
71
|
-
return super.createRenderRoot();
|
|
72
|
-
}
|
|
73
|
-
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="column-cell ${(0, class_map_js_1.classMap)({
|
|
83
|
-
numeric: f.isAtomicField() && f.isNumber(),
|
|
84
|
-
})}"
|
|
85
|
-
>
|
|
86
|
-
${this.renderCell(f, f.name, {
|
|
87
|
-
hideStartGutter,
|
|
88
|
-
hideEndGutter,
|
|
89
|
-
isHeader: true,
|
|
90
|
-
})}
|
|
91
|
-
</th>`;
|
|
92
|
-
}
|
|
93
|
-
renderField(row, f) {
|
|
94
|
-
return (0, lit_1.html) `<td
|
|
95
|
-
class="column-cell ${(0, class_map_js_1.classMap)({
|
|
96
|
-
numeric: f.isAtomicField() && f.isNumber(),
|
|
97
|
-
})}"
|
|
98
|
-
>
|
|
99
|
-
${this.renderFieldContent(row, f)}
|
|
100
|
-
</td>`;
|
|
101
|
-
}
|
|
102
|
-
getColumnWidth(f) {
|
|
103
|
-
const key = (0, util_1.getFieldKey)(f);
|
|
104
|
-
return this.ctx.layout[key].width;
|
|
105
|
-
}
|
|
106
|
-
getContentStyle(f, isHeader = false) {
|
|
107
|
-
const width = this.getColumnWidth(f);
|
|
108
|
-
let style = '';
|
|
109
|
-
if (isHeader)
|
|
110
|
-
return style;
|
|
111
|
-
if (typeof width !== 'undefined') {
|
|
112
|
-
style += `width: ${width}px; min-width: ${width}px; max-width: ${width}px;`;
|
|
113
|
-
}
|
|
114
|
-
const height = this.ctx.layout[(0, util_1.getFieldKey)(f)].height;
|
|
115
|
-
if (typeof height === 'number') {
|
|
116
|
-
style += `height: ${height}px;`;
|
|
117
|
-
}
|
|
118
|
-
return style;
|
|
119
|
-
}
|
|
120
|
-
renderCell(f, value, options) {
|
|
121
|
-
return (0, lit_1.html) `<div class="cell-wrapper">
|
|
122
|
-
<div
|
|
123
|
-
class=${(0, class_map_js_1.classMap)({
|
|
124
|
-
'cell-gutter': true,
|
|
125
|
-
'hide-gutter-border': options.hideStartGutter,
|
|
126
|
-
})}
|
|
127
|
-
></div>
|
|
128
|
-
<div
|
|
129
|
-
class="cell-content"
|
|
130
|
-
style="${this.getContentStyle(f, options.isHeader)}"
|
|
131
|
-
title="${value}"
|
|
132
|
-
>
|
|
133
|
-
${value}
|
|
134
|
-
</div>
|
|
135
|
-
<div
|
|
136
|
-
class=${(0, class_map_js_1.classMap)({
|
|
137
|
-
'cell-gutter': true,
|
|
138
|
-
'hide-gutter-border': options.hideEndGutter,
|
|
139
|
-
})}
|
|
140
|
-
></div>
|
|
141
|
-
</div>`;
|
|
142
|
-
}
|
|
143
|
-
renderFieldContent(row, f) {
|
|
144
|
-
var _a;
|
|
145
|
-
const renderAs = (0, util_1.shouldRenderAs)(f);
|
|
146
|
-
// Render nested tables without gutters
|
|
147
|
-
if (renderAs === 'table') {
|
|
148
|
-
return (0, lit_1.html) `<malloy-table
|
|
149
|
-
.data=${row.cell(f)}
|
|
150
|
-
.pinnedHeader=${(_a = this.pinnedHeader) !== null && _a !== void 0 ? _a : false}
|
|
151
|
-
.rowLimit=${this.pinnedHeader ? 1 : Infinity}
|
|
152
|
-
></malloy-table>`;
|
|
153
|
-
}
|
|
154
|
-
const resultCellValue = row.cell(f).value;
|
|
155
|
-
let renderValue = '';
|
|
156
|
-
if (this.pinnedHeader)
|
|
157
|
-
renderValue = '';
|
|
158
|
-
else if (renderAs === 'bar-chart') {
|
|
159
|
-
renderValue = (0, lit_1.html) `<malloy-bar-chart
|
|
160
|
-
.data=${row.cell(f)}
|
|
161
|
-
></malloy-bar-chart>`;
|
|
162
|
-
}
|
|
163
|
-
else if ((0, util_1.valueIsNumber)(f, resultCellValue)) {
|
|
164
|
-
// TS doesn't support typeguards for multiple parameters, so unfortunately have to assert AtomicField here. https://github.com/microsoft/TypeScript/issues/26916
|
|
165
|
-
renderValue = (0, render_numeric_field_1.renderNumericField)(f, resultCellValue);
|
|
166
|
-
}
|
|
167
|
-
else if (resultCellValue === null) {
|
|
168
|
-
renderValue = '∅';
|
|
169
|
-
}
|
|
170
|
-
else if ((0, util_1.valueIsString)(f, resultCellValue)) {
|
|
171
|
-
renderValue = resultCellValue;
|
|
172
|
-
}
|
|
173
|
-
return this.renderCell(f, renderValue, {
|
|
174
|
-
hideStartGutter: (0, util_1.isFirstChild)(f),
|
|
175
|
-
hideEndGutter: (0, util_1.isLastChild)(f),
|
|
176
|
-
isHeader: false,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
willUpdate(changedProperties) {
|
|
180
|
-
if (this.ctx.root && changedProperties.has('data')) {
|
|
181
|
-
this.ctx.layout = (0, table_layout_1.getTableLayout)(this.metadata);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
render() {
|
|
185
|
-
const fields = this.data.field.allFields;
|
|
186
|
-
const headers = fields.map(f => this.renderHeader(f));
|
|
187
|
-
const rows = [];
|
|
188
|
-
let i = 0;
|
|
189
|
-
for (const row of this.data) {
|
|
190
|
-
if (i >= this.rowLimit)
|
|
191
|
-
break;
|
|
192
|
-
rows.push((0, lit_1.html) `<tr>
|
|
193
|
-
${fields.map(f => this.renderField(row, f))}
|
|
194
|
-
</tr>`);
|
|
195
|
-
i++;
|
|
196
|
-
}
|
|
197
|
-
const renderStickyHeader = () => {
|
|
198
|
-
if (this.ctx.root) {
|
|
199
|
-
return (0, lit_1.html) `<div class="sticky-header">
|
|
200
|
-
<div class="sticky-header-content">
|
|
201
|
-
<malloy-table
|
|
202
|
-
class=${(0, class_map_js_1.classMap)({
|
|
203
|
-
'pinned-header': true,
|
|
204
|
-
'scrolled': this._scrolling,
|
|
205
|
-
})}
|
|
206
|
-
.rowLimit=${1}
|
|
207
|
-
.data=${this.data}
|
|
208
|
-
.pinnedHeader=${true}
|
|
209
|
-
></malloy-table>
|
|
210
|
-
</div>
|
|
211
|
-
</div>`;
|
|
212
|
-
}
|
|
213
|
-
return lit_1.nothing;
|
|
214
|
-
};
|
|
215
|
-
return (0, lit_1.html) `<div
|
|
216
|
-
@scroll=${this._handleScroll}
|
|
217
|
-
class="table-wrapper"
|
|
218
|
-
part=${this.ctx.root ? 'table-container' : lit_1.nothing}
|
|
219
|
-
>
|
|
220
|
-
${renderStickyHeader()}
|
|
221
|
-
<table>
|
|
222
|
-
<thead>
|
|
223
|
-
<tr>
|
|
224
|
-
${headers}
|
|
225
|
-
</tr>
|
|
226
|
-
</thead>
|
|
227
|
-
<tbody>
|
|
228
|
-
${rows}
|
|
229
|
-
</tbody>
|
|
230
|
-
</table>
|
|
231
|
-
</div>`;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
exports.Table = Table;
|
|
235
|
-
Table.styles = (0, lit_1.css) `
|
|
236
|
-
.table-wrapper {
|
|
237
|
-
width: 100%;
|
|
238
|
-
height: 100%;
|
|
239
|
-
position: relative;
|
|
240
|
-
overflow: auto;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.sticky-header {
|
|
244
|
-
position: sticky;
|
|
245
|
-
top: 0px;
|
|
246
|
-
z-index: 100;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.sticky-header-content {
|
|
250
|
-
position: absolute;
|
|
251
|
-
top: 0px;
|
|
252
|
-
left: 0px;
|
|
253
|
-
pointer-events: none;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.sticky-header-content th {
|
|
257
|
-
pointer-events: all;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
table {
|
|
261
|
-
border-collapse: collapse;
|
|
262
|
-
background: var(--malloy-render--table-background);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
th {
|
|
266
|
-
transition: background-color 0.25s;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
table * {
|
|
270
|
-
box-sizing: border-box;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.column-cell {
|
|
274
|
-
height: var(--malloy-render--table-row-height);
|
|
275
|
-
overflow: hidden;
|
|
276
|
-
white-space: nowrap;
|
|
277
|
-
text-align: left;
|
|
278
|
-
padding: 0px;
|
|
279
|
-
vertical-align: top;
|
|
280
|
-
position: relative;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
td.column-cell {
|
|
284
|
-
font-weight: var(--malloy-render--table-body-weight);
|
|
285
|
-
color: var(--malloy-render--table-body-color);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
th.column-cell {
|
|
289
|
-
font-weight: var(--malloy-render--table-header-weight);
|
|
290
|
-
color: var(--malloy-render--table-header-color);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.column-cell.numeric {
|
|
294
|
-
text-align: right;
|
|
295
|
-
font-variant-numeric: tabular-nums;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.cell-wrapper {
|
|
299
|
-
// height: var(--malloy-render--table-row-height);
|
|
300
|
-
display: flex;
|
|
301
|
-
align-items: start;
|
|
302
|
-
overflow: hidden;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.cell-content {
|
|
306
|
-
border-top: var(--malloy-render--table-border);
|
|
307
|
-
height: 100%;
|
|
308
|
-
line-height: var(--malloy-render--table-row-height);
|
|
309
|
-
flex: 1;
|
|
310
|
-
overflow: hidden;
|
|
311
|
-
text-overflow: ellipsis;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.cell-gutter {
|
|
315
|
-
border-top: var(--malloy-render--table-border);
|
|
316
|
-
height: var(--malloy-render--table-row-height);
|
|
317
|
-
width: var(--malloy-render--table-gutter-size);
|
|
318
|
-
transition: border-color 0.25s;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.cell-gutter.hide-gutter-border {
|
|
322
|
-
border-color: transparent;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
.pinned-header table {
|
|
326
|
-
background: transparent;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
.pinned-header th {
|
|
330
|
-
background: var(--malloy-render--table-background);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
.pinned-header.scrolled th {
|
|
334
|
-
background: var(--malloy-render--table-pinned-background);
|
|
335
|
-
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.5);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.pinned-header.scrolled {
|
|
339
|
-
.cell-content,
|
|
340
|
-
.cell-gutter,
|
|
341
|
-
.cell-gutter.hide-gutter-border {
|
|
342
|
-
border-top: var(--malloy-render--table-pinned-border);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
`;
|
|
346
|
-
__decorate([
|
|
347
|
-
(0, decorators_js_1.property)({ attribute: false })
|
|
348
|
-
], Table.prototype, "data", void 0);
|
|
349
|
-
__decorate([
|
|
350
|
-
(0, decorators_js_1.property)({ type: Number })
|
|
351
|
-
], Table.prototype, "rowLimit", void 0);
|
|
352
|
-
__decorate([
|
|
353
|
-
(0, decorators_js_1.property)({ type: Boolean })
|
|
354
|
-
], Table.prototype, "pinnedHeader", void 0);
|
|
355
|
-
__decorate([
|
|
356
|
-
(0, decorators_js_1.state)()
|
|
357
|
-
], Table.prototype, "_scrolling", void 0);
|
|
358
|
-
__decorate([
|
|
359
|
-
(0, context_1.consume)({ context: tableContext }),
|
|
360
|
-
(0, decorators_js_1.property)({ attribute: false })
|
|
361
|
-
], Table.prototype, "parentCtx", void 0);
|
|
362
|
-
__decorate([
|
|
363
|
-
(0, context_1.provide)({ context: tableContext })
|
|
364
|
-
], Table.prototype, "ctx", void 0);
|
|
365
|
-
__decorate([
|
|
366
|
-
(0, context_1.consume)({ context: result_context_1.resultContext }),
|
|
367
|
-
(0, decorators_js_1.property)({ attribute: false })
|
|
368
|
-
], Table.prototype, "metadata", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
(0, decorators_js_1.eventOptions)({ passive: true })
|
|
371
|
-
], Table.prototype, "_handleScroll", null);
|
|
372
|
-
exports.Table = Table = __decorate([
|
|
373
|
-
(0, decorators_js_1.customElement)('malloy-table')
|
|
374
|
-
], Table);
|
|
375
|
-
//# sourceMappingURL=table.js.map
|