@databrainhq/plugin 0.8.1 → 0.8.2

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
@@ -2641,17 +2641,17 @@ var classnames$1 = { exports: {} };
2641
2641
  })(classnames$1);
2642
2642
  var classnames = classnames$1.exports;
2643
2643
  var styles$E = {
2644
- "btn-primary": "_btn-primary_1gon7_1",
2645
- "btn-secondary": "_btn-secondary_1gon7_5",
2646
- "btn-reject": "_btn-reject_1gon7_9",
2647
- "btn-outlined": "_btn-outlined_1gon7_14",
2648
- "btn-tertiary": "_btn-tertiary_1gon7_18",
2649
- "btn-default": "_btn-default_1gon7_22",
2650
- "btn-large": "_btn-large_1gon7_25",
2651
- "btn-small": "_btn-small_1gon7_28",
2652
- "btn-xs": "_btn-xs_1gon7_31",
2653
- "btn-medium": "_btn-medium_1gon7_34",
2654
- "btn-11rem": "_btn-11rem_1gon7_38"
2644
+ "btn-primary": "_btn-primary_17kvk_1",
2645
+ "btn-secondary": "_btn-secondary_17kvk_5",
2646
+ "btn-reject": "_btn-reject_17kvk_9",
2647
+ "btn-outlined": "_btn-outlined_17kvk_14",
2648
+ "btn-tertiary": "_btn-tertiary_17kvk_18",
2649
+ "btn-default": "_btn-default_17kvk_22",
2650
+ "btn-large": "_btn-large_17kvk_25",
2651
+ "btn-small": "_btn-small_17kvk_28",
2652
+ "btn-xs": "_btn-xs_17kvk_31",
2653
+ "btn-medium": "_btn-medium_17kvk_34",
2654
+ "btn-11rem": "_btn-11rem_17kvk_38"
2655
2655
  };
2656
2656
  var jsxRuntime = { exports: {} };
2657
2657
  var reactJsxRuntime_production_min = {};
@@ -6687,8 +6687,10 @@ const useCompanySubsetTableDataMutation = (options2) => useMutation(
6687
6687
  options2
6688
6688
  );
