@malloydata/malloy-explorer 0.0.294-dev250630221944 → 0.0.295-dev250710213205

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/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "malloy-samples"]
2
+ path = malloy-samples
3
+ url = git@github.com:malloydata/malloy-samples
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import * as Malloy from "@malloydata/malloy-interfaces";
3
+ import type { DrillData } from "@malloydata/render";
3
4
  import { SearchValueMapResult } from "../contexts/QueryEditorContext";
4
5
  declare export interface MalloyExplorerProviderProps {
5
6
  source: Malloy.SourceInfo;
@@ -9,11 +10,7 @@ declare export interface MalloyExplorerProviderProps {
9
10
  onFocusedNestViewPathChange: (path: string[]) => void;
10
11
  children: ReactNode | ReactNode[];
11
12
  topValues?: SearchValueMapResult[];
12
- onDrill?: ($$param0$: {
13
- stableQuery: Malloy.Query | void,
14
- stableDrillClauses: Malloy.DrillOperation[] | void,
15
- ...
16
- }) => void;
13
+ onDrill?: ($$param0$: DrillData) => void;
17
14
  }
18
15
  declare export function MalloyExplorerProvider(
19
16
  $$param0$: MalloyExplorerProviderProps,
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Development directions
2
2
 
3
+ - Initialize git sub-modules
4
+
5
+ ```
6
+ git submodule init
7
+ git submodule update
8
+ ```
9
+
3
10
  - Install required packages
4
11
 
5
12
  ```
@@ -8010,16 +8010,14 @@ function SelectorToken({
8010
8010
  onValueChange: handleValueChange,
8011
8011
  required: true,
8012
8012
  children: [/* @__PURE__ */ jsxRuntime.jsxs(Trigger$3, {
8013
- ..._stylex.props(tokenStyles.main, styles$H.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], fontStyles.body, tokenStyles.label, customStyle),
8013
+ ..._stylex.props(tokenStyles.main, styles$H.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], customStyle),
8014
8014
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8015
8015
  name: icon,
8016
8016
  customStyle: tokenStyles.icon
8017
8017
  }), /* @__PURE__ */ jsxRuntime.jsx(Value$1, {
8018
8018
  asChild: true,
8019
8019
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
8020
- ...{
8021
- className: "mlyb3r6kr mlylyipyv"
8022
- },
8020
+ ..._stylex.props(fontStyles.body, tokenStyles.label),
8023
8021
  children: label
8024
8022
  })
8025
8023
  })]
@@ -8048,17 +8046,15 @@ function SelectorToken({
8048
8046
  }, 10);
8049
8047
  }
8050
8048
  }
8051
- }), /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
8052
- children: /* @__PURE__ */ jsxRuntime.jsx(Group$1, {
8053
- ...{
8054
- className: "mly78zum5 mlydt5ytf mlyuyqlj2 mlyfawy5m mly195vfkc"
8055
- },
8056
- children: filteredItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, {
8057
- value: item.value,
8058
- selectedValue: value,
8059
- children: item.label
8060
- }, item.value))
8061
- })
8049
+ }), /* @__PURE__ */ jsxRuntime.jsx(Group$1, {
8050
+ ...{
8051
+ className: "mly78zum5 mlydt5ytf mlyuyqlj2 mlyfawy5m mly195vfkc mlyysyzu8"
8052
+ },
8053
+ children: filteredItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, {
8054
+ value: item.value,
8055
+ selectedValue: value,
8056
+ children: item.label
8057
+ }, item.value))
8062
8058
  })]
8063
8059
  })
8064
8060
  })
@@ -26307,19 +26303,22 @@ function DrillOperations({
26307
26303
  ...{
26308
26304
  className: "mly78zum5 mlydt5ytf mly1jnr06f"
26309
26305
  },
26310
- children: drills.map((drill, key2) => /* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
26311
- color: "cyan",
26312
- customStyle: localStyles.tokenGroup,
26313
- children: [/* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
26314
- field: drill.filter.fieldReference.getFieldInfo()
26315
- }), /* @__PURE__ */ jsxRuntime.jsx(Token, {
26316
- label: "="
26317
- }), drill.filter instanceof QB.ASTFilterWithLiteralEquality ? /* @__PURE__ */ jsxRuntime.jsx(LiteralValue, {
26318
- value: drill.filter.value.node
26319
- }) : /* @__PURE__ */ jsxRuntime.jsx(Token, {
26320
- label: drill.filter.filterString
26321
- })]
26322
- }, key2))
26306
+ children: drills.map((drill, key2) => {
26307
+ const field = drill.filter.expression.getFieldInfo();
26308
+ return field ? /* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
26309
+ color: "cyan",
26310
+ customStyle: localStyles.tokenGroup,
26311
+ children: [/* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
26312
+ field
26313
+ }), /* @__PURE__ */ jsxRuntime.jsx(Token, {
26314
+ label: "="
26315
+ }), drill.filter instanceof QB.ASTFilterWithLiteralEquality ? /* @__PURE__ */ jsxRuntime.jsx(LiteralValue, {
26316
+ value: drill.filter.value.node
26317
+ }) : /* @__PURE__ */ jsxRuntime.jsx(Token, {
26318
+ label: drill.filter.filterString
26319
+ })]
26320
+ }, key2) : null;
26321
+ })
26323
26322
  })]
26324
26323
  });
26325
26324
  }
@@ -31993,17 +31992,21 @@ function Visualization$1({
31993
31992
  const renderer = React.useMemo(() => new render.MalloyRenderer(), []);
31994
31993
  const [currentRenderer, setCurrentRenderer] = React.useState("table");
31995
31994
  const [plugin, setPlugin] = React.useState();
31995
+ const [error, setError] = React.useState("");
31996
31996
  const [open, setOpen] = React.useState(false);
31997
+ const tag = view.getTag().toString();
31997
31998
  React.useEffect(() => {
31998
31999
  var _a2;
32000
+ setError("");
31999
32001
  const viz = renderer.createViz({
32000
- onError: (error) => {
32001
- console.error("Malloy render error", error);
32002
+ onError: (error2) => {
32003
+ console.error("Malloy render error", error2);
32004
+ setError(error2.message);
32002
32005
  }
32003
32006
  });
32004
32007
  viz.setResult({
32005
32008
  schema: view.definition.getOutputSchema(),
32006
- annotations: view.getTag().toString().split("\n").map((value) => ({
32009
+ annotations: tag.split("\n").map((value) => ({
32007
32010
  value
32008
32011
  })),
32009
32012
  connection_name: ""
@@ -32011,17 +32014,23 @@ function Visualization$1({
32011
32014
  const metadata = viz.getMetadata();
32012
32015
  if (metadata) {
32013
32016
  const plugin2 = viz.getActivePlugin(metadata.getRootField().key);
32014
- if (plugin2 && render.isCoreVizPluginInstance(plugin2)) {
32015
- setCurrentRenderer(plugin2.name);
32016
- setPlugin(plugin2);
32017
+ if (plugin2) {
32018
+ if (render.isCoreVizPluginInstance(plugin2)) {
32019
+ setCurrentRenderer(plugin2.name);
32020
+ setPlugin(plugin2);
32021
+ return;
32022
+ }
32023
+ if (plugin2.name === "error") {
32024
+ setError(plugin2.getMetadata().message);
32025
+ }
32017
32026
  }
32018
- } else {
32019
- const currentTag = view.getTag();
32020
- const rendererTag = view.getTag(RENDERER_PREFIX);
32021
- const currentRenderer2 = ((_a2 = rendererTag.tag("viz")) == null ? void 0 : _a2.text()) ?? legacyToViz(tagToRenderer(currentTag) ?? "table");
32022
- setCurrentRenderer(currentRenderer2);
32023
32027
  }
32024
- }, [renderer, view]);
32028
+ const currentTag = view.getTag();
32029
+ const rendererTag = view.getTag(RENDERER_PREFIX);
32030
+ const currentRenderer2 = ((_a2 = rendererTag.tag("viz")) == null ? void 0 : _a2.text()) ?? legacyToViz(tagToRenderer(currentTag) ?? "table");
32031
+ setCurrentRenderer(currentRenderer2);
32032
+ setPlugin(void 0);
32033
+ }, [renderer, view, tag]);
32025
32034
  const updateViz = (renderer2) => {
32026
32035
  view.setTagProperty(["viz"], renderer2, RENDERER_PREFIX);
32027
32036
  setQuery == null ? void 0 : setQuery(rootQuery.build());
@@ -32049,6 +32058,13 @@ function Visualization$1({
32049
32058
  tooltip: "Edit Settings..."
32050
32059
  }, "gear"));
32051
32060
  }
32061
+ if (error) {
32062
+ tokens2.push(/* @__PURE__ */ jsxRuntime.jsx(Token, {
32063
+ icon: "warning",
32064
+ tooltip: error,
32065
+ customStyle: styles$o.trigger
32066
+ }));
32067
+ }
32052
32068
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
32053
32069
  children: [/* @__PURE__ */ jsxRuntime.jsx(TokenGroup, {
32054
32070
  customStyle: styles$o.group,
@@ -32618,7 +32634,8 @@ function ValueList({
32618
32634
  fieldPath,
32619
32635
  ref,
32620
32636
  customStyle,
32621
- showPath = true
32637
+ showPath = true,
32638
+ hideNoMatchMessage = false
32622
32639
  }) {
32623
32640
  const {
32624
32641
  searchResults
@@ -32640,7 +32657,7 @@ function ValueList({
32640
32657
  },
32641
32658
  children: value.fieldName
32642
32659
  }) : null]
32643
- }, value.fieldName + ":" + value.fieldValue)) : search ? /* @__PURE__ */ jsxRuntime.jsx("div", {
32660
+ }, value.fieldName + ":" + value.fieldValue)) : search && !hideNoMatchMessage ? /* @__PURE__ */ jsxRuntime.jsx("div", {
32644
32661
  ..._stylex.props(addMenuStyles.item),
32645
32662
  "data-disabled": "true",
32646
32663
  children: "No matching values"
@@ -32835,7 +32852,8 @@ const StringFilterCore = ({
32835
32852
  },
32836
32853
  customStyle: styles$i.valueList,
32837
32854
  showPath: false,
32838
- filter: (value) => !currentFilter.values.includes(value)
32855
+ filter: (value) => !currentFilter.values.includes(value),
32856
+ hideNoMatchMessage: true
32839
32857
  })
32840
32858
  })]
32841
32859
  }) : currentFilter.operator === "~" ? /* @__PURE__ */ jsxRuntime.jsx(StringEditor, {
@@ -34394,24 +34412,39 @@ function SortableOperation({
34394
34412
  id,
34395
34413
  ref: setNodeRef,
34396
34414
  style,
34397
- children: [granular ? /* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
34398
- customStyle: customStyles.tokenGroup,
34399
- children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
34400
- color,
34401
- icon,
34402
- label: fieldInfo.name,
34403
- dragProps: {
34404
- attributes,
34405
- listeners
34415
+ children: [granular ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
34416
+ ...{
34417
+ 0: {
34418
+ className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly11ogjb6 mly1g9of4s"
34419
+ },
34420
+ 1: {
34421
+ className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly1ae5hkt"
34406
34422
  }
34407
- }), /* @__PURE__ */ jsxRuntime.jsx(SelectorToken, {
34408
- color,
34409
- value: granular.value,
34410
- onChange: (granulation) => {
34411
- if (operation.field.expression instanceof QB.ASTTimeTruncationExpression) operation.field.expression.truncation = granulation;
34412
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34423
+ }[!!hoverActionsVisible << 0],
34424
+ children: [/* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
34425
+ customStyle: customStyles.tokenGroup,
34426
+ children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
34427
+ color,
34428
+ icon,
34429
+ label: fieldInfo.name,
34430
+ dragProps: {
34431
+ attributes,
34432
+ listeners
34433
+ }
34434
+ }), /* @__PURE__ */ jsxRuntime.jsx(SelectorToken, {
34435
+ color,
34436
+ value: granular.value,
34437
+ onChange: (granulation) => {
34438
+ if (operation.field.expression instanceof QB.ASTTimeTruncationExpression) operation.field.expression.truncation = granulation;
34439
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
34440
+ },
34441
+ items: granular.options
34442
+ })]
34443
+ }), hoverActions && /* @__PURE__ */ jsxRuntime.jsx("div", {
34444
+ ...{
34445
+ className: "mly2b4tyj mly2lah0s"
34413
34446
  },
34414
- items: granular.options
34447
+ children: hoverActions
34415
34448
  })]
34416
34449
  }) : /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
34417
34450
  field: fieldInfo,
@@ -34769,29 +34802,33 @@ function SingleFilterOperation({
34769
34802
  }
34770
34803
  setQuery == null ? void 0 : setQuery(rootQuery.build());
34771
34804
  }, [filterOperation.filter, rootQuery, setQuery]);
34772
- if (!(filterOperation.filter instanceof QB.ASTFilterWithFilterString)) {
34805
+ const {
34806
+ filter
34807
+ } = filterOperation;
34808
+ if (!(filter instanceof QB.ASTFilterWithFilterString)) {
34773
34809
  return null;
34774
34810
  }
34775
34811
  const {
34776
- fieldReference,
34812
+ expression,
34777
34813
  filterString
34778
- } = filterOperation.filter;
34779
- const filter = filterOperation.filter.getFilter();
34780
- const fieldInfo = fieldReference.getFieldInfo();
34781
- if (fieldInfo.kind !== "dimension" && fieldInfo.kind !== "measure") {
34782
- throw new Error(`Invalid filter field kind: ${fieldInfo.kind}`);
34814
+ } = filter;
34815
+ if (!(expression instanceof QB.ASTReferenceExpression)) {
34816
+ return null;
34783
34817
  }
34818
+ const fieldInfo = filter.getFieldInfo();
34819
+ const parsedFilter = filter.getFilter();
34820
+ const path = expression.path ?? [];
34784
34821
  const {
34785
34822
  op,
34786
34823
  value
34787
- } = parsedToLabels(filter, filterString);
34824
+ } = parsedToLabels(parsedFilter, filterString);
34788
34825
  const label = `${fieldInfo.name} ${op} ${value}`;
34789
34826
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34790
34827
  ..._stylex.props(hoverStyles.main),
34791
34828
  children: [/* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
34792
34829
  fieldInfo,
34793
- path: fieldReference.path ?? [],
34794
- filter,
34830
+ path,
34831
+ filter: parsedFilter,
34795
34832
  setFilter,
34796
34833
  trigger: /* @__PURE__ */ jsxRuntime.jsx(Token, {
34797
34834
  icon: "filter",
@@ -36702,17 +36739,14 @@ function RenderedResult({
36702
36739
  const viz = React.useMemo(() => {
36703
36740
  const renderer = new render.MalloyRenderer();
36704
36741
  const viz2 = renderer.createViz({
36705
- onDrill: ({
36706
- stableQuery,
36707
- stableDrillClauses
36708
- }) => {
36742
+ onDrill: (drillData) => {
36709
36743
  if (onDrill) {
36710
- onDrill({
36711
- stableQuery,
36712
- stableDrillClauses
36713
- });
36744
+ onDrill(drillData);
36714
36745
  return;
36715
36746
  }
36747
+ const {
36748
+ stableQuery
36749
+ } = drillData;
36716
36750
  const rootQuery = new QB.ASTQuery({
36717
36751
  query: stableQuery,
36718
36752
  source