@quillsql/react 2.15.4 → 2.15.6

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.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name2 in all)
10
13
  __defProp(target, name2, { get: all[name2], enumerable: true });
@@ -27,6 +30,358 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // ../../node_modules/pluralize/pluralize.js
34
+ var require_pluralize = __commonJS({
35
+ "../../node_modules/pluralize/pluralize.js"(exports2, module2) {
36
+ "use strict";
37
+ (function(root, pluralize2) {
38
+ if (typeof require === "function" && typeof exports2 === "object" && typeof module2 === "object") {
39
+ module2.exports = pluralize2();
40
+ } else if (typeof define === "function" && define.amd) {
41
+ define(function() {
42
+ return pluralize2();
43
+ });
44
+ } else {
45
+ root.pluralize = pluralize2();
46
+ }
47
+ })(exports2, function() {
48
+ var pluralRules = [];
49
+ var singularRules = [];
50
+ var uncountables = {};
51
+ var irregularPlurals = {};
52
+ var irregularSingles = {};
53
+ function sanitizeRule(rule) {
54
+ if (typeof rule === "string") {
55
+ return new RegExp("^" + rule + "$", "i");
56
+ }
57
+ return rule;
58
+ }
59
+ function restoreCase(word, token) {
60
+ if (word === token) return token;
61
+ if (word === word.toLowerCase()) return token.toLowerCase();
62
+ if (word === word.toUpperCase()) return token.toUpperCase();
63
+ if (word[0] === word[0].toUpperCase()) {
64
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
65
+ }
66
+ return token.toLowerCase();
67
+ }
68
+ function interpolate(str, args) {
69
+ return str.replace(/\$(\d{1,2})/g, function(match, index) {
70
+ return args[index] || "";
71
+ });
72
+ }
73
+ function replace(word, rule) {
74
+ return word.replace(rule[0], function(match, index) {
75
+ var result = interpolate(rule[1], arguments);
76
+ if (match === "") {
77
+ return restoreCase(word[index - 1], result);
78
+ }
79
+ return restoreCase(match, result);
80
+ });
81
+ }
82
+ function sanitizeWord(token, word, rules) {
83
+ if (!token.length || uncountables.hasOwnProperty(token)) {
84
+ return word;
85
+ }
86
+ var len = rules.length;
87
+ while (len--) {
88
+ var rule = rules[len];
89
+ if (rule[0].test(word)) return replace(word, rule);
90
+ }
91
+ return word;
92
+ }
93
+ function replaceWord(replaceMap, keepMap, rules) {
94
+ return function(word) {
95
+ var token = word.toLowerCase();
96
+ if (keepMap.hasOwnProperty(token)) {
97
+ return restoreCase(word, token);
98
+ }
99
+ if (replaceMap.hasOwnProperty(token)) {
100
+ return restoreCase(word, replaceMap[token]);
101
+ }
102
+ return sanitizeWord(token, word, rules);
103
+ };
104
+ }
105
+ function checkWord(replaceMap, keepMap, rules, bool) {
106
+ return function(word) {
107
+ var token = word.toLowerCase();
108
+ if (keepMap.hasOwnProperty(token)) return true;
109
+ if (replaceMap.hasOwnProperty(token)) return false;
110
+ return sanitizeWord(token, token, rules) === token;
111
+ };
112
+ }
113
+ function pluralize2(word, count, inclusive) {
114
+ var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
115
+ return (inclusive ? count + " " : "") + pluralized;
116
+ }
117
+ pluralize2.plural = replaceWord(
118
+ irregularSingles,
119
+ irregularPlurals,
120
+ pluralRules
121
+ );
122
+ pluralize2.isPlural = checkWord(
123
+ irregularSingles,
124
+ irregularPlurals,
125
+ pluralRules
126
+ );
127
+ pluralize2.singular = replaceWord(
128
+ irregularPlurals,
129
+ irregularSingles,
130
+ singularRules
131
+ );
132
+ pluralize2.isSingular = checkWord(
133
+ irregularPlurals,
134
+ irregularSingles,
135
+ singularRules
136
+ );
137
+ pluralize2.addPluralRule = function(rule, replacement) {
138
+ pluralRules.push([sanitizeRule(rule), replacement]);
139
+ };
140
+ pluralize2.addSingularRule = function(rule, replacement) {
141
+ singularRules.push([sanitizeRule(rule), replacement]);
142
+ };
143
+ pluralize2.addUncountableRule = function(word) {
144
+ if (typeof word === "string") {
145
+ uncountables[word.toLowerCase()] = true;
146
+ return;
147
+ }
148
+ pluralize2.addPluralRule(word, "$0");
149
+ pluralize2.addSingularRule(word, "$0");
150
+ };
151
+ pluralize2.addIrregularRule = function(single, plural) {
152
+ plural = plural.toLowerCase();
153
+ single = single.toLowerCase();
154
+ irregularSingles[single] = plural;
155
+ irregularPlurals[plural] = single;
156
+ };
157
+ [
158
+ // Pronouns.
159
+ ["I", "we"],
160
+ ["me", "us"],
161
+ ["he", "they"],
162
+ ["she", "they"],
163
+ ["them", "them"],
164
+ ["myself", "ourselves"],
165
+ ["yourself", "yourselves"],
166
+ ["itself", "themselves"],
167
+ ["herself", "themselves"],
168
+ ["himself", "themselves"],
169
+ ["themself", "themselves"],
170
+ ["is", "are"],
171
+ ["was", "were"],
172
+ ["has", "have"],
173
+ ["this", "these"],
174
+ ["that", "those"],
175
+ // Words ending in with a consonant and `o`.
176
+ ["echo", "echoes"],
177
+ ["dingo", "dingoes"],
178
+ ["volcano", "volcanoes"],
179
+ ["tornado", "tornadoes"],
180
+ ["torpedo", "torpedoes"],
181
+ // Ends with `us`.
182
+ ["genus", "genera"],
183
+ ["viscus", "viscera"],
184
+ // Ends with `ma`.
185
+ ["stigma", "stigmata"],
186
+ ["stoma", "stomata"],
187
+ ["dogma", "dogmata"],
188
+ ["lemma", "lemmata"],
189
+ ["schema", "schemata"],
190
+ ["anathema", "anathemata"],
191
+ // Other irregular rules.
192
+ ["ox", "oxen"],
193
+ ["axe", "axes"],
194
+ ["die", "dice"],
195
+ ["yes", "yeses"],
196
+ ["foot", "feet"],
197
+ ["eave", "eaves"],
198
+ ["goose", "geese"],
199
+ ["tooth", "teeth"],
200
+ ["quiz", "quizzes"],
201
+ ["human", "humans"],
202
+ ["proof", "proofs"],
203
+ ["carve", "carves"],
204
+ ["valve", "valves"],
205
+ ["looey", "looies"],
206
+ ["thief", "thieves"],
207
+ ["groove", "grooves"],
208
+ ["pickaxe", "pickaxes"],
209
+ ["passerby", "passersby"]
210
+ ].forEach(function(rule) {
211
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
212
+ });
213
+ [
214
+ [/s?$/i, "s"],
215
+ [/[^\u0000-\u007F]$/i, "$0"],
216
+ [/([^aeiou]ese)$/i, "$1"],
217
+ [/(ax|test)is$/i, "$1es"],
218
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
219
+ [/(e[mn]u)s?$/i, "$1s"],
220
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
221
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
222
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
223
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
224
+ [/(her|at|gr)o$/i, "$1oes"],
225
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
226
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
227
+ [/sis$/i, "ses"],
228
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
229
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
230
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
231
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
232
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
233
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
234
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
235
+ [/(child)(?:ren)?$/i, "$1ren"],
236
+ [/eaux$/i, "$0"],
237
+ [/m[ae]n$/i, "men"],
238
+ ["thou", "you"]
239
+ ].forEach(function(rule) {
240
+ return pluralize2.addPluralRule(rule[0], rule[1]);
241
+ });
242
+ [
243
+ [/s$/i, ""],
244
+ [/(ss)$/i, "$1"],
245
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
246
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
247
+ [/ies$/i, "y"],
248
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
249
+ [/\b(mon|smil)ies$/i, "$1ey"],
250
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
251
+ [/(seraph|cherub)im$/i, "$1"],
252
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
253
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
254
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
255
+ [/(test)(?:is|es)$/i, "$1is"],
256
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
257
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
258
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
259
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
260
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
261
+ [/(matr|append)ices$/i, "$1ix"],
262
+ [/(pe)(rson|ople)$/i, "$1rson"],
263
+ [/(child)ren$/i, "$1"],
264
+ [/(eau)x?$/i, "$1"],
265
+ [/men$/i, "man"]
266
+ ].forEach(function(rule) {
267
+ return pluralize2.addSingularRule(rule[0], rule[1]);
268
+ });
269
+ [
270
+ // Singular words with no plurals.
271
+ "adulthood",
272
+ "advice",
273
+ "agenda",
274
+ "aid",
275
+ "aircraft",
276
+ "alcohol",
277
+ "ammo",
278
+ "analytics",
279
+ "anime",
280
+ "athletics",
281
+ "audio",
282
+ "bison",
283
+ "blood",
284
+ "bream",
285
+ "buffalo",
286
+ "butter",
287
+ "carp",
288
+ "cash",
289
+ "chassis",
290
+ "chess",
291
+ "clothing",
292
+ "cod",
293
+ "commerce",
294
+ "cooperation",
295
+ "corps",
296
+ "debris",
297
+ "diabetes",
298
+ "digestion",
299
+ "elk",
300
+ "energy",
301
+ "equipment",
302
+ "excretion",
303
+ "expertise",
304
+ "firmware",
305
+ "flounder",
306
+ "fun",
307
+ "gallows",
308
+ "garbage",
309
+ "graffiti",
310
+ "hardware",
311
+ "headquarters",
312
+ "health",
313
+ "herpes",
314
+ "highjinks",
315
+ "homework",
316
+ "housework",
317
+ "information",
318
+ "jeans",
319
+ "justice",
320
+ "kudos",
321
+ "labour",
322
+ "literature",
323
+ "machinery",
324
+ "mackerel",
325
+ "mail",
326
+ "media",
327
+ "mews",
328
+ "moose",
329
+ "music",
330
+ "mud",
331
+ "manga",
332
+ "news",
333
+ "only",
334
+ "personnel",
335
+ "pike",
336
+ "plankton",
337
+ "pliers",
338
+ "police",
339
+ "pollution",
340
+ "premises",
341
+ "rain",
342
+ "research",
343
+ "rice",
344
+ "salmon",
345
+ "scissors",
346
+ "series",
347
+ "sewage",
348
+ "shambles",
349
+ "shrimp",
350
+ "software",
351
+ "species",
352
+ "staff",
353
+ "swine",
354
+ "tennis",
355
+ "traffic",
356
+ "transportation",
357
+ "trout",
358
+ "tuna",
359
+ "wealth",
360
+ "welfare",
361
+ "whiting",
362
+ "wildebeest",
363
+ "wildlife",
364
+ "you",
365
+ /pok[eé]mon$/i,
366
+ // Regexes.
367
+ /[^aeiou]ese$/i,
368
+ // "chinese", "japanese"
369
+ /deer$/i,
370
+ // "deer", "reindeer"
371
+ /fish$/i,
372
+ // "fish", "blowfish", "angelfish"
373
+ /measles$/i,
374
+ /o[iu]s$/i,
375
+ // "carnivorous"
376
+ /pox$/i,
377
+ // "chickpox", "smallpox"
378
+ /sheep$/i
379
+ ].forEach(pluralize2.addUncountableRule);
380
+ return pluralize2;
381
+ });
382
+ }
383
+ });
384
+
30
385
  // src/index.ts
