@malloydata/malloy-explorer 0.0.282-dev250527225235 → 0.0.282-dev250528154617

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/esm/index.js CHANGED
@@ -17,7 +17,7 @@ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
17
17
  import * as React from "react";
18
18
  import React__default, { useLayoutEffect, useEffect, useMemo, useState, useRef, createElement, useContext, useCallback, createContext, memo, useReducer } from "react";
19
19
  import * as QB from "@malloydata/malloy-query-builder";
20
- import { ASTArrowQueryDefinition, ASTArrowViewDefinition, ASTSegmentViewDefinition, ASTNestViewOperation, ASTRefinementViewDefinition, ASTOrderByViewOperation, ASTGroupByViewOperation, ASTAggregateViewOperation, ASTLimitViewOperation, ASTTimeTruncationExpression, ASTFilterWithFilterString, ASTWhereViewOperation, ASTHavingViewOperation, ASTDrillViewOperation } from "@malloydata/malloy-query-builder";
20
+ import { ASTArrowQueryDefinition, ASTArrowViewDefinition, ASTSegmentViewDefinition, ASTNestViewOperation, ASTRefinementViewDefinition, ASTFilterWithLiteralEquality, ASTOrderByViewOperation, ASTGroupByViewOperation, ASTAggregateViewOperation, ASTLimitViewOperation, ASTTimeTruncationExpression, ASTFilterWithFilterString, ASTWhereViewOperation, ASTHavingViewOperation, ASTDrillViewOperation, ASTQuery } from "@malloydata/malloy-query-builder";
21
21
  import { Tag } from "@malloydata/malloy-tag";
22
22
  import { TemporalFilterExpression, BooleanFilterExpression, NumberFilterExpression, StringFilterExpression } from "@malloydata/malloy-filter";
23
23
  import "@malloydata/render/webcomponent";
@@ -26100,6 +26100,85 @@ const styles$s = {
26100
26100
  $$css: true
26101
26101
  }
26102
26102
  };
