@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.
@@ -19,7 +19,6 @@ const jsxRuntime = require("react/jsx-runtime");
19
19
  const React = require("react");
20
20
  const QB = require("@malloydata/malloy-query-builder");
21
21
  const malloyTag = require("@malloydata/malloy-tag");
22
- const render = require("@malloydata/render");
23
22
  require("@malloydata/render/webcomponent");
24
23
  const ReactDOM = require("react-dom");
25
24
  function _interopNamespaceDefault(e) {
@@ -40,7 +39,6 @@ function _interopNamespaceDefault(e) {
40
39
  }
41
40
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
42
41
  const QB__namespace = /* @__PURE__ */ _interopNamespaceDefault(QB);
43
- const render__namespace = /* @__PURE__ */ _interopNamespaceDefault(render);
44
42
  const ReactDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactDOM);
45
43
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
46
44
  return function handleEvent(event) {
@@ -3351,13 +3349,19 @@ function MalloyExplorerProvider({
3351
3349
  topValues
3352
3350
  }) {
3353
3351
  const rootQuery = useQueryBuilder(source, query);
3352
+ const [currentNestView, setCurrentNestView] = React__namespace.useState(null);
3353
+ const [currentNestQueryPanel, setCurrentNestQueryPanel] = React__namespace.useState(null);
3354
3354
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, {
3355
3355
  children: /* @__PURE__ */ jsxRuntime.jsx(QueryEditorContext.Provider, {
3356
3356
  value: {
3357
3357
  source,
3358
3358
  rootQuery,
3359
3359
  setQuery,
3360
- topValues
3360
+ topValues,
3361
+ currentNestQueryPanel,
3362
+ onCurrentNestQueryPanelChange: setCurrentNestQueryPanel,
3363
+ currentNestView,
3364
+ onCurrentNestViewChange: setCurrentNestView
3361
3365
  },
3362
3366
  children
3363
3367
  })
@@ -3836,10 +3840,10 @@ function Icon({
3836
3840
  return null;
3837
3841
  }
3838
3842
  return /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {
3839
- ..._stylex.props(styles$M.main, colorVariants$3[color], SMALL_ICONS.includes(name) && styles$M.scaleUp, customStyle)
3843
+ ..._stylex.props(styles$N.main, colorVariants$3[color], SMALL_ICONS.includes(name) && styles$N.scaleUp, customStyle)
3840
3844
  });
3841
3845
  }
3842
- const styles$M = {
3846
+ const styles$N = {
3843
3847
  main: {
3844
3848
  display: "mly1rg5ohu",
3845
3849
  width: "mly1kky2od",
@@ -3912,17 +3916,17 @@ function Badge({
3912
3916
  customStyle
3913
3917
  }) {
3914
3918
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
3915
- ..._stylex.props(styles$L.main, colorVariants$2[color], customStyle),
3919
+ ..._stylex.props(styles$M.main, colorVariants$2[color], customStyle),
3916
3920
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
3917
3921
  color,
3918
3922
  name: icon
3919
3923
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
3920
- ..._stylex.props(fontStyles.badge, styles$L.label),
3924
+ ..._stylex.props(fontStyles.badge, styles$M.label),
3921
3925
  children: label
3922
3926
  })]
3923
3927
  });
3924
3928
  }
