@databrainhq/plugin 0.9.10 → 0.9.11

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,
@@ -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.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.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,69 +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
95576
  label: col.name,
95403
- setTimeGrainValue,
95404
- timeGrainValue,
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
- }));
95579
+ if (option2)
95452
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
+ });
95453
95588
  const field2 = {
95454
95589
  column: col.name,
95455
- operator: "BETWEEN",
95456
- value: `${value} AND ${minMax.max}`,
95457
- as: col.as
95590
+ operator: "=",
95591
+ value,
95592
+ as: col.as,
95593
+ defaultValues: option2
95458
95594
  };
95459
95595
  const index2 = prev.findIndex((f2) => f2.column === col.name);
95460
95596
  if (index2 === -1)
@@ -95463,51 +95599,51 @@ const GlobalFilters = ({
95463
95599
  updated[index2] = field2;
95464
95600
  return updated;
95465
95601
  });
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
- }));
95481
- setAppliedFilters((prev) => {
95482
- const field2 = {
95483
- column: col.name,
95484
- operator: "BETWEEN",
95485
- value: `${minMax.min} AND ${value}`,
95486
- as: col.as
95487
- };
95488
- const index2 = prev.findIndex((f2) => f2.column === col.name);
95489
- if (index2 === -1)
95490
- return [...prev, field2];
95491
- const updated = [...prev];
95492
- updated[index2] = field2;
95493
- return updated;
95494
- });
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, {
95499
95609
  filter: {
95500
95610
  tableName: filters2[0].tableName,
95501
95611
  columnName: col.name
95502
95612
  },
95503
95613
  companyId,
95504
- selectedOption: getSelectedOption(col.name),
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
+ }), col.as === "default" || col.as === "boolean" ? /* @__PURE__ */ jsx(FilterDropDown, {
95634
+ filter: {
95635
+ tableName: filters2[0].tableName,
95636
+ columnName: col.name
95637
+ },
95638
+ companyId,
95639
+ selectedOption: getSelectedOption(col.name, "boolean"),
95505
95640
  autoSelected: false,
95506
95641
  onChange: (option2) => setAppliedFilters((prev) => {
95507
95642
  const field2 = {
95508
95643
  column: col.name,
95509
95644
  operator: "=",
95510
- value: option2.value
95645
+ value: option2.value,
95646
+ as: col.as
95511
95647
  };
95512
95648
  const index2 = prev.findIndex((f2) => f2.column === col.name);
95513
95649
  if (index2 === -1)
@@ -95519,20 +95655,17 @@ const GlobalFilters = ({
95519
95655
  isSearchEnabled: true,
95520
95656
  integrationId,
95521
95657
  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
+ }) : null]
95659
+ })
95660
+ });
95661
+ })
95662
+ }), /* @__PURE__ */ jsx("div", {
95663
+ className: styles$s.AddFilter,
95664
+ children: /* @__PURE__ */ jsx(AddFilter, {
95665
+ columnList: filters2[0].columns.filter((col) => !col.isDefault),
95666
+ setFilterList,
95667
+ filterList
95668
+ })
95536
95669
  }), /* @__PURE__ */ jsxs("div", {
95537
95670
  className: styles$s.buttons,
95538
95671
  children: [/* @__PURE__ */ jsxs(Button, {
@@ -130028,57 +130161,60 @@ var styles$b = {
130028
130161
  "alt-container": "_alt-container_170un_49",
130029
130162
  fullscreen: fullscreen$2
130030
130163
  };
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";
130164
+ const cardContainer = "_cardContainer_pprak_1";
130165
+ const listHeader = "_listHeader_pprak_9";
130166
+ const metricName = "_metricName_pprak_17";
130167
+ const metricTitle = "_metricTitle_pprak_25";
130168
+ const metricDescription = "_metricDescription_pprak_33";
130169
+ const popup = "_popup_pprak_41";
130170
+ const metricFilter$1 = "_metricFilter_pprak_49";
130171
+ const popupIcon = "_popupIcon_pprak_57";
130172
+ const popupMenu = "_popupMenu_pprak_65";
130173
+ const popupItem = "_popupItem_pprak_73";
130174
+ const popupItemIcon = "_popupItemIcon_pprak_81";
130175
+ const csvBtn = "_csvBtn_pprak_89";
130176
+ const deleteBtn = "_deleteBtn_pprak_97";
130177
+ const metricData = "_metricData_pprak_105";
130178
+ const metricTable = "_metricTable_pprak_113";
130179
+ const singleValueData = "_singleValueData_pprak_121";
130180
+ const singleValue = "_singleValue_pprak_121";
130181
+ const noData = "_noData_pprak_137";
130182
+ const noDataContent = "_noDataContent_pprak_145";
130183
+ const noDataText = "_noDataText_pprak_153";
130184
+ const loading$1 = "_loading_pprak_161";
130185
+ const features = "_features_pprak_169";
130186
+ const fullscreen$1 = "_fullscreen_pprak_177";
130187
+ const deleteModal = "_deleteModal_pprak_185";
130188
+ const cancelBtn = "_cancelBtn_pprak_193";
130189
+ const warningIcon = "_warningIcon_pprak_201";
130190
+ const downloadCsv = "_downloadCsv_pprak_209";
130191
+ const downloadCsvWrapper = "_downloadCsvWrapper_pprak_217";
130192
+ const downloadCsvHeader = "_downloadCsvHeader_pprak_225";
130193
+ const downloadCsvFooter = "_downloadCsvFooter_pprak_233";
130194
+ const downloadCsvCancelBtn = "_downloadCsvCancelBtn_pprak_241";
130195
+ const downloadCsvDisableBtn = "_downloadCsvDisableBtn_pprak_247";
130196
+ const downloadCsvNote = "_downloadCsvNote_pprak_253";
130197
+ const downloadCsvExpiredNote = "_downloadCsvExpiredNote_pprak_261";
130198
+ const downloadCsvNoteText = "_downloadCsvNoteText_pprak_267";
130199
+ const downloadCsvSuccessNote = "_downloadCsvSuccessNote_pprak_273";
130200
+ const downloadCsvSuccessText = "_downloadCsvSuccessText_pprak_279";
130201
+ const downloadUrlTimeline = "_downloadUrlTimeline_pprak_301";
130202
+ const timeLineItem = "_timeLineItem_pprak_309";
130203
+ const timeLineActiveIcon = "_timeLineActiveIcon_pprak_317";
130204
+ const timeLineIcon = "_timeLineIcon_pprak_325";
130205
+ const timeLineItemline = "_timeLineItemline_pprak_333";
130206
+ const downloadCsvLoading = "_downloadCsvLoading_pprak_341";
130207
+ const downloadCsvLoadingIcon = "_downloadCsvLoadingIcon_pprak_349";
130208
+ const downloadCsvLoadingText = "_downloadCsvLoadingText_pprak_357";
130209
+ const timeLineCheckedIcon = "_timeLineCheckedIcon_pprak_365";
130210
+ const timeLineCheckedIconWrapper = "_timeLineCheckedIconWrapper_pprak_373";
130211
+ const downloadCsvBackBtnWrapper = "_downloadCsvBackBtnWrapper_pprak_381";
130212
+ const downloadCsvBackBtnText = "_downloadCsvBackBtnText_pprak_389";
130213
+ const downloadCsvHeaderText = "_downloadCsvHeaderText_pprak_411";
130214
+ const downloadCsvTabContainer = "_downloadCsvTabContainer_pprak_419";
130215
+ const downloadCsvActiveTab = "_downloadCsvActiveTab_pprak_427";
130216
+ const downloadCsvTab = "_downloadCsvTab_pprak_419";
130217
+ const downloadCsvActiveTabText = "_downloadCsvActiveTabText_pprak_443";
130082
130218
  var styles$a = {
130083
130219
  cardContainer,
130084
130220
  listHeader,
@@ -130111,11 +130247,14 @@ var styles$a = {
130111
130247
  downloadCsvHeader,
130112
130248
  downloadCsvFooter,
130113
130249
  downloadCsvCancelBtn,
130250
+ downloadCsvDisableBtn,
130114
130251
  downloadCsvNote,
130115
130252
  downloadCsvExpiredNote,
130116
130253
  downloadCsvNoteText,
130117
- "tab-border-bottom": "_tab-border-bottom_1qrhu_271",
130118
- "download-info-text": "_download-info-text_1qrhu_279",
130254
+ downloadCsvSuccessNote,
130255
+ downloadCsvSuccessText,
130256
+ "tab-border-bottom": "_tab-border-bottom_pprak_285",
130257
+ "download-info-text": "_download-info-text_pprak_293",
130119
130258
  downloadUrlTimeline,
130120
130259
  timeLineItem,
130121
130260
  timeLineActiveIcon,
@@ -131454,6 +131593,21 @@ const getSqlStatement = ({
131454
131593
  });
131455
131594
  return replacedStr;
131456
131595
  };
131596
+ const isLinkExpired = (url) => {
131597
+ const queryString = url.split("?")[1];
131598
+ const params = new URLSearchParams(queryString);
131599
+ const expires = parseInt(params.get("Expires"), 10);
131600
+ const currentTime = Math.floor(Date.now() / 1e3);
131601
+ const secondsLeft = expires - currentTime;
131602
+ return { isExpired: currentTime >= expires, secondsLeft };
131603
+ };
131604
+ const getUrls = (urls) => {
131605
+ try {
131606
+ return JSON.parse(urls);
131607
+ } catch {
131608
+ return [];
131609
+ }
131610
+ };
131457
131611
  const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131458
131612
  var _a2, _b2;
131459
131613
  const queryClient2 = useQueryClient();
@@ -131473,23 +131627,11 @@ const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131473
131627
  const { handleSubmit, register: register2 } = useForm();
131474
131628
  const { data: RawCsvUrlsData } = useExternalMetricRawCsvUrlsQuery(
131475
131629
  { 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 [];
131630
+ {
131631
+ enabled: !!(metricItem == null ? void 0 : metricItem.id),
131632
+ refetchInterval: 5e3
131491
131633
  }
131492
- };
131634
+ );
131493
131635
  const rawCsvSettings = useMemo(
131494
131636
  () => {
131495
131637
  var _a3, _b3;
@@ -131619,7 +131761,6 @@ const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131619
131761
  setLoading(false);
131620
131762
  setError("");
131621
131763
  onSuccess();
131622
- onCloseModal(false);
131623
131764
  } else if (invokeSaveRawCsvDetails == null ? void 0 : invokeSaveRawCsvDetails.error) {
131624
131765
  setLoading(false);
131625
131766
  setError(invokeSaveRawCsvDetails.error);
@@ -131665,18 +131806,11 @@ const useDownloadRawCsv = (onCloseModal, metricItem, filterValues2) => {
131665
131806
  { externalMetricId: metricItem == null ? void 0 : metricItem.id }
131666
131807
  ],
131667
131808
  (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
131809
  return {
131678
131810
  ...prev,
131679
- externalMetricRawCsvUrls: prevExternalMetricRawCsvUrls
131811
+ externalMetricRawCsvUrls: [
131812
+ insert_externalMetricRawCsvUrls_one
131813
+ ]
131680
131814
  };
131681
131815
  }
131682
131816
  );
@@ -131893,7 +132027,8 @@ const DownloadRawCsvModal = ({
131893
132027
  message: downloadCsvError
131894
132028
  }), /* @__PURE__ */ jsxs(ModalFooter, {
131895
132029
  children: [/* @__PURE__ */ jsx(Button, {
131896
- variant: "custom",
132030
+ variant: "secondary",
132031
+ size: "medium",
131897
132032
  type: "button",
131898
132033
  className: styles$a.downloadCsvCancelBtn,
131899
132034
  onClick: () => onCloseModal(false),
@@ -131973,7 +132108,8 @@ const DownloadRawCsvModal = ({
131973
132108
  message: downloadCsvError
131974
132109
  }), /* @__PURE__ */ jsxs(ModalFooter, {
131975
132110
  children: [/* @__PURE__ */ jsx(Button, {
131976
- variant: "custom",
132111
+ variant: "secondary",
132112
+ size: "medium",
131977
132113
  type: "button",
131978
132114
  className: styles$a.downloadCsvCancelBtn,
131979
132115
  onClick: () => onCloseModal(false),
@@ -131990,11 +132126,11 @@ const DownloadRawCsvModal = ({
131990
132126
  }),
131991
132127
  children: "Request url"
131992
132128
  }) : /* @__PURE__ */ jsx(Button, {
131993
- variant: "custom",
132129
+ variant: "secondary",
131994
132130
  type: "button",
131995
132131
  size: "medium",
131996
132132
  isDisabled: true,
131997
- className: styles$a.downloadCsvCancelBtn,
132133
+ className: styles$a.downloadCsvDisableBtn,
131998
132134
  children: "Request url"
131999
132135
  })]
132000
132136
  })]
@@ -132045,21 +132181,31 @@ const DownloadRawCsvModal = ({
132045
132181
  children: "Your download link has expired. Please click on Request url to generate a new download url."
132046
132182
  })]
132047
132183
  })]
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",
132184
+ }) : /* @__PURE__ */ jsxs(Fragment, {
132185
+ children: [/* @__PURE__ */ jsx("div", {
132186
+ className: styles$a.downloadCsvSuccessNote,
132187
+ children: /* @__PURE__ */ jsx(Text, {
132188
+ styleClass: "font-14b",
132057
132189
  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."]
132190
+ className: styles$a.downloadCsvSuccessText,
132191
+ children: "Congratulations! CSV download url is ready."
132192
+ })
132193
+ }), /* @__PURE__ */ jsxs("div", {
132194
+ className: styles$a.downloadCsvNote,
132195
+ children: [/* @__PURE__ */ jsx(Icons, {
132196
+ name: "info-icon",
132197
+ className: styles$a.popupItemIcon
132198
+ }), /* @__PURE__ */ jsxs("div", {
132199
+ className: styles$a.downloadCsvNoteText,
132200
+ children: [/* @__PURE__ */ jsx(Text, {
132201
+ styleClass: "primary",
132202
+ variant: "h1",
132203
+ children: "Note:"
132204
+ }), /* @__PURE__ */ jsxs(Text, {
132205
+ styleClass: "font-14",
132206
+ variant: "p",
132207
+ children: ["Your download may expire in", " ", (csvDownloadUrls.expireUrlIn / 60).toFixed(2), " ", "minutes."]
132208
+ })]
132063
132209
  })]
132064
132210
  })]
132065
132211
  }), downloadCsvError && /* @__PURE__ */ jsx(Error$1, {
@@ -132091,7 +132237,8 @@ const DownloadRawCsvModal = ({
132091
132237
  })
132092
132238
  })
132093
132239
  }), /* @__PURE__ */ jsx(Button, {
132094
- variant: "custom",
132240
+ variant: "secondary",
132241
+ size: "medium",
132095
132242
  type: "button",
132096
132243
  className: styles$a.downloadCsvCancelBtn,
132097
132244
  onClick: () => onCloseModal(false),
@@ -132104,11 +132251,11 @@ const DownloadRawCsvModal = ({
132104
132251
  onClick: () => handleDownload(url),
132105
132252
  children: "Download"
132106
132253
  })), csvDownloadUrls.isExpired && /* @__PURE__ */ jsx(Button, {
132107
- variant: "custom",
132254
+ variant: "secondary",
132108
132255
  type: "button",
132109
132256
  size: "medium",
132110
132257
  isDisabled: true,
132111
- className: styles$a.downloadCsvCancelBtn,
132258
+ className: styles$a.downloadCsvDisableBtn,
132112
132259
  children: "Download"
132113
132260
  })]
132114
132261
  })]
