@databrainhq/plugin 0.9.12 → 0.9.14

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
@@ -2533,14 +2533,13 @@ const floatingCreateButtonIcon = "_floatingCreateButtonIcon_12kmo_399";
2533
2533
  const floatingButton = "_floatingButton_12kmo_407";
2534
2534
  const staticContainer = "_staticContainer_12kmo_415";
2535
2535
  const floatingContainer = "_floatingContainer_12kmo_423";
2536
- const filterButton = "_filterButton_12kmo_439";
2536
+ const filterButton$1 = "_filterButton_12kmo_439";
2537
2537
  const filterText$1 = "_filterText_12kmo_447";
2538
- const filterLength = "_filterLength_12kmo_455";
2538
+ const filterLength$1 = "_filterLength_12kmo_455";
2539
2539
  var styles$M = {
2540
2540
  container: container$i,
2541
2541
  "static": "_static_12kmo_415",
2542
2542
  fixed,
2543
- "ml-[40px]": "_ml-[40px]_12kmo_1",
2544
2543
  inline,
2545
2544
  flex,
2546
2545
  table: table$3,
@@ -2549,7 +2548,6 @@ var styles$M = {
2549
2548
  hidden,
2550
2549
  "h-[10%]": "_h-[10%]_12kmo_1",
2551
2550
  "w-full": "_w-full_12kmo_1",
2552
- "w-[400px]": "_w-[400px]_12kmo_1",
2553
2551
  transform,
2554
2552
  resize,
2555
2553
  truncate,
@@ -2573,9 +2571,9 @@ var styles$M = {
2573
2571
  floatingButton,
2574
2572
  staticContainer,
2575
2573
  floatingContainer,
2576
- filterButton,
2574
+ filterButton: filterButton$1,
2577
2575
  filterText: filterText$1,
2578
- filterLength,
2576
+ filterLength: filterLength$1,
2579
2577
  "hover:cursor-pointer": "_hover:cursor-pointer_12kmo_1",
2580
2578
  "hover:cursor-text": "_hover:cursor-text_12kmo_1",
2581
2579
  "disabled:cursor-text": "_disabled:cursor-text_12kmo_1",
@@ -6488,27 +6486,99 @@ const TextAreaField = ({
6488
6486
  })]
6489
6487
  });
6490
6488
  };
