@malloydata/render 0.0.135-dev240325191847 → 0.0.135-dev240326154530
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 +145243 -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/html/dashboard.js
DELETED
|
@@ -1,242 +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.HTMLDashboardRenderer = void 0;
|
|
26
|
-
const drill_1 = require("../drill");
|
|
27
|
-
const container_1 = require("./container");
|
|
28
|
-
const text_1 = require("./text");
|
|
29
|
-
const utils_1 = require("./utils");
|
|
30
|
-
const tags_utils_1 = require("../tags_utils");
|
|
31
|
-
class HTMLDashboardRenderer extends container_1.ContainerRenderer {
|
|
32
|
-
constructor() {
|
|
33
|
-
super(...arguments);
|
|
34
|
-
this.childrenStyleDefaults = {
|
|
35
|
-
size: 'medium',
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
async render(table) {
|
|
39
|
-
if (!table.isArrayOrRecord()) {
|
|
40
|
-
return (0, utils_1.createErrorElement)(this.document, 'Invalid data for dashboard renderer.');
|
|
41
|
-
}
|
|
42
|
-
const fields = table.field.intrinsicFields;
|
|
43
|
-
const dimensions = fields.filter(field => field.isAtomicField() && field.sourceWasDimension());
|
|
44
|
-
const measures = fields.filter(field => !field.isAtomicField() || field.sourceWasMeasureLike());
|
|
45
|
-
const body = this.document.createElement('div');
|
|
46
|
-
for (const row of table) {
|
|
47
|
-
const dimensionsContainer = this.document.createElement('div');
|
|
48
|
-
dimensionsContainer.classList.add('dimensions');
|
|
49
|
-
dimensionsContainer.style.display = 'flex';
|
|
50
|
-
dimensionsContainer.style.flexWrap = 'wrap';
|
|
51
|
-
const rowElement = this.document.createElement('div');
|
|
52
|
-
rowElement.style.position = 'relative';
|
|
53
|
-
for (const field of dimensions) {
|
|
54
|
-
if ((0, tags_utils_1.isFieldHidden)(field)) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const renderer = this.childRenderers[field.name];
|
|
58
|
-
const rendered = await renderer.render(row.cell(field));
|
|
59
|
-
const renderedDimension = this.document.createElement('div');
|
|
60
|
-
renderedDimension.style.cssText = DIMENSION_BOX;
|
|
61
|
-
const dimensionTitle = this.document.createElement('div');
|
|
62
|
-
dimensionTitle.style.cssText = DIMENSION_TITLE;
|
|
63
|
-
dimensionTitle.appendChild(this.document.createTextNode((0, utils_1.formatTitle)(this.options, field, this.options.dataStyles[field.name])));
|
|
64
|
-
const dimensionInner = this.document.createElement('div');
|
|
65
|
-
dimensionInner.style.cssText = VERTICAL_CENTER;
|
|
66
|
-
dimensionInner.appendChild(rendered);
|
|
67
|
-
renderedDimension.appendChild(dimensionTitle);
|
|
68
|
-
renderedDimension.appendChild(dimensionInner);
|
|
69
|
-
dimensionsContainer.appendChild(renderedDimension);
|
|
70
|
-
}
|
|
71
|
-
if (dimensions.length > 0) {
|
|
72
|
-
const rowSeparatorOuter = this.document.createElement('div');
|
|
73
|
-
rowSeparatorOuter.classList.add('row-separator-outer');
|
|
74
|
-
rowSeparatorOuter.style.cssText = ROW_SEPARATOR_OUTER;
|
|
75
|
-
const rowSeparator = this.document.createElement('div');
|
|
76
|
-
rowSeparator.style.cssText = ROW_SEPARATOR;
|
|
77
|
-
rowSeparatorOuter.appendChild(rowSeparator);
|
|
78
|
-
dimensionsContainer.appendChild(rowSeparatorOuter);
|
|
79
|
-
}
|
|
80
|
-
const measuresContainer = this.document.createElement('div');
|
|
81
|
-
measuresContainer.style.cssText = MEASURE_BOXES;
|
|
82
|
-
for (const field of measures) {
|
|
83
|
-
if ((0, tags_utils_1.isFieldHidden)(field)) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const childRenderer = this.childRenderers[field.name];
|
|
87
|
-
await (0, utils_1.yieldTask)();
|
|
88
|
-
const rendered = await childRenderer.render(row.cell(field));
|
|
89
|
-
if (childRenderer instanceof HTMLDashboardRenderer) {
|
|
90
|
-
measuresContainer.appendChild(rendered);
|
|
91
|
-
}
|
|
92
|
-
else if (childRenderer instanceof text_1.HTMLTextRenderer) {
|
|
93
|
-
const measureBox = this.document.createElement('div');
|
|
94
|
-
measureBox.style.cssText = MEASURE_BOX;
|
|
95
|
-
const measureTitle = this.document.createElement('div');
|
|
96
|
-
measureTitle.style.cssText = TITLE;
|
|
97
|
-
measureTitle.appendChild(this.document.createTextNode((0, utils_1.formatTitle)(this.options, field, this.options.dataStyles[field.name])));
|
|
98
|
-
const measureInner = this.document.createElement('div');
|
|
99
|
-
measureInner.style.cssText = VERTICAL_CENTER;
|
|
100
|
-
const innerInner = this.document.createElement('div');
|
|
101
|
-
innerInner.style.cssText = SINGLE_VALUE;
|
|
102
|
-
innerInner.appendChild(rendered);
|
|
103
|
-
measureInner.appendChild(innerInner);
|
|
104
|
-
measureBox.appendChild(measureTitle);
|
|
105
|
-
measureBox.appendChild(measureInner);
|
|
106
|
-
measuresContainer.appendChild(measureBox);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
const measureBox = this.document.createElement('div');
|
|
110
|
-
measureBox.style.cssText = MEASURE_BOX;
|
|
111
|
-
const measureTitle = this.document.createElement('div');
|
|
112
|
-
measureTitle.style.cssText = TITLE;
|
|
113
|
-
measureTitle.appendChild(this.document.createTextNode((0, utils_1.formatTitle)(this.options, field, this.options.dataStyles[field.name])));
|
|
114
|
-
const measureInner = this.document.createElement('div');
|
|
115
|
-
measureInner.style.cssText = VERTICAL_CENTER;
|
|
116
|
-
const innerInner = this.document.createElement('div');
|
|
117
|
-
innerInner.style.cssText = HORIZONTAL_CENTER;
|
|
118
|
-
innerInner.appendChild(rendered);
|
|
119
|
-
measureInner.appendChild(innerInner);
|
|
120
|
-
measureBox.appendChild(measureTitle);
|
|
121
|
-
measureBox.appendChild(measureInner);
|
|
122
|
-
measuresContainer.appendChild(measureBox);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
rowElement.appendChild(dimensionsContainer);
|
|
126
|
-
if (dimensions.length > 0 && this.options.isDrillingEnabled) {
|
|
127
|
-
const drillElement = this.document.createElement('span');
|
|
128
|
-
const drillIcon = (0, utils_1.createDrillIcon)(this.document);
|
|
129
|
-
drillElement.appendChild(drillIcon);
|
|
130
|
-
drillElement.style.cssText =
|
|
131
|
-
'padding: 8px; vertical-align: top; width: 25px; cursor: pointer; position: absolute; top: 5px; right: 5px;';
|
|
132
|
-
drillElement.onclick = () => {
|
|
133
|
-
if (this.options.onDrill) {
|
|
134
|
-
const { drillQuery, drillFilters } = (0, drill_1.getDrillQuery)(row);
|
|
135
|
-
this.options.onDrill(drillQuery, drillIcon, drillFilters);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
rowElement.appendChild(drillElement);
|
|
139
|
-
}
|
|
140
|
-
const dashboardOuter = this.document.createElement('div');
|
|
141
|
-
dashboardOuter.classList.add('dashboard-outer');
|
|
142
|
-
dashboardOuter.style.cssText = DASHBOARD_OUTER;
|
|
143
|
-
if (dimensions.length > 0) {
|
|
144
|
-
const nestIndicator = this.document.createElement('div');
|
|
145
|
-
nestIndicator.style.cssText = NEST_INDICATOR;
|
|
146
|
-
dashboardOuter.appendChild(nestIndicator);
|
|
147
|
-
}
|
|
148
|
-
dashboardOuter.appendChild(measuresContainer);
|
|
149
|
-
rowElement.appendChild(dashboardOuter);
|
|
150
|
-
body.appendChild(rowElement);
|
|
151
|
-
}
|
|
152
|
-
return body;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.HTMLDashboardRenderer = HTMLDashboardRenderer;
|
|
156
|
-
const ROW_SEPARATOR_OUTER = `
|
|
157
|
-
display: flex;
|
|
158
|
-
flex-direction: column;
|
|
159
|
-
justify-content: flex-end;
|
|
160
|
-
flex: 1 0 auto;
|
|
161
|
-
`;
|
|
162
|
-
const DASHBOARD_OUTER = `
|
|
163
|
-
display: flex;
|
|
164
|
-
flex-direction: row;
|
|
165
|
-
font-size: 11px;
|
|
166
|
-
`;
|
|
167
|
-
const NESTING_DIV = `
|
|
168
|
-
background-color: var(--malloy-tile-background-color, #f7f7f7);
|
|
169
|
-
border: 1px solid var(--malloy-border-color, #e9e9e9);
|
|
170
|
-
`;
|
|
171
|
-
const NEST_INDICATOR = `
|
|
172
|
-
${NESTING_DIV}
|
|
173
|
-
min-height: 100%;
|
|
174
|
-
min-width: 11px;
|
|
175
|
-
margin: 6px;
|
|
176
|
-
border-radius: 4px;
|
|
177
|
-
`;
|
|
178
|
-
const ROW_SEPARATOR = `
|
|
179
|
-
${NESTING_DIV}
|
|
180
|
-
min-height: 11px;
|
|
181
|
-
max-height: 11px;
|
|
182
|
-
margin: 6px;
|
|
183
|
-
flex: 1 0 auto;
|
|
184
|
-
border-radius: 4px;
|
|
185
|
-
`;
|
|
186
|
-
const MEASURE_BOXES = `
|
|
187
|
-
display: flex;
|
|
188
|
-
flex-wrap: wrap;
|
|
189
|
-
`;
|
|
190
|
-
const DIMENSION_BOX = `
|
|
191
|
-
background-color: var(--malloy-tile-background-color, #f7f7f7);
|
|
192
|
-
border: 1px solid var(--malloy-border-color, #e9e9e9);
|
|
193
|
-
margin: 6px;
|
|
194
|
-
border-radius: 5px;
|
|
195
|
-
padding: 10px;
|
|
196
|
-
box-shadow: 0 1px 5px 0 var(--malloy-border-color, #f3f3f3);
|
|
197
|
-
`;
|
|
198
|
-
const MEASURE_BOX = `
|
|
199
|
-
margin: 6px;
|
|
200
|
-
border-radius: 5px;
|
|
201
|
-
border: 1px solid var(--malloy-border-color, #e9e9e9);
|
|
202
|
-
padding: 10px;
|
|
203
|
-
flex: 1 0 auto;
|
|
204
|
-
box-shadow: 0 1px 5px 0 var(--malloy-tile-background-color, #f3f3f3);
|
|
205
|
-
max-width: calc(100% - 11px);
|
|
206
|
-
display: flex;
|
|
207
|
-
flex-direction: column;
|
|
208
|
-
overflow: hidden;
|
|
209
|
-
`;
|
|
210
|
-
const DIMENSION_TITLE = `
|
|
211
|
-
font-size: 12px;
|
|
212
|
-
font-weight: 500;
|
|
213
|
-
color: var(--malloy-title-color, #505050);
|
|
214
|
-
margin-bottom: 5px;
|
|
215
|
-
font-family: var(--malloy-font-family, "Roboto");
|
|
216
|
-
`;
|
|
217
|
-
const TITLE = `
|
|
218
|
-
font-size: 11px;
|
|
219
|
-
font-family: var(--malloy-font-family, "Roboto");
|
|
220
|
-
font-weight: 500;
|
|
221
|
-
color: #var(--malloy-title-color, #505050);
|
|
222
|
-
`;
|
|
223
|
-
const SINGLE_VALUE = `
|
|
224
|
-
font-size: 20px;
|
|
225
|
-
display: flex;
|
|
226
|
-
justify-content: center;
|
|
227
|
-
align-items: center;
|
|
228
|
-
margin-top: 5px;
|
|
229
|
-
`;
|
|
230
|
-
const VERTICAL_CENTER = `
|
|
231
|
-
display: flex;
|
|
232
|
-
flex-direction: column;
|
|
233
|
-
justify-content: center;
|
|
234
|
-
flex: 1 0 auto;
|
|
235
|
-
`;
|
|
236
|
-
const HORIZONTAL_CENTER = `
|
|
237
|
-
display: flex;
|
|
238
|
-
justify-content: center;
|
|
239
|
-
align-items: center;
|
|
240
|
-
flex-direction: column;
|
|
241
|
-
`;
|
|
242
|
-
//# sourceMappingURL=dashboard.js.map
|
package/dist/html/data_volume.js
DELETED
|
@@ -1,94 +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 _a;
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.DataVolumeRendererFactory = exports.HTMLDataVolumeRenderer = void 0;
|
|
27
|
-
const text_1 = require("./text");
|
|
28
|
-
const data_styles_1 = require("../data_styles");
|
|
29
|
-
const renderer_factory_1 = require("../renderer_factory");
|
|
30
|
-
class HTMLDataVolumeRenderer extends text_1.HTMLTextRenderer {
|
|
31
|
-
constructor(document, options) {
|
|
32
|
-
super(document);
|
|
33
|
-
this.options = options;
|
|
34
|
-
}
|
|
35
|
-
getText(data) {
|
|
36
|
-
if (data.isNull()) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
if (!data.isNumber()) {
|
|
40
|
-
throw new Error(`Cannot format field ${data.field.name} as data volume since its not a number`);
|
|
41
|
-
}
|
|
42
|
-
let data_volume = data.number.value;
|
|
43
|
-
let unit = 'Bytes';
|
|
44
|
-
switch (this.options.data_volume_unit) {
|
|
45
|
-
case data_styles_1.DataVolumeUnit.Bytes:
|
|
46
|
-
// Do nothing.
|
|
47
|
-
break;
|
|
48
|
-
case data_styles_1.DataVolumeUnit.Kilobytes:
|
|
49
|
-
data_volume = data_volume / _a.kbMultiplier;
|
|
50
|
-
unit = 'KB';
|
|
51
|
-
break;
|
|
52
|
-
case data_styles_1.DataVolumeUnit.Megabytes:
|
|
53
|
-
data_volume = data_volume / _a.mbMultiplier;
|
|
54
|
-
unit = 'MB';
|
|
55
|
-
break;
|
|
56
|
-
case data_styles_1.DataVolumeUnit.Gigabytes:
|
|
57
|
-
data_volume = data_volume / _a.gbMultiplier;
|
|
58
|
-
unit = 'GB';
|
|
59
|
-
break;
|
|
60
|
-
case data_styles_1.DataVolumeUnit.Terabytes:
|
|
61
|
-
data_volume = data_volume / _a.tbMultiplier;
|
|
62
|
-
unit = 'TB';
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
return data_volume === null
|
|
66
|
-
? data_volume
|
|
67
|
-
: `${data_volume.toLocaleString()} ${unit}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.HTMLDataVolumeRenderer = HTMLDataVolumeRenderer;
|
|
71
|
-
_a = HTMLDataVolumeRenderer;
|
|
72
|
-
HTMLDataVolumeRenderer.kbMultiplier = 1024;
|
|
73
|
-
HTMLDataVolumeRenderer.mbMultiplier = _a.kbMultiplier * _a.kbMultiplier;
|
|
74
|
-
HTMLDataVolumeRenderer.gbMultiplier = _a.mbMultiplier * _a.kbMultiplier;
|
|
75
|
-
HTMLDataVolumeRenderer.tbMultiplier = _a.gbMultiplier * _a.kbMultiplier;
|
|
76
|
-
class DataVolumeRendererFactory extends renderer_factory_1.RendererFactory {
|
|
77
|
-
constructor() {
|
|
78
|
-
super();
|
|
79
|
-
this.addExtractor((options, tag) => {
|
|
80
|
-
var _b;
|
|
81
|
-
options.data_volume_unit =
|
|
82
|
-
(_b = tag === null || tag === void 0 ? void 0 : tag.text()) !== null && _b !== void 0 ? _b : data_styles_1.DataVolumeUnit.Bytes;
|
|
83
|
-
}, this.rendererName);
|
|
84
|
-
}
|
|
85
|
-
create(document, _styleDefaults, _rendererOptions, _field, options) {
|
|
86
|
-
return new HTMLDataVolumeRenderer(document, options);
|
|
87
|
-
}
|
|
88
|
-
get rendererName() {
|
|
89
|
-
return 'data_volume';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.DataVolumeRendererFactory = DataVolumeRendererFactory;
|
|
93
|
-
DataVolumeRendererFactory.instance = new DataVolumeRendererFactory();
|
|
94
|
-
//# sourceMappingURL=data_volume.js.map
|
package/dist/html/date.js
DELETED
|
@@ -1,66 +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.DateRendererFactory = exports.HTMLDateRenderer = void 0;
|
|
26
|
-
const malloy_1 = require("@malloydata/malloy");
|
|
27
|
-
const utils_1 = require("./utils");
|
|
28
|
-
const renderer_factory_1 = require("../renderer_factory");
|
|
29
|
-
class HTMLDateRenderer {
|
|
30
|
-
constructor(document, queryTimezone) {
|
|
31
|
-
this.document = document;
|
|
32
|
-
this.queryTimezone = queryTimezone;
|
|
33
|
-
}
|
|
34
|
-
async render(data) {
|
|
35
|
-
if (data.isNull()) {
|
|
36
|
-
return (0, utils_1.createNullElement)(this.document);
|
|
37
|
-
}
|
|
38
|
-
if (!data.isDate() && !data.isTimestamp()) {
|
|
39
|
-
return (0, utils_1.createErrorElement)(this.document, 'Invalid field for date renderer');
|
|
40
|
-
}
|
|
41
|
-
const timeframe = data.field.timeframe ||
|
|
42
|
-
(data.isTimestamp() ? malloy_1.TimestampTimeframe.Second : malloy_1.DateTimeframe.Day);
|
|
43
|
-
const timestring = (0, utils_1.timeToString)(data.value, timeframe, this.queryTimezone);
|
|
44
|
-
const element = this.document.createElement('span');
|
|
45
|
-
element.appendChild(this.document.createTextNode(timestring));
|
|
46
|
-
return element;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.HTMLDateRenderer = HTMLDateRenderer;
|
|
50
|
-
class DateRendererFactory extends renderer_factory_1.RendererFactory {
|
|
51
|
-
activates(field) {
|
|
52
|
-
return (field.hasParentExplore() &&
|
|
53
|
-
field.isAtomicField() &&
|
|
54
|
-
(field.type === malloy_1.AtomicFieldType.Date ||
|
|
55
|
-
field.type === malloy_1.AtomicFieldType.Timestamp));
|
|
56
|
-
}
|
|
57
|
-
create(document, _styleDefaults, _rendererOptions, _field, _options, timezone) {
|
|
58
|
-
return new HTMLDateRenderer(document, timezone);
|
|
59
|
-
}
|
|
60
|
-
get rendererName() {
|
|
61
|
-
return 'time';
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.DateRendererFactory = DateRendererFactory;
|
|
65
|
-
DateRendererFactory.instance = new DateRendererFactory();
|
|
66
|
-
//# sourceMappingURL=date.js.map
|
package/dist/html/duration.js
DELETED
|
@@ -1,108 +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.DurationRendererFactory = exports.HTMLDurationRenderer = void 0;
|
|
26
|
-
const text_1 = require("./text");
|
|
27
|
-
const data_styles_1 = require("../data_styles");
|
|
28
|
-
const renderer_factory_1 = require("../renderer_factory");
|
|
29
|
-
class HTMLDurationRenderer extends text_1.HTMLTextRenderer {
|
|
30
|
-
constructor(document, options) {
|
|
31
|
-
super(document);
|
|
32
|
-
this.options = options;
|
|
33
|
-
}
|
|
34
|
-
getText(data) {
|
|
35
|
-
var _a;
|
|
36
|
-
if (data.isNull()) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
if (!data.isNumber()) {
|
|
40
|
-
throw new Error(`Cannot format field ${data.field.name} as a duration unit since its not a number`);
|
|
41
|
-
}
|
|
42
|
-
const targetUnit = (_a = this.options.duration_unit) !== null && _a !== void 0 ? _a : data_styles_1.DurationUnit.Seconds;
|
|
43
|
-
let currentDuration = data.number.value;
|
|
44
|
-
let currentUnitValue = 0;
|
|
45
|
-
let durationParts = [];
|
|
46
|
-
let foundUnit = false;
|
|
47
|
-
for (const [unit, multiplier] of HTMLDurationRenderer.multiplierMap) {
|
|
48
|
-
if (unit === targetUnit) {
|
|
49
|
-
foundUnit = true;
|
|
50
|
-
}
|
|
51
|
-
if (!foundUnit) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
currentUnitValue = currentDuration % multiplier;
|
|
55
|
-
currentDuration = Math.floor((currentDuration /= multiplier));
|
|
56
|
-
if (currentUnitValue > 0) {
|
|
57
|
-
durationParts = [
|
|
58
|
-
this.formatTimeUnit(currentUnitValue, unit),
|
|
59
|
-
...durationParts,
|
|
60
|
-
];
|
|
61
|
-
}
|
|
62
|
-
if (currentDuration === 0) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (durationParts.length > 0) {
|
|
67
|
-
return durationParts.slice(0, 2).join(' ');
|
|
68
|
-
}
|
|
69
|
-
return this.formatTimeUnit(0, targetUnit);
|
|
70
|
-
}
|
|
71
|
-
formatTimeUnit(value, unit) {
|
|
72
|
-
let unitString = unit.toString();
|
|
73
|
-
if (value === 1) {
|
|
74
|
-
unitString = unitString.substring(0, unitString.length - 1);
|
|
75
|
-
}
|
|
76
|
-
return `${value} ${unitString}`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.HTMLDurationRenderer = HTMLDurationRenderer;
|
|
80
|
-
// Map of unit to how many units of the make up the following time unit.
|
|
81
|
-
HTMLDurationRenderer.multiplierMap = new Map([
|
|
82
|
-
[data_styles_1.DurationUnit.Nanoseconds, 1000],
|
|
83
|
-
[data_styles_1.DurationUnit.Microseconds, 1000],
|
|
84
|
-
[data_styles_1.DurationUnit.Milliseconds, 1000],
|
|
85
|
-
[data_styles_1.DurationUnit.Seconds, 60],
|
|
86
|
-
[data_styles_1.DurationUnit.Minutes, 60],
|
|
87
|
-
[data_styles_1.DurationUnit.Hours, 24],
|
|
88
|
-
[data_styles_1.DurationUnit.Days, Number.MAX_VALUE],
|
|
89
|
-
]);
|
|
90
|
-
class DurationRendererFactory extends renderer_factory_1.RendererFactory {
|
|
91
|
-
constructor() {
|
|
92
|
-
super();
|
|
93
|
-
this.addExtractor((options, value) => {
|
|
94
|
-
var _a;
|
|
95
|
-
options.duration_unit =
|
|
96
|
-
(_a = value === null || value === void 0 ? void 0 : value.text()) !== null && _a !== void 0 ? _a : data_styles_1.DurationUnit.Seconds;
|
|
97
|
-
}, this.rendererName);
|
|
98
|
-
}
|
|
99
|
-
create(document, _styleDefaults, _rendererOptions, _field, options) {
|
|
100
|
-
return new HTMLDurationRenderer(document, options);
|
|
101
|
-
}
|
|
102
|
-
get rendererName() {
|
|
103
|
-
return 'duration';
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.DurationRendererFactory = DurationRendererFactory;
|
|
107
|
-
DurationRendererFactory.instance = new DurationRendererFactory();
|
|
108
|
-
//# sourceMappingURL=duration.js.map
|