@malloydata/malloy-explorer 0.0.282-dev250527225235 → 0.0.284-dev250528183401

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.
@@ -26118,6 +26118,186 @@ const styles$s = {
26118
26118
  $$css: true
26119
26119
  }
26120
26120
  };
26121
+ function LiteralValue({
26122
+ value,
26123
+ customStyle
26124
+ }) {
26125
+ if (!value) {
26126
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26127
+ label: "∅"
26128
+ });
26129
+ }
26130
+ switch (value.kind) {
26131
+ case "boolean_literal":
26132
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26133
+ label: value.boolean_value ? "true" : "false",
26134
+ customStyle
26135
+ });
26136
+ case "date_literal":
26137
+ case "timestamp_literal":
26138
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26139
+ label: "TODO",
26140
+ customStyle
26141
+ });
26142
+ case "null_literal":
26143
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26144
+ label: "∅"
26145
+ });
26146
+ case "number_literal":
26147
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26148
+ label: value.number_value.toLocaleString(),
26149
+ customStyle
26150
+ });
26151
+ case "string_literal":
26152
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26153
+ label: value.string_value,
26154
+ customStyle
26155
+ });
26156
+ case "filter_expression_literal":
26157
+ return /* @__PURE__ */ jsxRuntime.jsx(Token, {
26158
+ label: value.filter_expression_value,
26159
+ customStyle
26160
+ });
26161
+ }
26162
+ }
26163
+ const QUERY_RENDERERS = ["table", "bar_chart", "dashboard", "json", "line_chart", "list", "list_detail", "point_map", "scatter_chart", "segment_map", "shape_map", "sparkline"];
26164
+ const ATOMIC_RENDERERS = ["number", "boolean", "currency", "image", "url", "percent", "text", "time"];
26165
+ const RENDERERS = [...QUERY_RENDERERS, ...ATOMIC_RENDERERS];
26166
+ function tagToRenderer(tag) {
26167
+ if (tag) {
26168
+ const tagProps = tag.getProperties();
26169
+ const tags = Object.keys(tagProps);
26170
+ for (const tag2 of tags) {
26171
+ if (RENDERERS.includes(tag2) && !tagProps[tag2].deleted) {
26172
+ return tag2;
26173
+ }
26174
+ }
26175
+ }
26176
+ return null;
26177
+ }
26178
+ function atomicTypeToIcon(type) {
26179
+ return atomicTypeMap[type];
26180
+ }
26181
+ function fieldKindToColor(kind) {
26182
+ return fieldKindMap[kind];
26183
+ }
26184
+ function fieldToIcon(field) {
26185
+ let icon;
26186
+ switch (field.kind) {
26187
+ case "view":
26188
+ icon = "query";
26189
+ break;
26190
+ case "dimension":
26191
+ case "measure":
26192
+ icon = atomicTypeToIcon(field.type.kind);
26193
+ break;
26194
+ case "join":
26195
+ icon = relationshipToIcon(field.relationship);
26196
+ break;
26197
+ }
26198
+ return icon;
26199
+ }
26200
+ function relationshipToIcon(relationship) {
26201
+ return relationshipMap[relationship];
26202
+ }
26203
+ function viewToVisualizationIcon(view) {
26204
+ const currentTag = view.getTag();
26205
+ const currentRenderer = tagToRenderer(currentTag) ?? "table";
26206
+ return `viz_${currentRenderer}`;
26207
+ }
26208
+ const atomicTypeMap = {
26209
+ array_type: "array",
26210
+ string_type: "string",
26211
+ date_type: "date",
26212
+ boolean_type: "boolean",
26213
+ number_type: "number",
26214
+ json_type: "json",
26215
+ record_type: "json",
26216
+ sql_native_type: "sql_native",
26217
+ timestamp_type: "date",
26218
+ filter_expression_type: "filter"
26219
+ };
26220
+ const fieldKindMap = {
26221
+ view: "purple",
26222
+ dimension: "cyan",
26223
+ measure: "green",
26224
+ join: void 0
26225
+ };
26226
+ const relationshipMap = {
26227
+ many: "many_to_one",
26228
+ cross: "one_to_many",
26229
+ one: "one_to_one"
26230
+ };
26231
+ function FieldToken({
26232
+ field,
26233
+ hoverActions,
26234
+ hoverActionsVisible,
26235
+ ...props2
26236
+ }) {
26237
+ let label = field.name;
26238
+ if (field.kind === "dimension" && (field.type.kind === "timestamp_type" || field.type.kind === "date_type")) {
26239
+ if (field.type.timeframe) {
26240
+ label += `.${field.type.timeframe}`;
26241
+ }
26242
+ }
26243
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
26244
+ ...{
26245
+ 0: {
26246
+ className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly28fmrt mly1x0xcia"
26247
+ },
26248
+ 1: {
26249
+ className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mlym9y5t7"
26250
+ }
26251
+ }[!!hoverActionsVisible << 0],
26252
+ children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
26253
+ label,
26254
+ color: fieldKindToColor(field.kind),
26255
+ icon: fieldToIcon(field),
26256
+ ...props2
26257
+ }), hoverActions && /* @__PURE__ */ jsxRuntime.jsx("div", {
26258
+ ...{
26259
+ className: "mly1vsucm1 mly2lah0s"
26260
+ },
26261
+ children: hoverActions
26262
+ })]
26263
+ });
26264
+ }
26265
+ function DrillOperations({
26266
+ drills
26267
+ }) {
26268
+ if (!drills.length) {
26269
+ return null;
26270
+ }
26271
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
26272
+ children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
26273
+ ..._stylex.props(styles$s.title),
26274
+ children: "drills"
26275
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
26276
+ ...{
26277
+ className: "mly78zum5 mlydt5ytf mly1jnr06f"
26278
+ },
26279
+ children: drills.map((drill, key2) => /* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
26280
+ color: "cyan",
26281
+ customStyle: localStyles.tokenGroup,
26282
+ children: [/* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
26283
+ field: drill.filter.fieldReference.getFieldInfo()
26284
+ }), /* @__PURE__ */ jsxRuntime.jsx(Token, {
26285
+ label: "="
26286
+ }), drill.filter instanceof QB.ASTFilterWithLiteralEquality ? /* @__PURE__ */ jsxRuntime.jsx(LiteralValue, {
26287
+ value: drill.filter.value.node
26288
+ }) : /* @__PURE__ */ jsxRuntime.jsx(Token, {
26289
+ label: drill.filter.filterString
26290
+ })]
26291
+ }, key2))
26292
+ })]
26293
+ });
26294
+ }
26295
+ const localStyles = {
26296
+ tokenGroup: {
26297
+ display: "mly78zum5",
26298
+ $$css: true
26299
+ }
26300
+ };
26121
26301
  function useCombinedRefs() {
26122
26302
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
26123
26303
  refs[_key] = arguments[_key];
@@ -30054,108 +30234,6 @@ function findUniqueFieldName(fields, rename, path = []) {
30054
30234
  }
30055
30235
  return `${rename} ${idx}`;
30056
30236
  }