6491
- const group$1 = "_group_13otg_1";
6492
- const button$8 = "_button_13otg_9";
6493
- const checkbox = "_checkbox_13otg_17";
6494
- const enabled = "_enabled_13otg_43";
6495
- const notenabled = "_notenabled_13otg_59";
6496
- const label$4 = "_label_13otg_75";
6497
- const labelActive = "_labelActive_13otg_83";
6498
- const labelInactive = "_labelInactive_13otg_91";
6489
+ const Switch = ({
6490
+ name,
6491
+ styles: styles2,
6492
+ placeholder,
6493
+ enabled: enabled2
6494
+ }) => {
6495
+ return /* @__PURE__ */ jsxs("label", {
6496
+ htmlFor: name,
6497
+ className: `${styles2.button}`,
6498
+ children: [Array.isArray(placeholder) && /* @__PURE__ */ jsxs(Fragment, {
6499
+ children: [/* @__PURE__ */ jsx("span", {
6500
+ className: ` ${styles2.label} ${!enabled2 ? styles2.labelActive : styles2.labelInactive}`,
6501
+ children: placeholder[0]
6502
+ }), /* @__PURE__ */ jsx("span", {
6503
+ className: ` ${styles2.switch} ${enabled2 ? styles2.enabled : styles2.notenabled}`
6504
+ }), /* @__PURE__ */ jsx("span", {
6505
+ className: ` ${styles2.label} ${enabled2 ? styles2.labelActive : styles2.labelInactive}`,
6506
+ children: placeholder[1]
6507
+ })]
6508
+ }), typeof placeholder === "string" && /* @__PURE__ */ jsxs(Fragment, {
6509
+ children: [/* @__PURE__ */ jsx("span", {
6510
+ className: ` ${styles2.switch} ${enabled2 ? styles2.enabled : styles2.notenabled}`
6511
+ }), /* @__PURE__ */ jsx("span", {
6512
+ className: ` ${styles2.label} ${enabled2 ? styles2.labelActive : styles2.labelInactive}`,
6513
+ children: placeholder
6514
+ })]
6515
+ }), !Array.isArray(placeholder) && typeof placeholder !== "string" && /* @__PURE__ */ jsx("span", {
6516
+ className: ` ${styles2.switch} ${enabled2 ? styles2.enabled : styles2.notenabled}`
6517
+ })]
6518
+ });
6519
+ };
6520
+ const group$1 = "_group_2xttg_1";
6521
+ const button$8 = "_button_2xttg_9";
6522
+ const toggleWidth = "_toggleWidth_2xttg_15";
6523
+ const checkbox = "_checkbox_2xttg_23";
6524
+ const enabled = "_enabled_2xttg_49";
6525
+ const notenabled = "_notenabled_2xttg_65";
6526
+ const toggle = "_toggle_2xttg_15";
6527
+ const label$4 = "_label_2xttg_89";
6528
+ const labelActive = "_labelActive_2xttg_97";
6529
+ const labelInactive = "_labelInactive_2xttg_105";
6530
+ const toggleInactive = "_toggleInactive_2xttg_113";
6499
6531
  var styles$B = {
6500
6532
  group: group$1,
6501
6533
  button: button$8,
6534
+ toggleWidth,
6502
6535
  checkbox,
6503
- "switch": "_switch_13otg_25",
6536
+ "switch": "_switch_2xttg_31",
6504
6537
  enabled,
6505
6538
  notenabled,
6539
+ toggle,
6506
6540
  label: label$4,
6507
6541
  labelActive,
6508
- labelInactive
6542
+ labelInactive,
6543
+ toggleInactive
6544
+ };
6545
+ const Toggle = ({
6546
+ name,
6547
+ styles: styles2,
6548
+ placeholder,
6549
+ enabled: enabled2
6550
+ }) => {
6551
+ return /* @__PURE__ */ jsxs("label", {
6552
+ htmlFor: name,
6553
+ className: `${styles2.button} ${styles2.toggleWidth}`,
6554
+ children: [Array.isArray(placeholder) && /* @__PURE__ */ jsxs(Fragment, {
6555
+ children: [/* @__PURE__ */ jsx("span", {
6556
+ className: ` ${styles2.label} ${enabled2 && styles2.toggleInactive}`,
6557
+ children: placeholder[0]
6558
+ }), /* @__PURE__ */ jsx("span", {
6559
+ className: ` ${styles2.switch} ${styles2.toggle} ${enabled2 ? styles2.enabled : styles2.notenabled}
6560
+ `
6561
+ }), /* @__PURE__ */ jsx("span", {
6562
+ className: ` ${styles2.label} ${enabled2 || styles2.toggleInactive}`,
6563
+ children: placeholder[1]
6564
+ })]
6565
+ }), typeof placeholder === "string" && /* @__PURE__ */ jsxs(Fragment, {
6566
+ children: [/* @__PURE__ */ jsx("span", {
6567
+ className: ` ${styles2.switch} ${styles2.toggle} ${enabled2 ? styles2.enabled : styles2.notenabled}
6568
+ `
6569
+ }), /* @__PURE__ */ jsx("span", {
6570
+ className: ` ${styles2.label} ${enabled2 || styles2.labelInactive}`,
6571
+ children: placeholder
6572
+ })]
6573
+ }), !Array.isArray(placeholder) && typeof placeholder !== "string" && /* @__PURE__ */ jsx("span", {
6574
+ className: ` ${styles2.switch} ${styles2.toggle} ${enabled2 ? styles2.enabled : styles2.notenabled}
6575
+ `
6576
+ })]
6577
+ });
6509
6578
  };
6510
6579
  const ToggleButton = ({
6511
6580
  enabled: enabled2,
6581
+ variant = "switch",
6512
6582
  onChange,
6513
6583
  label: label2,
6514
6584
  className = "",
@@ -6532,18 +6602,16 @@ const ToggleButton = ({
6532
6602
  target
6533
6603
  }) => onChange == null ? void 0 : onChange(target.checked),
6534
6604
  className: styles$B.checkbox
6535
- }), /* @__PURE__ */ jsxs("label", {
6536
- htmlFor: name,
6537
- className: styles$B.button,
6538
- children: [/* @__PURE__ */ jsx("span", {
6539
- className: `${styles$B.switch} ${enabled2 ? styles$B.enabled : styles$B.notenabled}`
6540
- }), placeholder ? /* @__PURE__ */ jsx("span", {
6541
- className: `
6542
- ${styles$B.label}
6543
- ${enabled2 ? styles$B.labelActive : styles$B.labelInactive}
6544
- `,
6545
- children: placeholder
6546
- }) : null]
6605
+ }), variant === "toggle" && /* @__PURE__ */ jsx(Toggle, {
6606
+ name,
6607
+ styles: styles$B,
6608
+ placeholder,
6609
+ enabled: enabled2
6610
+ }), variant === "switch" && /* @__PURE__ */ jsx(Switch, {
6611
+ name,
6612
+ styles: styles$B,
6613
+ placeholder,
6614
+ enabled: enabled2
6547
6615
  })]
