@databrainhq/plugin 0.7.18 → 0.7.20

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",
@@ -82408,6 +82409,17 @@ const Header = ({
82408
82409
  const {
82409
82410
  globalTheme
82410
82411
  } = useGlobalTheme();
82412
+ const saveDashboardStyle = useMemo(() => {
82413
+ var _a2, _b2;
82414
+ if (!globalTheme)
82415
+ return void 0;
82416
+ const style2 = {};
82417
+ if ((_a2 = globalTheme.dashboard.ctaColor) == null ? void 0 : _a2.trim())
82418
+ style2.backgroundColor = globalTheme.dashboard.ctaColor.trim() || void 0;
82419
+ if ((_b2 = globalTheme.dashboard.ctaTextColor) == null ? void 0 : _b2.trim())
82420
+ style2.color = globalTheme.dashboard.ctaTextColor.trim() || void 0;
82421
+ return style2;
82422
+ }, [globalTheme]);
82411
82423
  return /* @__PURE__ */ jsxs("div", {
82412
82424
  className: styles$h["header-container"],
82413
82425
  children: [/* @__PURE__ */ jsxs("div", {
@@ -82443,10 +82455,7 @@ const Header = ({
82443
82455
  className: styles$h["save-btn"],
82444
82456
  isDisabled: isDisableSaveBtn,
82445
82457
  onClick: () => setShowSaveMetricModal(true),
82446
- style: globalTheme ? {
82447
- backgroundColor: `${globalTheme.dashboard.ctaColor} !important`,
82448
- color: `${globalTheme.dashboard.ctaTextColor} !important`
82449
- } : void 0,
82458
+ style: saveDashboardStyle,
82450
82459
  children: [/* @__PURE__ */ jsx(Icons, {
82451
82460
  name: "save-icon",
82452
82461
  className: styles$h["save-btn-icon"]
@@ -84977,6 +84986,17 @@ const MetricForm = ({
84977
84986
  if (isEnableGroupBy)
84978
84987
  setSelectedGroupBy(selectedDimensions);
84979
84988
  }, [selectedDimensions, isEnableGroupBy]);
84989
+ const primaryButtonStyle = useMemo(() => {
84990
+ var _a2, _b2;
84991
+ if (!globalTheme)
84992
+ return void 0;
84993
+ const style2 = {};
84994
+ if ((_a2 = globalTheme.dashboard.ctaColor) == null ? void 0 : _a2.trim())
84995
+ style2.backgroundColor = globalTheme.dashboard.ctaColor.trim() || void 0;
84996
+ if ((_b2 = globalTheme.dashboard.ctaTextColor) == null ? void 0 : _b2.trim())
84997
+ style2.color = globalTheme.dashboard.ctaTextColor.trim() || void 0;
84998
+ return style2;
84999
+ }, [globalTheme]);
84980
85000
  return /* @__PURE__ */ jsxs("div", {
84981
85001
  className: styles$5["form-container"],
84982
85002
  children: [!isDisableTimeColumn && /* @__PURE__ */ jsxs("div", {
@@ -85092,6 +85112,7 @@ const MetricForm = ({
85092
85112
  type: "button",
85093
85113
  variant: "primary",
85094
85114
  size: "small",
85115
+ style: primaryButtonStyle,
85095
85116
  className: styles$5.disabled,
85096
85117
  isDisabled: !metricAggregate.value || !metricColumn.value,
85097
85118
  onClick: () => {
@@ -85183,6 +85204,7 @@ const MetricForm = ({
85183
85204
  type: "button",
85184
85205
  variant: "primary",
85185
85206
  size: "small",
85207
+ style: primaryButtonStyle,
85186
85208
  className: styles$5.disabled,
85187
85209
  isDisabled: !column2.value,
85188
85210
  onClick: () => {
@@ -85280,6 +85302,7 @@ const MetricForm = ({
85280
85302
  variant: "primary",
85281
85303
  size: "small",
85282
85304
  isDisabled: !filterColumn.value || !operator.value || !isFilterValue,
85305
+ style: primaryButtonStyle,
85283
85306
  className: styles$5.disabled,
85284
85307
  onClick: () => {
85285
85308
  setFilters((prev) => [...prev, `${isBigQuery || isMySql ? `${filterColumn.value}` : isMongoDb ? `\`${filterColumn.value}\`` : `"${filterColumn.value}"`} ${operator.value} ${isInFilter ? `(${selectedFilterValues.map((f2) => `'${f2}'`).join(", ")})` : `${filterValue.value ? `'${filterValue.value}'` : ""}`}`]);
@@ -85336,6 +85359,7 @@ const MetricForm = ({
85336
85359
  size: "small",
85337
85360
  isDisabled: !sortColumn.value || isDisableSorting,
85338
85361
  className: styles$5.disabled,
85362
+ style: primaryButtonStyle,
85339
85363
  onClick: () => {
85340
85364
  if (!columns.length) {
85341
85365
  setSort(`${sortAggregate.value}(${isBigQuery || isMySql ? `${sortColumn.value}` : isMongoDb ? `\`${sortColumn.value}\`` : `"${sortColumn.value}"`})`);
@@ -85386,10 +85410,7 @@ const MetricForm = ({
85386
85410
  variant: "primary",
85387
85411
  className: styles$5.generateButton,
85388
85412
  isDisabled: isGeneratingDataset || isDisableGenerate,
85389
- style: globalTheme ? {
85390
- backgroundColor: `${globalTheme.dashboard.ctaColor} !important`,
85391
- color: `${globalTheme.dashboard.ctaTextColor} !important`
85392
- } : void 0,
85413
+ style: primaryButtonStyle,
85393
85414
  onClick: () => {
85394
85415
  var _a2, _b2, _c2;
85395
85416
  setError("");
@@ -85802,6 +85823,17 @@ const EmbeddedMetricCreation = ({
85802
85823
  updateGroupData(data2, [selectedGroupBy[0]], selectedGroupBy, setGroupedData);
85803
85824
  }
85804
85825
  }, [groupedData, isEnableGroupBy, selectedGroupBy]);
85826
+ const createMetricStyle = useMemo(() => {
85827
+ var _a3, _b2;
85828
+ if (!globalTheme)
85829
+ return void 0;
85830
+ const style2 = {};
85831
+ if ((_a3 = globalTheme.dashboard.ctaColor) == null ? void 0 : _a3.trim())
85832
+ style2.backgroundColor = globalTheme.dashboard.ctaColor.trim() || void 0;
85833
+ if ((_b2 = globalTheme.dashboard.ctaTextColor) == null ? void 0 : _b2.trim())
85834
+ style2.color = globalTheme.dashboard.ctaTextColor.trim() || void 0;
85835
+ return style2;
85836
+ }, [globalTheme]);
85805
85837
  return /* @__PURE__ */ jsxs(Fragment, {
85806
85838
  children: [/* @__PURE__ */ jsx(Button, {
85807
85839
  type: "button",
@@ -85809,10 +85841,7 @@ const EmbeddedMetricCreation = ({
85809
85841
  size: "large",
85810
85842
  className: variant === "floating" ? styles$g.floatingCreateButton : "",
85811
85843
  onClick: () => setShowMetricCreateModal(true),
85812
- style: globalTheme ? {
85813
- backgroundColor: `${globalTheme.dashboard.ctaColor} !important`,
85814
- color: `${globalTheme.dashboard.ctaTextColor} !important`
85815
- } : void 0,
85844
+ style: createMetricStyle,
85816
85845
  children: variant === "floating" ? /* @__PURE__ */ jsx(mdiPlus, {
85817
85846
  className: styles$g.floatingCreateButtonIcon
85818
85847
  }) : "Create Metric"
@@ -91462,10 +91491,49 @@ const MetricCard = ({
91462
91491
  updateGroupData(dataDb, [selectedGroupBy[0]], selectedGroupBy, setGroupedData);
91463
91492
  }
91464
91493
  };
91465
- const onChangeFilterValue = (name, value) => setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91466
- ...rls,
91467
- value
91468
- } : rls));
91494
+ const onChangeFilterValue = (name, value, customValue) => {
91495
+ if (customValue) {
91496
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91497
+ ...rls,
91498
+ value,
91499
+ options: rls.options.map((option2) => option2.name === "Custom" ? {
91500
+ ...option2,
91501
+ ...customValue
91502
+ } : option2)
91503
+ } : rls));
91504
+ } else {
91505
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91506
+ ...rls,
91507
+ value
91508
+ } : rls));
91509
+ }
91510
+ };
91511
+ const titleStyle = useMemo(() => {
91512
+ var _a3, _b3, _c3;
91513
+ if (!globalTheme)
91514
+ return void 0;
91515
+ const style2 = {};
91516
+ if ((_a3 = globalTheme.cardTitle.fontWeight) == null ? void 0 : _a3.trim())
91517
+ style2.fontWeight = globalTheme.cardTitle.fontWeight.trim() || void 0;
91518
+ if ((_b3 = globalTheme.cardTitle.color) == null ? void 0 : _b3.trim())
91519
+ style2.color = globalTheme.cardTitle.color.trim() || void 0;
91520
+ if ((_c3 = globalTheme.cardTitle.fontSize) == null ? void 0 : _c3.trim())
91521
+ style2.color = globalTheme.cardTitle.fontSize.trim() || void 0;
91522
+ return style2;
91523
+ }, [globalTheme]);
91524
+ const descriptionStyle = useMemo(() => {
91525
+ var _a3, _b3, _c3;
91526
+ if (!globalTheme)
91527
+ return void 0;
91528
+ const style2 = {};
91529
+ if ((_a3 = globalTheme.cardDescription.fontWeight) == null ? void 0 : _a3.trim())
91530
+ style2.fontWeight = globalTheme.cardDescription.fontWeight.trim() || void 0;
91531
+ if ((_b3 = globalTheme.cardDescription.color) == null ? void 0 : _b3.trim())
91532
+ style2.color = globalTheme.cardDescription.color.trim() || void 0;
91533
+ if ((_c3 = globalTheme.cardDescription.fontSize) == null ? void 0 : _c3.trim())
91534
+ style2.color = globalTheme.cardDescription.fontSize.trim() || void 0;
91535
+ return style2;
91536
+ }, [globalTheme]);
91469
91537
  return /* @__PURE__ */ jsx(Fragment, {
91470
91538
  children: /* @__PURE__ */ jsxs("div", {
91471
91539
  className: styles.cardContainer,
@@ -91475,35 +91543,23 @@ const MetricCard = ({
91475
91543
  variant: "h3",
91476
91544
  styleClass: "primary",
91477
91545
  className: styles.metricName,
91478
- style: globalTheme ? {
91479
- color: globalTheme.cardTitle.color,
91480
- fontWeight: globalTheme.cardTitle.fontWeight,
91481
- fontSize: globalTheme.cardTitle.fontSize
91482
- } : void 0,
91546
+ style: titleStyle,
91483
91547
  children: [renderHeaderName ? renderHeaderName(metricItem.name) : /* @__PURE__ */ jsx(Button, {
91484
91548
  type: "button",
91485
91549
  variant: "custom",
91486
91550
  isDisabled: !clickBehaviourConfigs.card.isEnable,
91487
91551
  className: "disabled:cursor-text",
91488
91552
  onClick: () => handleCardClick(clickBehaviourConfigs, metricItem.metricId, metricItem.id),
91489
- style: globalTheme ? {
91490
- color: globalTheme.cardTitle.color,
91491
- fontWeight: globalTheme.cardTitle.fontWeight,
91492
- fontSize: globalTheme.cardTitle.fontSize
91493
- } : void 0,
91553
+ style: titleStyle,
91494
91554
  children: metricItem.name
91495
91555
  }), metricItem.description && /* @__PURE__ */ jsx("span", {
91496
91556
  className: styles.metricDescription,
91497
- style: globalTheme ? {
91498
- color: globalTheme.cardDescription.color,
91499
- fontWeight: globalTheme.cardDescription.fontWeight,
91500
- fontSize: globalTheme.cardDescription.fontSize
91501
- } : void 0,
91557
+ style: descriptionStyle,
91502
91558
  children: metricItem.description
91503
91559
  })]
91504
91560
  }), /* @__PURE__ */ jsxs("div", {
91505
91561
  className: styles.features,
91506
- children: [!!rlsConditions.length && /* @__PURE__ */ jsx("div", {
91562
+ children: [!!rlsConditions.length && (rlsConditions[0].datatype !== "date" ? /* @__PURE__ */ jsx("div", {
91507
91563
  className: styles.metricFilter,
91508
91564
  children: /* @__PURE__ */ jsx(FloatingDropDown, {
91509
91565
  label: rlsConditions[0].name,
@@ -91517,7 +91573,47 @@ const MetricCard = ({
91517
91573
  })),
91518
91574
  onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value)
91519
91575
  })
91520
- }), /* @__PURE__ */ jsxs(PopoverMenu, {
91576
+ }) : /* @__PURE__ */ jsx("div", {
91577
+ className: styles.metricFilter,
91578
+ children: /* @__PURE__ */ jsx(FloatingDropDown, {
91579
+ label: rlsConditions[0].name,
91580
+ selectedOption: {
91581
+ value: rlsConditions[0].value.name || rlsConditions[0].options[0].name,
91582
+ label: rlsConditions[0].value.name || rlsConditions[0].options[0].name
91583
+ },
91584
+ options: rlsConditions[0].options.map((o2) => ({
91585
+ value: o2.name,
91586
+ label: o2.name
91587
+ })),
91588
+ onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value),
91589
+ children: rlsConditions[0].value === "Custom" ? /* @__PURE__ */ jsxs("div", {
91590
+ className: "p-1",
91591
+ children: [/* @__PURE__ */ jsx(InputField, {
91592
+ label: "From Date",
91593
+ type: "date",
91594
+ onChange: ({
91595
+ target: {
91596
+ value
91597
+ }
91598
+ }) => {
91599
+ onChangeFilterValue(rlsConditions[0].name, "Custom", {
91600
+ from: new Date(Date.parse(value))
91601
+ });
91602
+ }
91603
+ }), /* @__PURE__ */ jsx(InputField, {
91604
+ label: "To Date",
91605
+ type: "date",
91606
+ onChange: ({
91607
+ target: {
91608
+ value
91609
+ }
91610
+ }) => onChangeFilterValue(rlsConditions[0].name, "Custom", {
91611
+ to: new Date(Date.parse(value))
91612
+ })
91613
+ })]
91614
+ }) : null
91615
+ })
91616
+ })), /* @__PURE__ */ jsxs(PopoverMenu, {
91521
91617
  buttonClass: styles.popup,
91522
91618
  button: /* @__PURE__ */ jsx(Icons, {
91523
91619
  name: "more-icon",
@@ -91733,10 +91829,49 @@ const SingleValueCard = ({
91733
91829
  const chartData = [{
91734
91830
  value: singleValueData2[0]
91735
91831
  }];
91736
- const onChangeFilterValue = (name, value) => setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91737
- ...rls,
91738
- value
91739
- } : rls));
91832
+ const onChangeFilterValue = (name, value, customValue) => {
91833
+ if (customValue) {
91834
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91835
+ ...rls,
91836
+ value,
91837
+ options: rls.options.map((option2) => option2.name === "Custom" ? {
91838
+ ...option2,
91839
+ ...customValue
91840
+ } : option2)
91841
+ } : rls));
91842
+ } else {
91843
+ setRlsConditions((prev) => prev.map((rls) => rls.name === name ? {
91844
+ ...rls,
91845
+ value
91846
+ } : rls));
91847
+ }
91848
+ };
91849
+ const titleStyle = useMemo(() => {
91850
+ var _a3, _b2, _c2;
91851
+ if (!globalTheme)
91852
+ return void 0;
91853
+ const style2 = {};
91854
+ if ((_a3 = globalTheme.cardTitle.fontWeight) == null ? void 0 : _a3.trim())
91855
+ style2.fontWeight = globalTheme.cardTitle.fontWeight.trim() || void 0;
91856
+ if ((_b2 = globalTheme.cardTitle.color) == null ? void 0 : _b2.trim())
91857
+ style2.color = globalTheme.cardTitle.color.trim() || void 0;
91858
+ if ((_c2 = globalTheme.cardTitle.fontSize) == null ? void 0 : _c2.trim())
91859
+ style2.color = globalTheme.cardTitle.fontSize.trim() || void 0;
91860
+ return style2;
91861
+ }, [globalTheme]);
91862
+ const descriptionStyle = useMemo(() => {
91863
+ var _a3, _b2, _c2;
91864
+ if (!globalTheme)
91865
+ return void 0;
91866
+ const style2 = {};
91867
+ if ((_a3 = globalTheme.cardDescription.fontWeight) == null ? void 0 : _a3.trim())
91868
+ style2.fontWeight = globalTheme.cardDescription.fontWeight.trim() || void 0;
91869
+ if ((_b2 = globalTheme.cardDescription.color) == null ? void 0 : _b2.trim())
91870
+ style2.color = globalTheme.cardDescription.color.trim() || void 0;
91871
+ if ((_c2 = globalTheme.cardDescription.fontSize) == null ? void 0 : _c2.trim())
91872
+ style2.color = globalTheme.cardDescription.fontSize.trim() || void 0;
91873
+ return style2;
91874
+ }, [globalTheme]);
91740
91875
  return /* @__PURE__ */ jsx(Fragment, {
91741
91876
  children: /* @__PURE__ */ jsxs("div", {
91742
91877
  className: styles.cardContainer,
@@ -91746,35 +91881,23 @@ const SingleValueCard = ({
91746
91881
  variant: "h3",
91747
91882
  styleClass: "primary",
91748
91883
  className: styles.metricName,
91749
- style: globalTheme ? {
91750
- color: globalTheme.cardTitle.color,
91751
- fontWeight: globalTheme.cardTitle.fontWeight,
91752
- fontSize: globalTheme.cardTitle.fontSize
91753
- } : void 0,
91884
+ style: titleStyle,
91754
91885
  children: [renderHeaderName ? renderHeaderName(metricItem.name) : /* @__PURE__ */ jsx(Button, {
91755
91886
  type: "button",
91756
91887
  variant: "custom",
91757
91888
  isDisabled: !clickBehaviourConfigs.card.isEnable,
91758
91889
  className: "disabled:cursor-text",
91759
91890
  onClick: () => handleCardClick(clickBehaviourConfigs, metricItem.metricId, metricItem.id),
91760
- style: globalTheme ? {
91761
- color: globalTheme.cardTitle.color,
91762
- fontWeight: globalTheme.cardTitle.fontWeight,
91763
- fontSize: globalTheme.cardTitle.fontSize
91764
- } : void 0,
91891
+ style: titleStyle,
91765
91892
  children: metricItem.name
91766
91893
  }), metricItem.description && /* @__PURE__ */ jsx("span", {
91767
91894
  className: styles.metricDescription,
91768
- style: globalTheme ? {
91769
- color: globalTheme.cardDescription.color,
91770
- fontWeight: globalTheme.cardDescription.fontWeight,
91771
- fontSize: globalTheme.cardDescription.fontSize
91772
- } : void 0,
91895
+ style: descriptionStyle,
91773
91896
  children: metricItem.description
91774
91897
  })]
91775
91898
  }), /* @__PURE__ */ jsx("div", {
91776
91899
  className: styles.features,
91777
- children: !!(rlsConditions == null ? void 0 : rlsConditions.length) && /* @__PURE__ */ jsx("div", {
91900
+ children: !!rlsConditions.length && (rlsConditions[0].datatype !== "date" ? /* @__PURE__ */ jsx("div", {
91778
91901
  className: styles.metricFilter,
91779
91902
  children: /* @__PURE__ */ jsx(FloatingDropDown, {
91780
91903
  label: rlsConditions[0].name,
@@ -91788,7 +91911,47 @@ const SingleValueCard = ({
91788
91911
  })),
91789
91912
  onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value)
91790
91913
  })
91791
- })
91914
+ }) : /* @__PURE__ */ jsx("div", {
91915
+ className: styles.metricFilter,
91916
+ children: /* @__PURE__ */ jsx(FloatingDropDown, {
91917
+ label: rlsConditions[0].name,
91918
+ selectedOption: {
91919
+ value: rlsConditions[0].value.name || rlsConditions[0].options[0].name,
91920
+ label: rlsConditions[0].value.name || rlsConditions[0].options[0].name
91921
+ },
91922
+ options: rlsConditions[0].options.map((o2) => ({
91923
+ value: o2.name,
91924
+ label: o2.name
91925
+ })),
91926
+ onChange: (option2) => onChangeFilterValue(rlsConditions[0].name, option2.value),
91927
+ children: rlsConditions[0].value === "Custom" ? /* @__PURE__ */ jsxs("div", {
91928
+ className: "p-1",
91929
+ children: [/* @__PURE__ */ jsx(InputField, {
91930
+ label: "From Date",
91931
+ type: "date",
91932
+ onChange: ({
91933
+ target: {
91934
+ value
91935
+ }
91936
+ }) => {
91937
+ onChangeFilterValue(rlsConditions[0].name, "Custom", {
91938
+ from: new Date(Date.parse(value))
91939
+ });
91940
+ }
91941
+ }), /* @__PURE__ */ jsx(InputField, {
91942
+ label: "To Date",
91943
+ type: "date",
91944
+ onChange: ({
91945
+ target: {
91946
+ value
91947
+ }
91948
+ }) => onChangeFilterValue(rlsConditions[0].name, "Custom", {
91949
+ to: new Date(Date.parse(value))
91950
+ })
91951
+ })]
91952
+ }) : null
91953
+ })
91954
+ }))
91792
91955
  })]
91793
91956
  }), chartType2 && /* @__PURE__ */ jsx("div", {
91794
91957
  className: `${styles.metricData} ${styles.singleValueData}`,
@@ -92030,13 +92193,21 @@ const EmbeddedDashboard = React__default.memo(({
92030
92193
  setGlobalTheme(res.themes[0]);
92031
92194
  }
92032
92195
  });
92196
+ const embedDashboardStyle = useMemo(() => {
92197
+ var _a3, _b3;
92198
+ if (!globalTheme)
92199
+ return void 0;
92200
+ const style2 = {};
92201
+ if ((_a3 = globalTheme.dashboard.backgroundColor) == null ? void 0 : _a3.trim())
92202
+ style2.backgroundColor = globalTheme.dashboard.backgroundColor.trim() || void 0;
92203
+ if ((_b3 = globalTheme.general.fontFamily) == null ? void 0 : _b3.trim())
92204
+ style2.fontFamily = globalTheme.general.fontFamily.trim() || void 0;
92205
+ return style2;
92206
+ }, [globalTheme]);
92033
92207
  return /* @__PURE__ */ jsx(Fragment, {
92034
92208
  children: /* @__PURE__ */ jsxs("div", {
92035
92209
  className: styles$C["embedDashboard-container"],
92036
- style: globalTheme ? {
92037
- backgroundColor: `${globalTheme.dashboard.backgroundColor} !important`,
92038
- fontFamily: `${globalTheme.general.fontFamily} !important`
92039
- } : void 0,
92210
+ style: embedDashboardStyle,
92040
92211
  children: [((_a2 = data2.externalDashboard) == null ? void 0 : _a2.id) && !isLoading && /* @__PURE__ */ jsxs(Fragment, {
92041
92212
  children: [!(options2 == null ? void 0 : options2.disableMetricCreation) && !data2.externalDashboard.filters.length && !data2.isAllowedToCreateMetrics ? null : /* @__PURE__ */ jsxs("div", {
92042
92213
  className: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? styles$C["embedDashboard-header-floating"] : styles$C["embedDashboard-header-static"],