3925
- const styles$L = {
3929
+ const styles$M = {
3926
3930
  main: {
3927
3931
  display: "mly3nfvp2",
3928
3932
  height: "mly1qx5ct2",
@@ -4004,10 +4008,10 @@ function Divider({
4004
4008
  customStyle
4005
4009
  }) {
4006
4010
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
4007
- ..._stylex.props(styles$K.main, orientationVariants[orientation], customStyle)
4011
+ ..._stylex.props(styles$L.main, orientationVariants[orientation], customStyle)
4008
4012
  });
4009
4013
  }
4010
- const styles$K = {
4014
+ const styles$L = {
4011
4015
  main: {
4012
4016
  background: "mly1xnbgy5",
4013
4017
  backgroundAttachment: null,
@@ -4808,19 +4812,12 @@ function Button({
4808
4812
  icon,
4809
4813
  label,
4810
4814
  tooltip,
4811
- onClick,
4812
4815
  isDisabled = false,
4813
4816
  customStyle,
4814
4817
  ...props2
4815
4818
  }) {
4816
4819
  const button = /* @__PURE__ */ jsxRuntime.jsxs("button", {
4817
- ..._stylex.props(styles$J.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4818
- ...onClick && {
4819
- onClick: (e) => {
4820
- e.preventDefault();
4821
- onClick(e);
4822
- }
4823
- },
4820
+ ..._stylex.props(styles$K.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4824
4821
  type: "button",
4825
4822
  disabled: isDisabled,
4826
4823
  ...props2,
@@ -4830,9 +4827,9 @@ function Button({
4830
4827
  },
4831
4828
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
4832
4829
  name: icon,
4833
- customStyle: styles$J.icon
4830
+ customStyle: styles$K.icon
4834
4831
  }), label && /* @__PURE__ */ jsxRuntime.jsx("div", {
4835
- ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$J.label),
4832
+ ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$K.label),
4836
4833
  children: label
4837
4834
  })]
4838
4835
  }), isDisabled && /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -4859,7 +4856,7 @@ function Button({
4859
4856
  return button;
4860
4857
  }
4861
4858
  }
4862
- const styles$J = {
4859
+ const styles$K = {
4863
4860
  main: {
4864
4861
  display: "mly3nfvp2",
4865
4862
  flexDirection: "mlydt5ytf",
@@ -5110,7 +5107,7 @@ function Token({
5110
5107
  }) {
5111
5108
  const isInteractive = onClick !== void 0 || asButtonTrigger;
5112
5109
  const token2 = /* @__PURE__ */ jsxRuntime.jsxs("div", {
5113
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$I.nonInteractive, customStyle),
5110
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$J.nonInteractive, customStyle),
5114
5111
  ...dragProps == null ? void 0 : dragProps.attributes,
5115
5112
  ...dragProps == null ? void 0 : dragProps.listeners,
5116
5113
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
@@ -5147,7 +5144,7 @@ function Token({
5147
5144
  })]
5148
5145
  }) : token2;
5149
5146
  }
5150
- const styles$I = {
5147
+ const styles$J = {
5151
5148
  nonInteractive: {
5152
5149
  cursor: "mlyt0e3qv",
5153
5150
  background: "mly1np9qvj",
@@ -5171,7 +5168,7 @@ function TokenGroup({
5171
5168
  }) {
5172
5169
  const count2 = React__namespace.Children.count(children);
5173
5170
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
5174
- ..._stylex.props(styles$H.main, customStyle),
5171
+ ..._stylex.props(styles$I.main, customStyle),
5175
5172
  children: React__namespace.Children.map(children, (child, index2) => /* @__PURE__ */ React__namespace.cloneElement(child, {
5176
5173
  customStyle: {
5177
5174
  ...child.props.customStyle,
@@ -5182,16 +5179,16 @@ function TokenGroup({
5182
5179
  });
5183
5180
  }
5184
5181
  const getChildStyle = (index2, count2) => {
5185
- if (count2 === 1) return styles$H.onlyChild;
5186
- if (index2 === 0) return styles$H.firstChild;
5187
- if (index2 === count2 - 1) return styles$H.lastChild;
5188
- return styles$H.innerChild;
5182
+ if (count2 === 1) return styles$I.onlyChild;
5183
+ if (index2 === 0) return styles$I.firstChild;
5184
+ if (index2 === count2 - 1) return styles$I.lastChild;
5185
+ return styles$I.innerChild;
5189
5186
  };
5190
5187
  const getTokenColor = (child, groupColor) => {
5191
5188
  const childColor = child.props.color;
5192
5189
  return childColor === void 0 ? groupColor : childColor;
5193
5190
  };
5194
- const styles$H = {
5191
+ const styles$I = {
5195
5192
  main: {
5196
5193
  display: "mlyrvj5dj",
5197
5194
  gridAutoFlow: "mly1mt1orb",
@@ -5263,7 +5260,7 @@ function ErrorIcon({
5263
5260
  },
5264
5261
  children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
5265
5262
  name: "warning",
5266
- customStyle: styles$G.errorIcon
5263
+ customStyle: styles$H.errorIcon
5267
5264
  })
5268
5265
  })
5269
5266
  }), /* @__PURE__ */ jsxRuntime.jsx(TooltipPortal, {
@@ -5276,7 +5273,7 @@ function ErrorIcon({
5276
5273
  })]
5277
5274
  });
5278
5275
  }
5279
- const styles$G = {
5276
+ const styles$H = {
5280
5277
  errorIcon: {
5281
5278
  color: "mly1e2nbdu",
5282
5279
  $$css: true
@@ -5321,22 +5318,22 @@ function EditableToken({
5321
5318
  className: "mly78zum5 mly6s0dn4"
5322
5319
  },
5323
5320
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
5324
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$F.focused, !!errorMessage && styles$F.hasError, customStyle),
5321
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$G.focused, !!errorMessage && styles$G.hasError, customStyle),
5325
5322
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
5326
5323
  name: icon,
5327
- customStyle: styles$F.icon
5324
+ customStyle: styles$G.icon
5328
5325
  }), /* @__PURE__ */ jsxRuntime.jsxs("span", {
5329
5326
  ...{
5330
5327
  className: "mlywz0xwf"
5331
5328
  },
5332
5329
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
5333
- ..._stylex.props(fontStyles.body, styles$F.placeholder),
5330
+ ..._stylex.props(fontStyles.body, styles$G.placeholder),
5334
5331
  style: {
5335
5332
  whiteSpaceCollapse: "preserve"
5336
5333
  },
5337
5334
  children: value
5338
5335
  }), /* @__PURE__ */ jsxRuntime.jsx("input", {
5339
- ..._stylex.props(styles$F.input, fontStyles.body),
5336
+ ..._stylex.props(styles$G.input, fontStyles.body),
5340
5337
  ref: inputRef,
5341
5338
  pattern: type === "number" ? "^-?[0-9.]*$" : void 0,
5342
5339
  value,
@@ -5361,7 +5358,7 @@ function EditableToken({
5361
5358
  })]
5362
5359
  });
5363
5360
  }
5364
- const styles$F = {
5361
+ const styles$G = {
5365
5362
  focused: {
5366
5363
  background: "mlyotlr4g",
5367
5364
  backgroundAttachment: null,
@@ -7703,12 +7700,12 @@ function TextInput({
7703
7700
  }
7704
7701
  };
7705
7702
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
7706
- ..._stylex.props(styles$E.main, isFocused && styles$E.focused, sizeVariants[size2], customStyle),
7703
+ ..._stylex.props(styles$F.main, isFocused && styles$F.focused, sizeVariants[size2], customStyle),
7707
7704
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
7708
7705
  name: icon,
7709
7706
  color: "secondary"
7710
7707
  }), /* @__PURE__ */ jsxRuntime.jsx("input", {
7711
- ..._stylex.props(fontStyles.body, styles$E.input),
7708
+ ..._stylex.props(fontStyles.body, styles$F.input),
7712
7709
  value,
7713
7710
  placeholder,
7714
7711
  onChange: handleChange,
@@ -7716,7 +7713,7 @@ function TextInput({
7716
7713
  onBlur: handleBlur,
7717
7714
  onKeyDown
7718
7715
  }), hasClear && /* @__PURE__ */ jsxRuntime.jsx("button", {
7719
- ..._stylex.props(fontStyles.supporting, styles$E.actionButton, value === "" && styles$E.hidden),
7716
+ ..._stylex.props(fontStyles.supporting, styles$F.actionButton, value === "" && styles$F.hidden),
7720
7717
  ref: buttonRef,
7721
7718
  onClick: () => onChange(""),
7722
7719
  tabIndex: 0,
@@ -7724,7 +7721,7 @@ function TextInput({
7724
7721
  })]
7725
7722
  });
7726
7723
  }
7727
- const styles$E = {
7724
+ const styles$F = {
7728
7725
  main: {
7729
7726
  display: "mly78zum5",
7730
7727
  alignItems: "mly6s0dn4",
@@ -7933,7 +7930,7 @@ function SelectorToken({
7933
7930
  onValueChange: handleValueChange,
7934
7931
  required: true,
7935
7932
  children: [/* @__PURE__ */ jsxRuntime.jsxs(Trigger$3, {
7936
- ..._stylex.props(tokenStyles.main, styles$D.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], fontStyles.body, tokenStyles.label, customStyle),
7933
+ ..._stylex.props(tokenStyles.main, styles$E.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], fontStyles.body, tokenStyles.label, customStyle),
7937
7934
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
7938
7935
  name: icon,
7939
7936
  customStyle: tokenStyles.icon
@@ -7962,7 +7959,7 @@ function SelectorToken({
7962
7959
  size: "compact",
7963
7960
  icon: "search",
7964
7961
  hasClear: true,
7965
- customStyle: styles$D.searchInput,
7962
+ customStyle: styles$E.searchInput,
7966
7963
  onKeyDown: (event) => {
7967
7964
  const excludedKeys = ["ArrowUp", "ArrowDown"];
7968
7965
  if (!excludedKeys.includes(event.key)) {
@@ -7995,21 +7992,21 @@ function SelectItem({
7995
7992
  ...props2
7996
7993
  }) {
7997
7994
  return /* @__PURE__ */ jsxRuntime.jsxs(Item$1, {
7998
- ..._stylex.props(fontStyles.body, styles$D.selectItem),
7995
+ ..._stylex.props(fontStyles.body, styles$E.selectItem),
7999
7996
  value,
8000
7997
  ...props2,
8001
7998
  children: [value === selectedValue ? /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8002
7999
  name: "radioChecked",
8003
- customStyle: styles$D.radioChecked
8000
+ customStyle: styles$E.radioChecked
8004
8001
  }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8005
8002
  name: "radioUnchecked",
8006
- customStyle: styles$D.radioUnchecked
8003
+ customStyle: styles$E.radioUnchecked
8007
8004
  }), /* @__PURE__ */ jsxRuntime.jsx(ItemText, {
8008
8005
  children
8009
8006
  })]
8010
8007
  });
8011
8008
  }
8012
- const styles$D = {
8009
+ const styles$E = {
8013
8010
  selectTrigger: {
8014
8011
  whiteSpace: "mlyuxw1ft",
8015
8012
  overflow: "mlyb3r6kr",
@@ -8099,7 +8096,7 @@ function Card({
8099
8096
  customStyle
8100
8097
  }) {
8101
8098
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
8102
- ..._stylex.props(styles$C.container, customStyle),
8099
+ ..._stylex.props(styles$D.container, customStyle),
8103
8100
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
8104
8101
  ...{
8105
8102
  className: "mly1717udv"
@@ -8113,7 +8110,7 @@ function Card({
8113
8110
  })]
8114
8111
  });
8115
8112
  }
8116
- const styles$C = {
8113
+ const styles$D = {
8117
8114
  container: {
8118
8115
  display: "mly78zum5",
8119
8116
  flexDirection: "mlydt5ytf",
@@ -8177,6 +8174,82 @@ const styles$C = {
8177
8174
  $$css: true
8178
8175
  }
8179
8176
  };
8177
+ function CollapsiblePanel({
8178
+ title,
8179
+ children,
8180
+ icon,
8181
+ defaultOpen = true,
8182
+ controls,
8183
+ collapsedControls,
8184
+ isFocused = false
8185
+ }) {
8186
+ const [isExpanded, setIsExpanded] = React.useState(defaultOpen);
8187
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
8188
+ ...{
8189
+ 0: {
8190
+ className: "mlygbc89k mly1sxf85j mly1717udv"
8191
+ },
8192
+ 1: {
8193
+ className: "mly1sxf85j mly1717udv mlybwr872"
8194
+ }
8195
+ }[!!isFocused << 0],
8196
+ children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
8197
+ ...{
8198
+ className: "mlyrvj5dj mly1mt1orb mly52fmzj mlylqzeqv mlyfawy5m mly167g77z mly6s0dn4"
8199
+ },
8200
+ children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
8201
+ ...{
8202
+ className: "mlyrvj5dj mly1mt1orb mlylqzeqv mly6s0dn4 mly167g77z"
8203
+ },
8204
+ children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
8205
+ name: icon,
8206
+ customStyle: styles$C.icon
8207
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
8208
+ ...{
8209
+ className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp mly117nqv4"
8210
+ },
8211
+ children: title
8212
+ })]
8213
+ }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
8214
+ ...{
8215
+ className: "mly78zum5"
8216
+ },
8217
+ children: [isExpanded ? /* @__PURE__ */ jsxRuntime.jsx("div", {
8218
+ ...{
8219
+ className: "mly78zum5 mly6s0dn4 mly1jnr06f"
8220
+ },
8221
+ children: controls
8222
+ }) : /* @__PURE__ */ jsxRuntime.jsx("div", {
8223
+ ...{
8224
+ className: "mly78zum5 mly6s0dn4 mly1jnr06f"
8225
+ },
8226
+ children: collapsedControls
8227
+ }), /* @__PURE__ */ jsxRuntime.jsx(Button, {
8228
+ variant: "flat",
8229
+ size: "compact",
8230
+ onClick: () => setIsExpanded(!isExpanded),
8231
+ icon: isExpanded ? "chevronDown" : "chevronRight",
8232
+ tooltip: isExpanded ? "Collapse" : "Expand"
8233
+ })]
8234
+ })]
8235
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
8236
+ ...{
8237
+ 0: {
8238
+ className: "mly1l4tkcb"
8239
+ },
8240
+ 1: {
8241
+ className: "mly1l4tkcb mly1s85apg"
8242
+ }
8243
+ }[!!!isExpanded << 0],
8244
+ children
8245
+ })]
8246
+ });
8247
+ }
8248
+ const styles$C = {
8249
+ icon: {
8250
+ $$css: true
8251
+ }
8252
+ };
8180
8253
  function CollapsibleListItem({
8181
8254
  label,
8182
8255
  sublabel,
@@ -19516,7 +19589,7 @@ function invalidDate() {
19516
19589
  return this._invalidDate;
19517
19590
  }
19518
19591
  var defaultOrdinal = "%d", defaultDayOfMonthOrdinalParse = /\d{1,2}/;
19519
- function ordinal(number2) {
19592
+ function ordinal$1(number2) {
19520
19593
  return this._ordinal.replace("%d", number2);
19521
19594
  }
19522
19595
  var defaultRelativeTime = {
@@ -22645,7 +22718,7 @@ var proto$1 = Locale.prototype;
22645
22718
  proto$1.calendar = calendar;
22646
22719
  proto$1.longDateFormat = longDateFormat;
22647
22720
  proto$1.invalidDate = invalidDate;
22648
- proto$1.ordinal = ordinal;
22721
+ proto$1.ordinal = ordinal$1;
22649
22722
  proto$1.preparse = preParsePostFormat;
22650
22723
  proto$1.postformat = preParsePostFormat;
22651
22724
  proto$1.relativeTime = relativeTime;
@@ -23618,25 +23691,113 @@ function SelectList({
23618
23691
  })
23619
23692
  });
23620
23693
  }
23694
+ const formats = {
23695
+ second: "YYYY-MM-DD HH:mm:ss",
23696
+ minute: "YYYY-MM-DD HH:mm",
23697
+ hour: "YYYY-MM-DD HH:00",
23698
+ day: "YYYY-MM-DD",
23699
+ week: "YYYY-MM-DD-[WK]",
23700
+ month: "YYYY-MM",
23701
+ quarter: "YYYY-[Q]Q",
23702
+ year: "YYYY"
23703
+ };
23704
+ const regexps = {
23705
+ second: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
23706
+ minute: /\d\d\d\d-\d\d-\d\d \d\d:\d\d/,
23707
+ hour: /\d\d\d\d-\d\d-\d\d \d\d:00/,
23708
+ day: /\d\d\d\d-\d\d-\d\d/,
23709
+ week: /\d\d\d\d-\d\d-\d\d-WK/,
23710
+ month: /\d\d\d\d-\d\d/,
23711
+ quarter: /\d\d\d\d-Q\d/,
23712
+ year: /\d\d\d\d/
23713
+ };
23714
+ const DateInput = ({
23715
+ value,
23716
+ setValue,
23717
+ placeholder,
23718
+ autoFocus,
23719
+ units,
23720
+ onFocus,
23721
+ onBlur,
23722
+ isActive,
23723
+ customStyle,
23724
+ forwardRef
23725
+ }) => {
23726
+ const format2 = formats[units];
23727
+ const [tempValue, setTempValue] = React.useState(hooks.utc(value).format(format2));
23728
+ React.useEffect(() => {
23729
+ setTempValue(hooks.utc(value).format(format2));
23730
+ }, [value, format2]);
23731
+ return /* @__PURE__ */ jsxRuntime.jsx("input", {
23732
+ ..._stylex.props(customStyle, isActive ? styles$y.active : null),
23733
+ type: "text",
23734
+ placeholder: placeholder || format2,
23735
+ value: tempValue,
23736
+ onFocus,
23737
+ onBlur,
23738
+ onChange: (event) => {
23739
+ const raw2 = event.target.value;
23740
+ setTempValue(raw2);
23741
+ const regex = regexps[units];
23742
+ if (raw2.match(regex)) {
23743
+ const m = hooks.utc(raw2, format2);
23744
+ if (m.isValid()) {
23745
+ setValue(m.toDate());
23746
+ }
23747
+ }
23748
+ },
23749
+ autoFocus,
23750
+ ref: forwardRef
23751
+ });
23752
+ };
23753
+ function guessUnits(moment2, isDateTime) {
23754
+ if (moment2.moment === "literal") {
23755
+ const {
23756
+ literal
23757
+ } = moment2;
23758
+ for (const unit in regexps) {
23759
+ const temporalUnit = unit;
23760
+ if (literal.match(regexps[temporalUnit])) {
23761
+ return temporalUnit;
23762
+ }
23763
+ }
23764
+ }
23765
+ return isDateTime ? "second" : "day";
23766
+ }
23767
+ const styles$y = {
23768
+ active: {
23769
+ backgroundColor: "mly1vzefiq",
23770
+ $$css: true
23771
+ }
23772
+ };
23621
23773
  function monthName(month) {
23622
23774
  return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][month];
23623
23775
  }
23776
+ const ordinal = Object.keys(formats);
23624
23777
  function DatePicker({
23625
23778
  value,
23626
23779
  setValue,
23627
23780
  units,
23628
23781
  maxLevel,
23629
- customStyle
23782
+ customStyle,
23783
+ forwardRef
23630
23784
  }) {
23631
23785
  const [date, setDate] = React.useState(value);
23632
23786
  const calendar2 = getCalendar(date);
23633
23787
  const [pickLevel, setPickLevel] = React.useState(units);
23634
- const yearBucket = Math.floor(hooks(date).year() / 10) * 10;
23788
+ const yearBucket = Math.floor(hooks.utc(date).year() / 10) * 10;
23789
+ React.useEffect(() => {
23790
+ const unitOrd = ordinal.findIndex((unit) => unit === units);
23791
+ const pickOrd = ordinal.findIndex((unit) => unit === pickLevel);
23792
+ if (pickOrd < unitOrd) {
23793
+ setPickLevel(units);
23794
+ }
23795
+ }, [units, pickLevel]);
23635
23796
  React.useEffect(() => {
23636
23797
  setDate(value);
23637
23798
  }, [value]);
23638
23799
  const setYear = (year) => {
23639
- const newDate = hooks(date).year(year).toDate();
23800
+ const newDate = hooks.utc(date).year(year).toDate();
23640
23801
  setDate(newDate);
23641
23802
  setValue(newDate);
23642
23803
  };
@@ -23660,12 +23821,12 @@ function DatePicker({
23660
23821
  1: {
23661
23822
  className: "mly1247r65 mlyfvyar9 mlymcgfsh mly36usyh mly78zum5 mly6s0dn4 mlyl56j7k mly8fuzfi mly1v5ugh9 mly1fcty0u mly1ypdohk mly6mezaz mly1sxf85j mlyt89l8w mly1fxp9ov mly6wxqrg mly10bk7bj"
23662
23823
  }
23663
- }[!!(hooks(date).year() === yearBucket + offset2) << 0],
23824
+ }[!!(hooks.utc(date).year() === yearBucket + offset2) << 0],
23664
23825
  children: yearBucket + offset2
23665
23826
  });
23666
23827
  };
23667
23828
  const setMonth2 = (month) => {
23668
- const newDate = hooks(date).month(month).toDate();
23829
+ const newDate = hooks.utc(date).month(month).toDate();
23669
23830
  setDate(newDate);
23670
23831
  setValue(newDate);
23671
23832
  };
@@ -23678,13 +23839,13 @@ function DatePicker({
23678
23839
  setValue(dateOfFirstDayOfWeek);
23679
23840
  };
23680
23841
  const setQuarter = (quarter) => {
23681
- const newDate = hooks(date).quarter(quarter + 1).toDate();
23842
+ const newDate = hooks.utc(date).quarter(quarter + 1).toDate();
23682
23843
  setDate(newDate);
23683
23844
  setValue(newDate);
23684
23845
  };
23685
23846
  const monthButton = (month) => {
23686
23847
  const click = () => setMonth2(month);
23687
- const isSelected = hooks(date).month() === month && hooks(date).year() === hooks(value).year();
23848
+ const isSelected = hooks.utc(date).month() === month && hooks.utc(date).year() === hooks.utc(value).year();
23688
23849
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
23689
23850
  onClick: click,
23690
23851
  ...{
@@ -23700,7 +23861,7 @@ function DatePicker({
23700
23861
  };
23701
23862
  const quarterButton = (quarter) => {
23702
23863
  const click = () => setQuarter(quarter);
23703
- const isSelected = hooks(date).quarter() - 1 === quarter && hooks(date).year() === hooks(value).year();
23864
+ const isSelected = hooks.utc(date).quarter() - 1 === quarter && hooks.utc(date).year() === hooks.utc(value).year();
23704
23865
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
23705
23866
  onClick: click,
23706
23867
  ...{
@@ -23715,7 +23876,8 @@ function DatePicker({
23715
23876
  });
23716
23877
  };
23717
23878
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
23718
- ..._stylex.props(styles$y.outer, customStyle),
23879
+ ..._stylex.props(styles$x.outer, customStyle),
23880
+ ref: forwardRef,
23719
23881
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
23720
23882
  ...{
23721
23883
  className: "mly78zum5 mly1q0g3np mly1qughib mly1nejdyq mlyu06os2"
@@ -23730,13 +23892,13 @@ function DatePicker({
23730
23892
  icon: "chevronLeft",
23731
23893
  onClick: () => {
23732
23894
  if (pickLevel === "day" || pickLevel === "week") {
23733
- setDate(hooks(date).subtract(1, "month").toDate());
23895
+ setDate(hooks.utc(date).subtract(1, "month").toDate());
23734
23896
  } else if (pickLevel === "month" || pickLevel === "quarter") {
23735
- setDate(hooks(date).subtract(1, "year").toDate());
23897
+ setDate(hooks.utc(date).subtract(1, "year").toDate());
23736
23898
  } else if (pickLevel === "year") {
23737
- setDate(hooks(date).subtract(10, "years").toDate());
23899
+ setDate(hooks.utc(date).subtract(10, "years").toDate());
23738
23900
  } else {
23739
- setDay(hooks(date).subtract(1, "days").toDate());
23901
+ setDay(hooks.utc(date).subtract(1, "days").toDate());
23740
23902
  }
23741
23903
  }
23742
23904
  })
@@ -23755,10 +23917,10 @@ function DatePicker({
23755
23917
  setPickLevel(maxLevel);
23756
23918
  }
23757
23919
  },
23758
- children: [(pickLevel === "day" || pickLevel === "week") && hooks(date).format("MMMM YYYY"), (pickLevel === "month" || pickLevel === "quarter") && hooks(date).format("YYYY"), pickLevel === "year" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
23920
+ children: [(pickLevel === "day" || pickLevel === "week") && hooks.utc(date).format("MMMM YYYY"), (pickLevel === "month" || pickLevel === "quarter") && hooks.utc(date).format("YYYY"), pickLevel === "year" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
23759
23921
  children: [yearBucket, "-", yearBucket + 9]
23760
23922
  }), (pickLevel === "hour" || pickLevel === "minute" || pickLevel === "second") && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
23761
- children: hooks(date).format("MMMM D, YYYY")
23923
+ children: hooks.utc(date).format("MMMM D, YYYY")
23762
23924
  })]
23763
23925
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
23764
23926
  ...{
@@ -23770,13 +23932,13 @@ function DatePicker({
23770
23932
  icon: "chevronRight",
23771
23933
  onClick: () => {
23772
23934
  if (pickLevel === "day" || pickLevel === "week") {
23773
- setDate(hooks(date).add(1, "month").toDate());
23935
+ setDate(hooks.utc(date).add(1, "month").toDate());
23774
23936
  } else if (pickLevel === "month" || pickLevel === "quarter") {
23775
- setDate(hooks(date).add(1, "year").toDate());
23937
+ setDate(hooks.utc(date).add(1, "year").toDate());
23776
23938
  } else if (pickLevel === "year") {
23777
- setDate(hooks(date).add(10, "years").toDate());
23939
+ setDate(hooks.utc(date).add(10, "years").toDate());
23778
23940
  } else {
23779
- setDay(hooks(date).add(1, "days").toDate());
23941
+ setDay(hooks.utc(date).add(1, "days").toDate());
23780
23942
  }
23781
23943
  }
23782
23944
  })
@@ -23983,25 +24145,25 @@ function DatePicker({
23983
24145
  },
23984
24146
  children: [/* @__PURE__ */ jsxRuntime.jsx(NumberInput, {
23985
24147
  label: "Hours",
23986
- value: parseInt(hooks(date).format("hh")),
24148
+ value: parseInt(hooks.utc(date).format("hh")),
23987
24149
  setValue: (hour12) => {
23988
- const amPm = hooks(date).hour() >= 12 ? "PM" : "AM";
23989
- const newHour24 = parseInt(hooks(`${hour12} ${amPm}`, ["hh A"]).format("H"));
23990
- setValue(hooks(date).hour(newHour24).toDate());
24150
+ const amPm = hooks.utc(date).hour() >= 12 ? "PM" : "AM";
24151
+ const newHour24 = parseInt(hooks.utc(`${hour12} ${amPm}`, ["hh A"]).format("H"));
24152
+ setValue(hooks.utc(date).hour(newHour24).toDate());
23991
24153
  },
23992
24154
  width: "40px"
23993
24155
  }), (units === "minute" || units === "second") && /* @__PURE__ */ jsxRuntime.jsx(NumberInput, {
23994
24156
  label: "Minutes",
23995
- value: hooks(date).minutes(),
24157
+ value: hooks.utc(date).minutes(),
23996
24158
  setValue: (minute) => {
23997
- setValue(hooks(date).minute(minute).toDate());
24159
+ setValue(hooks.utc(date).minute(minute).toDate());
23998
24160
  },
23999
24161
  width: "40px"
24000
24162
  }), units === "second" && /* @__PURE__ */ jsxRuntime.jsx(NumberInput, {
24001
24163
  label: "Seconds",
24002
- value: hooks(date).seconds(),
24164
+ value: hooks.utc(date).seconds(),
24003
24165
  setValue: (second) => {
24004
- setValue(hooks(date).second(second).toDate());
24166
+ setValue(hooks.utc(date).second(second).toDate());
24005
24167
  },
24006
24168
  width: "40px"
24007
24169
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -24011,11 +24173,11 @@ function DatePicker({
24011
24173
  flexDirection: "column"
24012
24174
  },
24013
24175
  children: /* @__PURE__ */ jsxRuntime.jsx(SelectDropdown, {
24014
- value: hooks(date).hour() >= 12 ? "PM" : "AM",
24176
+ value: hooks.utc(date).hour() >= 12 ? "PM" : "AM",
24015
24177
  onChange: (amPm) => {
24016
- const hour12 = parseInt(hooks(date).format("h"));
24017
- const newHour24 = parseInt(hooks(`${hour12} ${amPm}`, ["hh A"]).format("H"));
24018
- setValue(hooks(date).hour(newHour24).toDate());
24178
+ const hour12 = parseInt(hooks.utc(date).format("h"));
24179
+ const newHour24 = parseInt(hooks.utc(`${hour12} ${amPm}`, ["hh A"]).format("H"));
24180
+ setValue(hooks.utc(date).hour(newHour24).toDate());
24019
24181
  },
24020
24182
  options: [{
24021
24183
  value: "AM",
@@ -24030,7 +24192,7 @@ function DatePicker({
24030
24192
  })]
24031
24193
  });
24032
24194
  }
24033
- const styles$y = {
24195
+ const styles$x = {
24034
24196
  outer: {
24035
24197
  userSelect: "mly87ps6o",
24036
24198
  fontSize: "mlymhiqyu",
@@ -24039,7 +24201,7 @@ const styles$y = {
24039
24201
  }
24040
24202
  };
24041
24203
  function getCalendar(date) {
24042
- const firstDayOfMonth = hooks(date).date(1);
24204
+ const firstDayOfMonth = hooks.utc(date).date(1);
24043
24205
  const dow = firstDayOfMonth.day();
24044
24206
  const daysInMonth2 = firstDayOfMonth.daysInMonth();
24045
24207
  const daysInPreviousMonth = firstDayOfMonth.clone().subtract(1, "day").daysInMonth();
@@ -24116,7 +24278,7 @@ function Banner({
24116
24278
  className: "mly1q4ynmn mlyh8yej3 mly5yr21d mly78zum5 mlydt5ytf mly1kmqopl mly16zck5j"
24117
24279
  },
24118
24280
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
24119
- ..._stylex.props(styles$x.header, variantColors[variant], children ? styles$x.headerWithContent : null),
24281
+ ..._stylex.props(styles$w.header, variantColors[variant], children ? styles$w.headerWithContent : null),
24120
24282
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
24121
24283
  ...{
24122
24284
  className: "mly1qx5ct2 mly78zum5 mlyl56j7k mly6s0dn4"
@@ -24129,22 +24291,22 @@ function Banner({
24129
24291
  className: "mly78zum5 mlydt5ytf mlyb3r6kr"
24130
24292
  },
24131
24293
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
24132
- ..._stylex.props(styles$x.title, fontStyles.emphasized),
24294
+ ..._stylex.props(styles$w.title, fontStyles.emphasized),
24133
24295
  children: title
24134
24296
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
24135
- ..._stylex.props(styles$x.description, fontStyles.supporting),
24297
+ ..._stylex.props(styles$w.description, fontStyles.supporting),
24136
24298
  children: description
24137
24299
  })]
24138
24300
  })]
24139
24301
  }), children && /* @__PURE__ */ jsxRuntime.jsx("div", {
24140
- ..._stylex.props(styles$x.content, fontStyles.body),
24302
+ ..._stylex.props(styles$w.content, fontStyles.body),
24141
24303
  children: /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
24142
24304
  children
24143
24305
  })
24144
24306
  })]
24145
24307
  });
24146
24308
  }
24147
- const styles$x = {
24309
+ const styles$w = {
24148
24310
  header: {
24149
24311
  borderRadius: "mly1q4ynmn",
24150
24312
  borderStartStartRadius: null,
@@ -24286,14 +24448,14 @@ function AccordionList({
24286
24448
  onExpandedItemChange: handleExpandedItemChange
24287
24449
  },
24288
24450
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
24289
- ..._stylex.props(styles$w.main, customStyle),
24451
+ ..._stylex.props(styles$v.main, customStyle),
24290
24452
  children: React__namespace.Children.map(children, (child) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
24291
24453
  children: [child, /* @__PURE__ */ jsxRuntime.jsx(Divider, {})]
24292
24454
  }))
24293
24455
  })
24294
24456
  });