31
386
  var index_exports = {};
32
387
  __export(index_exports, {
@@ -70,6 +425,7 @@ __export(index_exports, {
70
425
  useQuill: () => useQuill,
71
426
  useReportBuilder: () => useReportBuilder,
72
427
  useReports: () => useReports,
428
+ useTenants: () => useTenants,
73
429
  useVirtualTables: () => useVirtualTables
74
430
  });
75
431
  module.exports = __toCommonJS(index_exports);
@@ -1379,6 +1735,7 @@ var DashboardFilterType = /* @__PURE__ */ ((DashboardFilterType4) => {
1379
1735
  DashboardFilterType4["Select"] = "select";
1380
1736
  DashboardFilterType4["MultiSelect"] = "multiselect";
1381
1737
  DashboardFilterType4["Date"] = "date";
1738
+ DashboardFilterType4["Tenant"] = "tenant";
1382
1739
  return DashboardFilterType4;
1383
1740
  })(DashboardFilterType || {});
1384
1741
  var convertCustomFilter = (filter) => {
@@ -1632,6 +1989,16 @@ var convertInternalDashboardFilterToDashboardFilter = (filter) => {
1632
1989
  },
1633
1990
  options
1634
1991
  };
1992
+ } else if (filter.filterType === "tenant" /* Tenant */) {
1993
+ return {
1994
+ label: filter.label,
1995
+ type: "tenant" /* Tenant */,
1996
+ value: filter.multiSelect ? filter.values ?? [] : filter.values?.[0] ?? null,
1997
+ options: (filter.options ?? []).map((opt) => ({
1998
+ label: opt.label,
1999
+ value: opt.value
2000
+ }))
2001
+ };
1635
2002
  }
1636
2003
  throw new Error(
1637
2004
  "Unknown InternalDashboardFilterType: " + filter.filterType
@@ -17496,7 +17863,7 @@ async function generatePivotWithSQL({
17496
17863
  if (!itemQuery) {
17497
17864
  throw Error("No item query found in report");
17498
17865
  }
17499
- sqlQuery = pivotQuery ?? generatePivotQuery(
17866
+ sqlQuery = generatePivotQuery(
17500
17867
  pivot,
17501
17868
  itemQuery,
17502
17869
  databaseType,
@@ -18814,10 +19181,15 @@ async function getPivotTable(report, dashboardFilters, dashboardName, getToken,
18814
19181
  });
18815
19182
  }
18816
19183
  }
19184
+ const pivotQuery = generatePivotQuery(
19185
+ pivot,
19186
+ report.itemQuery?.[0],
19187
+ client.databaseType
19188
+ );
18817
19189
  return {
18818
19190
  rows: [],
18819
19191
  rowCount: 0,
18820
- pivotQuery: "",
19192
+ pivotQuery: pivotQuery ?? "",
18821
19193
  columns
18822
19194
  };
18823
19195
  }
@@ -21298,7 +21670,19 @@ var DashboardFiltersContext = (0, import_react.createContext)({
21298
21670
  loadFiltersForDashboard: async () => {
21299
21671
  }
21300
21672
  });
21301
- var TenantContext = (0, import_react.createContext)({});
21673
+ var TenantContext = (0, import_react.createContext)({
21674
+ childTenantMappings: {},
21675
+ viewerTenants: {},
21676
+ viewerTenantsByOwner: {},
21677
+ isLoadingMappedTenants: false,
21678
+ isLoadingViewerTenants: false,
21679
+ fetchViewerTenantsForDashboard: async () => {
21680
+ },
21681
+ fetchMappedTenantsForDashboard: async () => {
21682
+ },
21683
+ getMappedTenantsForDashboard: async () => void 0,
21684
+ getViewerTenantsByOwner: async () => []
21685
+ });
21302
21686
  var FetchContext = (0, import_react.createContext)({
21303
21687
  getToken: async () => "",
21304
21688
  quillFetchWithToken: async () => ({ data: null })
@@ -21388,6 +21772,15 @@ var ContextProvider = ({
21388
21772
  const fetchSchemaProcessId = (0, import_react.useRef)(0);
21389
21773
  const currentTenant = (0, import_react.useRef)(null);
21390
21774
  const currentPublicKey = (0, import_react.useRef)(null);
21775
+ const [childTenantMappings, setChildTenantMappings] = (0, import_react.useState)({});
21776
+ const [viewerTenants, setViewerTenants] = (0, import_react.useState)({});
21777
+ const [viewerTenantsByOwner, setViewerTenantsByOwner] = (0, import_react.useState)({});
21778
+ const [isLoadingMappedTenants, setIsLoadingMappedTenants] = (0, import_react.useState)(false);
21779
+ const [isLoadingViewerTenants, setIsLoadingViewerTenants] = (0, import_react.useState)(false);
21780
+ const prevTenants = (0, import_react.useRef)(null);
21781
+ const viewerTenantsRequests = (0, import_react.useRef)(/* @__PURE__ */ new Set());
21782
+ const viewerTenantsByOwnerRequests = (0, import_react.useRef)(/* @__PURE__ */ new Set());
21783
+ const mappedTenantsRequests = (0, import_react.useRef)(/* @__PURE__ */ new Set());
21391
21784
  const loadDashboardProcessId = (0, import_react.useRef)({});
21392
21785
  (0, import_react.useEffect)(() => {
21393
21786
  if (!theme) {
@@ -21736,7 +22129,7 @@ var ContextProvider = ({
21736
22129
  });
21737
22130
  await Promise.allSettled(
21738
22131
  filters.map(async (filter) => {
21739
- if (filter.filterType !== "string") {
22132
+ if (filter.filterType === "date_range") {
21740
22133
  dashboardFiltersDispatch({
21741
22134
  type: "UPDATE_DASHBOARD_FILTER",
21742
22135
  dashboardName,
@@ -21760,6 +22153,10 @@ var ContextProvider = ({
21760
22153
  });
21761
22154
  return null;
21762
22155
  }
22156
+ if (filter.filterType === "tenant") {
22157
+ await fetchTenantFilterOptions(dashboardName, filter);
22158
+ return null;
22159
+ }
21763
22160
  const filterOptionsAbortController = new AbortController();
21764
22161
  filterOptionsAbortControllers.current.add(filterOptionsAbortController);
21765
22162
  try {
@@ -22121,7 +22518,8 @@ var ContextProvider = ({
22121
22518
  },
22122
22519
  task: "dashboards",
22123
22520
  metadata: {
22124
- clientId: publicKey2
22521
+ clientId: publicKey2,
22522
+ tenants
22125
22523
  // getSections: true, // skip fetching reports since 'dashboard' always does anyway
22126
22524
  },
22127
22525
  abortSignal: fetchDashboardsAbortController.current.signal,
@@ -22210,6 +22608,14 @@ var ContextProvider = ({
22210
22608
  loading: true
22211
22609
  };
22212
22610
  });
22611
+ dashboard2.tenantFilters?.forEach(
22612
+ (filter) => {
22613
+ acc[dashboard2.name][filter.label] = {
22614
+ filter: { ...filter, options: void 0 },
22615
+ loading: true
22616
+ };
22617
+ }
22618
+ );
22213
22619
  return acc;
22214
22620
  }, {})
22215
22621
  });
@@ -22285,6 +22691,180 @@ var ContextProvider = ({
22285
22691
  return { error: "Failed to fetch data" };
22286
22692
  }
22287
22693
  }
22694
+ const getDashboardViewerTenants = async (dashboardName) => {
22695
+ if (!populatedClient) {
22696
+ return [];
22697
+ }
22698
+ const { data } = await quillFetchWithToken({
22699
+ client: populatedClient,
22700
+ task: "viewer-tenants",
22701
+ metadata: {
22702
+ dashboardName
22703
+ }
22704
+ });
22705
+ return data?.viewerTenants || [];
22706
+ };
22707
+ const getOwnerViewerTenants = async (ownerTenant) => {
22708
+ if (!populatedClient) {
22709
+ return [];
22710
+ }
22711
+ const { data } = await quillFetchWithToken({
22712
+ client: populatedClient,
22713
+ task: "viewer-tenants-by-owner",
22714
+ metadata: {
22715
+ tenantField: ownerTenant
22716
+ }
22717
+ });
22718
+ return data?.viewerTenants || [];
22719
+ };
22720
+ const getMappedTenants = async (tenantsParam, dashboardName) => {
22721
+ if (!populatedClient) {
22722
+ return {};
22723
+ }
22724
+ const { data, queries } = await quillFetchWithToken({
22725
+ client: populatedClient,
22726
+ task: "mapped-tenants",
22727
+ metadata: {
22728
+ tenants: tenantsParam,
22729
+ dashboardName
22730
+ }
22731
+ });
22732
+ const childTenants = data.queryOrder;
22733
+ const queryResults = queries.queryResults.map((result) => {
22734
+ return result?.rows?.map((row) => ({
22735
+ value: row["flag"],
22736
+ label: row["label"]
22737
+ })) ?? null;
22738
+ });
22739
+ const mappedTenants = {};
22740
+ await Promise.all(
22741
+ childTenants.map(
22742
+ async (tenant, index) => {
22743
+ mappedTenants[tenant.tenantField] = queryResults[index];
22744
+ }
22745
+ )
22746
+ );
22747
+ return mappedTenants;
22748
+ };
22749
+ const fetchViewerTenantsForDashboard = (0, import_react.useCallback)(
22750
+ async (dashboardName) => {
22751
+ if (!populatedClient) return;
22752
+ if (viewerTenantsRequests.current.has(dashboardName)) {
22753
+ return;
22754
+ }
22755
+ if (viewerTenants[dashboardName]) {
22756
+ return;
22757
+ }
22758
+ viewerTenantsRequests.current.add(dashboardName);
22759
+ setIsLoadingViewerTenants(true);
22760
+ try {
22761
+ const viewerTenantsData = await getDashboardViewerTenants(dashboardName);
22762
+ setViewerTenants((prev) => ({
22763
+ ...prev,
22764
+ [dashboardName]: viewerTenantsData
22765
+ }));
22766
+ } catch (error) {
22767
+ console.error("Error fetching viewer tenants:", error);
22768
+ } finally {
22769
+ viewerTenantsRequests.current.delete(dashboardName);
22770
+ setIsLoadingViewerTenants(false);
22771
+ }
22772
+ },
22773
+ [populatedClient]
22774
+ );
22775
+ const fetchMappedTenantsForDashboard = async (dashboardName) => {
22776
+ await getMappedTenantsForDashboard(dashboardName);
22777
+ return;
22778
+ };
22779
+ const getMappedTenantsForDashboard = (0, import_react.useCallback)(
22780
+ async (dashboardName) => {
22781
+ if (!populatedClient || !tenants) return void 0;
22782
+ const tenantsChanged = !(0, import_fast_deep_equal.default)(prevTenants.current, tenants);
22783
+ if (childTenantMappings[dashboardName] && !tenantsChanged) {
22784
+ return childTenantMappings[dashboardName];
22785
+ }
22786
+ if (mappedTenantsRequests.current.has(dashboardName) && !tenantsChanged) {
22787
+ return new Promise((resolve) => {
22788
+ const checkInterval = setInterval(() => {
22789
+ if (!mappedTenantsRequests.current.has(dashboardName)) {
22790
+ clearInterval(checkInterval);
22791
+ resolve(childTenantMappings[dashboardName]);
22792
+ }
22793
+ }, 100);
22794
+ });
22795
+ }
22796
+ prevTenants.current = tenants;
22797
+ mappedTenantsRequests.current.add(dashboardName);
22798
+ setIsLoadingMappedTenants(true);
22799
+ try {
22800
+ const mappedTenants = await getMappedTenants(tenants, dashboardName);
22801
+ setChildTenantMappings((prev) => ({
22802
+ ...prev,
22803
+ [dashboardName]: mappedTenants
22804
+ }));
22805
+ return mappedTenants;
22806
+ } catch (error) {
22807
+ console.error("Error fetching mapped tenants:", error);
22808
+ setChildTenantMappings((prev) => ({
22809
+ ...prev,
22810
+ [dashboardName]: {}
22811
+ }));
22812
+ return void 0;
22813
+ } finally {
22814
+ mappedTenantsRequests.current.delete(dashboardName);
22815
+ setIsLoadingMappedTenants(false);
22816
+ }
22817
+ },
22818
+ [populatedClient, tenants, childTenantMappings]
22819
+ );
22820
+ const getViewerTenantsByOwner = (0, import_react.useCallback)(
22821
+ async (ownerTenant) => {
22822
+ if (!populatedClient) return [];
22823
+ if (viewerTenantsByOwner[ownerTenant]) {
22824
+ return viewerTenantsByOwner[ownerTenant];
22825
+ }
22826
+ if (viewerTenantsByOwnerRequests.current.has(ownerTenant)) {
22827
+ return new Promise((resolve) => {
22828
+ const checkInterval = setInterval(() => {
22829
+ if (!viewerTenantsByOwnerRequests.current.has(ownerTenant)) {
22830
+ clearInterval(checkInterval);
22831
+ resolve(viewerTenantsByOwner[ownerTenant] || []);
22832
+ }
22833
+ }, 100);
22834
+ });
22835
+ }
22836
+ viewerTenantsByOwnerRequests.current.add(ownerTenant);
22837
+ setIsLoadingViewerTenants(true);
22838
+ try {
22839
+ const viewerTenantsData = await getOwnerViewerTenants(ownerTenant);
22840
+ setViewerTenantsByOwner((prev) => ({
22841
+ ...prev,
22842
+ [ownerTenant]: viewerTenantsData
22843
+ }));
22844
+ return viewerTenantsData;
22845
+ } catch (error) {
22846
+ console.error("Error fetching viewer tenants by owner:", error);
22847
+ return [];
22848
+ } finally {
22849
+ viewerTenantsByOwnerRequests.current.delete(ownerTenant);
22850
+ setIsLoadingViewerTenants(false);
22851
+ }
22852
+ },
22853
+ [populatedClient, viewerTenantsByOwner]
22854
+ );
22855
+ const fetchTenantFilterOptions = async (dashboardName, filter) => {
22856
+ const mappings = await getMappedTenantsForDashboard(dashboardName);
22857
+ const options = mappings?.[filter.field] ?? [];
22858
+ dashboardFiltersDispatch({
22859
+ type: "UPDATE_DASHBOARD_FILTER",
22860
+ dashboardName,
22861
+ filterName: filter.label,
22862
+ data: {
22863
+ filter: { ...filter, options },
22864
+ loading: false
22865
+ }
22866
+ });
22867
+ };
22288
22868
  (0, import_react.useEffect)(() => {
22289
22869
  async function updateClientAndSchema(publicKey2) {
22290
22870
  if (!publicKey2 || populatedClient?.clientId === publicKey2 && populatedClient?.allTenantTypes?.length)
@@ -22443,7 +23023,17 @@ var ContextProvider = ({
22443
23023
  {
22444
23024
  value: {
22445
23025
  tenants: populatedClient?.currentTenants ?? tenants,
22446
- flags: populatedClient?.currentFlags ?? flags
23026
+ flags: populatedClient?.currentFlags ?? flags,
23027
+ childTenantMappings,
23028
+ viewerTenants,
23029
+ viewerTenantsByOwner,
23030
+ isLoadingMappedTenants,
23031
+ isLoadingViewerTenants,
23032
+ fetchViewerTenantsForDashboard,
23033
+ // fetchViewerTenantsByOwner,
23034
+ fetchMappedTenantsForDashboard,
23035
+ getMappedTenantsForDashboard,
23036
+ getViewerTenantsByOwner
22447
23037
  },
22448
23038
  children
22449
23039
  }
@@ -22531,7 +23121,7 @@ var useDashboardInternal = (dashboardName, customFilters) => {
22531
23121
  );
22532
23122
  if (!fetchFromServer && Object.keys(dashboardFilters[dashboardName] ?? {}).length && // there exists no non date filter that has undefined options
22533
23123
  Object.values(dashboardFilters[dashboardName] ?? {}).every(
22534
- (filter) => filter.filter.filterType === "date_range" /* Date */ || filter.filter.options
23124
+ (filter) => filter.filter.filterType === "date_range" /* Date */ || filter.filter.filterType === "tenant" /* Tenant */ || filter.filter.options
22535
23125
  )) {
22536
23126
  return;
22537
23127
  }
@@ -22548,6 +23138,9 @@ var useDashboardInternal = (dashboardName, customFilters) => {
22548
23138
  ...updatedDashboard?.filters?.map((filter) => ({
22549
23139
  ...filter,
22550
23140
  query: void 0
23141
+ })) ?? [],
23142
+ ...updatedDashboard?.tenantFilters?.map((filter) => ({
23143
+ ...filter
22551
23144
  })) ?? []
22552
23145
  ],
22553
23146
  void 0,
@@ -22738,8 +23331,10 @@ var useDashboards = () => {
22738
23331
  (a, b) => (a.createdAt?.getTime() ?? 0) - (b.createdAt?.getTime() ?? 0)
22739
23332
  );
22740
23333
  }, [dashboardConfig]);
23334
+ const { getMappedTenantsForDashboard } = (0, import_react2.useContext)(TenantContext);
22741
23335
  const createDashboard = async ({
22742
23336
  name: name2,
23337
+ tenantFilters,
22743
23338
  filters,
22744
23339
  dateFilter,
22745
23340
  dashboardOwners
@@ -22756,6 +23351,7 @@ var useDashboards = () => {
22756
23351
  tenantKeys: dashboardOwners,
22757
23352
  dashboardId: name2,
22758
23353
  name: name2,
23354
+ allTenantFilters: tenantFilters ?? [],
22759
23355
  filters,
22760
23356
  dateFilter
22761
23357
  },
@@ -22764,6 +23360,7 @@ var useDashboards = () => {
22764
23360
  });
22765
23361
  const body = {
22766
23362
  newDashboardName: name2.trim(),
23363
+ tenantFilters,
22767
23364
  filters,
22768
23365
  dateFilter,
22769
23366
  name: name2.trim(),
@@ -22816,6 +23413,7 @@ var useDashboards = () => {
22816
23413
  const updateDashboard = async (name2, {
22817
23414
  newName,
22818
23415
  filters,
23416
+ tenantFilters,
22819
23417
  dateFilter,
22820
23418
  customFilters,
22821
23419
  tenantKeys
@@ -22837,6 +23435,7 @@ var useDashboards = () => {
22837
23435
  const body = {
22838
23436
  newDashboardName: newName.trim(),
22839
23437
  filters,
23438
+ tenantFilters,
22840
23439
  dateFilter: dateFilter ?? null,
22841
23440
  name: name2.trim(),
22842
23441
  task: "edit-dashboard",
@@ -22866,6 +23465,7 @@ var useDashboards = () => {
22866
23465
  config: {
22867
23466
  ...dashboard,
22868
23467
  ...updated.data.dashboard,
23468
+ allTenantFilters: tenantFilters ?? [],
22869
23469
  dateFilter: updated.data.dashboard.dateFilter ? {
22870
23470
  ...updated.data.dashboard.dateFilter,
22871
23471
  presetOptions: updated.data.dashboard.dateFilter.presetOptions?.map(
@@ -22960,6 +23560,8 @@ var useDashboards = () => {
22960
23560
  endDate: !range.endDate || range.endDate instanceof Date ? range.endDate : new Date(range.endDate)
22961
23561
  // when range.endDate is a string
22962
23562
  } : void 0;
23563
+ const mappedTenants = await getMappedTenantsForDashboard(newName);
23564
+ const mappedTenantKeys = Object.keys(mappedTenants ?? {});
22963
23565
  const newFilters = [
22964
23566
  ...updatedDateFilter ? [updatedDateFilter] : [],
22965
23567
  ...updated.data.dashboard.filters.map(
@@ -22969,14 +23571,22 @@ var useDashboards = () => {
22969
23571
  values: oldFilters?.[f.label]?.filter?.values,
22970
23572
  operator: oldFilters?.[f.label]?.filter?.operator
22971
23573
  })
22972
- ) ?? []
23574
+ ) ?? [],
23575
+ ...(updated.data.dashboard.tenantFilters?.map(
23576
+ (f) => ({
23577
+ ...f,
23578
+ values: oldFilters?.[f.label]?.filter?.values
23579
+ })
23580
+ ) ?? []).filter((filter) => {
23581
+ return mappedTenantKeys.includes(filter.field);
23582
+ })
22973
23583
  ].map((f) => {
22974
23584
  if (f.filterType === "date_range" /* Date */) {
22975
23585
  return {
22976
23586
  ...f,
22977
- startDate: dashboardFilters[name2]?.[f.label]?.filter?.startDate,
22978
- endDate: dashboardFilters[name2]?.[f.label]?.filter?.endDate,
22979
- preset: dashboardFilters[name2]?.[f.label]?.filter?.preset
23587
+ startDate: dashboardFilters[name2]?.[f.label]?.filter?.startDate ?? f.startDate,
23588
+ endDate: dashboardFilters[name2]?.[f.label]?.filter?.endDate ?? f.endDate,
23589
+ preset: dashboardFilters[name2]?.[f.label]?.filter?.preset ?? f.preset
22980
23590
  };
22981
23591
  } else {
22982
23592
  return {
@@ -23118,6 +23728,20 @@ var useDashboard = (dashboardName) => {
23118
23728
  endDate: value.endDate
23119
23729
  };
23120
23730
  }
23731
+ } else if (f.filterType === "tenant" /* Tenant */) {
23732
+ const value = update.value;
23733
+ let values;
23734
+ if (Array.isArray(value)) {
23735
+ values = value;
23736
+ } else if (typeof value === "string") {
23737
+ values = [value];
23738
+ } else {
23739
+ values = [];
23740
+ }
23741
+ return {
23742
+ ...f,
23743
+ values
23744
+ };
23121
23745
  }
23122
23746
  return f;
23123
23747
  });
@@ -23384,7 +24008,7 @@ async function getExportData(client, dashboardFilters, reportId, getToken, event
23384
24008
  }
23385
24009
  var useExport = (reportId, {
23386
24010
  CustomDocumentComponent = QuillCustomDocumentComponent,
23387
- maximumRowsPerPage = 20,
24011
+ maximumRowsPerPage = 39,
23388
24012
  // if sectionKeyField is passed, then we will group by that field
23389
24013
  sectionField
23390
24014
  } = {}) => {
@@ -23502,7 +24126,7 @@ var useExport = (reportId, {
23502
24126
  let html = "";
23503
24127
  let currentPage = {};
23504
24128
  let currentCount = 0;
23505
- let pageNumber = 1;
24129
+ let pageNumber = 0;
23506
24130
  if (sectionField) {
23507
24131
  for (const groupKey in groupedRows) {
23508
24132
  const rows = groupedRows[groupKey];
@@ -23577,7 +24201,7 @@ var useExport = (reportId, {
23577
24201
  } else {
23578
24202
  const rows = report.rows;
23579
24203
  for (let i = 0; i < rows.length; i += maximumRowsPerPage) {
23580
- const remainingRows = rows.length - i * maximumRowsPerPage;
24204
+ const remainingRows = rows.length - i;
23581
24205
  const availableSpace = maximumRowsPerPage - currentCount;
23582
24206
  const rowsToAdd = Math.min(remainingRows, availableSpace);
23583
24207
  currentCount += rowsToAdd;
@@ -23602,7 +24226,7 @@ var useExport = (reportId, {
23602
24226
  currentCount = 0;
23603
24227
  }
23604
24228
  }
23605
- if (currentCount < maximumRowsPerPage) {
24229
+ if (currentCount > 0 && currentCount < maximumRowsPerPage) {
23606
24230
  pageNumber++;
23607
24231
  const div = document.createElement("div");
23608
24232
  const root = (0, import_client2.createRoot)(div);
@@ -23636,81 +24260,138 @@ var useExport = (reportId, {
23636
24260
  isPDFLoading
23637
24261
  };
23638
24262
  };
23639
- function QuillCustomDocumentComponent({ report }) {
23640
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", margin: "2rem" }, children: [
23641
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
23642
- "div",
23643
- {
23644
- style: { display: "flex", flexDirection: "row", alignItems: "center" },
23645
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
23646
- "h2",
23647
- {
23648
- style: {
23649
- fontSize: 18,
23650
- fontWeight: "600",
23651
- textAlign: "left",
23652
- paddingLeft: 10
23653
- // color: theme?.primaryTextColor,
23654
- },
23655
- children: report.name
23656
- }
23657
- )
23658
- }
23659
- ),
23660
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { paddingLeft: 20, paddingRight: 20 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
23661
- "div",
23662
- {
23663
- style: {
23664
- border: "1px solid",
23665
- borderRadius: "4px",
23666
- borderStyle: "none"
23667
- },
23668
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
23669
- "table",
23670
- {
23671
- style: {
23672
- fontFamily: "sans-serif",
23673
- width: "100%",
23674
- borderCollapse: "collapse",
23675
- borderStyle: "none"
23676
- },
23677
- children: [
23678
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
23679
- "thead",
23680
- {
23681
- style: {
23682
- textAlign: "left",
23683
- textOverflow: "ellipsis",
23684
- whiteSpace: "nowrap",
23685
- overflow: "hidden"
23686
- },
23687
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: report.columns.map((col, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
23688
- "th",
23689
- {
23690
- style: { padding: "2px", paddingLeft: "3px" },
23691
- children: col.label
24263
+ function QuillCustomDocumentComponent({
24264
+ report,
24265
+ pageNumber,
24266
+ numberOfPages,
24267
+ maximumRowsPerPage
24268
+ }) {
24269
+ const rowStartIndex = (pageNumber - 1) * maximumRowsPerPage;
24270
+ const rowEndIndex = pageNumber * maximumRowsPerPage;
24271
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
24272
+ "div",
24273
+ {
24274
+ style: {
24275
+ // height: 794,
24276
+ // minHeight: 794,
24277
+ // maxHeight: 794,
24278
+ height: 595,
24279
+ minHeight: 595,
24280
+ maxHeight: 595
24281
+ },
24282
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { paddingLeft: 10, paddingRight: 20 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
24283
+ "div",
24284
+ {
24285
+ style: {
24286
+ border: "none",
24287
+ borderRadius: "4px"
24288
+ },
24289
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
24290
+ "table",
24291
+ {
24292
+ style: {
24293
+ fontFamily: "sans-serif",
24294
+ width: "100%",
24295
+ borderCollapse: "collapse",
24296
+ borderStyle: "none",
24297
+ fontSize: 8
24298
+ },
24299
+ children: [
24300
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
24301
+ "thead",
24302
+ {
24303
+ style: {
24304
+ textAlign: "left",
24305
+ textOverflow: "ellipsis",
24306
+ whiteSpace: "nowrap",
24307
+ overflow: "hidden"
23692
24308
  },
23693
- "head" + colIndex
23694
- )) })
23695
- }
23696
- ),
23697
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tbody", { children: report.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: report.columns.map((col, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
23698
- "td",
23699
- {
23700
- style: { padding: "2px", paddingLeft: "3px" },
23701
- children: quillFormat({
23702
- value: row[col.field],
23703
- format: col.format
23704
- })
23705
- },
23706
- "cell" + col.field + colIndex + rowIndex
23707
- )) }, "row" + rowIndex)) })
23708
- ]
23709
- }
23710
- )
23711
- }
23712
- ) })
23713
- ] });
24309
+ children: [
24310
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { colSpan: report.columns.length, children: "\xA0" }) }),
24311
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
24312
+ "th",
24313
+ {
24314
+ style: {
24315
+ fontSize: "12px",
24316
+ fontWeight: "bold",
24317
+ textAlign: "left",
24318
+ whiteSpace: "nowrap",
24319
+ overflow: "hidden",
24320
+ textOverflow: "ellipsis",
24321
+ width: "100%",
24322
+ margin: 0
24323
+ },
24324
+ colSpan: report.columns.length,
24325
+ children: report.name
24326
+ }
24327
+ ) }),
24328
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { colSpan: report.columns.length, children: "\xA0" }) }),
24329
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: report.columns.map((col, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
24330
+ "th",
24331
+ {
24332
+ style: { padding: "2px", paddingLeft: "3px", fontSize: 8 },
24333
+ children: col.label
24334
+ },
24335
+ "head" + colIndex
24336
+ )) })
24337
+ ]
24338
+ }
24339
+ ),
24340
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tbody", { children: [
24341
+ report.rows.slice(rowStartIndex, rowEndIndex).map((row, rowIndex) => {
24342
+ return [
24343
+ // Title and header at the top of every page
24344
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: report.columns.map((col, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
24345
+ "td",
24346
+ {
24347
+ style: {
24348
+ padding: "2px",
24349
+ paddingLeft: "3px",
24350
+ fontSize: 8,
24351
+ whiteSpace: "nowrap",
24352
+ overflow: "hidden",
24353
+ textOverflow: "ellipsis",
24354
+ width: "100%"
24355
+ },
24356
+ children: quillFormat({
24357
+ value: row[col.field],
24358
+ format: col.format
24359
+ })
24360
+ },
24361
+ "cell" + col.field + colIndex + rowIndex
24362
+ )) }, "row" + rowIndex)
24363
+ ];
24364
+ }),
24365
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { colSpan: report.columns.length, children: "\xA0" }) }),
24366
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
24367
+ "td",
24368
+ {
24369
+ style: {
24370
+ fontSize: "8px",
24371
+ textAlign: "left",
24372
+ whiteSpace: "nowrap",
24373
+ overflow: "hidden",
24374
+ textOverflow: "ellipsis",
24375
+ width: "100%",
24376
+ margin: 0
24377
+ },
24378
+ colSpan: report.columns.length,
24379
+ children: [
24380
+ "Page ",
24381
+ pageNumber,
24382
+ " of ",
24383
+ numberOfPages
24384
+ ]
24385
+ }
24386
+ ) })
24387
+ ] })
24388
+ ]
24389
+ }
24390
+ )
24391
+ }
24392
+ ) })
24393
+ }
24394
+ );
23714
24395
  }
