@malloydata/render 0.0.117-dev240110181238 → 0.0.117-dev240110184814

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.
@@ -1,11 +1,14 @@
1
- import { Result, Tag } from '@malloydata/malloy';
1
+ import { ModelDef, QueryResult, Result, Tag } from '@malloydata/malloy';
2
2
  import { LitElement, PropertyValues } from 'lit';
3
3
  import './table';
4
4
  import './bar-chart';
5
5
  import { RenderResultMetadata } from './render-result-metadata';
6
6
  export declare class MalloyRender extends LitElement {
7
7
  static styles: import("lit").CSSResult;
8
- result: Result;
8
+ result?: Result;
9
+ queryResult?: QueryResult;
10
+ modelDef?: ModelDef;
11
+ private _result;
9
12
  metadata: RenderResultMetadata;
10
13
  willUpdate(changedProperties: PropertyValues<this>): void;
11
14
  updateTheme(modelTheme?: Tag, localTheme?: Tag): void;
@@ -29,6 +29,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.MalloyRender = void 0;
32
+ const malloy_1 = require("@malloydata/malloy");
32
33
  const lit_1 = require("lit");
33
34
  const decorators_js_1 = require("lit/decorators.js");
34
35
  require("./table");
@@ -51,10 +52,17 @@ function getThemeValue(prop, ...themes) {
51
52
  }
52
53
  let MalloyRender = class MalloyRender extends lit_1.LitElement {
53
54
  willUpdate(changedProperties) {
54
- if (changedProperties.has('result')) {
55
- this.metadata = (0, render_result_metadata_1.getResultMetadata)(this.result);
56
- const modelTag = this.result.modelTag;
57
- const { tag: resultTag } = this.result.tagParse();
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();
58
66
  const modelTheme = modelTag.tag('theme');
59
67
  const localTheme = resultTag.tag('theme');
60
68
  this.updateTheme(modelTheme, localTheme);
@@ -89,7 +97,7 @@ let MalloyRender = class MalloyRender extends lit_1.LitElement {
89
97
  render() {
90
98
  return (0, lit_1.html) `<malloy-table
91
99
  exportparts="table-container: container"
92
- .data=${this.result.data}
100
+ .data=${this._result.data}
93
101
  ></malloy-table>`;
94
102
  }
95
103
  };
@@ -129,6 +137,15 @@ MalloyRender.styles = (0, lit_1.css) `
129
137
  __decorate([
130
138
  (0, decorators_js_1.property)({ attribute: false })
131
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);
132
149
  __decorate([
133
150
  (0, context_1.provide)({ context: result_context_1.resultContext })
134
151
  ], MalloyRender.prototype, "metadata", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/render",
3
- "version": "0.0.117-dev240110181238",
3
+ "version": "0.0.117-dev240110184814",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@lit/context": "^1.1.0",
27
- "@malloydata/malloy": "^0.0.117-dev240110181238",
27
+ "@malloydata/malloy": "^0.0.117-dev240110184814",
28
28
  "@types/luxon": "^2.4.0",
29
29
  "lit": "^3.0.2",
30
30
  "lodash": "^4.17.20",