24295
24457
  }
24296
- const styles$w = {
24458
+ const styles$v = {
24297
24459
  main: {
24298
24460
  display: "mly78zum5",
24299
24461
  flexDirection: "mlydt5ytf",
@@ -24330,10 +24492,10 @@ function AccordionListItem({
24330
24492
  className: "mly78zum5 mlydt5ytf mlyb3r6kr mly1iyjqo2"
24331
24493
  },
24332
24494
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
24333
- ..._stylex.props(fontStyles.body, styles$v.label),
24495
+ ..._stylex.props(fontStyles.body, styles$u.label),
24334
24496
  children: label
24335
24497
  }), sublabel && /* @__PURE__ */ jsxRuntime.jsx("span", {
24336
- ..._stylex.props(fontStyles.supporting, styles$v.sublabel),
24498
+ ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
24337
24499
  children: sublabel
24338
24500
  })]
24339
24501
  }), badge && badge, endIcon && endIcon]
@@ -24345,7 +24507,7 @@ function AccordionListItem({
24345
24507
  })]
24346
24508
  });
24347
24509
  }
24348
- const styles$v = {
24510
+ const styles$u = {
24349
24511
  label: {
24350
24512
  flexGrow: "mly1iyjqo2",
24351
24513
  fontWeight: "mly1xlr1w8",
@@ -25136,40 +25298,6 @@ var MenuArrow = React__namespace.forwardRef(
25136
25298
  MenuArrow.displayName = ARROW_NAME$1;
25137
25299
  var SUB_NAME = "MenuSub";
25138
25300
  var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
25139
- var MenuSub = (props2) => {
25140
- const { __scopeMenu, children, open = false, onOpenChange } = props2;
25141
- const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
25142
- const popperScope = usePopperScope(__scopeMenu);
25143
- const [trigger, setTrigger] = React__namespace.useState(null);
25144
- const [content, setContent] = React__namespace.useState(null);
25145
- const handleOpenChange = useCallbackRef$1(onOpenChange);
25146
- React__namespace.useEffect(() => {
25147
- if (parentMenuContext.open === false) handleOpenChange(false);
25148
- return () => handleOpenChange(false);
25149
- }, [parentMenuContext.open, handleOpenChange]);
25150
- return /* @__PURE__ */ jsxRuntime.jsx(Root2$4, { ...popperScope, children: /* @__PURE__ */ jsxRuntime.jsx(
25151
- MenuProvider,
25152
- {
25153
- scope: __scopeMenu,
25154
- open,
25155
- onOpenChange: handleOpenChange,
25156
- content,
25157
- onContentChange: setContent,
25158
- children: /* @__PURE__ */ jsxRuntime.jsx(
25159
- MenuSubProvider,
25160
- {
25161
- scope: __scopeMenu,
25162
- contentId: useId(),
25163
- triggerId: useId(),
25164
- trigger,
25165
- onTriggerChange: setTrigger,
25166
- children
25167
- }
25168
- )
25169
- }
25170
- ) });
25171
- };
25172
- MenuSub.displayName = SUB_NAME;
25173
25301
  var SUB_TRIGGER_NAME$1 = "MenuSubTrigger";
25174
25302
  var MenuSubTrigger = React__namespace.forwardRef(
25175
25303
  (props2, forwardedRef) => {
@@ -25390,7 +25518,6 @@ var RadioItem = MenuRadioItem;
25390
25518
  var ItemIndicator = MenuItemIndicator;
25391
25519
  var Separator = MenuSeparator;
25392
25520
  var Arrow2 = MenuArrow;
25393
- var Sub = MenuSub;
25394
25521
  var SubTrigger = MenuSubTrigger;
25395
25522
  var SubContent = MenuSubContent;
25396
25523
  var DROPDOWN_MENU_NAME = "DropdownMenu";
@@ -25529,14 +25656,14 @@ var DropdownMenuGroup = React__namespace.forwardRef(
25529
25656
  );
25530
25657
  DropdownMenuGroup.displayName = GROUP_NAME;
25531
25658
  var LABEL_NAME = "DropdownMenuLabel";
25532
- var DropdownMenuLabel$1 = React__namespace.forwardRef(
25659
+ var DropdownMenuLabel = React__namespace.forwardRef(
25533
25660
  (props2, forwardedRef) => {
25534
25661
  const { __scopeDropdownMenu, ...labelProps } = props2;
25535
25662
  const menuScope = useMenuScope(__scopeDropdownMenu);
25536
25663
  return /* @__PURE__ */ jsxRuntime.jsx(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
25537
25664
  }
25538
25665
  );
25539
- DropdownMenuLabel$1.displayName = LABEL_NAME;
25666
+ DropdownMenuLabel.displayName = LABEL_NAME;
25540
25667
  var ITEM_NAME = "DropdownMenuItem";
25541
25668
  var DropdownMenuItem$1 = React__namespace.forwardRef(
25542
25669
  (props2, forwardedRef) => {
@@ -25590,16 +25717,6 @@ var DropdownMenuArrow = React__namespace.forwardRef(
25590
25717
  }
25591
25718
  );
25592
25719
  DropdownMenuArrow.displayName = ARROW_NAME;
25593
- var DropdownMenuSub = (props2) => {
25594
- const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props2;
25595
- const menuScope = useMenuScope(__scopeDropdownMenu);
25596
- const [open = false, setOpen] = useControllableState({
25597
- prop: openProp,
25598
- defaultProp: defaultOpen,
25599
- onChange: onOpenChange
25600
- });
25601
- return /* @__PURE__ */ jsxRuntime.jsx(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
25602
- };
25603
25720
  var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
25604
25721
  var DropdownMenuSubTrigger = React__namespace.forwardRef((props2, forwardedRef) => {
25605
25722
  const { __scopeDropdownMenu, ...subTriggerProps } = props2;
@@ -25636,11 +25753,7 @@ var Root2$1 = DropdownMenu$1;
25636
25753
  var Trigger$1 = DropdownMenuTrigger;
25637
25754
  var Portal2 = DropdownMenuPortal;
25638
25755
  var Content2 = DropdownMenuContent;
25639
- var Label2 = DropdownMenuLabel$1;
25640
25756
  var Item2 = DropdownMenuItem$1;
25641
- var Sub2 = DropdownMenuSub;
25642
- var SubTrigger2 = DropdownMenuSubTrigger;
25643
- var SubContent2 = DropdownMenuSubContent;
25644
25757
  function DropdownMenu({
25645
25758
  trigger,
25646
25759
  tooltip,
@@ -25679,7 +25792,7 @@ function DropdownMenu({
25679
25792
  children: trigger
25680
25793
  }), /* @__PURE__ */ jsxRuntime.jsx(Portal2, {
25681
25794
  children: /* @__PURE__ */ jsxRuntime.jsx(Content2, {
25682
- ..._stylex.props(fontStyles.body, styles$u.content),
25795
+ ..._stylex.props(fontStyles.body, styles$t.content),
25683
25796
  side: "bottom",
25684
25797
  align: "start",
25685
25798
  sideOffset: 4,
@@ -25706,79 +25819,22 @@ function DropdownMenuItem({
25706
25819
  disabled,
25707
25820
  children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
25708
25821
  name: icon,
25709
- customStyle: styles$u.icon
25822
+ customStyle: styles$t.icon
25710
25823
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
25711
25824
  ...{
25712
25825
  className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25713
25826
  },
25714
25827
  children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
25715
- ..._stylex.props(fontStyles.body, styles$u.label),
25828
+ ..._stylex.props(fontStyles.body, styles$t.label),
25716
25829
  children: label
25717
25830
  }), sublabel && /* @__PURE__ */ jsxRuntime.jsx("span", {
25718
- ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
25831
+ ..._stylex.props(fontStyles.supporting, styles$t.sublabel),
25719
25832
  children: sublabel
25720
25833
  })]
25721
25834
  })]
25722
25835
  });
25723
25836
  }
25724
- function DropdownSubMenuItem({
25725
- icon,
25726
- label,
25727
- sublabel,
25728
- disabled,
25729
- children,
25730
- open,
25731
- onOpenChange
25732
- }) {
25733
- const isControlled = open !== void 0 && onOpenChange !== void 0;
25734
- return /* @__PURE__ */ jsxRuntime.jsxs(Sub2, {
25735
- ...isControlled && {
25736
- open
25737
- },
25738
- children: [/* @__PURE__ */ jsxRuntime.jsxs(SubTrigger2, {
25739
- ...{
25740
- className: "mly78zum5 mly6s0dn4 mlye8ttls mly167g77z mly1kogg8i mly1ypdohk mly1a2a7pz mly1bw6wve mly5ezrf1 mly15rdse5 mly1z060rf mly5deeek mly1jacekv mly7ouyw2 mly7h4d18"
25741
- },
25742
- disabled,
25743
- ...isControlled && {
25744
- onClick: () => onOpenChange(!open)
25745
- },
25746
- children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
25747
- name: icon,
25748
- customStyle: styles$u.icon
25749
- }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
25750
- ...{
25751
- className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25752
- },
25753
- children: [/* @__PURE__ */ jsxRuntime.jsx("span", {
25754
- ..._stylex.props(fontStyles.body, styles$u.label),
25755
- children: label
25756
- }), sublabel && /* @__PURE__ */ jsxRuntime.jsx("span", {
25757
- ..._stylex.props(fontStyles.supporting, styles$u.sublabel),
25758
- children: sublabel
25759
- })]
25760
- }), !isControlled && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
25761
- name: "chevronRight",
25762
- customStyle: styles$u.icon
25763
- })]
25764
- }), /* @__PURE__ */ jsxRuntime.jsx(SubContent2, {
25765
- ...{
25766
- className: "mly78zum5 mlydt5ytf mly1q4ynmn mlyotlr4g mly17fq3gk mlyfawy5m"
25767
- },
25768
- sideOffset: 5,
25769
- children: React__namespace.Children.map(children, (child) => child)
25770
- })]
25771
- });
25772
- }
25773
- function DropdownMenuLabel({
25774
- label
25775
- }) {
25776
- return /* @__PURE__ */ jsxRuntime.jsx(Label2, {
25777
- ..._stylex.props(fontStyles.supporting, styles$u.menuLabel),
25778
- children: label
25779
- });
25780
- }
25781
- const styles$u = {
25837
+ const styles$t = {
25782
25838
  content: {
25783
25839
  display: "mly78zum5",
25784
25840
  flexDirection: "mlydt5ytf",
@@ -25814,19 +25870,6 @@ const styles$u = {
25814
25870
  paddingBottom: null,
25815
25871
  $$css: true
25816
25872
  },
25817
- menuLabel: {
25818
- padding: "mlydqdrvq",
25819
- paddingInline: null,
25820
- paddingStart: null,
25821
- paddingLeft: null,
25822
- paddingEnd: null,
25823
- paddingRight: null,
25824
- paddingBlock: null,
25825
- paddingTop: null,
25826
- paddingBottom: null,
25827
- color: "mly9dwj6z",
25828
- $$css: true
25829
- },
25830
25873
  icon: {
25831
25874
  color: "mly1mguc6l",
25832
25875
  $$css: true
@@ -25849,7 +25892,9 @@ function QueryActionBar({
25849
25892
  const {
25850
25893
  rootQuery,
25851
25894
  setQuery,
25852
- source
25895
+ source,
25896
+ onCurrentNestQueryPanelChange,
25897
+ onCurrentNestViewChange
25853
25898
  } = React.useContext(QueryEditorContext);
25854
25899
  const {
25855
25900
  onCollapse
@@ -25861,6 +25906,10 @@ function QueryActionBar({
25861
25906
  runQuery(source, rootQuery.build());
25862
25907
  }
25863
25908
  };
25909
+ const focusMainQueryPanel = () => {
25910
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
25911
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(null);
25912
+ };
25864
25913
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
25865
25914
  ...{
25866
25915
  className: "mly78zum5 mly1qughib mly6s0dn4 mlye8ttls"
@@ -25872,7 +25921,7 @@ function QueryActionBar({
25872
25921
  children: [/* @__PURE__ */ jsxRuntime.jsx(Icon, {
25873
25922
  name: "filterSliders"
25874
25923
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
25875
- ..._stylex.props(fontStyles.largeBody, styles$t.title),
25924
+ ..._stylex.props(fontStyles.largeBody, styles$s.title),
25876
25925
  children: "Query"
25877
25926
  })]
25878
25927
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -25880,7 +25929,10 @@ function QueryActionBar({
25880
25929
  className: "mly78zum5 mly167g77z"
25881
25930
  },
25882
25931
  children: [/* @__PURE__ */ jsxRuntime.jsx(Button, {
25883
- onClick: () => setQuery == null ? void 0 : setQuery(void 0),
25932
+ onClick: () => {
25933
+ focusMainQueryPanel();
25934
+ setQuery == null ? void 0 : setQuery(void 0);
25935
+ },
25884
25936
  isDisabled: !rootQuery || (rootQuery == null ? void 0 : rootQuery.isEmpty()),
25885
25937
  label: "Clear",
25886
25938
  variant: "flat",
@@ -25914,13 +25966,13 @@ function QueryActionBar({
25914
25966
  })]
25915
25967
  });
25916
25968
  }
25917
- const styles$t = {
25969
+ const styles$s = {
25918
25970
  title: {
25919
25971
  fontWeight: "mly1xlr1w8",
25920
25972
  $$css: true
25921
25973
  }
25922
25974
  };
25923
- const styles$s = {
25975
+ const styles$r = {
25924
25976
  labelWithIcon: {
25925
25977
  display: "mly78zum5",
25926
25978
  alignItems: "mly6s0dn4",
@@ -30009,6 +30061,12 @@ function FieldToken({
30009
30061
  hoverActionsVisible,
30010
30062
  ...props2
30011
30063
  }) {
30064
+ let label = field.name;
30065
+ if (field.kind === "dimension" && (field.type.kind === "timestamp_type" || field.type.kind === "date_type")) {
30066
+ if (field.type.timeframe) {
30067
+ label += `.${field.type.timeframe}`;
30068
+ }
30069
+ }
30012
30070
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
30013
30071
  ...{
30014
30072
  0: {
@@ -30019,7 +30077,7 @@ function FieldToken({
30019
30077
  }
30020
30078
  }[!!hoverActionsVisible << 0],
30021
30079
  children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
30022
- label: field.name,
30080
+ label,
30023
30081
  color: fieldKindToColor(field.kind),
30024
30082
  icon: fieldToIcon(field),
30025
30083
  ...props2
@@ -30039,32 +30097,32 @@ function BadgeForField({
30039
30097
  label: "view",
30040
30098
  icon: "view_filled",
30041
30099
  color: "purple",
30042
- customStyle: styles$r.noBackground
30100
+ customStyle: styles$q.noBackground
30043
30101
  });
30044
30102
  } else if (field.kind === "dimension") {
30045
30103
  return /* @__PURE__ */ jsxRuntime.jsx(Badge, {
30046
30104
  label: "dimension",
30047
30105
  icon: fieldToIcon(field),
30048
30106
  color: "cyan",
30049
- customStyle: styles$r.noBackground
30107
+ customStyle: styles$q.noBackground
30050
30108
  });
30051
30109
  } else if (field.kind === "measure") {
30052
30110
  return /* @__PURE__ */ jsxRuntime.jsx(Badge, {
30053
30111
  label: "measure",
30054
30112
  icon: fieldToIcon(field),
30055
30113
  color: "green",
30056
- customStyle: styles$r.noBackground
30114
+ customStyle: styles$q.noBackground
30057
30115
  });
30058
30116
  } else if (field.kind === "join") {
30059
30117
  return /* @__PURE__ */ jsxRuntime.jsx(Badge, {
30060
30118
  label: "join",
30061
30119
  icon: fieldToIcon(field),
30062
30120
  color: "gray",
30063
- customStyle: styles$r.noBackground
30121
+ customStyle: styles$q.noBackground
30064
30122
  });
30065
30123
  }
30066
30124
  }
30067
- const styles$r = {
30125
+ const styles$q = {
30068
30126
  noBackground: {
30069
30127
  backgroundColor: "mlyjbqb8w",
30070
30128
  $$css: true
@@ -30093,7 +30151,7 @@ function Visualization$1({
30093
30151
  onClick: () => setRenderer(viz)
30094
30152
  }));
30095
30153
  const tokens2 = [/* @__PURE__ */ jsxRuntime.jsx(SelectorToken, {
30096
- customStyle: styles$q.first,
30154
+ customStyle: styles$p.first,
30097
30155
  icon: `viz_${currentRenderer}`,
30098
30156
  value: currentRenderer,
30099
30157
  items: vizes,
@@ -30103,7 +30161,7 @@ function Visualization$1({
30103
30161
  children: tokens2
30104
30162
  });
30105
30163
  }
30106
- const styles$q = {
30164
+ const styles$p = {
30107
30165
  first: {
30108
30166
  flexGrow: "mly1iyjqo2",
30109
30167
  justifyContent: "mlylqzeqv",
@@ -30132,33 +30190,31 @@ function ViewAttributeTable({
30132
30190
  }) {
30133
30191
  const dimensions = viewInfo.schema.fields.filter((f2) => f2.kind === "dimension");
30134
30192
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
30135
- ..._stylex.props(styles$p.attributeTableContainer, style),
30136
- children: /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
30137
- children: /* @__PURE__ */ jsxRuntime.jsx("table", {
30138
- ...{
30139
- className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
30140
- },
30141
- children: /* @__PURE__ */ jsxRuntime.jsxs("tbody", {
30142
- children: [/* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTableRow, {
30143
- attribute: "chart type",
30144
- children: /* @__PURE__ */ jsxRuntime.jsx("div", {
30145
- ...{
30146
- className: "mly1rg5ohu"
30147
- },
30148
- children: /* @__PURE__ */ jsxRuntime.jsx(Visualization, {
30149
- annotations: viewInfo.annotations || []
30150
- })
30193
+ ..._stylex.props(styles$o.attributeTableContainer, style),
30194
+ children: /* @__PURE__ */ jsxRuntime.jsx("table", {
30195
+ ...{
30196
+ className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
30197
+ },
30198
+ children: /* @__PURE__ */ jsxRuntime.jsxs("tbody", {
30199
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTableRow, {
30200
+ attribute: "chart type",
30201
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", {
30202
+ ...{
30203
+ className: "mly1rg5ohu"
30204
+ },
30205
+ children: /* @__PURE__ */ jsxRuntime.jsx(Visualization, {
30206
+ annotations: viewInfo.annotations || []
30151
30207
  })
30152
- }), /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTableRow, {
30153
- attribute: "output",
30154
- children: dimensions.map((f2) => /* @__PURE__ */ jsxRuntime.jsx("span", {
30155
- children: /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
30156
- field: f2,
30157
- size: isCompact ? "compact" : "default"
30158
- })
30159
- }, `${f2.kind}::${f2.name}`))
30160
- })]
30161
- })
30208
+ })
30209
+ }), /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTableRow, {
30210
+ attribute: "output",
30211
+ children: dimensions.map((f2) => /* @__PURE__ */ jsxRuntime.jsx("span", {
30212
+ children: /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
30213
+ field: f2,
30214
+ size: isCompact ? "compact" : "default"
30215
+ })
30216
+ }, `${f2.kind}::${f2.name}`))
30217
+ })]
30162
30218
  })
30163
30219
  })
30164
30220
  });
@@ -30172,9 +30228,9 @@ function ViewAttributeTableRow({
30172
30228
  className: "mlydpxx8g"
30173
30229
  },
30174
30230
  children: [/* @__PURE__ */ jsxRuntime.jsx("td", {
30175
- ..._stylex.props(styles$p.attributeTableKeyCell, fontStyles.supporting),
30231
+ ..._stylex.props(styles$o.attributeTableKeyCell, fontStyles.supporting),
30176
30232
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
30177
- ..._stylex.props(styles$p.attributeTableKeyCellContent, fontStyles.supporting),
30233
+ ..._stylex.props(styles$o.attributeTableKeyCellContent, fontStyles.supporting),
30178
30234
  children: attribute
30179
30235
  })
30180
30236
  }), /* @__PURE__ */ jsxRuntime.jsx("td", {
@@ -30185,7 +30241,7 @@ function ViewAttributeTableRow({
30185
30241
  })]
30186
30242
  });
30187
30243
  }
30188
- const styles$p = {
30244
+ const styles$o = {
30189
30245
  attributeTableContainer: {
30190
30246
  padding: "mlye8ttls",
30191
30247
  paddingInline: null,
@@ -30212,6 +30268,9 @@ const styles$p = {
30212
30268
  boxSizing: "mly9f619",
30213
30269
  width: "mlyh8yej3",
30214
30270
  height: "mly1m3v4wt",
30271
+ overflow: "mlyysyzu8",
30272
+ overflowX: null,
30273
+ overflowY: null,
30215
30274
  $$css: true
30216
30275
  },
30217
30276
  attributeTableKeyCell: {
@@ -30333,7 +30392,7 @@ function HoverText({
30333
30392
  asChild: true,
30334
30393
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
30335
30394
  ref: textRef,
30336
- ..._stylex.props(styles$o.text, fontStyles.supporting),
30395
+ ..._stylex.props(styles$n.text, fontStyles.supporting),
30337
30396
  children: text2
30338
30397
  })
30339
30398
  }), /* @__PURE__ */ jsxRuntime.jsx(Portal$4, {
@@ -30341,7 +30400,7 @@ function HoverText({
30341
30400
  side,
30342
30401
  align,
30343
30402
  children: /* @__PURE__ */ jsxRuntime.jsx("pre", {
30344
- ..._stylex.props(styles$o.hoverText, fontStyles.tooltipText),
30403
+ ..._stylex.props(styles$n.hoverText, fontStyles.tooltipText),
30345
30404
  children: text2
30346
30405
  })
30347
30406
  })
@@ -30350,7 +30409,7 @@ function HoverText({
30350
30409
  })
30351
30410
  });
30352
30411
  }
30353
- const styles$o = {
30412
+ const styles$n = {
30354
30413
  text: {
30355
30414
  overflow: "mlyb3r6kr",
30356
30415
  overflowX: null,
@@ -30403,11 +30462,11 @@ function HoverCard({
30403
30462
  customStyle
30404
30463
  }) {
30405
30464
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
30406
- ..._stylex.props(styles$n.container, fontStyles.body, customStyle),
30465
+ ..._stylex.props(styles$m.container, fontStyles.body, customStyle),
30407
30466
  children
30408
30467
  });
30409
30468
  }
30410
- const styles$n = {
30469
+ const styles$m = {
30411
30470
  container: {
30412
30471
  boxShadow: "mly5n1uv4",
30413
30472
  backgroundColor: "mly12peec7",
@@ -30452,7 +30511,7 @@ function FieldHoverCard({
30452
30511
  details = /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTable, {
30453
30512
  viewInfo: field,
30454
30513
  isCompact: true,
30455
- style: styles$m.viewAttributeTable
30514
+ style: styles$l.viewAttributeTable
30456
30515
  });
30457
30516
  } else if (field.kind === "dimension") {
30458
30517
  details = /* @__PURE__ */ jsxRuntime.jsx(TopValuesTable, {
@@ -30461,7 +30520,7 @@ function FieldHoverCard({
30461
30520
  });
30462
30521
  }
30463
30522
  return /* @__PURE__ */ jsxRuntime.jsxs(HoverCard, {
30464
- customStyle: styles$m.container,
30523
+ customStyle: styles$l.container,
30465
30524
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
30466
30525
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
30467
30526
  ...{
@@ -30471,10 +30530,10 @@ function FieldHoverCard({
30471
30530
  field
30472
30531
  })
30473
30532
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
30474
- ..._stylex.props(fontStyles.supporting, styles$m.path),
30533
+ ..._stylex.props(fontStyles.supporting, styles$l.path),
30475
30534
  children: pathString
30476
30535
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
30477
- ..._stylex.props(fontStyles.emphasized, styles$m.title),
30536
+ ..._stylex.props(fontStyles.emphasized, styles$l.title),
30478
30537
  children: field.name
30479
30538
  }), description && /* @__PURE__ */ jsxRuntime.jsx(HoverText, {
30480
30539
  text: description
@@ -30484,7 +30543,7 @@ function FieldHoverCard({
30484
30543
  })]
30485
30544
  });
30486
30545
  }
30487
- const styles$m = {
30546
+ const styles$l = {
30488
30547
  container: {
30489
30548
  width: "mlybl57os",
30490
30549
  maxHeight: "mlyq3t0pi",
@@ -30776,10 +30835,10 @@ const PillInput = ({
30776
30835
  commitValue();
30777
30836
  });
30778
30837
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
30779
- ..._stylex.props(fontStyles.body, styles$l.main),
30838
+ ..._stylex.props(fontStyles.body, styles$k.main),
30780
30839
  children: /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
30781
30840
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
30782
- ..._stylex.props(styles$l.content, customStyle),
30841
+ ..._stylex.props(styles$k.content, customStyle),
30783
30842
  onKeyUp,
30784
30843
  onClick: () => {
30785
30844
  var _a2;
@@ -30846,7 +30905,7 @@ const Pill = ({
30846
30905
  onClick,
30847
30906
  tabIndex: 0,
30848
30907
  ref: forwardRef,
30849
- ..._stylex.props(styles$l.pill, colorVariants[color]),
30908
+ ..._stylex.props(styles$k.pill, colorVariants[color]),
30850
30909
  children: [children, /* @__PURE__ */ jsxRuntime.jsx("div", {
30851
30910
  title: "Remove",
30852
30911
  ...{
@@ -30861,7 +30920,7 @@ const Pill = ({
30861
30920
  })]
30862
30921
  });
30863
30922
  };
30864
- const styles$l = {
30923
+ const styles$k = {
30865
30924
  main: {
30866
30925
  borderRadius: "mly12oqio5",
30867
30926
  borderStartStartRadius: null,
@@ -31045,7 +31104,7 @@ function ValueList({
31045
31104
  children: (stringSearchResults == null ? void 0 : stringSearchResults.length) ? stringSearchResults.map((value) => /* @__PURE__ */ jsxRuntime.jsxs("div", {
31046
31105
  role: "menuitem",
31047
31106
  tabIndex: -1,
31048
- ..._stylex.props(addMenuStyles.item, styles$k.valueItem),
31107
+ ..._stylex.props(addMenuStyles.item, styles$j.valueItem),
31049
31108
  onClick: () => onClick(value),
31050
31109
  children: [/* @__PURE__ */ jsxRuntime.jsx(Value, {
31051
31110
  value
@@ -31069,10 +31128,10 @@ function Value({
31069
31128
  label: value.fieldValue ?? "∅",
31070
31129
  icon: "filter",
31071
31130
  color: "purple",
31072
- customStyle: styles$k.token
31131
+ customStyle: styles$j.token
31073
31132
  });
31074
31133
  }
31075
- const styles$k = {
31134
+ const styles$j = {
31076
31135
  valueItem: {
31077
31136
  height: "mly1qx5ct2",
31078
31137
  paddingTop: "mly1y1aw1k",
@@ -31248,7 +31307,7 @@ const StringFilterCore = ({
31248
31307
  setSearchValue("");
31249
31308
  }
31250
31309
  },
31251
- customStyle: styles$j.valueList
31310
+ customStyle: styles$i.valueList
31252
31311
  })
31253
31312
  })]
31254
31313
  }) : currentFilter.operator === "~" ? /* @__PURE__ */ jsxRuntime.jsx(StringEditor, {
@@ -31316,7 +31375,7 @@ function stringFilterChangeType(filter, type) {
31316
31375
  };
31317
31376
  }
31318
31377
  }
31319
- const styles$j = {
31378
+ const styles$i = {
31320
31379
  valueList: {
31321
31380
  maxHeight: "mly3d5gib",
31322
31381
  width: "mly1hfn5x7",
@@ -31571,83 +31630,6 @@ function makeFilterWithNewType(filter, type) {
31571
31630
  };
31572
31631
  }
31573
31632
  }
31574
- const formats = {
31575
- second: "YYYY-MM-DD HH:mm:ss",
31576
- minute: "YYYY-MM-DD HH:mm",
31577
- hour: "YYYY-MM-DD HH:00",
31578
- day: "YYYY-MM-DD",
31579
- week: "[WK]YYYY-WW",
31580
- month: "YYYY-MM",
31581
- quarter: "YYYY-[Q]Q",
31582
- year: "YYYY"
31583
- };
31584
- const regexps = {
31585
- second: /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/,
31586
- minute: /\d\d\d\d-\d\d-\d\d \d\d:\d\d/,
31587
- hour: /\d\d\d\d-\d\d-\d\d \d\d:00/,
31588
- day: /\d\d\d\d-\d\d-\d\d/,
31589
- week: /WK\d\d\d\d-\d\d-\d\d/,
31590
- month: /\d\d\d\d-\d\d/,
31591
- quarter: /\d\d\d\d-Q\d/,
31592
- year: /\d\d\d\d/
31593
- };
31594
- const DateInput = ({
31595
- value,
31596
- setValue,
31597
- placeholder,
31598
- autoFocus,
31599
- units,
31600
- onFocus,
31601
- onBlur,
31602
- isActive,
31603
- customStyle
31604
- }) => {
31605
- const format2 = formats[units];
31606
- const [tempValue, setTempValue] = React.useState(hooks(value).format(format2));
31607
- React.useEffect(() => {
31608
- setTempValue(hooks(value).format(format2));
31609
- }, [value, format2]);
31610
- return /* @__PURE__ */ jsxRuntime.jsx("input", {
31611
- ..._stylex.props(customStyle, isActive ? styles$i.active : null),
31612
- type: "text",
31613
- placeholder: placeholder || format2,
31614
- value: tempValue,
31615
- onFocus,
31616
- onBlur,
31617
- onChange: (event) => {
31618
- const raw2 = event.target.value;
31619
- setTempValue(raw2);
31620
- const regex = regexps[units];
31621
- if (raw2.match(regex)) {
31622
- const m = hooks(raw2, format2);
31623
- if (m.isValid()) {
31624
- setValue(m.toDate());
31625
- }
31626
- }
31627
- },
31628
- autoFocus
31629
- });
31630
- };
31631
- function guessUnits(moment2, isDateTime) {
31632
- if (moment2.moment === "literal") {
31633
- const {
31634
- literal
31635
- } = moment2;
31636
- for (const unit in regexps) {
31637
- const temporalUnit = unit;
31638
- if (literal.match(regexps[temporalUnit])) {
31639
- return temporalUnit;
31640
- }
31641
- }
31642
- }
31643
- return isDateTime ? "second" : "day";
31644
- }
31645
- const styles$i = {
31646
- active: {
31647
- backgroundColor: "mly1vzefiq",
31648
- $$css: true
31649
- }
31650
- };
31651
31633
  function typeFromFilter(filter) {
31652
31634
  if (filter.operator === "null" && filter.not) {
31653
31635
  return "-null";
@@ -31655,7 +31637,7 @@ function typeFromFilter(filter) {
31655
31637
  return filter.operator;
31656
31638
  }
31657
31639
  function unitsFromFilter(filter, isDateTime) {
31658
- if (filter.operator === "last" || filter.operator === "next") {
31640
+ if (filter.operator === "last" || filter.operator === "next" || filter.operator === "in_last") {
31659
31641
  return filter.units;
31660
31642
  } else if (filter.operator === "to") {
31661
31643
  return guessUnits(filter.fromMoment, isDateTime);
@@ -31697,11 +31679,14 @@ const DateTimeFilterCore = ({
31697
31679
  value: type,
31698
31680
  onChange: changeType,
31699
31681
  options: [{
31700
- value: "last",
31682
+ value: "in_last",
31701
31683
  label: "last"
31684
+ }, {
31685
+ value: "last",
31686
+ label: "last complete"
31702
31687
  }, {
31703
31688
  value: "next",
31704
- label: "next"
31689
+ label: "next complete"
31705
31690
  }, {
31706
31691
  value: "after",
31707
31692
  label: "after"
@@ -31728,6 +31713,7 @@ const DateTimeFilterCore = ({
31728
31713
  };
31729
31714
  function getTopEditorRow(currentFilter, updateFilter, units, setUnits, maxLevel) {
31730
31715
  switch (currentFilter.operator) {
31716
+ case "in_last":
31731
31717
  case "last":
31732
31718
  case "next":
31733
31719
  return /* @__PURE__ */ jsxRuntime.jsx(NUnitFilter, {
@@ -31840,15 +31826,48 @@ function NUnitFilter({
31840
31826
  });
31841
31827
  }
31842
31828
  function UnitFilter({
31829
+ currentFilter,
31830
+ updateFilter,
31843
31831
  units,
31844
31832
  setUnits,
31845
31833
  maxLevel
31846
31834
  }) {
31847
31835
  const options = maxLevel === "day" ? DateUnits : [...DateUnits, ...TimeUnits];
31836
+ const updateUnits = (units2) => {
31837
+ setUnits(units2);
31838
+ switch (currentFilter.operator) {
31839
+ case "after":
31840
+ updateFilter({
31841
+ ...currentFilter,
31842
+ after: updateMoment(currentFilter.after, units2)
31843
+ });
31844
+ return;
31845
+ case "before":
31846
+ updateFilter({
31847
+ ...currentFilter,
31848
+ before: updateMoment(currentFilter.before, units2)
31849
+ });
31850
+ return;
31851
+ case "to":
31852
+ updateFilter({
31853
+ ...currentFilter,
31854
+ fromMoment: updateMoment(currentFilter.fromMoment, units2),
31855
+ toMoment: updateMoment(currentFilter.toMoment, units2)
31856
+ });
31857
+ return;
31858
+ case "in": {
31859
+ updateFilter({
31860
+ ...currentFilter,
31861
+ in: updateMoment(currentFilter.in, units2)
31862
+ });
31863
+ return;
31864
+ }
31865
+ }
31866
+ };
31848
31867
  return /* @__PURE__ */ jsxRuntime.jsx(SelectDropdown, {
31849
31868
  options,
31850
31869
  value: units,
31851
- onChange: setUnits,
31870
+ onChange: updateUnits,
31852
31871
  customStyle: filterStyles.editorCell
31853
31872
  });
31854
31873
  }
@@ -31973,20 +31992,25 @@ function DoubleDateFilter({
31973
31992
  function createTemporalLiteral(date, units) {
31974
31993
  return {
31975
31994
  moment: "literal",
31976
- literal: hooks(date).format(formats[units])
31995
+ literal: hooks.utc(date).format(formats[units]),
31996
+ units
31977
31997
  };
31978
31998
  }
31979
31999
  function extractDateFromMoment(momentObj) {
31980
32000
  if (momentObj && momentObj.moment === "literal") {
31981
- return hooks(momentObj.literal).toDate();
32001
+ return hooks.utc(momentObj.literal, formats[momentObj.units ?? "second"]).toDate();
31982
32002
  }
31983
32003
  return /* @__PURE__ */ new Date();
31984
32004
  }
32005
+ function updateMoment(moment2, units) {
32006
+ return createTemporalLiteral(extractDateFromMoment(moment2), units);
32007
+ }
31985
32008
  function dateTimeFilterChangeType(filter, type, units) {
31986
32009
  let n = "7";
31987
32010
  let fromMoment = createTemporalLiteral(/* @__PURE__ */ new Date(), units);
31988
32011
  let toMoment = createTemporalLiteral(/* @__PURE__ */ new Date(), units);
31989
32012
  switch (filter.operator) {
32013
+ case "in_last":
31990
32014
  case "last":
31991
32015
  case "next":
31992
32016
  n = filter.n;
@@ -32006,6 +32030,7 @@ function dateTimeFilterChangeType(filter, type, units) {
32006
32030
  break;
32007
32031
  }
32008
32032
  switch (type) {
32033
+ case "in_last":
32009
32034
  case "last":
32010
32035
  case "next":
32011
32036
  return {
@@ -32023,6 +32048,11 @@ function dateTimeFilterChangeType(filter, type, units) {
32023
32048
  operator: type,
32024
32049
  before: fromMoment
32025
32050
  };
32051
+ case "in":
32052
+ return {
32053
+ operator: type,
32054
+ in: fromMoment
32055
+ };
32026
32056
  case "to":
32027
32057
  return {
32028
32058
  operator: type,
@@ -32088,6 +32118,13 @@ function FilterDialog({
32088
32118
  };
32089
32119
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
32090
32120
  ..._stylex.props(fontStyles.body, filterStyles.filterDialog),
32121
+ onKeyDown: (event) => {
32122
+ if (event.key === "Enter") {
32123
+ onApply();
32124
+ } else if (event.key === "Esc") {
32125
+ onCancel();
32126
+ }
32127
+ },
32091
32128
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
32092
32129
  ..._stylex.props(filterStyles.filterDialogHeader),
32093
32130
  children: fieldInfo.name
@@ -32191,12 +32228,17 @@ function FilterPopover({
32191
32228
  setFilter,
32192
32229
  trigger,
32193
32230
  anchor,
32194
- layoutProps
32231
+ layoutProps,
32232
+ onOpenChange
32195
32233
  }) {
32196
32234
  const [open, setOpen] = React.useState(false);
32235
+ const handleOpenChange = (open2) => {
32236
+ setOpen(open2);
32237
+ onOpenChange == null ? void 0 : onOpenChange(open2);
32238
+ };
32197
32239
  return /* @__PURE__ */ jsxRuntime.jsxs(Root2$2, {
32198
32240
  open,
32199
- onOpenChange: setOpen,
32241
+ onOpenChange: handleOpenChange,
32200
32242
  modal: true,
32201
32243
  children: [anchor ? /* @__PURE__ */ jsxRuntime.jsx(Anchor2$1, {
32202
32244
  asChild: true,
@@ -32215,7 +32257,7 @@ function FilterPopover({
32215
32257
  filter,
32216
32258
  path,
32217
32259
  onFilterApply: setFilter,
32218
- onOpenChange: setOpen
32260
+ onOpenChange: handleOpenChange
32219
32261
  })
32220
32262
  })
32221
32263
  })]
@@ -32236,7 +32278,7 @@ function FieldList({
32236
32278
  const groups2 = [];
32237
32279
  const lcSearch = search.toLocaleLowerCase();
32238
32280
  const buildGroups = (types22, path, name, fields2) => {
32239
- 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);
32281
+ 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);
32240
32282
  const joins = fields2.filter((field) => field.kind === "join");
32241
32283
  const arraysAndRecords = fields2.filter(isArrayOrRecord);
32242
32284
  if (filteredFields.length) {
@@ -32395,20 +32437,19 @@ function segmentHasOrderBy(segment, name) {
32395
32437
  function segmentNestNo(segment, name) {
32396
32438
  return segment.operations.items.reduce((acc, operation) => {
32397
32439
  if (operation instanceof QB.ASTNestViewOperation) {
32398
- if (name) {
32440
+ {
32399
32441
  if (operation.name === name) {
32400
32442
  do {
32401
32443
  acc += 1;
32402
32444
  } while (segment.hasFieldNamed(`${name} ${acc}`));
32403
32445
  }
32404
- } else {
32405
- return acc + 1;
32406
32446
  }
32407
32447
  }
32408
32448
  return acc;
32409
32449
  }, 1);
32410
32450
  }
32411
32451
  function addGroupBy(view, field, path) {
32452
+ const type = field.kind === "dimension" ? field.type.kind : "string";
32412
32453
  const segment = view.getOrAddDefaultSegment();
32413
32454
  const {
32414
32455
  fields
@@ -32417,7 +32458,13 @@ function addGroupBy(view, field, path) {
32417
32458
  if (fields.find((f2) => f2.name === field.name)) {
32418
32459
  rename = findUniqueFieldName(fields, field.name, path);
32419
32460
  }
32420
- segment.addGroupBy(field.name, path, rename);
32461
+ if (type === "date_type") {
32462
+ segment.addDateGroupBy(field.name, path, "day");
32463
+ } else if (type === "timestamp_type") {
32464
+ segment.addTimestampGroupBy(field.name, path, "second");
32465
+ } else {
32466
+ segment.addGroupBy(field.name, path, rename);
32467
+ }
32421
32468
  }
32422
32469
  function addAggregate(view, field, path) {
32423
32470
  const segment = view.getOrAddDefaultSegment();
@@ -32441,6 +32488,18 @@ function addNest(view, field) {
32441
32488
  }
32442
32489
  segment.addNest(field.name, rename);
32443
32490
  }
32491
+ function addOrderBy(view, field, direction = "desc") {
32492
+ const segment = view.getOrAddDefaultSegment();
32493
+ segment.addOrderBy(field.name, direction);
32494
+ }
32495
+ function addFilter(view, field, path, filter) {
32496
+ const segment = view.getOrAddDefaultSegment();
32497
+ if (field.kind === "dimension") {
32498
+ segment.addWhere(field.name, path, filter);
32499
+ } else {
32500
+ segment.addHaving(field.name, path, filter);
32501
+ }
32502
+ }
32444
32503
  function getSegmentIfPresent(parent) {
32445
32504
  const definition = getViewDefinition(parent);
32446
32505
  if (definition instanceof QB.ASTSegmentViewDefinition) {
@@ -32466,7 +32525,7 @@ function OperationActionTitle({
32466
32525
  return !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
32467
32526
  };
32468
32527
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
32469
- ..._stylex.props(styles$s.title, hoverStyles.main),
32528
+ ..._stylex.props(styles$r.title, hoverStyles.main),
32470
32529
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
32471
32530
  children: title
32472
32531
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
@@ -32863,7 +32922,14 @@ function RenameDialog({
32863
32922
  ..._stylex.props({
32864
32923
  ...dialogStyles.editorCell,
32865
32924
  ...dialogStyles.input
32866
- })
32925
+ }),
32926
+ onKeyDown: (event) => {
32927
+ if (event.key === "Enter") {
32928
+ onRename();
32929
+ } else if (event.key === "Esc") {
32930
+ setOpen(false);
32931
+ }
32932
+ }
32867
32933
  }), badName && /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, {
32868
32934
  errorMessage: "Name already in use"
32869
32935
  })]
@@ -33036,7 +33102,7 @@ function SortableOperations({
33036
33102
  fields,
33037
33103
  ...props2
33038
33104
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
33039
- ..._stylex.props(styles$s.tokenContainer),
33105
+ ..._stylex.props(styles$r.tokenContainer),
33040
33106
  children: /* @__PURE__ */ jsxRuntime.jsx(DndContext, {
33041
33107
  sensors,
33042
33108
  collisionDetection: closestCenter,
@@ -33044,6 +33110,7 @@ function SortableOperations({
33044
33110
  children: /* @__PURE__ */ jsxRuntime.jsx(SortableContext, {
33045
33111
  items,
33046
33112
  children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(SortableOperation, {
33113
+ rootQuery,
33047
33114
  id: item.id,
33048
33115
  color: kind === "group_by" ? "cyan" : "green",
33049
33116
  view,
@@ -33054,18 +33121,19 @@ function SortableOperations({
33054
33121
  })]
33055
33122
  });
33056
33123
  }
33124
+ const NULL_PATH = [];
33057
33125
  function SortableOperation({
33126
+ rootQuery,
33058
33127
  id,
33059
33128
  view,
33060
33129
  operation,
33061
33130
  color
33062
33131
  }) {
33063
33132
  const {
33064
- rootQuery,
33065
33133
  setQuery
33066
33134
  } = React.useContext(QueryEditorContext);
33067
33135
  const fieldInfo = operation.getFieldInfo();
33068
- const path = operation.field.getReference().path ?? [];
33136
+ const path = operation.field.getReference().path ?? NULL_PATH;
33069
33137
  const {
33070
33138
  attributes,
33071
33139
  listeners,
@@ -33085,37 +33153,64 @@ function SortableOperation({
33085
33153
  transform: CSS$1.Transform.toString(transform2),
33086
33154
  transition
33087
33155
  };
33156
+ const hoverActions = React.useMemo(() => {
33157
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
33158
+ children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, {
33159
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
33160
+ variant: "flat",
33161
+ icon: "meatballs",
33162
+ size: "compact",
33163
+ tooltip: "More Actions"
33164
+ }),
33165
+ onOpenChange: setHoverActionsVisible,
33166
+ children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
33167
+ label: "Rename",
33168
+ onClick: () => {
33169
+ setRenameTarget(operation);
33170
+ setRenameOpen(true);
33171
+ }
33172
+ }, "rename")]
33173
+ }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
33174
+ onClick: () => {
33175
+ operation.delete();
33176
+ setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33177
+ }
33178
+ })]
33179
+ });
33180
+ }, [fieldInfo, operation, path, rootQuery, setQuery]);
33181
+ const granular = granularityMenuItems(fieldInfo, operation.field);
33182
+ let icon = "orderBy";
33183
+ if (fieldInfo.kind === "dimension" || fieldInfo.kind === "measure") {
33184
+ icon = atomicTypeToIcon(fieldInfo.type.kind);
33185
+ }
33088
33186
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
33089
33187
  id,
33090
33188
  ref: setNodeRef,
33091
33189
  style,
33092
- children: [/* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
33190
+ children: [granular ? /* @__PURE__ */ jsxRuntime.jsxs(TokenGroup, {
33191
+ customStyle: customStyles.tokenGroup,
33192
+ children: [/* @__PURE__ */ jsxRuntime.jsx(Token, {
33193
+ color,
33194
+ icon,
33195
+ label: fieldInfo.name,
33196
+ dragProps: {
33197
+ attributes,
33198
+ listeners
33199
+ }
33200
+ }), /* @__PURE__ */ jsxRuntime.jsx(SelectorToken, {
33201
+ color,
33202
+ value: granular.value,
33203
+ onChange: (granulation) => {
33204
+ if (operation.field.expression instanceof QB.ASTTimeTruncationExpression) operation.field.expression.truncation = granulation;
33205
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
33206
+ },
33207
+ items: granular.options
33208
+ })]
33209
+ }) : /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
33093
33210
  field: fieldInfo,
33094
33211
  color,
33095
33212
  hoverActionsVisible,
33096
- hoverActions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
33097
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, {
33098
- trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
33099
- variant: "flat",
33100
- icon: "meatballs",
33101
- size: "compact",
33102
- tooltip: "More Actions"
33103
- }),
33104
- onOpenChange: setHoverActionsVisible,
33105
- children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
33106
- label: "Rename",
33107
- onClick: () => {
33108
- setRenameTarget(operation);
33109
- setRenameOpen(true);
33110
- }
33111
- })
33112
- }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsxRuntime.jsx(ClearButton, {
33113
- onClick: () => {
33114
- operation.delete();
33115
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33116
- }
33117
- })]
33118
- }),
33213
+ hoverActions,
33119
33214
  tooltip: /* @__PURE__ */ jsxRuntime.jsx(FieldHoverCard, {
33120
33215
  field: fieldInfo,
33121
33216
  path
@@ -33138,6 +33233,38 @@ function SortableOperation({
33138
33233
  })]
33139
33234
  });
33140
33235
  }
33236
+ const DateGranulation = ["day", "week", "month", "quarter", "year"];
33237
+ const TimestampGranulation = ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
33238
+ function granularityMenuItems(fieldInfo, field) {
33239
+ if (fieldInfo.kind !== "dimension" || !(field.expression instanceof QB.ASTTimeTruncationExpression)) {
33240
+ return null;
33241
+ }
33242
+ if (fieldInfo.type.kind === "timestamp_type") {
33243
+ return {
33244
+ value: fieldInfo.type.timeframe ?? "second",
33245
+ options: TimestampGranulation.map((value) => ({
33246
+ label: value,
33247
+ value
33248
+ }))
33249
+ };
33250
+ }
33251
+ if (fieldInfo.type.kind === "date_type") {
33252
+ return {
33253
+ value: fieldInfo.type.timeframe ?? "day",
33254
+ options: DateGranulation.map((value) => ({
33255
+ label: value,
33256
+ value
33257
+ }))
33258
+ };
33259
+ }
33260
+ return null;
33261
+ }
33262
+ const customStyles = {
33263
+ tokenGroup: {
33264
+ display: "mly78zum5",
33265
+ $$css: true
33266
+ }
33267
+ };
33141
33268
  function GroupByOperations({
33142
33269
  rootQuery,
33143
33270
  segment,
@@ -33186,10 +33313,10 @@ function FilterOperations({
33186
33313
  }
33187
33314
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
33188
33315
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
33189
- ..._stylex.props(styles$s.title),
33316
+ ..._stylex.props(styles$r.title),
33190
33317
  children: "filter by"
33191
33318
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
33192
- ..._stylex.props(styles$s.tokenContainer),
33319
+ ..._stylex.props(styles$r.tokenContainer),
33193
33320
  children: filters.map((filterOperation, key2) => {
33194
33321
  return /* @__PURE__ */ jsxRuntime.jsx(ErrorElement, {
33195
33322
  fallback: /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -33396,7 +33523,7 @@ const parsedToLabels = (parsed, filterString) => {
33396
33523
  const {
33397
33524
  not
33398
33525
  } = temporalClause;
33399
- op = `is${not ? " not" : ""} last`;
33526
+ op = `is${not ? " not" : ""} last complete`;
33400
33527
  value = temporalClause.n + " " + temporalClause.units;
33401
33528
  }
33402
33529
  break;
@@ -33405,7 +33532,7 @@ const parsedToLabels = (parsed, filterString) => {
33405
33532
  const {
33406
33533
  not
33407
33534
  } = temporalClause;
33408
- op = `is${not ? " not" : ""} nest`;
33535
+ op = `is${not ? " not" : ""} next complete`;
33409
33536
  value = temporalClause.n + " " + temporalClause.units;
33410
33537
  }
33411
33538
  break;
@@ -33453,7 +33580,7 @@ function LimitOperation({
33453
33580
  }
33454
33581
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
33455
33582
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
33456
- ..._stylex.props(styles$s.title),
33583
+ ..._stylex.props(styles$r.title),
33457
33584
  children: "limit"
33458
33585
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
33459
33586
  ..._stylex.props(hoverStyles.main),
@@ -33503,10 +33630,10 @@ function OrderByOperations({
33503
33630
  }
33504
33631
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
33505
33632
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
33506
- ..._stylex.props(styles$s.title),
33633
+ ..._stylex.props(styles$r.title),
33507
33634
  children: "order by"
33508
33635
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
33509
- ..._stylex.props(styles$s.tokenContainer),
33636
+ ..._stylex.props(styles$r.tokenContainer),
33510
33637
  children: orderBys.map((orderBy) => {
33511
33638
  const {
33512
33639
  fieldReference
@@ -33574,71 +33701,6 @@ function View({
33574
33701
  })]
33575
33702
  });
33576
33703
  }
33577
- function CollapsiblePanel({
33578
- title,
33579
- children,
33580
- icon,
33581
- defaultOpen = true,
33582
- controls,
33583
- collapsedControls
33584
- }) {
33585
- const [isExpanded, setIsExpanded] = React.useState(defaultOpen);
33586
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
33587
- ...{
33588
- className: "mlyzkdzjc mly1sxf85j mly1717udv"
33589
- },
33590
- children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
33591
- ...{
33592
- className: "mlyrvj5dj mly1mt1orb mly52fmzj mlylqzeqv mlyfawy5m mly167g77z mly6s0dn4"
33593
- },
33594
- children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
33595
- ...{
33596
- className: "mlyrvj5dj mly1mt1orb mlylqzeqv mly6s0dn4 mly167g77z"
33597
- },
33598
- children: [icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, {
33599
- name: icon,
33600
- customStyle: styles$f.icon
33601
- }), /* @__PURE__ */ jsxRuntime.jsx("div", {
33602
- ...{
33603
- className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp"
33604
- },
33605
- children: title
33606
- })]
33607
- }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
33608
- ...{
33609
- className: "mly78zum5"
33610
- },
33611
- children: [isExpanded ? /* @__PURE__ */ jsxRuntime.jsx("div", {
33612
- ...{
33613
- className: "mly78zum5 mly6s0dn4 mly1jnr06f"
33614
- },
33615
- children: controls
33616
- }) : /* @__PURE__ */ jsxRuntime.jsx("div", {
33617
- ...{
33618
- className: "mly78zum5 mly6s0dn4 mly1jnr06f"
33619
- },
33620
- children: collapsedControls
33621
- }), /* @__PURE__ */ jsxRuntime.jsx(Button, {
33622
- variant: "flat",
33623
- size: "compact",
33624
- onClick: () => setIsExpanded(!isExpanded),
33625
- icon: isExpanded ? "chevronDown" : "chevronRight",
33626
- tooltip: isExpanded ? "Collapse" : "Expand"
33627
- })]
33628
- })]
33629
- }), isExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", {
33630
- ...{
33631
- className: "mly1l4tkcb"
33632
- },
33633
- children
33634
- })]
33635
- });
33636
- }
33637
- const styles$f = {
33638
- icon: {
33639
- $$css: true
33640
- }
33641
- };
33642
33704
  function AddItem({
33643
33705
  icon,
33644
33706
  label,
@@ -33657,7 +33719,7 @@ function AddItem({
33657
33719
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
33658
33720
  role: "menuitem",
33659
33721
  tabIndex: -1,
33660
- ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$e.open : null),
33722
+ ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$f.open : null),
33661
33723
  onClick: doOnClick,
33662
33724
  "data-disabled": disabled ? "true" : void 0,
33663
33725
  children: [/* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -33681,7 +33743,7 @@ function AddItem({
33681
33743
  }) : null]
33682
33744
  });
33683
33745
  }
33684
- const styles$e = {
33746
+ const styles$f = {
33685
33747
  open: {
33686
33748
  background: "mly16o7sp0",
33687
33749
  backgroundAttachment: null,
@@ -33756,12 +33818,13 @@ function AddFieldItem({
33756
33818
  onAddOperation,
33757
33819
  isFilterOperation,
33758
33820
  search,
33759
- customStyle: styles$d.list
33821
+ customStyle: styles$e.list
33760
33822
  });
33761
33823
  }
33762
- const styles$d = {
33824
+ const styles$e = {
33763
33825
  list: {
33764
- width: "mlyqyf9gi",
33826
+ minWidth: "mly2ixbly",
33827
+ maxWidth: "mly1j9u4d2",
33765
33828
  $$css: true
33766
33829
  }
33767
33830
  };
@@ -33783,8 +33846,7 @@ function AddOrderBy({
33783
33846
  fields,
33784
33847
  types: ["dimension"],
33785
33848
  onAddOperation: (field) => {
33786
- const segment2 = view.getOrAddDefaultSegment();
33787
- segment2.addOrderBy(field.name, "asc");
33849
+ addOrderBy(view, field);
33788
33850
  setQuery == null ? void 0 : setQuery(rootQuery.build());
33789
33851
  },
33790
33852
  disabledMessage: "There must be at least one field in the output to order by.",
@@ -33861,28 +33923,21 @@ function AddWhere({
33861
33923
  const {
33862
33924
  fields
33863
33925
  } = getInputSchemaFromViewParent(view);
33864
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
33865
- children: /* @__PURE__ */ jsxRuntime.jsx(AddFieldItem, {
33866
- label: "Add filter",
33867
- icon: "filter",
33868
- view,
33869
- fields,
33870
- types: ["measure", "dimension"],
33871
- filter: (_segment, field) => (field.kind === "dimension" || field.kind === "measure") && FILTERABLE_TYPES$1.has(field.type.kind) && isNotAnnotatedFilteredField(field),
33872
- onAddOperation: (field, path, filter) => {
33873
- if (filter && (field.kind === "dimension" || field.kind === "measure")) {
33874
- const segment = view.getOrAddDefaultSegment();
33875
- if (field.kind === "dimension") {
33876
- segment.addWhere(field.name, path, filter);
33877
- } else {
33878
- segment.addHaving(field.name, path, filter);
33879
- }
33880
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33881
- }
33882
- },
33883
- isFilterOperation: true,
33884
- search
33885
- })
33926
+ return /* @__PURE__ */ jsxRuntime.jsx(AddFieldItem, {
33927
+ label: "Add filter",
33928
+ icon: "filter",
33929
+ view,
33930
+ fields,
33931
+ types: ["measure", "dimension"],
33932
+ filter: (_segment, field) => (field.kind === "dimension" || field.kind === "measure") && FILTERABLE_TYPES$1.has(field.type.kind) && isNotAnnotatedFilteredField(field),
33933
+ onAddOperation: (field, path, filter) => {
33934
+ if (filter && (field.kind === "dimension" || field.kind === "measure")) {
33935
+ addFilter(view, field, path, filter);
33936
+ setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
33937
+ }
33938
+ },
33939
+ isFilterOperation: true,
33940
+ search
33886
33941
  });
33887
33942
  }
33888
33943
  const FILTERABLE_TYPES$1 = /* @__PURE__ */ new Set(["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"]);
@@ -33963,7 +34018,7 @@ function AddMenu({
33963
34018
  value: search,
33964
34019
  onChange: setSearch,
33965
34020
  placeholder: "Search...",
33966
- customStyle: styles$c.search
34021
+ customStyle: styles$d.search
33967
34022
  })
33968
34023
  }), /* @__PURE__ */ jsxRuntime.jsx(Divider, {}), /* @__PURE__ */ jsxRuntime.jsxs("div", {
33969
34024
  ...{
@@ -34084,7 +34139,7 @@ function AddMenu({
34084
34139
  })]
34085
34140
  });
34086
34141
  }
34087
- const styles$c = {
34142
+ const styles$d = {
34088
34143
  search: {
34089
34144
  width: "mlyh8yej3",
34090
34145
  $$css: true
@@ -34099,7 +34154,7 @@ function NestOperations({
34099
34154
  return null;
34100
34155
  }
34101
34156
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
34102
- ..._stylex.props(styles$s.tokenContainer),
34157
+ ..._stylex.props(styles$r.tokenContainer),
34103
34158
  children: nests.map((nest) => /* @__PURE__ */ jsxRuntime.jsx(NestOperation, {
34104
34159
  rootQuery,
34105
34160
  view,
@@ -34113,10 +34168,31 @@ function NestOperation({
34113
34168
  nest
34114
34169
  }) {
34115
34170
  const {
34116
- setQuery
34171
+ setQuery,
34172
+ currentNestQueryPanel,
34173
+ onCurrentNestQueryPanelChange,
34174
+ onCurrentNestViewChange
34117
34175
  } = React.useContext(QueryEditorContext);
34118
34176
  const [renameOpen, setRenameOpen] = React.useState(false);
34119
- const defaultOpen = nest.view.definition.node.kind === "segment" && nest.view.definition.node.operations.length === 0;
34177
+ const panelRef = React__namespace.useRef(null);
34178
+ const isCurrentNestQueryPanelFocused = currentNestQueryPanel !== null && panelRef.current == currentNestQueryPanel;
34179
+ React__namespace.useEffect(() => {
34180
+ if (isCurrentNestQueryPanelFocused) {
34181
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(nest.view);
34182
+ }
34183
+ }, [nest, isCurrentNestQueryPanelFocused, onCurrentNestViewChange]);
34184
+ const focusCurrentNestQueryPanel = () => {
34185
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(panelRef.current);
34186
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(nest.view);
34187
+ };
34188
+ const focusParentQueryPanel = () => {
34189
+ const currentPanel = panelRef.current;
34190
+ const parent = findParentNestQueryPanel(currentPanel);
34191
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(parent);
34192
+ if (parent === null) {
34193
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
34194
+ }
34195
+ };
34120
34196
  const getControls = (nest2) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
34121
34197
  children: [/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, {
34122
34198
  trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
@@ -34129,6 +34205,7 @@ function NestOperation({
34129
34205
  icon: "clear",
34130
34206
  label: "Delete Query",
34131
34207
  onClick: () => {
34208
+ focusParentQueryPanel();
34132
34209
  nest2.delete();
34133
34210
  setQuery == null ? void 0 : setQuery(rootQuery.build());
34134
34211
  }
@@ -34143,29 +34220,41 @@ function NestOperation({
34143
34220
  view: nest2.view
34144
34221
  })]
34145
34222
  });
34146
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34223
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
34147
34224
  ...{
34148
34225
  className: "mlyj3b58b mly1yf7rl7 mly1xmf6yo mlyh8yej3"
34149
34226
  },
34150
- children: [/* @__PURE__ */ jsxRuntime.jsx(CollapsiblePanel, {
34151
- title: nest.name,
34152
- icon: viewToVisualizationIcon(nest.view),
34153
- defaultOpen,
34154
- controls: getControls(nest),
34155
- collapsedControls: getControls(nest),
34156
- children: /* @__PURE__ */ jsxRuntime.jsx(View, {
34227
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
34228
+ ref: panelRef,
34229
+ onPointerDownCapture: focusCurrentNestQueryPanel,
34230
+ "data-nest-panel": true,
34231
+ children: [/* @__PURE__ */ jsxRuntime.jsx(CollapsiblePanel, {
34232
+ title: nest.name,
34233
+ icon: viewToVisualizationIcon(nest.view),
34234
+ defaultOpen: true,
34235
+ controls: getControls(nest),
34236
+ collapsedControls: getControls(nest),
34237
+ isFocused: isCurrentNestQueryPanelFocused,
34238
+ children: /* @__PURE__ */ jsxRuntime.jsx(View, {
34239
+ rootQuery,
34240
+ view: nest.view
34241
+ })
34242
+ }), /* @__PURE__ */ jsxRuntime.jsx(RenameDialog, {
34157
34243
  rootQuery,
34158
- view: nest.view
34159
- })
34160
- }), /* @__PURE__ */ jsxRuntime.jsx(RenameDialog, {
34161
- rootQuery,
34162
- view,
34163
- target: nest,
34164
- open: renameOpen,
34165
- setOpen: setRenameOpen
34166
- })]
34244
+ view,
34245
+ target: nest,
34246
+ open: renameOpen,
34247
+ setOpen: setRenameOpen
34248
+ })]
34249
+ })
34167
34250
  }, nest.name);
34168
34251
  }
34252
+ function findParentNestQueryPanel(element2) {
34253
+ if (!element2 || !element2.parentElement) return null;
34254
+ const parentElement = element2.parentElement;
34255
+ if (parentElement.dataset.nestPanel !== void 0) return parentElement;
34256
+ return findParentNestQueryPanel(parentElement);
34257
+ }
34169
34258
  function Operations({
34170
34259
  rootQuery,
34171
34260
  view,
@@ -34267,7 +34356,7 @@ function ViewDefinition({
34267
34356
  function CollapsingView({
34268
34357
  viewDef
34269
34358
  }) {
34270
- const [collapsed, setCollapsed] = React.useState(true);
34359
+ const [collapsed, setCollapsed] = React.useState(false);
34271
34360
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34272
34361
  ...{
34273
34362
  0: {
@@ -34296,11 +34385,11 @@ function CollapsingView({
34296
34385
  })]
34297
34386
  }), !collapsed && /* @__PURE__ */ jsxRuntime.jsx(ViewAttributeTable, {
34298
34387
  viewInfo: viewDef.getViewInfo(),
34299
- style: styles$b.preview
34388
+ style: styles$c.preview
34300
34389
  })]
34301
34390
  });
34302
34391
  }
34303
- const styles$b = {
34392
+ const styles$c = {
34304
34393
  preview: {
34305
34394
  height: "mlyt7dq6l",
34306
34395
  maxHeight: "mly1hkcv85",
@@ -34332,75 +34421,91 @@ function Query({
34332
34421
  query,
34333
34422
  setQuery
34334
34423
  }) {
34335
- return /* @__PURE__ */ jsxRuntime.jsxs(CollapsiblePanel, {
34336
- title: "Main query",
34337
- controls: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
34338
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, {
34339
- trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
34340
- variant: "flat",
34341
- icon: "meatballs",
34342
- size: "compact",
34343
- tooltip: "More Actions"
34344
- }),
34345
- children: setQuery ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
34346
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34347
- icon: "clear",
34348
- label: "Clear query",
34349
- onClick: () => {
34350
- setQuery == null ? void 0 : setQuery(void 0);
34351
- },
34352
- disabled: rootQuery.isEmpty()
34353
- }), /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34354
- icon: "nest",
34355
- label: "Nest query",
34356
- onClick: () => {
34357
- if (rootQuery.definition instanceof QB.ASTArrowQueryDefinition) {
34358
- rootQuery.definition.view.convertToNest("Nest");
34359
- }
34360
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34361
- },
34362
- disabled: rootQuery.isEmpty() || !(rootQuery.definition instanceof QB.ASTArrowQueryDefinition)
34363
- })]
34364
- }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
34365
- }), query.definition instanceof QB.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsx(AddMenu, {
34366
- rootQuery,
34367
- view: query.definition
34368
- }) : null]
34369
- }),
34370
- collapsedControls: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
34371
- name: viewToVisualizationIcon(query)
34372
- }),
34373
- children: [query.definition instanceof QB.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
34374
- style: {
34375
- display: "flex",
34376
- flexDirection: "column",
34377
- gap: 8
34378
- },
34379
- children: [!query.isEmpty() && /* @__PURE__ */ jsxRuntime.jsx(Visualization$1, {
34380
- rootQuery,
34381
- view: query
34382
- }), /* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
34383
- rootQuery,
34384
- view: query.definition,
34385
- viewDef: query.definition.view
34386
- })]
34387
- }) : null, query.isEmpty() ? /* @__PURE__ */ jsxRuntime.jsx("div", {
34388
- ...{
34389
- className: "mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra"
34390
- },
34391
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
34392
- ...{
34393
- className: "mly78zum5 mly6s0dn4"
34424
+ const {
34425
+ currentNestQueryPanel,
34426
+ onCurrentNestQueryPanelChange,
34427
+ onCurrentNestViewChange
34428
+ } = React__namespace.useContext(QueryEditorContext);
34429
+ const focusMainQueryPanel = () => {
34430
+ onCurrentNestQueryPanelChange == null ? void 0 : onCurrentNestQueryPanelChange(null);
34431
+ onCurrentNestViewChange == null ? void 0 : onCurrentNestViewChange(null);
34432
+ };
34433
+ const canEditViz = query.definition instanceof QB.ASTSegmentViewDefinition;
34434
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
34435
+ onPointerDownCapture: focusMainQueryPanel,
34436
+ children: /* @__PURE__ */ jsxRuntime.jsxs(CollapsiblePanel, {
34437
+ title: "Main query",
34438
+ isFocused: !currentNestQueryPanel,
34439
+ controls: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
34440
+ children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, {
34441
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
34442
+ variant: "flat",
34443
+ icon: "meatballs",
34444
+ size: "compact",
34445
+ tooltip: "More Actions"
34446
+ }),
34447
+ children: setQuery ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
34448
+ children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34449
+ icon: "clear",
34450
+ label: "Clear query",
34451
+ onClick: () => {
34452
+ focusMainQueryPanel();
34453
+ setQuery == null ? void 0 : setQuery(void 0);
34454
+ },
34455
+ disabled: rootQuery.isEmpty()
34456
+ }), /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
34457
+ icon: "nest",
34458
+ label: "Nest query",
34459
+ onClick: () => {
34460
+ if (rootQuery.definition instanceof QB.ASTArrowQueryDefinition) {
34461
+ rootQuery.definition.view.convertToNest("Nest");
34462
+ }
34463
+ setQuery == null ? void 0 : setQuery(rootQuery.build());
34464
+ },
34465
+ disabled: rootQuery.isEmpty() || !(rootQuery.definition instanceof QB.ASTArrowQueryDefinition)
34466
+ })]
34467
+ }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
34468
+ }), query.definition instanceof QB.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsx(AddMenu, {
34469
+ rootQuery,
34470
+ view: query.definition
34471
+ }) : null]
34472
+ }),
34473
+ collapsedControls: /* @__PURE__ */ jsxRuntime.jsx(Icon, {
34474
+ name: viewToVisualizationIcon(query)
34475
+ }),
34476
+ children: [query.definition instanceof QB.ASTArrowQueryDefinition ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
34477
+ style: {
34478
+ display: "flex",
34479
+ flexDirection: "column",
34480
+ gap: 8
34394
34481
  },
34395
- children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
34396
- children: "Click"
34397
- }), /* @__PURE__ */ jsxRuntime.jsx(Icon, {
34398
- name: "insert"
34399
- }), /* @__PURE__ */ jsxRuntime.jsx("div", {
34400
- children: "to get started"
34482
+ children: [!query.isEmpty() && canEditViz && /* @__PURE__ */ jsxRuntime.jsx(Visualization$1, {
34483
+ rootQuery,
34484
+ view: query
34485
+ }), /* @__PURE__ */ jsxRuntime.jsx(ViewDefinition, {
34486
+ rootQuery,
34487
+ view: query.definition,
34488
+ viewDef: query.definition.view
34401
34489
  })]
34402
- })
34403
- }) : null]
34490
+ }) : null, query.isEmpty() ? /* @__PURE__ */ jsxRuntime.jsx("div", {
34491
+ ...{
34492
+ className: "mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra"
34493
+ },
34494
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
34495
+ ...{
34496
+ className: "mly78zum5 mly6s0dn4 mlywzxoxx"
34497
+ },
34498
+ children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
34499
+ children: "Click"
34500
+ }), /* @__PURE__ */ jsxRuntime.jsx(Icon, {
34501
+ name: "insert",
34502
+ color: "disabled"
34503
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
34504
+ children: "to get started"
34505
+ })]
34506
+ })
34507
+ }) : null]
34508
+ })
34404
34509
  });
34405
34510
  }
34406
34511
  function Source({
@@ -34408,14 +34513,14 @@ function Source({
34408
34513
  }) {
34409
34514
  if (rootQuery.definition instanceof QB.ASTArrowQueryDefinition) {
34410
34515
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
34411
- ..._stylex.props(styles$s.queryCard, styles$a.content),
34516
+ ..._stylex.props(styles$r.queryCard, styles$b.content),
34412
34517
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
34413
- ..._stylex.props(styles$s.labelWithIcon),
34518
+ ..._stylex.props(styles$r.labelWithIcon),
34414
34519
  children: [/* @__PURE__ */ jsxRuntime.jsx(Icon, {
34415
34520
  name: "database"
34416
34521
  }), /* @__PURE__ */ jsxRuntime.jsx("div", {
34417
34522
  ...{
34418
- className: "mlyb3r6kr mlylyipyv"
34523
+ className: "mlyb3r6kr mlylyipyv mly117nqv4"
34419
34524
  },
34420
34525
  children: rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name
34421
34526
  })]
@@ -34424,7 +34529,7 @@ function Source({
34424
34529
  }
34425
34530
  return null;
34426
34531
  }
34427
- const styles$a = {
34532
+ const styles$b = {
34428
34533
  content: {
34429
34534
  display: "mlyrvj5dj",
34430
34535
  gridAutoFlow: "mly1mt1orb",
@@ -34435,12 +34540,145 @@ const styles$a = {
34435
34540
  $$css: true
34436
34541
  }
34437
34542
  };
34543
+ function DateLiteralEditor({
34544
+ value,
34545
+ setValue,
34546
+ customStyle
34547
+ }) {
34548
+ const [errorMessage, setErrorMessage] = React.useState("");
34549
+ const [open, setOpen] = React.useState(false);
34550
+ const input = React.useRef(null);
34551
+ const picker = React.useRef(null);
34552
+ const isDate2 = value.kind === "date_literal";
34553
+ const date = isDate2 ? value.date_value : value.timestamp_value;
34554
+ const units = isDate2 ? "day" : "second";
34555
+ const onSetValue = (date2) => {
34556
+ if (date2) {
34557
+ setErrorMessage("");
34558
+ if (isDate2) {
34559
+ setValue({
34560
+ kind: "date_literal",
34561
+ date_value: hooks.utc(date2).format(formats["day"])
34562
+ });
34563
+ } else {
34564
+ setValue({
34565
+ kind: "timestamp_literal",
34566
+ timestamp_value: hooks.utc(date2).format(formats["second"])
34567
+ });
34568
+ }
34569
+ } else {
34570
+ setErrorMessage("Invalid date");
34571
+ }
34572
+ };
34573
+ useClickOutside([input, picker], () => {
34574
+ setOpen(false);
34575
+ });
34576
+ return /* @__PURE__ */ jsxRuntime.jsxs(Root2$2, {
34577
+ open,
34578
+ onOpenChange: () => {
34579
+ },
34580
+ children: [/* @__PURE__ */ jsxRuntime.jsx(Trigger$2, {
34581
+ asChild: true,
34582
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", {
34583
+ ..._stylex.props(tokenStyles.main, styles$a.wrapper, customStyle),
34584
+ children: /* @__PURE__ */ jsxRuntime.jsx(DateInput, {
34585
+ value: hooks.utc(date).toDate(),
34586
+ setValue: onSetValue,
34587
+ units,
34588
+ onFocus: () => setOpen(true),
34589
+ customStyle: {
34590
+ ...styles$a.input,
34591
+ ...isDate2 ? styles$a.dateInput : styles$a.timestampInput
34592
+ },
34593
+ forwardRef: input
34594
+ })
34595
+ })
34596
+ }), errorMessage && /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, {
34597
+ errorMessage
34598
+ }), /* @__PURE__ */ jsxRuntime.jsx(Portal$2, {
34599
+ children: /* @__PURE__ */ jsxRuntime.jsx(Content2$2, {
34600
+ align: "center",
34601
+ asChild: true,
34602
+ children: /* @__PURE__ */ jsxRuntime.jsx(DatePicker, {
34603
+ value: hooks.utc(date).toDate(),
34604
+ setValue: onSetValue,
34605
+ units,
34606
+ maxLevel: units,
34607
+ customStyle: styles$a.datePicker,
34608
+ forwardRef: picker
34609
+ })
34610
+ })
34611
+ })]
34612
+ });
34613
+ }
34614
+ const styles$a = {
34615
+ input: {
34616
+ border: "mly1gs6z28",
34617
+ borderWidth: null,
34618
+ borderInlineWidth: null,
34619
+ borderInlineStartWidth: null,
34620
+ borderLeftWidth: null,
34621
+ borderInlineEndWidth: null,
34622
+ borderRightWidth: null,
34623
+ borderBlockWidth: null,
34624
+ borderTopWidth: null,
34625
+ borderBottomWidth: null,
34626
+ borderStyle: null,
34627
+ borderInlineStyle: null,
34628
+ borderInlineStartStyle: null,
34629
+ borderLeftStyle: null,
34630
+ borderInlineEndStyle: null,
34631
+ borderRightStyle: null,
34632
+ borderBlockStyle: null,
34633
+ borderTopStyle: null,
34634
+ borderBottomStyle: null,
34635
+ borderColor: null,
34636
+ borderInlineColor: null,
34637
+ borderInlineStartColor: null,
34638
+ borderLeftColor: null,
34639
+ borderInlineEndColor: null,
34640
+ borderRightColor: null,
34641
+ borderBlockColor: null,
34642
+ borderTopColor: null,
34643
+ borderBottomColor: null,
34644
+ height: "mlyd7y6wv",
34645
+ backgroundColor: "mlyjbqb8w mlytw1abo",
34646
+ $$css: true
34647
+ },
34648
+ dateInput: {
34649
+ width: "mly869kya",
34650
+ $$css: true
34651
+ },
34652
+ timestampInput: {
34653
+ width: "mlynrytzq",
34654
+ $$css: true
34655
+ },
34656
+ wrapper: {
34657
+ $$css: true
34658
+ },
34659
+ datePicker: {
34660
+ display: "mly78zum5",
34661
+ flexDirection: "mlydt5ytf",
34662
+ boxShadow: "mly5n1uv4",
34663
+ backgroundColor: "mly12peec7",
34664
+ borderRadius: "mlyur7f20",
34665
+ borderStartStartRadius: null,
34666
+ borderStartEndRadius: null,
34667
+ borderEndStartRadius: null,
34668
+ borderEndEndRadius: null,
34669
+ borderTopLeftRadius: null,
34670
+ borderTopRightRadius: null,
34671
+ borderBottomLeftRadius: null,
34672
+ borderBottomRightRadius: null,
34673
+ width: "mly1hfn5x7",
34674
+ $$css: true
34675
+ }
34676
+ };
34438
34677
  function LiteralValueEditor({
34439
34678
  value,
34440
34679
  setValue,
34441
34680
  customStyle
34442
34681
  }) {
34443
- const [errorMessage, setErrorMessage] = React__namespace.useState("");
34444
34682
  if (!value) {
34445
34683
  return null;
34446
34684
  }
@@ -34455,31 +34693,18 @@ function LiteralValueEditor({
34455
34693
  label: "false",
34456
34694
  value: "false"
34457
34695
  }],
34458
- onChange: (value2) => setValue(value2 === "true"),
34696
+ onChange: (value2) => setValue({
34697
+ kind: "boolean_literal",
34698
+ boolean_value: value2 === "true"
34699
+ }),
34459
34700
  customStyle
34460
34701
  });
34461
34702
  case "date_literal":
34462
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34463
- ...{
34464
- className: "mly78zum5"
34465
- },
34466
- children: [/* @__PURE__ */ jsxRuntime.jsx("input", {
34467
- value: value.date_value.split(" ")[0],
34468
- type: "date",
34469
- onChange: (event) => {
34470
- if (event.target.valueAsDate) {
34471
- setErrorMessage("");
34472
- setValue({
34473
- date: event.target.valueAsDate,
34474
- granularity: "day"
34475
- });
34476
- } else {
34477
- setErrorMessage("Invalid date");
34478
- }
34479
- }
34480
- }), errorMessage && /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, {
34481
- errorMessage
34482
- })]
34703
+ case "timestamp_literal":
34704
+ return /* @__PURE__ */ jsxRuntime.jsx(DateLiteralEditor, {
34705
+ value,
34706
+ setValue,
34707
+ customStyle
34483
34708
  });
34484
34709
  case "null_literal":
34485
34710
  return /* @__PURE__ */ jsxRuntime.jsx(Token, {
@@ -34489,42 +34714,28 @@ function LiteralValueEditor({
34489
34714
  return /* @__PURE__ */ jsxRuntime.jsx(EditableToken, {
34490
34715
  value: value.number_value,
34491
34716
  type: "number",
34492
- onChange: (value2) => setValue(value2),
34717
+ onChange: (value2) => setValue({
34718
+ kind: "number_literal",
34719
+ number_value: value2
34720
+ }),
34493
34721
  customStyle
34494
34722
  });
34495
34723
  case "string_literal":
34496
34724
  return /* @__PURE__ */ jsxRuntime.jsx(EditableToken, {
34497
34725
  value: value.string_value,
34498
- onChange: (value2) => setValue(value2),
34726
+ onChange: (value2) => setValue({
34727
+ kind: "string_literal",
34728
+ string_value: value2
34729
+ }),
34499
34730
  customStyle
34500
34731
  });
34501
- case "timestamp_literal":
34502
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
34503
- ...{
34504
- className: "mly78zum5"
34505
- },
34506
- children: [/* @__PURE__ */ jsxRuntime.jsx("input", {
34507
- value: value.timestamp_value,
34508
- type: "date",
34509
- onChange: (event) => {
34510
- if (event.target.valueAsDate) {
34511
- setErrorMessage("");
34512
- setValue({
34513
- date: event.target.valueAsDate,
34514
- granularity: "second"
34515
- });
34516
- } else {
34517
- setErrorMessage("Invalid date");
34518
- }
34519
- }
34520
- }), errorMessage && /* @__PURE__ */ jsxRuntime.jsx(ErrorIcon, {
34521
- errorMessage
34522
- })]
34523
- });
34524
34732
  case "filter_expression_literal":
34525
34733
  return /* @__PURE__ */ jsxRuntime.jsx(EditableToken, {
34526
34734
  value: value.filter_expression_value,
34527
- onChange: (value2) => setValue(value2),
34735
+ onChange: (value2) => setValue({
34736
+ kind: "filter_expression_literal",
34737
+ filter_expression_value: value2
34738
+ }),
34528
34739
  customStyle
34529
34740
  });
34530
34741
  }
@@ -35110,34 +35321,22 @@ function Banners({
35110
35321
  function RenderedResult({
35111
35322
  result
35112
35323
  }) {
35113
- const [html2, setHTML] = React__namespace.useState();
35114
- const [rendering, setRendering] = React__namespace.useState(true);
35115
- React__namespace.useEffect(() => {
35116
- let canceled = false;
35117
- setRendering(true);
35118
- const updateResults = async () => {
35119
- const renderer = new render__namespace.HTMLView(document);
35120
- const html22 = await renderer.render(result, {
35121
- dataStyles: {},
35122
- isDrillingEnabled: true
35123
- });
35124
- if (canceled) {
35125
- return;
35126
- }
35127
- setRendering(false);
35128
- setHTML(html22);
35129
- };
35130
- updateResults();
35131
- return () => {
35132
- canceled = true;
35133
- };
35324
+ const [renderer, setRenderer] = React.useState();
35325
+ React.useEffect(() => {
35326
+ const renderer2 = document.createElement("malloy-render");
35327
+ renderer2.malloyResult = result;
35328
+ setRenderer(renderer2);
35134
35329
  }, [result]);
35135
- if (!rendering) return html2 && /* @__PURE__ */ jsxRuntime.jsx(DOMElement, {
35136
- className: "malloy-render_result-wrapper",
35137
- element: html2
35138
- });
35139
- return /* @__PURE__ */ jsxRuntime.jsx(ScrollableArea, {
35140
- children: /* @__PURE__ */ jsxRuntime.jsx("div", {
35330
+ if (renderer) {
35331
+ return /* @__PURE__ */ jsxRuntime.jsx(DOMElement, {
35332
+ element: renderer,
35333
+ style: {
35334
+ overflow: "hidden",
35335
+ height: "100%"
35336
+ }
35337
+ });
35338
+ } else {
35339
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
35141
35340
  ...{
35142
35341
  className: "mly78zum5 mlyl56j7k mly6s0dn4"
35143
35342
  },
@@ -35152,8 +35351,8 @@ function RenderedResult({
35152
35351
  children: "Rendering..."
35153
35352
  })]
35154
35353
  })
35155
- })
35156
- });
35354
+ });
35355
+ }
35157
35356
  }
35158
35357
  function LoadingDisplay({
35159
35358
  onCancel,
@@ -35350,7 +35549,7 @@ function ResultPanel({
35350
35549
  children: [/* @__PURE__ */ jsxRuntime.jsx(Content, {
35351
35550
  value: "Results",
35352
35551
  ...{
35353
- className: "mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619 mlyysyzu8"
35552
+ className: "mlyc7ga6q mlyh8yej3 mly5yr21d mly9f619"
35354
35553
  },
35355
35554
  children: submittedQuery && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35356
35555
  children: [draftQuery && submittedQuery && !queriesAreEqual(draftQuery, submittedQuery.query) && /* @__PURE__ */ jsxRuntime.jsxs("div", {
@@ -35569,15 +35768,21 @@ function flattenFieldsTree(fields, path = []) {
35569
35768
  case "measure":
35570
35769
  case "dimension":
35571
35770
  if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
35572
- return flattenFieldsTree(field.type.element_type.fields.map((dimension) => ({
35771
+ return [{
35772
+ path,
35773
+ field
35774
+ }, ...flattenFieldsTree(field.type.element_type.fields.map((dimension) => ({
35573
35775
  kind: field.kind,
35574
35776
  ...dimension
35575
- })), [...path, field.name]);
35777
+ })), [...path, field.name])];
35576
35778
  } else if (field.type.kind === "record_type") {
35577
- return flattenFieldsTree(field.type.fields.map((dimension) => ({
35779
+ return [{
35780
+ path,
35781
+ field
35782
+ }, ...flattenFieldsTree(field.type.fields.map((dimension) => ({
35578
35783
  kind: field.kind,
35579
35784
  ...dimension
35580
- })), [...path, field.name]);
35785
+ })), [...path, field.name])];
35581
35786
  }
35582
35787
  return [{
35583
35788
  path,
@@ -35619,64 +35824,46 @@ function groupFieldItemsByKind(items) {
35619
35824
  return acc;
35620
35825
  }, {}));
35621
35826
  }
35622
- const getNestName = (segment, rename = "Nest") => {
35623
- const nestNo = segmentNestNo(segment);
35624
- return nestNo > 1 ? `${rename} ${nestNo}` : rename;
35625
- };
35626
35827
  const FIELD_KIND_TO_TITLE = {
35627
35828
  view: "Views",
35628
35829
  measure: "Measures",
35629
35830
  dimension: "Dimensions"
35630
35831
  };
35631
- function useNestOperations(rootQuery) {
35632
- const nestOperations = React.useMemo(() => {
35633
- if (rootQuery) {
35634
- const queryDef = rootQuery.definition;
35635
- if (queryDef instanceof QB.ASTArrowQueryDefinition) {
35636
- return extractNestOperations(queryDef.view);
35637
- }
35638
- }
35639
- return [];
35640
- }, [rootQuery]);
35641
- return nestOperations;
35642
- }
35643
- const extractNestOperations = (view, nestOperations = []) => {
35644
- if (view instanceof QB.ASTArrowViewDefinition) {
35645
- return extractNestOperations(view.view, nestOperations);
35646
- } else if (view instanceof QB.ASTSegmentViewDefinition) {
35647
- view.operations.items.filter((operation) => operation instanceof QB.ASTNestViewOperation).forEach((operation) => {
35648
- const nestView = operation.view.definition;
35649
- nestOperations.push({
35650
- name: operation.name,
35651
- view: nestView
35652
- });
35653
- extractNestOperations(nestView, nestOperations);
35654
- });
35655
- return nestOperations;
35656
- } else if (view instanceof QB.ASTRefinementViewDefinition) {
35657
- return extractNestOperations(view.refinement, nestOperations);
35658
- }
35659
- return nestOperations;
35660
- };
35661
35832
  function useOperations(view, field, path) {
35833
+ const dimensionFields = React.useMemo(() => {
35834
+ const {
35835
+ fields
35836
+ } = getInputSchemaFromViewParent(view);
35837
+ return new Set(flattenFieldsTree(fields).filter(({
35838
+ field: field2
35839
+ }) => field2.kind === "dimension").map(({
35840
+ field: field2
35841
+ }) => field2.name));
35842
+ }, [view]);
35843
+ const measureFields = React.useMemo(() => {
35844
+ const {
35845
+ fields
35846
+ } = getInputSchemaFromViewParent(view);
35847
+ return new Set(flattenFieldsTree(fields).filter(({
35848
+ field: field2
35849
+ }) => field2.kind === "measure").map(({
35850
+ field: field2
35851
+ }) => field2.name));
35852
+ }, [view]);
35662
35853
  const isGroupByAllowed = React.useMemo(() => {
35663
35854
  if (!view) {
35664
35855
  return false;
35665
35856
  }
35666
- const fieldName = field.name;
35667
- const inputSchemaFields = getInputSchemaFromViewParent(view).fields;
35668
- const filteredFieldItems = flattenFieldsTree(inputSchemaFields).filter((item) => item.field.kind === "dimension");
35669
- return filteredFieldItems.some((item) => item.field.name === fieldName && item.path.join(".") === path.join("."));
35670
- }, [view, field, path]);
35857
+ const segment = getSegmentIfPresent(view);
35858
+ return dimensionFields.has(field.name) && !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
35859
+ }, [view, field, path, dimensionFields]);
35671
35860
  const isAggregateAllowed = React.useMemo(() => {
35672
35861
  if (!view) {
35673
35862
  return false;
35674
35863
  }
35675
- const fieldName = field.name;
35676
- const inputSchemaFields = getInputSchemaFromViewParent(view).fields;
35677
- const filteredFieldItems = flattenFieldsTree(inputSchemaFields).filter((item) => item.field.kind === "measure");
35678
- return filteredFieldItems.some((item) => item.field.name === fieldName && item.path.join(".") === path.join("."));
35679
- }, [view, field, path]);
35864
+ const segment = getSegmentIfPresent(view);
35865
+ return measureFields.has(field.name) && !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
35866
+ }, [view, field, path, measureFields]);
35680
35867
  const isFilterAllowed = React.useMemo(() => {
35681
35868
  if (!view) {
35682
35869
  return false;
@@ -35703,280 +35890,119 @@ function useOperations(view, field, path) {
35703
35890
  }
35704
35891
  const FILTERABLE_TYPES = ["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"];
35705
35892
  const ORDERABLE_TYPES = ["string_type", "number_type", "boolean_type", "date_type", "timestamp_type"];
35706
- function OperationDropdownMenuItems({
35707
- view,
35893
+ function FieldTokenWithActions({
35708
35894
  field,
35709
35895
  path,
35710
- withEmptyNest = false
35896
+ viewDef
35711
35897
  }) {
35712
35898
  const {
35713
35899
  rootQuery,
35714
- setQuery
35900
+ setQuery,
35901
+ currentNestView
35715
35902
  } = React.useContext(QueryEditorContext);
35903
+ const view = currentNestView ?? viewDef;
35716
35904
  const {
35717
35905
  isGroupByAllowed,
35718
35906
  isAggregateAllowed,
35719
35907
  isFilterAllowed,
35720
35908
  isOrderByAllowed
35721
35909
  } = useOperations(view, field, path);
35722
- const handleMenuItemClick = (event, operation) => {
35910
+ const [isFilterPopoverOpen, setIsFilterPopoverOpen] = React.useState();
35911
+ const [isTooltipOpen, setIsTooltipOpen] = React.useState(false);
35912
+ const handleAddOperationAction = (operation, filter) => {
35723
35913
  if (field.kind === "dimension" || field.kind === "measure") {
35724
- const segment = view.getOrAddDefaultSegment();
35725
- const currentView = withEmptyNest ? segment.addEmptyNest(getNestName(segment)).view : view;
35726
- const currentSegment = currentView.getOrAddDefaultSegment();
35727
35914
  if (operation === "groupBy" && isGroupByAllowed) {
35728
- addGroupBy(currentView, field, path);
35915
+ addGroupBy(view, field, path);
35729
35916
  } else if (operation === "aggregate" && isAggregateAllowed) {
35730
- addAggregate(currentView, field, path);
35917
+ addAggregate(view, field, path);
35731
35918
  } else if (operation === "orderBy" && isOrderByAllowed) {
35732
- currentSegment.addOrderBy(field.name, "asc");
35919
+ addOrderBy(view, field);
35920
+ } else if (operation === "filter" && isFilterAllowed && filter) {
35921
+ addFilter(view, field, path, filter);
35733
35922
  }
35734
35923
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35735
35924
  }
35736
35925
  };
35737
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
35738
- children: field.kind === "measure" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35739
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35740
- icon: "aggregate",
35741
- label: "Aggregate",
35742
- disabled: !isAggregateAllowed,
35743
- onClick: (event) => handleMenuItemClick(event, "aggregate")
35744
- }), /* @__PURE__ */ jsxRuntime.jsx(FilterDropdownSubmenuItem, {
35745
- view,
35746
- isFilterAllowed,
35747
- field,
35748
- path
35749
- }), /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35750
- icon: "orderBy",
35751
- label: "Order by",
35752
- disabled: !isOrderByAllowed,
35753
- onClick: (event) => handleMenuItemClick(event, "orderBy")
35754
- })]
35755
- }) : field.kind === "dimension" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35756
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35757
- icon: "groupBy",
35758
- label: "Group by",
35759
- disabled: !isGroupByAllowed,
35760
- onClick: (event) => handleMenuItemClick(event, "groupBy")
35761
- }), /* @__PURE__ */ jsxRuntime.jsx(FilterDropdownSubmenuItem, {
35762
- view,
35763
- isFilterAllowed,
35764
- field,
35765
- path
35766
- }), /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35767
- icon: "orderBy",
35768
- label: "Order by",
35769
- disabled: !isOrderByAllowed,
35770
- onClick: (event) => handleMenuItemClick(event, "orderBy")
35771
- })]
35772
- }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
35773
- });
35774
- }
35775
- function FilterDropdownSubmenuItem({
35776
- view,
35777
- isFilterAllowed,
35778
- field,
35779
- path
35780
- }) {
35781
- const {
35782
- rootQuery,
35783
- setQuery
35784
- } = React.useContext(QueryEditorContext);
35785
- const [isOpen, setIsOpen] = React.useState(false);
35786
- const handleFilterSet = (filter) => {
35787
- const segment = view.getOrAddDefaultSegment();
35788
- if (field.kind === "dimension") {
35789
- segment.addWhere(field.name, path, filter);
35790
- } else {
35791
- segment.addHaving(field.name, path, filter);
35792
- }
35793
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35794
- };
35795
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownSubMenuItem, {
35796
- icon: "filter",
35797
- label: "Filter",
35798
- disabled: !isFilterAllowed,
35799
- open: isOpen,
35800
- onOpenChange: setIsOpen,
35801
- children: /* @__PURE__ */ jsxRuntime.jsx(FilterDialog, {
35802
- fieldInfo: field,
35803
- path,
35804
- onFilterApply: handleFilterSet,
35805
- onOpenChange: setIsOpen
35806
- })
35807
- });
35808
- }
35809
- function NestFieldDropdownMenu({
35810
- view,
35811
- field,
35812
- path,
35813
- trigger,
35814
- onOpenChange
35815
- }) {
35816
- const {
35817
- rootQuery,
35818
- setQuery
35819
- } = React.useContext(QueryEditorContext);
35820
- const nestOperations = useNestOperations(rootQuery);
35821
- const nestViewWithinNestQuery = (operation) => {
35822
- const segment = operation.view.getOrAddDefaultSegment();
35823
- const {
35824
- fields
35825
- } = operation.view.getOutputSchema();
35826
- let rename;
35827
- if (fields.find((f2) => f2.name === field.name)) {
35828
- rename = findUniqueFieldName(fields, field.name);
35829
- }
35830
- segment.addNest(field.name, rename);
35831
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35832
- };
35833
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, {
35834
- trigger,
35835
- onOpenChange,
35836
- children: nestOperations.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35837
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, {
35838
- label: "Add to new nested query as..."
35839
- }), /* @__PURE__ */ jsxRuntime.jsx(OperationDropdownMenuItems, {
35840
- view,
35841
- field,
35842
- path,
35843
- withEmptyNest: true
35844
- })]
35845
- }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35846
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, {
35847
- label: "Add to nested query..."
35848
- }), nestOperations.map((operation, index2) => {
35849
- return field.kind === "view" ? /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, {
35850
- label: operation.name,
35851
- onClick: () => nestViewWithinNestQuery(operation)
35852
- }, index2) : /* @__PURE__ */ jsxRuntime.jsxs(DropdownSubMenuItem, {
35853
- label: operation.name,
35854
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, {
35855
- label: `Add to ${operation.name} query as...`
35856
- }), /* @__PURE__ */ jsxRuntime.jsx(OperationDropdownMenuItems, {
35857
- view: operation.view.parent.as.View(),
35858
- field,
35859
- path
35860
- })]
35861
- }, index2);
35862
- })]
35863
- })
35864
- });
35865
- }
35866
- function AddFieldDropdownMenu({
35867
- view,
35868
- field,
35869
- path,
35870
- ...props2
35871
- }) {
35872
- return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, {
35873
- ...props2,
35874
- children: [/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, {
35875
- label: "Add to main query as..."
35876
- }), /* @__PURE__ */ jsxRuntime.jsx(OperationDropdownMenuItems, {
35877
- view,
35878
- field,
35879
- path
35880
- })]
35881
- });
35882
- }
35883
- function FieldTokenWithActions({
35884
- field,
35885
- path
35886
- }) {
35887
- const {
35888
- rootQuery,
35889
- setQuery
35890
- } = React.useContext(QueryEditorContext);
35891
- const [isAddFieldMenuOpen, setIsAddFieldMenuOpen] = React.useState();
35892
- const [isNestFieldMenuOpen, setIsNestFieldMenuOpen] = React.useState();
35893
- const nestViews = useNestOperations(rootQuery);
35894
- const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
35895
- if (!(viewDef instanceof QB.ASTArrowQueryDefinition)) {
35896
- return null;
35897
- }
35898
- const hasAddFieldMenu = field.kind === "measure" || field.kind === "dimension";
35899
- const hasNestFieldMenu = field.kind === "measure" || field.kind === "dimension" || field.kind === "view" && nestViews.length > 0;
35900
- const addViewToMainQuery = () => {
35901
- if (field.kind === "view") {
35902
- if (rootQuery == null ? void 0 : rootQuery.isEmpty()) {
35903
- rootQuery == null ? void 0 : rootQuery.setView(field.name);
35904
- } else {
35905
- addNest(viewDef, field);
35906
- }
35926
+ const handleSetView = () => {
35927
+ if (field.kind === "view" && (rootQuery == null ? void 0 : rootQuery.isEmpty())) {
35928
+ rootQuery == null ? void 0 : rootQuery.setView(field.name);
35907
35929
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35908
35930
  }
35909
35931
  };
35910
- const nestViewWithinMainQuery = () => {
35932
+ const handleAddView = () => {
35911
35933
  if (field.kind === "view") {
35912
- addNest(viewDef, field);
35934
+ addNest(view, field);
35913
35935
  setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35914
35936
  }
35915
35937
  };
35916
- const hoverActions = () => {
35917
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35918
- children: [hasAddFieldMenu ? /* @__PURE__ */ jsxRuntime.jsx(AddFieldDropdownMenu, {
35919
- view: viewDef,
35920
- field,
35938
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
35939
+ field,
35940
+ hoverActions: field.kind === "view" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35941
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35942
+ icon: "insert",
35943
+ disabled: !(rootQuery == null ? void 0 : rootQuery.isEmpty()),
35944
+ onClick: handleSetView,
35945
+ tooltip: "Add view",
35946
+ onTooltipOpenChange: setIsTooltipOpen
35947
+ }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35948
+ icon: "nest",
35949
+ onClick: handleAddView,
35950
+ tooltip: "Add as new nested query",
35951
+ onTooltipOpenChange: setIsTooltipOpen
35952
+ })]
35953
+ }) : field.kind === "measure" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35954
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35955
+ icon: "aggregate",
35956
+ tooltip: "Add as aggregate",
35957
+ disabled: !isAggregateAllowed,
35958
+ onClick: () => handleAddOperationAction("aggregate"),
35959
+ onTooltipOpenChange: setIsTooltipOpen
35960
+ }), /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
35961
+ fieldInfo: field,
35921
35962
  path,
35922
- trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
35923
- variant: "flat",
35924
- size: "compact",
35925
- icon: "insert",
35926
- tooltip: "Add to main query"
35963
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
35964
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35965
+ icon: "filter",
35966
+ tooltip: "Add as filter",
35967
+ disabled: !isFilterAllowed,
35968
+ onTooltipOpenChange: setIsTooltipOpen
35927
35969
  }),
35928
- onOpenChange: (open) => setIsAddFieldMenuOpen(open)
35929
- }) : /* @__PURE__ */ jsxRuntime.jsx(Button, {
35930
- variant: "flat",
35931
- size: "compact",
35932
- icon: "insert",
35933
- onClick: addViewToMainQuery,
35934
- tooltip: "Add to main query"
35935
- }), hasNestFieldMenu ? /* @__PURE__ */ jsxRuntime.jsx(NestFieldDropdownMenu, {
35936
- view: viewDef,
35937
- field,
35970
+ onOpenChange: setIsFilterPopoverOpen
35971
+ }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35972
+ icon: "orderBy",
35973
+ tooltip: "Add as order by",
35974
+ disabled: !isOrderByAllowed,
35975
+ onClick: () => handleAddOperationAction("orderBy"),
35976
+ onTooltipOpenChange: setIsTooltipOpen
35977
+ })]
35978
+ }) : field.kind === "dimension" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
35979
+ children: [/* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35980
+ icon: "groupBy",
35981
+ tooltip: "Add as group by",
35982
+ disabled: !isGroupByAllowed,
35983
+ onClick: () => handleAddOperationAction("groupBy"),
35984
+ onTooltipOpenChange: setIsTooltipOpen
35985
+ }), /* @__PURE__ */ jsxRuntime.jsx(FilterPopover, {
35986
+ fieldInfo: field,
35938
35987
  path,
35939
- trigger: /* @__PURE__ */ jsxRuntime.jsx(Button, {
35940
- variant: "flat",
35941
- size: "compact",
35942
- icon: "nest",
35943
- tooltip: "Add to nested query"
35988
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
35989
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35990
+ icon: "filter",
35991
+ tooltip: "Add as filter",
35992
+ disabled: !isFilterAllowed,
35993
+ onTooltipOpenChange: setIsTooltipOpen
35944
35994
  }),
35945
- onOpenChange: (open) => setIsNestFieldMenuOpen(open)
35946
- }) : /* @__PURE__ */ jsxRuntime.jsx(Button, {
35947
- variant: "flat",
35948
- size: "compact",
35949
- icon: "nest",
35950
- onClick: nestViewWithinMainQuery,
35951
- tooltip: "Add to nested query"
35995
+ onOpenChange: setIsFilterPopoverOpen
35996
+ }), /* @__PURE__ */ jsxRuntime.jsx(ActionButton, {
35997
+ icon: "orderBy",
35998
+ tooltip: "Add as order by",
35999
+ disabled: !isOrderByAllowed,
36000
+ onClick: () => handleAddOperationAction("orderBy"),
36001
+ onTooltipOpenChange: setIsTooltipOpen
35952
36002
  })]