23715
24396
 
23716
24397
  // src/Chart.tsx
@@ -25082,7 +25763,7 @@ var MemoizedButton = ({
25082
25763
  }) => {
25083
25764
  const [theme] = (0, import_react11.useContext)(ThemeContext);
25084
25765
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
25085
- QuillToolTip,
25766
+ QuillToolTipPortal,
25086
25767
  {
25087
25768
  enabled: !!tooltipText && tooltipText !== "",
25088
25769
  text: tooltipText ?? "",
@@ -26319,6 +27000,140 @@ var QuillToolTip = ({
26319
27000
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "tooltip-text", style: { ...textStyle }, children: text })
26320
27001
  ] }) : children;
26321
27002
  };
27003
+ var QuillToolTipPortal = ({
27004
+ children,
27005
+ text,
27006
+ enabled = true,
27007
+ containerStyle = {},
27008
+ textStyle = {},
27009
+ mirror = false
27010
+ }) => {
27011
+ const [theme] = (0, import_react11.useContext)(ThemeContext);
27012
+ const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
27013
+ const tooltipRef = (0, import_react11.useRef)(null);
27014
+ const triggerRef = (0, import_react11.useRef)(null);
27015
+ const [tooltipPosition, setTooltipPosition] = (0, import_react11.useState)(void 0);
27016
+ const updatePosition = () => {
27017
+ if (triggerRef.current && tooltipRef.current) {
27018
+ const rect = triggerRef.current.getBoundingClientRect();
27019
+ const tooltipRect = tooltipRef.current.getBoundingClientRect();
27020
+ const viewportWidth = window.innerWidth;
27021
+ let top = rect.top + window.scrollY - tooltipRect.height - 8;
27022
+ let left = rect.left + window.scrollX;
27023
+ if (!mirror) {
27024
+ left = rect.left + rect.width / 2 - tooltipRect.width / 2 + window.scrollX;
27025
+ } else {
27026
+ left = rect.right - tooltipRect.width + window.scrollX;
27027
+ }
27028
+ if (left + tooltipRect.width > viewportWidth) {
27029
+ left = viewportWidth - tooltipRect.width - 16;
27030
+ }
27031
+ if (left < 16) {
27032
+ left = 16;
27033
+ }
27034
+ if (top < window.scrollY + 16) {
27035
+ top = rect.bottom + window.scrollY + 8;
27036
+ }
27037
+ setTooltipPosition({ top, left });
27038
+ }
27039
+ };
27040
+ (0, import_react11.useEffect)(() => {
27041
+ if (isOpen) {
27042
+ const timer2 = setTimeout(() => {
27043
+ updatePosition();
27044
+ }, 0);
27045
+ window.addEventListener("resize", updatePosition, { passive: true });
27046
+ window.addEventListener("scroll", updatePosition, { passive: true });
27047
+ return () => {
27048
+ clearTimeout(timer2);
27049
+ window.removeEventListener("resize", updatePosition);
27050
+ window.removeEventListener("scroll", updatePosition);
27051
+ };
27052
+ }
27053
+ }, [isOpen]);
27054
+ if (!enabled) {
27055
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
27056
+ }
27057
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
27058
+ "div",
27059
+ {
27060
+ ref: triggerRef,
27061
+ style: {
27062
+ display: "inline-block",
27063
+ position: "relative",
27064
+ ...containerStyle
27065
+ },
27066
+ onMouseEnter: () => setIsOpen(true),
27067
+ onMouseLeave: () => setIsOpen(false),
27068
+ children: [
27069
+ children,
27070
+ isOpen && (0, import_react_dom2.createPortal)(
27071
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
27072
+ "div",
27073
+ {
27074
+ ref: tooltipRef,
27075
+ style: {
27076
+ visibility: tooltipPosition ? "visible" : "hidden",
27077
+ position: "absolute",
27078
+ top: `${tooltipPosition?.top ?? 0}px`,
27079
+ left: `${tooltipPosition?.left ?? 0}px`,
27080
+ backgroundColor: "#ffffff",
27081
+ color: "#212121",
27082
+ textAlign: "center",
27083
+ borderRadius: 5,
27084
+ zIndex: 100,
27085
+ padding: 10,
27086
+ fontFamily: theme?.fontFamily,
27087
+ fontWeight: 600,
27088
+ fontSize: "small",
27089
+ whiteSpace: "nowrap",
27090
+ borderWidth: 1,
27091
+ borderStyle: "solid",
27092
+ borderColor: "#e7e7e7",
27093
+ boxShadow: "0px 1px 8px rgba(0, 0, 0, 0.07)",
27094
+ ...textStyle
27095
+ },
27096
+ children: [
27097
+ text,
27098
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
27099
+ "div",
27100
+ {
27101
+ style: {
27102
+ position: "absolute",
27103
+ top: "100%",
27104
+ left: "50%",
27105
+ marginLeft: -6,
27106
+ borderWidth: 6,
27107
+ borderStyle: "solid",
27108
+ borderColor: "transparent",
27109
+ borderTopColor: "#e7e7e7"
27110
+ }
27111
+ }
27112
+ ),
27113
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
27114
+ "div",
27115
+ {
27116
+ style: {
27117
+ position: "absolute",
27118
+ top: "100%",
27119
+ left: "50%",
27120
+ marginLeft: -5,
27121
+ borderWidth: 5,
27122
+ borderStyle: "solid",
27123
+ borderColor: "transparent",
27124
+ borderTopColor: "#ffffff"
27125
+ }
27126
+ }
27127
+ )
27128
+ ]
27129
+ }
27130
+ ),
27131
+ document.body
27132
+ )
27133
+ ]
27134
+ }
27135
+ );
27136
+ };
26322
27137
  var QuillChartBuilderCheckboxComponent = ({
26323
27138
  isChecked,
26324
27139
  label,
@@ -29371,7 +30186,7 @@ function QuillMultiSelectComponentWithCombo({
29371
30186
  );
29372
30187
  const potentialOptions = (0, import_react20.useMemo)(() => {
29373
30188
  return value.filter((opt) => !optionValues.has(opt ?? "")).map((opt) => ({
29374
- label: opt === "" ? "-" : opt ?? "-",
30189
+ label: opt === "" ? "-" : opt?.toString() ?? "-",
29375
30190
  value: opt ?? ""
29376
30191
  })).concat(options);
29377
30192
  }, [value, options]);
@@ -29388,7 +30203,9 @@ function QuillMultiSelectComponentWithCombo({
29388
30203
  if (matchingOptions.length === options.length && allSelectedLabel) {
29389
30204
  return allSelectedLabel;
29390
30205
  }
29391
- return matchingOptions.map((elem) => elem.label ?? "-").join(", ");
30206
+ return matchingOptions.map(
30207
+ (elem) => elem.label ?? "-"
30208
+ ).join(", ");
29392
30209
  }, [options, value]);
29393
30210
  const [selectAllCheckboxState, setSelectAllCheckboxState] = (0, import_react20.useState)(
29394
30211
  (() => {
@@ -30114,7 +30931,7 @@ function QuillSelectComponentWithCombo({
30114
30931
  textOverflow: "ellipsis",
30115
30932
  whiteSpace: "nowrap",
30116
30933
  overflow: "hidden",
30117
- fontWeight: value?.length || isLoading ? void 0 : 300
30934
+ fontWeight: value?.toString()?.length || isLoading ? void 0 : 300
30118
30935
  },
30119
30936
  children: selectedLabel
30120
30937
  }
@@ -30456,6 +31273,51 @@ function DashboardFilter2({
30456
31273
  ]
30457
31274
  }
30458
31275
  ) });
31276
+ } else if (filter.filterType === "tenant") {
31277
+ if (filter.multiSelect) {
31278
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
31279
+ QuillMultiSelectComponentWithCombo,
31280
+ {
31281
+ label: filter.label,
31282
+ value: filter.values ?? [],
31283
+ onChange: (e) => {
31284
+ if (Array.isArray(e.target.value) && e.target.value.length === 0) {
31285
+ onChangeFilter(filter, void 0);
31286
+ return;
31287
+ }
31288
+ onChangeFilter(filter, e.target.value);
31289
+ },
31290
+ options: [
31291
+ ...filter.options ? filter.options.map((elem) => ({
31292
+ label: elem.label,
31293
+ value: elem.value
31294
+ })) : []
31295
+ ],
31296
+ width: 200,
31297
+ isLoading,
31298
+ disabled
31299
+ }
31300
+ ) });
31301
+ }
31302
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
31303
+ QuillSelectComponentWithCombo,
31304
+ {
31305
+ label: filter.label,
31306
+ value: filter.values?.[0] ?? "",
31307
+ onChange: (e) => {
31308
+ onChangeFilter(filter, e.target.value);
31309
+ },
31310
+ options: [
31311
+ ...filter.options ? filter.options.map((elem) => ({
31312
+ label: elem.label,
31313
+ value: elem.value
31314
+ })) : []
31315
+ ],
31316
+ width: 200,
31317
+ isLoading,
31318
+ disabled
31319
+ }
31320
+ ) });
30459
31321
  }
