@databrainhq/plugin 0.9.10 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -4961,7 +4961,7 @@ const leave$2 = "_leave_ib5g4_85";
4961
4961
  const leaveFrom$2 = "_leaveFrom_ib5g4_91";
4962
4962
  const leaveTo$2 = "_leaveTo_ib5g4_97";
4963
4963
  const notAvailable = "_notAvailable_ib5g4_103";
4964
- const option$1 = "_option_ib5g4_109";
4964
+ const option$2 = "_option_ib5g4_109";
4965
4965
  const activeOption = "_activeOption_ib5g4_115";
4966
4966
  const optionSelected = "_optionSelected_ib5g4_121";
4967
4967
  const inactiveOption = "_inactiveOption_ib5g4_127";
@@ -4997,7 +4997,7 @@ var style = {
4997
4997
  leaveFrom: leaveFrom$2,
4998
4998
  leaveTo: leaveTo$2,
4999
4999
  notAvailable,
5000
- option: option$1,
5000
+ option: option$2,
5001
5001
  activeOption,
5002
5002
  optionSelected,
5003
5003
  inactiveOption,
@@ -5806,13 +5806,13 @@ const ChartConfig = ({
5806
5806
  }), /* @__PURE__ */ jsxs("form", {
5807
5807
  onSubmit: handleSubmit(onSubmitOptions),
5808
5808
  className: styles$K.form,
5809
- children: [["funnel", "guage", "boxplot", "table"].includes(chartType2) ? /* @__PURE__ */ jsx(Select, {
5809
+ children: [["funnel", "guage", "boxplot"].includes(chartType2) ? /* @__PURE__ */ jsx(Select, {
5810
5810
  label: "Measure",
5811
5811
  options: options2,
5812
5812
  onChange: setMeasure,
5813
5813
  value: measure
5814
5814
  }) : /* @__PURE__ */ jsx(HookMultiSelect, {
5815
- label: chartType2 === "row" ? "X-axis" : "Y-axis",
5815
+ label: chartType2 === "row" ? "X-axis" : chartType2 === "table" ? "Measure" : "Y-axis",
5816
5816
  name: "yAxisList",
5817
5817
  options: options2,
5818
5818
  defaultValue: options2.map((option2) => option2.value),
@@ -7324,8 +7324,8 @@ const floatingText = "_floatingText_u60ky_39";
7324
7324
  const normalText = "_normalText_u60ky_47";
7325
7325
  const dropdown$1 = "_dropdown_u60ky_55";
7326
7326
  const options$1 = "_options_u60ky_63";
7327
- const checkedOption$1 = "_checkedOption_u60ky_71";
7328
- const option = "_option_u60ky_63";
7327
+ const checkedOption$2 = "_checkedOption_u60ky_71";
7328
+ const option$1 = "_option_u60ky_63";
7329
7329
  const icon$1 = "_icon_u60ky_87";
7330
7330
  const text$2 = "_text_u60ky_95";
7331
7331
  const search = "_search_u60ky_103";
@@ -7342,8 +7342,8 @@ var styles$z = {
7342
7342
  normalText,
7343
7343
  dropdown: dropdown$1,
7344
7344
  options: options$1,
7345
- checkedOption: checkedOption$1,
7346
- option,
7345
+ checkedOption: checkedOption$2,
7346
+ option: option$1,
7347
7347
  icon: icon$1,
7348
7348
  text: text$2,
7349
7349
  search,
@@ -86704,27 +86704,38 @@ const FilterField = ({
86704
86704
  })
86705
86705
  });
86706
86706
  };
86707
- const container$9 = "_container_dkf3r_1";
86708
- const form$1 = "_form_dkf3r_7";
86709
- const filterHeader = "_filterHeader_dkf3r_13";
86710
- const titleContent = "_titleContent_dkf3r_19";
86711
- const title = "_title_dkf3r_19";
86712
- const buttons = "_buttons_dkf3r_31";
86713
- const apply = "_apply_dkf3r_37";
86714
- const applyIcon = "_applyIcon_dkf3r_43";
86715
- const reset = "_reset_dkf3r_49";
86716
- const filterFields = "_filterFields_dkf3r_55";
86717
- const filterDropdown$1 = "_filterDropdown_dkf3r_61";
86718
- const filters = "_filters_dkf3r_67";
86719
- const filterItem = "_filterItem_dkf3r_73";
86720
- const filterItemOperator = "_filterItemOperator_dkf3r_79";
86721
- const remove = "_remove_dkf3r_85";
86722
- const filterCol = "_filterCol_dkf3r_91";
86723
- const filterText = "_filterText_dkf3r_97";
86724
- const smallText = "_smallText_dkf3r_103";
86725
- const numberField = "_numberField_dkf3r_111";
86726
- const numberFieldWrapper = "_numberFieldWrapper_dkf3r_119";
86727
- const numberFieldLabel = "_numberFieldLabel_dkf3r_127";
86707
+ const container$9 = "_container_13zds_1";
86708
+ const form$1 = "_form_13zds_7";
86709
+ const filterHeader = "_filterHeader_13zds_13";
86710
+ const titleContent = "_titleContent_13zds_19";
86711
+ const title = "_title_13zds_19";
86712
+ const buttons = "_buttons_13zds_31";
86713
+ const apply = "_apply_13zds_37";
86714
+ const applyIcon = "_applyIcon_13zds_43";
86715
+ const reset = "_reset_13zds_49";
86716
+ const filterFields = "_filterFields_13zds_55";
86717
+ const AddFilter$1 = "_AddFilter_13zds_61";
86718
+ const filterDropdown$1 = "_filterDropdown_13zds_67";
86719
+ const filters = "_filters_13zds_73";
86720
+ const filterItem = "_filterItem_13zds_79";
86721
+ const filterItemOperator = "_filterItemOperator_13zds_85";
86722
+ const remove = "_remove_13zds_91";
86723
+ const filterCol = "_filterCol_13zds_97";
86724
+ const filterText = "_filterText_13zds_103";
86725
+ const smallText = "_smallText_13zds_109";
86726
+ const numberField = "_numberField_13zds_117";
86727
+ const numberFieldWrapper = "_numberFieldWrapper_13zds_125";
86728
+ const numberFieldLabel = "_numberFieldLabel_13zds_133";
86729
+ const numberFieldLabelText = "_numberFieldLabelText_13zds_141";
86730
+ const numberFieldLabelSelectText = "_numberFieldLabelSelectText_13zds_149";
86731
+ const numberFieldButtonClass = "_numberFieldButtonClass_13zds_157";
86732
+ const numberFieldLabelMenuClass = "_numberFieldLabelMenuClass_13zds_165";
86733
+ const checkedOption$1 = "_checkedOption_13zds_173";
86734
+ const option = "_option_13zds_181";
86735
+ const addFilterMenu = "_addFilterMenu_13zds_189";
86736
+ const appliedFilterTag = "_appliedFilterTag_13zds_197";
86737
+ const appliedfilters = "_appliedfilters_13zds_205";
86738
+ const textBold = "_textBold_13zds_213";
86728
86739
  var styles$s = {
86729
86740
  container: container$9,
86730
86741
  form: form$1,
@@ -86736,6 +86747,7 @@ var styles$s = {
86736
86747
  applyIcon,
86737
86748
  reset,
86738
86749
  filterFields,
86750
+ AddFilter: AddFilter$1,
86739
86751
  filterDropdown: filterDropdown$1,
86740
86752
  filters,
86741
86753
  filterItem,
@@ -86746,7 +86758,150 @@ var styles$s = {
86746
86758
  smallText,
86747
86759
  numberField,
86748
86760
  numberFieldWrapper,
86749
- numberFieldLabel
86761
+ numberFieldLabel,
86762
+ numberFieldLabelText,
86763
+ numberFieldLabelSelectText,
86764
+ numberFieldButtonClass,
86765
+ numberFieldLabelMenuClass,
86766
+ checkedOption: checkedOption$1,
86767
+ option,
86768
+ addFilterMenu,
86769
+ appliedFilterTag,
86770
+ appliedfilters,
86771
+ textBold
86772
+ };
86773
+ const NumberFilterField = ({
86774
+ setAppliedFilters,
86775
+ column: column2,
86776
+ defaultValues
86777
+ }) => {
86778
+ const [minMax, setMinMax] = useState(defaultValues || {
86779
+ min: 0,
86780
+ max: 1e6
86781
+ });
86782
+ return /* @__PURE__ */ jsx(Fragment, {
86783
+ children: /* @__PURE__ */ jsx(PopoverMenu, {
86784
+ menuClass: styles$s.numberFieldLabelMenuClass,
86785
+ button: /* @__PURE__ */ jsxs("div", {
86786
+ className: styles$s.numberField,
86787
+ children: [/* @__PURE__ */ jsxs("div", {
86788
+ className: styles$s.numberFieldLabelText,
86789
+ children: [/* @__PURE__ */ jsx(Text, {
86790
+ variant: "p",
86791
+ styleClass: "font-14",
86792
+ className: styles$s.numberFieldLabel,
86793
+ children: column2.label || column2.name
86794
+ }), /* @__PURE__ */ jsx(Text, {
86795
+ variant: "p",
86796
+ styleClass: "font-14",
86797
+ className: styles$s.numberFieldLabelSelectText,
86798
+ children: "Select an option"
86799
+ })]
86800
+ }), /* @__PURE__ */ jsx(materialSymbolsKeyboardArrowDown, {})]
86801
+ }),
86802
+ buttonClass: styles$s.numberFieldButtonClass,
86803
+ children: /* @__PURE__ */ jsxs("div", {
86804
+ className: styles$s.numberFieldWrapper,
86805
+ children: [/* @__PURE__ */ jsx(InputField, {
86806
+ label: "minimum",
86807
+ type: "number",
86808
+ value: minMax.min,
86809
+ onChange: ({
86810
+ target: {
86811
+ value
86812
+ }
86813
+ }) => {
86814
+ setMinMax((prev) => ({
86815
+ ...prev,
86816
+ min: Number(value)
86817
+ }));
86818
+ setAppliedFilters((prev) => {
86819
+ const field2 = {
86820
+ column: column2.name,
86821
+ operator: "BETWEEN",
86822
+ value: `${value} AND ${minMax.max}`,
86823
+ as: column2.as,
86824
+ defaultValues: {
86825
+ min: Number(value),
86826
+ max: minMax.max
86827
+ }
86828
+ };
86829
+ const index2 = prev.findIndex((f2) => f2.column === column2.name);
86830
+ if (index2 === -1)
86831
+ return [...prev, field2];
86832
+ const updated = [...prev];
86833
+ updated[index2] = field2;
86834
+ return updated;
86835
+ });
86836
+ }
86837
+ }), /* @__PURE__ */ jsx(InputField, {
86838
+ label: "maximum",
86839
+ type: "number",
86840
+ value: minMax.max,
86841
+ onChange: ({
86842
+ target: {
86843
+ value
86844
+ }
86845
+ }) => {
86846
+ setMinMax((prev) => ({
86847
+ ...prev,
86848
+ max: Number(value)
86849
+ }));
86850
+ setAppliedFilters((prev) => {
86851
+ const field2 = {
86852
+ column: column2.name,
86853
+ operator: "BETWEEN",
86854
+ value: `${minMax.min} AND ${value}`,
86855
+ as: column2.as,
86856
+ defaultValues: {
86857
+ max: Number(value),
86858
+ min: minMax.min
86859
+ }
86860
+ };
86861
+ const index2 = prev.findIndex((f2) => f2.column === column2.name);
86862
+ if (index2 === -1)
86863
+ return [...prev, field2];
86864
+ const updated = [...prev];
86865
+ updated[index2] = field2;
86866
+ return updated;
86867
+ });
86868
+ }
86869
+ })]
86870
+ })
86871
+ })
86872
+ });
86873
+ };
86874
+ const AddFilter = ({
86875
+ columnList,
86876
+ filterList,
86877
+ setFilterList
86878
+ }) => {
86879
+ return /* @__PURE__ */ jsx(Fragment, {
86880
+ children: !!columnList.length && /* @__PURE__ */ jsx(PopoverMenu, {
86881
+ button: /* @__PURE__ */ jsx(Button, {
86882
+ variant: "outlined",
86883
+ type: "button",
86884
+ size: "small",
86885
+ children: "Add Filter"
86886
+ }),
86887
+ position: "bottom-left",
86888
+ children: /* @__PURE__ */ jsx("div", {
86889
+ className: styles$s.addFilterMenu,
86890
+ children: columnList.map((col) => {
86891
+ const isSelected = !!filterList.find((opt) => opt.name === col.name);
86892
+ return /* @__PURE__ */ jsxs(Button, {
86893
+ variant: "secondary",
86894
+ onClick: () => {
86895
+ const updatedOptions = isSelected ? filterList.filter((opt) => opt.name !== col.name) : [...filterList, col];
86896
+ setFilterList(updatedOptions);
86897
+ },
86898
+ className: isSelected ? styles$s.checkedOption : styles$s.option,
86899
+ children: [isSelected ? /* @__PURE__ */ jsx(materialSymbolsCheckBox, {}) : /* @__PURE__ */ jsx(materialSymbolsCheckBoxOutlineBlank, {}), col.label || col.name]
86900
+ });
86901
+ })
86902
+ })
86903
+ })
86904
+ });
86750
86905
  };
86751
86906
  const groupArray = (array, key) => {
86752
86907
  return array.reduce((acc, item) => {
@@ -95063,20 +95218,20 @@ var zt = function(t3) {
95063
95218
  } }]), a4;
95064
95219
  }(), $t = "input", Gt = "navigate";
95065
95220
  var reactDatepicker = "";
95066
- const datePickerContainer = "_datePickerContainer_10xj7_1";
95067
- const buttonWrapper = "_buttonWrapper_10xj7_9";
95068
- const datePickerCalendarWrapper = "_datePickerCalendarWrapper_10xj7_17";
95069
- const label$1 = "_label_10xj7_25";
95070
- const text = "_text_10xj7_31";
95071
- const button$4 = "_button_10xj7_9";
95072
- const datePickerCalContainer = "_datePickerCalContainer_10xj7_43";
95073
- const datePickerOptionsWrapper = "_datePickerOptionsWrapper_10xj7_49";
95074
- const datePickerOption = "_datePickerOption_10xj7_49";
95075
- const datePickerCalendar = "_datePickerCalendar_10xj7_17";
95076
- const datePickerCalendarHeader = "_datePickerCalendarHeader_10xj7_73";
95077
- const checkedOption = "_checkedOption_10xj7_81";
95078
- const datePickerCalFooter = "_datePickerCalFooter_10xj7_89";
95079
- const dayClassName = "_dayClassName_10xj7_97";
95221
+ const datePickerContainer = "_datePickerContainer_1dons_1";
95222
+ const buttonWrapper = "_buttonWrapper_1dons_9";
95223
+ const datePickerCalendarWrapper = "_datePickerCalendarWrapper_1dons_17";
95224
+ const label$1 = "_label_1dons_25";
95225
+ const text = "_text_1dons_31";
95226
+ const button$4 = "_button_1dons_9";
95227
+ const datePickerCalContainer = "_datePickerCalContainer_1dons_43";
95228
+ const datePickerOptionsWrapper = "_datePickerOptionsWrapper_1dons_49";
95229
+ const datePickerOption = "_datePickerOption_1dons_49";
95230
+ const datePickerCalendar = "_datePickerCalendar_1dons_17";
95231
+ const datePickerCalendarHeader = "_datePickerCalendarHeader_1dons_73";
95232
+ const checkedOption = "_checkedOption_1dons_81";
95233
+ const datePickerCalFooter = "_datePickerCalFooter_1dons_89";
95234
+ const dayClassName = "_dayClassName_1dons_97";
95080
95235
  var styles$r = {
95081
95236
  datePickerContainer,
95082
95237
  buttonWrapper,
@@ -95146,12 +95301,12 @@ const options = [{
95146
95301
  }];
95147
95302
  const DateRangePicker = ({
95148
95303
  label: fieldLabel2,
95149
- setTimeGrainValue,
95150
- timeGrainValue,
95151
- onChange
95304
+ onChange,
95305
+ defaultValues
95152
95306
  }) => {
95153
- const [startDate, setStartDate] = useState(new Date());
95154
- const [endDate, setEndDate] = useState(new Date());
95307
+ const [timeGrainValue, setTimeGrainValue] = useState((defaultValues == null ? void 0 : defaultValues.timeGrainValue) || "");
95308
+ const [startDate, setStartDate] = useState(defaultValues == null ? void 0 : defaultValues.startDate);
95309
+ const [endDate, setEndDate] = useState(defaultValues == null ? void 0 : defaultValues.endDate);
95155
95310
  const datePickerRef = useRef(null);
95156
95311
  const handleOptionClick = ({
95157
95312
  endOffset,
@@ -95186,9 +95341,18 @@ const DateRangePicker = ({
95186
95341
  (_a2 = datePickerRef.current) == null ? void 0 : _a2.click();
95187
95342
  };
95188
95343
  useEffect(() => {
95189
- const startDateFormat = startDate.toISOString().slice(0, 10);
95190
- const endDateFormat = endDate.toISOString().slice(0, 10);
95191
- onChange == null ? void 0 : onChange(`${startDateFormat} - ${endDateFormat}`);
95344
+ const startDateFormat = startDate == null ? void 0 : startDate.toISOString().slice(0, 10);
95345
+ const endDateFormat = endDate == null ? void 0 : endDate.toISOString().slice(0, 10);
95346
+ if (startDateFormat && endDateFormat) {
95347
+ onChange == null ? void 0 : onChange({
95348
+ value: `${startDateFormat} - ${endDateFormat}`,
95349
+ startDate,
95350
+ endDate,
95351
+ timeGrainValue
95352
+ });
95353
+ } else {
95354
+ onChange == null ? void 0 : onChange(void 0);
95355
+ }
95192
95356
  }, [startDate, endDate]);
95193
95357
  return /* @__PURE__ */ jsx(Fragment, {
95194
95358
  children: /* @__PURE__ */ jsx(PopoverMenu, {
@@ -95202,11 +95366,11 @@ const DateRangePicker = ({
95202
95366
  styleClass: "font-14",
95203
95367
  className: styles$r.label,
95204
95368
  children: fieldLabel2
95205
- }), /* @__PURE__ */ jsxs(Text, {
95369
+ }), /* @__PURE__ */ jsx(Text, {
95206
95370
  variant: "p",
95207
95371
  styleClass: "font-14",
95208
95372
  className: styles$r.text,
95209
- children: [startDate.toDateString(), " - ", endDate.toDateString()]
95373
+ children: startDate && endDate ? `${startDate.toDateString()} - ${endDate.toDateString()}` : "Select"
95210
95374
  }), /* @__PURE__ */ jsx(materialSymbolsKeyboardArrowDown, {})]
95211
95375
  }),
95212
95376
  children: /* @__PURE__ */ jsxs("div", {
@@ -95237,7 +95401,7 @@ const DateRangePicker = ({
95237
95401
  selected: startDate,
95238
95402
  onChange: (date) => {
95239
95403
  const startDateFormat = date.toISOString().slice(0, 10);
95240
- const endDateFormat = endDate.toISOString().slice(0, 10);
95404
+ const endDateFormat = endDate == null ? void 0 : endDate.toISOString().slice(0, 10);
95241
95405
  setTimeGrainValue(`${startDateFormat} - ${endDateFormat}`);
95242
95406
  setStartDate(date);
95243
95407
  },
@@ -95247,7 +95411,7 @@ const DateRangePicker = ({
95247
95411
  }), /* @__PURE__ */ jsx(zt, {
95248
95412
  selected: endDate,
95249
95413
  onChange: (date) => {
95250
- const startDateFormat = startDate.toISOString().slice(0, 10);
95414
+ const startDateFormat = startDate == null ? void 0 : startDate.toISOString().slice(0, 10);
95251
95415
  const endDateFormat = date.toISOString().slice(0, 10);
95252
95416
  setTimeGrainValue(`${startDateFormat} - ${endDateFormat}`);
95253
95417
  setEndDate(date);
@@ -95298,14 +95462,10 @@ const GlobalFilters = ({
95298
95462
  companyId,
95299
95463
  renderAdditionalHeaderContent,
95300
95464
  externalDashboardId,
95301
- appliedfilters,
95465
+ appliedfilters: appliedfilters2,
95302
95466
  setAppliedFilters
95303
95467
  }) => {
95304
- const [timeGrainValue, setTimeGrainValue] = useState("");
95305
- const [minMax, setMinMax] = useState({
95306
- min: 100,
95307
- max: 1e3
95308
- });
95468
+ const [filterList, setFilterList] = useState([]);
95309
95469
  const resetFilters = () => {
95310
95470
  setAppliedFilters([]);
95311
95471
  onApply({
@@ -95315,7 +95475,7 @@ const GlobalFilters = ({
95315
95475
  };
95316
95476
  const handleSubmit = (e3) => {
95317
95477
  e3.preventDefault();
95318
- const filterColumns = appliedfilters.map((field2) => {
95478
+ const filterColumns = appliedfilters2.map((field2) => {
95319
95479
  const col = {
95320
95480
  column: field2.column,
95321
95481
  operator: field2.operator,
@@ -95338,14 +95498,23 @@ const GlobalFilters = ({
95338
95498
  filters: filterColumns
95339
95499
  });
95340
95500
  };
95341
- const getSelectedOption = useCallback((col) => {
95501
+ const getSelectedOption = useCallback((col, type3) => {
95342
95502
  var _a2;
95343
- const colValue = ((_a2 = appliedfilters.find((filter2) => filter2.column === col)) == null ? void 0 : _a2.value) || "";
95503
+ const colValue = ((_a2 = appliedfilters2.find((filter2) => filter2.column === col)) == null ? void 0 : _a2.value) || "";
95504
+ if (type3 === "string") {
95505
+ if (Array.isArray(colValue)) {
95506
+ return colValue.map((v4) => ({
95507
+ label: v4,
95508
+ value: v4
95509
+ }));
95510
+ }
95511
+ return [];
95512
+ }
95344
95513
  return {
95345
95514
  label: colValue,
95346
95515
  value: colValue
95347
95516
  };
95348
- }, [appliedfilters]);
95517
+ }, [appliedfilters2]);
95349
95518
  const {
95350
95519
  data,
95351
95520
  isLoading
@@ -95372,6 +95541,11 @@ const GlobalFilters = ({
95372
95541
  return `\`${name}\``;
95373
95542
  return `"${name}"`;
95374
95543
  };
95544
+ useEffect(() => {
95545
+ if (filters2[0].columns.length) {
95546
+ setFilterList(filters2[0].columns.filter((col) => col.isDefault));
95547
+ }
95548
+ }, [filters2]);
95375
95549
  return /* @__PURE__ */ jsx(Fragment, {
95376
95550
  children: (data == null ? void 0 : data.companyIntegrations.length) && !isLoading && /* @__PURE__ */ jsx("div", {
95377
95551
  className: styles$s.container,
@@ -95392,98 +95566,31 @@ const GlobalFilters = ({
95392
95566
  })
95393
95567
  }), /* @__PURE__ */ jsx("div", {
95394
95568
  className: styles$s.filterFields,
95395
- children: filters2[0].columns.map((col) => /* @__PURE__ */ jsx(Fragment, {
95396
- children: /* @__PURE__ */ jsxs("div", {
95397
- className: styles$s.filterCol,
95398
- children: [/* @__PURE__ */ jsx("div", {
95569
+ children: filterList.map((col) => {
95570
+ var _a2, _b2;
95571
+ return /* @__PURE__ */ jsx(Fragment, {
95572
+ children: /* @__PURE__ */ jsxs("div", {
95399
95573
  className: styles$s.filterDropdown,
95400
- children: col.as === "date" ? /* @__PURE__ */ jsx(Fragment, {
95574
+ children: [col.as === "date" && /* @__PURE__ */ jsx(Fragment, {
95401
95575
  children: /* @__PURE__ */ jsx(DateRangePicker, {
95402
- label: col.name,
95403
- setTimeGrainValue,
95404
- timeGrainValue,
95576
+ label: col.label || col.name,
95577
+ defaultValues: (_a2 = appliedfilters2.find((filter2) => filter2.column === col.name)) == null ? void 0 : _a2.defaultValues,
95405
95578
  onChange: (option2) => {
95406
- setAppliedFilters((prev) => {
95407
- const isTimeStamp = col.as.toLowerCase() !== "date";
95408
- const value = getTimeFilterValue({
95409
- timeGrainValue: option2,
95410
- isTimeStamp,
95411
- col: getColumnString(col.name),
95412
- database: integrationName
95413
- });
95414
- const field2 = {
95415
- column: col.name,
95416
- operator: "=",
95417
- value,
95418
- as: col.as
95419
- };
95420
- const index2 = prev.findIndex((f2) => f2.column === col.name);
95421
- if (index2 === -1)
95422
- return [...prev, field2];
95423
- const updated = [...prev];
95424
- updated[index2] = field2;
95425
- return updated;
95426
- });
95427
- }
95428
- })
95429
- }) : col.as === "number" ? /* @__PURE__ */ jsxs("div", {
95430
- className: styles$s.numberField,
95431
- children: [/* @__PURE__ */ jsx(Text, {
95432
- styleClass: "custom",
95433
- variant: "p",
95434
- className: styles$s.numberFieldLabel,
95435
- children: col.name
95436
- }), /* @__PURE__ */ jsxs("div", {
95437
- className: styles$s.numberFieldWrapper,
95438
- children: [/* @__PURE__ */ jsx(InputField, {
95439
- label: "min",
95440
- labelVariant: "floating",
95441
- type: "number",
95442
- defaultValue: 0,
95443
- onChange: ({
95444
- target: {
95445
- value
95446
- }
95447
- }) => {
95448
- setMinMax((prev) => ({
95449
- ...prev,
95450
- min: Number(value)
95451
- }));
95452
- setAppliedFilters((prev) => {
95453
- const field2 = {
95454
- column: col.name,
95455
- operator: "BETWEEN",
95456
- value: `${value} AND ${minMax.max}`,
95457
- as: col.as
95458
- };
95459
- const index2 = prev.findIndex((f2) => f2.column === col.name);
95460
- if (index2 === -1)
95461
- return [...prev, field2];
95462
- const updated = [...prev];
95463
- updated[index2] = field2;
95464
- return updated;
95465
- });
95466
- }
95467
- }), /* @__PURE__ */ jsx(InputField, {
95468
- label: "max",
95469
- labelVariant: "floating",
95470
- type: "number",
95471
- defaultValue: 0,
95472
- onChange: ({
95473
- target: {
95474
- value
95475
- }
95476
- }) => {
95477
- setMinMax((prev) => ({
95478
- ...prev,
95479
- max: Number(value)
95480
- }));
95579
+ if (option2)
95481
95580
  setAppliedFilters((prev) => {
95581
+ const isTimeStamp = col.as.toLowerCase() !== "date";
95582
+ const value = getTimeFilterValue({
95583
+ timeGrainValue: option2.value,
95584
+ isTimeStamp,
95585
+ col: getColumnString(col.name),
95586
+ database: integrationName
95587
+ });
95482
95588
  const field2 = {
95483
95589
  column: col.name,
95484
- operator: "BETWEEN",
95485
- value: `${minMax.min} AND ${value}`,
95486
- as: col.as
95590
+ operator: "=",
95591
+ value,
95592
+ as: col.as,
95593
+ defaultValues: option2
95487
95594
  };
95488
95595
  const index2 = prev.findIndex((f2) => f2.column === col.name);
95489
95596
  if (index2 === -1)
@@ -95492,22 +95599,52 @@ const GlobalFilters = ({
95492
95599
  updated[index2] = field2;
95493
95600
  return updated;
95494
95601
  });
95495
- }
95496
- })]
95497
- })]
95498
- }) : /* @__PURE__ */ jsx(FilterDropDown, {
95602
+ }
95603
+ })
95604
+ }), col.as === "number" && /* @__PURE__ */ jsx(NumberFilterField, {
95605
+ setAppliedFilters,
95606
+ column: col,
95607
+ defaultValues: (_b2 = appliedfilters2.find((filter2) => filter2.column === col.name)) == null ? void 0 : _b2.defaultValues
95608
+ }), col.as === "string" && /* @__PURE__ */ jsx(MultiFilterDropdown, {
95609
+ filter: {
95610
+ tableName: filters2[0].tableName,
95611
+ columnName: col.name
95612
+ },
95613
+ companyId,
95614
+ selectedOptions: getSelectedOption(col.name, "string") || [],
95615
+ autoSelected: false,
95616
+ onChange: (options2) => setAppliedFilters((prev) => {
95617
+ const field2 = {
95618
+ column: col.name,
95619
+ operator: "IN",
95620
+ value: options2.map((v4) => v4.value),
95621
+ as: col.as
95622
+ };
95623
+ const index2 = prev.findIndex((f2) => f2.column === col.name);
95624
+ if (index2 === -1)
95625
+ return [...prev, field2];
95626
+ const updated = [...prev];
95627
+ updated[index2] = field2;
95628
+ return updated;
95629
+ }),
95630
+ isSearchEnabled: true,
95631
+ integrationId,
95632
+ integrationName,
95633
+ label: col.label || col.name
95634
+ }), col.as === "default" || col.as === "boolean" ? /* @__PURE__ */ jsx(FilterDropDown, {
95499
95635
  filter: {
95500
95636
  tableName: filters2[0].tableName,
95501
95637
  columnName: col.name
95502
95638
  },
95503
95639
  companyId,
95504
- selectedOption: getSelectedOption(col.name),
95640
+ selectedOption: getSelectedOption(col.name, "boolean"),
95505
95641
  autoSelected: false,
95506
95642
  onChange: (option2) => setAppliedFilters((prev) => {
95507
95643
  const field2 = {
95508
95644
  column: col.name,
95509
95645
  operator: "=",
95510
- value: option2.value
95646
+ value: option2.value,
95647
+ as: col.as
95511
95648
  };
95512
95649
  const index2 = prev.findIndex((f2) => f2.column === col.name);
95513
95650
  if (index2 === -1)
@@ -95518,21 +95655,19 @@ const GlobalFilters = ({
95518
95655
  }),
95519
95656
  isSearchEnabled: true,
95520
95657
  integrationId,
95521
- integrationName
95522
- })
95523
- }), /* @__PURE__ */ jsx(Button, {
95524
- type: "button",
95525
- variant: "custom",
95526
- className: styles$s.remove,
95527
- onClick: () => {
95528
- setAppliedFilters((prev) => prev.filter((a4) => a4.column !== col.name));
95529
- },
95530
- children: /* @__PURE__ */ jsx(Icons, {
95531
- name: "delete-icon"
95532
- })
95533
- })]
95534
- })
95535
- }))
95658
+ integrationName,
95659
+ label: col.label || col.name
95660
+ }) : null]
95661
+ })
95662
+ });
95663
+ })
95664
+ }), /* @__PURE__ */ jsx("div", {
95665
+ className: styles$s.AddFilter,
95666
+ children: /* @__PURE__ */ jsx(AddFilter, {
95667
+ columnList: filters2[0].columns.filter((col) => !col.isDefault),
95668
+ setFilterList,
95669
+ filterList
95670
+ })
95536
95671
  }), /* @__PURE__ */ jsxs("div", {
95537
95672
  className: styles$s.buttons,
95538
95673
  children: [/* @__PURE__ */ jsxs(Button, {
@@ -130028,57 +130163,60 @@ var styles$b = {
130028
130163
  "alt-container": "_alt-container_170un_49",
130029
130164
  fullscreen: fullscreen$2
130030
130165
  };
130031
- const cardContainer = "_cardContainer_1qrhu_1";
130032
- const listHeader = "_listHeader_1qrhu_9";
130033
- const metricName = "_metricName_1qrhu_17";
130034
- const metricTitle = "_metricTitle_1qrhu_25";
130035
- const metricDescription = "_metricDescription_1qrhu_33";
130036
- const popup = "_popup_1qrhu_41";
130037
- const metricFilter$1 = "_metricFilter_1qrhu_49";
130038
- const popupIcon = "_popupIcon_1qrhu_57";
130039
- const popupMenu = "_popupMenu_1qrhu_65";
130040
- const popupItem = "_popupItem_1qrhu_73";
130041
- const popupItemIcon = "_popupItemIcon_1qrhu_81";
130042
- const csvBtn = "_csvBtn_1qrhu_89";
130043
- const deleteBtn = "_deleteBtn_1qrhu_97";
130044
- const metricData = "_metricData_1qrhu_105";
130045
- const metricTable = "_metricTable_1qrhu_113";
130046
- const singleValueData = "_singleValueData_1qrhu_121";
130047
- const singleValue = "_singleValue_1qrhu_121";
130048
- const noData = "_noData_1qrhu_137";
130049
- const noDataContent = "_noDataContent_1qrhu_145";
130050
- const noDataText = "_noDataText_1qrhu_153";
130051
- const loading$1 = "_loading_1qrhu_161";
130052
- const features = "_features_1qrhu_169";
130053
- const fullscreen$1 = "_fullscreen_1qrhu_177";
130054
- const deleteModal = "_deleteModal_1qrhu_185";
130055
- const cancelBtn = "_cancelBtn_1qrhu_193";
130056
- const warningIcon = "_warningIcon_1qrhu_201";
130057
- const downloadCsv = "_downloadCsv_1qrhu_209";
130058
- const downloadCsvWrapper = "_downloadCsvWrapper_1qrhu_217";
130059
- const downloadCsvHeader = "_downloadCsvHeader_1qrhu_225";
130060
- const downloadCsvFooter = "_downloadCsvFooter_1qrhu_233";
130061
- const downloadCsvCancelBtn = "_downloadCsvCancelBtn_1qrhu_241";
130062
- const downloadCsvNote = "_downloadCsvNote_1qrhu_249";
130063
- const downloadCsvExpiredNote = "_downloadCsvExpiredNote_1qrhu_257";
130064
- const downloadCsvNoteText = "_downloadCsvNoteText_1qrhu_263";
130065
- const downloadUrlTimeline = "_downloadUrlTimeline_1qrhu_287";
130066
- const timeLineItem = "_timeLineItem_1qrhu_295";
130067
- const timeLineActiveIcon = "_timeLineActiveIcon_1qrhu_303";
130068
- const timeLineIcon = "_timeLineIcon_1qrhu_311";
130069
- const timeLineItemline = "_timeLineItemline_1qrhu_319";
130070
- const downloadCsvLoading = "_downloadCsvLoading_1qrhu_327";
130071
- const downloadCsvLoadingIcon = "_downloadCsvLoadingIcon_1qrhu_335";
130072
- const downloadCsvLoadingText = "_downloadCsvLoadingText_1qrhu_343";
130073
- const timeLineCheckedIcon = "_timeLineCheckedIcon_1qrhu_351";
130074
- const timeLineCheckedIconWrapper = "_timeLineCheckedIconWrapper_1qrhu_359";
130075
- const downloadCsvBackBtnWrapper = "_downloadCsvBackBtnWrapper_1qrhu_367";
130076
- const downloadCsvBackBtnText = "_downloadCsvBackBtnText_1qrhu_375";
130077
- const downloadCsvHeaderText = "_downloadCsvHeaderText_1qrhu_397";
130078
- const downloadCsvTabContainer = "_downloadCsvTabContainer_1qrhu_405";
130079
- const downloadCsvActiveTab = "_downloadCsvActiveTab_1qrhu_413";
130080
- const downloadCsvTab = "_downloadCsvTab_1qrhu_405";
130081
- const downloadCsvActiveTabText = "_downloadCsvActiveTabText_1qrhu_429";
130166
+ const cardContainer = "_cardContainer_pprak_1";
130167
+ const listHeader = "_listHeader_pprak_9";
130168
+ const metricName = "_metricName_pprak_17";
130169
+ const metricTitle = "_metricTitle_pprak_25";
130170
+ const metricDescription = "_metricDescription_pprak_33";
130171
+ const popup = "_popup_pprak_41";
130172
+ const metricFilter$1 = "_metricFilter_pprak_49";
130173
+ const popupIcon = "_popupIcon_pprak_57";
130174
+ const popupMenu = "_popupMenu_pprak_65";
130175
+ const popupItem = "_popupItem_pprak_73";
130176
+ const popupItemIcon = "_popupItemIcon_pprak_81";
130177
+ const csvBtn = "_csvBtn_pprak_89";
130178
+ const deleteBtn = "_deleteBtn_pprak_97";
130179
+ const metricData = "_metricData_pprak_105";
130180
+ const metricTable = "_metricTable_pprak_113";
130181
+ const singleValueData = "_singleValueData_pprak_121";
130182
+ const singleValue = "_singleValue_pprak_121";
130183
+ const noData = "_noData_pprak_137";
130184
+ const noDataContent = "_noDataContent_pprak_145";
130185
+ const noDataText = "_noDataText_pprak_153";
130186
+ const loading$1 = "_loading_pprak_161";
130187
+ const features = "_features_pprak_169";
130188
+ const fullscreen$1 = "_fullscreen_pprak_177";
130189
+ const deleteModal = "_deleteModal_pprak_185";
130190
+ const cancelBtn = "_cancelBtn_pprak_193";
130191
+ const warningIcon = "_warningIcon_pprak_201";
130192
+ const downloadCsv = "_downloadCsv_pprak_209";
130193
+ const downloadCsvWrapper = "_downloadCsvWrapper_pprak_217";
130194
+ const downloadCsvHeader = "_downloadCsvHeader_pprak_225";
130195
+ const downloadCsvFooter = "_downloadCsvFooter_pprak_233";
130196
+ const downloadCsvCancelBtn = "_downloadCsvCancelBtn_pprak_241";
130197
+ const downloadCsvDisableBtn = "_downloadCsvDisableBtn_pprak_247";
130198
+ const downloadCsvNote = "_downloadCsvNote_pprak_253";
130199
+ const downloadCsvExpiredNote = "_downloadCsvExpiredNote_pprak_261";
130200
+ const downloadCsvNoteText = "_downloadCsvNoteText_pprak_267";
130201
+ const downloadCsvSuccessNote = "_downloadCsvSuccessNote_pprak_273";
130202
+ const downloadCsvSuccessText = "_downloadCsvSuccessText_pprak_279";
130203
+ const downloadUrlTimeline = "_downloadUrlTimeline_pprak_301";
130204
+ const timeLineItem = "_timeLineItem_pprak_309";
130205
+ const timeLineActiveIcon = "_timeLineActiveIcon_pprak_317";
130206
+ const timeLineIcon = "_timeLineIcon_pprak_325";
130207
+ const timeLineItemline = "_timeLineItemline_pprak_333";
130208
+ const downloadCsvLoading = "_downloadCsvLoading_pprak_341";
130209
+ const downloadCsvLoadingIcon = "_downloadCsvLoadingIcon_pprak_349";
130210
+ const downloadCsvLoadingText = "_downloadCsvLoadingText_pprak_357";
130211
+ const timeLineCheckedIcon = "_timeLineCheckedIcon_pprak_365";
130212
+ const timeLineCheckedIconWrapper = "_timeLineCheckedIconWrapper_pprak_373";
130213
+ const downloadCsvBackBtnWrapper = "_downloadCsvBackBtnWrapper_pprak_381";
130214
+ const downloadCsvBackBtnText = "_downloadCsvBackBtnText_pprak_389";
130215
+ const downloadCsvHeaderText = "_downloadCsvHeaderText_pprak_411";
130216
+ const downloadCsvTabContainer = "_downloadCsvTabContainer_pprak_419";
130217
+ const downloadCsvActiveTab = "_downloadCsvActiveTab_pprak_427";
130218
+ const downloadCsvTab = "_downloadCsvTab_pprak_419";
130219
+ const downloadCsvActiveTabText = "_downloadCsvActiveTabText_pprak_443";
130082
130220
  var styles$a = {
130083
130221
  cardContainer,
130084
130222
  listHeader,
@@ -130111,11 +130249,14 @@ var styles$a = {
130111
130249
  downloadCsvHeader,
130112
130250
  downloadCsvFooter,
130113
130251
  downloadCsvCancelBtn,
130252
+ downloadCsvDisableBtn,
130114
130253
  downloadCsvNote,
130115
130254
  downloadCsvExpiredNote,
130116
130255
  downloadCsvNoteText,
130117
- "tab-border-bottom": "_tab-border-bottom_1qrhu_271",
130118
- "download-info-text": "_download-info-text_1qrhu_279",
130256
+ downloadCsvSuccessNote,
130257
+ downloadCsvSuccessText,
130258
+ "tab-border-bottom": "_tab-border-bottom_pprak_285",
130259
+ "download-info-text": "_download-info-text_pprak_293",
130119
130260
  downloadUrlTimeline,
130120
130261
  timeLineItem,
130121
130262
  timeLineActiveIcon,
@@ -131454,6 +131595,21 @@ const getSqlStatement = ({
131454
131595
  });
131455
131596
  return replacedStr;
131456
131597
  };
131598
+ const isLinkExpired = (url) => {
131599
+ const queryString = url.split("?")[1];
131600
+ const params = new URLSearchParams(queryString);
131601
+ const expires = parseInt(params.get("Expires"), 10);
131602
+ const currentTime = Math.floor(Date.now() / 1e3);
131603
+ const secondsLeft = expires - currentTime;
131604
+ return { isExpired: currentTime >= expires, secondsLeft };
131605
+ };
131606
+ const getUrls = (urls) => {
131607
+ try {
131608
+ return JSON.parse(urls);
131609
+ } catch {
131610
+ return [];
131611
+ }
131612
+ };
131457
131613
  const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131458
131614
  var _a2, _b2;
131459
131615
  const queryClient2 = useQueryClient();
@@ -131473,23 +131629,11 @@ const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131473
131629
  const { handleSubmit, register: register2 } = useForm();
131474
131630
  const { data: RawCsvUrlsData } = useExternalMetricRawCsvUrlsQuery(
131475
131631
  { externalMetricId: metricItem == null ? void 0 : metricItem.id },
131476
- { enabled: !!(metricItem == null ? void 0 : metricItem.id) }
131477
- );
131478
- const isLinkExpired = (url) => {
131479
- const queryString = url.split("?")[1];
131480
- const params = new URLSearchParams(queryString);
131481
- const expires = parseInt(params.get("Expires"), 10);
131482
- const currentTime = Math.floor(Date.now() / 1e3);
131483
- const secondsLeft = expires - currentTime;
131484
- return { isExpired: currentTime >= expires, secondsLeft };
131485
- };
131486
- const getUrls = (urls) => {
131487
- try {
131488
- return JSON.parse(urls);
131489
- } catch {
131490
- return [];
131632
+ {
131633
+ enabled: !!(metricItem == null ? void 0 : metricItem.id),
131634
+ refetchInterval: 5e3
131491
131635
  }
131492
- };
131636
+ );
131493
131637
  const rawCsvSettings = useMemo(
131494
131638
  () => {
131495
131639
  var _a3, _b3;
@@ -131619,7 +131763,6 @@ const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131619
131763
  setLoading(false);
131620
131764
  setError("");
131621
131765
  onSuccess();
131622
- onCloseModal(false);
131623
131766
  } else if (invokeSaveRawCsvDetails == null ? void 0 : invokeSaveRawCsvDetails.error) {
131624
131767
  setLoading(false);
131625
131768
  setError(invokeSaveRawCsvDetails.error);
@@ -131665,18 +131808,11 @@ const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131665
131808
  { externalMetricId: metricItem == null ? void 0 : metricItem.id }
131666
131809
  ],
131667
131810
  (prev) => {
131668
- const prevExternalMetricRawCsvUrls = prev == null ? void 0 : prev.externalMetricRawCsvUrls;
131669
- const index2 = prevExternalMetricRawCsvUrls == null ? void 0 : prevExternalMetricRawCsvUrls.findIndex(
131670
- (url) => url.externalMetricId === (metricItem == null ? void 0 : metricItem.id)
131671
- );
131672
- if (index2 > -1) {
131673
- prevExternalMetricRawCsvUrls[index2] = {
131674
- ...insert_externalMetricRawCsvUrls_one
131675
- };
131676
- }
131677
131811
  return {
131678
131812
  ...prev,
131679
- externalMetricRawCsvUrls: prevExternalMetricRawCsvUrls
131813
+ externalMetricRawCsvUrls: [
131814
+ insert_externalMetricRawCsvUrls_one
131815
+ ]
131680
131816
  };
131681
131817
  }
131682
131818
  );
@@ -131893,7 +132029,8 @@ const DownloadRawCsvModal = ({
131893
132029
  message: downloadCsvError
131894
132030
  }), /* @__PURE__ */ jsxs(ModalFooter, {
131895
132031
  children: [/* @__PURE__ */ jsx(Button, {
131896
- variant: "custom",
132032
+ variant: "secondary",
132033
+ size: "medium",
131897
132034
  type: "button",
131898
132035
  className: styles$a.downloadCsvCancelBtn,
131899
132036
  onClick: () => onCloseModal(false),
@@ -131973,7 +132110,8 @@ const DownloadRawCsvModal = ({
131973
132110
  message: downloadCsvError
131974
132111
  }), /* @__PURE__ */ jsxs(ModalFooter, {
131975
132112
  children: [/* @__PURE__ */ jsx(Button, {
131976
- variant: "custom",
132113
+ variant: "secondary",
132114
+ size: "medium",
131977
132115
  type: "button",
131978
132116
  className: styles$a.downloadCsvCancelBtn,
131979
132117
  onClick: () => onCloseModal(false),
@@ -131990,11 +132128,11 @@ const DownloadRawCsvModal = ({
131990
132128
  }),
131991
132129
  children: "Request url"
131992
132130
  }) : /* @__PURE__ */ jsx(Button, {
131993
- variant: "custom",
132131
+ variant: "secondary",
131994
132132
  type: "button",
131995
132133
  size: "medium",
131996
132134
  isDisabled: true,
131997
- className: styles$a.downloadCsvCancelBtn,
132135
+ className: styles$a.downloadCsvDisableBtn,
131998
132136
  children: "Request url"
131999
132137
  })]
132000
132138
  })]
@@ -132045,21 +132183,31 @@ const DownloadRawCsvModal = ({
132045
132183
  children: "Your download link has expired. Please click on Request url to generate a new download url."
132046
132184
  })]
132047
132185
  })]
132048
- }) : /* @__PURE__ */ jsxs("div", {
132049
- className: styles$a.downloadCsvNote,
132050
- children: [/* @__PURE__ */ jsx(Icons, {
132051
- name: "info-icon",
132052
- className: styles$a.popupItemIcon
132053
- }), /* @__PURE__ */ jsxs("div", {
132054
- className: styles$a.downloadCsvNoteText,
132055
- children: [/* @__PURE__ */ jsx(Text, {
132056
- styleClass: "primary",
132186
+ }) : /* @__PURE__ */ jsxs(Fragment, {
132187
+ children: [/* @__PURE__ */ jsx("div", {
132188
+ className: styles$a.downloadCsvSuccessNote,
132189
+ children: /* @__PURE__ */ jsx(Text, {
132190
+ styleClass: "font-14b",
132057
132191
  variant: "h1",
132058
- children: "Note:"
132059
- }), /* @__PURE__ */ jsxs(Text, {
132060
- styleClass: "font-14",
132061
- variant: "p",
132062
- children: ["Your download may expire in", " ", (csvDownloadUrls.expireUrlIn / 60).toFixed(2), " ", "minutes. Please click Download button to download your raw CSV file."]
132192
+ className: styles$a.downloadCsvSuccessText,
132193
+ children: "Congratulations! CSV download url is ready."
132194
+ })
132195
+ }), /* @__PURE__ */ jsxs("div", {
132196
+ className: styles$a.downloadCsvNote,
132197
+ children: [/* @__PURE__ */ jsx(Icons, {
132198
+ name: "info-icon",
132199
+ className: styles$a.popupItemIcon
132200
+ }), /* @__PURE__ */ jsxs("div", {
132201
+ className: styles$a.downloadCsvNoteText,
132202
+ children: [/* @__PURE__ */ jsx(Text, {
132203
+ styleClass: "primary",
132204
+ variant: "h1",
132205
+ children: "Note:"
132206
+ }), /* @__PURE__ */ jsxs(Text, {
132207
+ styleClass: "font-14",
132208
+ variant: "p",
132209
+ children: ["Your download may expire in", " ", (csvDownloadUrls.expireUrlIn / 60).toFixed(2), " ", "minutes."]
132210
+ })]
132063
132211
  })]
132064
132212
  })]
132065
132213
  }), downloadCsvError && /* @__PURE__ */ jsx(Error$1, {
@@ -132091,7 +132239,8 @@ const DownloadRawCsvModal = ({
132091
132239
  })
132092
132240
  })
132093
132241
  }), /* @__PURE__ */ jsx(Button, {
132094
- variant: "custom",
132242
+ variant: "secondary",
132243
+ size: "medium",
132095
132244
  type: "button",
132096
132245
  className: styles$a.downloadCsvCancelBtn,
132097
132246
  onClick: () => onCloseModal(false),
@@ -132104,11 +132253,11 @@ const DownloadRawCsvModal = ({
132104
132253
  onClick: () => handleDownload(url),
132105
132254
  children: "Download"
132106
132255
  })), csvDownloadUrls.isExpired && /* @__PURE__ */ jsx(Button, {
132107
- variant: "custom",
132256
+ variant: "secondary",
132108
132257
  type: "button",
132109
132258
  size: "medium",
132110
132259
  isDisabled: true,
132111
- className: styles$a.downloadCsvCancelBtn,
132260
+ className: styles$a.downloadCsvDisableBtn,
132112
132261
  children: "Download"
132113
132262
  })]
132114
132263
  })]
@@ -132461,6 +132610,65 @@ const MetricTable = ({
132461
132610
  })]
132462
132611
  });
132463
132612
  };
132613
+ const AppliedFilter = ({
132614
+ appliedFilter,
132615
+ setAppliedFilters,
132616
+ onRemove
132617
+ }) => {
132618
+ return /* @__PURE__ */ jsx("div", {
132619
+ className: styles$s.appliedfilters,
132620
+ children: appliedFilter.map((filter2) => /* @__PURE__ */ jsxs("div", {
132621
+ className: styles$s.appliedFilterTag,
132622
+ children: [/* @__PURE__ */ jsx(Text, {
132623
+ variant: "p",
132624
+ styleClass: "font-14",
132625
+ className: styles$s.textBold,
132626
+ children: filter2.column
132627
+ }), /* @__PURE__ */ jsx(Text, {
132628
+ variant: "p",
132629
+ styleClass: "font-14",
132630
+ children: "is"
132631
+ }), filter2.as !== "string" && filter2.as !== "boolean" && filter2.as !== "default" && /* @__PURE__ */ jsx(Text, {
132632
+ variant: "p",
132633
+ styleClass: "font-14",
132634
+ children: "between"
132635
+ }), /* @__PURE__ */ jsx(Text, {
132636
+ variant: "p",
132637
+ styleClass: "font-14",
132638
+ className: styles$s.textBold,
132639
+ children: Array.isArray(filter2.value) ? filter2.as === "string" ? filter2.value.join(", ") : filter2.value.join(" & ") : typeof filter2.value === "string" && filter2.as === "number" ? filter2.value.replace("AND", "&") : typeof filter2.value === "string" && filter2.as === "date" ? filter2.value.split(" ").slice(2).join(" ").replace("AND", "&") : filter2.value
132640
+ }), /* @__PURE__ */ jsx(Button, {
132641
+ variant: "secondary",
132642
+ type: "button",
132643
+ onClick: () => {
132644
+ setAppliedFilters((prev) => prev.filter((a4) => a4.column !== filter2.column));
132645
+ const filterColumns = appliedFilter.filter((c3) => c3.column !== filter2.column).map((field2) => {
132646
+ const col = {
132647
+ column: field2.column,
132648
+ operator: field2.operator,
132649
+ as: field2.as
132650
+ };
132651
+ const formattedValue = field2.as === "date" || field2.as === "number" ? field2.value : getFormattedFilterValue({
132652
+ operator: field2.operator,
132653
+ value: field2.value
132654
+ });
132655
+ if (formattedValue != null) {
132656
+ Object.assign(col, {
132657
+ ...col,
132658
+ value: formattedValue
132659
+ });
132660
+ }
132661
+ return col;
132662
+ });
132663
+ onRemove(filterColumns);
132664
+ },
132665
+ children: /* @__PURE__ */ jsx(Icons, {
132666
+ name: "close-icon"
132667
+ })
132668
+ })]
132669
+ }))
132670
+ });
132671
+ };
132464
132672
  var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
132465
132673
  __proto__: null,
132466
132674
  Button,
@@ -132479,6 +132687,7 @@ var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
132479
132687
  isInFilterOperator,
132480
132688
  isNullFilterOperator,
132481
132689
  FilterField,
132690
+ getFormattedFilterValue,
132482
132691
  GlobalFilters,
132483
132692
  Tooltip,
132484
132693
  InfoTooltip,
@@ -132525,7 +132734,8 @@ var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
132525
132734
  ChartPopup,
132526
132735
  DrillBreadCrumb,
132527
132736
  MetricFilterDropDown,
132528
- Alert
132737
+ Alert,
132738
+ AppliedFilter
132529
132739
  }, Symbol.toStringTag, { value: "Module" }));
132530
132740
  const mdiPlus = (props) => /* @__PURE__ */ jsx("svg", {
132531
132741
  viewBox: "0 0 24 24",
@@ -133116,7 +133326,7 @@ const EmbeddedDashboard = e__default.memo(({
133116
133326
  data,
133117
133327
  isLoading
133118
133328
  } = useDashboardContext();
133119
- const [appliedfilters, setAppliedFilters] = useState([]);
133329
+ const [appliedfilters2, setAppliedFilters] = useState([]);
133120
133330
  const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
133121
133331
  const [globalFilters, setGlobalFilters] = useState({
133122
133332
  tableName: "",
@@ -133138,6 +133348,7 @@ const EmbeddedDashboard = e__default.memo(({
133138
133348
  return [adminThemeData == null ? void 0 : adminThemeData.themes[0], colors2];
133139
133349
  }, [adminThemeData == null ? void 0 : adminThemeData.themes[0]]);
133140
133350
  useApplyAdminTheme(adminTheme);
133351
+ const globalFilterRef = useRef(null);
133141
133352
  return /* @__PURE__ */ jsx(Fragment, {
133142
133353
  children: /* @__PURE__ */ jsxs("div", {
133143
133354
  className: styles$M["embedDashboard-container"],
@@ -133178,31 +133389,46 @@ const EmbeddedDashboard = e__default.memo(({
133178
133389
  })]
133179
133390
  }), /* @__PURE__ */ jsxs("div", {
133180
133391
  className: styles$M["embedDashboard-wrapper"],
133181
- children: [data.externalDashboard.filters.length ? /* @__PURE__ */ jsx(PopoverMenu, {
133182
- button: /* @__PURE__ */ jsxs(Button, {
133183
- type: "button",
133184
- variant: "custom",
133185
- className: styles$M.filterButton,
133186
- children: [/* @__PURE__ */ jsxs("div", {
133187
- className: styles$M.filterText,
133188
- children: [/* @__PURE__ */ jsx(Icons, {
133189
- name: "filter-icon"
133190
- }), " Filters"]
133191
- }), appliedfilters.length === 0 ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx("span", {
133192
- className: styles$M.filterLength,
133193
- children: appliedfilters.length
133194
- })]
133195
- }),
133196
- menuClass: "w-[400px] ml-[40px]",
133197
- position: "bottom-left",
133198
- children: /* @__PURE__ */ jsx(GlobalFilters, {
133199
- companyId: data.companyId,
133200
- externalDashboardId: data.externalDashboard.id,
133201
- filters: data.externalDashboard.filters,
133202
- onApply: (values) => setGlobalFilters(values),
133203
- appliedfilters,
133204
- setAppliedFilters
133205
- })
133392
+ children: [data.externalDashboard.filters.length ? /* @__PURE__ */ jsxs(Fragment, {
133393
+ children: [/* @__PURE__ */ jsx(PopoverMenu, {
133394
+ button: /* @__PURE__ */ jsxs("div", {
133395
+ className: styles$M.filterButton,
133396
+ ref: globalFilterRef,
133397
+ children: [/* @__PURE__ */ jsxs("div", {
133398
+ className: styles$M.filterText,
133399
+ children: [/* @__PURE__ */ jsx(Icons, {
133400
+ name: "filter-icon"
133401
+ }), " Filters"]
133402
+ }), appliedfilters2.length === 0 ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx("span", {
133403
+ className: styles$M.filterLength,
133404
+ children: appliedfilters2.length
133405
+ })]
133406
+ }),
133407
+ menuClass: "w-[400px] ml-[40px]",
133408
+ position: "bottom-left",
133409
+ children: /* @__PURE__ */ jsx(GlobalFilters, {
133410
+ companyId: data.companyId,
133411
+ externalDashboardId: data.externalDashboard.id,
133412
+ filters: data.externalDashboard.filters,
133413
+ onApply: (values) => {
133414
+ var _a3;
133415
+ setGlobalFilters(values);
133416
+ (_a3 = globalFilterRef.current) == null ? void 0 : _a3.click();
133417
+ },
133418
+ appliedfilters: appliedfilters2,
133419
+ setAppliedFilters
133420
+ })
133421
+ }), /* @__PURE__ */ jsx(AppliedFilter, {
133422
+ appliedFilter: appliedfilters2,
133423
+ setAppliedFilters,
133424
+ onRemove: (filters2) => {
133425
+ var _a3, _b3;
133426
+ return setGlobalFilters({
133427
+ tableName: (_b3 = (_a3 = data.externalDashboard) == null ? void 0 : _a3.filters) == null ? void 0 : _b3[0].tableName,
133428
+ filters: filters2
133429
+ });
133430
+ }
133431
+ })]
133206
133432
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
133207
133433
  client: data.clientId,
133208
133434
  isLiveMode: data.isLiveMode,