@malloydata/malloy-explorer 0.0.269-dev250430234249 → 0.0.275-dev250509203914

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, ASTLimitViewOperation, ASTNestViewOperation, ASTOrderByViewOperation, 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";
@@ -3332,13 +3331,19 @@ function MalloyExplorerProvider({
3332
3331
  topValues
3333
3332
  }) {
3334
3333
  const rootQuery = useQueryBuilder(source, query);
3334
+ const [currentNestView, setCurrentNestView] = React.useState(null);
3335
+ const [currentNestQueryPanel, setCurrentNestQueryPanel] = React.useState(null);
3335
3336
  return /* @__PURE__ */ jsx(TooltipProvider, {
3336
3337
  children: /* @__PURE__ */ jsx(QueryEditorContext.Provider, {
3337
3338
  value: {
3338
3339
  source,
3339
3340
  rootQuery,
3340
3341
  setQuery,
3341
- topValues
3342
+ topValues,
3343
+ currentNestQueryPanel,
3344
+ onCurrentNestQueryPanelChange: setCurrentNestQueryPanel,
3345
+ currentNestView,
3346
+ onCurrentNestViewChange: setCurrentNestView
3342
3347
  },
3343
3348
  children
3344
3349
  })
@@ -3817,10 +3822,10 @@ function Icon({
3817
3822
  return null;
3818
3823
  }
3819
3824
  return /* @__PURE__ */ jsx(IconComponent, {
3820
- ..._stylex.props(styles$M.main, colorVariants$3[color], SMALL_ICONS.includes(name) && styles$M.scaleUp, customStyle)
3825
+ ..._stylex.props(styles$N.main, colorVariants$3[color], SMALL_ICONS.includes(name) && styles$N.scaleUp, customStyle)
3821
3826
  });
3822
3827
  }
3823
- const styles$M = {
3828
+ const styles$N = {
3824
3829
  main: {
3825
3830
  display: "mly1rg5ohu",
3826
3831
  width: "mly1kky2od",
@@ -3893,17 +3898,17 @@ function Badge({
3893
3898
  customStyle
3894
3899
  }) {
3895
3900
  return /* @__PURE__ */ jsxs("div", {
3896
- ..._stylex.props(styles$L.main, colorVariants$2[color], customStyle),
3901
+ ..._stylex.props(styles$M.main, colorVariants$2[color], customStyle),
3897
3902
  children: [icon && /* @__PURE__ */ jsx(Icon, {
3898
3903
  color,
3899
3904
  name: icon
3900
3905
  }), /* @__PURE__ */ jsx("div", {
3901
- ..._stylex.props(fontStyles.badge, styles$L.label),
3906
+ ..._stylex.props(fontStyles.badge, styles$M.label),
3902
3907
  children: label
3903
3908
  })]
3904
3909
  });
3905
3910
  }
3906
- const styles$L = {
3911
+ const styles$M = {
3907
3912
  main: {
3908
3913
  display: "mly3nfvp2",
3909
3914
  height: "mly1qx5ct2",
@@ -3985,10 +3990,10 @@ function Divider({
3985
3990
  customStyle
3986
3991
  }) {
3987
3992
  return /* @__PURE__ */ jsx("div", {
3988
- ..._stylex.props(styles$K.main, orientationVariants[orientation], customStyle)
3993
+ ..._stylex.props(styles$L.main, orientationVariants[orientation], customStyle)
3989
3994
  });
3990
3995
  }
3991
- const styles$K = {
3996
+ const styles$L = {
3992
3997
  main: {
3993
3998
  background: "mly1xnbgy5",
3994
3999
  backgroundAttachment: null,
@@ -4789,19 +4794,12 @@ function Button({
4789
4794
  icon,
4790
4795
  label,
4791
4796
  tooltip,
4792
- onClick,
4793
4797
  isDisabled = false,
4794
4798
  customStyle,
4795
4799
  ...props2
4796
4800
  }) {
4797
4801
  const button = /* @__PURE__ */ jsxs("button", {
4798
- ..._stylex.props(styles$J.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4799
- ...onClick && {
4800
- onClick: (e) => {
4801
- e.preventDefault();
4802
- onClick(e);
4803
- }
4804
- },
4802
+ ..._stylex.props(styles$K.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4805
4803
  type: "button",
4806
4804
  disabled: isDisabled,
4807
4805
  ...props2,
@@ -4811,9 +4809,9 @@ function Button({
4811
4809
  },
4812
4810
  children: [icon && /* @__PURE__ */ jsx(Icon, {
4813
4811
  name: icon,
4814
- customStyle: styles$J.icon
4812
+ customStyle: styles$K.icon
4815
4813
  }), label && /* @__PURE__ */ jsx("div", {
4816
- ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$J.label),
4814
+ ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$K.label),
4817
4815
  children: label
4818
4816
  })]
4819
4817
  }), isDisabled && /* @__PURE__ */ jsx("div", {
@@ -4840,7 +4838,7 @@ function Button({
4840
4838
  return button;
4841
4839
  }
4842
4840
  }
4843
- const styles$J = {
4841
+ const styles$K = {
4844
4842
  main: {
4845
4843
  display: "mly3nfvp2",
4846
4844
  flexDirection: "mlydt5ytf",
@@ -5091,7 +5089,7 @@ function Token({
5091
5089
  }) {
5092
5090
  const isInteractive = onClick !== void 0 || asButtonTrigger;
5093
5091
  const token2 = /* @__PURE__ */ jsxs("div", {
5094
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$I.nonInteractive, customStyle),
5092
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$J.nonInteractive, customStyle),
5095
5093
  ...dragProps == null ? void 0 : dragProps.attributes,
5096
5094
  ...dragProps == null ? void 0 : dragProps.listeners,
5097
5095
  children: [icon && /* @__PURE__ */ jsx(Icon, {
@@ -5128,7 +5126,7 @@ function Token({
5128
5126
  })]
5129
5127
  }) : token2;
5130
5128
  }
5131
- const styles$I = {
5129
+ const styles$J = {
5132
5130
  nonInteractive: {
5133
5131
  cursor: "mlyt0e3qv",
5134
5132
  background: "mly1np9qvj",
@@ -5152,7 +5150,7 @@ function TokenGroup({
5152
5150
  }) {
5153
5151
  const count2 = React.Children.count(children);
5154
5152
  return /* @__PURE__ */ jsx("div", {
5155
- ..._stylex.props(styles$H.main, customStyle),
5153
+ ..._stylex.props(styles$I.main, customStyle),
5156
5154
  children: React.Children.map(children, (child, index2) => /* @__PURE__ */ React.cloneElement(child, {
5157
5155
  customStyle: {
5158
5156
  ...child.props.customStyle,
@@ -5163,16 +5161,16 @@ function TokenGroup({
5163
5161
  });
5164
5162
  }
5165
5163
  const getChildStyle = (index2, count2) => {
5166
- if (count2 === 1) return styles$H.onlyChild;
5167
- if (index2 === 0) return styles$H.firstChild;
5168
- if (index2 === count2 - 1) return styles$H.lastChild;
5169
- return styles$H.innerChild;
5164
+ if (count2 === 1) return styles$I.onlyChild;
5165
+ if (index2 === 0) return styles$I.firstChild;
5166
+ if (index2 === count2 - 1) return styles$I.lastChild;
5167
+ return styles$I.innerChild;
5170
5168
  };
5171
5169
  const getTokenColor = (child, groupColor) => {
5172
5170
  const childColor = child.props.color;
5173
5171
  return childColor === void 0 ? groupColor : childColor;
5174
5172
  };
5175
- const styles$H = {
5173
+ const styles$I = {
5176
5174
  main: {
5177
5175
  display: "mlyrvj5dj",
5178
5176
  gridAutoFlow: "mly1mt1orb",
@@ -5244,7 +5242,7 @@ function ErrorIcon({
5244
5242
  },
5245
5243
  children: /* @__PURE__ */ jsx(Icon, {
5246
5244
  name: "warning",
5247
- customStyle: styles$G.errorIcon
5245
+ customStyle: styles$H.errorIcon
5248
5246
  })
5249
5247
  })
5250
5248
  }), /* @__PURE__ */ jsx(TooltipPortal, {
@@ -5257,7 +5255,7 @@ function ErrorIcon({
5257
5255
  })]
5258
5256
  });
5259
5257
  }
5260
- const styles$G = {
5258
+ const styles$H = {
5261
5259
  errorIcon: {
5262
5260
  color: "mly1e2nbdu",
5263
5261
  $$css: true
@@ -5302,22 +5300,22 @@ function EditableToken({
5302
5300
  className: "mly78zum5 mly6s0dn4"
5303
5301
  },
5304
5302
  children: [/* @__PURE__ */ jsxs("div", {
5305
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$F.focused, !!errorMessage && styles$F.hasError, customStyle),
5303
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$G.focused, !!errorMessage && styles$G.hasError, customStyle),
5306
5304
  children: [icon && /* @__PURE__ */ jsx(Icon, {
5307
5305
  name: icon,
5308
- customStyle: styles$F.icon
5306
+ customStyle: styles$G.icon
5309
5307
  }), /* @__PURE__ */ jsxs("span", {
5310
5308
  ...{
5311
5309
  className: "mlywz0xwf"
5312
5310
  },
5313
5311
  children: [/* @__PURE__ */ jsx("span", {
5314
- ..._stylex.props(fontStyles.body, styles$F.placeholder),
5312
+ ..._stylex.props(fontStyles.body, styles$G.placeholder),
5315
5313
  style: {
5316
5314
  whiteSpaceCollapse: "preserve"
5317
5315
  },
5318
5316
  children: value
5319
5317
  }), /* @__PURE__ */ jsx("input", {
5320
- ..._stylex.props(styles$F.input, fontStyles.body),
5318
+ ..._stylex.props(styles$G.input, fontStyles.body),
5321
5319
  ref: inputRef,
5322
5320
  pattern: type === "number" ? "^-?[0-9.]*$" : void 0,
5323
5321
  value,
@@ -5342,7 +5340,7 @@ function EditableToken({
5342
5340
  })]
5343
5341
  });
5344
5342
  }
5345
- const styles$F = {
5343
+ const styles$G = {
5346
5344
  focused: {
5347
5345
  background: "mlyotlr4g",
5348
5346
  backgroundAttachment: null,
@@ -7684,12 +7682,12 @@ function TextInput({
7684
7682
  }
7685
7683
  };
7686
7684
  return /* @__PURE__ */ jsxs("div", {
7687
- ..._stylex.props(styles$E.main, isFocused && styles$E.focused, sizeVariants[size2], customStyle),
7685
+ ..._stylex.props(styles$F.main, isFocused && styles$F.focused, sizeVariants[size2], customStyle),
7688
7686
  children: [icon && /* @__PURE__ */ jsx(Icon, {
7689
7687
  name: icon,
7690
7688
  color: "secondary"
7691
7689
  }), /* @__PURE__ */ jsx("input", {
7692
- ..._stylex.props(fontStyles.body, styles$E.input),
7690
+ ..._stylex.props(fontStyles.body, styles$F.input),
7693
7691
  value,
7694
7692
  placeholder,
7695
7693
  onChange: handleChange,
@@ -7697,7 +7695,7 @@ function TextInput({
7697
7695
  onBlur: handleBlur,
7698
7696
  onKeyDown
7699
7697
  }), hasClear && /* @__PURE__ */ jsx("button", {
7700
- ..._stylex.props(fontStyles.supporting, styles$E.actionButton, value === "" && styles$E.hidden),
7698
+ ..._stylex.props(fontStyles.supporting, styles$F.actionButton, value === "" && styles$F.hidden),
7701
7699
  ref: buttonRef,
7702
7700
  onClick: () => onChange(""),
7703
7701
  tabIndex: 0,
@@ -7705,7 +7703,7 @@ function TextInput({
7705
7703
  })]
7706
7704
  });
7707
7705
  }
7708
- const styles$E = {
7706
+ const styles$F = {
7709
7707
  main: {
7710
7708
  display: "mly78zum5",
7711
7709
  alignItems: "mly6s0dn4",
@@ -7914,7 +7912,7 @@ function SelectorToken({
7914
7912
  onValueChange: handleValueChange,
7915
7913
  required: true,
7916
7914
  children: [/* @__PURE__ */ jsxs(Trigger$3, {
7917
- ..._stylex.props(tokenStyles.main, styles$D.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], fontStyles.body, tokenStyles.label, customStyle),
7915
+ ..._stylex.props(tokenStyles.main, styles$E.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], fontStyles.body, tokenStyles.label, customStyle),
7918
7916
  children: [icon && /* @__PURE__ */ jsx(Icon, {
7919
7917
  name: icon,
7920
7918
  customStyle: tokenStyles.icon
@@ -7943,7 +7941,7 @@ function SelectorToken({
7943
7941
  size: "compact",
7944
7942
  icon: "search",
7945
7943
  hasClear: true,
7946
- customStyle: styles$D.searchInput,
7944
+ customStyle: styles$E.searchInput,
7947
7945
  onKeyDown: (event) => {
7948
7946
  const excludedKeys = ["ArrowUp", "ArrowDown"];
7949
7947
  if (!excludedKeys.includes(event.key)) {
@@ -7976,21 +7974,21 @@ function SelectItem({
7976
7974
  ...props2
7977
7975
  }) {
7978
7976
  return /* @__PURE__ */ jsxs(Item$1, {
7979
- ..._stylex.props(fontStyles.body, styles$D.selectItem),
7977
+ ..._stylex.props(fontStyles.body, styles$E.selectItem),
7980
7978
  value,
7981
7979
  ...props2,
7982
7980
  children: [value === selectedValue ? /* @__PURE__ */ jsx(Icon, {
7983
7981
  name: "radioChecked",
7984
- customStyle: styles$D.radioChecked
7982
+ customStyle: styles$E.radioChecked
7985
7983
  }) : /* @__PURE__ */ jsx(Icon, {
7986
7984
  name: "radioUnchecked",
7987
- customStyle: styles$D.radioUnchecked
7985
+ customStyle: styles$E.radioUnchecked
7988
7986
  }), /* @__PURE__ */ jsx(ItemText, {
7989
7987
  children
7990
7988
  })]
7991
7989
  });
7992
7990
  }
7993
- const styles$D = {
7991
+ const styles$E = {
7994
7992
  selectTrigger: {
7995
7993
  whiteSpace: "mlyuxw1ft",
7996
7994
  overflow: "mlyb3r6kr",
@@ -8080,7 +8078,7 @@ function Card({
8080
8078
  customStyle
8081
8079
  }) {
8082
8080
  return /* @__PURE__ */ jsxs("div", {
8083
- ..._stylex.props(styles$C.container, customStyle),
8081
+ ..._stylex.props(styles$D.container, customStyle),
8084
8082
  children: [/* @__PURE__ */ jsx("div", {
8085
8083
  ...{
8086
8084
  className: "mly1717udv"
@@ -8094,7 +8092,7 @@ function Card({
8094
8092
  })]
8095
8093
  });
8096
8094
  }
8097
- const styles$C = {
8095
+ const styles$D = {
8098
8096
  container: {
8099
8097
  display: "mly78zum5",
8100
8098
  flexDirection: "mlydt5ytf",
@@ -8158,6 +8156,82 @@ const styles$C = {
8158
8156
  $$css: true
8159
8157
  }
8160
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
+ };
8161
8235
  function CollapsibleListItem({
8162
8236
  label,
8163
8237
  sublabel,
@@ -19497,7 +19571,7 @@ function invalidDate() {
19497
19571
  return this._invalidDate;
19498
19572
  }
19499
19573
  var defaultOrdinal = "%d", defaultDayOfMonthOrdinalParse = /\d{1,2}/;
19500
- function ordinal(number2) {
19574
+ function ordinal$1(number2) {
19501
19575
  return this._ordinal.replace("%d", number2);
19502
19576
  }
19503
19577
  var defaultRelativeTime = {
@@ -22626,7 +22700,7 @@ var proto$1 = Locale.prototype;
22626
22700
  proto$1.calendar = calendar;
22627
22701
  proto$1.longDateFormat = longDateFormat;
22628
22702
  proto$1.invalidDate = invalidDate;
22629
- proto$1.ordinal = ordinal;
22703
+ proto$1.ordinal = ordinal$1;
22630
22704
  proto$1.preparse = preParsePostFormat;
22631
22705
  proto$1.postformat = preParsePostFormat;
22632
22706
  proto$1.relativeTime = relativeTime;
@@ -23599,25 +23673,113 @@ function SelectList({
23599
23673
  })
23600
23674
  });
23601
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
+ };
23602
23755
  function monthName(month) {
23603
23756
  return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][month];
23604
23757
  }
23758
+ const ordinal = Object.keys(formats);
23605
23759
  function DatePicker({
23606
23760
  value,
23607
23761
  setValue,
23608
23762
  units,
23609
23763
  maxLevel,
23610
- customStyle
23764
+ customStyle,
23765
+ forwardRef
23611
23766
  }) {
23612
23767
  const [date, setDate] = useState(value);
23613
23768
  const calendar2 = getCalendar(date);
23614
23769
  const [pickLevel, setPickLevel] = useState(units);
23615
- const yearBucket = Math.floor(hooks(date).year() / 10) * 10;
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]);
23619
23781
  const setYear = (year) => {
23620
- const newDate = hooks(date).year(year).toDate();
23782
+ const newDate = hooks.utc(date).year(year).toDate();
23621
23783
  setDate(newDate);
23622
23784
  setValue(newDate);
23623
23785
  };
@@ -23641,12 +23803,12 @@ function DatePicker({
23641
23803
  1: {
23642
23804
  className: "mly1247r65 mlyfvyar9 mlymcgfsh mly36usyh mly78zum5 mly6s0dn4 mlyl56j7k mly8fuzfi mly1v5ugh9 mly1fcty0u mly1ypdohk mly6mezaz mly1sxf85j mlyt89l8w mly1fxp9ov mly6wxqrg mly10bk7bj"
23643
23805
  }
23644
- }[!!(hooks(date).year() === yearBucket + offset2) << 0],
23806
+ }[!!(hooks.utc(date).year() === yearBucket + offset2) << 0],
23645
23807
  children: yearBucket + offset2
23646
23808
  });
23647
23809
  };
23648
23810
  const setMonth2 = (month) => {
23649
- const newDate = hooks(date).month(month).toDate();
23811
+ const newDate = hooks.utc(date).month(month).toDate();
23650
23812
  setDate(newDate);
23651
23813
  setValue(newDate);
23652
23814
  };
@@ -23659,13 +23821,13 @@ function DatePicker({
23659
23821
  setValue(dateOfFirstDayOfWeek);
23660
23822
  };
23661
23823
  const setQuarter = (quarter) => {
23662
- const newDate = hooks(date).quarter(quarter + 1).toDate();
23824
+ const newDate = hooks.utc(date).quarter(quarter + 1).toDate();
23663
23825
  setDate(newDate);
23664
23826
  setValue(newDate);
23665
23827
  };
23666
23828
  const monthButton = (month) => {
23667
23829
  const click = () => setMonth2(month);
23668
- const isSelected = hooks(date).month() === month && hooks(date).year() === hooks(value).year();
23830
+ const isSelected = hooks.utc(date).month() === month && hooks.utc(date).year() === hooks.utc(value).year();
23669
23831
  return /* @__PURE__ */ jsx("div", {
23670
23832
  onClick: click,
23671
23833
  ...{
@@ -23681,7 +23843,7 @@ function DatePicker({
23681
23843
  };
23682
23844
  const quarterButton = (quarter) => {
23683
23845
  const click = () => setQuarter(quarter);
23684
- const isSelected = hooks(date).quarter() - 1 === quarter && hooks(date).year() === hooks(value).year();
23846
+ const isSelected = hooks.utc(date).quarter() - 1 === quarter && hooks.utc(date).year() === hooks.utc(value).year();
23685
23847
  return /* @__PURE__ */ jsxs("div", {
23686
23848
  onClick: click,
23687
23849
  ...{
@@ -23696,7 +23858,8 @@ function DatePicker({
23696
23858
  });
23697
23859
  };
23698
23860
  return /* @__PURE__ */ jsxs("div", {
23699
- ..._stylex.props(styles$y.outer, customStyle),
23861
+ ..._stylex.props(styles$x.outer, customStyle),
23862
+ ref: forwardRef,
23700
23863
  children: [/* @__PURE__ */ jsxs("div", {
23701
23864
  ...{
23702
23865
  className: "mly78zum5 mly1q0g3np mly1qughib mly1nejdyq mlyu06os2"
@@ -23711,13 +23874,13 @@ function DatePicker({
23711
23874
  icon: "chevronLeft",
23712
23875
  onClick: () => {
23713
23876
  if (pickLevel === "day" || pickLevel === "week") {
23714
- setDate(hooks(date).subtract(1, "month").toDate());
23877
+ setDate(hooks.utc(date).subtract(1, "month").toDate());
23715
23878
  } else if (pickLevel === "month" || pickLevel === "quarter") {
23716
- setDate(hooks(date).subtract(1, "year").toDate());
23879
+ setDate(hooks.utc(date).subtract(1, "year").toDate());
23717
23880
  } else if (pickLevel === "year") {
23718
- setDate(hooks(date).subtract(10, "years").toDate());
23881
+ setDate(hooks.utc(date).subtract(10, "years").toDate());
23719
23882
  } else {
23720
- setDay(hooks(date).subtract(1, "days").toDate());
23883
+ setDay(hooks.utc(date).subtract(1, "days").toDate());
23721
23884
  }
23722
23885
  }
23723
23886
  })
@@ -23736,10 +23899,10 @@ function DatePicker({
23736
23899
  setPickLevel(maxLevel);
23737
23900
  }
23738
23901
  },
23739
- children: [(pickLevel === "day" || pickLevel === "week") && hooks(date).format("MMMM YYYY"), (pickLevel === "month" || pickLevel === "quarter") && hooks(date).format("YYYY"), pickLevel === "year" && /* @__PURE__ */ jsxs(Fragment, {
23902
+ children: [(pickLevel === "day" || pickLevel === "week") && hooks.utc(date).format("MMMM YYYY"), (pickLevel === "month" || pickLevel === "quarter") && hooks.utc(date).format("YYYY"), pickLevel === "year" && /* @__PURE__ */ jsxs(Fragment, {
23740
23903
  children: [yearBucket, "-", yearBucket + 9]
23741
23904
  }), (pickLevel === "hour" || pickLevel === "minute" || pickLevel === "second") && /* @__PURE__ */ jsx(Fragment, {
23742
- children: hooks(date).format("MMMM D, YYYY")
23905
+ children: hooks.utc(date).format("MMMM D, YYYY")
23743
23906
  })]
23744
23907
  }), /* @__PURE__ */ jsx("div", {
23745
23908
  ...{
@@ -23751,13 +23914,13 @@ function DatePicker({
23751
23914
  icon: "chevronRight",
23752
23915
  onClick: () => {
23753
23916
  if (pickLevel === "day" || pickLevel === "week") {
23754
- setDate(hooks(date).add(1, "month").toDate());
23917
+ setDate(hooks.utc(date).add(1, "month").toDate());
23755
23918
  } else if (pickLevel === "month" || pickLevel === "quarter") {
23756
- setDate(hooks(date).add(1, "year").toDate());
23919
+ setDate(hooks.utc(date).add(1, "year").toDate());
23757
23920
  } else if (pickLevel === "year") {
23758
- setDate(hooks(date).add(10, "years").toDate());
23921
+ setDate(hooks.utc(date).add(10, "years").toDate());
23759
23922
  } else {
23760
- setDay(hooks(date).add(1, "days").toDate());
23923
+ setDay(hooks.utc(date).add(1, "days").toDate());
23761
23924
  }
23762
23925
  }
23763
23926
  })
@@ -23964,25 +24127,25 @@ function DatePicker({
23964
24127
  },
23965
24128
  children: [/* @__PURE__ */ jsx(NumberInput, {
23966
24129
  label: "Hours",
23967
- value: parseInt(hooks(date).format("hh")),
24130
+ value: parseInt(hooks.utc(date).format("hh")),
23968
24131
  setValue: (hour12) => {
23969
- const amPm = hooks(date).hour() >= 12 ? "PM" : "AM";
23970
- const newHour24 = parseInt(hooks(`${hour12} ${amPm}`, ["hh A"]).format("H"));
23971
- setValue(hooks(date).hour(newHour24).toDate());
24132
+ const amPm = hooks.utc(date).hour() >= 12 ? "PM" : "AM";
24133
+ const newHour24 = parseInt(hooks.utc(`${hour12} ${amPm}`, ["hh A"]).format("H"));
24134
+ setValue(hooks.utc(date).hour(newHour24).toDate());
23972
24135
  },
23973
24136
  width: "40px"
23974
24137
  }), (units === "minute" || units === "second") && /* @__PURE__ */ jsx(NumberInput, {
23975
24138
  label: "Minutes",
23976
- value: hooks(date).minutes(),
24139
+ value: hooks.utc(date).minutes(),
23977
24140
  setValue: (minute) => {
23978
- setValue(hooks(date).minute(minute).toDate());
24141
+ setValue(hooks.utc(date).minute(minute).toDate());
23979
24142
  },
23980
24143
  width: "40px"
23981
24144
  }), units === "second" && /* @__PURE__ */ jsx(NumberInput, {
23982
24145
  label: "Seconds",
23983
- value: hooks(date).seconds(),
24146
+ value: hooks.utc(date).seconds(),
23984
24147
  setValue: (second) => {
23985
- setValue(hooks(date).second(second).toDate());
24148
+ setValue(hooks.utc(date).second(second).toDate());
23986
24149
  },
23987
24150
  width: "40px"
23988
24151
  }), /* @__PURE__ */ jsx("div", {
@@ -23992,11 +24155,11 @@ function DatePicker({
23992
24155
  flexDirection: "column"
23993
24156
  },
23994
24157
  children: /* @__PURE__ */ jsx(SelectDropdown, {
23995
- value: hooks(date).hour() >= 12 ? "PM" : "AM",
24158
+ value: hooks.utc(date).hour() >= 12 ? "PM" : "AM",
23996
24159
  onChange: (amPm) => {
23997
- const hour12 = parseInt(hooks(date).format("h"));
23998
- const newHour24 = parseInt(hooks(`${hour12} ${amPm}`, ["hh A"]).format("H"));
23999
- setValue(hooks(date).hour(newHour24).toDate());
24160
+ const hour12 = parseInt(hooks.utc(date).format("h"));
24161
+ const newHour24 = parseInt(hooks.utc(`${hour12} ${amPm}`, ["hh A"]).format("H"));
24162
+ setValue(hooks.utc(date).hour(newHour24).toDate());
24000
24163
  },
24001
24164
  options: [{
24002
24165
  value: "AM",
@@ -24011,7 +24174,7 @@ function DatePicker({
24011
24174
  })]
24012
24175
  });
24013
24176
  }
24014
- const styles$y = {
24177
+ const styles$x = {
24015
24178
  outer: {
24016
24179
  userSelect: "mly87ps6o",
24017
24180
  fontSize: "mlymhiqyu",
@@ -24020,7 +24183,7 @@ const styles$y = {
24020
24183
  }
24021
24184
  };
24022
24185
  function getCalendar(date) {
24023
- const firstDayOfMonth = hooks(date).date(1);
24186
+ const firstDayOfMonth = hooks.utc(date).date(1);
24024
24187
  const dow = firstDayOfMonth.day();
24025
24188
  const daysInMonth2 = firstDayOfMonth.daysInMonth();
24026
24189
  const daysInPreviousMonth = firstDayOfMonth.clone().subtract(1, "day").daysInMonth();
@@ -24097,7 +24260,7 @@ function Banner({
24097
24260
  className: "mly1q4ynmn mlyh8yej3 mly5yr21d mly78zum5 mlydt5ytf mly1kmqopl mly16zck5j"
24098
24261
  },
24099
24262
  children: [/* @__PURE__ */ jsxs("div", {
24100
- ..._stylex.props(styles$x.header, variantColors[variant], children ? styles$x.headerWithContent : null),
24263
+ ..._stylex.props(styles$w.header, variantColors[variant], children ? styles$w.headerWithContent : null),
24101
24264
  children: [/* @__PURE__ */ jsx("div", {
24102
24265
  ...{
24103
24266
  className: "mly1qx5ct2 mly78zum5 mlyl56j7k mly6s0dn4"
@@ -24110,22 +24273,22 @@ function Banner({
24110
24273
  className: "mly78zum5 mlydt5ytf mlyb3r6kr"
24111
24274
  },
24112
24275
  children: [/* @__PURE__ */ jsx("div", {
24113
- ..._stylex.props(styles$x.title, fontStyles.emphasized),
24276
+ ..._stylex.props(styles$w.title, fontStyles.emphasized),
24114
24277
  children: title
24115
24278
  }), /* @__PURE__ */ jsx("div", {
24116
- ..._stylex.props(styles$x.description, fontStyles.supporting),
24279
+ ..._stylex.props(styles$w.description, fontStyles.supporting),
24117
24280
  children: description
24118
24281
  })]
24119
24282
  })]
24120
24283
  }), children && /* @__PURE__ */ jsx("div", {
24121
- ..._stylex.props(styles$x.content, fontStyles.body),
24284
+ ..._stylex.props(styles$w.content, fontStyles.body),
24122
24285
  children: /* @__PURE__ */ jsx(ScrollableArea, {
24123
24286
  children
24124
24287
  })
24125
24288
  })]
24126
24289
  });
24127
24290
  }
24128
- const styles$x = {
24291
+ const styles$w = {
24129
24292
  header: {
24130
24293
  borderRadius: "mly1q4ynmn",
24131
24294
  borderStartStartRadius: null,
@@ -24267,14 +24430,14 @@ function AccordionList({
24267
24430
  onExpandedItemChange: handleExpandedItemChange
24268
24431
  },
24269
24432
  children: /* @__PURE__ */ jsx("div", {
24270
- ..._stylex.props(styles$w.main, customStyle),
24433
+ ..._stylex.props(styles$v.main, customStyle),
24271
24434
  children: React.Children.map(children, (child) => /* @__PURE__ */ jsxs(Fragment, {
24272
24435
  children: [child, /* @__PURE__ */ jsx(Divider, {})]
24273
24436
  }))
24274
24437
  })
24275
24438
  });
24276
24439
  }
24277
- const styles$w = {
24440
+ const styles$v = {
24278
24441
  main: {
24279
24442
  display: "mly78zum5",
24280
24443
  flexDirection: "mlydt5ytf",
@@ -24311,10 +24474,10 @@ function AccordionListItem({
24311
24474
  className: "mly78zum5 mlydt5ytf mlyb3r6kr mly1iyjqo2"
24312
24475
  },
24313
24476
  children: [/* @__PURE__ */ jsx("span", {
24314
- ..._stylex.props(fontStyles.body, styles$v.label),
24477
+ ..._stylex.props(fontStyles.body, styles$u.label),
24315
24478
  children: label
24316
24479
  }), sublabel && /* @__PURE__ */ jsx("span", {
24317
- ..._stylex.props(fontStyles.supporting, styles$v.sublabel),
24480
+ ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
24318
24481
  children: sublabel
24319
24482
  })]
24320
24483
  }), badge && badge, endIcon && endIcon]
@@ -24326,7 +24489,7 @@ function AccordionListItem({
24326
24489
  })]
24327
24490
  });
24328
24491
  }
24329
- const styles$v = {
24492
+ const styles$u = {
24330
24493
  label: {
24331
24494
  flexGrow: "mly1iyjqo2",
24332
24495
  fontWeight: "mly1xlr1w8",
@@ -25117,40 +25280,6 @@ var MenuArrow = React.forwardRef(
25117
25280
  MenuArrow.displayName = ARROW_NAME$1;
25118
25281
  var SUB_NAME = "MenuSub";
25119
25282
  var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
25120
- var MenuSub = (props2) => {
25121
- const { __scopeMenu, children, open = false, onOpenChange } = props2;
25122
- const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
25123
- const popperScope = usePopperScope(__scopeMenu);
25124
- const [trigger, setTrigger] = React.useState(null);
25125
- const [content, setContent] = React.useState(null);
25126
- const handleOpenChange = useCallbackRef$1(onOpenChange);
25127
- React.useEffect(() => {
25128
- if (parentMenuContext.open === false) handleOpenChange(false);
25129
- return () => handleOpenChange(false);
25130
- }, [parentMenuContext.open, handleOpenChange]);
25131
- return /* @__PURE__ */ jsx(Root2$4, { ...popperScope, children: /* @__PURE__ */ jsx(
25132
- MenuProvider,
25133
- {
25134
- scope: __scopeMenu,
25135
- open,
25136
- onOpenChange: handleOpenChange,
25137
- content,
25138
- onContentChange: setContent,
25139
- children: /* @__PURE__ */ jsx(
25140
- MenuSubProvider,
25141
- {
25142
- scope: __scopeMenu,
25143
- contentId: useId(),
25144
- triggerId: useId(),
25145
- trigger,
25146
- onTriggerChange: setTrigger,
25147
- children
25148
- }
25149
- )
25150
- }
25151
- ) });
25152
- };
25153
- MenuSub.displayName = SUB_NAME;
25154
25283
  var SUB_TRIGGER_NAME$1 = "MenuSubTrigger";
25155
25284
  var MenuSubTrigger = React.forwardRef(
25156
25285
  (props2, forwardedRef) => {
@@ -25371,7 +25500,6 @@ var RadioItem = MenuRadioItem;
25371
25500
  var ItemIndicator = MenuItemIndicator;
25372
25501
  var Separator = MenuSeparator;
25373
25502
  var Arrow2 = MenuArrow;
25374
- var Sub = MenuSub;
25375
25503
  var SubTrigger = MenuSubTrigger;
25376
25504
  var SubContent = MenuSubContent;
25377
25505
  var DROPDOWN_MENU_NAME = "DropdownMenu";
@@ -25510,14 +25638,14 @@ var DropdownMenuGroup = React.forwardRef(
25510
25638
  );
25511
25639
  DropdownMenuGroup.displayName = GROUP_NAME;
25512
25640
  var LABEL_NAME = "DropdownMenuLabel";
25513
- var DropdownMenuLabel$1 = React.forwardRef(
25641
+ var DropdownMenuLabel = React.forwardRef(
25514
25642
  (props2, forwardedRef) => {
25515
25643
  const { __scopeDropdownMenu, ...labelProps } = props2;
25516
25644
  const menuScope = useMenuScope(__scopeDropdownMenu);
25517
25645
  return /* @__PURE__ */ jsx(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
25518
25646
  }
25519
25647
  );
25520
- DropdownMenuLabel$1.displayName = LABEL_NAME;
25648
+ DropdownMenuLabel.displayName = LABEL_NAME;
25521
25649
  var ITEM_NAME = "DropdownMenuItem";
25522
25650
  var DropdownMenuItem$1 = React.forwardRef(
25523
25651
  (props2, forwardedRef) => {
@@ -25571,16 +25699,6 @@ var DropdownMenuArrow = React.forwardRef(
25571
25699
  }
25572
25700
  );
25573
25701
  DropdownMenuArrow.displayName = ARROW_NAME;
25574
- var DropdownMenuSub = (props2) => {
25575
- const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props2;
25576
- const menuScope = useMenuScope(__scopeDropdownMenu);
25577
- const [open = false, setOpen] = useControllableState({
25578
- prop: openProp,
25579
- defaultProp: defaultOpen,
25580
- onChange: onOpenChange
25581
- });
25582
- return /* @__PURE__ */ jsx(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
25583
- };
25584
25702
  var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
25585
25703
  var DropdownMenuSubTrigger = React.forwardRef((props2, forwardedRef) => {
25586
25704
  const { __scopeDropdownMenu, ...subTriggerProps } = props2;
@@ -25617,11 +25735,7 @@ var Root2$1 = DropdownMenu$1;
25617
25735
  var Trigger$1 = DropdownMenuTrigger;
25618
25736
  var Portal2 = DropdownMenuPortal;
25619
25737
  var Content2 = DropdownMenuContent;
25620
- var Label2 = DropdownMenuLabel$1;
25621
25738
  var Item2 = DropdownMenuItem$1;
25622
- var Sub2 = DropdownMenuSub;
25623
- var SubTrigger2 = DropdownMenuSubTrigger;
25624
- var SubContent2 = DropdownMenuSubContent;
25625
25739
  function DropdownMenu({
25626
25740
  trigger,
25627
25741
  tooltip,
@@ -25660,7 +25774,7 @@ function DropdownMenu({
25660
25774
  children: trigger
25661
25775
  }), /* @__PURE__ */ jsx(Portal2, {
25662
25776
  children: /* @__PURE__ */ jsx(Content2, {
25663
- ..._stylex.props(fontStyles.body, styles$u.content),
25777
+ ..._stylex.props(fontStyles.body, styles$t.content),
25664
25778
  side: "bottom",
25665
25779
  align: "start",
25666
25780
  sideOffset: 4,
@@ -25687,79 +25801,22 @@ function DropdownMenuItem({
25687
25801
  disabled,
25688
25802
  children: [icon && /* @__PURE__ */ jsx(Icon, {
25689
25803
  name: icon,
25690
- customStyle: styles$u.icon
25804
+ customStyle: styles$t.icon
25691
25805
  }), /* @__PURE__ */ jsxs("div", {
25692
25806
  ...{
25693
25807
  className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25694
25808
  },
25695
25809
  children: [/* @__PURE__ */ jsx("span", {
25696
- ..._stylex.props(fontStyles.body, styles$u.label),
25810
+ ..._stylex.props(fontStyles.body, styles$t.label),
25697
25811
  children: label
25698
25812
  }), sublabel && /* @__PURE__ */ jsx("span", {
25699
- ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
25813
+ ..._stylex.props(fontStyles.supporting, styles$t.sublabel),
25700
25814
  children: sublabel
25701
25815
  })]
25702
25816
  })]
25703
25817
  });
25704
25818
  }
25705
- function DropdownSubMenuItem({
25706
- icon,
25707
- label,
25708
- sublabel,
25709
- disabled,
25710
- children,
25711
- open,
25712
- onOpenChange
25713
- }) {
25714
- const isControlled = open !== void 0 && onOpenChange !== void 0;
25715
- return /* @__PURE__ */ jsxs(Sub2, {
25716
- ...isControlled && {
25717
- open
25718
- },
25719
- children: [/* @__PURE__ */ jsxs(SubTrigger2, {
25720
- ...{
25721
- className: "mly78zum5 mly6s0dn4 mlye8ttls mly167g77z mly1kogg8i mly1ypdohk mly1a2a7pz mly1bw6wve mly5ezrf1 mly15rdse5 mly1z060rf mly5deeek mly1jacekv mly7ouyw2 mly7h4d18"
25722
- },
25723
- disabled,
25724
- ...isControlled && {
25725
- onClick: () => onOpenChange(!open)
25726
- },
25727
- children: [icon && /* @__PURE__ */ jsx(Icon, {
25728
- name: icon,
25729
- customStyle: styles$u.icon
25730
- }), /* @__PURE__ */ jsxs("div", {
25731
- ...{
25732
- className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25733
- },
25734
- children: [/* @__PURE__ */ jsx("span", {
25735
- ..._stylex.props(fontStyles.body, styles$u.label),
25736
- children: label
25737
- }), sublabel && /* @__PURE__ */ jsx("span", {
25738
- ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
25739
- children: sublabel
25740
- })]
25741
- }), !isControlled && /* @__PURE__ */ jsx(Icon, {
25742
- name: "chevronRight",
25743
- customStyle: styles$u.icon
25744
- })]
25745
- }), /* @__PURE__ */ jsx(SubContent2, {
25746
- ...{
25747
- className: "mly78zum5 mlydt5ytf mly1q4ynmn mlyotlr4g mly17fq3gk mlyfawy5m"
25748
- },
25749
- sideOffset: 5,
25750
- children: React.Children.map(children, (child) => child)
25751
- })]
25752
- });
25753
- }
25754
- function DropdownMenuLabel({
25755
- label
25756
- }) {
25757
- return /* @__PURE__ */ jsx(Label2, {
25758
- ..._stylex.props(fontStyles.supporting, styles$u.menuLabel),
25759
- children: label
25760
- });
25761
- }
25762
- const styles$u = {
25819
+ const styles$t = {
25763
25820
  content: {
25764
25821
  display: "mly78zum5",
25765
25822
  flexDirection: "mlydt5ytf",
@@ -25795,19 +25852,6 @@ const styles$u = {
25795
25852
  paddingBottom: null,
25796
25853
  $$css: true
25797
25854
  },
25798
- menuLabel: {
25799
- padding: "mlydqdrvq",
25800
- paddingInline: null,
25801
- paddingStart: null,
25802
- paddingLeft: null,
25803
- paddingEnd: null,
25804
- paddingRight: null,
25805
- paddingBlock: null,
25806
- paddingTop: null,
25807
- paddingBottom: null,
25808
- color: "mly9dwj6z",
25809
- $$css: true
25810
- },
25811
25855
  icon: {
25812
25856
  color: "mly1mguc6l",
25813
25857
  $$css: true
@@ -25830,7 +25874,9 @@ function QueryActionBar({
25830
25874
  const {
25831
25875
  rootQuery,
25832
25876
  setQuery,
25833
- source
25877
+ source,
25878
+ onCurrentNestQueryPanelChange,
25879
+ onCurrentNestViewChange
25834
25880
  } = useContext(QueryEditorContext);
25835
25881
  const {
25836
25882
  onCollapse
@@ -25842,6 +25888,10 @@ function QueryActionBar({
25842
25888
  runQuery(source, rootQuery.build());
25843
25889
  }
25844
25890
  };
25891
+ const focusMainQueryPanel = () => {
25892
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
25893
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(null);
25894
+ };
25845
25895
  return /* @__PURE__ */ jsxs("div", {
25846
25896
  ...{
25847
25897
  className: "mly78zum5 mly1qughib mly6s0dn4 mlye8ttls"
@@ -25853,7 +25903,7 @@ function QueryActionBar({
25853
25903
  children: [/* @__PURE__ */ jsx(Icon, {
25854
25904
  name: "filterSliders"
25855
25905
  }), /* @__PURE__ */ jsx("div", {
25856
- ..._stylex.props(fontStyles.largeBody, styles$t.title),
25906
+ ..._stylex.props(fontStyles.largeBody, styles$s.title),
25857
25907
  children: "Query"
25858
25908
  })]
25859
25909
  }), /* @__PURE__ */ jsxs("div", {
@@ -25861,7 +25911,10 @@ function QueryActionBar({
25861
25911
  className: "mly78zum5 mly167g77z"
25862
25912
  },
25863
25913
  children: [/* @__PURE__ */ jsx(Button, {
25864
- onClick: () => setQuery == null ? void 0 : setQuery(void 0),
25914
+ onClick: () => {
25915
+ focusMainQueryPanel();
25916
+ setQuery == null ? void 0 : setQuery(void 0);
25917
+ },
25865
25918
  isDisabled: !rootQuery || (rootQuery == null ? void 0 : rootQuery.isEmpty()),
25866
25919
  label: "Clear",
25867
25920
  variant: "flat",
@@ -25895,13 +25948,13 @@ function QueryActionBar({
25895
25948
  })]
25896
25949
  });
25897
25950
  }
25898
- const styles$t = {
25951
+ const styles$s = {
25899
25952
  title: {
25900
25953
  fontWeight: "mly1xlr1w8",
25901
25954
  $$css: true
25902
25955
  }
25903
25956
  };
25904
- const styles$s = {
25957
+ const styles$r = {
25905
25958
  labelWithIcon: {
25906
25959
  display: "mly78zum5",
25907
25960
  alignItems: "mly6s0dn4",
@@ -29990,6 +30043,12 @@ function FieldToken({
29990
30043
  hoverActionsVisible,
29991
30044
  ...props2
29992
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
+ }
29993
30052
  return /* @__PURE__ */ jsxs("div", {
29994
30053
  ...{
29995
30054
  0: {
@@ -30000,7 +30059,7 @@ function FieldToken({
30000
30059
  }
30001
30060
  }[!!hoverActionsVisible << 0],
30002
30061
  children: [/* @__PURE__ */ jsx(Token, {
30003
- label: field.name,
30062
+ label,
30004
30063
  color: fieldKindToColor(field.kind),
30005
30064
  icon: fieldToIcon(field),
30006
30065
  ...props2
@@ -30020,32 +30079,32 @@ function BadgeForField({
30020
30079
  label: "view",
30021
30080
  icon: "view_filled",
30022
30081
  color: "purple",
30023
- customStyle: styles$r.noBackground
30082
+ customStyle: styles$q.noBackground
30024
30083
  });
30025
30084
  } else if (field.kind === "dimension") {
30026
30085
  return /* @__PURE__ */ jsx(Badge, {
30027
30086
  label: "dimension",
30028
30087
  icon: fieldToIcon(field),
30029
30088
  color: "cyan",
30030
- customStyle: styles$r.noBackground
30089
+ customStyle: styles$q.noBackground
30031
30090
  });
30032
30091
  } else if (field.kind === "measure") {
30033
30092
  return /* @__PURE__ */ jsx(Badge, {
30034
30093
  label: "measure",
30035
30094
  icon: fieldToIcon(field),
30036
30095
  color: "green",
30037
- customStyle: styles$r.noBackground
30096
+ customStyle: styles$q.noBackground
30038
30097
  });
30039
30098
  } else if (field.kind === "join") {
30040
30099
  return /* @__PURE__ */ jsx(Badge, {
30041
30100
  label: "join",
30042
30101
  icon: fieldToIcon(field),
30043
30102
  color: "gray",
30044
- customStyle: styles$r.noBackground
30103
+ customStyle: styles$q.noBackground
30045
30104
  });
30046
30105
  }
30047
30106
  }
30048
- const styles$r = {
30107
+ const styles$q = {
30049
30108
  noBackground: {
30050
30109
  backgroundColor: "mlyjbqb8w",
30051
30110
  $$css: true
@@ -30074,7 +30133,7 @@ function Visualization$1({
30074
30133
  onClick: () => setRenderer(viz)
30075
30134
  }));
30076
30135
  const tokens2 = [/* @__PURE__ */ jsx(SelectorToken, {
30077
- customStyle: styles$q.first,
30136
+ customStyle: styles$p.first,
30078
30137
  icon: `viz_${currentRenderer}`,
30079
30138
  value: currentRenderer,
30080
30139
  items: vizes,
@@ -30084,7 +30143,7 @@ function Visualization$1({
30084
30143
  children: tokens2
30085
30144
  });
30086
30145
  }
30087
- const styles$q = {
30146
+ const styles$p = {
30088
30147
  first: {
30089
30148
  flexGrow: "mly1iyjqo2",
30090
30149
  justifyContent: "mlylqzeqv",
@@ -30113,33 +30172,31 @@ function ViewAttributeTable({
30113
30172
  }) {
30114
30173
  const dimensions = viewInfo.schema.fields.filter((f2) => f2.kind === "dimension");
30115
30174
  return /* @__PURE__ */ jsx("div", {
30116
- ..._stylex.props(styles$p.attributeTableContainer, style),
30117
- children: /* @__PURE__ */ jsx(ScrollableArea, {
30118
- children: /* @__PURE__ */ jsx("table", {
30119
- ...{
30120
- className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
30121
- },
30122
- children: /* @__PURE__ */ jsxs("tbody", {
30123
- children: [/* @__PURE__ */ jsx(ViewAttributeTableRow, {
30124
- attribute: "chart type",
30125
- children: /* @__PURE__ */ jsx("div", {
30126
- ...{
30127
- className: "mly1rg5ohu"
30128
- },
30129
- children: /* @__PURE__ */ jsx(Visualization, {
30130
- annotations: viewInfo.annotations || []
30131
- })
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 || []
30132
30189
  })
30133
- }), /* @__PURE__ */ jsx(ViewAttributeTableRow, {
30134
- attribute: "output",
30135
- children: dimensions.map((f2) => /* @__PURE__ */ jsx("span", {
30136
- children: /* @__PURE__ */ jsx(FieldToken, {
30137
- field: f2,
30138
- size: isCompact ? "compact" : "default"
30139
- })
30140
- }, `${f2.kind}::${f2.name}`))
30141
- })]
30142
- })
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
+ })]
30143
30200
  })
30144
30201
  })
30145
30202
  });
@@ -30153,9 +30210,9 @@ function ViewAttributeTableRow({
30153
30210
  className: "mlydpxx8g"
30154
30211
  },
30155
30212
  children: [/* @__PURE__ */ jsx("td", {
30156
- ..._stylex.props(styles$p.attributeTableKeyCell, fontStyles.supporting),
30213
+ ..._stylex.props(styles$o.attributeTableKeyCell, fontStyles.supporting),
30157
30214
  children: /* @__PURE__ */ jsx("div", {
30158
- ..._stylex.props(styles$p.attributeTableKeyCellContent, fontStyles.supporting),
30215
+ ..._stylex.props(styles$o.attributeTableKeyCellContent, fontStyles.supporting),
30159
30216
  children: attribute
30160
30217
  })
30161
30218
  }), /* @__PURE__ */ jsx("td", {
@@ -30166,7 +30223,7 @@ function ViewAttributeTableRow({
30166
30223
  })]
30167
30224
  });
30168
30225
  }
30169
- const styles$p = {
30226
+ const styles$o = {
30170
30227
  attributeTableContainer: {
30171
30228
  padding: "mlye8ttls",
30172
30229
  paddingInline: null,
@@ -30193,6 +30250,9 @@ const styles$p = {
30193
30250
  boxSizing: "mly9f619",
30194
30251
  width: "mlyh8yej3",
30195
30252
  height: "mly1m3v4wt",
30253
+ overflow: "mlyysyzu8",
30254
+ overflowX: null,
30255
+ overflowY: null,
30196
30256
  $$css: true
30197
30257
  },
30198
30258
  attributeTableKeyCell: {
@@ -30314,7 +30374,7 @@ function HoverText({
30314
30374
  asChild: true,
30315
30375
  children: /* @__PURE__ */ jsx("div", {
30316
30376
  ref: textRef,
30317
- ..._stylex.props(styles$o.text, fontStyles.supporting),
30377
+ ..._stylex.props(styles$n.text, fontStyles.supporting),
30318
30378
  children: text2
30319
30379
  })
30320
30380
  }), /* @__PURE__ */ jsx(Portal$4, {
@@ -30322,7 +30382,7 @@ function HoverText({
30322
30382
  side,
30323
30383
  align,
30324
30384
  children: /* @__PURE__ */ jsx("pre", {
30325
- ..._stylex.props(styles$o.hoverText, fontStyles.tooltipText),
30385
+ ..._stylex.props(styles$n.hoverText, fontStyles.tooltipText),
30326
30386
  children: text2
30327
30387
  })
30328
30388
  })
@@ -30331,7 +30391,7 @@ function HoverText({
30331
30391
  })
30332
30392
  });
30333
30393
  }
30334
- const styles$o = {
30394
+ const styles$n = {
30335
30395
  text: {
30336
30396
  overflow: "mlyb3r6kr",
30337
30397
  overflowX: null,
@@ -30384,11 +30444,11 @@ function HoverCard({
30384
30444
  customStyle
30385
30445
  }) {
30386
30446
  return /* @__PURE__ */ jsx("div", {
30387
- ..._stylex.props(styles$n.container, fontStyles.body, customStyle),
30447
+ ..._stylex.props(styles$m.container, fontStyles.body, customStyle),
30388
30448
  children
30389
30449
  });
30390
30450
  }
30391
- const styles$n = {
30451
+ const styles$m = {
30392
30452
  container: {
30393
30453
  boxShadow: "mly5n1uv4",
30394
30454
  backgroundColor: "mly12peec7",
@@ -30433,7 +30493,7 @@ function FieldHoverCard({
30433
30493
  details = /* @__PURE__ */ jsx(ViewAttributeTable, {
30434
30494
  viewInfo: field,
30435
30495
  isCompact: true,
30436
- style: styles$m.viewAttributeTable
30496
+ style: styles$l.viewAttributeTable
30437
30497
  });
30438
30498
  } else if (field.kind === "dimension") {
30439
30499
  details = /* @__PURE__ */ jsx(TopValuesTable, {
@@ -30442,7 +30502,7 @@ function FieldHoverCard({
30442
30502
  });
30443
30503
  }
30444
30504
  return /* @__PURE__ */ jsxs(HoverCard, {
30445
- customStyle: styles$m.container,
30505
+ customStyle: styles$l.container,
30446
30506
  children: [/* @__PURE__ */ jsxs("div", {
30447
30507
  children: [/* @__PURE__ */ jsx("div", {
30448
30508
  ...{
@@ -30452,10 +30512,10 @@ function FieldHoverCard({
30452
30512
  field
30453
30513
  })
30454
30514
  }), /* @__PURE__ */ jsx("div", {
30455
- ..._stylex.props(fontStyles.supporting, styles$m.path),
30515
+ ..._stylex.props(fontStyles.supporting, styles$l.path),
30456
30516
  children: pathString
30457
30517
  }), /* @__PURE__ */ jsx("div", {
30458
- ..._stylex.props(fontStyles.emphasized, styles$m.title),
30518
+ ..._stylex.props(fontStyles.emphasized, styles$l.title),
30459
30519
  children: field.name
30460
30520
  }), description && /* @__PURE__ */ jsx(HoverText, {
30461
30521
  text: description
@@ -30465,7 +30525,7 @@ function FieldHoverCard({
30465
30525
  })]
30466
30526
  });
30467
30527
  }
30468
- const styles$m = {
30528
+ const styles$l = {
30469
30529
  container: {
30470
30530
  width: "mlybl57os",
30471
30531
  maxHeight: "mlyq3t0pi",
@@ -30757,10 +30817,10 @@ const PillInput = ({
30757
30817
  commitValue();
30758
30818
  });
30759
30819
  return /* @__PURE__ */ jsx("div", {
30760
- ..._stylex.props(fontStyles.body, styles$l.main),
30820
+ ..._stylex.props(fontStyles.body, styles$k.main),
30761
30821
  children: /* @__PURE__ */ jsx(ScrollableArea, {
30762
30822
  children: /* @__PURE__ */ jsxs("div", {
30763
- ..._stylex.props(styles$l.content, customStyle),
30823
+ ..._stylex.props(styles$k.content, customStyle),
30764
30824
  onKeyUp,
30765
30825
  onClick: () => {
30766
30826
  var _a2;
@@ -30827,7 +30887,7 @@ const Pill = ({
30827
30887
  onClick,
30828
30888
  tabIndex: 0,
30829
30889
  ref: forwardRef,
30830
- ..._stylex.props(styles$l.pill, colorVariants[color]),
30890
+ ..._stylex.props(styles$k.pill, colorVariants[color]),
30831
30891
  children: [children, /* @__PURE__ */ jsx("div", {
30832
30892
  title: "Remove",
30833
30893
  ...{
@@ -30842,7 +30902,7 @@ const Pill = ({
30842
30902
  })]
30843
30903
  });
30844
30904
  };
30845
- const styles$l = {
30905
+ const styles$k = {
30846
30906
  main: {
30847
30907
  borderRadius: "mly12oqio5",
30848
30908
  borderStartStartRadius: null,
@@ -31026,7 +31086,7 @@ function ValueList({
31026
31086
  children: (stringSearchResults == null ? void 0 : stringSearchResults.length) ? stringSearchResults.map((value) => /* @__PURE__ */ jsxs("div", {
31027
31087
  role: "menuitem",
31028
31088
  tabIndex: -1,
31029
- ..._stylex.props(addMenuStyles.item, styles$k.valueItem),
31089
+ ..._stylex.props(addMenuStyles.item, styles$j.valueItem),
31030
31090
  onClick: () => onClick(value),
31031
31091
  children: [/* @__PURE__ */ jsx(Value, {
31032
31092
  value
@@ -31050,10 +31110,10 @@ function Value({
31050
31110
  label: value.fieldValue ?? "∅",
31051
31111
  icon: "filter",
31052
31112
  color: "purple",
31053
- customStyle: styles$k.token
31113
+ customStyle: styles$j.token
31054
31114
  });
31055
31115
  }
31056
- const styles$k = {
31116
+ const styles$j = {
31057
31117
  valueItem: {
31058
31118
  height: "mly1qx5ct2",
31059
31119
  paddingTop: "mly1y1aw1k",
@@ -31229,7 +31289,7 @@ const StringFilterCore = ({
31229
31289
  setSearchValue("");
31230
31290
  }
31231
31291
  },
31232
- customStyle: styles$j.valueList
31292
+ customStyle: styles$i.valueList
31233
31293
  })
31234
31294
  })]
31235
31295
  }) : currentFilter.operator === "~" ? /* @__PURE__ */ jsx(StringEditor, {
@@ -31297,7 +31357,7 @@ function stringFilterChangeType(filter, type) {
31297
31357
  };
31298
31358
  }
31299
31359
  }
31300
- const styles$j = {
31360
+ const styles$i = {
31301
31361
  valueList: {
31302
31362
  maxHeight: "mly3d5gib",
31303
31363
  width: "mly1hfn5x7",
@@ -31552,83 +31612,6 @@ function makeFilterWithNewType(filter, type) {
31552
31612
  };
31553
31613
  }
31554
31614
  }
31555
- const formats = {
31556
- second: "YYYY-MM-DD HH:mm:ss",
31557
- minute: "YYYY-MM-DD HH:mm",
31558
- hour: "YYYY-MM-DD HH:00",
31559
- day: "YYYY-MM-DD",
31560
- week: "[WK]YYYY-WW",
31561
- month: "YYYY-MM",
31562
- quarter: "YYYY-[Q]Q",
31563
- year: "YYYY"
31564
- };
31565
- const regexps = {
31566
- second: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
31567
- minute: /\d\d\d\d-\d\d-\d\d \d\d:\d\d/,
31568
- hour: /\d\d\d\d-\d\d-\d\d \d\d:00/,
31569
- day: /\d\d\d\d-\d\d-\d\d/,
31570
- week: /WK\d\d\d\d-\d\d-\d\d/,
31571
- month: /\d\d\d\d-\d\d/,
31572
- quarter: /\d\d\d\d-Q\d/,
31573
- year: /\d\d\d\d/
31574
- };
31575
- const DateInput = ({
31576
- value,
31577
- setValue,
31578
- placeholder,
31579
- autoFocus,
31580
- units,
31581
- onFocus,
31582
- onBlur,
31583
- isActive,
31584
- customStyle
31585
- }) => {
31586
- const format2 = formats[units];
31587
- const [tempValue, setTempValue] = useState(hooks(value).format(format2));
31588
- useEffect(() => {
31589
- setTempValue(hooks(value).format(format2));
31590
- }, [value, format2]);
31591
- return /* @__PURE__ */ jsx("input", {
31592
- ..._stylex.props(customStyle, isActive ? styles$i.active : null),
31593
- type: "text",
31594
- placeholder: placeholder || format2,
31595
- value: tempValue,
31596
- onFocus,
31597
- onBlur,
31598
- onChange: (event) => {
31599
- const raw2 = event.target.value;
31600
- setTempValue(raw2);
31601
- const regex = regexps[units];
31602
- if (raw2.match(regex)) {
31603
- const m = hooks(raw2, format2);
31604
- if (m.isValid()) {
31605
- setValue(m.toDate());
31606
- }
31607
- }
31608
- },
31609
- autoFocus
31610
- });
31611
- };
31612
- function guessUnits(moment2, isDateTime) {
31613
- if (moment2.moment === "literal") {
31614
- const {
31615
- literal
31616
- } = moment2;
31617
- for (const unit in regexps) {
31618
- const temporalUnit = unit;
31619
- if (literal.match(regexps[temporalUnit])) {
31620
- return temporalUnit;
31621
- }
31622
- }
31623
- }
31624
- return isDateTime ? "second" : "day";
31625
- }
31626
- const styles$i = {
31627
- active: {
31628
- backgroundColor: "mly1vzefiq",
31629
- $$css: true
31630
- }
31631
- };
31632
31615
  function typeFromFilter(filter) {
31633
31616
  if (filter.operator === "null" && filter.not) {
31634
31617
  return "-null";
@@ -31636,7 +31619,7 @@ function typeFromFilter(filter) {
31636
31619
  return filter.operator;
31637
31620
  }
31638
31621
  function unitsFromFilter(filter, isDateTime) {
31639
- if (filter.operator === "last" || filter.operator === "next") {
31622
+ if (filter.operator === "last" || filter.operator === "next" || filter.operator === "in_last") {
31640
31623
  return filter.units;
31641
31624
  } else if (filter.operator === "to") {
31642
31625
  return guessUnits(filter.fromMoment, isDateTime);
@@ -31678,11 +31661,14 @@ const DateTimeFilterCore = ({
31678
31661
  value: type,
31679
31662
  onChange: changeType,
31680
31663
  options: [{
31681
- value: "last",
31664
+ value: "in_last",
31682
31665
  label: "last"
31666
+ }, {
31667
+ value: "last",
31668
+ label: "last complete"
31683
31669
  }, {
31684
31670
  value: "next",
31685
- label: "next"
31671
+ label: "next complete"
31686
31672
  }, {
31687
31673
  value: "after",
31688
31674
  label: "after"
@@ -31709,6 +31695,7 @@ const DateTimeFilterCore = ({
31709
31695
  };
31710
31696
  function getTopEditorRow(currentFilter, updateFilter, units, setUnits, maxLevel) {
31711
31697
  switch (currentFilter.operator) {
31698
+ case "in_last":
31712
31699
  case "last":
31713
31700
  case "next":
31714
31701
  return /* @__PURE__ */ jsx(NUnitFilter, {
@@ -31821,15 +31808,48 @@ function NUnitFilter({
31821
31808
  });
31822
31809
  }
31823
31810
  function UnitFilter({
31811
+ currentFilter,
31812
+ updateFilter,
31824
31813
  units,
31825
31814
  setUnits,
31826
31815
  maxLevel
31827
31816
  }) {
31828
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
+ };
31829
31849
  return /* @__PURE__ */ jsx(SelectDropdown, {
31830
31850
  options,
31831
31851
  value: units,
31832
- onChange: setUnits,
31852
+ onChange: updateUnits,
31833
31853
  customStyle: filterStyles.editorCell
31834
31854
  });
31835
31855
  }
@@ -31954,20 +31974,25 @@ function DoubleDateFilter({
31954
31974
  function createTemporalLiteral(date, units) {
31955
31975
  return {
31956
31976
  moment: "literal",
31957
- literal: hooks(date).format(formats[units])
31977
+ literal: hooks.utc(date).format(formats[units]),
31978
+ units
31958
31979
  };
31959
31980
  }
31960
31981
  function extractDateFromMoment(momentObj) {
31961
31982
  if (momentObj && momentObj.moment === "literal") {
31962
- return hooks(momentObj.literal).toDate();
31983
+ return hooks.utc(momentObj.literal, formats[momentObj.units ?? "second"]).toDate();
31963
31984
  }
31964
31985
  return /* @__PURE__ */ new Date();
31965
31986
  }
31987
+ function updateMoment(moment2, units) {
31988
+ return createTemporalLiteral(extractDateFromMoment(moment2), units);
31989
+ }
31966
31990
  function dateTimeFilterChangeType(filter, type, units) {
31967
31991
  let n = "7";
31968
31992
  let fromMoment = createTemporalLiteral(/* @__PURE__ */ new Date(), units);
31969
31993
  let toMoment = createTemporalLiteral(/* @__PURE__ */ new Date(), units);
31970
31994
  switch (filter.operator) {
31995
+ case "in_last":
31971
31996
  case "last":
31972
31997
  case "next":
31973
31998
  n = filter.n;
@@ -31987,6 +32012,7 @@ function dateTimeFilterChangeType(filter, type, units) {
31987
32012
  break;
31988
32013
  }
31989
32014
  switch (type) {
32015
+ case "in_last":
31990
32016
  case "last":
31991
32017
  case "next":
31992
32018
  return {
@@ -32004,6 +32030,11 @@ function dateTimeFilterChangeType(filter, type, units) {
32004
32030
  operator: type,
32005
32031
  before: fromMoment
32006
32032
  };
32033
+ case "in":
32034
+ return {
32035
+ operator: type,
32036
+ in: fromMoment
32037
+ };
32007
32038
  case "to":
32008
32039
  return {
32009
32040
  operator: type,
@@ -32069,6 +32100,13 @@ function FilterDialog({
32069
32100
  };
32070
32101
  return /* @__PURE__ */ jsxs("div", {
32071
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
+ },
32072
32110
  children: [/* @__PURE__ */ jsx("div", {
32073
32111
  ..._stylex.props(filterStyles.filterDialogHeader),
32074
32112
  children: fieldInfo.name
@@ -32172,12 +32210,17 @@ function FilterPopover({
32172
32210
  setFilter,
32173
32211
  trigger,
32174
32212
  anchor,
32175
- layoutProps
32213
+ layoutProps,
32214
+ onOpenChange
32176
32215
  }) {
32177
32216
  const [open, setOpen] = useState(false);
32217
+ const handleOpenChange = (open2) => {
32218
+ setOpen(open2);
32219
+ onOpenChange == null ? void 0 : onOpenChange(open2);
32220
+ };
32178
32221
  return /* @__PURE__ */ jsxs(Root2$2, {
32179
32222
  open,
32180
- onOpenChange: setOpen,
32223
+ onOpenChange: handleOpenChange,
32181
32224
  modal: true,
32182
32225
  children: [anchor ? /* @__PURE__ */ jsx(Anchor2$1, {
32183
32226
  asChild: true,
@@ -32196,7 +32239,7 @@ function FilterPopover({
32196
32239
  filter,
32197
32240
  path,
32198
32241
  onFilterApply: setFilter,
32199
- onOpenChange: setOpen
32242
+ onOpenChange: handleOpenChange
32200
32243
  })
32201
32244
  })
32202
32245
  })]
@@ -32217,7 +32260,7 @@ function FieldList({
32217
32260
  const groups2 = [];
32218
32261
  const lcSearch = search.toLocaleLowerCase();
32219
32262
  const buildGroups = (types22, path, name, fields2) => {
32220
- const filteredFields = sortFieldInfos(fields2).filter((field) => field.kind !== "join").filter((field) => !isArrayOrRecord(field)).filter((field) => field.name.toLocaleLowerCase().includes(lcSearch) && types22.includes(field.kind)).filter((field) => filter ? filter(view, field, path) : true);
32263
+ const filteredFields = sortFieldInfos(fields2).filter((field) => field.kind !== "join").filter((field) => field.name.toLocaleLowerCase().includes(lcSearch) && types22.includes(field.kind)).filter((field) => filter ? filter(view, field, path) : true);
32221
32264
  const joins = fields2.filter((field) => field.kind === "join");
32222
32265
  const arraysAndRecords = fields2.filter(isArrayOrRecord);
32223
32266
  if (filteredFields.length) {
@@ -32376,20 +32419,19 @@ function segmentHasOrderBy(segment, name) {
32376
32419
  function segmentNestNo(segment, name) {
32377
32420
  return segment.operations.items.reduce((acc, operation) => {
32378
32421
  if (operation instanceof ASTNestViewOperation) {
32379
- if (name) {
32422
+ {
32380
32423
  if (operation.name === name) {
32381
32424
  do {
32382
32425
  acc += 1;
32383
32426
  } while (segment.hasFieldNamed(`${name} ${acc}`));
32384
32427
  }
32385
- } else {
32386
- return acc + 1;
32387
32428
  }
32388
32429
  }
32389
32430
  return acc;
32390
32431
  }, 1);
32391
32432
  }
32392
32433
  function addGroupBy(view, field, path) {
32434
+ const type = field.kind === "dimension" ? field.type.kind : "string";
32393
32435
  const segment = view.getOrAddDefaultSegment();
32394
32436
  const {
32395
32437
  fields
@@ -32398,7 +32440,13 @@ function addGroupBy(view, field, path) {
32398
32440
  if (fields.find((f2) => f2.name === field.name)) {
32399
32441
  rename = findUniqueFieldName(fields, field.name, path);
32400
32442
  }
32401
- 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
+ }
32402
32450
  }
32403
32451
  function addAggregate(view, field, path) {
32404
32452
  const segment = view.getOrAddDefaultSegment();
@@ -32422,6 +32470,18 @@ function addNest(view, field) {
32422
32470
  }
32423
32471
  segment.addNest(field.name, rename);
32424
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
+ }
32425
32485
  function getSegmentIfPresent(parent) {
32426
32486
  const definition = getViewDefinition(parent);
32427
32487
  if (definition instanceof ASTSegmentViewDefinition) {
@@ -32447,7 +32507,7 @@ function OperationActionTitle({
32447
32507
  return !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
32448
32508
  };
32449
32509
  return /* @__PURE__ */ jsxs("div", {
32450
- ..._stylex.props(styles$s.title, hoverStyles.main),
32510
+ ..._stylex.props(styles$r.title, hoverStyles.main),
32451
32511
  children: [/* @__PURE__ */ jsx("div", {
32452
32512
  children: title
32453
32513
  }), /* @__PURE__ */ jsx("div", {
@@ -32844,7 +32904,14 @@ function RenameDialog({
32844
32904
  ..._stylex.props({
32845
32905
  ...dialogStyles.editorCell,
32846
32906
  ...dialogStyles.input
32847
- })
32907
+ }),
32908
+ onKeyDown: (event) => {
32909
+ if (event.key === "Enter") {
32910
+ onRename();
32911
+ } else if (event.key === "Esc") {
32912
+ setOpen(false);
32913
+ }
32914
+ }
32848
32915
  }), badName && /* @__PURE__ */ jsx(ErrorIcon, {
32849
32916
  errorMessage: "Name already in use"
32850
32917
  })]
@@ -33017,7 +33084,7 @@ function SortableOperations({
33017
33084
  fields,
33018
33085
  ...props2
33019
33086
  }), /* @__PURE__ */ jsx("div", {
33020
- ..._stylex.props(styles$s.tokenContainer),
33087
+ ..._stylex.props(styles$r.tokenContainer),
33021
33088
  children: /* @__PURE__ */ jsx(DndContext, {
33022
33089
  sensors,
33023
33090
  collisionDetection: closestCenter,
@@ -33025,6 +33092,7 @@ function SortableOperations({
33025
33092
  children: /* @__PURE__ */ jsx(SortableContext, {
33026
33093
  items,
33027
33094
  children: items.map((item) => /* @__PURE__ */ jsx(SortableOperation, {
33095
+ rootQuery,
33028
33096
  id: item.id,
33029
33097
  color: kind === "group_by" ? "cyan" : "green",
33030
33098
  view,
@@ -33035,18 +33103,19 @@ function SortableOperations({
33035
33103
  })]
33036
33104
  });
33037
33105
  }
33106
+ const NULL_PATH = [];
33038
33107
  function SortableOperation({
33108
+ rootQuery,
33039
33109
  id,
33040
33110
  view,
33041
33111
  operation,
33042
33112
  color
33043
33113
  }) {
33044
33114
  const {
33045
- rootQuery,
33046
33115
  setQuery
33047
33116
  } = useContext(QueryEditorContext);
33048
33117
  const fieldInfo = operation.getFieldInfo();
33049
- const path = operation.field.getReference().path ?? [];
33118
+ const path = operation.field.getReference().path ?? NULL_PATH;
33050
33119
  const {
33051
33120
  attributes,
33052
33121
  listeners,
@@ -33066,37 +33135,64 @@ function SortableOperation({
33066
33135
  transform: CSS$1.Transform.toString(transform2),
33067
33136
  transition
33068
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
+ }
33069
33168
  return /* @__PURE__ */ jsxs("div", {
33070
33169
  id,
33071
33170
  ref: setNodeRef,
33072
33171
  style,
33073
- 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, {
33074
33192
  field: fieldInfo,
33075
33193
  color,
33076
33194
  hoverActionsVisible,
33077
- hoverActions: /* @__PURE__ */ jsxs(Fragment, {
33078
- children: [/* @__PURE__ */ jsx(DropdownMenu, {
33079
- trigger: /* @__PURE__ */ jsx(Button, {
33080
- variant: "flat",
33081
- icon: "meatballs",
33082
- size: "compact",
33083
- tooltip: "More Actions"
33084
- }),
33085
- onOpenChange: setHoverActionsVisible,
33086
- children: /* @__PURE__ */ jsx(DropdownMenuItem, {
33087
- label: "Rename",
33088
- onClick: () => {
33089
- setRenameTarget(operation);
33090
- setRenameOpen(true);
33091
- }
33092
- })
33093
- }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsx(ClearButton, {
33094
- onClick: () => {
33095
- operation.delete();
33096
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33097
- }
33098
- })]
33099
- }),
33195
+ hoverActions,
33100
33196
  tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
33101
33197
  field: fieldInfo,
33102
33198
  path
@@ -33119,6 +33215,38 @@ function SortableOperation({
33119
33215
  })]
33120
33216
  });
33121
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
+ };
33122
33250
  function GroupByOperations({
33123
33251
  rootQuery,
33124
33252
  segment,
@@ -33167,10 +33295,10 @@ function FilterOperations({
33167
33295
  }
33168
33296
  return /* @__PURE__ */ jsxs("div", {
33169
33297
  children: [/* @__PURE__ */ jsx("div", {
33170
- ..._stylex.props(styles$s.title),
33298
+ ..._stylex.props(styles$r.title),
33171
33299
  children: "filter by"
33172
33300
  }), /* @__PURE__ */ jsx("div", {
33173
- ..._stylex.props(styles$s.tokenContainer),
33301
+ ..._stylex.props(styles$r.tokenContainer),
33174
33302
  children: filters.map((filterOperation, key2) => {
33175
33303
  return /* @__PURE__ */ jsx(ErrorElement, {
33176
33304
  fallback: /* @__PURE__ */ jsxs("div", {
@@ -33377,7 +33505,7 @@ const parsedToLabels = (parsed, filterString) => {
33377
33505
  const {
33378
33506
  not
33379
33507
  } = temporalClause;
33380
- op = `is${not ? " not" : ""} last`;
33508
+ op = `is${not ? " not" : ""} last complete`;
33381
33509
  value = temporalClause.n + " " + temporalClause.units;
33382
33510
  }
33383
33511
  break;
@@ -33386,7 +33514,7 @@ const parsedToLabels = (parsed, filterString) => {
33386
33514
  const {
33387
33515
  not
33388
33516
  } = temporalClause;
33389
- op = `is${not ? " not" : ""} nest`;
33517
+ op = `is${not ? " not" : ""} next complete`;
33390
33518
  value = temporalClause.n + " " + temporalClause.units;
33391
33519
  }
33392
33520
  break;
@@ -33434,7 +33562,7 @@ function LimitOperation({
33434
33562
  }
33435
33563
  return /* @__PURE__ */ jsxs("div", {
33436
33564
  children: [/* @__PURE__ */ jsx("div", {
33437
- ..._stylex.props(styles$s.title),
33565
+ ..._stylex.props(styles$r.title),
33438
33566
  children: "limit"
33439
33567
  }), /* @__PURE__ */ jsxs("div", {
33440
33568
  ..._stylex.props(hoverStyles.main),
@@ -33484,10 +33612,10 @@ function OrderByOperations({
33484
33612
  }
33485
33613
  return /* @__PURE__ */ jsxs("div", {
33486
33614
  children: [/* @__PURE__ */ jsx("div", {
33487
- ..._stylex.props(styles$s.title),
33615
+ ..._stylex.props(styles$r.title),
33488
33616
  children: "order by"
33489
33617
  }), /* @__PURE__ */ jsx("div", {
33490
- ..._stylex.props(styles$s.tokenContainer),
33618
+ ..._stylex.props(styles$r.tokenContainer),
33491
33619
  children: orderBys.map((orderBy) => {
33492
33620
  const {
33493
33621
  fieldReference
@@ -33555,71 +33683,6 @@ function View({
33555
33683
  })]
33556
33684
  });
33557
33685
  }
33558
- function CollapsiblePanel({
33559
- title,
33560
- children,
33561
- icon,
33562
- defaultOpen = true,
33563
- controls,
33564
- collapsedControls
33565
- }) {
33566
- const [isExpanded, setIsExpanded] = useState(defaultOpen);
33567
- return /* @__PURE__ */ jsxs("div", {
33568
- ...{
33569
- className: "mlyzkdzjc mly1sxf85j mly1717udv"
33570
- },
33571
- children: [/* @__PURE__ */ jsxs("div", {
33572
- ...{
33573
- className: "mlyrvj5dj mly1mt1orb mly52fmzj mlylqzeqv mlyfawy5m mly167g77z mly6s0dn4"
33574
- },
33575
- children: [/* @__PURE__ */ jsxs("div", {
33576
- ...{
33577
- className: "mlyrvj5dj mly1mt1orb mlylqzeqv mly6s0dn4 mly167g77z"
33578
- },
33579
- children: [icon && /* @__PURE__ */ jsx(Icon, {
33580
- name: icon,
33581
- customStyle: styles$f.icon
33582
- }), /* @__PURE__ */ jsx("div", {
33583
- ...{
33584
- className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp"
33585
- },
33586
- children: title
33587
- })]
33588
- }), /* @__PURE__ */ jsxs("div", {
33589
- ...{
33590
- className: "mly78zum5"
33591
- },
33592
- children: [isExpanded ? /* @__PURE__ */ jsx("div", {
33593
- ...{
33594
- className: "mly78zum5 mly6s0dn4 mly1jnr06f"
33595
- },
33596
- children: controls
33597
- }) : /* @__PURE__ */ jsx("div", {
33598
- ...{
33599
- className: "mly78zum5 mly6s0dn4 mly1jnr06f"
33600
- },
33601
- children: collapsedControls
33602
- }), /* @__PURE__ */ jsx(Button, {
33603
- variant: "flat",
33604
- size: "compact",
33605
- onClick: () => setIsExpanded(!isExpanded),
33606
- icon: isExpanded ? "chevronDown" : "chevronRight",
33607
- tooltip: isExpanded ? "Collapse" : "Expand"
33608
- })]
33609
- })]
33610
- }), isExpanded && /* @__PURE__ */ jsx("div", {
33611
- ...{
33612
- className: "mly1l4tkcb"
33613
- },
33614
- children
33615
- })]
33616
- });
33617
- }
33618
- const styles$f = {
33619
- icon: {
33620
- $$css: true
33621
- }
33622
- };
33623
33686
  function AddItem({
33624
33687
  icon,
33625
33688
  label,
@@ -33638,7 +33701,7 @@ function AddItem({
33638
33701
  children: /* @__PURE__ */ jsxs("div", {
33639
33702
  role: "menuitem",
33640
33703
  tabIndex: -1,
33641
- ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$e.open : null),
33704
+ ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$f.open : null),
33642
33705
  onClick: doOnClick,
33643
33706
  "data-disabled": disabled ? "true" : void 0,
33644
33707
  children: [/* @__PURE__ */ jsxs("div", {
@@ -33662,7 +33725,7 @@ function AddItem({
33662
33725
  }) : null]
33663
33726
  });
33664
33727
  }
33665
- const styles$e = {
33728
+ const styles$f = {
33666
33729
  open: {
33667
33730
  background: "mly16o7sp0",
33668
33731
  backgroundAttachment: null,
@@ -33737,12 +33800,13 @@ function AddFieldItem({
33737
33800
  onAddOperation,
33738
33801
  isFilterOperation,
33739
33802
  search,
33740
- customStyle: styles$d.list
33803
+ customStyle: styles$e.list
33741
33804
  });
33742
33805
  }
33743
- const styles$d = {
33806
+ const styles$e = {
33744
33807
  list: {
33745
- width: "mlyqyf9gi",
33808
+ minWidth: "mly2ixbly",
33809
+ maxWidth: "mly1j9u4d2",
33746
33810
  $$css: true
33747
33811
  }
33748
33812
  };
@@ -33764,8 +33828,7 @@ function AddOrderBy({
33764
33828
  fields,
33765
33829
  types: ["dimension"],
33766
33830
  onAddOperation: (field) => {
33767
- const segment2 = view.getOrAddDefaultSegment();
33768
- segment2.addOrderBy(field.name, "asc");
33831
+ addOrderBy(view, field);
33769
33832
  setQuery == null ? void 0 : setQuery(rootQuery.build());
33770
33833
  },
33771
33834
  disabledMessage: "There must be at least one field in the output to order by.",
@@ -33842,28 +33905,21 @@ function AddWhere({
33842
33905
  const {
33843
33906
  fields
33844
33907
  } = getInputSchemaFromViewParent(view);
33845
- return /* @__PURE__ */ jsx(Fragment, {
33846
- children: /* @__PURE__ */ jsx(AddFieldItem, {
33847
- label: "Add filter",
33848
- icon: "filter",
33849
- view,
33850
- fields,
33851
- types: ["measure", "dimension"],
33852
- filter: (_segment, field) => (field.kind === "dimension" || field.kind === "measure") && FILTERABLE_TYPES$1.has(field.type.kind) && isNotAnnotatedFilteredField(field),
33853
- onAddOperation: (field, path, filter) => {
33854
- if (filter && (field.kind === "dimension" || field.kind === "measure")) {
33855
- const segment = view.getOrAddDefaultSegment();
33856
- if (field.kind === "dimension") {
33857
- segment.addWhere(field.name, path, filter);
33858
- } else {
33859
- segment.addHaving(field.name, path, filter);
33860
- }
33861
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33862
- }
33863
- },
33864
- isFilterOperation: true,
33865
- search
33866
- })
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
33867
33923
  });
33868
33924
  }
33869
33925
  const FILTERABLE_TYPES$1 = /* @__PURE__ */ new Set(["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"]);
@@ -33944,7 +34000,7 @@ function AddMenu({
33944
34000
  value: search,
33945
34001
  onChange: setSearch,
33946
34002
  placeholder: "Search...",
33947
- customStyle: styles$c.search
34003
+ customStyle: styles$d.search
33948
34004
  })
33949
34005
  }), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsxs("div", {
33950
34006
  ...{
@@ -34065,7 +34121,7 @@ function AddMenu({
34065
34121
  })]
34066
34122
  });
34067
34123
  }
34068
- const styles$c = {
34124
+ const styles$d = {
34069
34125
  search: {
34070
34126
  width: "mlyh8yej3",
34071
34127
  $$css: true
@@ -34080,7 +34136,7 @@ function NestOperations({
34080
34136
  return null;
34081
34137
  }
34082
34138
  return /* @__PURE__ */ jsx("div", {
34083
- ..._stylex.props(styles$s.tokenContainer),
34139
+ ..._stylex.props(styles$r.tokenContainer),
34084
34140
  children: nests.map((nest) => /* @__PURE__ */ jsx(NestOperation, {
34085
34141
  rootQuery,
34086
34142
  view,
@@ -34094,10 +34150,31 @@ function NestOperation({
34094
34150
  nest
34095
34151
  }) {
34096
34152
  const {
34097
- setQuery
34153
+ setQuery,
34154
+ currentNestQueryPanel,
34155
+ onCurrentNestQueryPanelChange,
34156
+ onCurrentNestViewChange
34098
34157
  } = useContext(QueryEditorContext);
34099
34158
  const [renameOpen, setRenameOpen] = useState(false);
34100
- const defaultOpen = nest.view.definition.node.kind === "segment" && nest.view.definition.node.operations.length === 0;
34159
+ const panelRef = React.useRef(null);
34160
+ const isCurrentNestQueryPanelFocused = currentNestQueryPanel !== null && panelRef.current == currentNestQueryPanel;
34161
+ React.useEffect(() => {
34162
+ if (isCurrentNestQueryPanelFocused) {
34163
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(nest.view);
34164
+ }
34165
+ }, [nest, isCurrentNestQueryPanelFocused, onCurrentNestViewChange]);
34166
+ const focusCurrentNestQueryPanel = () => {
34167
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(panelRef.current);
34168
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(nest.view);
34169
+ };
34170
+ const focusParentQueryPanel = () => {
34171
+ const currentPanel = panelRef.current;
34172
+ const parent = findParentNestQueryPanel(currentPanel);
34173
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(parent);
34174
+ if (parent === null) {
34175
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
34176
+ }
34177
+ };
34101
34178
  const getControls = (nest2) => /* @__PURE__ */ jsxs(Fragment, {
34102
34179
  children: [/* @__PURE__ */ jsxs(DropdownMenu, {
34103
34180
  trigger: /* @__PURE__ */ jsx(Button, {
@@ -34110,6 +34187,7 @@ function NestOperation({
34110
34187
  icon: "clear",
34111
34188
  label: "Delete Query",
34112
34189
  onClick: () => {
34190
+ focusParentQueryPanel();
34113
34191
  nest2.delete();
34114
34192
  setQuery == null ? void 0 : setQuery(rootQuery.build());
34115
34193
  }
@@ -34124,29 +34202,41 @@ function NestOperation({
34124
34202
  view: nest2.view
34125
34203
  })]
34126
34204
  });
34127
- return /* @__PURE__ */ jsxs("div", {
34205
+ return /* @__PURE__ */ jsx("div", {
34128
34206
  ...{
34129
34207
  className: "mlyj3b58b mly1yf7rl7 mly1xmf6yo mlyh8yej3"
34130
34208
  },
34131
- children: [/* @__PURE__ */ jsx(CollapsiblePanel, {
34132
- title: nest.name,
34133
- icon: viewToVisualizationIcon(nest.view),
34134
- defaultOpen,
34135
- controls: getControls(nest),
34136
- collapsedControls: getControls(nest),
34137
- children: /* @__PURE__ */ jsx(View, {
34209
+ children: /* @__PURE__ */ jsxs("div", {
34210
+ ref: panelRef,
34211
+ onPointerDownCapture: focusCurrentNestQueryPanel,
34212
+ "data-nest-panel": true,
34213
+ children: [/* @__PURE__ */ jsx(CollapsiblePanel, {
34214
+ title: nest.name,
34215
+ icon: viewToVisualizationIcon(nest.view),
34216
+ defaultOpen: true,
34217
+ controls: getControls(nest),
34218
+ collapsedControls: getControls(nest),
34219
+ isFocused: isCurrentNestQueryPanelFocused,
34220
+ children: /* @__PURE__ */ jsx(View, {
34221
+ rootQuery,
34222
+ view: nest.view
34223
+ })
34224
+ }), /* @__PURE__ */ jsx(RenameDialog, {
34138
34225
  rootQuery,
34139
- view: nest.view
34140
- })
34141
- }), /* @__PURE__ */ jsx(RenameDialog, {
34142
- rootQuery,
34143
- view,
34144
- target: nest,
34145
- open: renameOpen,
34146
- setOpen: setRenameOpen
34147
- })]
34226
+ view,
34227
+ target: nest,
34228
+ open: renameOpen,
34229
+ setOpen: setRenameOpen
34230
+ })]
34231
+ })
34148
34232
  }, nest.name);
34149
34233
  }
34234
+ function findParentNestQueryPanel(element2) {
34235
+ if (!element2 || !element2.parentElement) return null;
34236
+ const parentElement = element2.parentElement;
34237
+ if (parentElement.dataset.nestPanel !== void 0) return parentElement;
34238
+ return findParentNestQueryPanel(parentElement);
34239
+ }
34150
34240
  function Operations({
34151
34241
  rootQuery,
34152
34242
  view,
@@ -34248,7 +34338,7 @@ function ViewDefinition({
34248
34338
  function CollapsingView({
34249
34339
  viewDef
34250
34340
  }) {
34251
- const [collapsed, setCollapsed] = useState(true);
34341
+ const [collapsed, setCollapsed] = useState(false);
34252
34342
  return /* @__PURE__ */ jsxs("div", {
34253
34343
  ...{
34254
34344
  0: {
@@ -34277,11 +34367,11 @@ function CollapsingView({
34277
34367
  })]
34278
34368
  }), !collapsed && /* @__PURE__ */ jsx(ViewAttributeTable, {
34279
34369
  viewInfo: viewDef.getViewInfo(),
34280
- style: styles$b.preview
34370
+ style: styles$c.preview
34281
34371
  })]
34282
34372
  });
34283
34373
  }
34284
- const styles$b = {
34374
+ const styles$c = {
34285
34375
  preview: {
34286
34376
  height: "mlyt7dq6l",
34287
34377
  maxHeight: "mly1hkcv85",
@@ -34313,75 +34403,91 @@ function Query({
34313
34403
  query,
34314
34404
  setQuery
34315
34405
  }) {
34316
- return /* @__PURE__ */ jsxs(CollapsiblePanel, {
34317
- title: "Main query",
34318
- controls: /* @__PURE__ */ jsxs(Fragment, {
34319
- children: [/* @__PURE__ */ jsx(DropdownMenu, {
34320
- trigger: /* @__PURE__ */ jsx(Button, {
34321
- variant: "flat",
34322
- icon: "meatballs",
34323
- size: "compact",
34324
- tooltip: "More Actions"
34325
- }),
34326
- children: setQuery ? /* @__PURE__ */ jsxs(Fragment, {
34327
- children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
34328
- icon: "clear",
34329
- label: "Clear query",
34330
- onClick: () => {
34331
- setQuery == null ? void 0 : setQuery(void 0);
34332
- },
34333
- disabled: rootQuery.isEmpty()
34334
- }), /* @__PURE__ */ jsx(DropdownMenuItem, {
34335
- icon: "nest",
34336
- label: "Nest query",
34337
- onClick: () => {
34338
- if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
34339
- rootQuery.definition.view.convertToNest("Nest");
34340
- }
34341
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34342
- },
34343
- disabled: rootQuery.isEmpty() || !(rootQuery.definition instanceof ASTArrowQueryDefinition)
34344
- })]
34345
- }) : /* @__PURE__ */ jsx(Fragment, {})
34346
- }), query.definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsx(AddMenu, {
34347
- rootQuery,
34348
- view: query.definition
34349
- }) : null]
34350
- }),
34351
- collapsedControls: /* @__PURE__ */ jsx(Icon, {
34352
- name: viewToVisualizationIcon(query)
34353
- }),
34354
- children: [query.definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsxs("div", {
34355
- style: {
34356
- display: "flex",
34357
- flexDirection: "column",
34358
- gap: 8
34359
- },
34360
- children: [!query.isEmpty() && /* @__PURE__ */ jsx(Visualization$1, {
34361
- rootQuery,
34362
- view: query
34363
- }), /* @__PURE__ */ jsx(ViewDefinition, {
34364
- rootQuery,
34365
- view: query.definition,
34366
- viewDef: query.definition.view
34367
- })]
34368
- }) : null, query.isEmpty() ? /* @__PURE__ */ jsx("div", {
34369
- ...{
34370
- className: "mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra"
34371
- },
34372
- children: /* @__PURE__ */ jsxs("div", {
34373
- ...{
34374
- className: "mly78zum5 mly6s0dn4"
34406
+ const {
34407
+ currentNestQueryPanel,
34408
+ onCurrentNestQueryPanelChange,
34409
+ onCurrentNestViewChange
34410
+ } = React.useContext(QueryEditorContext);
34411
+ const focusMainQueryPanel = () => {
34412
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(null);
34413
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
34414
+ };
34415
+ const canEditViz = query.definition instanceof ASTSegmentViewDefinition;
34416
+ return /* @__PURE__ */ jsx("div", {
34417
+ onPointerDownCapture: focusMainQueryPanel,
34418
+ children: /* @__PURE__ */ jsxs(CollapsiblePanel, {
34419
+ title: "Main query",
34420
+ isFocused: !currentNestQueryPanel,
34421
+ controls: /* @__PURE__ */ jsxs(Fragment, {
34422
+ children: [/* @__PURE__ */ jsx(DropdownMenu, {
34423
+ trigger: /* @__PURE__ */ jsx(Button, {
34424
+ variant: "flat",
34425
+ icon: "meatballs",
34426
+ size: "compact",
34427
+ tooltip: "More Actions"
34428
+ }),
34429
+ children: setQuery ? /* @__PURE__ */ jsxs(Fragment, {
34430
+ children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
34431
+ icon: "clear",
34432
+ label: "Clear query",
34433
+ onClick: () => {
34434
+ focusMainQueryPanel();
34435
+ setQuery == null ? void 0 : setQuery(void 0);
34436
+ },
34437
+ disabled: rootQuery.isEmpty()
34438
+ }), /* @__PURE__ */ jsx(DropdownMenuItem, {
34439
+ icon: "nest",
34440
+ label: "Nest query",
34441
+ onClick: () => {
34442
+ if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
34443
+ rootQuery.definition.view.convertToNest("Nest");
34444
+ }
34445
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
34446
+ },
34447
+ disabled: rootQuery.isEmpty() || !(rootQuery.definition instanceof ASTArrowQueryDefinition)
34448
+ })]
34449
+ }) : /* @__PURE__ */ jsx(Fragment, {})
34450
+ }), query.definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsx(AddMenu, {
34451
+ rootQuery,
34452
+ view: query.definition
34453
+ }) : null]
34454
+ }),
34455
+ collapsedControls: /* @__PURE__ */ jsx(Icon, {
34456
+ name: viewToVisualizationIcon(query)
34457
+ }),
34458
+ children: [query.definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsxs("div", {
34459
+ style: {
34460
+ display: "flex",
34461
+ flexDirection: "column",
34462
+ gap: 8
34375
34463
  },
34376
- children: [/* @__PURE__ */ jsx("div", {
34377
- children: "Click"
34378
- }), /* @__PURE__ */ jsx(Icon, {
34379
- name: "insert"
34380
- }), /* @__PURE__ */ jsx("div", {
34381
- children: "to get started"
34464
+ children: [!query.isEmpty() && canEditViz && /* @__PURE__ */ jsx(Visualization$1, {
34465
+ rootQuery,
34466
+ view: query
34467
+ }), /* @__PURE__ */ jsx(ViewDefinition, {
34468
+ rootQuery,
34469
+ view: query.definition,
34470
+ viewDef: query.definition.view
34382
34471
  })]
34383
- })
34384
- }) : null]
34472
+ }) : null, query.isEmpty() ? /* @__PURE__ */ jsx("div", {
34473
+ ...{
34474
+ className: "mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra"
34475
+ },
34476
+ children: /* @__PURE__ */ jsxs("div", {
34477
+ ...{
34478
+ className: "mly78zum5 mly6s0dn4 mlywzxoxx"
34479
+ },
34480
+ children: [/* @__PURE__ */ jsx("div", {
34481
+ children: "Click"
34482
+ }), /* @__PURE__ */ jsx(Icon, {
34483
+ name: "insert",
34484
+ color: "disabled"
34485
+ }), /* @__PURE__ */ jsx("div", {
34486
+ children: "to get started"
34487
+ })]
34488
+ })
34489
+ }) : null]
34490
+ })
34385
34491
  });
34386
34492
  }
34387
34493
  function Source({
@@ -34389,14 +34495,14 @@ function Source({
34389
34495
  }) {
34390
34496
  if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
34391
34497
  return /* @__PURE__ */ jsx("div", {
34392
- ..._stylex.props(styles$s.queryCard, styles$a.content),
34498
+ ..._stylex.props(styles$r.queryCard, styles$b.content),
34393
34499
  children: /* @__PURE__ */ jsxs("div", {
34394
- ..._stylex.props(styles$s.labelWithIcon),
34500
+ ..._stylex.props(styles$r.labelWithIcon),
34395
34501
  children: [/* @__PURE__ */ jsx(Icon, {
34396
34502
  name: "database"
34397
34503
  }), /* @__PURE__ */ jsx("div", {
34398
34504
  ...{
34399
- className: "mlyb3r6kr mlylyipyv"
34505
+ className: "mlyb3r6kr mlylyipyv mly117nqv4"
34400
34506
  },
34401
34507
  children: rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name
34402
34508
  })]
@@ -34405,7 +34511,7 @@ function Source({
34405
34511
  }
34406
34512
  return null;
34407
34513
  }
34408
- const styles$a = {
34514
+ const styles$b = {
34409
34515
  content: {
34410
34516
  display: "mlyrvj5dj",
34411
34517
  gridAutoFlow: "mly1mt1orb",
@@ -34416,12 +34522,145 @@ const styles$a = {
34416
34522
  $$css: true
34417
34523
  }
34418
34524
  };
34525
+ function DateLiteralEditor({
34526
+ value,
34527
+ setValue,
34528
+ customStyle
34529
+ }) {
34530
+ const [errorMessage, setErrorMessage] = useState("");
34531
+ const [open, setOpen] = useState(false);
34532
+ const input = useRef(null);
34533
+ const picker = useRef(null);
34534
+ const isDate2 = value.kind === "date_literal";
34535
+ const date = isDate2 ? value.date_value : value.timestamp_value;
34536
+ const units = isDate2 ? "day" : "second";
34537
+ const onSetValue = (date2) => {
34538
+ if (date2) {
34539
+ setErrorMessage("");
34540
+ if (isDate2) {
34541
+ setValue({
34542
+ kind: "date_literal",
34543
+ date_value: hooks.utc(date2).format(formats["day"])
34544
+ });
34545
+ } else {
34546
+ setValue({
34547
+ kind: "timestamp_literal",
34548
+ timestamp_value: hooks.utc(date2).format(formats["second"])
34549
+ });
34550
+ }
34551
+ } else {
34552
+ setErrorMessage("Invalid date");
34553
+ }
34554
+ };
34555
+ useClickOutside([input, picker], () => {
34556
+ setOpen(false);
34557
+ });
34558
+ return /* @__PURE__ */ jsxs(Root2$2, {
34559
+ open,
34560
+ onOpenChange: () => {
34561
+ },
34562
+ children: [/* @__PURE__ */ jsx(Trigger$2, {
34563
+ asChild: true,
34564
+ children: /* @__PURE__ */ jsx("div", {
34565
+ ..._stylex.props(tokenStyles.main, styles$a.wrapper, customStyle),
34566
+ children: /* @__PURE__ */ jsx(DateInput, {
34567
+ value: hooks.utc(date).toDate(),
34568
+ setValue: onSetValue,
34569
+ units,
34570
+ onFocus: () => setOpen(true),
34571
+ customStyle: {
34572
+ ...styles$a.input,
34573
+ ...isDate2 ? styles$a.dateInput : styles$a.timestampInput
34574
+ },
34575
+ forwardRef: input
34576
+ })
34577
+ })
34578
+ }), errorMessage && /* @__PURE__ */ jsx(ErrorIcon, {
34579
+ errorMessage
34580
+ }), /* @__PURE__ */ jsx(Portal$2, {
34581
+ children: /* @__PURE__ */ jsx(Content2$2, {
34582
+ align: "center",
34583
+ asChild: true,
34584
+ children: /* @__PURE__ */ jsx(DatePicker, {
34585
+ value: hooks.utc(date).toDate(),
34586
+ setValue: onSetValue,
34587
+ units,
34588
+ maxLevel: units,
34589
+ customStyle: styles$a.datePicker,
34590
+ forwardRef: picker
34591
+ })
34592
+ })
34593
+ })]
34594
+ });
34595
+ }
34596
+ const styles$a = {
34597
+ input: {
34598
+ border: "mly1gs6z28",
34599
+ borderWidth: null,
34600
+ borderInlineWidth: null,
34601
+ borderInlineStartWidth: null,
34602
+ borderLeftWidth: null,
34603
+ borderInlineEndWidth: null,
34604
+ borderRightWidth: null,
34605
+ borderBlockWidth: null,
34606
+ borderTopWidth: null,
34607
+ borderBottomWidth: null,
34608
+ borderStyle: null,
34609
+ borderInlineStyle: null,
34610
+ borderInlineStartStyle: null,
34611
+ borderLeftStyle: null,
34612
+ borderInlineEndStyle: null,
34613
+ borderRightStyle: null,
34614
+ borderBlockStyle: null,
34615
+ borderTopStyle: null,
34616
+ borderBottomStyle: null,
34617
+ borderColor: null,
34618
+ borderInlineColor: null,
34619
+ borderInlineStartColor: null,
34620
+ borderLeftColor: null,
34621
+ borderInlineEndColor: null,
34622
+ borderRightColor: null,
34623
+ borderBlockColor: null,
34624
+ borderTopColor: null,
34625
+ borderBottomColor: null,
34626
+ height: "mlyd7y6wv",
34627
+ backgroundColor: "mlyjbqb8w mlytw1abo",
34628
+ $$css: true
34629
+ },
34630
+ dateInput: {
34631
+ width: "mly869kya",
34632
+ $$css: true
34633
+ },
34634
+ timestampInput: {
34635
+ width: "mlynrytzq",
34636
+ $$css: true
34637
+ },
34638
+ wrapper: {
34639
+ $$css: true
34640
+ },
34641
+ datePicker: {
34642
+ display: "mly78zum5",
34643
+ flexDirection: "mlydt5ytf",
34644
+ boxShadow: "mly5n1uv4",
34645
+ backgroundColor: "mly12peec7",
34646
+ borderRadius: "mlyur7f20",
34647
+ borderStartStartRadius: null,
34648
+ borderStartEndRadius: null,
34649
+ borderEndStartRadius: null,
34650
+ borderEndEndRadius: null,
34651
+ borderTopLeftRadius: null,
34652
+ borderTopRightRadius: null,
34653
+ borderBottomLeftRadius: null,
34654
+ borderBottomRightRadius: null,
34655
+ width: "mly1hfn5x7",
34656
+ $$css: true
34657
+ }
34658
+ };
34419
34659
  function LiteralValueEditor({
34420
34660
  value,
34421
34661
  setValue,
34422
34662
  customStyle
34423
34663
  }) {
34424
- const [errorMessage, setErrorMessage] = React.useState("");
34425
34664
  if (!value) {
34426
34665
  return null;
34427
34666
  }
@@ -34436,31 +34675,18 @@ function LiteralValueEditor({
34436
34675
  label: "false",
34437
34676
  value: "false"
34438
34677
  }],
34439
- onChange: (value2) => setValue(value2 === "true"),
34678
+ onChange: (value2) => setValue({
34679
+ kind: "boolean_literal",
34680
+ boolean_value: value2 === "true"
34681
+ }),
34440
34682
  customStyle
34441
34683
  });
34442
34684
  case "date_literal":
34443
- return /* @__PURE__ */ jsxs("div", {
34444
- ...{
34445
- className: "mly78zum5"
34446
- },
34447
- children: [/* @__PURE__ */ jsx("input", {
34448
- value: value.date_value.split(" ")[0],
34449
- type: "date",
34450
- onChange: (event) => {
34451
- if (event.target.valueAsDate) {
34452
- setErrorMessage("");
34453
- setValue({
34454
- date: event.target.valueAsDate,
34455
- granularity: "day"
34456
- });
34457
- } else {
34458
- setErrorMessage("Invalid date");
34459
- }
34460
- }
34461
- }), errorMessage && /* @__PURE__ */ jsx(ErrorIcon, {
34462
- errorMessage
34463
- })]
34685
+ case "timestamp_literal":
34686
+ return /* @__PURE__ */ jsx(DateLiteralEditor, {
34687
+ value,
34688
+ setValue,
34689
+ customStyle
34464
34690
  });
34465
34691
  case "null_literal":
34466
34692
  return /* @__PURE__ */ jsx(Token, {
@@ -34470,42 +34696,28 @@ function LiteralValueEditor({
34470
34696
  return /* @__PURE__ */ jsx(EditableToken, {
34471
34697
  value: value.number_value,
34472
34698
  type: "number",
34473
- onChange: (value2) => setValue(value2),
34699
+ onChange: (value2) => setValue({
34700
+ kind: "number_literal",
34701
+ number_value: value2
34702
+ }),
34474
34703
  customStyle
34475
34704
  });
34476
34705
  case "string_literal":
34477
34706
  return /* @__PURE__ */ jsx(EditableToken, {
34478
34707
  value: value.string_value,
34479
- onChange: (value2) => setValue(value2),
34708
+ onChange: (value2) => setValue({
34709
+ kind: "string_literal",
34710
+ string_value: value2
34711
+ }),
34480
34712
  customStyle
34481
34713
  });
34482
- case "timestamp_literal":
34483
- return /* @__PURE__ */ jsxs("div", {
34484
- ...{
34485
- className: "mly78zum5"
34486
- },
34487
- children: [/* @__PURE__ */ jsx("input", {
34488
- value: value.timestamp_value,
34489
- type: "date",
34490
- onChange: (event) => {
34491
- if (event.target.valueAsDate) {
34492
- setErrorMessage("");
34493
- setValue({
34494
- date: event.target.valueAsDate,
34495
- granularity: "second"
34496
- });
34497
- } else {
34498
- setErrorMessage("Invalid date");
34499
- }
34500
- }
34501
- }), errorMessage && /* @__PURE__ */ jsx(ErrorIcon, {
34502
- errorMessage
34503
- })]
34504
- });
34505
34714
  case "filter_expression_literal":
34506
34715
  return /* @__PURE__ */ jsx(EditableToken, {
34507
34716
  value: value.filter_expression_value,
34508
- onChange: (value2) => setValue(value2),
34717
+ onChange: (value2) => setValue({
34718
+ kind: "filter_expression_literal",
34719
+ filter_expression_value: value2
34720
+ }),
34509
34721
  customStyle
34510
34722
  });
34511
34723
  }
@@ -35091,34 +35303,22 @@ function Banners({
35091
35303
  function RenderedResult({
35092
35304
  result
35093
35305
  }) {
35094
- const [html2, setHTML] = React.useState();
35095
- const [rendering, setRendering] = React.useState(true);
35096
- React.useEffect(() => {
35097
- let canceled = false;
35098
- setRendering(true);
35099
- const updateResults = async () => {
35100
- const renderer = new render.HTMLView(document);
35101
- const html22 = await renderer.render(result, {
35102
- dataStyles: {},
35103
- isDrillingEnabled: true
35104
- });
35105
- if (canceled) {
35106
- return;
35107
- }
35108
- setRendering(false);
35109
- setHTML(html22);
35110
- };
35111
- updateResults();
35112
- return () => {
35113
- canceled = true;
35114
- };
35306
+ const [renderer, setRenderer] = useState();
35307
+ useEffect(() => {
35308
+ const renderer2 = document.createElement("malloy-render");
35309
+ renderer2.malloyResult = result;
35310
+ setRenderer(renderer2);
35115
35311
  }, [result]);
35116
- if (!rendering) return html2 && /* @__PURE__ */ jsx(DOMElement, {
35117
- className: "malloy-render_result-wrapper",
35118
- element: html2
35119
- });
35120
- return /* @__PURE__ */ jsx(ScrollableArea, {
35121
- 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", {
35122
35322
  ...{
35123
35323
  className: "mly78zum5 mlyl56j7k mly6s0dn4"
35124
35324
  },
@@ -35133,8 +35333,8 @@ function RenderedResult({
35133
35333
  children: "Rendering..."
35134
35334
  })]
35135
35335
  })
35136
- })
35137
- });
35336
+ });
35337
+ }
35138
35338
  }
35139
35339
  function LoadingDisplay({
35140
35340
  onCancel,
@@ -35331,7 +35531,7 @@ function ResultPanel({
35331
35531
  children: [/* @__PURE__ */ jsx(Content, {
35332
35532
  value: "Results",
35333
35533
  ...{
35334
- className: "mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619 mlyysyzu8"
35534
+ className: "mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619"
35335
35535
  },
35336
35536
  children: submittedQuery && /* @__PURE__ */ jsxs(Fragment, {
35337
35537
  children: [draftQuery && submittedQuery && !queriesAreEqual(draftQuery, submittedQuery.query) && /* @__PURE__ */ jsxs("div", {
@@ -35550,15 +35750,21 @@ function flattenFieldsTree(fields, path = []) {
35550
35750
  case "measure":
35551
35751
  case "dimension":
35552
35752
  if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
35553
- return flattenFieldsTree(field.type.element_type.fields.map((dimension) => ({
35753
+ return [{
35754
+ path,
35755
+ field
35756
+ }, ...flattenFieldsTree(field.type.element_type.fields.map((dimension) => ({
35554
35757
  kind: field.kind,
35555
35758
  ...dimension
35556
- })), [...path, field.name]);
35759
+ })), [...path, field.name])];
35557
35760
  } else if (field.type.kind === "record_type") {
35558
- return flattenFieldsTree(field.type.fields.map((dimension) => ({
35761
+ return [{
35762
+ path,
35763
+ field
35764
+ }, ...flattenFieldsTree(field.type.fields.map((dimension) => ({
35559
35765
  kind: field.kind,
35560
35766
  ...dimension
35561
- })), [...path, field.name]);
35767
+ })), [...path, field.name])];
35562
35768
  }
35563
35769
  return [{
35564
35770
  path,
@@ -35600,64 +35806,46 @@ function groupFieldItemsByKind(items) {
35600
35806
  return acc;
35601
35807
  }, {}));
35602
35808
  }
35603
- const getNestName = (segment, rename = "Nest") => {
35604
- const nestNo = segmentNestNo(segment);
35605
- return nestNo > 1 ? `${rename} ${nestNo}` : rename;
35606
- };
35607
35809
  const FIELD_KIND_TO_TITLE = {
35608
35810
  view: "Views",
35609
35811
  measure: "Measures",
35610
35812
  dimension: "Dimensions"
35611
35813
  };
35612
- function useNestOperations(rootQuery) {
35613
- const nestOperations = useMemo(() => {
35614
- if (rootQuery) {
35615
- const queryDef = rootQuery.definition;
35616
- if (queryDef instanceof ASTArrowQueryDefinition) {
35617
- return extractNestOperations(queryDef.view);
35618
- }
35619
- }
35620
- return [];
35621
- }, [rootQuery]);
35622
- return nestOperations;
35623
- }
35624
- const extractNestOperations = (view, nestOperations = []) => {
35625
- if (view instanceof ASTArrowViewDefinition) {
35626
- return extractNestOperations(view.view, nestOperations);
35627
- } else if (view instanceof ASTSegmentViewDefinition) {
35628
- view.operations.items.filter((operation) => operation instanceof ASTNestViewOperation).forEach((operation) => {
35629
- const nestView = operation.view.definition;
35630
- nestOperations.push({
35631
- name: operation.name,
35632
- view: nestView
35633
- });
35634
- extractNestOperations(nestView, nestOperations);
35635
- });
35636
- return nestOperations;
35637
- } else if (view instanceof ASTRefinementViewDefinition) {
35638
- return extractNestOperations(view.refinement, nestOperations);
35639
- }
35640
- return nestOperations;
35641
- };
35642
35814
  function useOperations(view, field, path) {
35815
+ const dimensionFields = useMemo(() => {
35816
+ const {
35817
+ fields
35818
+ } = getInputSchemaFromViewParent(view);
35819
+ return new Set(flattenFieldsTree(fields).filter(({
35820
+ field: field2
35821
+ }) => field2.kind === "dimension").map(({
35822
+ field: field2
35823
+ }) => field2.name));
35824
+ }, [view]);
35825
+ const measureFields = useMemo(() => {
35826
+ const {
35827
+ fields
35828
+ } = getInputSchemaFromViewParent(view);
35829
+ return new Set(flattenFieldsTree(fields).filter(({
35830
+ field: field2
35831
+ }) => field2.kind === "measure").map(({
35832
+ field: field2
35833
+ }) => field2.name));
35834
+ }, [view]);
35643
35835
  const isGroupByAllowed = useMemo(() => {
35644
35836
  if (!view) {
35645
35837
  return false;
35646
35838
  }
35647
- const fieldName = field.name;
35648
- const inputSchemaFields = getInputSchemaFromViewParent(view).fields;
35649
- const filteredFieldItems = flattenFieldsTree(inputSchemaFields).filter((item) => item.field.kind === "dimension");
35650
- return filteredFieldItems.some((item) => item.field.name === fieldName && item.path.join(".") === path.join("."));
35651
- }, [view, field, path]);
35839
+ const segment = getSegmentIfPresent(view);
35840
+ return dimensionFields.has(field.name) && !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
35841
+ }, [view, field, path, dimensionFields]);
35652
35842
  const isAggregateAllowed = useMemo(() => {
35653
35843
  if (!view) {
35654
35844
  return false;
35655
35845
  }
35656
- const fieldName = field.name;
35657
- const inputSchemaFields = getInputSchemaFromViewParent(view).fields;
35658
- const filteredFieldItems = flattenFieldsTree(inputSchemaFields).filter((item) => item.field.kind === "measure");
35659
- return filteredFieldItems.some((item) => item.field.name === fieldName && item.path.join(".") === path.join("."));
35660
- }, [view, field, path]);
35846
+ const segment = getSegmentIfPresent(view);
35847
+ return measureFields.has(field.name) && !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
35848
+ }, [view, field, path, measureFields]);
35661
35849
  const isFilterAllowed = useMemo(() => {
35662
35850
  if (!view) {
35663
35851
  return false;
@@ -35684,280 +35872,119 @@ function useOperations(view, field, path) {
35684
35872
  }
35685
35873
  const FILTERABLE_TYPES = ["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"];
35686
35874
  const ORDERABLE_TYPES = ["string_type", "number_type", "boolean_type", "date_type", "timestamp_type"];
35687
- function OperationDropdownMenuItems({
35688
- view,
35875
+ function FieldTokenWithActions({
35689
35876
  field,
35690
35877
  path,
35691
- withEmptyNest = false
35878
+ viewDef
35692
35879
  }) {
35693
35880
  const {
35694
35881
  rootQuery,
35695
- setQuery
35882
+ setQuery,
35883
+ currentNestView
35696
35884
  } = React__default.useContext(QueryEditorContext);
35885
+ const view = currentNestView ?? viewDef;
35697
35886
  const {
35698
35887
  isGroupByAllowed,
35699
35888
  isAggregateAllowed,
35700
35889
  isFilterAllowed,
35701
35890
  isOrderByAllowed
35702
35891
  } = useOperations(view, field, path);
35703
- const handleMenuItemClick = (event, operation) => {
35892
+ const [isFilterPopoverOpen, setIsFilterPopoverOpen] = useState();
35893
+ const [isTooltipOpen, setIsTooltipOpen] = useState(false);
35894
+ const handleAddOperationAction = (operation, filter) => {
35704
35895
  if (field.kind === "dimension" || field.kind === "measure") {
35705
- const segment = view.getOrAddDefaultSegment();
35706
- const currentView = withEmptyNest ? segment.addEmptyNest(getNestName(segment)).view : view;
35707
- const currentSegment = currentView.getOrAddDefaultSegment();
35708
35896
  if (operation === "groupBy" && isGroupByAllowed) {
35709
- addGroupBy(currentView, field, path);
35897
+ addGroupBy(view, field, path);
35710
35898
  } else if (operation === "aggregate" && isAggregateAllowed) {
35711
- addAggregate(currentView, field, path);
35899
+ addAggregate(view, field, path);
35712
35900
  } else if (operation === "orderBy" && isOrderByAllowed) {
35713
- currentSegment.addOrderBy(field.name, "asc");
35901
+ addOrderBy(view, field);
35902
+ } else if (operation === "filter" && isFilterAllowed && filter) {
35903
+ addFilter(view, field, path, filter);
35714
35904
  }
35715
35905
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35716
35906
  }
35717
35907
  };
35718
- return /* @__PURE__ */ jsx(Fragment, {
35719
- children: field.kind === "measure" ? /* @__PURE__ */ jsxs(Fragment, {
35720
- children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
35721
- icon: "aggregate",
35722
- label: "Aggregate",
35723
- disabled: !isAggregateAllowed,
35724
- onClick: (event) => handleMenuItemClick(event, "aggregate")
35725
- }), /* @__PURE__ */ jsx(FilterDropdownSubmenuItem, {
35726
- view,
35727
- isFilterAllowed,
35728
- field,
35729
- path
35730
- }), /* @__PURE__ */ jsx(DropdownMenuItem, {
35731
- icon: "orderBy",
35732
- label: "Order by",
35733
- disabled: !isOrderByAllowed,
35734
- onClick: (event) => handleMenuItemClick(event, "orderBy")
35735
- })]
35736
- }) : field.kind === "dimension" ? /* @__PURE__ */ jsxs(Fragment, {
35737
- children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
35738
- icon: "groupBy",
35739
- label: "Group by",
35740
- disabled: !isGroupByAllowed,
35741
- onClick: (event) => handleMenuItemClick(event, "groupBy")
35742
- }), /* @__PURE__ */ jsx(FilterDropdownSubmenuItem, {
35743
- view,
35744
- isFilterAllowed,
35745
- field,
35746
- path
35747
- }), /* @__PURE__ */ jsx(DropdownMenuItem, {
35748
- icon: "orderBy",
35749
- label: "Order by",
35750
- disabled: !isOrderByAllowed,
35751
- onClick: (event) => handleMenuItemClick(event, "orderBy")
35752
- })]
35753
- }) : /* @__PURE__ */ jsx(Fragment, {})
35754
- });
35755
- }
35756
- function FilterDropdownSubmenuItem({
35757
- view,
35758
- isFilterAllowed,
35759
- field,
35760
- path
35761
- }) {
35762
- const {
35763
- rootQuery,
35764
- setQuery
35765
- } = React__default.useContext(QueryEditorContext);
35766
- const [isOpen, setIsOpen] = useState(false);
35767
- const handleFilterSet = (filter) => {
35768
- const segment = view.getOrAddDefaultSegment();
35769
- if (field.kind === "dimension") {
35770
- segment.addWhere(field.name, path, filter);
35771
- } else {
35772
- segment.addHaving(field.name, path, filter);
35773
- }
35774
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35775
- };
35776
- return /* @__PURE__ */ jsx(DropdownSubMenuItem, {
35777
- icon: "filter",
35778
- label: "Filter",
35779
- disabled: !isFilterAllowed,
35780
- open: isOpen,
35781
- onOpenChange: setIsOpen,
35782
- children: /* @__PURE__ */ jsx(FilterDialog, {
35783
- fieldInfo: field,
35784
- path,
35785
- onFilterApply: handleFilterSet,
35786
- onOpenChange: setIsOpen
35787
- })
35788
- });
35789
- }
35790
- function NestFieldDropdownMenu({
35791
- view,
35792
- field,
35793
- path,
35794
- trigger,
35795
- onOpenChange
35796
- }) {
35797
- const {
35798
- rootQuery,
35799
- setQuery
35800
- } = useContext(QueryEditorContext);
35801
- const nestOperations = useNestOperations(rootQuery);
35802
- const nestViewWithinNestQuery = (operation) => {
35803
- const segment = operation.view.getOrAddDefaultSegment();
35804
- const {
35805
- fields
35806
- } = operation.view.getOutputSchema();
35807
- let rename;
35808
- if (fields.find((f2) => f2.name === field.name)) {
35809
- rename = findUniqueFieldName(fields, field.name);
35810
- }
35811
- segment.addNest(field.name, rename);
35812
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35813
- };
35814
- return /* @__PURE__ */ jsx(DropdownMenu, {
35815
- trigger,
35816
- onOpenChange,
35817
- children: nestOperations.length === 0 ? /* @__PURE__ */ jsxs(Fragment, {
35818
- children: [/* @__PURE__ */ jsx(DropdownMenuLabel, {
35819
- label: "Add to new nested query as..."
35820
- }), /* @__PURE__ */ jsx(OperationDropdownMenuItems, {
35821
- view,
35822
- field,
35823
- path,
35824
- withEmptyNest: true
35825
- })]
35826
- }) : /* @__PURE__ */ jsxs(Fragment, {
35827
- children: [/* @__PURE__ */ jsx(DropdownMenuLabel, {
35828
- label: "Add to nested query..."
35829
- }), nestOperations.map((operation, index2) => {
35830
- return field.kind === "view" ? /* @__PURE__ */ jsx(DropdownMenuItem, {
35831
- label: operation.name,
35832
- onClick: () => nestViewWithinNestQuery(operation)
35833
- }, index2) : /* @__PURE__ */ jsxs(DropdownSubMenuItem, {
35834
- label: operation.name,
35835
- children: [/* @__PURE__ */ jsx(DropdownMenuLabel, {
35836
- label: `Add to ${operation.name} query as...`
35837
- }), /* @__PURE__ */ jsx(OperationDropdownMenuItems, {
35838
- view: operation.view.parent.as.View(),
35839
- field,
35840
- path
35841
- })]
35842
- }, index2);
35843
- })]
35844
- })
35845
- });
35846
- }
35847
- function AddFieldDropdownMenu({
35848
- view,
35849
- field,
35850
- path,
35851
- ...props2
35852
- }) {
35853
- return /* @__PURE__ */ jsxs(DropdownMenu, {
35854
- ...props2,
35855
- children: [/* @__PURE__ */ jsx(DropdownMenuLabel, {
35856
- label: "Add to main query as..."
35857
- }), /* @__PURE__ */ jsx(OperationDropdownMenuItems, {
35858
- view,
35859
- field,
35860
- path
35861
- })]
35862
- });
35863
- }
35864
- function FieldTokenWithActions({
35865
- field,
35866
- path
35867
- }) {
35868
- const {
35869
- rootQuery,
35870
- setQuery
35871
- } = React__default.useContext(QueryEditorContext);
35872
- const [isAddFieldMenuOpen, setIsAddFieldMenuOpen] = useState();
35873
- const [isNestFieldMenuOpen, setIsNestFieldMenuOpen] = useState();
35874
- const nestViews = useNestOperations(rootQuery);
35875
- const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
35876
- if (!(viewDef instanceof ASTArrowQueryDefinition)) {
35877
- return null;
35878
- }
35879
- const hasAddFieldMenu = field.kind === "measure" || field.kind === "dimension";
35880
- const hasNestFieldMenu = field.kind === "measure" || field.kind === "dimension" || field.kind === "view" && nestViews.length > 0;
35881
- const addViewToMainQuery = () => {
35882
- if (field.kind === "view") {
35883
- if (rootQuery == null ? void 0 : rootQuery.isEmpty()) {
35884
- rootQuery == null ? void 0 : rootQuery.setView(field.name);
35885
- } else {
35886
- addNest(viewDef, field);
35887
- }
35908
+ const handleSetView = () => {
35909
+ if (field.kind === "view" && (rootQuery == null ? void 0 : rootQuery.isEmpty())) {
35910
+ rootQuery == null ? void 0 : rootQuery.setView(field.name);
35888
35911
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35889
35912
  }
35890
35913
  };
35891
- const nestViewWithinMainQuery = () => {
35914
+ const handleAddView = () => {
35892
35915
  if (field.kind === "view") {
35893
- addNest(viewDef, field);
35916
+ addNest(view, field);
35894
35917
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35895
35918
  }
35896
35919
  };
35897
- const hoverActions = () => {
35898
- return /* @__PURE__ */ jsxs(Fragment, {
35899
- children: [hasAddFieldMenu ? /* @__PURE__ */ jsx(AddFieldDropdownMenu, {
35900
- view: viewDef,
35901
- field,
35920
+ return /* @__PURE__ */ jsx(FieldToken, {
35921
+ field,
35922
+ hoverActions: field.kind === "view" ? /* @__PURE__ */ jsxs(Fragment, {
35923
+ children: [/* @__PURE__ */ jsx(ActionButton, {
35924
+ icon: "insert",
35925
+ disabled: !(rootQuery == null ? void 0 : rootQuery.isEmpty()),
35926
+ onClick: handleSetView,
35927
+ tooltip: "Add view",
35928
+ onTooltipOpenChange: setIsTooltipOpen
35929
+ }), /* @__PURE__ */ jsx(ActionButton, {
35930
+ icon: "nest",
35931
+ onClick: handleAddView,
35932
+ tooltip: "Add as new nested query",
35933
+ onTooltipOpenChange: setIsTooltipOpen
35934
+ })]
35935
+ }) : field.kind === "measure" ? /* @__PURE__ */ jsxs(Fragment, {
35936
+ children: [/* @__PURE__ */ jsx(ActionButton, {
35937
+ icon: "aggregate",
35938
+ tooltip: "Add as aggregate",
35939
+ disabled: !isAggregateAllowed,
35940
+ onClick: () => handleAddOperationAction("aggregate"),
35941
+ onTooltipOpenChange: setIsTooltipOpen
35942
+ }), /* @__PURE__ */ jsx(FilterPopover, {
35943
+ fieldInfo: field,
35902
35944
  path,
35903
- trigger: /* @__PURE__ */ jsx(Button, {
35904
- variant: "flat",
35905
- size: "compact",
35906
- icon: "insert",
35907
- tooltip: "Add to main query"
35945
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
35946
+ trigger: /* @__PURE__ */ jsx(ActionButton, {
35947
+ icon: "filter",
35948
+ tooltip: "Add as filter",
35949
+ disabled: !isFilterAllowed,
35950
+ onTooltipOpenChange: setIsTooltipOpen
35908
35951
  }),
35909
- onOpenChange: (open) => setIsAddFieldMenuOpen(open)
35910
- }) : /* @__PURE__ */ jsx(Button, {
35911
- variant: "flat",
35912
- size: "compact",
35913
- icon: "insert",
35914
- onClick: addViewToMainQuery,
35915
- tooltip: "Add to main query"
35916
- }), hasNestFieldMenu ? /* @__PURE__ */ jsx(NestFieldDropdownMenu, {
35917
- view: viewDef,
35918
- field,
35952
+ onOpenChange: setIsFilterPopoverOpen
35953
+ }), /* @__PURE__ */ jsx(ActionButton, {
35954
+ icon: "orderBy",
35955
+ tooltip: "Add as order by",
35956
+ disabled: !isOrderByAllowed,
35957
+ onClick: () => handleAddOperationAction("orderBy"),
35958
+ onTooltipOpenChange: setIsTooltipOpen
35959
+ })]
35960
+ }) : field.kind === "dimension" ? /* @__PURE__ */ jsxs(Fragment, {
35961
+ children: [/* @__PURE__ */ jsx(ActionButton, {
35962
+ icon: "groupBy",
35963
+ tooltip: "Add as group by",
35964
+ disabled: !isGroupByAllowed,
35965
+ onClick: () => handleAddOperationAction("groupBy"),
35966
+ onTooltipOpenChange: setIsTooltipOpen
35967
+ }), /* @__PURE__ */ jsx(FilterPopover, {
35968
+ fieldInfo: field,
35919
35969
  path,
35920
- trigger: /* @__PURE__ */ jsx(Button, {
35921
- variant: "flat",
35922
- size: "compact",
35923
- icon: "nest",
35924
- tooltip: "Add to nested query"
35970
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
35971
+ trigger: /* @__PURE__ */ jsx(ActionButton, {
35972
+ icon: "filter",
35973
+ tooltip: "Add as filter",
35974
+ disabled: !isFilterAllowed,
35975
+ onTooltipOpenChange: setIsTooltipOpen
35925
35976
  }),
35926
- onOpenChange: (open) => setIsNestFieldMenuOpen(open)
35927
- }) : /* @__PURE__ */ jsx(Button, {
35928
- variant: "flat",
35929
- size: "compact",
35930
- icon: "nest",
35931
- onClick: nestViewWithinMainQuery,
35932
- tooltip: "Add to nested query"
35977
+ onOpenChange: setIsFilterPopoverOpen
35978
+ }), /* @__PURE__ */ jsx(ActionButton, {
35979
+ icon: "orderBy",
35980
+ tooltip: "Add as order by",
35981
+ disabled: !isOrderByAllowed,
35982
+ onClick: () => handleAddOperationAction("orderBy"),
35983
+ onTooltipOpenChange: setIsTooltipOpen
35933
35984
  })]
35934
- });
35935
- };
35936
- return hasAddFieldMenu ? /* @__PURE__ */ jsx(AddFieldDropdownMenu, {
35937
- view: viewDef,
35938
- field,
35939
- path,
35940
- trigger: /* @__PURE__ */ jsx(FieldToken, {
35941
- field,
35942
- hoverActionsVisible: isAddFieldMenuOpen || isNestFieldMenuOpen,
35943
- hoverActions: hoverActions(),
35944
- asButtonTrigger: true
35945
- }),
35946
- onOpenChange: (open) => setIsAddFieldMenuOpen(open),
35947
- tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
35948
- field,
35949
- path
35950
- }),
35951
- tooltipProps: {
35952
- side: "right",
35953
- align: "start",
35954
- alignOffset: 28
35955
- }
35956
- }) : /* @__PURE__ */ jsx(FieldToken, {
35957
- field,
35958
- onClick: addViewToMainQuery,
35959
- hoverActions: hoverActions(),
35960
- hoverActionsVisible: isAddFieldMenuOpen || isNestFieldMenuOpen,
35985
+ }) : null,
35986
+ onClick: field.kind === "dimension" && isGroupByAllowed ? () => handleAddOperationAction("groupBy") : field.kind === "measure" && isAggregateAllowed ? () => handleAddOperationAction("aggregate") : field.kind === "view" ? () => handleAddView() : void 0,
35987
+ hoverActionsVisible: isFilterPopoverOpen || isTooltipOpen,
35961
35988
  tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
35962
35989
  field,
35963
35990
  path
@@ -35969,6 +35996,30 @@ function FieldTokenWithActions({
35969
35996
  }
35970
35997
  });
35971
35998
  }
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
+ })]
36021
+ });
36022
+ }
35972
36023
  const FIELD_KIND_ORDER = ["dimension", "measure", "view"];
35973
36024
  function SearchResultList({
35974
36025
  source,
@@ -35980,6 +36031,13 @@ function SearchResultList({
35980
36031
  items: groupFieldItemsByPath(source, group.items)
35981
36032
  }));
35982
36033
  }, [source, items]);
36034
+ const {
36035
+ rootQuery
36036
+ } = React.useContext(QueryEditorContext);
36037
+ const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
36038
+ if (!(viewDef instanceof ASTArrowQueryDefinition)) {
36039
+ return null;
36040
+ }
35983
36041
  return /* @__PURE__ */ jsxs("div", {
35984
36042
  ...{
35985
36043
  className: "mly78zum5 mlydt5ytf mly1cy8zhl mlyou54vl mlye8ttls mly10cdfl8"
@@ -36014,7 +36072,8 @@ function SearchResultList({
36014
36072
  path
36015
36073
  }) => /* @__PURE__ */ jsx(FieldTokenWithActions, {
36016
36074
  field,
36017
- path
36075
+ path,
36076
+ viewDef
36018
36077
  }, [...path, field.name].join(".")))))
36019
36078
  })]
36020
36079
  }, group))]
@@ -36057,6 +36116,13 @@ function FieldGroupList({
36057
36116
  group
36058
36117
  }) => group === fieldGroupType)) == null ? void 0 : _a2.items) ?? [];
36059
36118
  }, [fieldGroupsByKindByPath, fieldGroupType]);
36119
+ const {
36120
+ rootQuery
36121
+ } = React.useContext(QueryEditorContext);
36122
+ const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
36123
+ if (!(viewDef instanceof ASTArrowQueryDefinition)) {
36124
+ return null;
36125
+ }
36060
36126
  return /* @__PURE__ */ jsx("div", {
36061
36127
  ...{
36062
36128
  className: "mly78zum5 mlydt5ytf mly167g77z"
@@ -36071,7 +36137,8 @@ function FieldGroupList({
36071
36137
  path
36072
36138
  }) => /* @__PURE__ */ jsx(FieldTokenWithActions, {
36073
36139
  field,
36074
- path
36140
+ path,
36141
+ viewDef
36075
36142
  }, [...path, field.name].join(".")))
36076
36143
  }, item.groupPath.join(".")))
36077
36144
  })