30057
- const QUERY_RENDERERS = ["table", "bar_chart", "dashboard", "json", "line_chart", "list", "list_detail", "point_map", "scatter_chart", "segment_map", "shape_map", "sparkline"];
30058
- const ATOMIC_RENDERERS = ["number", "boolean", "currency", "image", "url", "percent", "text", "time"];
30059
- const RENDERERS = [...QUERY_RENDERERS, ...ATOMIC_RENDERERS];
30060
- function tagToRenderer(tag) {
30061
- if (tag) {
30062
- const tagProps = tag.getProperties();
30063
- const tags = Object.keys(tagProps);
30064
- for (const tag2 of tags) {
30065
- if (RENDERERS.includes(tag2) && !tagProps[tag2].deleted) {
30066
- return tag2;
30067
- }
30068
- }
30069
- }
30070
- return null;
30071
- }
30072
- function atomicTypeToIcon(type) {
30073
- return atomicTypeMap[type];
30074
- }
30075
- function fieldKindToColor(kind) {
30076
- return fieldKindMap[kind];
30077
- }
30078
- function fieldToIcon(field) {
30079
- let icon;
30080
- switch (field.kind) {
30081
- case "view":
30082
- icon = "query";
30083
- break;
30084
- case "dimension":
30085
- case "measure":
30086
- icon = atomicTypeToIcon(field.type.kind);
30087
- break;
30088
- case "join":
30089
- icon = relationshipToIcon(field.relationship);
30090
- break;
30091
- }
30092
- return icon;
30093
- }
30094
- function relationshipToIcon(relationship) {
30095
- return relationshipMap[relationship];
30096
- }
30097
- function viewToVisualizationIcon(view) {
30098
- const currentTag = view.getTag();
30099
- const currentRenderer = tagToRenderer(currentTag) ?? "table";
30100
- return `viz_${currentRenderer}`;
30101
- }
30102
- const atomicTypeMap = {
30103
- array_type: "array",
30104
- string_type: "string",
30105
- date_type: "date",
30106
- boolean_type: "boolean",
30107
- number_type: "number",
30108
- json_type: "json",
30109
- record_type: "json",
30110
- sql_native_type: "sql_native",
30111
- timestamp_type: "date",
30112
- filter_expression_type: "filter"
30113
- };
30114
- const fieldKindMap = {
30115
- view: "purple",
30116
- dimension: "cyan",
30117
- measure: "green",
30118
- join: void 0
30119
- };
30120
- const relationshipMap = {
30121
- many: "many_to_one",
30122
- cross: "one_to_many",
30123
- one: "one_to_one"
30124
- };
30125
- function FieldToken({
30126
- field,
30127
- hoverActions,
30128
- hoverActionsVisible,
30129
- ...props2
30130
- }) {
30131
- let label = field.name;
30132
- if (field.kind === "dimension" && (field.type.kind === "timestamp_type" || field.type.kind === "date_type")) {
30133
- if (field.type.timeframe) {
30134
- label += `.${field.type.timeframe}`;
30135
- }
30136
- }
30137
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
30138
- ...{
30139
- 0: {
30140
- className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly28fmrt mly1x0xcia"
30141
- },
30142
- 1: {
30143
- className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mlym9y5t7"
30144
- }
30145
- }[!!hoverActionsVisible << 0],
30146
- children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
30147
- label,
30148
- color: fieldKindToColor(field.kind),
30149
- icon: fieldToIcon(field),
30150
- ...props2
30151
- }), hoverActions && /* @__PURE__ */ jsxRuntime.jsx("div", {
30152
- ...{
30153
- className: "mly1vsucm1 mly2lah0s"
30154
- },
30155
- children: hoverActions
30156
- })]
30157
- });
30158
- }
30159
30237
  function BadgeForField({
30160
30238
  field
30161
30239
  }) {
@@ -34414,6 +34492,7 @@ function Operations({
34414
34492
  }) {
34415
34493
  const groupBys = [];
34416
34494
  const aggregates = [];
34495
+ const drills = [];
34417
34496
  const filters = [];
34418
34497
  const orderBys = [];
34419
34498
  const nests = [];
@@ -34435,8 +34514,9 @@ function Operations({
34435
34514
  orderBys.push(operation);
34436
34515
  } else if (operation instanceof QB.ASTNestViewOperation) {
34437
34516
  nests.push(operation);
34438
- } else if (operation instanceof QB.ASTDrillViewOperation) ;
34439
- else {
34517
+ } else if (operation instanceof QB.ASTDrillViewOperation) {
34518
+ drills.push(operation);
34519
+ } else {
34440
34520
  limit = operation;
34441
34521
  }
34442
34522
  });
@@ -34454,6 +34534,9 @@ function Operations({
34454
34534
  segment,
34455
34535
  view,
34456
34536
  aggregates
34537
+ }), /* @__PURE__ */ jsxRuntime.jsx(DrillOperations, {
34538
+ rootQuery,
34539
+ drills
34457
34540
  }), /* @__PURE__ */ jsxRuntime.jsx(FilterOperations, {
34458
34541
  rootQuery,
34459
34542
  filters
@@ -35476,6 +35559,7 @@ const styles$5 = {
35476
35559
  }
35477
35560
  };
35478
35561
  function ResultDisplay({
35562
+ source,
35479
35563
  query
35480
35564
  }) {
35481
35565
  let displayComponent;
@@ -35509,6 +35593,7 @@ function ResultDisplay({
35509
35593
  break;
35510
35594
  case "finished":
35511
35595
  displayComponent = /* @__PURE__ */ jsxRuntime.jsx(ResponseDisplay, {
35596
+ source,
35512
35597
  response: query.response
35513
35598
  });
35514
35599
  break;
@@ -35516,6 +35601,7 @@ function ResultDisplay({
35516
35601
  return displayComponent;
35517
35602
  }
35518
35603
  function ResponseDisplay({
35604
+ source,
35519
35605
  response
35520
35606
  }) {
35521
35607
  let messageComponent = null;
@@ -35541,7 +35627,8 @@ function ResponseDisplay({
35541
35627
  children: [(response == null ? void 0 : response.runInfo) && /* @__PURE__ */ jsxRuntime.jsx(RunInfoHover, {
35542
35628
  runInfo: response.runInfo
35543
35629
  }), messageComponent, (response == null ? void 0 : response.result) && /* @__PURE__ */ jsxRuntime.jsx(RenderedResult, {
35544
- result: response.result
35630
+ result: response.result,
35631
+ source
35545
35632
  })]
35546
35633
  });
35547
35634
  }
@@ -35584,14 +35671,30 @@ function Banners({
35584
35671
  });
35585
35672
  }
35586
35673
  function RenderedResult({
35587
- result
35674
+ result,
35675
+ source
35588
35676
  }) {
35589
35677
  const [renderer, setRenderer] = React.useState();
35678
+ const {
35679
+ setQuery
35680
+ } = React.useContext(QueryEditorContext);
35590
35681
  React.useEffect(() => {
35591
35682
  const renderer2 = document.createElement("malloy-render");
35592
35683
  renderer2.malloyResult = result;
35684
+ renderer2.onDrill = ({
35685
+ stableQuery
35686
+ }) => {
35687
+ const rootQuery = new QB.ASTQuery({
35688
+ query: stableQuery,
35689
+ source
35690
+ });
35691
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
35692
+ };
35693
+ renderer2.tableConfig = {
35694
+ enableDrill: true
35695
+ };
35593
35696
  setRenderer(renderer2);
35594
- }, [result]);
35697
+ }, [result, source, setQuery]);
35595
35698
  if (renderer) {
35596
35699
  return /* @__PURE__ */ jsxRuntime.jsx(DOMElement, {
35597
35700
  element: renderer,
@@ -35831,6 +35934,7 @@ function ResultPanel({
35831
35934
  })]
35832
35935
  })]
35833
35936
  }), /* @__PURE__ */ jsxRuntime.jsx(ResultDisplay, {
35937
+ source,
35834
35938
  query: submittedQuery
35835
35939
  })]
35836
35940
  })