26103
+ function LiteralValue({
26104
+ value,
26105
+ customStyle
26106
+ }) {
26107
+ if (!value) {
26108
+ return /* @__PURE__ */ jsx(Token, {
26109
+ label: "∅"
26110
+ });
26111
+ }
26112
+ switch (value.kind) {
26113
+ case "boolean_literal":
26114
+ return /* @__PURE__ */ jsx(Token, {
26115
+ label: value.boolean_value ? "true" : "false",
26116
+ customStyle
26117
+ });
26118
+ case "date_literal":
26119
+ case "timestamp_literal":
26120
+ return /* @__PURE__ */ jsx(Token, {
26121
+ label: "TODO",
26122
+ customStyle
26123
+ });
26124
+ case "null_literal":
26125
+ return /* @__PURE__ */ jsx(Token, {
26126
+ label: "∅"
26127
+ });
26128
+ case "number_literal":
26129
+ return /* @__PURE__ */ jsx(Token, {
26130
+ label: value.number_value.toLocaleString(),
26131
+ customStyle
26132
+ });
26133
+ case "string_literal":
26134
+ return /* @__PURE__ */ jsx(Token, {
26135
+ label: value.string_value,
26136
+ customStyle
26137
+ });
26138
+ case "filter_expression_literal":
26139
+ return /* @__PURE__ */ jsx(Token, {
26140
+ label: value.filter_expression_value,
26141
+ customStyle
26142
+ });
26143
+ }
26144
+ }
26145
+ function DrillOperations({
26146
+ drills
26147
+ }) {
26148
+ if (!drills.length) {
26149
+ return null;
26150
+ }
26151
+ return /* @__PURE__ */ jsxs("div", {
26152
+ children: [/* @__PURE__ */ jsx("div", {
26153
+ ..._stylex.props(styles$s.title),
26154
+ children: "drills"
26155
+ }), /* @__PURE__ */ jsx("div", {
26156
+ ...{
26157
+ className: "mly78zum5 mlydt5ytf mly1jnr06f"
26158
+ },
26159
+ children: drills.map((drill, key2) => /* @__PURE__ */ jsxs(TokenGroup, {
26160
+ color: "cyan",
26161
+ customStyle: localStyles.tokenGroup,
26162
+ children: [/* @__PURE__ */ jsx(Token, {
26163
+ label: drill.filter.fieldReference.name,
26164
+ icon: "filter"
26165
+ }), /* @__PURE__ */ jsx(Token, {
26166
+ label: "="
26167
+ }), drill.filter instanceof ASTFilterWithLiteralEquality ? /* @__PURE__ */ jsx(LiteralValue, {
26168
+ value: drill.filter.value.node
26169
+ }) : /* @__PURE__ */ jsx(Token, {
26170
+ label: drill.filter.filterString
26171
+ })]
26172
+ }, key2))
26173
+ })]
26174
+ });
26175
+ }
26176
+ const localStyles = {
26177
+ tokenGroup: {
26178
+ display: "mly78zum5",
26179
+ $$css: true
26180
+ }
26181
+ };
26103
26182
  function useCombinedRefs() {
26104
26183
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
26105
26184
  refs[_key] = arguments[_key];
@@ -34396,6 +34475,7 @@ function Operations({
34396
34475
  }) {
34397
34476
  const groupBys = [];
34398
34477
  const aggregates = [];
34478
+ const drills = [];
34399
34479
  const filters = [];
34400
34480
  const orderBys = [];
34401
34481
  const nests = [];
@@ -34417,8 +34497,9 @@ function Operations({
34417
34497
  orderBys.push(operation);
34418
34498
  } else if (operation instanceof ASTNestViewOperation) {
34419
34499
  nests.push(operation);
34420
- } else if (operation instanceof ASTDrillViewOperation) ;
34421
- else {
34500
+ } else if (operation instanceof ASTDrillViewOperation) {
34501
+ drills.push(operation);
34502
+ } else {
34422
34503
  limit = operation;
34423
34504
  }
34424
34505
  });
@@ -34436,6 +34517,9 @@ function Operations({
34436
34517
  segment,
34437
34518
  view,
34438
34519
  aggregates
34520
+ }), /* @__PURE__ */ jsx(DrillOperations, {
34521
+ rootQuery,
34522
+ drills
34439
34523
  }), /* @__PURE__ */ jsx(FilterOperations, {
34440
34524
  rootQuery,
34441
34525
  filters
@@ -35458,6 +35542,7 @@ const styles$5 = {
35458
35542
  }
35459
35543
  };
35460
35544
  function ResultDisplay({
35545
+ source,
35461
35546
  query
35462
35547
  }) {
35463
35548
  let displayComponent;
@@ -35491,6 +35576,7 @@ function ResultDisplay({
35491
35576
  break;
35492
35577
  case "finished":
35493
35578
  displayComponent = /* @__PURE__ */ jsx(ResponseDisplay, {
35579
+ source,
35494
35580
  response: query.response
35495
35581
  });
35496
35582
  break;
@@ -35498,6 +35584,7 @@ function ResultDisplay({
35498
35584
  return displayComponent;
35499
35585
  }
35500
35586
  function ResponseDisplay({
35587
+ source,
35501
35588
  response
35502
35589
  }) {
35503
35590
  let messageComponent = null;
@@ -35523,7 +35610,8 @@ function ResponseDisplay({
35523
35610
  children: [(response == null ? void 0 : response.runInfo) && /* @__PURE__ */ jsx(RunInfoHover, {
35524
35611
  runInfo: response.runInfo
35525
35612
  }), messageComponent, (response == null ? void 0 : response.result) && /* @__PURE__ */ jsx(RenderedResult, {
35526
- result: response.result
35613
+ result: response.result,
35614
+ source
35527
35615
  })]
35528
35616
  });
35529
35617
  }
@@ -35566,14 +35654,30 @@ function Banners({
35566
35654
  });
35567
35655
  }
35568
35656
  function RenderedResult({
35569
- result
35657
+ result,
35658
+ source
35570
35659
  }) {
35571
35660
  const [renderer, setRenderer] = useState();
35661
+ const {
35662
+ setQuery
35663
+ } = useContext(QueryEditorContext);
35572
35664
  useEffect(() => {
35573
35665
  const renderer2 = document.createElement("malloy-render");
35574
35666
  renderer2.malloyResult = result;
35667
+ renderer2.onDrill = ({
35668
+ stableQuery
35669
+ }) => {
35670
+ const rootQuery = new ASTQuery({
35671
+ query: stableQuery,
35672
+ source
35673
+ });
35674
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
35675
+ };
35676
+ renderer2.tableConfig = {
35677
+ enableDrill: true
35678
+ };
35575
35679
  setRenderer(renderer2);
35576
- }, [result]);
35680
+ }, [result, source, setQuery]);
35577
35681
  if (renderer) {
35578
35682
  return /* @__PURE__ */ jsx(DOMElement, {
35579
35683
  element: renderer,
@@ -35813,6 +35917,7 @@ function ResultPanel({
35813
35917
  })]
35814
35918
  })]
35815
35919
  }), /* @__PURE__ */ jsx(ResultDisplay, {
35920
+ source,
35816
35921
  query: submittedQuery
35817
35922
  })]
35818
35923
  })