6548
6616
  });
6549
6617
  };
@@ -86704,38 +86772,41 @@ const FilterField = ({
86704
86772
  })
86705
86773
  });
86706
86774
  };
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";
86775
+ const container$9 = "_container_158ok_1";
86776
+ const form$1 = "_form_158ok_7";
86777
+ const filterHeader = "_filterHeader_158ok_13";
86778
+ const titleContent = "_titleContent_158ok_19";
86779
+ const title = "_title_158ok_19";
86780
+ const buttons = "_buttons_158ok_31";
86781
+ const apply = "_apply_158ok_37";
86782
+ const applyIcon = "_applyIcon_158ok_43";
86783
+ const reset = "_reset_158ok_49";
86784
+ const filterFields = "_filterFields_158ok_55";
86785
+ const AddFilter$1 = "_AddFilter_158ok_61";
86786
+ const filterDropdown$1 = "_filterDropdown_158ok_67";
86787
+ const filters = "_filters_158ok_73";
86788
+ const filterItem = "_filterItem_158ok_79";
86789
+ const filterItemOperator = "_filterItemOperator_158ok_85";
86790
+ const remove = "_remove_158ok_91";
86791
+ const filterCol = "_filterCol_158ok_97";
86792
+ const filterText = "_filterText_158ok_103";
86793
+ const smallText = "_smallText_158ok_109";
86794
+ const numberField = "_numberField_158ok_117";
86795
+ const numberFieldWrapper = "_numberFieldWrapper_158ok_125";
86796
+ const numberFieldLabel = "_numberFieldLabel_158ok_133";
86797
+ const numberFieldLabelText = "_numberFieldLabelText_158ok_141";
86798
+ const numberFieldLabelSelectText = "_numberFieldLabelSelectText_158ok_149";
86799
+ const numberFieldButtonClass = "_numberFieldButtonClass_158ok_157";
86800
+ const numberFieldLabelMenuClass = "_numberFieldLabelMenuClass_158ok_165";
86801
+ const checkedOption$1 = "_checkedOption_158ok_173";
86802
+ const option = "_option_158ok_181";
86803
+ const addFilterMenu = "_addFilterMenu_158ok_189";
86804
+ const appliedFilterTag = "_appliedFilterTag_158ok_197";
86805
+ const appliedfilters = "_appliedfilters_158ok_205";
86806
+ const textBold = "_textBold_158ok_213";
86807
+ const filterButton = "_filterButton_158ok_221";
86808
+ const filterBtnText = "_filterBtnText_158ok_229";
86809
+ const filterLength = "_filterLength_158ok_237";
86739
86810
  var styles$s = {
86740
86811
  container: container$9,
86741
86812
  form: form$1,
@@ -86768,7 +86839,10 @@ var styles$s = {
86768
86839
  addFilterMenu,
86769
86840
  appliedFilterTag,
86770
86841
  appliedfilters,
86771
- textBold
86842
+ textBold,
86843
+ filterButton,
86844
+ filterBtnText,
86845
+ filterLength
86772
86846
  };
86773
86847
  const NumberFilterField = ({
86774
86848
  setAppliedFilters,
@@ -86903,6 +86977,48 @@ const AddFilter = ({
86903
86977
  })
86904
86978
  });
86905
86979
  };