6689
6689
  const EmbeddedDashboardMetricsDocument = `
6690
- query EmbeddedDashboardMetrics($where: externalDashboardMetrics_bool_exp) {
6691
- externalDashboardMetrics(where: $where) {
6690
+ query EmbeddedDashboardMetrics($externalDashboardId: String! = "") {
6691
+ externalDashboardMetrics(
6692
+ where: {externalDashboard: {externalDashboardId: {_eq: $externalDashboardId}}, externalMetric: {isMarkedDeleted: {_eq: false}}}
6693
+ ) {
6692
6694
  externalMetricId
6693
6695
  externalDashboardId
6694
6696
  externalMetric {
@@ -7028,20 +7030,16 @@ const useEmbeddedDashboard = (token) => {
7028
7030
  isLoading: isExternalDashboardMetricsDataLoading
7029
7031
  } = useEmbeddedDashboardMetricsQuery(
7030
7032
  {
7031
- where: {
7032
- externalDashboard: {
7033
- externalDashboardId: { _eq: externalDashboardId },
7034
- externalDashboardMetrics: {
7035
- externalMetric: { isMarkedDeleted: { _eq: false } }
7036
- }
7037
- }
7038
- }
7033
+ externalDashboardId
7039
7034
  },
7040
7035
  { enabled: !!externalDashboardId }
7041
7036
  );
7042
- const { data: idData, isLoading: isLoadingId } = useGetExternalDashboardIdQuery({ externalDashboardId });
7037
+ const { data: idData, isLoading: isLoadingId } = useGetExternalDashboardIdQuery(
7038
+ { externalDashboardId },
7039
+ { enabled: !!externalDashboardId }
7040
+ );
7043
7041
  const externalDashboardMetrics = externalDashboardMetricsData == null ? void 0 : externalDashboardMetricsData.externalDashboardMetrics;
7044
- const { data: accessData, isLoading: isLoadingAccessData } = useMetricAccessQuery({ companyId });
7042
+ const { data: accessData, isLoading: isLoadingAccessData } = useMetricAccessQuery({ companyId }, { enabled: !!companyId });
7045
7043
  const isAllowedToCreateMetrics = (accessData == null ? void 0 : accessData.companySubsetTables.length) ? accessData.companySubsetTables[0].isAllowMetricCreation && !isTestKey : false;
7046
7044
  const isAllowedToDeleteMetrics = (accessData == null ? void 0 : accessData.companySubsetTables.length) ? accessData.companySubsetTables[0].isAllowMetricDeletion && !isTestKey : false;
7047
7045
  return {
@@ -7052,6 +7050,7 @@ const useEmbeddedDashboard = (token) => {
7052
7050
  mode,
7053
7051
  externalDashboardMetrics,
7054
7052
  externalDashboard: idData == null ? void 0 : idData.externalDashboards[0],
7053
+ externalDashboardId,
7055
7054
  rlsSettings,
7056
7055
  companyTenancyType: companyTenancyType || "TABLE",
7057
7056
  isAllowedToCreateMetrics,
@@ -7323,13 +7322,92 @@ const useOutsideAlerter = ({
7323
7322
  };
7324
7323
  }, [wrapRef, onOutsideClick]);
7325
7324
  };
7325
+ const useApplyAdminTheme = (adminTheme) => {
7326
+ useEffect(() => {
7327
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j;
7328
+ if (!adminTheme) {
7329
+ const adminStyles2 = document.querySelector("#dbn-admin-styles");
7330
+ if (adminStyles2)
7331
+ document.head.removeChild(adminStyles2);
7332
+ return;
7333
+ }
7334
+ const adminStyles = document.getElementById("dbn-admin-styles") || document.createElement("style");
7335
+ adminStyles.setAttribute("type", "text/css");
7336
+ adminStyles.setAttribute("id", "dbn-admin-styles");
7337
+ let style2 = "";
7338
+ if ((_a2 = adminTheme.general.fontFamily) == null ? void 0 : _a2.trim()) {
7339
+ style2 = `
7340
+ #dbn-dashboard {
7341
+ font-family: ${adminTheme.general.fontFamily} !important;
7342
+ }`;
7343
+ }
7344
+ if ((_b2 = adminTheme.dashboard.backgroundColor) == null ? void 0 : _b2.trim()) {
7345
+ style2 = `${style2}
7346
+ #dbn-dashboard {
7347
+ background-color: ${adminTheme.dashboard.backgroundColor} !important;
7348
+ }`;
7349
+ }
7350
+ if ((_c2 = adminTheme.dashboard.ctaColor) == null ? void 0 : _c2.trim()) {
7351
+ style2 = `${style2}
7352
+ .dbn-btn-primary {
7353
+ background-color: ${adminTheme.dashboard.ctaColor} !important;
7354
+ }`;
7355
+ }
7356
+ if ((_d = adminTheme.dashboard.ctaTextColor) == null ? void 0 : _d.trim()) {
7357
+ style2 = `${style2}
7358
+ .dbn-btn-primary {
7359
+ color: ${adminTheme.dashboard.ctaTextColor} !important;
7360
+ }`;
7361
+ }
7362
+ if ((_e = adminTheme.cardTitle.fontWeight) == null ? void 0 : _e.trim()) {
7363
+ style2 = `${style2}
7364
+ .dbn-metric-card-title {
7365
+ font-weight: ${adminTheme.cardTitle.fontWeight} !important;
7366
+ }`;
7367
+ }
7368
+ if ((_f = adminTheme.cardTitle.fontSize) == null ? void 0 : _f.trim()) {
7369
+ style2 = `${style2}
7370
+ .dbn-metric-card-title {
7371
+ font-size: ${adminTheme.cardTitle.fontSize} !important;
7372
+ }`;
7373
+ }
7374
+ if ((_g = adminTheme.cardTitle.color) == null ? void 0 : _g.trim()) {
7375
+ style2 = `${style2}
7376
+ .dbn-metric-card-title {
7377
+ color: ${adminTheme.cardTitle.color} !important;
7378
+ }`;
7379
+ }
7380
+ if ((_h = adminTheme.cardDescription.fontWeight) == null ? void 0 : _h.trim()) {
7381
+ style2 = `${style2}
7382
+ .dbn-metric-card-description {
7383
+ font-weight: ${adminTheme.cardDescription.fontWeight} !important;
7384
+ }`;
7385
+ }
7386
+ if ((_i = adminTheme.cardDescription.fontSize) == null ? void 0 : _i.trim()) {
7387
+ style2 = `${style2}
7388
+ .dbn-metric-card-description {
7389
+ font-size: ${adminTheme.cardDescription.fontSize} !important;
7390
+ }`;
7391
+ }
7392
+ if ((_j = adminTheme.cardDescription.color) == null ? void 0 : _j.trim()) {
7393
+ style2 = `${style2}
7394
+ .dbn-metric-card-description {
7395
+ color: ${adminTheme.cardDescription.color} !important;
7396
+ }`;
7397
+ }
7398
+ adminStyles.innerHTML = "";
7399
+ adminStyles.innerHTML = style2;
7400
+ document.head.appendChild(adminStyles);
7401
+ }, [adminTheme]);
7402
+ };
7326
7403
  var index$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7327
7404
  __proto__: null,
7328
7405
  useEmbeddedDashboard,
7329
7406
  useExternalMetric,
7330
7407
  useGenerateDatasetMetrics,
7331
7408
  useGenerateEmbeddedMetric,
7332
- useOutsideAlerter
7409
+ useOutsideAlerter,
7410
+ useApplyAdminTheme
7333
7411
  }, Symbol.toStringTag, { value: "Module" }));
7334
7412
  const materialSymbolsKeyboardArrowDown = (props) => /* @__PURE__ */ jsx("svg", {
7335
7413
  viewBox: "0 0 24 24",
@@ -82531,22 +82609,6 @@ var styles$k = {
82531
82609
  "save-btn": "_save-btn_t2r6v_17",
82532
82610
  "save-btn-icon": "_save-btn-icon_t2r6v_21"
82533
82611
  };
82534
- const ThemeContext = createContext(null);
82535
- const useGlobalTheme = () => {
82536
- return useContext(ThemeContext);
82537
- };
82538
- const GlobalThemeProvider = ({
82539
- children: children2
82540
- }) => {
82541
- const [globalTheme, setGlobalTheme] = useState();
82542
- return /* @__PURE__ */ jsx(ThemeContext.Provider, {
82543
- value: {
82544
- globalTheme,
82545
- setGlobalTheme
82546
- },
82547
- children: children2
82548
- });
82549
- };
82550
82612
  const Header = ({
82551
82613
  setShowMetricCreateModal,
82552
82614
  isDisableSaveBtn,
@@ -82555,20 +82617,6 @@ const Header = ({
82555
82617
  setShowSaveMetricModal,
82556
82618
  setShowSqlModal
82557
82619
  }) => {
82558
- const {
82559
- globalTheme
82560
- } = useGlobalTheme();
82561
- const saveDashboardStyle = useMemo(() => {
82562
- var _a2, _b2;
82563
- if (!globalTheme)
82564
- return void 0;
82565
- const style2 = {};
82566
- if ((_a2 = globalTheme.dashboard.ctaColor) == null ? void 0 : _a2.trim())
82567
- style2.backgroundColor = globalTheme.dashboard.ctaColor.trim() || void 0;
82568
- if ((_b2 = globalTheme.dashboard.ctaTextColor) == null ? void 0 : _b2.trim())
82569
- style2.color = globalTheme.dashboard.ctaTextColor.trim() || void 0;
82570
- return style2;
82571
- }, [globalTheme]);
82572
82620
  return /* @__PURE__ */ jsxs("div", {
82573
82621
  className: styles$k["header-container"],
82574
82622
  children: [/* @__PURE__ */ jsxs("div", {
@@ -82604,10 +82652,8 @@ const Header = ({
82604
82652
  className: styles$k["save-btn"],
82605
82653
  isDisabled: isDisableSaveBtn,
82606
82654
  onClick: () => setShowSaveMetricModal(true),
82607
- style: saveDashboardStyle,
82608
82655
  children: [/* @__PURE__ */ jsx(Icons, {
82609
- name: "save-icon",
82610
- className: styles$k["save-btn-icon"]
82656
+ name: "save-icon"
82611
82657
  }), "Save to Dashboard"]
82612
82658
  })]
82613
82659
  })]
@@ -83810,13 +83856,10 @@ const ChartTab = ({
83810
83856
  setBackGroundColor,
83811
83857
  headerChild,
83812
83858
  tableSettings,
83813
- setTableSettings
83859
+ setTableSettings,
83860
+ chartColors
83814
83861
  }) => {
83815
- var _a2, _b2, _c2, _d;
83816
83862
  const chartRef = useRef(null);
83817
- const {
83818
- globalTheme
83819
- } = useGlobalTheme();
83820
83863
  const [isSettingsShow, setSettingsShow] = useState(false);
83821
83864
  const [isShowFullScreen, setShowFullScreen] = useState(false);
83822
83865
  const handleChartRightClick = (params) => {
@@ -83941,7 +83984,7 @@ const ChartTab = ({
83941
83984
  sankeyData,
83942
83985
  singleValueData: singleValueData2,
83943
83986
  margins,
83944
- colors: globalTheme ? (_b2 = (_a2 = globalTheme.chart.palettes) == null ? void 0 : _a2.find((palette) => palette.name === globalTheme.chart.selected)) == null ? void 0 : _b2.colors : void 0,
83987
+ colors: chartColors,
83945
83988
  legendSettings,
83946
83989
  labelSettings,
83947
83990
  axisSettings,
@@ -83999,7 +84042,7 @@ const ChartTab = ({
83999
84042
  sankeyData,
84000
84043
  singleValueData: singleValueData2,
84001
84044
  margins,
84002
- colors: globalTheme ? (_d = (_c2 = globalTheme.chart.palettes) == null ? void 0 : _c2.find((palette) => palette === globalTheme.chart.selected)) == null ? void 0 : _d.colors : void 0,
84045
+ colors: chartColors,
84003
84046
  legendSettings,
84004
84047
  labelSettings,
84005
84048
  axisSettings,
@@ -84383,7 +84426,8 @@ const MetricOutput = ({
84383
84426
  isEnableGroupBy,
84384
84427
  backGroundColor,
84385
84428
  setBackGroundColor,
84386
- moreTabs
84429
+ moreTabs,
84430
+ chartColors
84387
84431
  }) => {
84388
84432
  var _a2;
84389
84433
  const [selectedTab2, setSelectedTab] = useState(TABLE_TAB);
@@ -84457,7 +84501,8 @@ const MetricOutput = ({
84457
84501
  backGroundColor,
84458
84502
  setBackGroundColor,
84459
84503
  tableSettings,
84460
- setTableSettings
84504
+ setTableSettings,
84505
+ chartColors
84461
84506
  }), (_a2 = moreTabs == null ? void 0 : moreTabs.find((tabObj) => tabObj.name === selectedTab2)) == null ? void 0 : _a2.tabContent]
84462
84507
  })]
84463
84508
  });
@@ -84980,9 +85025,6 @@ const MetricForm = ({
84980
85025
  clientId,
84981
85026
  clientColumn
84982
85027
  }) => {
84983
- const {
84984
- globalTheme
84985
- } = useGlobalTheme();
84986
85028
  const [metrics, setMetrics] = useState([]);
84987
85029
  const [timeGrainValue, setTimeGrainValue] = useState("");
84988
85030
  const [timeColumn, setTimeColumn] = useState({
@@ -85148,17 +85190,6 @@ const MetricForm = ({
85148
85190
  if (isEnableGroupBy)
85149
85191
  setSelectedGroupBy(selectedDimensions);
85150
85192
  }, [selectedDimensions, isEnableGroupBy]);
85151
- const primaryButtonStyle = useMemo(() => {
85152
- var _a2, _b2;
85153
- if (!globalTheme)
85154
- return void 0;
85155
- const style2 = {};
85156
- if ((_a2 = globalTheme.dashboard.ctaColor) == null ? void 0 : _a2.trim())
85157
- style2.backgroundColor = globalTheme.dashboard.ctaColor.trim() || void 0;
85158
- if ((_b2 = globalTheme.dashboard.ctaTextColor) == null ? void 0 : _b2.trim())
85159
- style2.color = globalTheme.dashboard.ctaTextColor.trim() || void 0;
85160
- return style2;
85161
- }, [globalTheme]);
85162
85193
  return /* @__PURE__ */ jsxs("div", {
85163
85194
  className: styles$8["form-container"],
85164
85195
  children: [!isDisableTimeColumn && /* @__PURE__ */ jsxs("div", {
@@ -85274,7 +85305,6 @@ const MetricForm = ({
85274
85305
  type: "button",
85275
85306
  variant: "primary",
85276
85307
  size: "small",
85277
- style: primaryButtonStyle,
85278
85308
  className: styles$8.disabled,
85279
85309
  isDisabled: !metricAggregate.value || !metricColumn.value,
85280
85310
  onClick: () => {
@@ -85366,7 +85396,6 @@ const MetricForm = ({
85366
85396
  type: "button",
85367
85397
  variant: "primary",
85368
85398
  size: "small",
85369
- style: primaryButtonStyle,
85370
85399
  className: styles$8.disabled,
85371
85400
  isDisabled: !column2.value,
85372
85401
  onClick: () => {
@@ -85464,7 +85493,6 @@ const MetricForm = ({
85464
85493
  variant: "primary",
85465
85494
  size: "small",
85466
85495
  isDisabled: !filterColumn.value || !operator.value || !isFilterValue,
85467
- style: primaryButtonStyle,
85468
85496
  className: styles$8.disabled,
85469
85497
  onClick: () => {
85470
85498
  setFilters((prev) => [...prev, `${isBigQuery || isMySql ? `${filterColumn.value}` : isMongoDb ? `\`${filterColumn.value}\`` : `"${filterColumn.value}"`} ${operator.value} ${isInFilter ? `(${selectedFilterValues.map((f2) => `'${f2}'`).join(", ")})` : `${filterValue.value ? `'${filterValue.value}'` : ""}`}`]);
@@ -85521,7 +85549,6 @@ const MetricForm = ({
85521
85549
  size: "small",
85522
85550
  isDisabled: !sortColumn.value || isDisableSorting,
85523
85551
  className: styles$8.disabled,
85524
- style: primaryButtonStyle,
85525
85552
  onClick: () => {
85526
85553
  if (!columns.length) {
85527
85554
  setSort(`${sortAggregate.value}(${isBigQuery || isMySql ? `${sortColumn.value}` : isMongoDb ? `\`${sortColumn.value}\`` : `"${sortColumn.value}"`})`);
@@ -85572,7 +85599,6 @@ const MetricForm = ({
85572
85599
  variant: "primary",
85573
85600
  className: styles$8.generateButton,
85574
85601
  isDisabled: isGeneratingDataset || isDisableGenerate,
85575
- style: primaryButtonStyle,
85576
85602
  onClick: () => {
85577
85603
  var _a2, _b2, _c2;
85578
85604
  setError("");
@@ -85722,12 +85748,10 @@ const EmbeddedMetricCreation = ({
85722
85748
  companyId,
85723
85749
  mode,
85724
85750
  externalDashboardId,
85725
- variant = "static"
85751
+ variant = "static",
85752
+ chartColors
85726
85753
  }) => {
85727
85754
  var _a2;
85728
- const {
85729
- globalTheme
85730
- } = useGlobalTheme();
85731
85755
  const [isLoading, setLoading] = useState(false);
85732
85756
  const [error2, setError] = useState("");
85733
85757
  const [data2, setData] = useState();
@@ -85985,17 +86009,6 @@ const EmbeddedMetricCreation = ({
85985
86009
  updateGroupData(data2, [selectedGroupBy[0]], selectedGroupBy, setGroupedData);
85986
86010
  }
85987
86011
  }, [groupedData, isEnableGroupBy, selectedGroupBy]);
85988
- const createMetricStyle = useMemo(() => {
85989
- var _a3, _b2;
85990
- if (!globalTheme)
85991
- return void 0;
85992
- const style2 = {};
85993
- if ((_a3 = globalTheme.dashboard.ctaColor) == null ? void 0 : _a3.trim())
85994
- style2.backgroundColor = globalTheme.dashboard.ctaColor.trim() || void 0;
85995
- if ((_b2 = globalTheme.dashboard.ctaTextColor) == null ? void 0 : _b2.trim())
85996
- style2.color = globalTheme.dashboard.ctaTextColor.trim() || void 0;
85997
- return style2;
85998
- }, [globalTheme]);
85999
86012
  return /* @__PURE__ */ jsxs(Fragment, {
86000
86013
  children: [/* @__PURE__ */ jsx(Button, {
86001
86014
  type: "button",
@@ -86003,7 +86016,6 @@ const EmbeddedMetricCreation = ({
86003
86016
  size: "large",
86004
86017
  className: variant === "floating" ? styles$j.floatingCreateButton : "",
86005
86018
  onClick: () => setShowMetricCreateModal(true),
86006
- style: createMetricStyle,
86007
86019
  children: variant === "floating" ? /* @__PURE__ */ jsx(mdiPlus, {
86008
86020
  className: styles$j.floatingCreateButtonIcon
86009
86021
  }) : "Create Metric"
@@ -86079,7 +86091,8 @@ const EmbeddedMetricCreation = ({
86079
86091
  customSettings,
86080
86092
  setCustomSettings,
86081
86093
  tableSettings,
86082
- setTableSettings
86094
+ setTableSettings,
86095
+ chartColors
86083
86096
  })]
86084
86097
  })
86085
86098
  }), /* @__PURE__ */ jsx(Modal, {
@@ -91360,34 +91373,36 @@ var styles$4 = {
91360
91373
  "noMetric-wrapper": "_noMetric-wrapper_1b506_25",
91361
91374
  "alt-container": "_alt-container_1b506_33"
91362
91375
  };
91363
- const cardContainer = "_cardContainer_btizd_1";
91364
- const listHeader = "_listHeader_btizd_9";
91365
- const metricName = "_metricName_btizd_17";
91366
- const metricDescription = "_metricDescription_btizd_25";
91367
- const popup = "_popup_btizd_33";
91368
- const metricFilter$1 = "_metricFilter_btizd_41";
91369
- const popupIcon = "_popupIcon_btizd_49";
91370
- const popupMenu = "_popupMenu_btizd_57";
91371
- const popupItem = "_popupItem_btizd_65";
91372
- const popupItemIcon = "_popupItemIcon_btizd_73";
91373
- const csvBtn = "_csvBtn_btizd_81";
91374
- const deleteBtn = "_deleteBtn_btizd_89";
91375
- const metricData = "_metricData_btizd_97";
91376
- const singleValueData = "_singleValueData_btizd_105";
91377
- const singleValue = "_singleValue_btizd_105";
91378
- const noData = "_noData_btizd_121";
91379
- const noDataContent = "_noDataContent_btizd_129";
91380
- const noDataText = "_noDataText_btizd_137";
91381
- const loading$1 = "_loading_btizd_145";
91382
- const features = "_features_btizd_153";
91383
- const fullscreen$1 = "_fullscreen_btizd_161";
91384
- const deleteModal = "_deleteModal_btizd_169";
91385
- const cancelBtn = "_cancelBtn_btizd_177";
91386
- const warningIcon = "_warningIcon_btizd_185";
91376
+ const cardContainer = "_cardContainer_1ax68_1";
91377
+ const listHeader = "_listHeader_1ax68_9";
91378
+ const metricName = "_metricName_1ax68_17";
91379
+ const metricTitle = "_metricTitle_1ax68_25";
91380
+ const metricDescription = "_metricDescription_1ax68_33";
91381
+ const popup = "_popup_1ax68_41";
91382
+ const metricFilter$1 = "_metricFilter_1ax68_49";
91383
+ const popupIcon = "_popupIcon_1ax68_57";
91384
+ const popupMenu = "_popupMenu_1ax68_65";
91385
+ const popupItem = "_popupItem_1ax68_73";
91386
+ const popupItemIcon = "_popupItemIcon_1ax68_81";
91387
+ const csvBtn = "_csvBtn_1ax68_89";
91388
+ const deleteBtn = "_deleteBtn_1ax68_97";
91389
+ const metricData = "_metricData_1ax68_105";
91390
+ const singleValueData = "_singleValueData_1ax68_113";
91391
+ const singleValue = "_singleValue_1ax68_113";
91392
+ const noData = "_noData_1ax68_129";
91393
+ const noDataContent = "_noDataContent_1ax68_137";
91394
+ const noDataText = "_noDataText_1ax68_145";
91395
+ const loading$1 = "_loading_1ax68_153";
91396
+ const features = "_features_1ax68_161";
91397
+ const fullscreen$1 = "_fullscreen_1ax68_169";
91398
+ const deleteModal = "_deleteModal_1ax68_177";
91399
+ const cancelBtn = "_cancelBtn_1ax68_185";
91400
+ const warningIcon = "_warningIcon_1ax68_193";
91387
91401
  var styles$3 = {
91388
91402
  cardContainer,
91389
91403
  listHeader,
91390
91404
  metricName,
91405
+ metricTitle,
91391
91406
  metricDescription,
91392
91407
  popup,
91393
91408
  metricFilter: metricFilter$1,
@@ -91809,7 +91824,7 @@ const useUnderlyingData = ({
91809
91824
  }) => {
91810
91825
  const sqlQuery = getSqlStatement({
91811
91826
  query,
91812
- limit: "100",
91827
+ limit: "5000",
91813
91828
  clientName,
91814
91829
  tenancyType,
91815
91830
  values
@@ -91853,11 +91868,8 @@ const MetricCard = ({
91853
91868
  renderHeaderName,
91854
91869
  onDelete
91855
91870
  }) => {
91856
- var _a2, _b2, _c2;
91871
+ var _a2;
91857
91872
  const chartRef = useRef(null);
91858
- const {
91859
- globalTheme
91860
- } = useGlobalTheme();
91861
91873
  const filterValues2 = {};
91862
91874
  if (param == null ? void 0 : param.values) {
91863
91875
  for (const key in param.values) {
@@ -92112,32 +92124,6 @@ const MetricCard = ({
92112
92124
  } : rls));
92113
92125
  }
92114
92126
  };
92115
- const titleStyle = useMemo(() => {
92116
- var _a3, _b3, _c3;
92117
- if (!globalTheme)
92118
- return void 0;
92119
- const style2 = {};
92120
- if ((_a3 = globalTheme.cardTitle.fontWeight) == null ? void 0 : _a3.trim())
92121
- style2.fontWeight = globalTheme.cardTitle.fontWeight.trim() || void 0;
92122
- if ((_b3 = globalTheme.cardTitle.color) == null ? void 0 : _b3.trim())
92123
- style2.color = globalTheme.cardTitle.color.trim() || void 0;
92124
- if ((_c3 = globalTheme.cardTitle.fontSize) == null ? void 0 : _c3.trim())
92125
- style2.color = globalTheme.cardTitle.fontSize.trim() || void 0;
92126
- return style2;
92127
- }, [globalTheme]);
92128
- const descriptionStyle = useMemo(() => {
92129
- var _a3, _b3, _c3;
92130
- if (!globalTheme)
92131
- return void 0;
92132
- const style2 = {};
92133
- if ((_a3 = globalTheme.cardDescription.fontWeight) == null ? void 0 : _a3.trim())
92134
- style2.fontWeight = globalTheme.cardDescription.fontWeight.trim() || void 0;
92135
- if ((_b3 = globalTheme.cardDescription.color) == null ? void 0 : _b3.trim())
92136
- style2.color = globalTheme.cardDescription.color.trim() || void 0;
92137
- if ((_c3 = globalTheme.cardDescription.fontSize) == null ? void 0 : _c3.trim())
92138
- style2.color = globalTheme.cardDescription.fontSize.trim() || void 0;
92139
- return style2;
92140
- }, [globalTheme]);
92141
92127
  const [isShowChartPopup, setShowChartPopup] = useState(false);
92142
92128
  const [chartParams, setChartParams] = useState();
92143
92129
  const handleChartRightClick = (params) => {
@@ -92171,22 +92157,22 @@ const MetricCard = ({
92171
92157
  },
92172
92158
  children: [/* @__PURE__ */ jsxs("div", {
92173
92159
  className: styles$3.listHeader,
92174
- children: [/* @__PURE__ */ jsxs(Text, {
92175
- variant: "h3",
92176
- styleClass: "primary",
92160
+ children: [/* @__PURE__ */ jsxs("div", {
92177
92161
  className: styles$3.metricName,
92178
- style: titleStyle,
92179
- children: [renderHeaderName ? renderHeaderName(metricItem.name) : /* @__PURE__ */ jsx(Button, {
92162
+ children: [/* @__PURE__ */ jsx(Button, {
92180
92163
  type: "button",
92181
92164
  variant: "custom",
92182
92165
  isDisabled: !clickBehaviourConfigs.card.isEnable,
92183
92166
  className: "disabled:cursor-text",
92184
92167
  onClick: () => handleCardClick(clickBehaviourConfigs, metricItem.metricId, metricItem.id),
92185
- style: titleStyle,
92186
- children: metricItem.name
92168
+ children: /* @__PURE__ */ jsx(Text, {
92169
+ variant: "h3",
92170
+ styleClass: "primary",
92171
+ className: `${styles$3.metricTitle} dbn-metric-card-title`,
92172
+ children: renderHeaderName ? renderHeaderName(metricItem.name) : metricItem.name
92173
+ })
92187
92174
  }), metricItem.description && /* @__PURE__ */ jsx("span", {
92188
- className: styles$3.metricDescription,
92189
- style: descriptionStyle,
92175
+ className: `${styles$3.metricDescription} dbn-metric-card-description`,
92190
92176
  children: metricItem.description
92191
92177
  })]
92192
92178
  }), /* @__PURE__ */ jsxs("div", {
@@ -92206,32 +92192,29 @@ const MetricCard = ({
92206
92192
  type: "button",
92207
92193
  variant: "custom",
92208
92194
  className: styles$3.popupItem,
92209
- onClick: () => {
92210
- var _a3, _b3;
92211
- return onMaximize({
92195
+ onClick: () => onMaximize({
92196
+ labels: labels2,
92197
+ data: {
92212
92198
  labels: labels2,
92213
- data: {
92214
- labels: labels2,
92215
- datasets
92216
- },
92217
- chartType: chartType2,
92218
- funnelData,
92219
- sankeyData,
92220
- singleValueData: singleValueData2,
92221
- margins,
92222
- colors: globalTheme ? (_b3 = (_a3 = globalTheme.chart.palettes) == null ? void 0 : _a3.find((palette) => palette.name === globalTheme.chart.selected)) == null ? void 0 : _b3.colors : colors2,
92223
- legendSettings,
92224
- labelSettings,
92225
- axisSettings,
92226
- customSettings,
92227
- backGroundColor,
92228
- tableSettings,
92229
- enableSaveAs: true,
92230
- chartClickConfig: clickBehaviourConfigs.chart,
92231
- chartRef,
92232
- handleChartRightClick
92233
- });
92234
- },
92199
+ datasets
92200
+ },
92201
+ chartType: chartType2,
92202
+ funnelData,
92203
+ sankeyData,
92204
+ singleValueData: singleValueData2,
92205
+ margins,
92206
+ colors: colors2,
92207
+ legendSettings,
92208
+ labelSettings,
92209
+ axisSettings,
92210
+ customSettings,
92211
+ backGroundColor,
92212
+ tableSettings,
92213
+ enableSaveAs: true,
92214
+ chartClickConfig: clickBehaviourConfigs.chart,
92215
+ chartRef,
92216
+ handleChartRightClick
92217
+ }),
92235
92218
  children: [/* @__PURE__ */ jsx(Icons, {
92236
92219
  name: "fullscreen-icon",
92237
92220
  className: styles$3.popupItemIcon
@@ -92314,7 +92297,7 @@ const MetricCard = ({
92314
92297
  axisSettings,
92315
92298
  tableSettings,
92316
92299
  enableSaveAs: true,
92317
- colors: globalTheme ? (_c2 = (_b2 = globalTheme.chart.palettes) == null ? void 0 : _b2.find((palette) => palette.name === globalTheme.chart.selected)) == null ? void 0 : _c2.colors : colors2,
92300
+ colors: colors2,
92318
92301
  updateGroup,
92319
92302
  isEnableGroupBy,
92320
92303
  customSettings,
@@ -92352,9 +92335,6 @@ const SingleValueCard = ({
92352
92335
  onDelete
92353
92336
  }) => {
92354
92337
  var _a2;
92355
- const {
92356
- globalTheme
92357
- } = useGlobalTheme();
92358
92338
  const filterValues2 = {};
92359
92339
  if (param == null ? void 0 : param.values) {
92360
92340
  for (const key in param.values) {
@@ -92472,53 +92452,27 @@ const SingleValueCard = ({
92472
92452
  } : rls));
92473
92453
  }
92474
92454
  };
92475
- const titleStyle = useMemo(() => {
92476
- var _a3, _b2, _c2;
92477
- if (!globalTheme)
92478
- return void 0;
92479
- const style2 = {};
92480
- if ((_a3 = globalTheme.cardTitle.fontWeight) == null ? void 0 : _a3.trim())
92481
- style2.fontWeight = globalTheme.cardTitle.fontWeight.trim() || void 0;
92482
- if ((_b2 = globalTheme.cardTitle.color) == null ? void 0 : _b2.trim())
92483
- style2.color = globalTheme.cardTitle.color.trim() || void 0;
92484
- if ((_c2 = globalTheme.cardTitle.fontSize) == null ? void 0 : _c2.trim())
92485
- style2.color = globalTheme.cardTitle.fontSize.trim() || void 0;
92486
- return style2;
92487
- }, [globalTheme]);
92488
- const descriptionStyle = useMemo(() => {
92489
- var _a3, _b2, _c2;
92490
- if (!globalTheme)
92491
- return void 0;
92492
- const style2 = {};
92493
- if ((_a3 = globalTheme.cardDescription.fontWeight) == null ? void 0 : _a3.trim())
92494
- style2.fontWeight = globalTheme.cardDescription.fontWeight.trim() || void 0;
92495
- if ((_b2 = globalTheme.cardDescription.color) == null ? void 0 : _b2.trim())
92496
- style2.color = globalTheme.cardDescription.color.trim() || void 0;
92497
- if ((_c2 = globalTheme.cardDescription.fontSize) == null ? void 0 : _c2.trim())
92498
- style2.color = globalTheme.cardDescription.fontSize.trim() || void 0;
92499
- return style2;
92500
- }, [globalTheme]);
92501
92455
  return /* @__PURE__ */ jsx(Fragment, {
92502
92456
  children: /* @__PURE__ */ jsxs("div", {
92503
92457
  className: styles$3.cardContainer,
92504
92458
  children: [/* @__PURE__ */ jsxs("div", {
92505
92459
  className: styles$3.listHeader,
92506
- children: [/* @__PURE__ */ jsxs(Text, {
92507
- variant: "h3",
92508
- styleClass: "primary",
92460
+ children: [/* @__PURE__ */ jsxs("div", {
92509
92461
  className: styles$3.metricName,
92510
- style: titleStyle,
92511
- children: [renderHeaderName ? renderHeaderName(metricItem.name) : /* @__PURE__ */ jsx(Button, {
92462
+ children: [/* @__PURE__ */ jsx(Button, {
92512
92463
  type: "button",
92513
92464
  variant: "custom",
92514
92465
  isDisabled: !clickBehaviourConfigs.card.isEnable,
92515
92466
  className: "disabled:cursor-text",
92516
92467
  onClick: () => handleCardClick(clickBehaviourConfigs, metricItem.metricId, metricItem.id),
92517
- style: titleStyle,
92518
- children: metricItem.name
92468
+ children: /* @__PURE__ */ jsx(Text, {
92469
+ variant: "h3",
92470
+ styleClass: "primary",
92471
+ className: `${styles$3.metricTitle} dbn-metric-card-title`,
92472
+ children: renderHeaderName ? renderHeaderName(metricItem.name) : metricItem.name
92473
+ })
92519
92474
  }), metricItem.description && /* @__PURE__ */ jsx("span", {
92520
- className: styles$3.metricDescription,
92521
- style: descriptionStyle,
92475
+ className: `${styles$3.metricDescription} dbn-metric-card-description`,
92522
92476
  children: metricItem.description
92523
92477
  })]
92524
92478
  }), /* @__PURE__ */ jsxs("div", {
@@ -92658,17 +92612,31 @@ const DeleteMetricModal = ({
92658
92612
  isOpen,
92659
92613
  onClose,
92660
92614
  onSuccess,
92661
- metricId
92615
+ metricId,
92616
+ dashboardId
92662
92617
  }) => {
92618
+ const queryClient2 = useQueryClient();
92663
92619
  const {
92664
92620
  mutateAsync: deleteMetric,
92665
92621
  isLoading
92666
92622
  } = useMarkDeleteMetricMutation();
92667
92623
  const handleDeleteMetric = async () => {
92624
+ if (!metricId || !dashboardId)
92625
+ return;
92668
92626
  await deleteMetric({
92669
92627
  id: metricId
92670
92628
  }, {
92671
92629
  onSuccess: () => {
92630
+ queryClient2.setQueryData(["EmbeddedDashboardMetrics", {
92631
+ dashboardId
92632
+ }], (prev) => {
92633
+ var _a2;
92634
+ const externalDashboardMetrics = (_a2 = prev == null ? void 0 : prev.externalDashboardMetrics) == null ? void 0 : _a2.filter((exDm) => exDm.externalMetricId !== metricId);
92635
+ return {
92636
+ ...prev,
92637
+ externalDashboardMetrics
92638
+ };
92639
+ });
92672
92640
  onSuccess();
92673
92641
  }
92674
92642
  });
@@ -92698,8 +92666,9 @@ const DeleteMetricModal = ({
92698
92666
  variant: "reject",
92699
92667
  type: "button",
92700
92668
  size: "default",
92669
+ isDisabled: isLoading,
92701
92670
  onClick: handleDeleteMetric,
92702
- children: isLoading ? "Delete..." : "Delete"
92671
+ children: isLoading ? "Deleting..." : "Delete"
92703
92672
  })]
92704
92673
  })]
92705
92674
  });
@@ -92716,7 +92685,8 @@ const ExternalMetricList = ({
92716
92685
  breakpoint,
92717
92686
  layoutCols,
92718
92687
  params,
92719
- companyTenancyType = "TABLE"
92688
+ companyTenancyType = "TABLE",
92689
+ externalDashboardId
92720
92690
  }) => {
92721
92691
  const [isFullScreen, setFullScreen] = useState(false);
92722
92692
  const [deleteModal2, setDeleteModal] = useState({
@@ -92816,7 +92786,8 @@ const ExternalMetricList = ({
92816
92786
  onClose: () => setDeleteModal({
92817
92787
  id: "",
92818
92788
  show: false
92819
- })
92789
+ }),
92790
+ dashboardId: externalDashboardId
92820
92791
  }) : null]
92821
92792
  }) : /* @__PURE__ */ jsx(Fragment, {
92822
92793
  children: !isMetricListLoading ? /* @__PURE__ */ jsx("div", {
@@ -92918,38 +92889,31 @@ const EmbeddedDashboard = React__default.memo(({
92918
92889
  data: data2,
92919
92890
  isLoading
92920
92891
  } = useEmbeddedDashboard(token);
92921
- const {
92922
- globalTheme,
92923
- setGlobalTheme
92924
- } = useGlobalTheme();
92925
92892
  const [isShowFilters, setShowFilters] = useState(false);
92926
92893
  const [globalFilters, setGlobalFilters] = useState({
92927
92894
  tableName: "",
92928
92895
  filters: []
92929
92896
  });
92930
- useGetThemesQuery({
92897
+ const {
92898
+ data: adminThemeData
92899
+ } = useGetThemesQuery({
92931
92900
  companyId: data2.companyId
92932
92901
  }, {
92933
- enabled: !!data2.companyId,
92934
- onSuccess: (res) => {
92935
- setGlobalTheme(res.themes[0]);
92936
- }
92937
- });
92938
- const embedDashboardStyle = useMemo(() => {
92939
- var _a3, _b3;
92940
- if (!globalTheme)
92941
- return void 0;
92942
- const style2 = {};
92943
- if ((_a3 = globalTheme.dashboard.backgroundColor) == null ? void 0 : _a3.trim())
92944
- style2.backgroundColor = globalTheme.dashboard.backgroundColor.trim() || void 0;
92945
- if ((_b3 = globalTheme.general.fontFamily) == null ? void 0 : _b3.trim())
92946
- style2.fontFamily = globalTheme.general.fontFamily.trim() || void 0;
92947
- return style2;
92948
- }, [globalTheme]);
92902
+ enabled: !!data2.companyId
92903
+ });
92904
+ const [adminTheme, adminThemeChartColors] = useMemo(() => {
92905
+ var _a3, _b3, _c2, _d;
92906
+ const colors2 = (_d = (_c2 = (_b3 = (_a3 = adminThemeData == null ? void 0 : adminThemeData.themes[0]) == null ? void 0 : _a3.chart) == null ? void 0 : _b3.palettes) == null ? void 0 : _c2.find((palette) => {
92907
+ var _a4, _b4;
92908
+ return palette.name === ((_b4 = (_a4 = adminThemeData.themes[0]) == null ? void 0 : _a4.chart) == null ? void 0 : _b4.selected);
92909
+ })) == null ? void 0 : _d.colors;
92910
+ return [adminThemeData == null ? void 0 : adminThemeData.themes[0], colors2];
92911
+ }, [adminThemeData == null ? void 0 : adminThemeData.themes[0]]);
92912
+ useApplyAdminTheme(adminTheme);
92949
92913
  return /* @__PURE__ */ jsx(Fragment, {
92950
92914
  children: /* @__PURE__ */ jsxs("div", {
92951
92915
  className: styles$F["embedDashboard-container"],
92952
- style: embedDashboardStyle,
92916
+ id: "dbn-dashboard",
92953
92917
  children: [((_a2 = data2.externalDashboard) == null ? void 0 : _a2.id) && !isLoading && /* @__PURE__ */ jsxs(Fragment, {
92954
92918
  children: [!(options2 == null ? void 0 : options2.disableMetricCreation) && !data2.externalDashboard.filters.length && !data2.isAllowedToCreateMetrics ? null : /* @__PURE__ */ jsxs("div", {
92955
92919
  className: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? styles$F["embedDashboard-header-floating"] : styles$F["embedDashboard-header-static"],
@@ -92976,7 +92940,8 @@ const EmbeddedDashboard = React__default.memo(({
92976
92940
  companyId: data2.companyId,
92977
92941
  mode: data2.mode,
92978
92942
  externalDashboardId: data2.externalDashboard.id,
92979
- variant: options2 == null ? void 0 : options2.headerVariant
92943
+ variant: options2 == null ? void 0 : options2.headerVariant,
92944
+ chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors
92980
92945
  })]
92981
92946
  })]
92982
92947
  }), /* @__PURE__ */ jsxs("div", {
@@ -92988,13 +92953,14 @@ const EmbeddedDashboard = React__default.memo(({
92988
92953
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
92989
92954
  client: data2.clientId,
92990
92955
  isLiveMode: data2.mode,
92956
+ externalDashboardId: data2.externalDashboardId,
92991
92957
  isAllowedToDeleteMetrics: data2.isAllowedToDeleteMetrics,
92992
92958
  externalDashboardMetrics: data2.externalDashboardMetrics,
92993
92959
  isMetricListLoading: isLoading,
92994
92960
  globalFilters,
92995
92961
  breakpoint: theme2 == null ? void 0 : theme2.breakpoint,
92996
92962
  layoutCols: theme2 == null ? void 0 : theme2.metricLayoutCols,
92997
- chartColors: options2 == null ? void 0 : options2.chartColors,
92963
+ chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors,
92998
92964
  params: Array.isArray(data2.rlsSettings) ? data2.rlsSettings : [],
92999
92965
  companyTenancyType: data2.companyTenancyType
93000
92966
  })]
@@ -93029,9 +92995,7 @@ const PluginProvider = ({
93029
92995
  FallbackComponent: ErrorFallback,
93030
92996
  children: /* @__PURE__ */ jsx(QueryClientProvider, {
93031
92997
  client: queryClient,
93032
- children: /* @__PURE__ */ jsx(GlobalThemeProvider, {
93033
- children: children2
93034
- })
92998
+ children: children2
93035
92999
  })
93036
93000
  });
93037
93001
  };