@malloydata/malloy-explorer 0.0.271-dev250506000031 → 0.0.275-dev250512182350

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,9 +17,8 @@ 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, ASTSegmentViewDefinition, ASTRefinementViewDefinition, ASTOrderByViewOperation, ASTLimitViewOperation, ASTNestViewOperation, ASTAggregateViewOperation, ASTGroupByViewOperation, ASTWhereViewOperation, ASTHavingViewOperation, ASTArrowViewDefinition } from "@malloydata/malloy-query-builder";
20
+ import { ASTArrowQueryDefinition, ASTSegmentViewDefinition, ASTRefinementViewDefinition, ASTOrderByViewOperation, ASTLimitViewOperation, ASTNestViewOperation, ASTAggregateViewOperation, ASTGroupByViewOperation, ASTTimeTruncationExpression, ASTWhereViewOperation, ASTHavingViewOperation, ASTArrowViewDefinition } from "@malloydata/malloy-query-builder";
21
21
  import { Tag } from "@malloydata/malloy-tag";
22
- import * as render from "@malloydata/render";
23
22
  import "@malloydata/render/webcomponent";
24
23
  import * as ReactDOM from "react-dom";
25
24
  import ReactDOM__default, { unstable_batchedUpdates, createPortal } from "react-dom";
@@ -8157,6 +8156,82 @@ const styles$D = {
8157
8156
  $$css: true
8158
8157
  }
8159
8158
  };
8159
+ function CollapsiblePanel({
8160
+ title,
8161
+ children,
8162
+ icon,
8163
+ defaultOpen = true,
8164
+ controls,
8165
+ collapsedControls,
8166
+ isFocused = false
8167
+ }) {
8168
+ const [isExpanded, setIsExpanded] = useState(defaultOpen);
8169
+ return /* @__PURE__ */ jsxs("div", {
8170
+ ...{
8171
+ 0: {
8172
+ className: "mlygbc89k mly1sxf85j mly1717udv"
8173
+ },
8174
+ 1: {
8175
+ className: "mly1sxf85j mly1717udv mlybwr872"
8176
+ }
8177
+ }[!!isFocused << 0],
8178
+ children: [/* @__PURE__ */ jsxs("div", {
8179
+ ...{
8180
+ className: "mlyrvj5dj mly1mt1orb mly52fmzj mlylqzeqv mlyfawy5m mly167g77z mly6s0dn4"
8181
+ },
8182
+ children: [/* @__PURE__ */ jsxs("div", {
8183
+ ...{
8184
+ className: "mlyrvj5dj mly1mt1orb mlylqzeqv mly6s0dn4 mly167g77z"
8185
+ },
8186
+ children: [icon && /* @__PURE__ */ jsx(Icon, {
8187
+ name: icon,
8188
+ customStyle: styles$C.icon
8189
+ }), /* @__PURE__ */ jsx("div", {
8190
+ ...{
8191
+ className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp mly117nqv4"
8192
+ },
8193
+ children: title
8194
+ })]
8195
+ }), /* @__PURE__ */ jsxs("div", {
8196
+ ...{
8197
+ className: "mly78zum5"
8198
+ },
8199
+ children: [isExpanded ? /* @__PURE__ */ jsx("div", {
8200
+ ...{
8201
+ className: "mly78zum5 mly6s0dn4 mly1jnr06f"
8202
+ },
8203
+ children: controls
8204
+ }) : /* @__PURE__ */ jsx("div", {
8205
+ ...{
8206
+ className: "mly78zum5 mly6s0dn4 mly1jnr06f"
8207
+ },
8208
+ children: collapsedControls
8209
+ }), /* @__PURE__ */ jsx(Button, {
8210
+ variant: "flat",
8211
+ size: "compact",
8212
+ onClick: () => setIsExpanded(!isExpanded),
8213
+ icon: isExpanded ? "chevronDown" : "chevronRight",
8214
+ tooltip: isExpanded ? "Collapse" : "Expand"
8215
+ })]
8216
+ })]
8217
+ }), /* @__PURE__ */ jsx("div", {
8218
+ ...{
8219
+ 0: {
8220
+ className: "mly1l4tkcb"
8221
+ },
8222
+ 1: {
8223
+ className: "mly1l4tkcb mly1s85apg"
8224
+ }
8225
+ }[!!!isExpanded << 0],
8226
+ children
8227
+ })]
8228
+ });
8229
+ }
8230
+ const styles$C = {
8231
+ icon: {
8232
+ $$css: true
8233
+ }
8234
+ };
8160
8235
  function CollapsibleListItem({
8161
8236
  label,
8162
8237
  sublabel,
@@ -8184,10 +8259,10 @@ function CollapsibleListItem({
8184
8259
  className: "mly78zum5 mlydt5ytf mly1iyjqo2 mlyb3r6kr"
8185
8260
  },
8186
8261
  children: [/* @__PURE__ */ jsx("span", {
8187
- ..._stylex.props(fontStyles.body, styles$C.label),
8262
+ ..._stylex.props(fontStyles.body, styles$B.label),
8188
8263
  children: label
8189
8264
  }), sublabel && /* @__PURE__ */ jsx("span", {
8190
- ..._stylex.props(fontStyles.supporting, styles$C.sublabel),
8265
+ ..._stylex.props(fontStyles.supporting, styles$B.sublabel),
8191
8266
  children: sublabel
8192
8267
  })]
8193
8268
  })]
@@ -8199,7 +8274,7 @@ function CollapsibleListItem({
8199
8274
  })]
8200
8275
  });
8201
8276
  }
