@databrainhq/plugin 0.7.18 → 0.7.19

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
@@ -2554,6 +2554,7 @@ var styles$C = {
2554
2554
  truncate,
2555
2555
  border,
2556
2556
  "p-2": "_p-2_1ddns_1",
2557
+ "p-1": "_p-1_1ddns_1",
2557
2558
  "text-center": "_text-center_1ddns_1",
2558
2559
  "text-sm": "_text-sm_1ddns_1",
2559
2560
  "text-xs": "_text-xs_1ddns_1",
@@ -91462,10 +91463,23 @@ const MetricCard = ({
91462
91463
  updateGroupData(dataDb, [selectedGroupBy[0]], selectedGroupBy, setGroupedData);
91463
91464
  }
91464
91465
  };
91465
- const onChangeFilterValue = (name, value) => setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91466
- ...rls,
91467
- value
91468
- } : rls));
91466
+ const onChangeFilterValue = (name, value, customValue) => {
91467
+ if (customValue) {
91468
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91469
+ ...rls,
91470
+ value,
91471
+ options: rls.options.map((option2) => option2.name === "Custom" ? {
91472
+ ...option2,
91473
+ ...customValue
91474
+ } : option2)
91475
+ } : rls));
91476
+ } else {
91477
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91478
+ ...rls,
91479
+ value
91480
+ } : rls));
91481
+ }
91482
+ };
91469
91483
  return /* @__PURE__ */ jsx(Fragment, {
91470
91484
  children: /* @__PURE__ */ jsxs("div", {
91471
91485
  className: styles.cardContainer,
@@ -91503,7 +91517,7 @@ const MetricCard = ({
91503
91517
  })]
91504
91518
  }), /* @__PURE__ */ jsxs("div", {
91505
91519
  className: styles.features,
91506
- children: [!!rlsConditions.length && /* @__PURE__ */ jsx("div", {
91520
+ children: [!!rlsConditions.length && (rlsConditions[0].datatype !== "date" ? /* @__PURE__ */ jsx("div", {
91507
91521
  className: styles.metricFilter,
91508
91522
  children: /* @__PURE__ */ jsx(FloatingDropDown, {
91509
91523
  label: rlsConditions[0].name,
@@ -91517,7 +91531,47 @@ const MetricCard = ({
91517
91531
  })),
91518
91532
  onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value)
91519
91533
  })
91520
- }), /* @__PURE__ */ jsxs(PopoverMenu, {
91534
+ }) : /* @__PURE__ */ jsx("div", {
91535
+ className: styles.metricFilter,
91536
+ children: /* @__PURE__ */ jsx(FloatingDropDown, {
91537
+ label: rlsConditions[0].name,
91538
+ selectedOption: {
91539
+ value: rlsConditions[0].value.name || rlsConditions[0].options[0].name,
91540
+ label: rlsConditions[0].value.name || rlsConditions[0].options[0].name
91541
+ },
91542
+ options: rlsConditions[0].options.map((o2) => ({
91543
+ value: o2.name,
91544
+ label: o2.name
91545
+ })),
91546
+ onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value),
91547
+ children: rlsConditions[0].value === "Custom" ? /* @__PURE__ */ jsxs("div", {
91548
+ className: "p-1",
91549
+ children: [/* @__PURE__ */ jsx(InputField, {
91550
+ label: "From Date",
91551
+ type: "date",
91552
+ onChange: ({
91553
+ target: {
91554
+ value
91555
+ }
91556
+ }) => {
91557
+ onChangeFilterValue(rlsConditions[0].name, "Custom", {
91558
+ from: new Date(Date.parse(value))
91559
+ });
91560
+ }
91561
+ }), /* @__PURE__ */ jsx(InputField, {
91562
+ label: "To Date",
91563
+ type: "date",
91564
+ onChange: ({
91565
+ target: {
91566
+ value
91567
+ }
91568
+ }) => onChangeFilterValue(rlsConditions[0].name, "Custom", {
91569
+ to: new Date(Date.parse(value))
91570
+ })
91571
+ })]
91572
+ }) : null
91573
+ })
91574
+ })), /* @__PURE__ */ jsxs(PopoverMenu, {
91521
91575
  buttonClass: styles.popup,
91522
91576
  button: /* @__PURE__ */ jsx(Icons, {
91523
91577
  name: "more-icon",
@@ -91733,10 +91787,23 @@ const SingleValueCard = ({
91733
91787
  const chartData = [{
91734
91788
  value: singleValueData2[0]
91735
91789
  }];
91736
- const onChangeFilterValue = (name, value) => setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91737
- ...rls,
91738
- value
91739
- } : rls));
91790
+ const onChangeFilterValue = (name, value, customValue) => {
91791
+ if (customValue) {
91792
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91793
+ ...rls,
91794
+ value,
91795
+ options: rls.options.map((option2) => option2.name === "Custom" ? {
91796
+ ...option2,
91797
+ ...customValue
91798
+ } : option2)
91799
+ } : rls));
91800
+ } else {
91801
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91802
+ ...rls,
91803
+ value
91804
+ } : rls));
91805
+ }
91806
+ };
91740
91807
  return /* @__PURE__ */ jsx(Fragment, {
91741
91808
  children: /* @__PURE__ */ jsxs("div", {
91742
91809
  className: styles.cardContainer,
@@ -91774,7 +91841,7 @@ const SingleValueCard = ({
91774
91841
  })]
91775
91842
  }), /* @__PURE__ */ jsx("div", {
91776
91843
  className: styles.features,
91777
- children: !!(rlsConditions == null ? void 0 : rlsConditions.length) && /* @__PURE__ */ jsx("div", {
91844
+ children: !!rlsConditions.length && (rlsConditions[0].datatype !== "date" ? /* @__PURE__ */ jsx("div", {
91778
91845
  className: styles.metricFilter,
91779
91846
  children: /* @__PURE__ */ jsx(FloatingDropDown, {
91780
91847
  label: rlsConditions[0].name,
@@ -91788,7 +91855,47 @@ const SingleValueCard = ({
91788
91855
  })),
91789
91856
  onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value)
91790
91857
  })
91791
- })
91858
+ }) : /* @__PURE__ */ jsx("div", {
91859
+ className: styles.metricFilter,
91860
+ children: /* @__PURE__ */ jsx(FloatingDropDown, {
91861
+ label: rlsConditions[0].name,
91862
+ selectedOption: {
91863
+ value: rlsConditions[0].value.name || rlsConditions[0].options[0].name,
91864
+ label: rlsConditions[0].value.name || rlsConditions[0].options[0].name
91865
+ },
91866
+ options: rlsConditions[0].options.map((o2) => ({
91867
+ value: o2.name,
91868
+ label: o2.name
91869
+ })),
91870
+ onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value),
91871
+ children: rlsConditions[0].value === "Custom" ? /* @__PURE__ */ jsxs("div", {
91872
+ className: "p-1",
91873
+ children: [/* @__PURE__ */ jsx(InputField, {
91874
+ label: "From Date",
91875
+ type: "date",
91876
+ onChange: ({
91877
+ target: {
91878
+ value
91879
+ }
91880
+ }) => {
91881
+ onChangeFilterValue(rlsConditions[0].name, "Custom", {
91882
+ from: new Date(Date.parse(value))
91883
+ });
91884
+ }
91885
+ }), /* @__PURE__ */ jsx(InputField, {
91886
+ label: "To Date",
91887
+ type: "date",
91888
+ onChange: ({
91889
+ target: {
91890
+ value
91891
+ }
91892
+ }) => onChangeFilterValue(rlsConditions[0].name, "Custom", {
91893
+ to: new Date(Date.parse(value))
91894
+ })
91895
+ })]
91896
+ }) : null
91897
+ })
91898
+ }))
91792
91899
  })]
91793
91900
  }), chartType2 && /* @__PURE__ */ jsx("div", {
91794
91901
  className: `${styles.metricData} ${styles.singleValueData}`,