86980
+ const AppliedFilter = ({
86981
+ appliedFilter,
86982
+ setAppliedFilters,
86983
+ onChangeFilters
86984
+ }) => {
86985
+ return /* @__PURE__ */ jsx("div", {
86986
+ className: styles$s.appliedfilters,
86987
+ children: appliedFilter.map((filter2) => /* @__PURE__ */ jsxs("div", {
86988
+ className: styles$s.appliedFilterTag,
86989
+ children: [/* @__PURE__ */ jsx(Text, {
86990
+ variant: "p",
86991
+ styleClass: "font-14",
86992
+ className: styles$s.textBold,
86993
+ children: filter2.column
86994
+ }), /* @__PURE__ */ jsx(Text, {
86995
+ variant: "p",
86996
+ styleClass: "font-14",
86997
+ children: "is"
86998
+ }), filter2.as !== "string" && filter2.as !== "boolean" && filter2.as !== "default" && /* @__PURE__ */ jsx(Text, {
86999
+ variant: "p",
87000
+ styleClass: "font-14",
87001
+ children: "between"
87002
+ }), /* @__PURE__ */ jsx(Text, {
87003
+ variant: "p",
87004
+ styleClass: "font-14",
87005
+ className: styles$s.textBold,
87006
+ 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
87007
+ }), /* @__PURE__ */ jsx(Button, {
87008
+ variant: "secondary",
87009
+ type: "button",
87010
+ onClick: () => {
87011
+ setAppliedFilters((prev) => prev.filter((a4) => a4.column !== filter2.column));
87012
+ const filterColumns = appliedFilter.filter((c3) => c3.column !== filter2.column);
87013
+ onChangeFilters(filterColumns);
87014
+ },
87015
+ children: /* @__PURE__ */ jsx(Icons, {
87016
+ name: "close-icon"
87017
+ })
87018
+ })]
87019
+ }))
87020
+ });
87021
+ };
86906
87022
  const groupArray = (array, key) => {
86907
87023
  return array.reduce((acc, item) => {
86908
87024
  const group2 = item[key];
@@ -95321,6 +95437,9 @@ const DateRangePicker = ({
95321
95437
  if (type3 === "month") {
95322
95438
  const lastThreeMonths = new Date();
95323
95439
  lastThreeMonths.setMonth(lastThreeMonths.getMonth() + startOffset);
95440
+ if (startOffset === 0) {
95441
+ lastThreeMonths.setDate(1);
95442
+ }
95324
95443
  setStartDate(lastThreeMonths);
95325
95444
  setEndDate(new Date());
95326
95445
  } else if (type3 === "year") {
@@ -95461,21 +95580,22 @@ const GlobalFilters = ({
95461
95580
  onApply,
95462
95581
  companyId,
95463
95582
  renderAdditionalHeaderContent,
95464
- externalDashboardId,
95465
- appliedfilters: appliedfilters2,
95466
- setAppliedFilters
95583
+ externalDashboardId
95467
95584
  }) => {
95585
+ const [appliedfilters2, setAppliedFilters] = useState([]);
95586
+ const globalFilterRef = useRef(null);
95468
95587
  const [filterList, setFilterList] = useState([]);
95469
95588
  const resetFilters = () => {
95589
+ var _a2;
95470
95590
  setAppliedFilters([]);
95471
95591
  onApply({
95472
95592
  tableName: "",
95473
95593
  filters: []
95474
95594
  });
95595
+ (_a2 = globalFilterRef.current) == null ? void 0 : _a2.click();
95475
95596
  };
95476
- const handleSubmit = (e3) => {
95477
- e3.preventDefault();
95478
- const filterColumns = appliedfilters2.map((field2) => {
95597
+ const onChangeFilters = (updatedFilters) => {
95598
+ const filterColumns = updatedFilters.map((field2) => {
95479
95599
  const col = {
95480
95600
  column: field2.column,
95481
95601
  operator: field2.operator,
@@ -95498,6 +95618,12 @@ const GlobalFilters = ({
95498
95618
  filters: filterColumns
95499
95619
  });
95500
95620
  };
95621
+ const handleSubmit = (e3) => {
95622
+ var _a2;
95623
+ e3.preventDefault();
95624
+ onChangeFilters(appliedfilters2);
95625
+ (_a2 = globalFilterRef.current) == null ? void 0 : _a2.click();
95626
+ };
95501
95627
  const getSelectedOption = useCallback((col, type3) => {
95502
95628
  var _a2;
95503
95629
  const colValue = ((_a2 = appliedfilters2.find((filter2) => filter2.column === col)) == null ? void 0 : _a2.value) || "";
@@ -95544,148 +95670,183 @@ const GlobalFilters = ({
95544
95670
  useEffect(() => {
95545
95671
  if (filters2[0].columns.length) {
95546
95672
  setFilterList(filters2[0].columns.filter((col) => col.isDefault));
95673
+ } else {
95674
+ setAppliedFilters([]);
95675
+ onApply({
95676
+ tableName: filters2[0].tableName,
95677
+ filters: []
95678
+ });
95547
95679
  }
95548
95680
  }, [filters2]);
95681
+ useEffect(() => {
95682
+ setAppliedFilters([]);
95683
+ onApply({
95684
+ tableName: filters2[0].tableName,
95685
+ filters: []
95686
+ });
95687
+ }, [externalDashboardId]);
95549
95688
  return /* @__PURE__ */ jsx(Fragment, {
95550
- children: (data == null ? void 0 : data.companyIntegrations.length) && !isLoading && /* @__PURE__ */ jsx("div", {
95551
- className: styles$s.container,
95552
- children: /* @__PURE__ */ jsxs("form", {
95553
- className: styles$s.form,
95554
- onSubmit: handleSubmit,
95555
- onReset: resetFilters,
95556
- children: [/* @__PURE__ */ jsx("div", {
95557
- className: styles$s.filterHeader,
95558
- children: /* @__PURE__ */ jsxs("div", {
95559
- className: styles$s.titleContent,
95560
- children: [/* @__PURE__ */ jsx(Text, {
95561
- variant: "p",
95562
- styleClass: "primary",
95563
- className: styles$s.title,
95564
- children: "Filters"
95565
- }), renderAdditionalHeaderContent ? renderAdditionalHeaderContent() : null]
95566
- })
95567
- }), /* @__PURE__ */ jsx("div", {
95568
- className: styles$s.filterFields,
95569
- children: filterList.map((col) => {
95570
- var _a2, _b2;
95571
- return /* @__PURE__ */ jsx(Fragment, {
95689
+ children: (data == null ? void 0 : data.companyIntegrations.length) && !isLoading && /* @__PURE__ */ jsxs(Fragment, {
95690
+ children: [/* @__PURE__ */ jsx(PopoverMenu, {
95691
+ button: /* @__PURE__ */ jsxs("div", {
95692
+ className: styles$s.filterButton,
95693
+ ref: globalFilterRef,
95694
+ children: [/* @__PURE__ */ jsxs("div", {
95695
+ className: styles$s.filterBtnText,
95696
+ children: [/* @__PURE__ */ jsx(Icons, {
95697
+ name: "filter-icon"
95698
+ }), " Filters"]
95699
+ }), appliedfilters2.length === 0 ? null : /* @__PURE__ */ jsx("span", {
95700
+ className: styles$s.filterLength,
95701
+ children: appliedfilters2.length
95702
+ })]
95703
+ }),
95704
+ position: "bottom-left",
95705
+ children: /* @__PURE__ */ jsx("div", {
95706
+ className: styles$s.container,
95707
+ children: /* @__PURE__ */ jsxs("form", {
95708
+ className: styles$s.form,
95709
+ onSubmit: handleSubmit,
95710
+ onReset: resetFilters,
95711
+ children: [/* @__PURE__ */ jsx("div", {
95712
+ className: styles$s.filterHeader,
95572
95713
  children: /* @__PURE__ */ jsxs("div", {
95573
- className: styles$s.filterDropdown,
95574
- children: [col.as === "date" && /* @__PURE__ */ jsx(Fragment, {
95575
- children: /* @__PURE__ */ jsx(DateRangePicker, {
95576
- label: col.label || col.name,
95577
- defaultValues: (_a2 = appliedfilters2.find((filter2) => filter2.column === col.name)) == null ? void 0 : _a2.defaultValues,
95578
- onChange: (option2) => {
95579
- if (option2)
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
- });
95588
- const field2 = {
95589
- column: col.name,
95590
- operator: "=",
95591
- value,
95592
- as: col.as,
95593
- defaultValues: option2
95594
- };
95595
- const index2 = prev.findIndex((f2) => f2.column === col.name);
95596
- if (index2 === -1)
95597
- return [...prev, field2];
95598
- const updated = [...prev];
95599
- updated[index2] = field2;
95600
- return updated;
95601
- });
95602
- }
95714
+ className: styles$s.titleContent,
95715
+ children: [/* @__PURE__ */ jsx(Text, {
95716
+ variant: "p",
95717
+ styleClass: "primary",
95718
+ className: styles$s.title,
95719
+ children: "Filters"
95720
+ }), renderAdditionalHeaderContent ? renderAdditionalHeaderContent() : null]
95721
+ })
95722
+ }), /* @__PURE__ */ jsx("div", {
95723
+ className: styles$s.filterFields,
95724
+ children: filterList.map((col) => {
95725
+ var _a2, _b2;
95726
+ return /* @__PURE__ */ jsx(Fragment, {
95727
+ children: /* @__PURE__ */ jsxs("div", {
95728
+ className: styles$s.filterDropdown,
95729
+ children: [col.as === "date" && /* @__PURE__ */ jsx(Fragment, {
95730
+ children: /* @__PURE__ */ jsx(DateRangePicker, {
95731
+ label: col.label || col.name,
95732
+ defaultValues: (_a2 = appliedfilters2.find((filter2) => filter2.column === col.name)) == null ? void 0 : _a2.defaultValues,
95733
+ onChange: (option2) => {
95734
+ if (option2)
95735
+ setAppliedFilters((prev) => {
95736
+ const isTimeStamp = col.as.toLowerCase() !== "date";
95737
+ const value = getTimeFilterValue({
95738
+ timeGrainValue: option2.value,
95739
+ isTimeStamp,
95740
+ col: getColumnString(col.name),
95741
+ database: integrationName
95742
+ });
95743
+ const field2 = {
95744
+ column: col.name,
95745
+ operator: "=",
95746
+ value,
95747
+ as: col.as,
95748
+ defaultValues: option2
95749
+ };
95750
+ const index2 = prev.findIndex((f2) => f2.column === col.name);
95751
+ if (index2 === -1)
95752
+ return [...prev, field2];
95753
+ const updated = [...prev];
95754
+ updated[index2] = field2;
95755
+ return updated;
95756
+ });
95757
+ }
95758
+ })
95759
+ }), col.as === "number" && /* @__PURE__ */ jsx(NumberFilterField, {
95760
+ setAppliedFilters,
95761
+ column: col,
95762
+ defaultValues: (_b2 = appliedfilters2.find((filter2) => filter2.column === col.name)) == null ? void 0 : _b2.defaultValues
95763
+ }), col.as === "string" && /* @__PURE__ */ jsx(MultiFilterDropdown, {
95764
+ filter: {
95765
+ tableName: filters2[0].tableName,
95766
+ columnName: col.name
95767
+ },
95768
+ companyId,
95769
+ selectedOptions: getSelectedOption(col.name, "string") || [],
95770
+ autoSelected: false,
95771
+ onChange: (options2) => setAppliedFilters((prev) => {
95772
+ const field2 = {
95773
+ column: col.name,
95774
+ operator: "IN",
95775
+ value: options2.map((v4) => v4.value),
95776
+ as: col.as
95777
+ };
95778
+ const index2 = prev.findIndex((f2) => f2.column === col.name);
95779
+ if (index2 === -1)
95780
+ return [...prev, field2];
95781
+ const updated = [...prev];
95782
+ updated[index2] = field2;
95783
+ return updated;
95784
+ }),
95785
+ isSearchEnabled: true,
95786
+ integrationId,
95787
+ integrationName,
95788
+ label: col.label || col.name
95789
+ }), col.as === "default" || col.as === "boolean" ? /* @__PURE__ */ jsx(FilterDropDown, {
95790
+ filter: {
95791
+ tableName: filters2[0].tableName,
95792
+ columnName: col.name
95793
+ },
95794
+ companyId,
95795
+ selectedOption: getSelectedOption(col.name, "boolean"),
95796
+ autoSelected: false,
95797
+ onChange: (option2) => setAppliedFilters((prev) => {
95798
+ const field2 = {
95799
+ column: col.name,
95800
+ operator: "=",
95801
+ value: option2.value,
95802
+ as: col.as
95803
+ };
95804
+ const index2 = prev.findIndex((f2) => f2.column === col.name);
95805
+ if (index2 === -1)
95806
+ return [...prev, field2];
95807
+ const updated = [...prev];
95808
+ updated[index2] = field2;
95809
+ return updated;
95810
+ }),
95811
+ isSearchEnabled: true,
95812
+ integrationId,
95813
+ integrationName,
95814
+ label: col.label || col.name
95815
+ }) : null]
95603
95816
  })
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, {
95635
- filter: {
95636
- tableName: filters2[0].tableName,
95637
- columnName: col.name
95638
- },
95639
- companyId,
95640
- selectedOption: getSelectedOption(col.name, "boolean"),
95641
- autoSelected: false,
95642
- onChange: (option2) => setAppliedFilters((prev) => {
95643
- const field2 = {
95644
- column: col.name,
95645
- operator: "=",
95646
- value: option2.value,
95647
- as: col.as
95648
- };
95649
- const index2 = prev.findIndex((f2) => f2.column === col.name);
95650
- if (index2 === -1)
95651
- return [...prev, field2];
95652
- const updated = [...prev];
95653
- updated[index2] = field2;
95654
- return updated;
95655
- }),
95656
- isSearchEnabled: true,
95657
- integrationId,
95658
- integrationName,
95659
- label: col.label || col.name
95660
- }) : null]
95817
+ });
95661
95818
  })
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
95819
+ }), /* @__PURE__ */ jsx("div", {
95820
+ className: styles$s.AddFilter,
95821
+ children: /* @__PURE__ */ jsx(AddFilter, {
95822
+ columnList: filters2[0].columns.filter((col) => !col.isDefault),
95823
+ setFilterList,
95824
+ filterList
95825
+ })
95826
+ }), /* @__PURE__ */ jsxs("div", {
95827
+ className: styles$s.buttons,
95828
+ children: [/* @__PURE__ */ jsxs(Button, {
95829
+ type: "reset",
95830
+ variant: "secondary",
95831
+ className: styles$s.reset,
95832
+ children: [/* @__PURE__ */ jsx(Icons, {
95833
+ name: "reset-icon",
95834
+ className: styles$s.applyIcon
95835
+ }), " ", "Reset Filters"]
95836
+ }), /* @__PURE__ */ jsx(Button, {
95837
+ type: "submit",
95838
+ variant: "primary",
95839
+ className: styles$s.apply,
95840
+ children: "Apply"
95841
+ })]
95842
+ })]
95670
95843
  })
95671
- }), /* @__PURE__ */ jsxs("div", {
95672
- className: styles$s.buttons,
95673
- children: [/* @__PURE__ */ jsxs(Button, {
95674
- type: "reset",
95675
- variant: "secondary",
95676
- className: styles$s.reset,
95677
- children: [/* @__PURE__ */ jsx(Icons, {
95678
- name: "reset-icon",
95679
- className: styles$s.applyIcon
95680
- }), " Reset Filters"]
95681
- }), /* @__PURE__ */ jsx(Button, {
95682
- type: "submit",
95683
- variant: "primary",
95684
- className: styles$s.apply,
95685
- children: "Apply"
95686
- })]
95687
- })]
95688
- })
95844
+ })
95845
+ }), /* @__PURE__ */ jsx(AppliedFilter, {
95846
+ appliedFilter: appliedfilters2,
95847
+ setAppliedFilters,
95848
+ onChangeFilters: (updatedFilters) => onChangeFilters(updatedFilters)
95849
+ })]
95689
95850
  })
95690
95851
  });
95691
95852
  };
@@ -130163,60 +130324,60 @@ var styles$b = {
130163
130324
  "alt-container": "_alt-container_170un_49",
130164
130325
  fullscreen: fullscreen$2
130165
130326
  };
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";
130327
+ const cardContainer = "_cardContainer_sacr7_1";
130328
+ const listHeader = "_listHeader_sacr7_9";
130329
+ const metricName = "_metricName_sacr7_17";
130330
+ const metricTitle = "_metricTitle_sacr7_25";
130331
+ const metricDescription = "_metricDescription_sacr7_33";
130332
+ const popup = "_popup_sacr7_41";
130333
+ const metricFilter$1 = "_metricFilter_sacr7_49";
130334
+ const popupIcon = "_popupIcon_sacr7_57";
130335
+ const popupMenu = "_popupMenu_sacr7_65";
130336
+ const popupItem = "_popupItem_sacr7_73";
130337
+ const popupItemIcon = "_popupItemIcon_sacr7_81";
130338
+ const csvBtn = "_csvBtn_sacr7_89";
130339
+ const deleteBtn = "_deleteBtn_sacr7_97";
130340
+ const metricData = "_metricData_sacr7_105";
130341
+ const metricTable = "_metricTable_sacr7_113";
130342
+ const singleValueData = "_singleValueData_sacr7_121";
130343
+ const singleValue = "_singleValue_sacr7_121";
130344
+ const noData = "_noData_sacr7_137";
130345
+ const noDataContent = "_noDataContent_sacr7_145";
130346
+ const noDataText = "_noDataText_sacr7_153";
130347
+ const loading$1 = "_loading_sacr7_161";
130348
+ const features = "_features_sacr7_169";
130349
+ const fullscreen$1 = "_fullscreen_sacr7_177";
130350
+ const deleteModal = "_deleteModal_sacr7_185";
130351
+ const cancelBtn = "_cancelBtn_sacr7_193";
130352
+ const warningIcon = "_warningIcon_sacr7_201";
130353
+ const downloadCsv = "_downloadCsv_sacr7_209";
130354
+ const downloadCsvWrapper = "_downloadCsvWrapper_sacr7_217";
130355
+ const downloadCsvHeader = "_downloadCsvHeader_sacr7_225";
130356
+ const downloadCsvFooter = "_downloadCsvFooter_sacr7_233";
130357
+ const downloadCsvCancelBtn = "_downloadCsvCancelBtn_sacr7_241";
130358
+ const downloadCsvDisableBtn = "_downloadCsvDisableBtn_sacr7_247";
130359
+ const downloadCsvNote = "_downloadCsvNote_sacr7_253";
130360
+ const downloadCsvExpiredNote = "_downloadCsvExpiredNote_sacr7_261";
130361
+ const downloadCsvNoteText = "_downloadCsvNoteText_sacr7_267";
130362
+ const downloadCsvSuccessNote = "_downloadCsvSuccessNote_sacr7_273";
130363
+ const downloadCsvSuccessText = "_downloadCsvSuccessText_sacr7_279";
130364
+ const downloadUrlTimeline = "_downloadUrlTimeline_sacr7_301";
130365
+ const timeLineItem = "_timeLineItem_sacr7_309";
130366
+ const timeLineActiveIcon = "_timeLineActiveIcon_sacr7_317";
130367
+ const timeLineIcon = "_timeLineIcon_sacr7_325";
130368
+ const timeLineItemline = "_timeLineItemline_sacr7_333";
130369
+ const downloadCsvLoading = "_downloadCsvLoading_sacr7_341";
130370
+ const downloadCsvLoadingIcon = "_downloadCsvLoadingIcon_sacr7_349";
130371
+ const downloadCsvLoadingText = "_downloadCsvLoadingText_sacr7_357";
130372
+ const timeLineCheckedIcon = "_timeLineCheckedIcon_sacr7_365";
130373
+ const timeLineCheckedIconWrapper = "_timeLineCheckedIconWrapper_sacr7_373";
130374
+ const downloadCsvBackBtnWrapper = "_downloadCsvBackBtnWrapper_sacr7_381";
130375
+ const downloadCsvBackBtnText = "_downloadCsvBackBtnText_sacr7_389";
130376
+ const downloadCsvHeaderText = "_downloadCsvHeaderText_sacr7_411";
130377
+ const downloadCsvTabContainer = "_downloadCsvTabContainer_sacr7_419";
130378
+ const downloadCsvActiveTab = "_downloadCsvActiveTab_sacr7_427";
130379
+ const downloadCsvTab = "_downloadCsvTab_sacr7_419";
130380
+ const downloadCsvActiveTabText = "_downloadCsvActiveTabText_sacr7_443";
130220
130381
  var styles$a = {
130221
130382
  cardContainer,
130222
130383
  listHeader,
@@ -130255,8 +130416,8 @@ var styles$a = {
130255
130416
  downloadCsvNoteText,
130256
130417
  downloadCsvSuccessNote,
130257
130418
  downloadCsvSuccessText,
130258
- "tab-border-bottom": "_tab-border-bottom_pprak_285",
130259
- "download-info-text": "_download-info-text_pprak_293",
130419
+ "tab-border-bottom": "_tab-border-bottom_sacr7_285",
130420
+ "download-info-text": "_download-info-text_sacr7_293",
130260
130421
  downloadUrlTimeline,
130261
130422
  timeLineItem,
130262
130423
  timeLineActiveIcon,
@@ -131115,7 +131276,7 @@ const MetricCard = ({
131115
131276
  color: "blue"
131116
131277
  }
131117
131278
  })
131118
- }), (drillDownSettings == null ? void 0 : drillDownSettings.isEnableGroupBy) && /* @__PURE__ */ jsx(DrillBreadCrumb, {
131279
+ }), (drillDownSettings == null ? void 0 : drillDownSettings.isEnableGroupBy) && !!dataDb.length && /* @__PURE__ */ jsx(DrillBreadCrumb, {
131119
131280
  dimensions: drillDownSettings.selectedDimensions,
131120
131281
  drilledLevel
131121
131282
  }), (chartParams == null ? void 0 : chartParams.name) && columnName && /* @__PURE__ */ jsx(ChartPopup$1, {
@@ -132610,65 +132771,6 @@ const MetricTable = ({
132610
132771
  })]
132611
132772
  });
132612
132773
  };
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
- };
132672
132774
  var index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
132673
132775
  __proto__: null,
132674
132776
  Button,
@@ -133326,7 +133428,6 @@ const EmbeddedDashboard = e__default.memo(({
133326
133428
  data,
133327
133429
  isLoading
133328
133430
  } = useDashboardContext();
133329
- const [appliedfilters2, setAppliedFilters] = useState([]);
133330
133431
  const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
133331
133432
  const [globalFilters, setGlobalFilters] = useState({
133332
133433
  tableName: "",
@@ -133348,7 +133449,6 @@ const EmbeddedDashboard = e__default.memo(({
133348
133449
  return [adminThemeData == null ? void 0 : adminThemeData.themes[0], colors2];
133349
133450
  }, [adminThemeData == null ? void 0 : adminThemeData.themes[0]]);
133350
133451
  useApplyAdminTheme(adminTheme);
133351
- const globalFilterRef = useRef(null);
133352
133452
  return /* @__PURE__ */ jsx(Fragment, {
133353
133453
  children: /* @__PURE__ */ jsxs("div", {
133354
133454
  className: styles$M["embedDashboard-container"],
@@ -133389,46 +133489,13 @@ const EmbeddedDashboard = e__default.memo(({
133389
133489
  })]
133390
133490
  }), /* @__PURE__ */ jsxs("div", {
133391
133491
  className: styles$M["embedDashboard-wrapper"],
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
- })]
133492
+ children: [data.externalDashboard.filters.length ? /* @__PURE__ */ jsx(GlobalFilters, {
133493
+ companyId: data.companyId,
133494
+ externalDashboardId: data.externalDashboard.id,
133495
+ filters: data.externalDashboard.filters,
133496
+ onApply: (values) => {
133497
+ setGlobalFilters(values);
133498
+ }
133432
133499
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
133433
133500
  client: data.clientId,
133434
133501
  isLiveMode: data.isLiveMode,