30460
31322
  return null;
30461
31323
  }
@@ -33940,11 +34802,13 @@ function Chart({
33940
34802
  (0, import_react29.useEffect)(() => {
33941
34803
  setFilterValues(
33942
34804
  Object.values(reportFilters[reportId] ?? {}).reduce((acc, f) => {
33943
- acc[f.filter.label] = f.filter.filterType === "string" ? f.filter.stringFilterType === "multiselect" ? { values: f.filter.values, operator: "IN" } : { selectedValue: f.filter.selectedValue } : {
34805
+ acc[f.filter.label] = f.filter.filterType === "string" ? f.filter.stringFilterType === "multiselect" ? { values: f.filter.values, operator: "IN" } : { selectedValue: f.filter.selectedValue } : f.filter.filterType === "date_range" ? {
33944
34806
  startDate: f.filter.startDate,
33945
34807
  endDate: f.filter.endDate,
33946
34808
  preset: f.filter.preset,
33947
34809
  comparisonRange: f.filter.comparisonRange
34810
+ } : {
34811
+ values: f.filter.values
33948
34812
  };
33949
34813
  return acc;
33950
34814
  }, {})
@@ -34068,6 +34932,10 @@ function Chart({
34068
34932
  }
34069
34933
  };
34070
34934
  }
34935
+ } else if (filter.filterType === "tenant" /* Tenant */) {
34936
+ filterValue = {
34937
+ values: value ? Array.isArray(value) ? value : [value] : []
34938
+ };
34071
34939
  }
34072
34940
  setFilterValues((filterValues2) => ({
34073
34941
  ...filterValues2,
@@ -36714,11 +37582,13 @@ function Dashboard({
36714
37582
  (0, import_react37.useEffect)(() => {
36715
37583
  setFilterValues(
36716
37584
  Object.values(populatedDashboardFilters ?? {}).reduce((acc, f) => {
36717
- acc[f.label] = f.filterType === "string" ? f.stringFilterType === "multiselect" ? { values: f.values, operator: "IN" } : { selectedValue: f.selectedValue } : {
37585
+ acc[f.label] = f.filterType === "string" ? f.stringFilterType === "multiselect" ? { values: f.values, operator: "IN" } : { selectedValue: f.selectedValue } : f.filterType === "date_range" ? {
36718
37586
  startDate: f.startDate,
36719
37587
  endDate: f.endDate,
36720
37588
  preset: f.preset,
36721
37589
  comparisonRange: f.comparisonRange
37590
+ } : {
37591
+ values: f.values
36722
37592
  };
36723
37593
  return acc;
36724
37594
  }, {})
@@ -36863,6 +37733,10 @@ function Dashboard({
36863
37733
  }
36864
37734
  };
36865
37735
  }
37736
+ } else if (filter.filterType === "tenant" /* Tenant */) {
37737
+ filterValue = {
37738
+ values: value ? Array.isArray(value) ? value : [value] : []
37739
+ };
36866
37740
  }
36867
37741
  setFilterValues((filterValues2) => ({
36868
37742
  ...filterValues2,
@@ -40234,6 +41108,10 @@ function InternalChart({
40234
41108
  }
40235
41109
  };
40236
41110
  }
41111
+ } else if (filter.filterType === "tenant" /* Tenant */) {
41112
+ filterValue = {
41113
+ values: value ? Array.isArray(value) ? value : [value] : []
41114
+ };
40237
41115
  }
40238
41116
  setFilterValues((filterValues2) => ({
40239
41117
  ...filterValues2,
@@ -41055,6 +41933,7 @@ var ListboxTextInput2 = ({
41055
41933
  };
41056
41934
 
41057
41935
  // src/ChartBuilder.tsx
41936
+ var import_pluralize = __toESM(require_pluralize(), 1);
41058
41937
  var import_jsx_runtime65 = require("react/jsx-runtime");
41059
41938
  var CHART_TYPES = [
41060
41939
  "column",
@@ -41501,7 +42380,7 @@ function ChartBuilder({
41501
42380
  const validFilter = (0, import_react43.useMemo)(() => {
41502
42381
  return specificDashboardFilters.reduce(
41503
42382
  (acc, filter) => {
41504
- if (filter.filterType === "date_range") {
42383
+ if (filter.filterType === "date_range" || filter.filterType === "tenant") {
41505
42384
  acc[filter.label] = true;
41506
42385
  return acc;
41507
42386
  }
@@ -42644,6 +43523,30 @@ function ChartBuilder({
42644
43523
  setIsSubmitting(false);
42645
43524
  setTriggeredEditChart(false);
42646
43525
  };
43526
+ const memoizedTooltipText = (0, import_react43.useMemo)(() => {
43527
+ const getTooltipText = () => {
43528
+ if (formData.name === "") {
43529
+ return "Please enter a name for the chart";
43530
+ }
43531
+ if (formData.dashboardName === "") {
43532
+ return "Please select a dashboard";
43533
+ }
43534
+ if (formData.chartType === "") {
43535
+ return "Please select a chart type";
43536
+ }
43537
+ if (filterIssues.length !== 0) {
43538
+ return "Please fix the filter issues";
43539
+ }
43540
+ if (Object.values(validFilter).includes(false)) {
43541
+ return "Please fix the filter issues";
43542
+ }
43543
+ if (currentDashboard?.tenantKeys && customTenantAccess && Object.values(formFlags ?? {}).every((value) => !value.length)) {
43544
+ return "Please fix the tenant issues";
43545
+ }
43546
+ return "";
43547
+ };
43548
+ return getTooltipText();
43549
+ }, [formData, filterIssues, validFilter, formFlags, currentDashboard]);
42647
43550
  isHorizontalView = windowWidth < 1200 ? false : isHorizontalView;
42648
43551
  if (!schemaData.schema) {
42649
43552
  return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { children: "No schema" });
@@ -43733,7 +44636,7 @@ function ChartBuilder({
43733
44636
  })) ?? [],
43734
44637
  width: 200,
43735
44638
  emptyLabel: dashboardOwner.scope === "database" ? "No tags supplied" : void 0,
43736
- allSelectedLabel: "All " + dashboardOwner.name + "s",
44639
+ allSelectedLabel: "All " + (0, import_pluralize.default)(dashboardOwner.name),
43737
44640
  style: {
43738
44641
  display: customTenantAccess || containsCustomFields ? "inline" : "none",
43739
44642
  marginTop: -1,
@@ -43758,7 +44661,7 @@ function ChartBuilder({
43758
44661
  {}
43759
44662
  ) ?? {},
43760
44663
  width: 200,
43761
- allSelectedLabel: "All " + dashboardOwner.name + "s",
44664
+ allSelectedLabel: "All " + (0, import_pluralize.default)(dashboardOwner.name),
43762
44665
  style: {
43763
44666
  display: customTenantAccess || containsCustomFields ? "inline" : "none",
43764
44667
  marginTop: -1,
@@ -43863,7 +44766,7 @@ function ChartBuilder({
43863
44766
  gap: 6
43864
44767
  },
43865
44768
  children: specificDashboardFilters.filter((f) => {
43866
- return f.filterType !== "date_range";
44769
+ return f.filterType === "string";
43867
44770
  }).map((filter, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(ChartBuilderInputRowContainer, { children: [
43868
44771
  /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
43869
44772
  TextInputComponent,
@@ -44041,6 +44944,7 @@ function ChartBuilder({
44041
44944
  disabled: formData.name === "" || formData.dashboardName === "" || formData.chartType === "" || filterIssues.length !== 0 || Object.values(validFilter).includes(false) || currentDashboard?.tenantKeys && customTenantAccess && Object.values(formFlags ?? {}).every(
44042
44945
  (value) => !value.length
44043
44946
  ),
44947
+ tooltipText: memoizedTooltipText,
44044
44948
  label: buttonLabel ? buttonLabel : report ? "Save changes" : "Add to dashboard"
44045
44949
  }
44046
44950
  )
@@ -50009,7 +50913,8 @@ var SaveReport = ({
50009
50913
  reportBuilder,
50010
50914
  setIsOpen
50011
50915
  }
50012
- )
50916
+ ),
50917
+ submitButtonLabel
50013
50918
  }) => {
50014
50919
  return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { children: [
50015
50920
  SaveTrigger,
@@ -50052,7 +50957,7 @@ var SaveReport = ({
50052
50957
  FormContainer: ChartBuilderFormContainer,
50053
50958
  hideDateRangeFilter: true,
50054
50959
  hideDeleteButton: true,
50055
- buttonLabel: !!reportBuilder.reportId ? "Save changes" : "Add to dashboard",
50960
+ buttonLabel: submitButtonLabel ?? (!!reportBuilder.reportId ? "Save changes" : "Add to dashboard"),
50056
50961
  onClickChartElement,
50057
50962
  isEditingMode: true
50058
50963
  }
@@ -50151,7 +51056,8 @@ function ReportBuilder({
50151
51056
  hideCopySQL = true,
50152
51057
  isChartBuilderHorizontalView = true,
50153
51058
  onClickChartElement,
50154
- onRequestAddVirtualTable
51059
+ onRequestAddVirtualTable,
51060
+ submitButtonLabel
50155
51061
  }) {
50156
51062
  const [theme] = (0, import_react53.useContext)(ThemeContext);
50157
51063
  const parentRef = (0, import_react53.useRef)(null);
@@ -50539,7 +51445,7 @@ function ReportBuilder({
50539
51445
  setIsChartBuilderOpen(true);
50540
51446
  },
50541
51447
  disabled: !!errorMessage || !!pivotError || tableLoading || loading || !!unresolvedReportMessage,
50542
- label: reportId ? "Save changes" : "Add to dashboard",
51448
+ label: submitButtonLabel ?? (reportId ? "Save changes" : "Add to dashboard"),
50543
51449
  tooltipText: unresolvedReportMessage
50544
51450
  }
50545
51451
  )
@@ -50585,7 +51491,8 @@ function ReportBuilder({
50585
51491
  ErrorMessageComponent,
50586
51492
  PivotRowContainer,
50587
51493
  PivotColumnContainer,
50588
- onClickChartElement
51494
+ onClickChartElement,
51495
+ submitButtonLabel
50589
51496
  }
50590
51497
  ),
50591
51498
  isSaveQueryModalOpen && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
@@ -50862,31 +51769,69 @@ function StaticChart({
50862
51769
  );
50863
51770
  }
50864
51771
 
50865
- // src/hooks/useQuill.ts
51772
+ // src/hooks/useTenants.ts
50866
51773
  var import_react55 = require("react");
51774
+ var useTenants = (dashboardName) => {
51775
+ const {
51776
+ tenants,
51777
+ flags,
51778
+ childTenantMappings,
51779
+ viewerTenants,
51780
+ isLoadingMappedTenants,
51781
+ isLoadingViewerTenants,
51782
+ fetchViewerTenantsForDashboard,
51783
+ fetchMappedTenantsForDashboard,
51784
+ getMappedTenantsForDashboard,
51785
+ getViewerTenantsByOwner
51786
+ } = (0, import_react55.useContext)(TenantContext);
51787
+ (0, import_react55.useEffect)(() => {
51788
+ if (dashboardName) {
51789
+ fetchViewerTenantsForDashboard(dashboardName);
51790
+ }
51791
+ }, [dashboardName, fetchViewerTenantsForDashboard]);
51792
+ (0, import_react55.useEffect)(() => {
51793
+ if (dashboardName) {
51794
+ fetchMappedTenantsForDashboard(dashboardName);
51795
+ }
51796
+ }, [dashboardName, fetchMappedTenantsForDashboard]);
51797
+ return {
51798
+ tenants,
51799
+ flags,
51800
+ childTenantMappings: dashboardName ? childTenantMappings[dashboardName] || {} : {},
51801
+ mappedTenants: dashboardName ? childTenantMappings[dashboardName] || {} : {},
51802
+ viewerTenants: dashboardName ? viewerTenants[dashboardName] || [] : [],
51803
+ isLoadingMappedTenants,
51804
+ isLoadingViewerTenants,
51805
+ getMappedTenantsForDashboard,
51806
+ getViewerTenantsByOwner
51807
+ };
51808
+ };
51809
+
51810
+ // src/hooks/useQuill.ts
51811
+ var import_react56 = require("react");
50867
51812
  var useQuill = (reportId, pagination) => {
50868
- const { reports, reportsDispatch, fetchIndividualReport } = (0, import_react55.useContext)(ReportsContext);
51813
+ const { reports, reportsDispatch, fetchIndividualReport } = (0, import_react56.useContext)(ReportsContext);
50869
51814
  const { allReportsById } = useAllReports();
50870
- const { getToken } = (0, import_react55.useContext)(FetchContext);
50871
- const dashboardReport = (0, import_react55.useMemo)(() => {
51815
+ const { getToken } = (0, import_react56.useContext)(FetchContext);
51816
+ const dashboardReport = (0, import_react56.useMemo)(() => {
50872
51817
  return allReportsById[reportId ?? ""];
50873
51818
  }, [allReportsById[reportId ?? ""]]);
50874
- const { dashboardFilters, dashboardCustomFilters } = (0, import_react55.useContext)(
51819
+ const { dashboardFilters, dashboardCustomFilters } = (0, import_react56.useContext)(
50875
51820
  DashboardFiltersContext
50876
51821
  );
50877
- const { reportFilters, customReportFilters, reportFiltersDispatch } = (0, import_react55.useContext)(ReportFiltersContext);
50878
- const specificReportFilters = (0, import_react55.useMemo)(() => {
51822
+ const { reportFilters, customReportFilters, reportFiltersDispatch } = (0, import_react56.useContext)(ReportFiltersContext);
51823
+ const specificReportFilters = (0, import_react56.useMemo)(() => {
50879
51824
  if (!reportId) return null;
50880
51825
  return Object.values(reportFilters[reportId] ?? []).map((f) => f.filter);
50881
51826
  }, [reportFilters, reportId]);
50882
- const [schemaData] = (0, import_react55.useContext)(SchemaDataContext);
50883
- const [client, isClientLoading] = (0, import_react55.useContext)(ClientContext);
50884
- const { tenants } = (0, import_react55.useContext)(TenantContext);
50885
- const { eventTracking } = (0, import_react55.useContext)(EventTrackingContext);
50886
- const [loading, setLoading] = (0, import_react55.useState)(true);
50887
- const [error, setError] = (0, import_react55.useState)(void 0);
50888
- const [previousPage, setPreviousPage] = (0, import_react55.useState)(0);
50889
- const processedReport = (0, import_react55.useMemo)(() => {
51827
+ const [schemaData] = (0, import_react56.useContext)(SchemaDataContext);
51828
+ const [client, isClientLoading] = (0, import_react56.useContext)(ClientContext);
51829
+ const { tenants } = (0, import_react56.useContext)(TenantContext);
51830
+ const { eventTracking } = (0, import_react56.useContext)(EventTrackingContext);
51831
+ const [loading, setLoading] = (0, import_react56.useState)(true);
51832
+ const [error, setError] = (0, import_react56.useState)(void 0);
51833
+ const [previousPage, setPreviousPage] = (0, import_react56.useState)(0);
51834
+ const processedReport = (0, import_react56.useMemo)(() => {
50890
51835
  return reportId && allReportsById[reportId] ? convertInternalReportToReport(
50891
51836
  mergeComparisonRange(allReportsById[reportId]),
50892
51837
  specificReportFilters ?? [],
@@ -50894,7 +51839,7 @@ var useQuill = (reportId, pagination) => {
50894
51839
  "useQuill"
50895
51840
  ) : void 0;
50896
51841
  }, [reportId, reportId && allReportsById[reportId], specificReportFilters]);
50897
- const [additionalProcessing, setAdditionProcessing] = (0, import_react55.useState)(
51842
+ const [additionalProcessing, setAdditionProcessing] = (0, import_react56.useState)(
50898
51843
  pagination ? {
50899
51844
  page: pagination
50900
51845
  } : void 0
@@ -51043,7 +51988,7 @@ var useQuill = (reportId, pagination) => {
51043
51988
  setLoading(false);
51044
51989
  }
51045
51990
  };
51046
- (0, import_react55.useEffect)(() => {
51991
+ (0, import_react56.useEffect)(() => {
51047
51992
  if (isClientLoading) return;
51048
51993
  if (reportId && specificReportFilters) {
51049
51994
  fetchReportHelper(reportId, {
@@ -51082,10 +52027,10 @@ var useQuill = (reportId, pagination) => {
51082
52027
  };
51083
52028
 
51084
52029
  // src/hooks/useFormat.ts
51085
- var import_react56 = require("react");
52030
+ var import_react57 = require("react");
51086
52031
  var useMemoizedRows = (reportId) => {
51087
52032
  const { data } = useQuill(reportId);
51088
- const formattedRows = (0, import_react56.useMemo)(() => {
52033
+ const formattedRows = (0, import_react57.useMemo)(() => {
51089
52034
  if (!data || !data.rows || !data.columns)
51090
52035
  return { rows: [], loading: true };
51091
52036
  return {
@@ -51109,7 +52054,7 @@ var useMemoizedRows = (reportId) => {
51109
52054
  };
51110
52055
 
51111
52056
  // src/hooks/useAskQuill.tsx
51112
- var import_react57 = require("react");
52057
+ var import_react58 = require("react");
51113
52058
  function convertColumnInternalToAskQuillColumn(columns) {
51114
52059
  return columns.map((column) => {
51115
52060
  let convertedFieldType = FieldType.String;
@@ -51133,13 +52078,13 @@ function convertColumnInternalToAskQuillColumn(columns) {
51133
52078
  });
51134
52079
  }
51135
52080
  var useAskQuill = (dashboardName) => {
51136
- const [client] = (0, import_react57.useContext)(ClientContext);
51137
- const [schemaData] = (0, import_react57.useContext)(SchemaDataContext);
51138
- const { tenants } = (0, import_react57.useContext)(TenantContext);
51139
- const { getToken } = (0, import_react57.useContext)(FetchContext);
51140
- const { eventTracking } = (0, import_react57.useContext)(EventTrackingContext);
51141
- const [astInfo, setAstInfo] = (0, import_react57.useState)(void 0);
51142
- const [data, setData] = (0, import_react57.useState)({
52081
+ const [client] = (0, import_react58.useContext)(ClientContext);
52082
+ const [schemaData] = (0, import_react58.useContext)(SchemaDataContext);
52083
+ const { tenants } = (0, import_react58.useContext)(TenantContext);
52084
+ const { getToken } = (0, import_react58.useContext)(FetchContext);
52085
+ const { eventTracking } = (0, import_react58.useContext)(EventTrackingContext);
52086
+ const [astInfo, setAstInfo] = (0, import_react58.useState)(void 0);
52087
+ const [data, setData] = (0, import_react58.useState)({
51143
52088
  rows: [],
51144
52089
  columns: [],
51145
52090
  pivot: null,
@@ -51149,9 +52094,9 @@ var useAskQuill = (dashboardName) => {
51149
52094
  pivotColumnFields: [],
51150
52095
  pivotValueFields: []
51151
52096
  });
51152
- const [loading, setLoading] = (0, import_react57.useState)(false);
51153
- const [error, setError] = (0, import_react57.useState)(void 0);
51154
- const [ask, setAsk] = (0, import_react57.useState)(
52097
+ const [loading, setLoading] = (0, import_react58.useState)(false);
52098
+ const [error, setError] = (0, import_react58.useState)(void 0);
52099
+ const [ask, setAsk] = (0, import_react58.useState)(
51155
52100
  async () => void 0
51156
52101
  );
51157
52102
  const askHelper = async (query) => {
@@ -51351,7 +52296,7 @@ var useAskQuill = (dashboardName) => {
51351
52296
  });
51352
52297
  setLoading(false);
51353
52298
  };
51354
- (0, import_react57.useEffect)(() => {
52299
+ (0, import_react58.useEffect)(() => {
51355
52300
  setAsk(() => askHelper);
51356
52301
  }, [schemaData.schema]);
51357
52302
  return {
@@ -51365,13 +52310,13 @@ var useAskQuill = (dashboardName) => {
51365
52310
  };
51366
52311
 
51367
52312
  // src/hooks/useVirtualTables.tsx
51368
- var import_react58 = require("react");
52313
+ var import_react59 = require("react");
51369
52314
  var useVirtualTables = () => {
51370
- const [schemaData, setSchemaData] = (0, import_react58.useContext)(SchemaDataContext);
51371
- const { tenants } = (0, import_react58.useContext)(TenantContext);
51372
- const { getToken, quillFetchWithToken } = (0, import_react58.useContext)(FetchContext);
51373
- const { eventTracking } = (0, import_react58.useContext)(EventTrackingContext);
51374
- const [loadingTables, setLoadingTables] = (0, import_react58.useState)({});
52315
+ const [schemaData, setSchemaData] = (0, import_react59.useContext)(SchemaDataContext);
52316
+ const { tenants } = (0, import_react59.useContext)(TenantContext);
52317
+ const { getToken, quillFetchWithToken } = (0, import_react59.useContext)(FetchContext);
52318
+ const { eventTracking } = (0, import_react59.useContext)(EventTrackingContext);
52319
+ const [loadingTables, setLoadingTables] = (0, import_react59.useState)({});
51375
52320
  const handleReload = async (client, caller) => {
51376
52321
  setSchemaData({ ...schemaData, isSchemaLoading: true });
51377
52322
  setLoadingTables(
@@ -51540,5 +52485,6 @@ var useVirtualTables = () => {
51540
52485
  useQuill,
51541
52486
  useReportBuilder,
51542
52487
  useReports,
52488
+ useTenants,
51543
52489
  useVirtualTables
51544
52490
  });