35953
- });
35954
- };
35955
- return hasAddFieldMenu ? /* @__PURE__ */ jsxRuntime.jsx(AddFieldDropdownMenu, {
35956
- view: viewDef,
35957
- field,
35958
- path,
35959
- trigger: /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
35960
- field,
35961
- hoverActionsVisible: isAddFieldMenuOpen || isNestFieldMenuOpen,
35962
- hoverActions: hoverActions(),
35963
- asButtonTrigger: true
35964
- }),
35965
- onOpenChange: (open) => setIsAddFieldMenuOpen(open),
35966
- tooltip: /* @__PURE__ */ jsxRuntime.jsx(FieldHoverCard, {
35967
- field,
35968
- path
35969
- }),
35970
- tooltipProps: {
35971
- side: "right",
35972
- align: "start",
35973
- alignOffset: 28
35974
- }
35975
- }) : /* @__PURE__ */ jsxRuntime.jsx(FieldToken, {
35976
- field,
35977
- onClick: addViewToMainQuery,
35978
- hoverActions: hoverActions(),
35979
- hoverActionsVisible: isAddFieldMenuOpen || isNestFieldMenuOpen,
36003
+ }) : null,
36004
+ onClick: field.kind === "dimension" && isGroupByAllowed ? () => handleAddOperationAction("groupBy") : field.kind === "measure" && isAggregateAllowed ? () => handleAddOperationAction("aggregate") : field.kind === "view" ? () => handleAddView() : void 0,
36005
+ hoverActionsVisible: isFilterPopoverOpen || isTooltipOpen,
35980
36006
  tooltip: /* @__PURE__ */ jsxRuntime.jsx(FieldHoverCard, {
35981
36007
  field,
35982
36008
  path
@@ -35988,6 +36014,30 @@ function FieldTokenWithActions({
35988
36014
  }
35989
36015
  });
35990
36016
  }