@@ -132461,6 +132608,65 @@ const MetricTable = ({
132461
132608
  })]
132462
132609
  });
132463
132610
  };
132611
+ const AppliedFilter = ({
132612
+ appliedFilter,
132613
+ setAppliedFilters,
132614
+ onRemove
132615
+ }) => {
132616
+ return /* @__PURE__ */ jsx("div", {
132617
+ className: styles$s.appliedfilters,
132618
+ children: appliedFilter.map((filter2) => /* @__PURE__ */ jsxs("div", {
132619
+ className: styles$s.appliedFilterTag,
132620
+ children: [/* @__PURE__ */ jsx(Text, {
132621
+ variant: "p",
132622
+ styleClass: "font-14",
132623
+ className: styles$s.textBold,
132624
+ children: filter2.column
132625
+ }), /* @__PURE__ */ jsx(Text, {
132626
+ variant: "p",
132627
+ styleClass: "font-14",
132628
+ children: "is"
132629
+ }), filter2.as !== "string" && filter2.as !== "boolean" && filter2.as !== "default" && /* @__PURE__ */ jsx(Text, {
132630
+ variant: "p",
132631
+ styleClass: "font-14",
132632
+ children: "between"
132633
+ }), /* @__PURE__ */ jsx(Text, {
132634
+ variant: "p",
132635
+ styleClass: "font-14",
132636
+ className: styles$s.textBold,
132637
+ 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
132638
+ }), /* @__PURE__ */ jsx(Button, {
132639
+ variant: "secondary",
132640
+ type: "button",
132641
+ onClick: () => {
132642
+ setAppliedFilters((prev) => prev.filter((a4) => a4.column !== filter2.column));
132643
+ const filterColumns = appliedFilter.filter((c3) => c3.column !== filter2.column).map((field2) => {
132644
+ const col = {
132645
+ column: field2.column,
132646
+ operator: field2.operator,
132647
+ as: field2.as
132648
+ };
132649
+ const formattedValue = field2.as === "date" || field2.as === "number" ? field2.value : getFormattedFilterValue({
132650
+ operator: field2.operator,
132651
+ value: field2.value
132652
+ });
132653
+ if (formattedValue != null) {
132654
+ Object.assign(col, {
132655
+ ...col,
132656
+ value: formattedValue
132657
+ });
132658
+ }
132659
+ return col;
132660
+ });
132661
+ onRemove(filterColumns);
132662
+ },
132663
+ children: /* @__PURE__ */ jsx(Icons, {
132664
+ name: "close-icon"
132665
+ })
132666
+ })]
132667
+ }))
132668
+ });
132669
+ };
132464
132670
  var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