8202
- const styles$C = {
8277
+ const styles$B = {
8203
8278
  label: {
8204
8279
  flexGrow: "mly1iyjqo2",
8205
8280
  fontWeight: "mly1xlr1w8",
@@ -19013,7 +19088,7 @@ function Spinner({
19013
19088
  } = SIZES[size2];
19014
19089
  const frameSize = diameter + border * 2;
19015
19090
  return /* @__PURE__ */ jsx("div", {
19016
- ..._stylex.props(styles$B.root, customStyle),
19091
+ ..._stylex.props(styles$A.root, customStyle),
19017
19092
  children: /* @__PURE__ */ jsx("span", {
19018
19093
  "aria-valuetext": "Loading",
19019
19094
  ...{
@@ -19033,7 +19108,7 @@ function Spinner({
19033
19108
  })
19034
19109
  });
19035
19110
  }
19036
- const styles$B = {
19111
+ const styles$A = {
19037
19112
  root: {
19038
19113
  alignItems: "mly6s0dn4",
19039
19114
  display: "mly3nfvp2",
@@ -19496,7 +19571,7 @@ function invalidDate() {
19496
19571
  return this._invalidDate;
19497
19572
  }
19498
19573
  var defaultOrdinal = "%d", defaultDayOfMonthOrdinalParse = /\d{1,2}/;
19499
- function ordinal(number2) {
19574
+ function ordinal$1(number2) {
19500
19575
  return this._ordinal.replace("%d", number2);
19501
19576
  }
19502
19577
  var defaultRelativeTime = {
@@ -22625,7 +22700,7 @@ var proto$1 = Locale.prototype;
22625
22700
  proto$1.calendar = calendar;
22626
22701
  proto$1.longDateFormat = longDateFormat;
22627
22702
  proto$1.invalidDate = invalidDate;
22628
- proto$1.ordinal = ordinal;
22703
+ proto$1.ordinal = ordinal$1;
22629
22704
  proto$1.preparse = preParsePostFormat;
22630
22705
  proto$1.postformat = preParsePostFormat;
22631
22706
  proto$1.relativeTime = relativeTime;
@@ -23431,7 +23506,7 @@ const Popover = ({
23431
23506
  })
23432
23507
  });
23433
23508
  };
23434
- const styles$A = {
23509
+ const styles$z = {
23435
23510
  wrapper: {
23436
23511
  position: "mly1n2onr6",
23437
23512
  $$css: true
@@ -23483,7 +23558,7 @@ const SelectDropdown = ({
23483
23558
  setOpen(false);
23484
23559
  };
23485
23560
  return /* @__PURE__ */ jsxs("div", {
23486
- ..._stylex.props(styles$A.wrapper, customStyle),
23561
+ ..._stylex.props(styles$z.wrapper, customStyle),
23487
23562
  children: [/* @__PURE__ */ jsxs("button", {
23488
23563
  type: "button",
23489
23564
  autoFocus,
@@ -23551,7 +23626,7 @@ function SelectList({
23551
23626
  const [hoveredIndex, setHoveredIndex] = useState(null);
23552
23627
  return /* @__PURE__ */ jsx(ScrollableArea, {
23553
23628
  children: /* @__PURE__ */ jsx("div", {
23554
- ..._stylex.props(styles$A.selectListDiv, customStyle),
23629
+ ..._stylex.props(styles$z.selectListDiv, customStyle),
23555
23630
  children: options.reduce((result, option2, index2) => {
23556
23631
  const isSelected = value !== void 0 && valueEqual(value, option2.value);
23557
23632
  if (option2.divider) {
@@ -23583,8 +23658,8 @@ function SelectList({
23583
23658
  }), /* @__PURE__ */ jsx(Icon, {
23584
23659
  name: "checkmark",
23585
23660
  customStyle: {
23586
- ...styles$A.checkIcon,
23587
- ...isSelected ? styles$A.checkIconSelected : void 0
23661
+ ...styles$z.checkIcon,
23662
+ ...isSelected ? styles$z.checkIconSelected : void 0
23588
23663
  }
23589
23664
  }), /* @__PURE__ */ jsx("span", {
23590
23665
  ...{
@@ -23598,9 +23673,89 @@ function SelectList({
23598
23673
  })
23599
23674
  });
23600
23675
  }
23676
+ const formats = {
23677
+ second: "YYYY-MM-DD HH:mm:ss",
23678
+ minute: "YYYY-MM-DD HH:mm",
23679
+ hour: "YYYY-MM-DD HH:00",
23680
+ day: "YYYY-MM-DD",
23681
+ week: "YYYY-MM-DD-[WK]",
23682
+ month: "YYYY-MM",
23683
+ quarter: "YYYY-[Q]Q",
23684
+ year: "YYYY"
23685
+ };
23686
+ const regexps = {
23687
+ second: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
23688
+ minute: /\d\d\d\d-\d\d-\d\d \d\d:\d\d/,
23689
+ hour: /\d\d\d\d-\d\d-\d\d \d\d:00/,
23690
+ day: /\d\d\d\d-\d\d-\d\d/,
23691
+ week: /\d\d\d\d-\d\d-\d\d-WK/,
23692
+ month: /\d\d\d\d-\d\d/,
23693
+ quarter: /\d\d\d\d-Q\d/,
23694
+ year: /\d\d\d\d/
23695
+ };
23696
+ const DateInput = ({
23697
+ value,
23698
+ setValue,
23699
+ placeholder,
23700
+ autoFocus,
23701
+ units,
23702
+ onFocus,
23703
+ onBlur,
23704
+ isActive,
23705
+ customStyle,
23706
+ forwardRef
23707
+ }) => {
23708
+ const format2 = formats[units];
23709
+ const [tempValue, setTempValue] = useState(hooks.utc(value).format(format2));
23710
+ useEffect(() => {
23711
+ setTempValue(hooks.utc(value).format(format2));
23712
+ }, [value, format2]);
23713
+ return /* @__PURE__ */ jsx("input", {
23714
+ ..._stylex.props(customStyle, isActive ? styles$y.active : null),
23715
+ type: "text",
23716
+ placeholder: placeholder || format2,
23717
+ value: tempValue,
23718
+ onFocus,
23719
+ onBlur,
23720
+ onChange: (event) => {
23721
+ const raw2 = event.target.value;
23722
+ setTempValue(raw2);
23723
+ const regex = regexps[units];
23724
+ if (raw2.match(regex)) {
23725
+ const m = hooks.utc(raw2, format2);
23726
+ if (m.isValid()) {
23727
+ setValue(m.toDate());
23728
+ }
23729
+ }
23730
+ },
23731
+ autoFocus,
23732
+ ref: forwardRef
23733
+ });
23734
+ };
23735
+ function guessUnits(moment2, isDateTime) {
23736
+ if (moment2.moment === "literal") {
23737
+ const {
23738
+ literal
23739
+ } = moment2;
23740
+ for (const unit in regexps) {
23741
+ const temporalUnit = unit;
23742
+ if (literal.match(regexps[temporalUnit])) {
23743
+ return temporalUnit;
23744
+ }
23745
+ }
23746
+ }
23747
+ return isDateTime ? "second" : "day";
23748
+ }
23749
+ const styles$y = {
23750
+ active: {
23751
+ backgroundColor: "mly1vzefiq",
23752
+ $$css: true
23753
+ }
23754
+ };
23601
23755
  function monthName(month) {
23602
23756
  return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][month];
23603
23757
  }
23758
+ const ordinal = Object.keys(formats);
23604
23759
  function DatePicker({
23605
23760
  value,
23606
23761
  setValue,
@@ -23613,6 +23768,13 @@ function DatePicker({
23613
23768
  const calendar2 = getCalendar(date);
23614
23769
  const [pickLevel, setPickLevel] = useState(units);
23615
23770
  const yearBucket = Math.floor(hooks.utc(date).year() / 10) * 10;
23771
+ useEffect(() => {
23772
+ const unitOrd = ordinal.findIndex((unit) => unit === units);
23773
+ const pickOrd = ordinal.findIndex((unit) => unit === pickLevel);
23774
+ if (pickOrd < unitOrd) {
23775
+ setPickLevel(units);
23776
+ }
23777
+ }, [units, pickLevel]);
23616
23778
  useEffect(() => {
23617
23779
  setDate(value);
23618
23780
  }, [value]);
@@ -23696,7 +23858,7 @@ function DatePicker({
23696
23858
  });
23697
23859
  };
23698
23860
  return /* @__PURE__ */ jsxs("div", {
23699
- ..._stylex.props(styles$z.outer, customStyle),
23861
+ ..._stylex.props(styles$x.outer, customStyle),
23700
23862
  ref: forwardRef,
23701
23863
  children: [/* @__PURE__ */ jsxs("div", {
23702
23864
  ...{
@@ -24012,7 +24174,7 @@ function DatePicker({
24012
24174
  })]
24013
24175
  });
24014
24176
  }
24015
- const styles$z = {
24177
+ const styles$x = {
24016
24178
  outer: {
24017
24179
  userSelect: "mly87ps6o",
24018
24180
  fontSize: "mlymhiqyu",
@@ -24098,7 +24260,7 @@ function Banner({
24098
24260
  className: "mly1q4ynmn mlyh8yej3 mly5yr21d mly78zum5 mlydt5ytf mly1kmqopl mly16zck5j"
24099
24261
  },
24100
24262
  children: [/* @__PURE__ */ jsxs("div", {
24101
- ..._stylex.props(styles$y.header, variantColors[variant], children ? styles$y.headerWithContent : null),
24263
+ ..._stylex.props(styles$w.header, variantColors[variant], children ? styles$w.headerWithContent : null),
24102
24264
  children: [/* @__PURE__ */ jsx("div", {
24103
24265
  ...{
24104
24266
  className: "mly1qx5ct2 mly78zum5 mlyl56j7k mly6s0dn4"
@@ -24111,22 +24273,22 @@ function Banner({
24111
24273
  className: "mly78zum5 mlydt5ytf mlyb3r6kr"
24112
24274
  },
24113
24275
  children: [/* @__PURE__ */ jsx("div", {
24114
- ..._stylex.props(styles$y.title, fontStyles.emphasized),
24276
+ ..._stylex.props(styles$w.title, fontStyles.emphasized),
24115
24277
  children: title
24116
24278
  }), /* @__PURE__ */ jsx("div", {
24117
- ..._stylex.props(styles$y.description, fontStyles.supporting),
24279
+ ..._stylex.props(styles$w.description, fontStyles.supporting),
24118
24280
  children: description
24119
24281
  })]
24120
24282
  })]
24121
24283
  }), children && /* @__PURE__ */ jsx("div", {
24122
- ..._stylex.props(styles$y.content, fontStyles.body),
24284
+ ..._stylex.props(styles$w.content, fontStyles.body),
24123
24285
  children: /* @__PURE__ */ jsx(ScrollableArea, {
24124
24286
  children
24125
24287
  })
24126
24288
  })]
24127
24289
  });
24128
24290
  }
24129
- const styles$y = {
24291
+ const styles$w = {
24130
24292
  header: {
24131
24293
  borderRadius: "mly1q4ynmn",
24132
24294
  borderStartStartRadius: null,
@@ -24268,14 +24430,14 @@ function AccordionList({
24268
24430
  onExpandedItemChange: handleExpandedItemChange
24269
24431
  },
24270
24432
  children: /* @__PURE__ */ jsx("div", {
24271
- ..._stylex.props(styles$x.main, customStyle),
24433
+ ..._stylex.props(styles$v.main, customStyle),
24272
24434
  children: React.Children.map(children, (child) => /* @__PURE__ */ jsxs(Fragment, {
24273
24435
  children: [child, /* @__PURE__ */ jsx(Divider, {})]
24274
24436
  }))
24275
24437
  })
24276
24438
  });
24277
24439
  }
24278
- const styles$x = {
24440
+ const styles$v = {
24279
24441
  main: {
24280
24442
  display: "mly78zum5",
24281
24443
  flexDirection: "mlydt5ytf",
@@ -24312,10 +24474,10 @@ function AccordionListItem({
24312
24474
  className: "mly78zum5 mlydt5ytf mlyb3r6kr mly1iyjqo2"
24313
24475
  },
24314
24476
  children: [/* @__PURE__ */ jsx("span", {
24315
- ..._stylex.props(fontStyles.body, styles$w.label),
24477
+ ..._stylex.props(fontStyles.body, styles$u.label),
24316
24478
  children: label
24317
24479
  }), sublabel && /* @__PURE__ */ jsx("span", {
24318
- ..._stylex.props(fontStyles.supporting, styles$w.sublabel),
24480
+ ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
24319
24481
  children: sublabel
24320
24482
  })]
24321
24483
  }), badge && badge, endIcon && endIcon]
@@ -24327,7 +24489,7 @@ function AccordionListItem({
24327
24489
  })]
24328
24490
  });
24329
24491
  }
24330
- const styles$w = {
24492
+ const styles$u = {
24331
24493
  label: {
24332
24494
  flexGrow: "mly1iyjqo2",
24333
24495
  fontWeight: "mly1xlr1w8",
@@ -25612,7 +25774,7 @@ function DropdownMenu({
25612
25774
  children: trigger
25613
25775
  }), /* @__PURE__ */ jsx(Portal2, {
25614
25776
  children: /* @__PURE__ */ jsx(Content2, {
25615
- ..._stylex.props(fontStyles.body, styles$v.content),
25777
+ ..._stylex.props(fontStyles.body, styles$t.content),
25616
25778
  side: "bottom",
25617
25779
  align: "start",
25618
25780
  sideOffset: 4,
@@ -25639,22 +25801,22 @@ function DropdownMenuItem({
25639
25801
  disabled,
25640
25802
  children: [icon && /* @__PURE__ */ jsx(Icon, {
25641
25803
  name: icon,
25642
- customStyle: styles$v.icon
25804
+ customStyle: styles$t.icon
25643
25805
  }), /* @__PURE__ */ jsxs("div", {
25644
25806
  ...{
25645
25807
  className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25646
25808
  },
25647
25809
  children: [/* @__PURE__ */ jsx("span", {
25648
- ..._stylex.props(fontStyles.body, styles$v.label),
25810
+ ..._stylex.props(fontStyles.body, styles$t.label),
25649
25811
  children: label
25650
25812
  }), sublabel && /* @__PURE__ */ jsx("span", {
25651
- ..._stylex.props(fontStyles.supporting, styles$v.sublabel),
25813
+ ..._stylex.props(fontStyles.supporting, styles$t.sublabel),
25652
25814
  children: sublabel
25653
25815
  })]
25654
25816
  })]
25655
25817
  });
25656
25818
  }
25657
- const styles$v = {
25819
+ const styles$t = {
25658
25820
  content: {
25659
25821
  display: "mly78zum5",
25660
25822
  flexDirection: "mlydt5ytf",
@@ -25741,7 +25903,7 @@ function QueryActionBar({
25741
25903
  children: [/* @__PURE__ */ jsx(Icon, {
25742
25904
  name: "filterSliders"
25743
25905
  }), /* @__PURE__ */ jsx("div", {
25744
- ..._stylex.props(fontStyles.largeBody, styles$u.title),
25906
+ ..._stylex.props(fontStyles.largeBody, styles$s.title),
25745
25907
  children: "Query"
25746
25908
  })]
25747
25909
  }), /* @__PURE__ */ jsxs("div", {
@@ -25786,13 +25948,13 @@ function QueryActionBar({
25786
25948
  })]
25787
25949
  });
25788
25950
  }
25789
- const styles$u = {
25951
+ const styles$s = {
25790
25952
  title: {
25791
25953
  fontWeight: "mly1xlr1w8",
25792
25954
  $$css: true
25793
25955
  }
25794
25956
  };
25795
- const styles$t = {
25957
+ const styles$r = {
25796
25958
  labelWithIcon: {
25797
25959
  display: "mly78zum5",
25798
25960
  alignItems: "mly6s0dn4",
@@ -29881,6 +30043,12 @@ function FieldToken({
29881
30043
  hoverActionsVisible,
29882
30044
  ...props2
29883
30045
  }) {
30046
+ let label = field.name;
30047
+ if (field.kind === "dimension" && (field.type.kind === "timestamp_type" || field.type.kind === "date_type")) {
30048
+ if (field.type.timeframe) {
30049
+ label += `.${field.type.timeframe}`;
30050
+ }
30051
+ }
29884
30052
  return /* @__PURE__ */ jsxs("div", {
29885
30053
  ...{
29886
30054
  0: {
@@ -29891,7 +30059,7 @@ function FieldToken({
29891
30059
  }
29892
30060
  }[!!hoverActionsVisible << 0],
29893
30061
  children: [/* @__PURE__ */ jsx(Token, {
29894
- label: field.name,
30062
+ label,
29895
30063
  color: fieldKindToColor(field.kind),
29896
30064
  icon: fieldToIcon(field),
29897
30065
  ...props2
@@ -29911,32 +30079,32 @@ function BadgeForField({
29911
30079
  label: "view",
29912
30080
  icon: "view_filled",
29913
30081
  color: "purple",
29914
- customStyle: styles$s.noBackground
30082
+ customStyle: styles$q.noBackground
29915
30083
  });
29916
30084
  } else if (field.kind === "dimension") {
29917
30085
  return /* @__PURE__ */ jsx(Badge, {
29918
30086
  label: "dimension",
29919
30087
  icon: fieldToIcon(field),
29920
30088
  color: "cyan",
29921
- customStyle: styles$s.noBackground
30089
+ customStyle: styles$q.noBackground
29922
30090
  });
29923
30091
  } else if (field.kind === "measure") {
29924
30092
  return /* @__PURE__ */ jsx(Badge, {
29925
30093
  label: "measure",
29926
30094
  icon: fieldToIcon(field),
29927
30095
  color: "green",
29928
- customStyle: styles$s.noBackground
30096
+ customStyle: styles$q.noBackground
29929
30097
  });
29930
30098
  } else if (field.kind === "join") {
29931
30099
  return /* @__PURE__ */ jsx(Badge, {
29932
30100
  label: "join",
29933
30101
  icon: fieldToIcon(field),
29934
30102
  color: "gray",
29935
- customStyle: styles$s.noBackground
30103
+ customStyle: styles$q.noBackground
29936
30104
  });
29937
30105
  }
29938
30106
  }
29939
- const styles$s = {
30107
+ const styles$q = {
29940
30108
  noBackground: {
29941
30109
  backgroundColor: "mlyjbqb8w",
29942
30110
  $$css: true
@@ -29965,7 +30133,7 @@ function Visualization$1({
29965
30133
  onClick: () => setRenderer(viz)
29966
30134
  }));
29967
30135
  const tokens2 = [/* @__PURE__ */ jsx(SelectorToken, {
29968
- customStyle: styles$r.first,
30136
+ customStyle: styles$p.first,
29969
30137
  icon: `viz_${currentRenderer}`,
29970
30138
  value: currentRenderer,
29971
30139
  items: vizes,
@@ -29975,7 +30143,7 @@ function Visualization$1({
29975
30143
  children: tokens2
29976
30144
  });
29977
30145
  }
29978
- const styles$r = {
30146
+ const styles$p = {
29979
30147
  first: {
29980
30148
  flexGrow: "mly1iyjqo2",
29981
30149
  justifyContent: "mlylqzeqv",
@@ -30004,33 +30172,31 @@ function ViewAttributeTable({
30004
30172
  }) {
30005
30173
  const dimensions = viewInfo.schema.fields.filter((f2) => f2.kind === "dimension");
30006
30174
  return /* @__PURE__ */ jsx("div", {
30007
- ..._stylex.props(styles$q.attributeTableContainer, style),
30008
- children: /* @__PURE__ */ jsx(ScrollableArea, {
30009
- children: /* @__PURE__ */ jsx("table", {
30010
- ...{
30011
- className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
30012
- },
30013
- children: /* @__PURE__ */ jsxs("tbody", {
30014
- children: [/* @__PURE__ */ jsx(ViewAttributeTableRow, {
30015
- attribute: "chart type",
30016
- children: /* @__PURE__ */ jsx("div", {
30017
- ...{
30018
- className: "mly1rg5ohu"
30019
- },
30020
- children: /* @__PURE__ */ jsx(Visualization, {
30021
- annotations: viewInfo.annotations || []
30022
- })
30175
+ ..._stylex.props(styles$o.attributeTableContainer, style),
30176
+ children: /* @__PURE__ */ jsx("table", {
30177
+ ...{
30178
+ className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
30179
+ },
30180
+ children: /* @__PURE__ */ jsxs("tbody", {
30181
+ children: [/* @__PURE__ */ jsx(ViewAttributeTableRow, {
30182
+ attribute: "chart type",
30183
+ children: /* @__PURE__ */ jsx("div", {
30184
+ ...{
30185
+ className: "mly1rg5ohu"
30186
+ },
30187
+ children: /* @__PURE__ */ jsx(Visualization, {
30188
+ annotations: viewInfo.annotations || []
30023
30189
  })
30024
- }), /* @__PURE__ */ jsx(ViewAttributeTableRow, {
30025
- attribute: "output",
30026
- children: dimensions.map((f2) => /* @__PURE__ */ jsx("span", {
30027
- children: /* @__PURE__ */ jsx(FieldToken, {
30028
- field: f2,
30029
- size: isCompact ? "compact" : "default"
30030
- })
30031
- }, `${f2.kind}::${f2.name}`))
30032
- })]
30033
- })
30190
+ })
30191
+ }), /* @__PURE__ */ jsx(ViewAttributeTableRow, {
30192
+ attribute: "output",
30193
+ children: dimensions.map((f2) => /* @__PURE__ */ jsx("span", {
30194
+ children: /* @__PURE__ */ jsx(FieldToken, {
30195
+ field: f2,
30196
+ size: isCompact ? "compact" : "default"
30197
+ })
30198
+ }, `${f2.kind}::${f2.name}`))
30199
+ })]
30034
30200
  })
30035
30201
  })
30036
30202
  });
@@ -30044,9 +30210,9 @@ function ViewAttributeTableRow({
30044
30210
  className: "mlydpxx8g"
30045
30211
  },
30046
30212
  children: [/* @__PURE__ */ jsx("td", {
30047
- ..._stylex.props(styles$q.attributeTableKeyCell, fontStyles.supporting),
30213
+ ..._stylex.props(styles$o.attributeTableKeyCell, fontStyles.supporting),
30048
30214
  children: /* @__PURE__ */ jsx("div", {
30049
- ..._stylex.props(styles$q.attributeTableKeyCellContent, fontStyles.supporting),
30215
+ ..._stylex.props(styles$o.attributeTableKeyCellContent, fontStyles.supporting),
30050
30216
  children: attribute
30051
30217
  })
30052
30218
  }), /* @__PURE__ */ jsx("td", {
@@ -30057,7 +30223,7 @@ function ViewAttributeTableRow({
30057
30223
  })]
30058
30224
  });
30059
30225
  }
30060
- const styles$q = {
30226
+ const styles$o = {
30061
30227
  attributeTableContainer: {
30062
30228
  padding: "mlye8ttls",
30063
30229
  paddingInline: null,
@@ -30084,6 +30250,9 @@ const styles$q = {
30084
30250
  boxSizing: "mly9f619",
30085
30251
  width: "mlyh8yej3",
30086
30252
  height: "mly1m3v4wt",
30253
+ overflow: "mlyysyzu8",
30254
+ overflowX: null,
30255
+ overflowY: null,
30087
30256
  $$css: true
30088
30257
  },
30089
30258
  attributeTableKeyCell: {
@@ -30205,7 +30374,7 @@ function HoverText({
30205
30374
  asChild: true,
30206
30375
  children: /* @__PURE__ */ jsx("div", {
30207
30376
  ref: textRef,
30208
- ..._stylex.props(styles$p.text, fontStyles.supporting),
30377
+ ..._stylex.props(styles$n.text, fontStyles.supporting),
30209
30378
  children: text2
30210
30379
  })
30211
30380
  }), /* @__PURE__ */ jsx(Portal$4, {
@@ -30213,7 +30382,7 @@ function HoverText({
30213
30382
  side,
30214
30383
  align,
30215
30384
  children: /* @__PURE__ */ jsx("pre", {
30216
- ..._stylex.props(styles$p.hoverText, fontStyles.tooltipText),
30385
+ ..._stylex.props(styles$n.hoverText, fontStyles.tooltipText),
30217
30386
  children: text2
30218
30387
  })
30219
30388
  })
@@ -30222,7 +30391,7 @@ function HoverText({
30222
30391
  })
30223
30392
  });
30224
30393
  }
30225
- const styles$p = {
30394
+ const styles$n = {
30226
30395
  text: {
30227
30396
  overflow: "mlyb3r6kr",
30228
30397
  overflowX: null,
@@ -30275,11 +30444,11 @@ function HoverCard({
30275
30444
  customStyle
30276
30445
  }) {
30277
30446
  return /* @__PURE__ */ jsx("div", {
30278
- ..._stylex.props(styles$o.container, fontStyles.body, customStyle),
30447
+ ..._stylex.props(styles$m.container, fontStyles.body, customStyle),
30279
30448
  children
30280
30449
  });
30281
30450
  }
30282
- const styles$o = {
30451
+ const styles$m = {
30283
30452
  container: {
30284
30453
  boxShadow: "mly5n1uv4",
30285
30454
  backgroundColor: "mly12peec7",
@@ -30324,7 +30493,7 @@ function FieldHoverCard({
30324
30493
  details = /* @__PURE__ */ jsx(ViewAttributeTable, {
30325
30494
  viewInfo: field,
30326
30495
  isCompact: true,
30327
- style: styles$n.viewAttributeTable
30496
+ style: styles$l.viewAttributeTable
30328
30497
  });
30329
30498
  } else if (field.kind === "dimension") {
30330
30499
  details = /* @__PURE__ */ jsx(TopValuesTable, {
@@ -30333,7 +30502,7 @@ function FieldHoverCard({
30333
30502
  });
30334
30503
  }
30335
30504
  return /* @__PURE__ */ jsxs(HoverCard, {
30336
- customStyle: styles$n.container,
30505
+ customStyle: styles$l.container,
30337
30506
  children: [/* @__PURE__ */ jsxs("div", {
30338
30507
  children: [/* @__PURE__ */ jsx("div", {
30339
30508
  ...{
@@ -30343,10 +30512,10 @@ function FieldHoverCard({
30343
30512
  field
30344
30513
  })
30345
30514
  }), /* @__PURE__ */ jsx("div", {
30346
- ..._stylex.props(fontStyles.supporting, styles$n.path),
30515
+ ..._stylex.props(fontStyles.supporting, styles$l.path),
30347
30516
  children: pathString
30348
30517
  }), /* @__PURE__ */ jsx("div", {
30349
- ..._stylex.props(fontStyles.emphasized, styles$n.title),
30518
+ ..._stylex.props(fontStyles.emphasized, styles$l.title),
30350
30519
  children: field.name
30351
30520
  }), description && /* @__PURE__ */ jsx(HoverText, {
30352
30521
  text: description
@@ -30356,7 +30525,7 @@ function FieldHoverCard({
30356
30525
  })]
30357
30526
  });
30358
30527
  }
30359
- const styles$n = {
30528
+ const styles$l = {
30360
30529
  container: {
30361
30530
  width: "mlybl57os",
30362
30531
  maxHeight: "mlyq3t0pi",
@@ -30648,10 +30817,10 @@ const PillInput = ({
30648
30817
  commitValue();
30649
30818
  });
30650
30819
  return /* @__PURE__ */ jsx("div", {
30651
- ..._stylex.props(fontStyles.body, styles$m.main),
30820
+ ..._stylex.props(fontStyles.body, styles$k.main),
30652
30821
  children: /* @__PURE__ */ jsx(ScrollableArea, {
30653
30822
  children: /* @__PURE__ */ jsxs("div", {
30654
- ..._stylex.props(styles$m.content, customStyle),
30823
+ ..._stylex.props(styles$k.content, customStyle),
30655
30824
  onKeyUp,
30656
30825
  onClick: () => {
30657
30826
  var _a2;
@@ -30718,7 +30887,7 @@ const Pill = ({
30718
30887
  onClick,
30719
30888
  tabIndex: 0,
30720
30889
  ref: forwardRef,
30721
- ..._stylex.props(styles$m.pill, colorVariants[color]),
30890
+ ..._stylex.props(styles$k.pill, colorVariants[color]),
30722
30891
  children: [children, /* @__PURE__ */ jsx("div", {
30723
30892
  title: "Remove",
30724
30893
  ...{
@@ -30733,7 +30902,7 @@ const Pill = ({
30733
30902
  })]
30734
30903
  });
30735
30904
  };
30736
- const styles$m = {
30905
+ const styles$k = {
30737
30906
  main: {
30738
30907
  borderRadius: "mly12oqio5",
30739
30908
  borderStartStartRadius: null,
@@ -30917,7 +31086,7 @@ function ValueList({
30917
31086
  children: (stringSearchResults == null ? void 0 : stringSearchResults.length) ? stringSearchResults.map((value) => /* @__PURE__ */ jsxs("div", {
30918
31087
  role: "menuitem",
30919
31088
  tabIndex: -1,
30920
- ..._stylex.props(addMenuStyles.item, styles$l.valueItem),
31089
+ ..._stylex.props(addMenuStyles.item, styles$j.valueItem),
30921
31090
  onClick: () => onClick(value),
30922
31091
  children: [/* @__PURE__ */ jsx(Value, {
30923
31092
  value
@@ -30941,10 +31110,10 @@ function Value({
30941
31110
  label: value.fieldValue ?? "∅",
30942
31111
  icon: "filter",
30943
31112
  color: "purple",
30944
- customStyle: styles$l.token
31113
+ customStyle: styles$j.token
30945
31114
  });
30946
31115
  }
30947
- const styles$l = {
31116
+ const styles$j = {
30948
31117
  valueItem: {
30949
31118
  height: "mly1qx5ct2",
30950
31119
  paddingTop: "mly1y1aw1k",
@@ -31120,7 +31289,7 @@ const StringFilterCore = ({
31120
31289
  setSearchValue("");
31121
31290
  }
31122
31291
  },
31123
- customStyle: styles$k.valueList
31292
+ customStyle: styles$i.valueList
31124
31293
  })
31125
31294
  })]
31126
31295
  }) : currentFilter.operator === "~" ? /* @__PURE__ */ jsx(StringEditor, {
@@ -31188,7 +31357,7 @@ function stringFilterChangeType(filter, type) {
31188
31357
  };
31189
31358
  }
31190
31359
  }
31191
- const styles$k = {
31360
+ const styles$i = {
31192
31361
  valueList: {
31193
31362
  maxHeight: "mly3d5gib",
31194
31363
  width: "mly1hfn5x7",
@@ -31443,85 +31612,6 @@ function makeFilterWithNewType(filter, type) {
31443
31612
  };
31444
31613
  }
31445
31614
  }
31446
- const formats = {
31447
- second: "YYYY-MM-DD HH:mm:ss",
31448
- minute: "YYYY-MM-DD HH:mm",
31449
- hour: "YYYY-MM-DD HH:00",
31450
- day: "YYYY-MM-DD",
31451
- week: "[WK]YYYY-WW",
31452
- month: "YYYY-MM",
31453
- quarter: "YYYY-[Q]Q",
31454
- year: "YYYY"
31455
- };
31456
- const regexps = {
31457
- second: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
31458
- minute: /\d\d\d\d-\d\d-\d\d \d\d:\d\d/,
31459
- hour: /\d\d\d\d-\d\d-\d\d \d\d:00/,
31460
- day: /\d\d\d\d-\d\d-\d\d/,
31461
- week: /WK\d\d\d\d-\d\d-\d\d/,
31462
- month: /\d\d\d\d-\d\d/,
31463
- quarter: /\d\d\d\d-Q\d/,
31464
- year: /\d\d\d\d/
31465
- };
31466
- const DateInput = ({
31467
- value,
31468
- setValue,
31469
- placeholder,
31470
- autoFocus,
31471
- units,
31472
- onFocus,
31473
- onBlur,
31474
- isActive,
31475
- customStyle,
31476
- forwardRef
31477
- }) => {
31478
- const format2 = formats[units];
31479
- const [tempValue, setTempValue] = useState(hooks.utc(value).format(format2));
31480
- useEffect(() => {
31481
- setTempValue(hooks.utc(value).format(format2));
31482
- }, [value, format2]);
31483
- return /* @__PURE__ */ jsx("input", {
31484
- ..._stylex.props(customStyle, isActive ? styles$j.active : null),
31485
- type: "text",
31486
- placeholder: placeholder || format2,
31487
- value: tempValue,
31488
- onFocus,
31489
- onBlur,
31490
- onChange: (event) => {
31491
- const raw2 = event.target.value;
31492
- setTempValue(raw2);
31493
- const regex = regexps[units];
31494
- if (raw2.match(regex)) {
31495
- const m = hooks.utc(raw2, format2);
31496
- if (m.isValid()) {
31497
- setValue(m.toDate());
31498
- }
31499
- }
31500
- },
31501
- autoFocus,
31502
- ref: forwardRef
31503
- });
31504
- };
31505
- function guessUnits(moment2, isDateTime) {
31506
- if (moment2.moment === "literal") {
31507
- const {
31508
- literal
31509
- } = moment2;
31510
- for (const unit in regexps) {
31511
- const temporalUnit = unit;
31512
- if (literal.match(regexps[temporalUnit])) {
31513
- return temporalUnit;
31514
- }
31515
- }
31516
- }
31517
- return isDateTime ? "second" : "day";
31518
- }
31519
- const styles$j = {
31520
- active: {
31521
- backgroundColor: "mly1vzefiq",
31522
- $$css: true
31523
- }
31524
- };
31525
31615
  function typeFromFilter(filter) {
31526
31616
  if (filter.operator === "null" && filter.not) {
31527
31617
  return "-null";
@@ -31718,15 +31808,48 @@ function NUnitFilter({
31718
31808
  });
31719
31809
  }
31720
31810
  function UnitFilter({
31811
+ currentFilter,
31812
+ updateFilter,
31721
31813
  units,
31722
31814
  setUnits,
31723
31815
  maxLevel
31724
31816
  }) {
31725
31817
  const options = maxLevel === "day" ? DateUnits : [...DateUnits, ...TimeUnits];
31818
+ const updateUnits = (units2) => {
31819
+ setUnits(units2);
31820
+ switch (currentFilter.operator) {
31821
+ case "after":
31822
+ updateFilter({
31823
+ ...currentFilter,
31824
+ after: updateMoment(currentFilter.after, units2)
31825
+ });
31826
+ return;
31827
+ case "before":
31828
+ updateFilter({
31829
+ ...currentFilter,
31830
+ before: updateMoment(currentFilter.before, units2)
31831
+ });
31832
+ return;
31833
+ case "to":
31834
+ updateFilter({
31835
+ ...currentFilter,
31836
+ fromMoment: updateMoment(currentFilter.fromMoment, units2),
31837
+ toMoment: updateMoment(currentFilter.toMoment, units2)
31838
+ });
31839
+ return;
31840
+ case "in": {
31841
+ updateFilter({
31842
+ ...currentFilter,
31843
+ in: updateMoment(currentFilter.in, units2)
31844
+ });
31845
+ return;
31846
+ }
31847
+ }
31848
+ };
31726
31849
  return /* @__PURE__ */ jsx(SelectDropdown, {
31727
31850
  options,
31728
31851
  value: units,
31729
- onChange: setUnits,
31852
+ onChange: updateUnits,
31730
31853
  customStyle: filterStyles.editorCell
31731
31854
  });
31732
31855
  }
@@ -31851,15 +31974,19 @@ function DoubleDateFilter({
31851
31974
  function createTemporalLiteral(date, units) {
31852
31975
  return {
31853
31976
  moment: "literal",
31854
- literal: hooks.utc(date).format(formats[units])
31977
+ literal: hooks.utc(date).format(formats[units]),
31978
+ units
31855
31979
  };
31856
31980
  }
31857
31981
  function extractDateFromMoment(momentObj) {
31858
31982
  if (momentObj && momentObj.moment === "literal") {
31859
- return hooks.utc(momentObj.literal).toDate();
31983
+ return hooks.utc(momentObj.literal, formats[momentObj.units ?? "second"]).toDate();
31860
31984
  }
31861
31985
  return /* @__PURE__ */ new Date();
31862
31986
  }
31987
+ function updateMoment(moment2, units) {
31988
+ return createTemporalLiteral(extractDateFromMoment(moment2), units);
31989
+ }
31863
31990
  function dateTimeFilterChangeType(filter, type, units) {
31864
31991
  let n = "7";
31865
31992
  let fromMoment = createTemporalLiteral(/* @__PURE__ */ new Date(), units);
@@ -31903,6 +32030,11 @@ function dateTimeFilterChangeType(filter, type, units) {
31903
32030
  operator: type,
31904
32031
  before: fromMoment
31905
32032
  };
32033
+ case "in":
32034
+ return {
32035
+ operator: type,
32036
+ in: fromMoment
32037
+ };
31906
32038
  case "to":
31907
32039
  return {
31908
32040
  operator: type,
@@ -31968,6 +32100,13 @@ function FilterDialog({
31968
32100
  };
31969
32101
  return /* @__PURE__ */ jsxs("div", {
31970
32102
  ..._stylex.props(fontStyles.body, filterStyles.filterDialog),
32103
+ onKeyDown: (event) => {
32104
+ if (event.key === "Enter") {
32105
+ onApply();
32106
+ } else if (event.key === "Esc") {
32107
+ onCancel();
32108
+ }
32109
+ },
31971
32110
  children: [/* @__PURE__ */ jsx("div", {
31972
32111
  ..._stylex.props(filterStyles.filterDialogHeader),
31973
32112
  children: fieldInfo.name
@@ -32161,7 +32300,7 @@ function FieldList({
32161
32300
  ..._stylex.props(customStyle),
32162
32301
  children: groups.length ? groups.map((group) => /* @__PURE__ */ jsxs("div", {
32163
32302
  children: [/* @__PURE__ */ jsx("div", {
32164
- ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
32303
+ ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
32165
32304
  "data-disabled": "true",
32166
32305
  children: group.name
32167
32306
  }), group.fields.map((field) => isFilterOperation && (field.kind === "dimension" || field.kind === "measure") ? /* @__PURE__ */ jsx(FilterPopover, {
@@ -32171,7 +32310,7 @@ function FieldList({
32171
32310
  anchor: /* @__PURE__ */ jsx("div", {
32172
32311
  role: "menuitem",
32173
32312
  tabIndex: -1,
32174
- ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
32313
+ ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
32175
32314
  children: /* @__PURE__ */ jsx(PopoverTrigger, {
32176
32315
  asChild: true,
32177
32316
  children: /* @__PURE__ */ jsx(FieldToken, {
@@ -32198,7 +32337,7 @@ function FieldList({
32198
32337
  }, group.name + ":" + field.name) : /* @__PURE__ */ jsx("div", {
32199
32338
  role: "menuitem",
32200
32339
  tabIndex: -1,
32201
- ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
32340
+ ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
32202
32341
  children: /* @__PURE__ */ jsx(FieldToken, {
32203
32342
  field,
32204
32343
  onClick: () => onAddOperation(field, group.path),
@@ -32221,7 +32360,7 @@ function FieldList({
32221
32360
  })
32222
32361
  });
32223
32362
  }
32224
- const styles$i = {
32363
+ const styles$h = {
32225
32364
  fieldItem: {
32226
32365
  height: "mly1qx5ct2",
32227
32366
  paddingTop: "mly1y1aw1k",
@@ -32239,7 +32378,7 @@ function FieldMenu({
32239
32378
  }) {
32240
32379
  const [search, setSearch] = useState("");
32241
32380
  return /* @__PURE__ */ jsxs("div", {
32242
- ..._stylex.props(addMenuStyles.content, styles$h.content),
32381
+ ..._stylex.props(addMenuStyles.content, styles$g.content),
32243
32382
  role: "menu",
32244
32383
  children: [/* @__PURE__ */ jsx("div", {
32245
32384
  ..._stylex.props(addMenuStyles.item),
@@ -32265,7 +32404,7 @@ function FieldMenu({
32265
32404
  })]
32266
32405
  });
32267
32406
  }
32268
- const styles$h = {
32407
+ const styles$g = {
32269
32408
  content: {
32270
32409
  maxHeight: "mly3d5gib",
32271
32410
  $$css: true
@@ -32292,6 +32431,7 @@ function segmentNestNo(segment, name) {
32292
32431
  }, 1);
32293
32432
  }
32294
32433
  function addGroupBy(view, field, path) {
32434
+ const type = field.kind === "dimension" ? field.type.kind : "string";
32295
32435
  const segment = view.getOrAddDefaultSegment();
32296
32436
  const {
32297
32437
  fields
@@ -32300,7 +32440,13 @@ function addGroupBy(view, field, path) {
32300
32440
  if (fields.find((f2) => f2.name === field.name)) {
32301
32441
  rename = findUniqueFieldName(fields, field.name, path);
32302
32442
  }
32303
- segment.addGroupBy(field.name, path, rename);
32443
+ if (type === "date_type") {
32444
+ segment.addDateGroupBy(field.name, path, "day");
32445
+ } else if (type === "timestamp_type") {
32446
+ segment.addTimestampGroupBy(field.name, path, "second");
32447
+ } else {
32448
+ segment.addGroupBy(field.name, path, rename);
32449
+ }
32304
32450
  }
32305
32451
  function addAggregate(view, field, path) {
32306
32452
  const segment = view.getOrAddDefaultSegment();
@@ -32324,6 +32470,18 @@ function addNest(view, field) {
32324
32470
  }
32325
32471
  segment.addNest(field.name, rename);
32326
32472
  }
32473
+ function addOrderBy(view, field, direction = "desc") {
32474
+ const segment = view.getOrAddDefaultSegment();
32475
+ segment.addOrderBy(field.name, direction);
32476
+ }
32477
+ function addFilter(view, field, path, filter) {
32478
+ const segment = view.getOrAddDefaultSegment();
32479
+ if (field.kind === "dimension") {
32480
+ segment.addWhere(field.name, path, filter);
32481
+ } else {
32482
+ segment.addHaving(field.name, path, filter);
32483
+ }
32484
+ }
32327
32485
  function getSegmentIfPresent(parent) {
32328
32486
  const definition = getViewDefinition(parent);
32329
32487
  if (definition instanceof ASTSegmentViewDefinition) {
@@ -32349,7 +32507,7 @@ function OperationActionTitle({
32349
32507
  return !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
32350
32508
  };
32351
32509
  return /* @__PURE__ */ jsxs("div", {
32352
- ..._stylex.props(styles$t.title, hoverStyles.main),
32510
+ ..._stylex.props(styles$r.title, hoverStyles.main),
32353
32511
  children: [/* @__PURE__ */ jsx("div", {
32354
32512
  children: title
32355
32513
  }), /* @__PURE__ */ jsx("div", {
@@ -32746,7 +32904,14 @@ function RenameDialog({
32746
32904
  ..._stylex.props({
32747
32905
  ...dialogStyles.editorCell,
32748
32906
  ...dialogStyles.input
32749
- })
32907
+ }),
32908
+ onKeyDown: (event) => {
32909
+ if (event.key === "Enter") {
32910
+ onRename();
32911
+ } else if (event.key === "Esc") {
32912
+ setOpen(false);
32913
+ }
32914
+ }
32750
32915
  }), badName && /* @__PURE__ */ jsx(ErrorIcon, {
32751
32916
  errorMessage: "Name already in use"
32752
32917
  })]
@@ -32919,7 +33084,7 @@ function SortableOperations({
32919
33084
  fields,
32920
33085
  ...props2
32921
33086
  }), /* @__PURE__ */ jsx("div", {
32922
- ..._stylex.props(styles$t.tokenContainer),
33087
+ ..._stylex.props(styles$r.tokenContainer),
32923
33088
  children: /* @__PURE__ */ jsx(DndContext, {
32924
33089
  sensors,
32925
33090
  collisionDetection: closestCenter,
@@ -32927,6 +33092,7 @@ function SortableOperations({
32927
33092
  children: /* @__PURE__ */ jsx(SortableContext, {
32928
33093
  items,
32929
33094
  children: items.map((item) => /* @__PURE__ */ jsx(SortableOperation, {
33095
+ rootQuery,
32930
33096
  id: item.id,
32931
33097
  color: kind === "group_by" ? "cyan" : "green",
32932
33098
  view,
@@ -32937,18 +33103,19 @@ function SortableOperations({
32937
33103
  })]
32938
33104
  });
32939
33105
  }
33106
+ const NULL_PATH = [];
32940
33107
  function SortableOperation({
33108
+ rootQuery,
32941
33109
  id,
32942
33110
  view,
32943
33111
  operation,
32944
33112
  color
32945
33113
  }) {
32946
33114
  const {
32947
- rootQuery,
32948
33115
  setQuery
32949
33116
  } = useContext(QueryEditorContext);
32950
33117
  const fieldInfo = operation.getFieldInfo();
32951
- const path = operation.field.getReference().path ?? [];
33118
+ const path = operation.field.getReference().path ?? NULL_PATH;
32952
33119
  const {
32953
33120
  attributes,
32954
33121
  listeners,
@@ -32968,37 +33135,64 @@ function SortableOperation({
32968
33135
  transform: CSS$1.Transform.toString(transform2),
32969
33136
  transition
32970
33137
  };
33138
+ const hoverActions = useMemo(() => {
33139
+ return /* @__PURE__ */ jsxs(Fragment, {
33140
+ children: [/* @__PURE__ */ jsx(DropdownMenu, {
33141
+ trigger: /* @__PURE__ */ jsx(Button, {
33142
+ variant: "flat",
33143
+ icon: "meatballs",
33144
+ size: "compact",
33145
+ tooltip: "More Actions"
33146
+ }),
33147
+ onOpenChange: setHoverActionsVisible,
33148
+ children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
33149
+ label: "Rename",
33150
+ onClick: () => {
33151
+ setRenameTarget(operation);
33152
+ setRenameOpen(true);
33153
+ }
33154
+ }, "rename")]
33155
+ }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsx(ClearButton, {
33156
+ onClick: () => {
33157
+ operation.delete();
33158
+ setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33159
+ }
33160
+ })]
33161
+ });
33162
+ }, [fieldInfo, operation, path, rootQuery, setQuery]);
33163
+ const granular = granularityMenuItems(fieldInfo, operation.field);
33164
+ let icon = "orderBy";
33165
+ if (fieldInfo.kind === "dimension" || fieldInfo.kind === "measure") {
33166
+ icon = atomicTypeToIcon(fieldInfo.type.kind);
33167
+ }
32971
33168
  return /* @__PURE__ */ jsxs("div", {
32972
33169
  id,
32973
33170
  ref: setNodeRef,
32974
33171
  style,
32975
- children: [/* @__PURE__ */ jsx(FieldToken, {
33172
+ children: [granular ? /* @__PURE__ */ jsxs(TokenGroup, {
33173
+ customStyle: customStyles.tokenGroup,
33174
+ children: [/* @__PURE__ */ jsx(Token, {
33175
+ color,
33176
+ icon,
33177
+ label: fieldInfo.name,
33178
+ dragProps: {
33179
+ attributes,
33180
+ listeners
33181
+ }
33182
+ }), /* @__PURE__ */ jsx(SelectorToken, {
33183
+ color,
33184
+ value: granular.value,
33185
+ onChange: (granulation) => {
33186
+ if (operation.field.expression instanceof ASTTimeTruncationExpression) operation.field.expression.truncation = granulation;
33187
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
33188
+ },
33189
+ items: granular.options
33190
+ })]
33191
+ }) : /* @__PURE__ */ jsx(FieldToken, {
32976
33192
  field: fieldInfo,
32977
33193
  color,
32978
33194
  hoverActionsVisible,
32979
- hoverActions: /* @__PURE__ */ jsxs(Fragment, {
32980
- children: [/* @__PURE__ */ jsx(DropdownMenu, {
32981
- trigger: /* @__PURE__ */ jsx(Button, {
32982
- variant: "flat",
32983
- icon: "meatballs",
32984
- size: "compact",
32985
- tooltip: "More Actions"
32986
- }),
32987
- onOpenChange: setHoverActionsVisible,
32988
- children: /* @__PURE__ */ jsx(DropdownMenuItem, {
32989
- label: "Rename",
32990
- onClick: () => {
32991
- setRenameTarget(operation);
32992
- setRenameOpen(true);
32993
- }
32994
- })
32995
- }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsx(ClearButton, {
32996
- onClick: () => {
32997
- operation.delete();
32998
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
32999
- }
33000
- })]
33001
- }),
33195
+ hoverActions,
33002
33196
  tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
33003
33197
  field: fieldInfo,
33004
33198
  path
@@ -33021,6 +33215,38 @@ function SortableOperation({
33021
33215
  })]
33022
33216
  });
33023
33217
  }
33218
+ const DateGranulation = ["day", "week", "month", "quarter", "year"];
33219
+ const TimestampGranulation = ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
33220
+ function granularityMenuItems(fieldInfo, field) {
33221
+ if (fieldInfo.kind !== "dimension" || !(field.expression instanceof ASTTimeTruncationExpression)) {
33222
+ return null;
33223
+ }
33224
+ if (fieldInfo.type.kind === "timestamp_type") {
33225
+ return {
33226
+ value: fieldInfo.type.timeframe ?? "second",
33227
+ options: TimestampGranulation.map((value) => ({
33228
+ label: value,
33229
+ value
33230
+ }))
33231
+ };
33232
+ }
33233
+ if (fieldInfo.type.kind === "date_type") {
33234
+ return {
33235
+ value: fieldInfo.type.timeframe ?? "day",
33236
+ options: DateGranulation.map((value) => ({
33237
+ label: value,
33238
+ value
33239
+ }))
33240
+ };
33241
+ }
33242
+ return null;
33243
+ }
33244
+ const customStyles = {
33245
+ tokenGroup: {
33246
+ display: "mly78zum5",
33247
+ $$css: true
33248
+ }
33249
+ };
33024
33250
  function GroupByOperations({
33025
33251
  rootQuery,
33026
33252
  segment,
@@ -33069,10 +33295,10 @@ function FilterOperations({
33069
33295
  }
33070
33296
  return /* @__PURE__ */ jsxs("div", {
33071
33297
  children: [/* @__PURE__ */ jsx("div", {
33072
- ..._stylex.props(styles$t.title),
33298
+ ..._stylex.props(styles$r.title),
33073
33299
  children: "filter by"
33074
33300
  }), /* @__PURE__ */ jsx("div", {
33075
- ..._stylex.props(styles$t.tokenContainer),
33301
+ ..._stylex.props(styles$r.tokenContainer),
33076
33302
  children: filters.map((filterOperation, key2) => {
33077
33303
  return /* @__PURE__ */ jsx(ErrorElement, {
33078
33304
  fallback: /* @__PURE__ */ jsxs("div", {
@@ -33336,7 +33562,7 @@ function LimitOperation({
33336
33562
  }
33337
33563
  return /* @__PURE__ */ jsxs("div", {
33338
33564
  children: [/* @__PURE__ */ jsx("div", {
33339
- ..._stylex.props(styles$t.title),
33565
+ ..._stylex.props(styles$r.title),
33340
33566
  children: "limit"
33341
33567
  }), /* @__PURE__ */ jsxs("div", {
33342
33568
  ..._stylex.props(hoverStyles.main),
@@ -33386,10 +33612,10 @@ function OrderByOperations({
33386
33612
  }
33387
33613
  return /* @__PURE__ */ jsxs("div", {
33388
33614
  children: [/* @__PURE__ */ jsx("div", {
33389
- ..._stylex.props(styles$t.title),
33615
+ ..._stylex.props(styles$r.title),
33390
33616
  children: "order by"
33391
33617
  }), /* @__PURE__ */ jsx("div", {
33392
- ..._stylex.props(styles$t.tokenContainer),
33618
+ ..._stylex.props(styles$r.tokenContainer),
33393
33619
  children: orderBys.map((orderBy) => {
33394
33620
  const {
33395
33621
  fieldReference
@@ -33457,77 +33683,6 @@ function View({
33457
33683
  })]
33458
33684
  });
33459
33685
  }
33460
- function CollapsiblePanel({
33461
- title,
33462
- children,
33463
- icon,
33464
- defaultOpen = true,
33465
- controls,
33466
- collapsedControls,
33467
- isFocused = false
33468
- }) {
33469
- const [isExpanded, setIsExpanded] = useState(defaultOpen);
33470
- return /* @__PURE__ */ jsxs("div", {
33471
- ...{
33472
- 0: {
33473
- className: "mlygbc89k mly1sxf85j mly1717udv"
33474
- },
33475
- 1: {
33476
- className: "mly1sxf85j mly1717udv mlybwr872"
33477
- }
33478
- }[!!isFocused << 0],
33479
- children: [/* @__PURE__ */ jsxs("div", {
33480
- ...{
33481
- className: "mlyrvj5dj mly1mt1orb mly52fmzj mlylqzeqv mlyfawy5m mly167g77z mly6s0dn4"
33482
- },
33483
- children: [/* @__PURE__ */ jsxs("div", {
33484
- ...{
33485
- className: "mlyrvj5dj mly1mt1orb mlylqzeqv mly6s0dn4 mly167g77z"
33486
- },
33487
- children: [icon && /* @__PURE__ */ jsx(Icon, {
33488
- name: icon,
33489
- customStyle: styles$g.icon
33490
- }), /* @__PURE__ */ jsx("div", {
33491
- ...{
33492
- className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp"
33493
- },
33494
- children: title
33495
- })]
33496
- }), /* @__PURE__ */ jsxs("div", {
33497
- ...{
33498
- className: "mly78zum5"
33499
- },
33500
- children: [isExpanded ? /* @__PURE__ */ jsx("div", {
33501
- ...{
33502
- className: "mly78zum5 mly6s0dn4 mly1jnr06f"
33503
- },
33504
- children: controls
33505
- }) : /* @__PURE__ */ jsx("div", {
33506
- ...{
33507
- className: "mly78zum5 mly6s0dn4 mly1jnr06f"
33508
- },
33509
- children: collapsedControls
33510
- }), /* @__PURE__ */ jsx(Button, {
33511
- variant: "flat",
33512
- size: "compact",
33513
- onClick: () => setIsExpanded(!isExpanded),
33514
- icon: isExpanded ? "chevronDown" : "chevronRight",
33515
- tooltip: isExpanded ? "Collapse" : "Expand"
33516
- })]
33517
- })]
33518
- }), isExpanded && /* @__PURE__ */ jsx("div", {
33519
- ...{
33520
- className: "mly1l4tkcb"
33521
- },
33522
- children
33523
- })]
33524
- });
33525
- }
33526
- const styles$g = {
33527
- icon: {
33528
- $$css: true
33529
- }
33530
- };
33531
33686
  function AddItem({
33532
33687
  icon,
33533
33688
  label,
@@ -33650,7 +33805,8 @@ function AddFieldItem({
33650
33805
  }
33651
33806
  const styles$e = {
33652
33807
  list: {
33653
- width: "mlyqyf9gi",
33808
+ minWidth: "mly2ixbly",
33809
+ maxWidth: "mly1j9u4d2",
33654
33810
  $$css: true
33655
33811
  }
33656
33812
  };
@@ -33672,8 +33828,7 @@ function AddOrderBy({
33672
33828
  fields,
33673
33829
  types: ["dimension"],
33674
33830
  onAddOperation: (field) => {
33675
- const segment2 = view.getOrAddDefaultSegment();
33676
- segment2.addOrderBy(field.name, "asc");
33831
+ addOrderBy(view, field);
33677
33832
  setQuery == null ? void 0 : setQuery(rootQuery.build());
33678
33833
  },
33679
33834
  disabledMessage: "There must be at least one field in the output to order by.",
@@ -33750,28 +33905,21 @@ function AddWhere({
33750
33905
  const {
33751
33906
  fields
33752
33907
  } = getInputSchemaFromViewParent(view);
33753
- return /* @__PURE__ */ jsx(Fragment, {
33754
- children: /* @__PURE__ */ jsx(AddFieldItem, {
33755
- label: "Add filter",
33756
- icon: "filter",
33757
- view,
33758
- fields,
33759
- types: ["measure", "dimension"],
33760
- filter: (_segment, field) => (field.kind === "dimension" || field.kind === "measure") && FILTERABLE_TYPES$1.has(field.type.kind) && isNotAnnotatedFilteredField(field),
33761
- onAddOperation: (field, path, filter) => {
33762
- if (filter && (field.kind === "dimension" || field.kind === "measure")) {
33763
- const segment = view.getOrAddDefaultSegment();
33764
- if (field.kind === "dimension") {
33765
- segment.addWhere(field.name, path, filter);
33766
- } else {
33767
- segment.addHaving(field.name, path, filter);
33768
- }
33769
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33770
- }
33771
- },
33772
- isFilterOperation: true,
33773
- search
33774
- })
33908
+ return /* @__PURE__ */ jsx(AddFieldItem, {
33909
+ label: "Add filter",
33910
+ icon: "filter",
33911
+ view,
33912
+ fields,
33913
+ types: ["measure", "dimension"],
33914
+ filter: (_segment, field) => (field.kind === "dimension" || field.kind === "measure") && FILTERABLE_TYPES$1.has(field.type.kind) && isNotAnnotatedFilteredField(field),
33915
+ onAddOperation: (field, path, filter) => {
33916
+ if (filter && (field.kind === "dimension" || field.kind === "measure")) {
33917
+ addFilter(view, field, path, filter);
33918
+ setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33919
+ }
33920
+ },
33921
+ isFilterOperation: true,
33922
+ search
33775
33923
  });
33776
33924
  }
33777
33925
  const FILTERABLE_TYPES$1 = /* @__PURE__ */ new Set(["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"]);
@@ -33988,7 +34136,7 @@ function NestOperations({
33988
34136
  return null;
33989
34137
  }
33990
34138
  return /* @__PURE__ */ jsx("div", {
33991
- ..._stylex.props(styles$t.tokenContainer),
34139
+ ..._stylex.props(styles$r.tokenContainer),
33992
34140
  children: nests.map((nest) => /* @__PURE__ */ jsx(NestOperation, {
33993
34141
  rootQuery,
33994
34142
  view,
@@ -34027,7 +34175,6 @@ function NestOperation({
34027
34175
  onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
34028
34176
  }
34029
34177
  };
34030
- const defaultOpen = nest.view.definition.node.kind === "segment" && nest.view.definition.node.operations.length === 0;
34031
34178
  const getControls = (nest2) => /* @__PURE__ */ jsxs(Fragment, {
34032
34179
  children: [/* @__PURE__ */ jsxs(DropdownMenu, {
34033
34180
  trigger: /* @__PURE__ */ jsx(Button, {
@@ -34066,7 +34213,7 @@ function NestOperation({
34066
34213
  children: [/* @__PURE__ */ jsx(CollapsiblePanel, {
34067
34214
  title: nest.name,
34068
34215
  icon: viewToVisualizationIcon(nest.view),
34069
- defaultOpen,
34216
+ defaultOpen: true,
34070
34217
  controls: getControls(nest),
34071
34218
  collapsedControls: getControls(nest),
34072
34219
  isFocused: isCurrentNestQueryPanelFocused,
@@ -34191,7 +34338,7 @@ function ViewDefinition({
34191
34338
  function CollapsingView({
34192
34339
  viewDef
34193
34340
  }) {
34194
- const [collapsed, setCollapsed] = useState(true);
34341
+ const [collapsed, setCollapsed] = useState(false);
34195
34342
  return /* @__PURE__ */ jsxs("div", {
34196
34343
  ...{
34197
34344
  0: {
@@ -34265,6 +34412,7 @@ function Query({
34265
34412
  onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(null);
34266
34413
  onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
34267
34414
  };
34415
+ const canEditViz = query.definition instanceof ASTSegmentViewDefinition;
34268
34416
  return /* @__PURE__ */ jsx("div", {
34269
34417
  onPointerDownCapture: focusMainQueryPanel,
34270
34418
  children: /* @__PURE__ */ jsxs(CollapsiblePanel, {
@@ -34313,7 +34461,7 @@ function Query({
34313
34461
  flexDirection: "column",
34314
34462
  gap: 8
34315
34463
  },
34316
- children: [!query.isEmpty() && /* @__PURE__ */ jsx(Visualization$1, {
34464
+ children: [!query.isEmpty() && canEditViz && /* @__PURE__ */ jsx(Visualization$1, {
34317
34465
  rootQuery,
34318
34466
  view: query
34319
34467
  }), /* @__PURE__ */ jsx(ViewDefinition, {
@@ -34327,12 +34475,13 @@ function Query({
34327
34475
  },
34328
34476
  children: /* @__PURE__ */ jsxs("div", {
34329
34477
  ...{
34330
- className: "mly78zum5 mly6s0dn4"
34478
+ className: "mly78zum5 mly6s0dn4 mlywzxoxx"
34331
34479
  },
34332
34480
  children: [/* @__PURE__ */ jsx("div", {
34333
34481
  children: "Click"
34334
34482
  }), /* @__PURE__ */ jsx(Icon, {
34335
- name: "insert"
34483
+ name: "insert",
34484
+ color: "disabled"
34336
34485
  }), /* @__PURE__ */ jsx("div", {
34337
34486
  children: "to get started"
34338
34487
  })]
@@ -34346,14 +34495,14 @@ function Source({
34346
34495
  }) {
34347
34496
  if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
34348
34497
  return /* @__PURE__ */ jsx("div", {
34349
- ..._stylex.props(styles$t.queryCard, styles$b.content),
34498
+ ..._stylex.props(styles$r.queryCard, styles$b.content),
34350
34499
  children: /* @__PURE__ */ jsxs("div", {
34351
- ..._stylex.props(styles$t.labelWithIcon),
34500
+ ..._stylex.props(styles$r.labelWithIcon),
34352
34501
  children: [/* @__PURE__ */ jsx(Icon, {
34353
34502
  name: "database"
34354
34503
  }), /* @__PURE__ */ jsx("div", {
34355
34504
  ...{
34356
- className: "mlyb3r6kr mlylyipyv"
34505
+ className: "mlyb3r6kr mlylyipyv mly117nqv4"
34357
34506
  },
34358
34507
  children: rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name
34359
34508
  })]
@@ -35154,34 +35303,22 @@ function Banners({
35154
35303
  function RenderedResult({
35155
35304
  result
35156
35305
  }) {
35157
- const [html2, setHTML] = React.useState();
35158
- const [rendering, setRendering] = React.useState(true);
35159
- React.useEffect(() => {
35160
- let canceled = false;
35161
- setRendering(true);
35162
- const updateResults = async () => {
35163
- const renderer = new render.HTMLView(document);
35164
- const html22 = await renderer.render(result, {
35165
- dataStyles: {},
35166
- isDrillingEnabled: true
35167
- });
35168
- if (canceled) {
35169
- return;
35170
- }
35171
- setRendering(false);
35172
- setHTML(html22);
35173
- };
35174
- updateResults();
35175
- return () => {
35176
- canceled = true;
35177
- };
35306
+ const [renderer, setRenderer] = useState();
35307
+ useEffect(() => {
35308
+ const renderer2 = document.createElement("malloy-render");
35309
+ renderer2.malloyResult = result;
35310
+ setRenderer(renderer2);
35178
35311
  }, [result]);
35179
- if (!rendering) return html2 && /* @__PURE__ */ jsx(DOMElement, {
35180
- className: "malloy-render_result-wrapper",
35181
- element: html2
35182
- });
35183
- return /* @__PURE__ */ jsx(ScrollableArea, {
35184
- children: /* @__PURE__ */ jsx("div", {
35312
+ if (renderer) {
35313
+ return /* @__PURE__ */ jsx(DOMElement, {
35314
+ element: renderer,
35315
+ style: {
35316
+ overflow: "hidden",
35317
+ height: "100%"
35318
+ }
35319
+ });
35320
+ } else {
35321
+ return /* @__PURE__ */ jsx("div", {
35185
35322
  ...{
35186
35323
  className: "mly78zum5 mlyl56j7k mly6s0dn4"
35187
35324
  },
@@ -35196,8 +35333,8 @@ function RenderedResult({
35196
35333
  children: "Rendering..."
35197
35334
  })]
35198
35335
  })
35199
- })
35200
- });
35336
+ });
35337
+ }
35201
35338
  }
35202
35339
  function LoadingDisplay({
35203
35340
  onCancel,
@@ -35394,7 +35531,7 @@ function ResultPanel({
35394
35531
  children: [/* @__PURE__ */ jsx(Content, {
35395
35532
  value: "Results",
35396
35533
  ...{
35397
- className: "mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619 mlyysyzu8"
35534
+ className: "mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619"
35398
35535
  },
35399
35536
  children: submittedQuery && /* @__PURE__ */ jsxs(Fragment, {
35400
35537
  children: [draftQuery && submittedQuery && !queriesAreEqual(draftQuery, submittedQuery.query) && /* @__PURE__ */ jsxs("div", {
@@ -35753,6 +35890,7 @@ function FieldTokenWithActions({
35753
35890
  isOrderByAllowed
35754
35891
  } = useOperations(view, field, path);
35755
35892
  const [isFilterPopoverOpen, setIsFilterPopoverOpen] = useState();
35893
+ const [isTooltipOpen, setIsTooltipOpen] = useState(false);
35756
35894
  const handleAddOperationAction = (operation, filter) => {
35757
35895
  if (field.kind === "dimension" || field.kind === "measure") {
35758
35896
  if (operation === "groupBy" && isGroupByAllowed) {
@@ -35760,15 +35898,9 @@ function FieldTokenWithActions({
35760
35898
  } else if (operation === "aggregate" && isAggregateAllowed) {
35761
35899
  addAggregate(view, field, path);
35762
35900
  } else if (operation === "orderBy" && isOrderByAllowed) {
35763
- const segment = view.getOrAddDefaultSegment();
35764
- segment.addOrderBy(field.name, "asc");
35901
+ addOrderBy(view, field);
35765
35902
  } else if (operation === "filter" && isFilterAllowed && filter) {
35766
- const segment = view.getOrAddDefaultSegment();
35767
- if (field.kind === "dimension") {
35768
- segment.addWhere(field.name, path, filter);
35769
- } else {
35770
- segment.addHaving(field.name, path, filter);
35771
- }
35903
+ addFilter(view, field, path, filter);
35772
35904
  }
35773
35905
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35774
35906
  }
@@ -35792,18 +35924,21 @@ function FieldTokenWithActions({
35792
35924
  icon: "insert",
35793
35925
  disabled: !(rootQuery == null ? void 0 : rootQuery.isEmpty()),
35794
35926
  onClick: handleSetView,
35795
- tooltip: "Add view"
35927
+ tooltip: "Add view",
35928
+ onTooltipOpenChange: setIsTooltipOpen
35796
35929
  }), /* @__PURE__ */ jsx(ActionButton, {
35797
35930
  icon: "nest",
35798
35931
  onClick: handleAddView,
35799
- tooltip: "Add as new nested query"
35932
+ tooltip: "Add as new nested query",
35933
+ onTooltipOpenChange: setIsTooltipOpen
35800
35934
  })]
35801
35935
  }) : field.kind === "measure" ? /* @__PURE__ */ jsxs(Fragment, {
35802
35936
  children: [/* @__PURE__ */ jsx(ActionButton, {
35803
35937
  icon: "aggregate",
35804
35938
  tooltip: "Add as aggregate",
35805
35939
  disabled: !isAggregateAllowed,
35806
- onClick: () => handleAddOperationAction("aggregate")
35940
+ onClick: () => handleAddOperationAction("aggregate"),
35941
+ onTooltipOpenChange: setIsTooltipOpen
35807
35942
  }), /* @__PURE__ */ jsx(FilterPopover, {
35808
35943
  fieldInfo: field,
35809
35944
  path,
@@ -35811,21 +35946,24 @@ function FieldTokenWithActions({
35811
35946
  trigger: /* @__PURE__ */ jsx(ActionButton, {
35812
35947
  icon: "filter",
35813
35948
  tooltip: "Add as filter",
35814
- disabled: !isFilterAllowed
35949
+ disabled: !isFilterAllowed,
35950
+ onTooltipOpenChange: setIsTooltipOpen
35815
35951
  }),
35816
35952
  onOpenChange: setIsFilterPopoverOpen
35817
35953
  }), /* @__PURE__ */ jsx(ActionButton, {
35818
35954
  icon: "orderBy",
35819
35955
  tooltip: "Add as order by",
35820
35956
  disabled: !isOrderByAllowed,
35821
- onClick: () => handleAddOperationAction("orderBy")
35957
+ onClick: () => handleAddOperationAction("orderBy"),
35958
+ onTooltipOpenChange: setIsTooltipOpen
35822
35959
  })]
35823
35960
  }) : field.kind === "dimension" ? /* @__PURE__ */ jsxs(Fragment, {
35824
35961
  children: [/* @__PURE__ */ jsx(ActionButton, {
35825
35962
  icon: "groupBy",
35826
35963
  tooltip: "Add as group by",
35827
35964
  disabled: !isGroupByAllowed,
35828
- onClick: () => handleAddOperationAction("groupBy")
35965
+ onClick: () => handleAddOperationAction("groupBy"),
35966
+ onTooltipOpenChange: setIsTooltipOpen
35829
35967
  }), /* @__PURE__ */ jsx(FilterPopover, {
35830
35968
  fieldInfo: field,
35831
35969
  path,
@@ -35833,17 +35971,20 @@ function FieldTokenWithActions({
35833
35971
  trigger: /* @__PURE__ */ jsx(ActionButton, {
35834
35972
  icon: "filter",
35835
35973
  tooltip: "Add as filter",
35836
- disabled: !isFilterAllowed
35974
+ disabled: !isFilterAllowed,
35975
+ onTooltipOpenChange: setIsTooltipOpen
35837
35976
  }),
35838
35977
  onOpenChange: setIsFilterPopoverOpen
35839
35978
  }), /* @__PURE__ */ jsx(ActionButton, {
35840
35979
  icon: "orderBy",
35841
35980
  tooltip: "Add as order by",
35842
35981
  disabled: !isOrderByAllowed,
35843
- onClick: () => handleAddOperationAction("orderBy")
35982
+ onClick: () => handleAddOperationAction("orderBy"),
35983
+ onTooltipOpenChange: setIsTooltipOpen
35844
35984
  })]
35845
35985
  }) : null,
35846
- hoverActionsVisible: isFilterPopoverOpen,
35986
+ onClick: field.kind === "dimension" && isGroupByAllowed ? () => handleAddOperationAction("groupBy") : field.kind === "measure" && isAggregateAllowed ? () => handleAddOperationAction("aggregate") : field.kind === "view" ? () => handleAddView() : void 0,
35987
+ hoverActionsVisible: isFilterPopoverOpen || isTooltipOpen,
35847
35988
  tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
35848
35989
  field,
35849
35990
  path
@@ -35855,11 +35996,28 @@ function FieldTokenWithActions({
35855
35996
  }
35856
35997
  });
35857
35998
  }
35858
- function ActionButton(props2) {
35859
- return /* @__PURE__ */ jsx(Button, {
35860
- variant: "flat",
35861
- size: "compact",
35862
- ...props2
35999
+ function ActionButton({
36000
+ tooltip,
36001
+ onTooltipOpenChange,
36002
+ ...props2
36003
+ }) {
36004
+ return /* @__PURE__ */ jsxs(Tooltip, {
36005
+ delayDuration: 300,
36006
+ onOpenChange: onTooltipOpenChange,
36007
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, {
36008
+ asChild: true,
36009
+ children: /* @__PURE__ */ jsx(Button, {
36010
+ variant: "flat",
36011
+ size: "compact",
36012
+ ...props2
36013
+ })
36014
+ }), /* @__PURE__ */ jsx(TooltipPortal, {
36015
+ children: /* @__PURE__ */ jsx(TooltipContent, {
36016
+ sideOffset: 8,
36017
+ ..._stylex.props(fontStyles.body, tooltipStyles.default),
36018
+ children: tooltip
36019
+ })
36020
+ })]
35863
36021
  });
35864
36022
  }
35865
36023
  const FIELD_KIND_ORDER = ["dimension", "measure", "view"];