36017
+ function ActionButton({
36018
+ tooltip,
36019
+ onTooltipOpenChange,
36020
+ ...props2
36021
+ }) {
36022
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, {
36023
+ delayDuration: 300,
36024
+ onOpenChange: onTooltipOpenChange,
36025
+ children: [/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, {
36026
+ asChild: true,
36027
+ children: /* @__PURE__ */ jsxRuntime.jsx(Button, {
36028
+ variant: "flat",
36029
+ size: "compact",
36030
+ ...props2
36031
+ })
36032
+ }), /* @__PURE__ */ jsxRuntime.jsx(TooltipPortal, {
36033
+ children: /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, {
36034
+ sideOffset: 8,
36035
+ ..._stylex.props(fontStyles.body, tooltipStyles.default),
36036
+ children: tooltip
36037
+ })
36038
+ })]
36039
+ });
36040
+ }
35991
36041
  const FIELD_KIND_ORDER = ["dimension", "measure", "view"];
35992
36042
  function SearchResultList({
35993
36043
  source,
@@ -35999,6 +36049,13 @@ function SearchResultList({
35999
36049
  items: groupFieldItemsByPath(source, group.items)
36000
36050
  }));
36001
36051
  }, [source, items]);
36052
+ const {
36053
+ rootQuery
36054
+ } = React__namespace.useContext(QueryEditorContext);
36055
+ const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
36056
+ if (!(viewDef instanceof QB.ASTArrowQueryDefinition)) {
36057
+ return null;
36058
+ }
36002
36059
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
36003
36060
  ...{
36004
36061
  className: "mly78zum5 mlydt5ytf mly1cy8zhl mlyou54vl mlye8ttls mly10cdfl8"
@@ -36033,7 +36090,8 @@ function SearchResultList({
36033
36090
  path
36034
36091
  }) => /* @__PURE__ */ jsxRuntime.jsx(FieldTokenWithActions, {
36035
36092
  field,
36036
- path
36093
+ path,
36094
+ viewDef
36037
36095
  }, [...path, field.name].join(".")))))
36038
36096
  })]
36039
36097
  }, group))]
@@ -36076,6 +36134,13 @@ function FieldGroupList({
36076
36134
  group
36077
36135
  }) => group === fieldGroupType)) == null ? void 0 : _a2.items) ?? [];
36078
36136
  }, [fieldGroupsByKindByPath, fieldGroupType]);
36137
+ const {
36138
+ rootQuery
36139
+ } = React__namespace.useContext(QueryEditorContext);
36140
+ const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
36141
+ if (!(viewDef instanceof QB.ASTArrowQueryDefinition)) {
36142
+ return null;
36143
+ }
36079
36144
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
36080
36145
  ...{
36081
36146
  className: "mly78zum5 mlydt5ytf mly167g77z"
@@ -36090,7 +36155,8 @@ function FieldGroupList({
36090
36155
  path
36091
36156
  }) => /* @__PURE__ */ jsxRuntime.jsx(FieldTokenWithActions, {
36092
36157
  field,
36093
- path
36158
+ path,
36159
+ viewDef
36094
36160
  }, [...path, field.name].join(".")))
36095
36161
  }, item.groupPath.join(".")))
36096
36162
  })