132465
132671
  __proto__: null,
132466
132672
  Button,
@@ -132479,6 +132685,7 @@ var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
132479
132685
  isInFilterOperator,
132480
132686
  isNullFilterOperator,
132481
132687
  FilterField,
132688
+ getFormattedFilterValue,
132482
132689
  GlobalFilters,
132483
132690
  Tooltip,
132484
132691
  InfoTooltip,
@@ -132525,7 +132732,8 @@ var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
132525
132732
  ChartPopup,
132526
132733
  DrillBreadCrumb,
132527
132734
  MetricFilterDropDown,
132528
- Alert
132735
+ Alert,
132736
+ AppliedFilter
132529
132737
  }, Symbol.toStringTag, { value: "Module" }));
132530
132738
  const mdiPlus = (props) => /* @__PURE__ */ jsx("svg", {
132531
132739
  viewBox: "0 0 24 24",
@@ -133116,7 +133324,7 @@ const EmbeddedDashboard = e__default.memo(({
133116
133324
  data,
133117
133325
  isLoading
133118
133326
  } = useDashboardContext();
133119
- const [appliedfilters, setAppliedFilters] = useState([]);
133327
+ const [appliedfilters2, setAppliedFilters] = useState([]);
133120
133328
  const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
133121
133329
  const [globalFilters, setGlobalFilters] = useState({
133122
133330
  tableName: "",
@@ -133138,6 +133346,7 @@ const EmbeddedDashboard = e__default.memo(({
133138
133346
  return [adminThemeData == null ? void 0 : adminThemeData.themes[0], colors2];
133139
133347
  }, [adminThemeData == null ? void 0 : adminThemeData.themes[0]]);
133140
133348
  useApplyAdminTheme(adminTheme);
133349
+ const globalFilterRef = useRef(null);
133141
133350
  return /* @__PURE__ */ jsx(Fragment, {
133142
133351
  children: /* @__PURE__ */ jsxs("div", {
133143
133352
  className: styles$M["embedDashboard-container"],
@@ -133178,31 +133387,46 @@ const EmbeddedDashboard = e__default.memo(({
133178
133387
  })]
133179
133388
  }), /* @__PURE__ */ jsxs("div", {
133180
133389
  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
- })
133390
+ children: [data.externalDashboard.filters.length ? /* @__PURE__ */ jsxs(Fragment, {
133391
+ children: [/* @__PURE__ */ jsx(PopoverMenu, {
133392
+ button: /* @__PURE__ */ jsxs("div", {
133393
+ className: styles$M.filterButton,
133394
+ ref: globalFilterRef,
133395
+ children: [/* @__PURE__ */ jsxs("div", {
133396
+ className: styles$M.filterText,
133397
+ children: [/* @__PURE__ */ jsx(Icons, {
133398
+ name: "filter-icon"
133399
+ }), " Filters"]
133400
+ }), appliedfilters2.length === 0 ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx("span", {
133401
+ className: styles$M.filterLength,
133402
+ children: appliedfilters2.length
133403
+ })]
133404
+ }),
133405
+ menuClass: "w-[400px] ml-[40px]",
133406
+ position: "bottom-left",
133407
+ children: /* @__PURE__ */ jsx(GlobalFilters, {
133408
+ companyId: data.companyId,
133409
+ externalDashboardId: data.externalDashboard.id,
133410
+ filters: data.externalDashboard.filters,
133411
+ onApply: (values) => {
133412
+ var _a3;
133413
+ setGlobalFilters(values);
133414
+ (_a3 = globalFilterRef.current) == null ? void 0 : _a3.click();
133415
+ },
133416
+ appliedfilters: appliedfilters2,
133417
+ setAppliedFilters
133418
+ })
133419
+ }), /* @__PURE__ */ jsx(AppliedFilter, {
133420
+ appliedFilter: appliedfilters2,
133421
+ setAppliedFilters,
133422
+ onRemove: (filters2) => {
133423
+ var _a3, _b3;
133424
+ return setGlobalFilters({
133425
+ tableName: (_b3 = (_a3 = data.externalDashboard) == null ? void 0 : _a3.filters) == null ? void 0 : _b3[0].tableName,
133426
+ filters: filters2
133427
+ });
133428
+ }
133429
+ })]
133206
133430
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
133207
133431
  client: data.clientId,
133208
133432
  isLiveMode: data.isLiveMode,