@quillsql/react 2.16.48 → 2.16.49
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 +539 -557
- package/dist/index.d.cts +121 -161
- package/dist/index.d.ts +121 -161
- package/dist/index.js +513 -531
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -58633,23 +58633,23 @@ function ChartEditor({
|
|
|
58633
58633
|
}
|
|
58634
58634
|
|
|
58635
58635
|
// src/Chat.tsx
|
|
58636
|
-
import { useContext as useContext37, useEffect as useEffect32, useRef as
|
|
58636
|
+
import { useContext as useContext37, useEffect as useEffect32, useRef as useRef25, useState as useState42 } from "react";
|
|
58637
58637
|
|
|
58638
58638
|
// src/ChatChartCard.tsx
|
|
58639
|
-
import { useMemo as
|
|
58639
|
+
import { useMemo as useMemo33 } from "react";
|
|
58640
58640
|
|
|
58641
58641
|
// src/hooks/useForm.tsx
|
|
58642
58642
|
init_Filter();
|
|
58643
58643
|
init_ReportBuilder();
|
|
58644
58644
|
import {
|
|
58645
|
-
useCallback as
|
|
58645
|
+
useCallback as useCallback5,
|
|
58646
58646
|
useContext as useContext36,
|
|
58647
58647
|
useEffect as useEffect31,
|
|
58648
58648
|
useLayoutEffect as useLayoutEffect4,
|
|
58649
|
-
useMemo as
|
|
58649
|
+
useMemo as useMemo32,
|
|
58650
58650
|
useReducer as useReducer2,
|
|
58651
|
-
useRef as
|
|
58652
|
-
useState as
|
|
58651
|
+
useRef as useRef24,
|
|
58652
|
+
useState as useState41
|
|
58653
58653
|
} from "react";
|
|
58654
58654
|
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
|
58655
58655
|
init_util();
|
|
@@ -59657,171 +59657,6 @@ function countFilterRules(value) {
|
|
|
59657
59657
|
}, 0);
|
|
59658
59658
|
}
|
|
59659
59659
|
|
|
59660
|
-
// src/hooks/useReportFilterDraft.ts
|
|
59661
|
-
import { useCallback as useCallback5, useMemo as useMemo32, useRef as useRef24, useState as useState41 } from "react";
|
|
59662
|
-
var normalizeOperatorKey = (operator) => String(operator ?? "").trim().toLowerCase().replace(/[_\s]+/g, "");
|
|
59663
|
-
var defaultFilterRuleValueForOperator = (operator) => {
|
|
59664
|
-
const key = normalizeOperatorKey(operator);
|
|
59665
|
-
if (key === "in" || key === "notin") {
|
|
59666
|
-
return [];
|
|
59667
|
-
}
|
|
59668
|
-
return "";
|
|
59669
|
-
};
|
|
59670
|
-
var buildSeededFilterQuery = (queryBuilderProps) => {
|
|
59671
|
-
const fieldData = queryBuilderProps?.fields?.[0];
|
|
59672
|
-
const fieldName = String(fieldData?.name ?? "").trim();
|
|
59673
|
-
let operator = "in";
|
|
59674
|
-
const firstOperator = queryBuilderProps?.getOperators?.(fieldName, {
|
|
59675
|
-
fieldData
|
|
59676
|
-
})?.[0];
|
|
59677
|
-
if (firstOperator) {
|
|
59678
|
-
operator = String(firstOperator.name ?? firstOperator.value ?? "in");
|
|
59679
|
-
}
|
|
59680
|
-
return {
|
|
59681
|
-
combinator: "and",
|
|
59682
|
-
rules: [
|
|
59683
|
-
{
|
|
59684
|
-
field: fieldName,
|
|
59685
|
-
operator,
|
|
59686
|
-
value: defaultFilterRuleValueForOperator(operator)
|
|
59687
|
-
}
|
|
59688
|
-
]
|
|
59689
|
-
};
|
|
59690
|
-
};
|
|
59691
|
-
var EMPTY_COMMITTED_FILTERS = {
|
|
59692
|
-
combinator: "and",
|
|
59693
|
-
rules: []
|
|
59694
|
-
};
|
|
59695
|
-
var hashString2 = (input) => {
|
|
59696
|
-
let hash = 2166136261;
|
|
59697
|
-
for (let i = 0; i < input.length; i++) {
|
|
59698
|
-
hash ^= input.charCodeAt(i);
|
|
59699
|
-
hash = Math.imul(hash, 16777619);
|
|
59700
|
-
}
|
|
59701
|
-
return String(hash >>> 0);
|
|
59702
|
-
};
|
|
59703
|
-
var fieldCatalogSignature = (fields) => {
|
|
59704
|
-
const names = fields.map((field) => String(field.name ?? "").trim()).filter(Boolean).sort();
|
|
59705
|
-
return `${names.length}:${hashString2(names.join("\0"))}`;
|
|
59706
|
-
};
|
|
59707
|
-
var committedFiltersSignature = (committed) => {
|
|
59708
|
-
try {
|
|
59709
|
-
return hashString2(
|
|
59710
|
-
JSON.stringify(stripQueryBuilderTransientFields(committed))
|
|
59711
|
-
);
|
|
59712
|
-
} catch {
|
|
59713
|
-
return "unserializable";
|
|
59714
|
-
}
|
|
59715
|
-
};
|
|
59716
|
-
function useReportFilterDraft(args) {
|
|
59717
|
-
const { reportId, committedFilters, queryBuilderProps, setFilters } = args;
|
|
59718
|
-
const committed = isQueryBuilderDisplayGroup(committedFilters) ? committedFilters : EMPTY_COMMITTED_FILTERS;
|
|
59719
|
-
const committedRef = useRef24(committed);
|
|
59720
|
-
committedRef.current = committed;
|
|
59721
|
-
const setFiltersRef = useRef24(setFilters);
|
|
59722
|
-
setFiltersRef.current = setFilters;
|
|
59723
|
-
const lastNonEmptyFieldsRef = useRef24([]);
|
|
59724
|
-
const prevReportIdForFieldsRef = useRef24(reportId);
|
|
59725
|
-
if (prevReportIdForFieldsRef.current !== reportId) {
|
|
59726
|
-
prevReportIdForFieldsRef.current = reportId;
|
|
59727
|
-
lastNonEmptyFieldsRef.current = [];
|
|
59728
|
-
}
|
|
59729
|
-
if (queryBuilderProps.fields.length > 0) {
|
|
59730
|
-
lastNonEmptyFieldsRef.current = queryBuilderProps.fields;
|
|
59731
|
-
}
|
|
59732
|
-
const effectiveFields = queryBuilderProps.fields.length > 0 ? queryBuilderProps.fields : lastNonEmptyFieldsRef.current;
|
|
59733
|
-
const effectiveFieldsRef = useRef24(effectiveFields);
|
|
59734
|
-
effectiveFieldsRef.current = effectiveFields;
|
|
59735
|
-
const getOperatorsRef = useRef24(queryBuilderProps.getOperators);
|
|
59736
|
-
getOperatorsRef.current = queryBuilderProps.getOperators;
|
|
59737
|
-
const committedSignature = useMemo32(
|
|
59738
|
-
() => committedFiltersSignature(committed),
|
|
59739
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- `committed` normalizes null to a stable constant
|
|
59740
|
-
[committedFilters]
|
|
59741
|
-
);
|
|
59742
|
-
const fieldsSignature = useMemo32(
|
|
59743
|
-
() => fieldCatalogSignature(effectiveFields),
|
|
59744
|
-
[effectiveFields]
|
|
59745
|
-
);
|
|
59746
|
-
const [resetEpoch, setResetEpoch] = useState41(0);
|
|
59747
|
-
const [seedEpoch, setSeedEpoch] = useState41(0);
|
|
59748
|
-
const draftRef = useRef24(committed);
|
|
59749
|
-
const [isFilterDraftDirty, setIsFilterDraftDirty] = useState41(false);
|
|
59750
|
-
const [isFilterDraftEmpty, setIsFilterDraftEmpty] = useState41(
|
|
59751
|
-
committed.rules.length === 0
|
|
59752
|
-
);
|
|
59753
|
-
const draftResetKey = `${reportId}|${committedSignature}|${resetEpoch}`;
|
|
59754
|
-
const prevDraftResetKeyRef = useRef24(draftResetKey);
|
|
59755
|
-
if (prevDraftResetKeyRef.current !== draftResetKey) {
|
|
59756
|
-
prevDraftResetKeyRef.current = draftResetKey;
|
|
59757
|
-
draftRef.current = committed;
|
|
59758
|
-
const nextEmpty = committed.rules.length === 0;
|
|
59759
|
-
if (isFilterDraftDirty) setIsFilterDraftDirty(false);
|
|
59760
|
-
if (isFilterDraftEmpty !== nextEmpty) setIsFilterDraftEmpty(nextEmpty);
|
|
59761
|
-
}
|
|
59762
|
-
const filterDraftKey = `${draftResetKey}|${seedEpoch}|${fieldsSignature}`;
|
|
59763
|
-
const handleQueryChange = useCallback5((next) => {
|
|
59764
|
-
if (!isQueryBuilderDisplayGroup(next)) return;
|
|
59765
|
-
const nextGroup = next;
|
|
59766
|
-
draftRef.current = nextGroup;
|
|
59767
|
-
const nextDirty = areQueryBuilderFilterDraftsDirty(
|
|
59768
|
-
nextGroup,
|
|
59769
|
-
committedRef.current
|
|
59770
|
-
);
|
|
59771
|
-
const nextEmpty = nextGroup.rules.length === 0;
|
|
59772
|
-
setIsFilterDraftDirty((prev) => prev === nextDirty ? prev : nextDirty);
|
|
59773
|
-
setIsFilterDraftEmpty((prev) => prev === nextEmpty ? prev : nextEmpty);
|
|
59774
|
-
}, []);
|
|
59775
|
-
const commitFilterDraft = useCallback5(() => {
|
|
59776
|
-
setFiltersRef.current(draftRef.current);
|
|
59777
|
-
}, []);
|
|
59778
|
-
const resetFilterDraft = useCallback5(() => {
|
|
59779
|
-
draftRef.current = committedRef.current;
|
|
59780
|
-
setIsFilterDraftDirty(false);
|
|
59781
|
-
setIsFilterDraftEmpty(committedRef.current.rules.length === 0);
|
|
59782
|
-
setResetEpoch((epoch) => epoch + 1);
|
|
59783
|
-
}, []);
|
|
59784
|
-
const seedFilterDraft = useCallback5(() => {
|
|
59785
|
-
const seeded = buildSeededFilterQuery({
|
|
59786
|
-
fields: effectiveFieldsRef.current,
|
|
59787
|
-
getOperators: getOperatorsRef.current
|
|
59788
|
-
});
|
|
59789
|
-
draftRef.current = seeded;
|
|
59790
|
-
setIsFilterDraftDirty(
|
|
59791
|
-
areQueryBuilderFilterDraftsDirty(seeded, committedRef.current)
|
|
59792
|
-
);
|
|
59793
|
-
setIsFilterDraftEmpty(false);
|
|
59794
|
-
setSeedEpoch((epoch) => epoch + 1);
|
|
59795
|
-
}, []);
|
|
59796
|
-
const getDefaultValue = useCallback5(
|
|
59797
|
-
(rule) => defaultFilterRuleValueForOperator(rule?.operator),
|
|
59798
|
-
[]
|
|
59799
|
-
);
|
|
59800
|
-
const filterDraftQueryBuilderProps = useMemo32(
|
|
59801
|
-
() => ({
|
|
59802
|
-
...queryBuilderProps,
|
|
59803
|
-
fields: effectiveFields,
|
|
59804
|
-
// Uncontrolled: react-querybuilder owns the draft; only read at mount,
|
|
59805
|
-
// so passing the live draft means popover/remount cycles keep edits.
|
|
59806
|
-
defaultQuery: draftRef.current,
|
|
59807
|
-
onQueryChange: handleQueryChange,
|
|
59808
|
-
addRuleToNewGroups: true,
|
|
59809
|
-
getDefaultValue
|
|
59810
|
-
}),
|
|
59811
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- filterDraftKey covers draftRef resets
|
|
59812
|
-
[queryBuilderProps, effectiveFields, handleQueryChange, getDefaultValue, filterDraftKey]
|
|
59813
|
-
);
|
|
59814
|
-
return {
|
|
59815
|
-
filterDraftKey,
|
|
59816
|
-
filterDraftQueryBuilderProps,
|
|
59817
|
-
isFilterDraftDirty,
|
|
59818
|
-
isFilterDraftEmpty,
|
|
59819
|
-
commitFilterDraft,
|
|
59820
|
-
resetFilterDraft,
|
|
59821
|
-
seedFilterDraft
|
|
59822
|
-
};
|
|
59823
|
-
}
|
|
59824
|
-
|
|
59825
59660
|
// src/hooks/useFormRefreshDecision.ts
|
|
59826
59661
|
var normalize = (value) => String(value ?? "").trim();
|
|
59827
59662
|
var toColumnKey = (table, field) => `${table}::${field}`;
|
|
@@ -60079,6 +59914,13 @@ var AGGREGATION_OPTION_TYPES = [
|
|
|
60079
59914
|
var QUERY_BUILDER_MULTI_VALUE_OPERATORS = /* @__PURE__ */ new Set(["in", "notin"]);
|
|
60080
59915
|
var TABLE_FORMAT_CACHE_MAX_ENTRIES = 5e3;
|
|
60081
59916
|
var PIVOT_DATE_BUCKET_FORMAT_OPTIONS = ["date"];
|
|
59917
|
+
var PIVOT_DATE_BUCKET_OPTIONS = [
|
|
59918
|
+
{ label: "Automatic", value: "" },
|
|
59919
|
+
{ label: "Daily", value: "day" },
|
|
59920
|
+
{ label: "Weekly", value: "week" },
|
|
59921
|
+
{ label: "Monthly", value: "month" },
|
|
59922
|
+
{ label: "Yearly", value: "year" }
|
|
59923
|
+
];
|
|
60082
59924
|
var AXIS_FORMAT_OPTIONS = [
|
|
60083
59925
|
{ value: "string", label: "string" },
|
|
60084
59926
|
{ value: "whole_number", label: "whole number" },
|
|
@@ -60141,6 +59983,10 @@ var logUseFormPivotShapeDebug = (label, payload) => {
|
|
|
60141
59983
|
if (!isUseFormPivotShapeDebugEnabled()) return;
|
|
60142
59984
|
console.log(`[useReport][pivot-shape] ${label}`, payload);
|
|
60143
59985
|
};
|
|
59986
|
+
var BOOLEAN_FILTER_VALUE_OPTIONS = [
|
|
59987
|
+
{ name: "true", label: "True", value: "true" },
|
|
59988
|
+
{ name: "false", label: "False", value: "false" }
|
|
59989
|
+
];
|
|
60144
59990
|
function canonicalTablesForFilterUniqueValuesQueryKey(tables) {
|
|
60145
59991
|
return (tables ?? []).map((table) => {
|
|
60146
59992
|
const name2 = String(table?.name ?? "").trim();
|
|
@@ -62283,9 +62129,6 @@ function getChartTypeOptions2(formData) {
|
|
|
62283
62129
|
(elem) => !(formData.pivot && formData.pivot.columnField && (elem === "bar" || elem === "pie" || elem === "US map" || elem === "World map"))
|
|
62284
62130
|
).map((elem) => ({ label: elem, value: elem }));
|
|
62285
62131
|
}
|
|
62286
|
-
function isSetReportTableColumnSidebarPatch(columns) {
|
|
62287
|
-
return Boolean(columns) && typeof columns === "object" && !Array.isArray(columns) && "patch" in columns && typeof columns.patch === "object" && columns.patch !== null && typeof columns.patch.id === "string";
|
|
62288
|
-
}
|
|
62289
62132
|
function processPivotState(next, options = {}) {
|
|
62290
62133
|
const {
|
|
62291
62134
|
nextState,
|
|
@@ -62342,7 +62185,10 @@ function processPivotState(next, options = {}) {
|
|
|
62342
62185
|
}
|
|
62343
62186
|
const valueField = String(aggregation.valueField ?? "").trim();
|
|
62344
62187
|
if (!valueField) {
|
|
62345
|
-
return {
|
|
62188
|
+
return {
|
|
62189
|
+
...aggregation,
|
|
62190
|
+
aggregationType: "count"
|
|
62191
|
+
};
|
|
62346
62192
|
}
|
|
62347
62193
|
const valueField2 = String(aggregation.valueField2 ?? "").trim();
|
|
62348
62194
|
if (valueField2 && valueField2 !== valueField) {
|
|
@@ -63354,10 +63200,10 @@ function generateDraftSessionId() {
|
|
|
63354
63200
|
}
|
|
63355
63201
|
function useReport(reportIdArg, options = {}) {
|
|
63356
63202
|
const propReportId = String(reportIdArg ?? "").trim();
|
|
63357
|
-
const [createdReportId, setCreatedReportId] =
|
|
63203
|
+
const [createdReportId, setCreatedReportId] = useState41(null);
|
|
63358
63204
|
const effectiveReportId = propReportId || createdReportId || "";
|
|
63359
63205
|
const { eventTracking } = useContext36(EventTrackingContext);
|
|
63360
|
-
const [draftSessionId, setDraftSessionId] =
|
|
63206
|
+
const [draftSessionId, setDraftSessionId] = useState41(generateDraftSessionId);
|
|
63361
63207
|
const useInMemoryEngines = options.useInMemoryEngines ?? false;
|
|
63362
63208
|
const restrictFieldOptionsToSelectedDatasources = options.restrictFieldOptionsToSelectedDatasources ?? true;
|
|
63363
63209
|
const reportOverride = options.reportOverride ?? null;
|
|
@@ -63366,30 +63212,30 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63366
63212
|
options.destinationDashboardName ?? ""
|
|
63367
63213
|
).trim();
|
|
63368
63214
|
const controlledPagination = options.state?.pagination;
|
|
63369
|
-
const initialPaginationRef =
|
|
63215
|
+
const initialPaginationRef = useRef24({
|
|
63370
63216
|
...getDefaultPaginationState(),
|
|
63371
63217
|
...options.initialState?.pagination ?? {}
|
|
63372
63218
|
});
|
|
63373
|
-
const [internalPagination, setInternalPagination] =
|
|
63219
|
+
const [internalPagination, setInternalPagination] = useState41(
|
|
63374
63220
|
initialPaginationRef.current
|
|
63375
63221
|
);
|
|
63376
|
-
const [paginationInteracted, setPaginationInteracted] =
|
|
63222
|
+
const [paginationInteracted, setPaginationInteracted] = useState41(
|
|
63377
63223
|
() => Boolean(
|
|
63378
63224
|
options.state?.pagination || options.initialState?.pagination || options.onPaginationChange
|
|
63379
63225
|
)
|
|
63380
63226
|
);
|
|
63381
63227
|
const pagination = controlledPagination ?? internalPagination;
|
|
63382
63228
|
const paginationActive = paginationInteracted || Boolean(controlledPagination);
|
|
63383
|
-
const paginationRef =
|
|
63229
|
+
const paginationRef = useRef24(pagination);
|
|
63384
63230
|
paginationRef.current = pagination;
|
|
63385
|
-
const onPaginationChangeRef =
|
|
63231
|
+
const onPaginationChangeRef = useRef24(options.onPaginationChange);
|
|
63386
63232
|
onPaginationChangeRef.current = options.onPaginationChange;
|
|
63387
|
-
const controlledPaginationRef =
|
|
63233
|
+
const controlledPaginationRef = useRef24(Boolean(controlledPagination));
|
|
63388
63234
|
controlledPaginationRef.current = Boolean(controlledPagination);
|
|
63389
|
-
const autoResetPageIndexRef =
|
|
63235
|
+
const autoResetPageIndexRef = useRef24(true);
|
|
63390
63236
|
autoResetPageIndexRef.current = options.autoResetPageIndex ?? true;
|
|
63391
|
-
const paginationPageCountRef =
|
|
63392
|
-
const applyPaginationUpdate =
|
|
63237
|
+
const paginationPageCountRef = useRef24(-1);
|
|
63238
|
+
const applyPaginationUpdate = useCallback5(
|
|
63393
63239
|
(updater, { activate = true } = {}) => {
|
|
63394
63240
|
if (activate) {
|
|
63395
63241
|
setPaginationInteracted(true);
|
|
@@ -63401,11 +63247,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63401
63247
|
},
|
|
63402
63248
|
[]
|
|
63403
63249
|
);
|
|
63404
|
-
const setPagination =
|
|
63250
|
+
const setPagination = useCallback5(
|
|
63405
63251
|
(updater) => applyPaginationUpdate(updater),
|
|
63406
63252
|
[applyPaginationUpdate]
|
|
63407
63253
|
);
|
|
63408
|
-
const setPageIndex =
|
|
63254
|
+
const setPageIndex = useCallback5(
|
|
63409
63255
|
(updater) => applyPaginationUpdate((old) => ({
|
|
63410
63256
|
...old,
|
|
63411
63257
|
pageIndex: clampPageIndex(
|
|
@@ -63415,7 +63261,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63415
63261
|
})),
|
|
63416
63262
|
[applyPaginationUpdate]
|
|
63417
63263
|
);
|
|
63418
|
-
const setPageSize =
|
|
63264
|
+
const setPageSize = useCallback5(
|
|
63419
63265
|
(updater) => applyPaginationUpdate(
|
|
63420
63266
|
(old) => paginationStateAfterPageSizeChange(
|
|
63421
63267
|
old,
|
|
@@ -63424,62 +63270,64 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63424
63270
|
),
|
|
63425
63271
|
[applyPaginationUpdate]
|
|
63426
63272
|
);
|
|
63427
|
-
const resetPagination =
|
|
63273
|
+
const resetPagination = useCallback5(
|
|
63428
63274
|
(defaultState) => applyPaginationUpdate(
|
|
63429
63275
|
defaultState ? getDefaultPaginationState() : initialPaginationRef.current
|
|
63430
63276
|
),
|
|
63431
63277
|
[applyPaginationUpdate]
|
|
63432
63278
|
);
|
|
63433
|
-
const resetPageIndex =
|
|
63279
|
+
const resetPageIndex = useCallback5(
|
|
63434
63280
|
(defaultState) => {
|
|
63435
63281
|
const target = defaultState ? 0 : initialPaginationRef.current.pageIndex;
|
|
63436
63282
|
setPageIndex(target);
|
|
63437
63283
|
},
|
|
63438
63284
|
[setPageIndex]
|
|
63439
63285
|
);
|
|
63440
|
-
const resetPageSize =
|
|
63286
|
+
const resetPageSize = useCallback5(
|
|
63441
63287
|
(defaultState) => {
|
|
63442
63288
|
const target = defaultState ? getDefaultPaginationState().pageSize : initialPaginationRef.current.pageSize;
|
|
63443
63289
|
setPageSize(target);
|
|
63444
63290
|
},
|
|
63445
63291
|
[setPageSize]
|
|
63446
63292
|
);
|
|
63447
|
-
const nextPage =
|
|
63293
|
+
const nextPage = useCallback5(
|
|
63448
63294
|
() => setPageIndex((old) => old + 1),
|
|
63449
63295
|
[setPageIndex]
|
|
63450
63296
|
);
|
|
63451
|
-
const previousPage =
|
|
63297
|
+
const previousPage = useCallback5(
|
|
63452
63298
|
() => setPageIndex((old) => old - 1),
|
|
63453
63299
|
[setPageIndex]
|
|
63454
63300
|
);
|
|
63455
|
-
const firstPage =
|
|
63456
|
-
const lastPage =
|
|
63301
|
+
const firstPage = useCallback5(() => setPageIndex(0), [setPageIndex]);
|
|
63302
|
+
const lastPage = useCallback5(
|
|
63457
63303
|
() => setPageIndex(paginationPageCountRef.current - 1),
|
|
63458
63304
|
[setPageIndex]
|
|
63459
63305
|
);
|
|
63460
|
-
const chartPivotHydratedFromSourceRef =
|
|
63461
|
-
const lastPivotHydrateCompletedSourceIdRef =
|
|
63462
|
-
const groupRowsBySetViaSetReportRef =
|
|
63463
|
-
const groupColumnsBySetViaSetReportRef =
|
|
63464
|
-
const
|
|
63465
|
-
const
|
|
63306
|
+
const chartPivotHydratedFromSourceRef = useRef24(false);
|
|
63307
|
+
const lastPivotHydrateCompletedSourceIdRef = useRef24(null);
|
|
63308
|
+
const groupRowsBySetViaSetReportRef = useRef24(false);
|
|
63309
|
+
const groupColumnsBySetViaSetReportRef = useRef24(false);
|
|
63310
|
+
const dateBucketSetViaSetReportRef = useRef24(false);
|
|
63311
|
+
const aggregationStateSetViaSetReportRef = useRef24(false);
|
|
63312
|
+
const prevReportIdForChartPivotHydrationRef = useRef24(effectiveReportId);
|
|
63466
63313
|
if (prevReportIdForChartPivotHydrationRef.current !== effectiveReportId) {
|
|
63467
63314
|
prevReportIdForChartPivotHydrationRef.current = effectiveReportId;
|
|
63468
63315
|
chartPivotHydratedFromSourceRef.current = false;
|
|
63469
63316
|
groupRowsBySetViaSetReportRef.current = false;
|
|
63470
63317
|
groupColumnsBySetViaSetReportRef.current = false;
|
|
63318
|
+
dateBucketSetViaSetReportRef.current = false;
|
|
63471
63319
|
aggregationStateSetViaSetReportRef.current = false;
|
|
63472
63320
|
}
|
|
63473
|
-
const [chartPivotHydrationEpoch, setChartPivotHydrationEpoch] =
|
|
63321
|
+
const [chartPivotHydrationEpoch, setChartPivotHydrationEpoch] = useState41(0);
|
|
63474
63322
|
const [
|
|
63475
63323
|
expandReportBuilderColumnsForFlatTable,
|
|
63476
63324
|
setExpandReportBuilderColumnsForFlatTable
|
|
63477
|
-
] =
|
|
63478
|
-
const prevPivotStateForColumnExpansionRef =
|
|
63479
|
-
const [sourceReport, setSourceReport] =
|
|
63325
|
+
] = useState41(false);
|
|
63326
|
+
const prevPivotStateForColumnExpansionRef = useRef24(null);
|
|
63327
|
+
const [sourceReport, setSourceReport] = useState41(
|
|
63480
63328
|
null
|
|
63481
63329
|
);
|
|
63482
|
-
const prevSourceReportIdForPivotHydrationRef =
|
|
63330
|
+
const prevSourceReportIdForPivotHydrationRef = useRef24(null);
|
|
63483
63331
|
{
|
|
63484
63332
|
const currentSourceId = sourceReport ? String(
|
|
63485
63333
|
sourceReport.id ?? sourceReport._id ?? ""
|
|
@@ -63491,11 +63339,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63491
63339
|
lastPivotHydrateCompletedSourceIdRef.current = null;
|
|
63492
63340
|
}
|
|
63493
63341
|
}
|
|
63494
|
-
const [preserveSchemaWideOptions, setPreserveSchemaWideOptions] =
|
|
63495
|
-
const [initialSchemaScopedTableNames, setInitialSchemaScopedTableNames] =
|
|
63496
|
-
const [tableColumnsEditedSignature, setTableColumnsEditedSignature] =
|
|
63497
|
-
const [chartAxisEdits, setChartAxisEdits] =
|
|
63498
|
-
const [chartVisibilityOverrides, setChartVisibilityOverrides] =
|
|
63342
|
+
const [preserveSchemaWideOptions, setPreserveSchemaWideOptions] = useState41(false);
|
|
63343
|
+
const [initialSchemaScopedTableNames, setInitialSchemaScopedTableNames] = useState41(null);
|
|
63344
|
+
const [tableColumnsEditedSignature, setTableColumnsEditedSignature] = useState41(null);
|
|
63345
|
+
const [chartAxisEdits, setChartAxisEdits] = useState41({});
|
|
63346
|
+
const [chartVisibilityOverrides, setChartVisibilityOverrides] = useState41({});
|
|
63499
63347
|
const [client] = useContext36(ClientContext);
|
|
63500
63348
|
const [schemaData] = useContext36(SchemaDataContext);
|
|
63501
63349
|
const { tenants, flags } = useContext36(TenantContext);
|
|
@@ -63508,7 +63356,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63508
63356
|
clientDefaultDashboardName,
|
|
63509
63357
|
destinationDashboardName
|
|
63510
63358
|
].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
|
|
63511
|
-
const initialFormState =
|
|
63359
|
+
const initialFormState = useMemo32(
|
|
63512
63360
|
() => ({
|
|
63513
63361
|
columns: [],
|
|
63514
63362
|
queryColumns: [],
|
|
@@ -63516,6 +63364,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63516
63364
|
queryFilters: { combinator: "and", rules: [] },
|
|
63517
63365
|
groupRowsBy: void 0,
|
|
63518
63366
|
groupColumnsBy: void 0,
|
|
63367
|
+
dateBucket: void 0,
|
|
63519
63368
|
aggregationState: [],
|
|
63520
63369
|
aggregationTablesByIndex: [],
|
|
63521
63370
|
pivotSort: void 0,
|
|
@@ -63545,6 +63394,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63545
63394
|
queryFilters,
|
|
63546
63395
|
groupRowsBy,
|
|
63547
63396
|
groupColumnsBy,
|
|
63397
|
+
dateBucket,
|
|
63548
63398
|
aggregationState,
|
|
63549
63399
|
aggregationTablesByIndex,
|
|
63550
63400
|
pivotSort,
|
|
@@ -63554,16 +63404,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63554
63404
|
schemaDatasourceIds
|
|
63555
63405
|
} = formState;
|
|
63556
63406
|
const schemaDatasourceIdsKey = schemaDatasourceIds?.map((id) => String(id ?? "").trim()).join("\0") ?? "";
|
|
63557
|
-
const queryColumnsBootstrapKey =
|
|
63407
|
+
const queryColumnsBootstrapKey = useMemo32(
|
|
63558
63408
|
() => queryColumns.map(
|
|
63559
63409
|
(c) => `${String(c.table ?? "").trim()}\0${String(c.field ?? "").trim()}`
|
|
63560
63410
|
).join("\n"),
|
|
63561
63411
|
[queryColumns]
|
|
63562
63412
|
);
|
|
63563
|
-
const dashboardNameForNewReport =
|
|
63413
|
+
const dashboardNameForNewReport = useMemo32(() => {
|
|
63564
63414
|
return [clientDefaultDashboardName, destinationDashboardName].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
|
|
63565
63415
|
}, [clientDefaultDashboardName, destinationDashboardName]);
|
|
63566
|
-
const filterStackRef =
|
|
63416
|
+
const filterStackRef = useRef24(filterStack);
|
|
63567
63417
|
filterStackRef.current = filterStack;
|
|
63568
63418
|
const resolvedGroupRowsBy = decodePivotGroupOptionValue(groupRowsBy);
|
|
63569
63419
|
const resolvedGroupColumnsBy = decodePivotGroupOptionValue(groupColumnsBy);
|
|
@@ -63578,8 +63428,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63578
63428
|
setChartAxisEdits({});
|
|
63579
63429
|
setChartVisibilityOverrides({});
|
|
63580
63430
|
}, [effectiveReportId]);
|
|
63581
|
-
const bootstrapReportTaskUsedForReportIdRef =
|
|
63582
|
-
const schemaScopeInitializedForReportIdRef =
|
|
63431
|
+
const bootstrapReportTaskUsedForReportIdRef = useRef24(null);
|
|
63432
|
+
const schemaScopeInitializedForReportIdRef = useRef24(null);
|
|
63583
63433
|
const initializeSchemaScopeForReport = (report) => {
|
|
63584
63434
|
if (!report) return;
|
|
63585
63435
|
if (schemaScopeInitializedForReportIdRef.current === effectiveReportId)
|
|
@@ -63592,26 +63442,26 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63592
63442
|
);
|
|
63593
63443
|
schemaScopeInitializedForReportIdRef.current = effectiveReportId;
|
|
63594
63444
|
};
|
|
63595
|
-
const internalFilters =
|
|
63445
|
+
const internalFilters = useMemo32(
|
|
63596
63446
|
() => internalFiltersFromFilterStack(filterStack),
|
|
63597
63447
|
[filterStack]
|
|
63598
63448
|
);
|
|
63599
|
-
const customFilters =
|
|
63449
|
+
const customFilters = useMemo32(
|
|
63600
63450
|
() => customFiltersFromFilterStack(filterStack),
|
|
63601
63451
|
[filterStack]
|
|
63602
63452
|
);
|
|
63603
|
-
const reloadKey =
|
|
63604
|
-
const schemaForReportBuilderState =
|
|
63453
|
+
const reloadKey = useMemo32(() => 0, []);
|
|
63454
|
+
const schemaForReportBuilderState = useMemo32(() => {
|
|
63605
63455
|
if (schemaData.schemaWithCustomFields?.length) {
|
|
63606
63456
|
return schemaData.schemaWithCustomFields;
|
|
63607
63457
|
}
|
|
63608
63458
|
return schemaData.schema ?? [];
|
|
63609
63459
|
}, [schemaData.schema, schemaData.schemaWithCustomFields]);
|
|
63610
|
-
const schemaForReportBuilderStateRef =
|
|
63611
|
-
const customFieldsRef =
|
|
63460
|
+
const schemaForReportBuilderStateRef = useRef24(schemaForReportBuilderState);
|
|
63461
|
+
const customFieldsRef = useRef24(schemaData.customFields);
|
|
63612
63462
|
schemaForReportBuilderStateRef.current = schemaForReportBuilderState;
|
|
63613
63463
|
customFieldsRef.current = schemaData.customFields;
|
|
63614
|
-
const isBoolAggregationField =
|
|
63464
|
+
const isBoolAggregationField = useCallback5(
|
|
63615
63465
|
(field, table2) => {
|
|
63616
63466
|
const fieldType = resolveFieldType({
|
|
63617
63467
|
field,
|
|
@@ -63624,19 +63474,19 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63624
63474
|
},
|
|
63625
63475
|
[]
|
|
63626
63476
|
);
|
|
63627
|
-
const schemaForeignKeyMap =
|
|
63477
|
+
const schemaForeignKeyMap = useMemo32(
|
|
63628
63478
|
() => getSchemaForeignKeyMapping(schemaForReportBuilderState),
|
|
63629
63479
|
[schemaForReportBuilderState]
|
|
63630
63480
|
);
|
|
63631
63481
|
const reportBuilderBaseTableNamesKey = (sourceReport?.reportBuilderState?.tables ?? []).map((t) => String(t?.name ?? "").trim()).filter(Boolean).join("\0") ?? "";
|
|
63632
|
-
const selectedBaseTableNamesForFieldOptions =
|
|
63482
|
+
const selectedBaseTableNamesForFieldOptions = useMemo32(() => {
|
|
63633
63483
|
const fromPicker = schemaDatasourceIds?.map((id) => String(id ?? "").trim()).filter(Boolean) ?? [];
|
|
63634
63484
|
if (fromPicker.length > 0) {
|
|
63635
63485
|
return fromPicker;
|
|
63636
63486
|
}
|
|
63637
63487
|
return (sourceReport?.reportBuilderState?.tables ?? []).map((t) => String(t?.name ?? "").trim()).filter(Boolean);
|
|
63638
63488
|
}, [schemaDatasourceIdsKey, reportBuilderBaseTableNamesKey]);
|
|
63639
|
-
const fieldOptionsAllowedTableNames =
|
|
63489
|
+
const fieldOptionsAllowedTableNames = useMemo32(() => {
|
|
63640
63490
|
if (!restrictFieldOptionsToSelectedDatasources) {
|
|
63641
63491
|
return null;
|
|
63642
63492
|
}
|
|
@@ -63738,18 +63588,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63738
63588
|
schemaForReportBuilderState,
|
|
63739
63589
|
queryColumnsBootstrapKey
|
|
63740
63590
|
]);
|
|
63741
|
-
const datasourceOptions =
|
|
63591
|
+
const datasourceOptions = useMemo32(() => {
|
|
63742
63592
|
const seen = /* @__PURE__ */ new Set();
|
|
63743
63593
|
const result = [];
|
|
63744
63594
|
for (const table2 of schemaForReportBuilderState) {
|
|
63745
63595
|
const name2 = String(table2.name ?? "").trim();
|
|
63746
63596
|
if (!name2 || seen.has(name2)) continue;
|
|
63747
63597
|
seen.add(name2);
|
|
63748
|
-
result.push({
|
|
63598
|
+
result.push({ value: name2, label: toTitleCaseLabel(name2) });
|
|
63749
63599
|
}
|
|
63750
63600
|
return result;
|
|
63751
63601
|
}, [schemaForReportBuilderState]);
|
|
63752
|
-
const queryBuilderFieldConfigByName =
|
|
63602
|
+
const queryBuilderFieldConfigByName = useMemo32(() => {
|
|
63753
63603
|
const configByName = buildQueryBuilderFieldConfigByName(
|
|
63754
63604
|
schemaForReportBuilderState
|
|
63755
63605
|
);
|
|
@@ -63883,7 +63733,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63883
63733
|
sourceReport?.columns,
|
|
63884
63734
|
sourceReport?.reportBuilderState?.columns
|
|
63885
63735
|
]);
|
|
63886
|
-
const filterUniqueValuesRequest =
|
|
63736
|
+
const filterUniqueValuesRequest = useMemo32(() => {
|
|
63887
63737
|
const dashboardName = resolvedSourceDashboardName;
|
|
63888
63738
|
const reportBuilderStateFromSource = sourceReport?.reportBuilderState;
|
|
63889
63739
|
const isStringReportBuilderColumn = (column) => {
|
|
@@ -64104,13 +63954,13 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64104
63954
|
sourceReport?.reportBuilderState,
|
|
64105
63955
|
resolvedSourceDashboardName
|
|
64106
63956
|
]);
|
|
64107
|
-
const filterUniqueValuesRequestHash =
|
|
63957
|
+
const filterUniqueValuesRequestHash = useMemo32(
|
|
64108
63958
|
() => stableSerializeForQueryKey(
|
|
64109
63959
|
filterUniqueValuesRequestForQueryKey(filterUniqueValuesRequest)
|
|
64110
63960
|
),
|
|
64111
63961
|
[filterUniqueValuesRequest]
|
|
64112
63962
|
);
|
|
64113
|
-
const customFiltersHashForUniqueValues =
|
|
63963
|
+
const customFiltersHashForUniqueValues = useMemo32(
|
|
64114
63964
|
() => stableSerializeForQueryKey(customFilters),
|
|
64115
63965
|
[customFilters]
|
|
64116
63966
|
);
|
|
@@ -64207,7 +64057,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64207
64057
|
enabled: filterUniqueValuesEnabled,
|
|
64208
64058
|
retry: false
|
|
64209
64059
|
});
|
|
64210
|
-
const backendUniqueValuesByFieldName =
|
|
64060
|
+
const backendUniqueValuesByFieldName = useMemo32(() => {
|
|
64211
64061
|
const valuesByField = /* @__PURE__ */ new Map();
|
|
64212
64062
|
const uniqueValuesByColumn = filterUniqueValuesQuery.data?.uniqueValuesByColumn;
|
|
64213
64063
|
if (!uniqueValuesByColumn || typeof uniqueValuesByColumn !== "object") {
|
|
@@ -64256,7 +64106,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64256
64106
|
effectiveReportId,
|
|
64257
64107
|
useFormFiltersDebugEnabled
|
|
64258
64108
|
]);
|
|
64259
|
-
const filterValueOptionsByFieldName =
|
|
64109
|
+
const filterValueOptionsByFieldName = useMemo32(() => {
|
|
64260
64110
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
64261
64111
|
const selectedMultiselectByField = collectSelectedStringMultiselectValuesByField(queryFilters);
|
|
64262
64112
|
const collectValuesForField = (fieldName) => {
|
|
@@ -64322,7 +64172,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64322
64172
|
queryBuilderFieldConfigByName,
|
|
64323
64173
|
queryFilters
|
|
64324
64174
|
]);
|
|
64325
|
-
const filterFieldsComputed =
|
|
64175
|
+
const filterFieldsComputed = useMemo32(() => {
|
|
64326
64176
|
const fields = [];
|
|
64327
64177
|
const seen = /* @__PURE__ */ new Set();
|
|
64328
64178
|
const addField = (fieldName, fieldType, tableName, rawFieldName) => {
|
|
@@ -64423,9 +64273,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64423
64273
|
queryBuilderFieldConfigByName,
|
|
64424
64274
|
queryFilters
|
|
64425
64275
|
]);
|
|
64426
|
-
const filterFieldsStableReportIdRef =
|
|
64427
|
-
const filterFieldsStableCacheRef =
|
|
64428
|
-
const filterFields =
|
|
64276
|
+
const filterFieldsStableReportIdRef = useRef24("");
|
|
64277
|
+
const filterFieldsStableCacheRef = useRef24([]);
|
|
64278
|
+
const filterFields = useMemo32(() => {
|
|
64429
64279
|
const rid = String(effectiveReportId ?? "");
|
|
64430
64280
|
if (filterFieldsStableReportIdRef.current !== rid) {
|
|
64431
64281
|
filterFieldsStableReportIdRef.current = rid;
|
|
@@ -64440,14 +64290,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64440
64290
|
}
|
|
64441
64291
|
return filterFieldsComputed;
|
|
64442
64292
|
}, [effectiveReportId, filterFieldsComputed]);
|
|
64443
|
-
const getFilterOperators =
|
|
64293
|
+
const getFilterOperators = useMemo32(
|
|
64444
64294
|
() => (_field, misc) => {
|
|
64445
64295
|
const fieldType = misc?.fieldData?.quillFieldType ?? queryBuilderFieldConfigByName[String(_field ?? "").trim()]?.fieldType ?? "string";
|
|
64446
64296
|
return QUERY_BUILDER_OPERATORS_BY_FIELD_TYPE[fieldType] ?? QUERY_BUILDER_OPERATORS_BY_FIELD_TYPE.string;
|
|
64447
64297
|
},
|
|
64448
64298
|
[queryBuilderFieldConfigByName]
|
|
64449
64299
|
);
|
|
64450
|
-
const getFilterInputType =
|
|
64300
|
+
const getFilterInputType = useMemo32(
|
|
64451
64301
|
() => (_field, operator, misc) => {
|
|
64452
64302
|
const fieldType = misc?.fieldData?.quillFieldType ?? queryBuilderFieldConfigByName[String(_field ?? "").trim()]?.fieldType ?? "string";
|
|
64453
64303
|
if (fieldType === "date" && isRelativeDateQueryBuilderOperator(operator)) {
|
|
@@ -64457,17 +64307,20 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64457
64307
|
},
|
|
64458
64308
|
[queryBuilderFieldConfigByName]
|
|
64459
64309
|
);
|
|
64460
|
-
const getFilterValueEditorType =
|
|
64310
|
+
const getFilterValueEditorType = useMemo32(
|
|
64461
64311
|
() => (_field, operator, misc) => {
|
|
64462
64312
|
const fieldType = misc?.fieldData?.quillFieldType ?? queryBuilderFieldConfigByName[String(_field ?? "").trim()]?.fieldType;
|
|
64463
64313
|
if (fieldType === "string" && isMultiValueOperator(operator)) {
|
|
64464
64314
|
return "multiselect";
|
|
64465
64315
|
}
|
|
64316
|
+
if (fieldType === "boolean") {
|
|
64317
|
+
return "select";
|
|
64318
|
+
}
|
|
64466
64319
|
return void 0;
|
|
64467
64320
|
},
|
|
64468
64321
|
[queryBuilderFieldConfigByName]
|
|
64469
64322
|
);
|
|
64470
|
-
const getFilterValues =
|
|
64323
|
+
const getFilterValues = useMemo32(
|
|
64471
64324
|
() => (_field, operator, misc) => {
|
|
64472
64325
|
const fieldName = String(_field ?? "").trim();
|
|
64473
64326
|
if (!fieldName) {
|
|
@@ -64478,6 +64331,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64478
64331
|
misc,
|
|
64479
64332
|
queryBuilderFieldConfigByName
|
|
64480
64333
|
);
|
|
64334
|
+
if (fieldType === "boolean") {
|
|
64335
|
+
return BOOLEAN_FILTER_VALUE_OPTIONS;
|
|
64336
|
+
}
|
|
64481
64337
|
if (fieldType !== "string" || !isMultiValueOperator(operator)) {
|
|
64482
64338
|
return [];
|
|
64483
64339
|
}
|
|
@@ -64494,7 +64350,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64494
64350
|
},
|
|
64495
64351
|
[filterValueOptionsByFieldName, queryBuilderFieldConfigByName]
|
|
64496
64352
|
);
|
|
64497
|
-
const filterQueryBuilderProps =
|
|
64353
|
+
const filterQueryBuilderProps = useMemo32(
|
|
64498
64354
|
() => ({
|
|
64499
64355
|
fields: filterFields,
|
|
64500
64356
|
listsAsArrays: true,
|
|
@@ -64511,7 +64367,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64511
64367
|
getFilterValues
|
|
64512
64368
|
]
|
|
64513
64369
|
);
|
|
64514
|
-
const filtersForQueryBuilder =
|
|
64370
|
+
const filtersForQueryBuilder = useMemo32(
|
|
64515
64371
|
() => canonicalizeMultiselectStringRulesToOptionValues(
|
|
64516
64372
|
queryFilters,
|
|
64517
64373
|
filterValueOptionsByFieldName,
|
|
@@ -64578,12 +64434,12 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64578
64434
|
...table2 ? { table: table2 } : {}
|
|
64579
64435
|
};
|
|
64580
64436
|
};
|
|
64581
|
-
const tenantHash =
|
|
64437
|
+
const tenantHash = useMemo32(
|
|
64582
64438
|
() => stableSerializeForQueryKey(tenants),
|
|
64583
64439
|
[tenants]
|
|
64584
64440
|
);
|
|
64585
|
-
const flagHash =
|
|
64586
|
-
const clientHash =
|
|
64441
|
+
const flagHash = useMemo32(() => stableSerializeForQueryKey(flags), [flags]);
|
|
64442
|
+
const clientHash = useMemo32(
|
|
64587
64443
|
() => stableSerializeForQueryKey({
|
|
64588
64444
|
publicKey: client?.publicKey,
|
|
64589
64445
|
clientId: client?.clientId,
|
|
@@ -64591,7 +64447,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64591
64447
|
}),
|
|
64592
64448
|
[client]
|
|
64593
64449
|
);
|
|
64594
|
-
const reloadKeyHash =
|
|
64450
|
+
const reloadKeyHash = useMemo32(
|
|
64595
64451
|
() => stableSerializeForQueryKey(reloadKey),
|
|
64596
64452
|
[reloadKey]
|
|
64597
64453
|
);
|
|
@@ -64624,6 +64480,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64624
64480
|
// grouping from the prior report would otherwise win over the new report.
|
|
64625
64481
|
groupRowsBy: void 0,
|
|
64626
64482
|
groupColumnsBy: void 0,
|
|
64483
|
+
dateBucket: void 0,
|
|
64627
64484
|
aggregationState: [],
|
|
64628
64485
|
aggregationTablesByIndex: [],
|
|
64629
64486
|
pivotSort: void 0,
|
|
@@ -64810,6 +64667,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64810
64667
|
const sourceDisplayColumns = sourceDisplayColumnsFromSchema.length > 0 ? sourceDisplayColumnsFromSchema : sourceQueryColumns;
|
|
64811
64668
|
const nextGroupRowsBy = shouldTakePivotGroupsFromSource ? groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption : prev.groupRowsBy !== void 0 ? prev.groupRowsBy : groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption;
|
|
64812
64669
|
const nextGroupColumnsBy = shouldTakePivotGroupsFromSource ? groupColumnsBySetViaSetReportRef.current ? prev.groupColumnsBy : sourceColumnGroupOption : prev.groupColumnsBy !== void 0 ? prev.groupColumnsBy : prev.groupRowsBy !== void 0 ? prev.groupColumnsBy : sourceColumnGroupOption;
|
|
64670
|
+
const sourceDateBucket = sourceReport.pivot?.dateBucket ?? sourceReport.reportBuilderState?.pivot?.dateBucket;
|
|
64671
|
+
const nextDateBucket = dateBucketSetViaSetReportRef.current ? prev.dateBucket : sourceDateBucket;
|
|
64813
64672
|
const nextFromSource = {
|
|
64814
64673
|
...prev,
|
|
64815
64674
|
queryColumns: prev.queryColumns.length ? prev.queryColumns : sourceQueryColumns,
|
|
@@ -64818,6 +64677,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64818
64677
|
queryFilters: nextQueryFilters,
|
|
64819
64678
|
groupRowsBy: nextGroupRowsBy,
|
|
64820
64679
|
groupColumnsBy: nextGroupColumnsBy,
|
|
64680
|
+
dateBucket: nextDateBucket,
|
|
64821
64681
|
aggregationState: nextAggregationState,
|
|
64822
64682
|
aggregationTablesByIndex: nextAggregationTablesByIndex,
|
|
64823
64683
|
pivotSort: prev.pivotSort ?? (sourceReport.pivot?.sort && sourceReport.pivot?.sortField && sourceReport.pivot?.sortDirection ? {
|
|
@@ -64850,11 +64710,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64850
64710
|
schemaForReportBuilderState,
|
|
64851
64711
|
sourceReport
|
|
64852
64712
|
]);
|
|
64853
|
-
const appliedAggregationState =
|
|
64713
|
+
const appliedAggregationState = useMemo32(
|
|
64854
64714
|
() => aggregationState.filter(isAppliedAggregation),
|
|
64855
64715
|
[aggregationState]
|
|
64856
64716
|
);
|
|
64857
|
-
const pivotState =
|
|
64717
|
+
const pivotState = useMemo32(() => {
|
|
64858
64718
|
if (!resolvedGroupRowsBy && !resolvedGroupColumnsBy && appliedAggregationState.length === 0) {
|
|
64859
64719
|
return null;
|
|
64860
64720
|
}
|
|
@@ -64898,6 +64758,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64898
64758
|
rowFieldType,
|
|
64899
64759
|
columnField: effectiveColumnField,
|
|
64900
64760
|
columnFieldType,
|
|
64761
|
+
dateBucket: chartPivotHydratedFromSourceRef.current ? dateBucket : dateBucket ?? priorPivot?.dateBucket,
|
|
64901
64762
|
aggregations,
|
|
64902
64763
|
...rowFieldTable ? { rowFieldTable } : {},
|
|
64903
64764
|
...columnFieldTable ? { columnFieldTable } : {}
|
|
@@ -64908,6 +64769,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64908
64769
|
aggregationTablesByIndex,
|
|
64909
64770
|
appliedAggregationState,
|
|
64910
64771
|
baseReportBuilderTables,
|
|
64772
|
+
dateBucket,
|
|
64911
64773
|
groupColumnsBy,
|
|
64912
64774
|
groupRowsBy,
|
|
64913
64775
|
schemaForReportBuilderState,
|
|
@@ -64929,7 +64791,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64929
64791
|
}
|
|
64930
64792
|
prevPivotStateForColumnExpansionRef.current = pivotState;
|
|
64931
64793
|
}, [pivotState]);
|
|
64932
|
-
const effectiveReportBuilderTables =
|
|
64794
|
+
const effectiveReportBuilderTables = useMemo32(() => {
|
|
64933
64795
|
const explicitBaseFromSchemaPicker = Array.isArray(schemaDatasourceIds) && schemaDatasourceIds.length > 0 ? schemaDatasourceIds.map((tableName) => String(tableName ?? "").trim()).filter(Boolean).map((name2) => ({ name: name2 })) : null;
|
|
64934
64796
|
const baseTablesForMerge = explicitBaseFromSchemaPicker ?? baseReportBuilderTables;
|
|
64935
64797
|
return mergeReportBuilderTables(
|
|
@@ -64953,28 +64815,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64953
64815
|
queryColumns,
|
|
64954
64816
|
schemaDatasourceIds
|
|
64955
64817
|
]);
|
|
64956
|
-
const datasources =
|
|
64957
|
-
return effectiveReportBuilderTables.map((table2) =>
|
|
64958
|
-
const name2 = String(table2.name ?? "").trim();
|
|
64959
|
-
if (!name2) return null;
|
|
64960
|
-
const alias = String(table2.alias ?? "").trim();
|
|
64961
|
-
return {
|
|
64962
|
-
id: name2,
|
|
64963
|
-
label: alias || name2
|
|
64964
|
-
};
|
|
64965
|
-
}).filter(
|
|
64966
|
-
(entry) => Boolean(entry)
|
|
64967
|
-
);
|
|
64818
|
+
const datasources = useMemo32(() => {
|
|
64819
|
+
return effectiveReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).filter((name2) => Boolean(name2));
|
|
64968
64820
|
}, [effectiveReportBuilderTables]);
|
|
64969
|
-
const effectiveReportBuilderTableNames =
|
|
64821
|
+
const effectiveReportBuilderTableNames = useMemo32(
|
|
64970
64822
|
() => effectiveReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).filter((name2) => Boolean(name2)),
|
|
64971
64823
|
[effectiveReportBuilderTables]
|
|
64972
64824
|
);
|
|
64973
|
-
const baseReportBuilderTableNames =
|
|
64825
|
+
const baseReportBuilderTableNames = useMemo32(
|
|
64974
64826
|
() => baseReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).filter((name2) => Boolean(name2)),
|
|
64975
64827
|
[baseReportBuilderTables]
|
|
64976
64828
|
);
|
|
64977
|
-
const normalizeQueryBuilderFieldNameForConfig =
|
|
64829
|
+
const normalizeQueryBuilderFieldNameForConfig = useMemo32(() => {
|
|
64978
64830
|
const configEntries = Object.entries(queryBuilderFieldConfigByName);
|
|
64979
64831
|
const preferredTableNames = /* @__PURE__ */ new Set([
|
|
64980
64832
|
...effectiveReportBuilderTableNames,
|
|
@@ -65036,7 +64888,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65036
64888
|
effectiveReportBuilderTableNames,
|
|
65037
64889
|
queryBuilderFieldConfigByName
|
|
65038
64890
|
]);
|
|
65039
|
-
const normalizeQueryBuilderFiltersForConfig =
|
|
64891
|
+
const normalizeQueryBuilderFiltersForConfig = useMemo32(() => {
|
|
65040
64892
|
const normalizeGroup = (group) => {
|
|
65041
64893
|
const groupRules = Array.isArray(group.rules) ? group.rules : [];
|
|
65042
64894
|
const nextRules = groupRules.map((entry) => {
|
|
@@ -65073,14 +64925,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65073
64925
|
return normalizeGroup(group);
|
|
65074
64926
|
};
|
|
65075
64927
|
}, [normalizeQueryBuilderFieldNameForConfig, queryBuilderFieldConfigByName]);
|
|
65076
|
-
const refreshSelectionTables =
|
|
64928
|
+
const refreshSelectionTables = useMemo32(() => {
|
|
65077
64929
|
return [
|
|
65078
64930
|
getPivotGroupOptionTable(groupRowsBy),
|
|
65079
64931
|
getPivotGroupOptionTable(groupColumnsBy),
|
|
65080
64932
|
...aggregationTablesByIndex
|
|
65081
64933
|
].map((tableName) => String(tableName ?? "").trim()).filter((tableName) => Boolean(tableName));
|
|
65082
64934
|
}, [aggregationTablesByIndex, groupColumnsBy, groupRowsBy]);
|
|
65083
|
-
const refreshSelectionFields =
|
|
64935
|
+
const refreshSelectionFields = useMemo32(() => {
|
|
65084
64936
|
const resolveFieldTableForSelection = (field, tableHint) => {
|
|
65085
64937
|
const fieldName = String(field ?? "").trim();
|
|
65086
64938
|
if (!fieldName) return "";
|
|
@@ -65130,7 +64982,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65130
64982
|
schemaForReportBuilderState,
|
|
65131
64983
|
sourceReport
|
|
65132
64984
|
]);
|
|
65133
|
-
const refreshDecision =
|
|
64985
|
+
const refreshDecision = useMemo32(
|
|
65134
64986
|
() => decideReportBuilderRefresh({
|
|
65135
64987
|
baseTables: baseReportBuilderTables,
|
|
65136
64988
|
baseColumns: baseReportBuilderColumns,
|
|
@@ -65144,7 +64996,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65144
64996
|
refreshSelectionTables
|
|
65145
64997
|
]
|
|
65146
64998
|
);
|
|
65147
|
-
const effectiveReportBuilderColumns =
|
|
64999
|
+
const effectiveReportBuilderColumns = useMemo32(() => {
|
|
65148
65000
|
const columnsFromPivot = [];
|
|
65149
65001
|
const appendPivotColumn = (field, tableHint) => {
|
|
65150
65002
|
const normalizedField = String(field ?? "").trim();
|
|
@@ -65242,7 +65094,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65242
65094
|
queryBuilderFieldConfigByName,
|
|
65243
65095
|
queryFilters
|
|
65244
65096
|
]);
|
|
65245
|
-
const resolvedSortFieldType =
|
|
65097
|
+
const resolvedSortFieldType = useMemo32(() => {
|
|
65246
65098
|
const sortField = pivotSort?.sortField;
|
|
65247
65099
|
if (!sortField || !pivotState) return void 0;
|
|
65248
65100
|
if (sortField === resolvedGroupRowsBy) {
|
|
@@ -65263,7 +65115,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65263
65115
|
resolvedGroupColumnsBy,
|
|
65264
65116
|
resolvedGroupRowsBy
|
|
65265
65117
|
]);
|
|
65266
|
-
const effectiveReportBuilderState =
|
|
65118
|
+
const effectiveReportBuilderState = useMemo32(() => {
|
|
65267
65119
|
if (!sourceReport && effectiveReportBuilderTables.length === 0) {
|
|
65268
65120
|
return void 0;
|
|
65269
65121
|
}
|
|
@@ -65302,11 +65154,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65302
65154
|
resolvedSortFieldType,
|
|
65303
65155
|
sourceReport
|
|
65304
65156
|
]);
|
|
65305
|
-
const effectiveReportBuilderStateHash =
|
|
65157
|
+
const effectiveReportBuilderStateHash = useMemo32(
|
|
65306
65158
|
() => stableSerializeForQueryKey(effectiveReportBuilderState),
|
|
65307
65159
|
[effectiveReportBuilderState]
|
|
65308
65160
|
);
|
|
65309
|
-
const prevPaginationResetStateHashRef =
|
|
65161
|
+
const prevPaginationResetStateHashRef = useRef24(null);
|
|
65310
65162
|
useEffect31(() => {
|
|
65311
65163
|
const prevHash = prevPaginationResetStateHashRef.current;
|
|
65312
65164
|
prevPaginationResetStateHashRef.current = effectiveReportBuilderStateHash;
|
|
@@ -65323,7 +65175,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65323
65175
|
activate: false
|
|
65324
65176
|
});
|
|
65325
65177
|
}, [applyPaginationUpdate, effectiveReportBuilderStateHash]);
|
|
65326
|
-
const pivotTableDataReportBuilderState =
|
|
65178
|
+
const pivotTableDataReportBuilderState = useMemo32(() => {
|
|
65327
65179
|
if (!effectiveReportBuilderState?.pivot) {
|
|
65328
65180
|
return void 0;
|
|
65329
65181
|
}
|
|
@@ -65343,11 +65195,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65343
65195
|
limit: null
|
|
65344
65196
|
};
|
|
65345
65197
|
}, [effectiveReportBuilderState, schemaForReportBuilderState]);
|
|
65346
|
-
const pivotTableDataReportBuilderStateHash =
|
|
65198
|
+
const pivotTableDataReportBuilderStateHash = useMemo32(
|
|
65347
65199
|
() => stableSerializeForQueryKey(pivotTableDataReportBuilderState),
|
|
65348
65200
|
[pivotTableDataReportBuilderState]
|
|
65349
65201
|
);
|
|
65350
|
-
const sourceReportMatchesEffectiveReportId =
|
|
65202
|
+
const sourceReportMatchesEffectiveReportId = useMemo32(() => {
|
|
65351
65203
|
const loadTarget = String(effectiveReportId ?? "").trim();
|
|
65352
65204
|
if (!loadTarget || !sourceReport) {
|
|
65353
65205
|
return true;
|
|
@@ -65357,7 +65209,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65357
65209
|
).trim();
|
|
65358
65210
|
return sid === loadTarget;
|
|
65359
65211
|
}, [effectiveReportId, sourceReport]);
|
|
65360
|
-
const shouldSkipRedundantFlatTableReportBuilderQuery =
|
|
65212
|
+
const shouldSkipRedundantFlatTableReportBuilderQuery = useMemo32(() => {
|
|
65361
65213
|
if (!sourceReport || pivotState) {
|
|
65362
65214
|
return false;
|
|
65363
65215
|
}
|
|
@@ -65423,7 +65275,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65423
65275
|
tableRefreshQueryEnabled,
|
|
65424
65276
|
useFormRefreshDebugEnabled
|
|
65425
65277
|
]);
|
|
65426
|
-
const chartTypes =
|
|
65278
|
+
const chartTypes = useMemo32(() => {
|
|
65427
65279
|
return getChartTypeOptions2({ pivot: pivotState });
|
|
65428
65280
|
}, [pivotState]);
|
|
65429
65281
|
useEffect31(() => {
|
|
@@ -65461,7 +65313,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65461
65313
|
});
|
|
65462
65314
|
}
|
|
65463
65315
|
}, [chartType, chartTypes, sourceReport]);
|
|
65464
|
-
const schemaScopedTableNames =
|
|
65316
|
+
const schemaScopedTableNames = useMemo32(() => {
|
|
65465
65317
|
if (preserveSchemaWideOptions) {
|
|
65466
65318
|
return [];
|
|
65467
65319
|
}
|
|
@@ -65476,7 +65328,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65476
65328
|
preserveSchemaWideOptions,
|
|
65477
65329
|
sourceReport?.reportBuilderState?.tables
|
|
65478
65330
|
]);
|
|
65479
|
-
const joinCompatibleSchemaTableNames =
|
|
65331
|
+
const joinCompatibleSchemaTableNames = useMemo32(() => {
|
|
65480
65332
|
if (schemaScopedTableNames.length === 0) {
|
|
65481
65333
|
return [];
|
|
65482
65334
|
}
|
|
@@ -65485,7 +65337,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65485
65337
|
schemaForeignKeyMap
|
|
65486
65338
|
);
|
|
65487
65339
|
}, [schemaForeignKeyMap, schemaScopedTableNames]);
|
|
65488
|
-
const aggregationFallbackTarget =
|
|
65340
|
+
const aggregationFallbackTarget = useMemo32(() => {
|
|
65489
65341
|
const tableNames = effectiveReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
65490
65342
|
const referencedTableNames = (sourceReport?.referencedTables ?? []).filter(
|
|
65491
65343
|
(name2) => typeof name2 === "string" && name2.length > 0
|
|
@@ -65493,7 +65345,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65493
65345
|
const tableNamesToUse = tableNames.length ? tableNames : referencedTableNames;
|
|
65494
65346
|
return tableNamesToUse.length > 0 ? tableNamesToUse.join(", ") : "table";
|
|
65495
65347
|
}, [effectiveReportBuilderTables, sourceReport?.referencedTables]);
|
|
65496
|
-
const aggregationFallbackTableName =
|
|
65348
|
+
const aggregationFallbackTableName = useMemo32(() => {
|
|
65497
65349
|
const tableNames = effectiveReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
65498
65350
|
const referencedTableNames = (sourceReport?.referencedTables ?? []).filter(
|
|
65499
65351
|
(name2) => typeof name2 === "string" && name2.length > 0
|
|
@@ -65501,7 +65353,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65501
65353
|
const tableNamesToUse = tableNames.length ? tableNames : referencedTableNames;
|
|
65502
65354
|
return tableNamesToUse[0] ?? "table";
|
|
65503
65355
|
}, [effectiveReportBuilderTables, sourceReport?.referencedTables]);
|
|
65504
|
-
const cleanedAggregations =
|
|
65356
|
+
const cleanedAggregations = useMemo32(() => {
|
|
65505
65357
|
return aggregationState.filter((aggregation) => Boolean(aggregation?.aggregationType)).map((aggregation, index) => {
|
|
65506
65358
|
const aggregationType = String(aggregation.aggregationType);
|
|
65507
65359
|
const normalizedAggregationType = aggregationType.toLowerCase();
|
|
@@ -65523,7 +65375,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65523
65375
|
aggregationTablesByIndex,
|
|
65524
65376
|
isBoolAggregationField
|
|
65525
65377
|
]);
|
|
65526
|
-
const { aggregationBaseOptions, aggregationOptionTableLookup } =
|
|
65378
|
+
const { aggregationBaseOptions, aggregationOptionTableLookup } = useMemo32(() => {
|
|
65527
65379
|
const joinScoped = fieldOptionsAllowedTableNames ? joinCompatibleSchemaTableNames.filter(
|
|
65528
65380
|
(name2) => fieldOptionsAllowedTableNames.has(name2)
|
|
65529
65381
|
) : joinCompatibleSchemaTableNames;
|
|
@@ -65569,7 +65421,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65569
65421
|
if (!canAggregateColumn(column, aggregationType)) continue;
|
|
65570
65422
|
const isNumberSharePercentage = aggregationType === "percentage" && !isBoolColumn;
|
|
65571
65423
|
if (isNumberSharePercentage && !resolvedGroupRowsBy) continue;
|
|
65572
|
-
const value = `${aggregationType}:${fieldName}`;
|
|
65424
|
+
const value = tableName ? `${aggregationType}:${tableName}::${fieldName}` : `${aggregationType}:${fieldName}`;
|
|
65573
65425
|
if (seen.has(value)) continue;
|
|
65574
65426
|
const aggregationWord = aggregationType === "percentage" ? isBoolColumn ? "Percent" : "Percent of Total" : formatAggregationTypeForDisplay(aggregationType);
|
|
65575
65427
|
options2.push({
|
|
@@ -65577,8 +65429,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65577
65429
|
label: tableName ? `${aggregationWord} ${toTitleCaseLabel(tableName)} ${toTitleCaseLabel(fieldName)}` : `${aggregationWord} ${toTitleCaseLabel(fieldName)}`
|
|
65578
65430
|
});
|
|
65579
65431
|
seen.add(value);
|
|
65580
|
-
if (tableName
|
|
65581
|
-
tableLookup.
|
|
65432
|
+
if (tableName) {
|
|
65433
|
+
if (!tableLookup.has(value)) {
|
|
65434
|
+
tableLookup.set(value, tableName);
|
|
65435
|
+
}
|
|
65436
|
+
const unqualifiedValue = `${aggregationType}:${fieldName}`;
|
|
65437
|
+
if (!tableLookup.has(unqualifiedValue)) {
|
|
65438
|
+
tableLookup.set(unqualifiedValue, tableName);
|
|
65439
|
+
}
|
|
65582
65440
|
}
|
|
65583
65441
|
}
|
|
65584
65442
|
}
|
|
@@ -65600,7 +65458,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65600
65458
|
resolvedGroupRowsBy,
|
|
65601
65459
|
schemaForReportBuilderState
|
|
65602
65460
|
]);
|
|
65603
|
-
const { schemaColumnOptions, columnIdentifierLookup } =
|
|
65461
|
+
const { schemaColumnOptions, columnIdentifierLookup } = useMemo32(() => {
|
|
65604
65462
|
const lookup = /* @__PURE__ */ new Map();
|
|
65605
65463
|
const options2 = [];
|
|
65606
65464
|
for (const table2 of schemaData.schemaWithCustomFields) {
|
|
@@ -65627,7 +65485,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65627
65485
|
columnIdentifierLookup: lookup
|
|
65628
65486
|
};
|
|
65629
65487
|
}, [schemaData.schemaWithCustomFields]);
|
|
65630
|
-
const tableColumnPickerPoolOptions =
|
|
65488
|
+
const tableColumnPickerPoolOptions = useMemo32(() => {
|
|
65631
65489
|
const allowed = new Set(
|
|
65632
65490
|
effectiveReportBuilderTableNames.map((name2) => String(name2 ?? "").trim()).filter(Boolean)
|
|
65633
65491
|
);
|
|
@@ -65638,16 +65496,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65638
65496
|
(option) => allowed.has(String(option.tableName ?? "").trim())
|
|
65639
65497
|
);
|
|
65640
65498
|
}, [effectiveReportBuilderTableNames, schemaColumnOptions]);
|
|
65641
|
-
const columns =
|
|
65499
|
+
const columns = useMemo32(() => {
|
|
65642
65500
|
return displayColumns.filter((column) => Boolean(column.field)).map((column) => encodeColumnOptionValue(column.table, column.field));
|
|
65643
65501
|
}, [displayColumns]);
|
|
65644
|
-
const selectedColumnOptions =
|
|
65502
|
+
const selectedColumnOptions = useMemo32(() => {
|
|
65645
65503
|
return displayColumns.map((column) => {
|
|
65646
65504
|
const value = column.alias || column.field;
|
|
65647
65505
|
return value ? { label: value, value } : null;
|
|
65648
65506
|
}).filter((option) => option !== null);
|
|
65649
65507
|
}, [displayColumns]);
|
|
65650
|
-
const scopedSchemaColumns =
|
|
65508
|
+
const scopedSchemaColumns = useMemo32(() => {
|
|
65651
65509
|
const tableNames = fieldOptionsAllowedTableNames ? Array.from(fieldOptionsAllowedTableNames) : joinCompatibleSchemaTableNames;
|
|
65652
65510
|
const schemaTables = schemaForReportBuilderState;
|
|
65653
65511
|
const tablesToUse = tableNames.length ? schemaTables.filter((table2) => tableNames.includes(table2.name ?? "")) : schemaTables;
|
|
@@ -65668,7 +65526,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65668
65526
|
joinCompatibleSchemaTableNames,
|
|
65669
65527
|
schemaForReportBuilderState
|
|
65670
65528
|
]);
|
|
65671
|
-
const pivotUniqueValuesByColumn =
|
|
65529
|
+
const pivotUniqueValuesByColumn = useMemo32(() => {
|
|
65672
65530
|
const explicitUniqueValues = sourceReport?.uniqueStringsByColumn ?? sourceReport?.columnUniqueValues ?? sourceReport?.uniqueValues;
|
|
65673
65531
|
if (explicitUniqueValues && typeof explicitUniqueValues === "object" && !Array.isArray(explicitUniqueValues)) {
|
|
65674
65532
|
return explicitUniqueValues;
|
|
@@ -65694,7 +65552,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65694
65552
|
}
|
|
65695
65553
|
return result;
|
|
65696
65554
|
}, [sourceReport]);
|
|
65697
|
-
const possiblePivotFields =
|
|
65555
|
+
const possiblePivotFields = useMemo32(() => {
|
|
65698
65556
|
const options2 = getPossiblePivotFieldOptions(
|
|
65699
65557
|
scopedSchemaColumns,
|
|
65700
65558
|
pivotUniqueValuesByColumn
|
|
@@ -65705,7 +65563,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65705
65563
|
columnFields: options2.columnFields.filter((field) => !isIdColumn(field))
|
|
65706
65564
|
};
|
|
65707
65565
|
}, [scopedSchemaColumns, pivotUniqueValuesByColumn]);
|
|
65708
|
-
const groupRowsByOptions =
|
|
65566
|
+
const groupRowsByOptions = useMemo32(() => {
|
|
65709
65567
|
const allowedFields = new Set(possiblePivotFields.rowFields);
|
|
65710
65568
|
const seenValues = /* @__PURE__ */ new Set();
|
|
65711
65569
|
const options2 = [];
|
|
@@ -65732,7 +65590,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65732
65590
|
}
|
|
65733
65591
|
return options2;
|
|
65734
65592
|
}, [groupRowsBy, possiblePivotFields.rowFields, scopedSchemaColumns]);
|
|
65735
|
-
const groupColumnsByOptions =
|
|
65593
|
+
const groupColumnsByOptions = useMemo32(() => {
|
|
65736
65594
|
const allowedFields = new Set(possiblePivotFields.columnFields);
|
|
65737
65595
|
const seenValues = /* @__PURE__ */ new Set();
|
|
65738
65596
|
const options2 = [];
|
|
@@ -65759,19 +65617,19 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65759
65617
|
}
|
|
65760
65618
|
return options2;
|
|
65761
65619
|
}, [groupColumnsBy, possiblePivotFields.columnFields, scopedSchemaColumns]);
|
|
65762
|
-
const cleanedSort =
|
|
65620
|
+
const cleanedSort = useMemo32(() => {
|
|
65763
65621
|
const activeSort = resolvedGroupRowsBy ? pivotSort : regularSort;
|
|
65764
65622
|
if (!activeSort?.sortField || !activeSort?.sortDirection) {
|
|
65765
65623
|
return "";
|
|
65766
65624
|
}
|
|
65767
65625
|
return toFlatSortValue(activeSort.sortField, activeSort.sortDirection);
|
|
65768
65626
|
}, [pivotSort, regularSort, resolvedGroupRowsBy]);
|
|
65769
|
-
const aggregationSortLabelFallbackTable =
|
|
65627
|
+
const aggregationSortLabelFallbackTable = useMemo32(() => {
|
|
65770
65628
|
const reportBuilderTableName = effectiveReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).find((tableName) => Boolean(tableName));
|
|
65771
65629
|
if (reportBuilderTableName) return reportBuilderTableName;
|
|
65772
65630
|
return (sourceReport?.referencedTables ?? []).map((tableName) => String(tableName ?? "").trim()).find((tableName) => Boolean(tableName));
|
|
65773
65631
|
}, [effectiveReportBuilderTables, sourceReport?.referencedTables]);
|
|
65774
|
-
const sortOptions =
|
|
65632
|
+
const sortOptions = useMemo32(() => {
|
|
65775
65633
|
if (resolvedGroupRowsBy) {
|
|
65776
65634
|
const aggregationSortFields = getPivotAggregationSortFields(
|
|
65777
65635
|
aggregationState,
|
|
@@ -65830,12 +65688,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65830
65688
|
resolvedGroupRowsBy,
|
|
65831
65689
|
selectedColumnOptions
|
|
65832
65690
|
]);
|
|
65833
|
-
const aggregationOptions =
|
|
65691
|
+
const { aggregationValues, aggregationOptions } = useMemo32(() => {
|
|
65834
65692
|
const baseOptions = aggregationBaseOptions.map((option) => ({
|
|
65835
65693
|
value: option.value,
|
|
65836
65694
|
label: option.label
|
|
65837
65695
|
}));
|
|
65838
|
-
|
|
65696
|
+
const seenValues = new Set(baseOptions.map((option) => option.value));
|
|
65697
|
+
const injectedOptions = [];
|
|
65698
|
+
const values = aggregationState.map((aggregation, index) => {
|
|
65839
65699
|
const normalizedAggregationType = String(
|
|
65840
65700
|
aggregation.aggregationType ?? ""
|
|
65841
65701
|
).toLowerCase();
|
|
@@ -65843,27 +65703,36 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65843
65703
|
const currentValueField = String(aggregation.valueField ?? "").trim();
|
|
65844
65704
|
const currentValueField2 = String(aggregation.valueField2 ?? "").trim();
|
|
65845
65705
|
const isPercentageRatio = normalizedAggregationType === "percentage" && Boolean(currentValueField) && Boolean(currentValueField2);
|
|
65846
|
-
const
|
|
65847
|
-
const
|
|
65848
|
-
const
|
|
65849
|
-
|
|
65850
|
-
|
|
65851
|
-
|
|
65852
|
-
|
|
65853
|
-
|
|
65854
|
-
|
|
65855
|
-
|
|
65856
|
-
|
|
65706
|
+
const isTableTarget = !isPercentageRatio && !currentValueField && (normalizedAggregationType === "count" || normalizedAggregationType === "percentage");
|
|
65707
|
+
const labelTarget = isPercentageRatio ? `${currentValueField}:${currentValueField2}` : currentValueField ? currentValueField : isTableTarget ? tableHint || aggregationFallbackTableName : aggregationFallbackTarget;
|
|
65708
|
+
const fieldTable = isTableTarget || !aggregation.aggregationType ? "" : tableHint || String(
|
|
65709
|
+
aggregationOptionTableLookup.get(
|
|
65710
|
+
`${aggregation.aggregationType}:${labelTarget}`
|
|
65711
|
+
) ?? ""
|
|
65712
|
+
).trim();
|
|
65713
|
+
const currentValue = aggregation.aggregationType ? `${aggregation.aggregationType}:${fieldTable ? `${fieldTable}::` : ""}${labelTarget}` : "";
|
|
65714
|
+
if (currentValue && !seenValues.has(currentValue)) {
|
|
65715
|
+
const isBoolPercentage = normalizedAggregationType === "percentage" && Boolean(currentValueField) && isBoolAggregationField(currentValueField, tableHint || void 0) === true;
|
|
65716
|
+
const currentLabel = isPercentageRatio ? `Percent ${toTitleCaseLabel(currentValueField)} of ${toTitleCaseLabel(currentValueField2)}` : normalizedAggregationType === "percentage" ? isBoolPercentage ? `Percent ${toTitleCaseLabel(labelTarget)}` : `Percent of Total ${toTitleCaseLabel(labelTarget)}` : `${formatAggregationTypeForDisplay(aggregation.aggregationType)} ${toTitleCaseLabel(labelTarget)}`;
|
|
65717
|
+
injectedOptions.push({ value: currentValue, label: currentLabel });
|
|
65718
|
+
seenValues.add(currentValue);
|
|
65719
|
+
}
|
|
65720
|
+
return currentValue;
|
|
65857
65721
|
});
|
|
65722
|
+
return {
|
|
65723
|
+
aggregationValues: values,
|
|
65724
|
+
aggregationOptions: [...injectedOptions, ...baseOptions]
|
|
65725
|
+
};
|
|
65858
65726
|
}, [
|
|
65859
65727
|
aggregationFallbackTableName,
|
|
65860
65728
|
aggregationFallbackTarget,
|
|
65861
65729
|
aggregationState,
|
|
65862
65730
|
aggregationBaseOptions,
|
|
65731
|
+
aggregationOptionTableLookup,
|
|
65863
65732
|
aggregationTablesByIndex,
|
|
65864
65733
|
isBoolAggregationField
|
|
65865
65734
|
]);
|
|
65866
|
-
const nextPivot =
|
|
65735
|
+
const nextPivot = useMemo32(() => {
|
|
65867
65736
|
if (!sourceReport) return null;
|
|
65868
65737
|
return pivotState ? {
|
|
65869
65738
|
...pivotState,
|
|
@@ -65874,15 +65743,15 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65874
65743
|
rowLimit: limit?.value
|
|
65875
65744
|
} : null;
|
|
65876
65745
|
}, [sourceReport, pivotState, pivotSort, limit, resolvedSortFieldType]);
|
|
65877
|
-
const nextPivotHash =
|
|
65746
|
+
const nextPivotHash = useMemo32(
|
|
65878
65747
|
() => stableSerializeForQueryKey(nextPivot),
|
|
65879
65748
|
[nextPivot]
|
|
65880
65749
|
);
|
|
65881
|
-
const filterStackHash =
|
|
65750
|
+
const filterStackHash = useMemo32(
|
|
65882
65751
|
() => stableSerializeForQueryKey(filterStack),
|
|
65883
65752
|
[filterStack]
|
|
65884
65753
|
);
|
|
65885
|
-
const shouldSkipPivotRefreshForUnchangedPivot =
|
|
65754
|
+
const shouldSkipPivotRefreshForUnchangedPivot = useMemo32(() => {
|
|
65886
65755
|
if (!sourceReport || !nextPivot) return false;
|
|
65887
65756
|
if (!Array.isArray(sourceReport.rows) || sourceReport.rows.length === 0) {
|
|
65888
65757
|
return false;
|
|
@@ -65920,7 +65789,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65920
65789
|
shouldSkipPivotRefreshForUnchangedPivot,
|
|
65921
65790
|
sourceReport
|
|
65922
65791
|
]);
|
|
65923
|
-
const shouldSkipRedundantPivotTableDataReportBuilderQuery =
|
|
65792
|
+
const shouldSkipRedundantPivotTableDataReportBuilderQuery = useMemo32(() => {
|
|
65924
65793
|
if (!sourceReport || !nextPivot) {
|
|
65925
65794
|
return false;
|
|
65926
65795
|
}
|
|
@@ -66022,7 +65891,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66022
65891
|
});
|
|
66023
65892
|
const tablePageReportBuilderState = pivotTableDataReportBuilderState ?? effectiveReportBuilderState;
|
|
66024
65893
|
const tablePageReportBuilderStateHash = pivotTableDataReportBuilderState ? pivotTableDataReportBuilderStateHash : effectiveReportBuilderStateHash;
|
|
66025
|
-
const tablePaginationSort =
|
|
65894
|
+
const tablePaginationSort = useMemo32(() => {
|
|
66026
65895
|
const sortEntry = tablePageReportBuilderState?.sort?.[0];
|
|
66027
65896
|
const field = String(sortEntry?.field ?? "").trim();
|
|
66028
65897
|
if (!field || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(field)) {
|
|
@@ -66084,7 +65953,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66084
65953
|
const tablePageRows = tablePageQueryEnabled && !tablePageQuery.data?.error && Array.isArray(tablePageQuery.data?.report?.rows) ? tablePageQuery.data.report.rows : void 0;
|
|
66085
65954
|
const tablePageRowCount = tablePageQueryEnabled && typeof tablePageQuery.data?.report?.rowCount === "number" && tablePageQuery.data.report.rowCount > 0 ? tablePageQuery.data.report.rowCount : void 0;
|
|
66086
65955
|
const tablePageFetching = tablePageQueryEnabled && tablePageQuery.isFetching;
|
|
66087
|
-
const paginationTotalRowCount =
|
|
65956
|
+
const paginationTotalRowCount = useMemo32(() => {
|
|
66088
65957
|
if (tablePageRowCount !== void 0) {
|
|
66089
65958
|
return Math.max(tablePageRowCount, baseWindowRowsLength);
|
|
66090
65959
|
}
|
|
@@ -66198,7 +66067,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66198
66067
|
effectiveReportId,
|
|
66199
66068
|
useFormRefreshDebugEnabled
|
|
66200
66069
|
]);
|
|
66201
|
-
const chartData =
|
|
66070
|
+
const chartData = useMemo32(() => {
|
|
66202
66071
|
if (!sourceReport) return void 0;
|
|
66203
66072
|
const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
|
|
66204
66073
|
const chartPivotForDisplay = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
|
|
@@ -66234,18 +66103,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66234
66103
|
useInMemoryEngines,
|
|
66235
66104
|
chartPivotHydrationEpoch
|
|
66236
66105
|
]);
|
|
66237
|
-
const baseChart =
|
|
66106
|
+
const baseChart = useMemo32(
|
|
66238
66107
|
() => normalizePivotChartForDisplay(chartData),
|
|
66239
66108
|
[chartData]
|
|
66240
66109
|
);
|
|
66241
|
-
const chartAxesBaseChart =
|
|
66110
|
+
const chartAxesBaseChart = useMemo32(() => {
|
|
66242
66111
|
if (!chartData) return void 0;
|
|
66243
66112
|
if (chartData.pivot?.columnField) {
|
|
66244
66113
|
return normalizePivotChartForAxisControls(chartData, effectiveReportId);
|
|
66245
66114
|
}
|
|
66246
66115
|
return baseChart;
|
|
66247
66116
|
}, [baseChart, chartData, effectiveReportId]);
|
|
66248
|
-
const chartAxisOptions =
|
|
66117
|
+
const chartAxisOptions = useMemo32(() => {
|
|
66249
66118
|
if (!chartAxesBaseChart) return [];
|
|
66250
66119
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
66251
66120
|
const registerOption = (fieldRaw, labelRaw, formatRaw) => {
|
|
@@ -66283,14 +66152,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66283
66152
|
);
|
|
66284
66153
|
return Array.from(optionsByField.values());
|
|
66285
66154
|
}, [chartAxesBaseChart]);
|
|
66286
|
-
const chartAxisOptionByField =
|
|
66155
|
+
const chartAxisOptionByField = useMemo32(() => {
|
|
66287
66156
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
66288
66157
|
for (const option of chartAxisOptions) {
|
|
66289
66158
|
optionsByField.set(option.value, option);
|
|
66290
66159
|
}
|
|
66291
66160
|
return optionsByField;
|
|
66292
66161
|
}, [chartAxisOptions]);
|
|
66293
|
-
const xAxisOptions =
|
|
66162
|
+
const xAxisOptions = useMemo32(() => {
|
|
66294
66163
|
if (!chartAxesBaseChart) return chartAxisOptions;
|
|
66295
66164
|
const pivot = chartAxesBaseChart.pivot;
|
|
66296
66165
|
const pivotRowField = String(pivot?.rowField ?? "").trim();
|
|
@@ -66313,7 +66182,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66313
66182
|
}
|
|
66314
66183
|
return chartAxisOptions;
|
|
66315
66184
|
}, [chartAxesBaseChart, chartAxisOptions, chartAxisOptionByField]);
|
|
66316
|
-
const yAxisOptions =
|
|
66185
|
+
const yAxisOptions = useMemo32(() => {
|
|
66317
66186
|
if (!chartAxesBaseChart) return [];
|
|
66318
66187
|
const keepOption = (option) => {
|
|
66319
66188
|
const col = findSchemaColumnForChartAxisField(
|
|
@@ -66349,21 +66218,21 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66349
66218
|
chartAxisOptions,
|
|
66350
66219
|
schemaColumnOptions
|
|
66351
66220
|
]);
|
|
66352
|
-
const normalizedChartXAxisOptions =
|
|
66221
|
+
const normalizedChartXAxisOptions = useMemo32(() => {
|
|
66353
66222
|
return xAxisOptions.map((option) => ({
|
|
66354
66223
|
value: String(option.value ?? "").trim(),
|
|
66355
66224
|
label: String(option.label ?? option.value ?? "").trim(),
|
|
66356
66225
|
format: String(option.format ?? "").trim()
|
|
66357
66226
|
}));
|
|
66358
66227
|
}, [xAxisOptions]);
|
|
66359
|
-
const normalizedChartYAxisOptions =
|
|
66228
|
+
const normalizedChartYAxisOptions = useMemo32(() => {
|
|
66360
66229
|
return yAxisOptions.map((option) => ({
|
|
66361
66230
|
value: String(option.value ?? "").trim(),
|
|
66362
66231
|
label: String(option.label ?? option.value ?? "").trim(),
|
|
66363
66232
|
format: String(option.format ?? "").trim()
|
|
66364
66233
|
}));
|
|
66365
66234
|
}, [yAxisOptions]);
|
|
66366
|
-
const resolvedYAxisFields =
|
|
66235
|
+
const resolvedYAxisFields = useMemo32(() => {
|
|
66367
66236
|
if (!chartAxesBaseChart) return [];
|
|
66368
66237
|
const normalizeYAxisField = (yAxisFieldRaw) => {
|
|
66369
66238
|
const field = String(yAxisFieldRaw?.field ?? "").trim();
|
|
@@ -66406,7 +66275,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66406
66275
|
chartAxisOptionByField,
|
|
66407
66276
|
chartAxisOptions
|
|
66408
66277
|
]);
|
|
66409
|
-
const resolvedXAxisField =
|
|
66278
|
+
const resolvedXAxisField = useMemo32(() => {
|
|
66410
66279
|
if (!chartAxesBaseChart) return "";
|
|
66411
66280
|
const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
|
|
66412
66281
|
const pivotRowField = String(
|
|
@@ -66438,7 +66307,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66438
66307
|
chartAxisOptions,
|
|
66439
66308
|
resolvedYAxisFields
|
|
66440
66309
|
]);
|
|
66441
|
-
const resolvedXAxisFormat =
|
|
66310
|
+
const resolvedXAxisFormat = useMemo32(() => {
|
|
66442
66311
|
if (!chartAxesBaseChart) {
|
|
66443
66312
|
return "string";
|
|
66444
66313
|
}
|
|
@@ -66466,7 +66335,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66466
66335
|
resolvedXAxisField,
|
|
66467
66336
|
resolvedYAxisFields
|
|
66468
66337
|
]);
|
|
66469
|
-
const resolvedXAxisLabel =
|
|
66338
|
+
const resolvedXAxisLabel = useMemo32(() => {
|
|
66470
66339
|
const defaultXLabel = String(
|
|
66471
66340
|
chartAxesBaseChart?.xAxisLabel ?? chartAxisOptionByField.get(resolvedXAxisField)?.label ?? ""
|
|
66472
66341
|
).trim();
|
|
@@ -66480,13 +66349,13 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66480
66349
|
chartAxisOptionByField,
|
|
66481
66350
|
resolvedXAxisField
|
|
66482
66351
|
]);
|
|
66483
|
-
const chartVisibility =
|
|
66352
|
+
const chartVisibility = useMemo32(
|
|
66484
66353
|
() => ({
|
|
66485
66354
|
showLegend: chartVisibilityOverrides.showLegend ?? Boolean(baseChart?.showLegend ?? false)
|
|
66486
66355
|
}),
|
|
66487
66356
|
[baseChart?.showLegend, chartVisibilityOverrides]
|
|
66488
66357
|
);
|
|
66489
|
-
const axisConfig =
|
|
66358
|
+
const axisConfig = useMemo32(() => {
|
|
66490
66359
|
const pivotBucketXAxis = isPivotTableDateBucketRowAxis(
|
|
66491
66360
|
chartAxesBaseChart,
|
|
66492
66361
|
resolvedXAxisField
|
|
@@ -66528,14 +66397,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66528
66397
|
resolvedYAxisFields,
|
|
66529
66398
|
chartVisibility.showLegend
|
|
66530
66399
|
]);
|
|
66531
|
-
const resolvedYAxisFieldsForDisplay =
|
|
66400
|
+
const resolvedYAxisFieldsForDisplay = useMemo32(() => {
|
|
66532
66401
|
if (!baseChart) return resolvedYAxisFields;
|
|
66533
66402
|
return mapResolvedPivotYAxisFieldsForDisplay({
|
|
66534
66403
|
chart: baseChart,
|
|
66535
66404
|
resolvedYAxisFields
|
|
66536
66405
|
});
|
|
66537
66406
|
}, [baseChart, resolvedYAxisFields]);
|
|
66538
|
-
const chart =
|
|
66407
|
+
const chart = useMemo32(() => {
|
|
66539
66408
|
if (!baseChart) return void 0;
|
|
66540
66409
|
let columns2 = mergeChartColumnFormatsFromYAxisFields(
|
|
66541
66410
|
baseChart.columns,
|
|
@@ -66587,7 +66456,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66587
66456
|
const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(
|
|
66588
66457
|
chart && chart.pivot && Array.isArray(chart.columns) && chart.columns.length > 0
|
|
66589
66458
|
);
|
|
66590
|
-
const chartAxes =
|
|
66459
|
+
const chartAxes = useMemo32(() => {
|
|
66591
66460
|
const yAxisItems = resolvedYAxisFields.map(
|
|
66592
66461
|
(yAxisField, index) => ({
|
|
66593
66462
|
id: String(index),
|
|
@@ -66736,8 +66605,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66736
66605
|
xAxisOptions,
|
|
66737
66606
|
yAxisOptions
|
|
66738
66607
|
]);
|
|
66739
|
-
const tableFormatCacheRef =
|
|
66740
|
-
const tableFormatMerge =
|
|
66608
|
+
const tableFormatCacheRef = useRef24(/* @__PURE__ */ new Map());
|
|
66609
|
+
const tableFormatMerge = useMemo32(
|
|
66741
66610
|
() => mergeDisplayAndSourceForTableFormats({
|
|
66742
66611
|
effectiveReportBuilderTableNames,
|
|
66743
66612
|
scopedSchemaColumns,
|
|
@@ -66751,7 +66620,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66751
66620
|
sourceReport
|
|
66752
66621
|
]
|
|
66753
66622
|
);
|
|
66754
|
-
const table =
|
|
66623
|
+
const table = useMemo32(() => {
|
|
66755
66624
|
const baseWindowRows = Array.isArray(sourceReport?.rows) ? sourceReport.rows : [];
|
|
66756
66625
|
const rawRows = !paginationActive ? baseWindowRows : tablePageRows ?? baseWindowRows.slice(paginationRangeStart, paginationRangeEnd);
|
|
66757
66626
|
const { columns: mergedFromReport } = mergeDisplayAndSourceForTableFormats({
|
|
@@ -66880,7 +66749,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66880
66749
|
const {
|
|
66881
66750
|
columnsOptions: tableFormattingColumnOptions,
|
|
66882
66751
|
hasTableDrivenColumnOrder
|
|
66883
|
-
} =
|
|
66752
|
+
} = useMemo32(() => {
|
|
66884
66753
|
if (isPivotTableChart && chart?.columns?.length) {
|
|
66885
66754
|
const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
|
|
66886
66755
|
const pivotTableColumns = aggregationSlotColumns ? aggregationSlotColumns.tableColumns : chart.columns.map((c) => ({
|
|
@@ -66914,7 +66783,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66914
66783
|
schemaColumnOptions,
|
|
66915
66784
|
table.columns
|
|
66916
66785
|
]);
|
|
66917
|
-
const availableFields =
|
|
66786
|
+
const availableFields = useMemo32(
|
|
66918
66787
|
() => tableColumnPickerPoolOptions.map((option) => ({
|
|
66919
66788
|
id: option.value,
|
|
66920
66789
|
label: option.label,
|
|
@@ -66922,24 +66791,24 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66922
66791
|
})),
|
|
66923
66792
|
[tableColumnPickerPoolOptions]
|
|
66924
66793
|
);
|
|
66925
|
-
const axisSelectFormatLabels =
|
|
66794
|
+
const axisSelectFormatLabels = useMemo32(
|
|
66926
66795
|
() => AXIS_FORMAT_OPTIONS.map((option) => option.label),
|
|
66927
66796
|
[]
|
|
66928
66797
|
);
|
|
66929
|
-
const xAxisFormatOptionLabels =
|
|
66798
|
+
const xAxisFormatOptionLabels = useMemo32(() => {
|
|
66930
66799
|
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField)) {
|
|
66931
66800
|
return ["date", ...axisSelectFormatLabels];
|
|
66932
66801
|
}
|
|
66933
66802
|
return axisSelectFormatLabels;
|
|
66934
66803
|
}, [chartAxesBaseChart, resolvedXAxisField, axisSelectFormatLabels]);
|
|
66935
|
-
const tableDerivedColumnOrder =
|
|
66804
|
+
const tableDerivedColumnOrder = useMemo32(() => {
|
|
66936
66805
|
return tableFormattingColumnOptions.map((option) => option.value);
|
|
66937
66806
|
}, [tableFormattingColumnOptions]);
|
|
66938
|
-
const tableDerivedColumnOrderSignature =
|
|
66807
|
+
const tableDerivedColumnOrderSignature = useMemo32(
|
|
66939
66808
|
() => tableDerivedColumnOrder.join("|"),
|
|
66940
66809
|
[tableDerivedColumnOrder]
|
|
66941
66810
|
);
|
|
66942
|
-
const activeTableColumnIds =
|
|
66811
|
+
const activeTableColumnIds = useMemo32(() => {
|
|
66943
66812
|
if (isPivotTableChart && chart?.columns?.length) {
|
|
66944
66813
|
const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
|
|
66945
66814
|
if (aggregationSlotColumns) {
|
|
@@ -66978,7 +66847,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66978
66847
|
tableDerivedColumnOrder,
|
|
66979
66848
|
tableFormattingColumnOptions
|
|
66980
66849
|
]);
|
|
66981
|
-
const columnOptionById =
|
|
66850
|
+
const columnOptionById = useMemo32(() => {
|
|
66982
66851
|
const map = /* @__PURE__ */ new Map();
|
|
66983
66852
|
for (const option of tableColumnPickerPoolOptions) {
|
|
66984
66853
|
map.set(option.value, option);
|
|
@@ -66990,7 +66859,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66990
66859
|
}
|
|
66991
66860
|
return map;
|
|
66992
66861
|
}, [tableColumnPickerPoolOptions, tableFormattingColumnOptions]);
|
|
66993
|
-
const displayColumnById =
|
|
66862
|
+
const displayColumnById = useMemo32(() => {
|
|
66994
66863
|
const map = /* @__PURE__ */ new Map();
|
|
66995
66864
|
for (const column of displayColumns) {
|
|
66996
66865
|
const field = String(column.field ?? "").trim();
|
|
@@ -67001,7 +66870,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67001
66870
|
}
|
|
67002
66871
|
return map;
|
|
67003
66872
|
}, [displayColumns]);
|
|
67004
|
-
const tableColumnSettingsById =
|
|
66873
|
+
const tableColumnSettingsById = useMemo32(() => {
|
|
67005
66874
|
const map = /* @__PURE__ */ new Map();
|
|
67006
66875
|
const effectiveById = tableFormatMerge.formatByColumnOptionId;
|
|
67007
66876
|
const chartColById = /* @__PURE__ */ new Map();
|
|
@@ -67119,13 +66988,13 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67119
66988
|
sourceReport?.columns,
|
|
67120
66989
|
tableFormatMerge
|
|
67121
66990
|
]);
|
|
67122
|
-
const tableColumnSettingsCoalesceRef =
|
|
66991
|
+
const tableColumnSettingsCoalesceRef = useRef24(
|
|
67123
66992
|
/* @__PURE__ */ new Map()
|
|
67124
66993
|
);
|
|
67125
66994
|
useLayoutEffect4(() => {
|
|
67126
66995
|
tableColumnSettingsCoalesceRef.current = new Map(tableColumnSettingsById);
|
|
67127
66996
|
}, [tableColumnSettingsById]);
|
|
67128
|
-
const tableColumnItems =
|
|
66997
|
+
const tableColumnItems = useMemo32(() => {
|
|
67129
66998
|
const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
|
|
67130
66999
|
const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
|
|
67131
67000
|
const items = activeTableColumnIds.map((columnId) => {
|
|
@@ -67161,19 +67030,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67161
67030
|
isPivotTableChart,
|
|
67162
67031
|
tableColumnSettingsById
|
|
67163
67032
|
]);
|
|
67164
|
-
const tableColumnById =
|
|
67033
|
+
const tableColumnById = useMemo32(() => {
|
|
67165
67034
|
return new Map(tableColumnItems.map((item) => [item.id, item]));
|
|
67166
67035
|
}, [tableColumnItems]);
|
|
67167
|
-
const
|
|
67036
|
+
const tableColumnValues = useMemo32(() => {
|
|
67168
67037
|
const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
|
|
67169
67038
|
const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
|
|
67170
67039
|
return tableColumnItems.map((item) => {
|
|
67171
67040
|
const coerced = coerceTableColumnFormatToAxisValue(item.format);
|
|
67172
67041
|
const usePivotDateOptions = isPivotTableChart && item.field === pivotRowFieldForFormat && isDateType(pivotRowFieldType) && coerced === "string";
|
|
67173
67042
|
return {
|
|
67174
|
-
|
|
67043
|
+
value: item.id,
|
|
67175
67044
|
label: item.label,
|
|
67176
|
-
visible: true,
|
|
67177
67045
|
format: item.formatLabel,
|
|
67178
67046
|
...usePivotDateOptions ? { formatOptions: [...PIVOT_DATE_BUCKET_FORMAT_OPTIONS] } : {}
|
|
67179
67047
|
};
|
|
@@ -67336,22 +67204,32 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67336
67204
|
columns: buildSetReportColumnsFromIds(nextColumnIds, nextSettingsById)
|
|
67337
67205
|
};
|
|
67338
67206
|
};
|
|
67339
|
-
let
|
|
67207
|
+
let applyReportChange;
|
|
67208
|
+
const setReport = (nextState) => {
|
|
67209
|
+
const { columns: nextColumns, ...rest } = nextState;
|
|
67210
|
+
const nextSettingsById = nextColumns === void 0 ? tableColumnSettingsById : new Map(
|
|
67211
|
+
nextColumns.map((column) => [
|
|
67212
|
+
column.value,
|
|
67213
|
+
{ label: column.label, format: column.format }
|
|
67214
|
+
])
|
|
67215
|
+
);
|
|
67216
|
+
applyReportChange({
|
|
67217
|
+
...rest,
|
|
67218
|
+
...nextColumns !== void 0 ? {
|
|
67219
|
+
columns: buildSetReportColumnsFromIds(
|
|
67220
|
+
nextColumns.map((column) => column.value),
|
|
67221
|
+
nextSettingsById
|
|
67222
|
+
)
|
|
67223
|
+
} : {}
|
|
67224
|
+
});
|
|
67225
|
+
};
|
|
67340
67226
|
const commitTableColumns = (nextColumnIds, settingsById) => {
|
|
67341
|
-
|
|
67227
|
+
applyReportChange({
|
|
67342
67228
|
columns: buildSetReportColumnsFromIds(nextColumnIds, settingsById)
|
|
67343
67229
|
});
|
|
67344
67230
|
};
|
|
67345
|
-
|
|
67346
|
-
|
|
67347
|
-
if (isSetReportTableColumnSidebarPatch(nextState.columns)) {
|
|
67348
|
-
const expanded = buildColumnSidebarSetReportInput(
|
|
67349
|
-
nextState.columns.patch
|
|
67350
|
-
);
|
|
67351
|
-
if (!expanded) return;
|
|
67352
|
-
const { columns: _omitSidebarColumnPatch, ...rest } = nextState;
|
|
67353
|
-
effectiveNextState = { ...rest, ...expanded };
|
|
67354
|
-
}
|
|
67231
|
+
applyReportChange = (nextState) => {
|
|
67232
|
+
const effectiveNextState = nextState;
|
|
67355
67233
|
if (effectiveNextState.showLegend !== void 0) {
|
|
67356
67234
|
setChartVisibilityOverrides((previous) => ({
|
|
67357
67235
|
...previous,
|
|
@@ -67424,15 +67302,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67424
67302
|
});
|
|
67425
67303
|
}
|
|
67426
67304
|
const isPivotSortUpdate = effectiveNextState.sort !== void 0 && Boolean(nextPivot);
|
|
67427
|
-
const
|
|
67428
|
-
|
|
67429
|
-
|
|
67305
|
+
const isAppendingEmptyAggregationPlaceholder = Array.isArray(effectiveNextState.aggregations) && effectiveNextState.aggregations.length === aggregationValues.length + 1 && effectiveNextState.aggregations.slice(0, aggregationValues.length).every(
|
|
67306
|
+
(value, index) => String(value ?? "") === aggregationValues[index]
|
|
67307
|
+
) && String(
|
|
67308
|
+
effectiveNextState.aggregations[aggregationValues.length] ?? ""
|
|
67309
|
+
).trim().length === 0;
|
|
67310
|
+
const touchesPivotState = effectiveNextState.groupRowsBy !== void 0 || effectiveNextState.groupColumnsBy !== void 0 || effectiveNextState.dateBucket !== void 0 || effectiveNextState.aggregations !== void 0 && !isAppendingEmptyAggregationPlaceholder || isPivotSortUpdate || effectiveNextState.limit !== void 0;
|
|
67430
67311
|
const isDatasourceUpdate = effectiveNextState.datasources !== void 0;
|
|
67431
67312
|
const hasRowGroupSelection = typeof effectiveNextState.groupRowsBy === "string" && effectiveNextState.groupRowsBy.trim().length > 0;
|
|
67432
67313
|
const hasColumnGroupSelection = typeof effectiveNextState.groupColumnsBy === "string" && effectiveNextState.groupColumnsBy.trim().length > 0;
|
|
67433
|
-
const hasAggregationSelection = effectiveNextState.aggregations !== void 0 && (typeof effectiveNextState.aggregations === "string" ? effectiveNextState.aggregations.trim().length > 0 :
|
|
67434
|
-
(aggregation) => Boolean(aggregation?.aggregationType) && Boolean(String(aggregation?.valueField ?? "").trim())
|
|
67435
|
-
)
|
|
67314
|
+
const hasAggregationSelection = effectiveNextState.aggregations !== void 0 && (typeof effectiveNextState.aggregations === "string" ? effectiveNextState.aggregations.trim().length > 0 : effectiveNextState.aggregations.some(
|
|
67315
|
+
(aggregation) => typeof aggregation === "string" ? aggregation.trim().length > 0 : Boolean(aggregation?.aggregationType) && Boolean(String(aggregation?.valueField ?? "").trim())
|
|
67316
|
+
));
|
|
67436
67317
|
const isClearingRowGrouping = effectiveNextState.groupRowsBy !== void 0 && String(effectiveNextState.groupRowsBy ?? "").trim().length === 0;
|
|
67437
67318
|
const queuePromoteColumnToRow = isClearingRowGrouping && !sourceReport;
|
|
67438
67319
|
const shouldRefreshExpandedTableData = useInMemoryEngines && (hasRowGroupSelection || hasColumnGroupSelection || hasAggregationSelection) || !useInMemoryEngines && !nextPivot && effectiveNextState.sort !== void 0;
|
|
@@ -67505,7 +67386,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67505
67386
|
}
|
|
67506
67387
|
}
|
|
67507
67388
|
}
|
|
67508
|
-
if (effectiveNextState.columns !== void 0
|
|
67389
|
+
if (effectiveNextState.columns !== void 0) {
|
|
67509
67390
|
const normalizedDisplayColumns = normalizeColumnsInput(
|
|
67510
67391
|
effectiveNextState.columns,
|
|
67511
67392
|
columnIdentifierLookup
|
|
@@ -67592,6 +67473,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67592
67473
|
groupColumnsBySetViaSetReportRef.current = true;
|
|
67593
67474
|
next.groupColumnsBy = effectiveNextState.groupColumnsBy || void 0;
|
|
67594
67475
|
}
|
|
67476
|
+
if (effectiveNextState.dateBucket !== void 0) {
|
|
67477
|
+
dateBucketSetViaSetReportRef.current = true;
|
|
67478
|
+
next.dateBucket = effectiveNextState.dateBucket || void 0;
|
|
67479
|
+
}
|
|
67595
67480
|
if (effectiveNextState.aggregations !== void 0) {
|
|
67596
67481
|
aggregationStateSetViaSetReportRef.current = true;
|
|
67597
67482
|
next.aggregationTablesByIndex = [...next.aggregationTablesByIndex];
|
|
@@ -67606,54 +67491,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67606
67491
|
],
|
|
67607
67492
|
schemaForeignKeyMap
|
|
67608
67493
|
).map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
67609
|
-
if (typeof effectiveNextState.aggregations === "
|
|
67610
|
-
const { index, value } = effectiveNextState.aggregations;
|
|
67611
|
-
if (index >= 0 && index <= next.aggregationState.length) {
|
|
67612
|
-
const rawValue = String(value ?? "").trim();
|
|
67613
|
-
next.aggregationState = [...next.aggregationState];
|
|
67614
|
-
if (!rawValue) {
|
|
67615
|
-
if (index === next.aggregationState.length) {
|
|
67616
|
-
next.aggregationState.push({ valueField: "" });
|
|
67617
|
-
next.aggregationTablesByIndex.push(void 0);
|
|
67618
|
-
} else if (index < next.aggregationState.length) {
|
|
67619
|
-
next.aggregationState.splice(index, 1);
|
|
67620
|
-
next.aggregationTablesByIndex.splice(index, 1);
|
|
67621
|
-
}
|
|
67622
|
-
} else {
|
|
67623
|
-
const [aggregationTypeRaw] = rawValue.split(":");
|
|
67624
|
-
const aggregationType = aggregationTypeRaw;
|
|
67625
|
-
const { field: target, table: table2 } = resolveAggregationSelection(
|
|
67626
|
-
rawValue,
|
|
67627
|
-
aggregationOptionTableLookup,
|
|
67628
|
-
preferredTables
|
|
67629
|
-
);
|
|
67630
|
-
const normalizedSelection = normalizeAggregationSelection(
|
|
67631
|
-
aggregationType,
|
|
67632
|
-
target,
|
|
67633
|
-
table2,
|
|
67634
|
-
preferredTables
|
|
67635
|
-
);
|
|
67636
|
-
const existing = next.aggregationState[index];
|
|
67637
|
-
const preservedValueField2 = aggregationType !== "percentage" && existing?.valueField2 ? { valueField2: existing.valueField2 } : {};
|
|
67638
|
-
const nextAggregation = {
|
|
67639
|
-
...preservedValueField2,
|
|
67640
|
-
aggregationType,
|
|
67641
|
-
...normalizedSelection.valueField ? { valueField: normalizedSelection.valueField } : {},
|
|
67642
|
-
...normalizedSelection.valueField2 ? { valueField2: normalizedSelection.valueField2 } : {},
|
|
67643
|
-
...normalizedSelection.table ? { valueFieldTable: normalizedSelection.table } : {}
|
|
67644
|
-
};
|
|
67645
|
-
if (index === next.aggregationState.length) {
|
|
67646
|
-
next.aggregationState.push(nextAggregation);
|
|
67647
|
-
next.aggregationTablesByIndex.push(
|
|
67648
|
-
normalizedSelection.table || void 0
|
|
67649
|
-
);
|
|
67650
|
-
} else {
|
|
67651
|
-
next.aggregationState[index] = nextAggregation;
|
|
67652
|
-
next.aggregationTablesByIndex[index] = normalizedSelection.table || void 0;
|
|
67653
|
-
}
|
|
67654
|
-
}
|
|
67655
|
-
}
|
|
67656
|
-
} else if (typeof effectiveNextState.aggregations === "string") {
|
|
67494
|
+
if (typeof effectiveNextState.aggregations === "string") {
|
|
67657
67495
|
const rawValue = effectiveNextState.aggregations.trim();
|
|
67658
67496
|
if (!rawValue) {
|
|
67659
67497
|
next.aggregationState = [];
|
|
@@ -67685,15 +67523,49 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67685
67523
|
];
|
|
67686
67524
|
}
|
|
67687
67525
|
} else {
|
|
67688
|
-
|
|
67689
|
-
|
|
67690
|
-
|
|
67691
|
-
|
|
67692
|
-
|
|
67693
|
-
|
|
67694
|
-
|
|
67695
|
-
|
|
67526
|
+
const decoded = effectiveNextState.aggregations.map(
|
|
67527
|
+
(aggregation) => {
|
|
67528
|
+
if (typeof aggregation !== "string") {
|
|
67529
|
+
return {
|
|
67530
|
+
aggregation,
|
|
67531
|
+
table: String(aggregation.valueFieldTable ?? "").trim() || resolveFieldTable({
|
|
67532
|
+
report: sourceReport,
|
|
67533
|
+
field: aggregation.valueField,
|
|
67534
|
+
schemaTables: schemaForReportBuilderState,
|
|
67535
|
+
preferredTables
|
|
67536
|
+
}) || void 0
|
|
67537
|
+
};
|
|
67538
|
+
}
|
|
67539
|
+
const rawValue = aggregation.trim();
|
|
67540
|
+
if (!rawValue) {
|
|
67541
|
+
return { aggregation: { valueField: "" }, table: void 0 };
|
|
67542
|
+
}
|
|
67543
|
+
const [aggregationTypeRaw] = rawValue.split(":");
|
|
67544
|
+
const aggregationType = aggregationTypeRaw;
|
|
67545
|
+
const { field: target, table: table2 } = resolveAggregationSelection(
|
|
67546
|
+
rawValue,
|
|
67547
|
+
aggregationOptionTableLookup,
|
|
67548
|
+
preferredTables
|
|
67549
|
+
);
|
|
67550
|
+
const normalizedSelection = normalizeAggregationSelection(
|
|
67551
|
+
aggregationType,
|
|
67552
|
+
target,
|
|
67553
|
+
table2,
|
|
67554
|
+
preferredTables
|
|
67555
|
+
);
|
|
67556
|
+
return {
|
|
67557
|
+
aggregation: {
|
|
67558
|
+
aggregationType,
|
|
67559
|
+
...normalizedSelection.valueField ? { valueField: normalizedSelection.valueField } : {},
|
|
67560
|
+
...normalizedSelection.valueField2 ? { valueField2: normalizedSelection.valueField2 } : {},
|
|
67561
|
+
...normalizedSelection.table ? { valueFieldTable: normalizedSelection.table } : {}
|
|
67562
|
+
},
|
|
67563
|
+
table: normalizedSelection.table || void 0
|
|
67564
|
+
};
|
|
67565
|
+
}
|
|
67696
67566
|
);
|
|
67567
|
+
next.aggregationState = decoded.map((entry) => entry.aggregation);
|
|
67568
|
+
next.aggregationTablesByIndex = decoded.map((entry) => entry.table);
|
|
67697
67569
|
}
|
|
67698
67570
|
}
|
|
67699
67571
|
if (effectiveNextState.sort !== void 0) {
|
|
@@ -67808,29 +67680,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67808
67680
|
}
|
|
67809
67681
|
});
|
|
67810
67682
|
};
|
|
67811
|
-
const
|
|
67812
|
-
|
|
67813
|
-
|
|
67814
|
-
byId: tableColumnById,
|
|
67815
|
-
columnList: tableColumnList,
|
|
67816
|
-
getSetReportColumns: (ids) => {
|
|
67817
|
-
const out = [];
|
|
67818
|
-
for (const rawId of ids) {
|
|
67819
|
-
const id = String(rawId ?? "").trim();
|
|
67820
|
-
if (!id) continue;
|
|
67821
|
-
const option = columnOptionById.get(id);
|
|
67822
|
-
if (!option) continue;
|
|
67823
|
-
const item = tableColumnById.get(id);
|
|
67824
|
-
const customLabel = String(item?.customLabel ?? "").trim();
|
|
67825
|
-
const format9 = String(item?.format ?? "").trim();
|
|
67826
|
-
out.push({
|
|
67827
|
-
field: option.field,
|
|
67828
|
-
...option.tableName ? { table: option.tableName } : {},
|
|
67829
|
-
...customLabel ? { label: customLabel } : {},
|
|
67830
|
-
...format9 ? { format: format9 } : {}
|
|
67831
|
-
});
|
|
67832
|
-
}
|
|
67833
|
-
return out;
|
|
67683
|
+
const columnActions = {
|
|
67684
|
+
replace: (nextColumns) => {
|
|
67685
|
+
applyReportChange({ columns: nextColumns });
|
|
67834
67686
|
},
|
|
67835
67687
|
reorder: (oldIndex, newIndex) => {
|
|
67836
67688
|
if (loading || isPivotTableChart) return;
|
|
@@ -67894,21 +67746,15 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67894
67746
|
setTableColumnsEditedSignature(tableDerivedColumnOrderSignature);
|
|
67895
67747
|
commitTableColumns(nextColumnIds, tableColumnSettingsById);
|
|
67896
67748
|
},
|
|
67897
|
-
getColumnSidebarSetReportInput: (id, updates) => {
|
|
67898
|
-
const normalizedId = String(id ?? "").trim();
|
|
67899
|
-
if (!normalizedId) return null;
|
|
67900
|
-
return {
|
|
67901
|
-
columns: { patch: { id: normalizedId, ...updates } }
|
|
67902
|
-
};
|
|
67903
|
-
},
|
|
67904
67749
|
update: (id, updates) => {
|
|
67905
67750
|
const normalizedId = String(id ?? "").trim();
|
|
67906
67751
|
if (!normalizedId) return;
|
|
67907
|
-
|
|
67908
|
-
|
|
67752
|
+
const expanded = buildColumnSidebarSetReportInput({
|
|
67753
|
+
id: normalizedId,
|
|
67754
|
+
...updates
|
|
67909
67755
|
});
|
|
67910
|
-
|
|
67911
|
-
|
|
67756
|
+
if (expanded) applyReportChange(expanded);
|
|
67757
|
+
}
|
|
67912
67758
|
};
|
|
67913
67759
|
const setFilters = (nextFilters) => {
|
|
67914
67760
|
const preparedForStack = prepareQueryBuilderFiltersForSet(
|
|
@@ -67966,13 +67812,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
67966
67812
|
}
|
|
67967
67813
|
}
|
|
67968
67814
|
};
|
|
67969
|
-
const
|
|
67970
|
-
reportId: effectiveReportId,
|
|
67971
|
-
committedFilters: filtersForQueryBuilder,
|
|
67972
|
-
queryBuilderProps: filterQueryBuilderProps,
|
|
67973
|
-
setFilters
|
|
67974
|
-
});
|
|
67975
|
-
const saveChanges = useCallback6(async () => {
|
|
67815
|
+
const saveChanges = useCallback5(async () => {
|
|
67976
67816
|
if (!client) return;
|
|
67977
67817
|
if (!String(dashboardNameForNewReport ?? "").trim()) return;
|
|
67978
67818
|
if (!sourceReport) return;
|
|
@@ -68050,17 +67890,23 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68050
67890
|
groupRowsByOptions,
|
|
68051
67891
|
groupColumnsBy,
|
|
68052
67892
|
groupColumnsByOptions,
|
|
68053
|
-
|
|
67893
|
+
dateBucket,
|
|
67894
|
+
dateBucketOptions: PIVOT_DATE_BUCKET_OPTIONS,
|
|
67895
|
+
/** Encoded selection per aggregation slot (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
|
|
67896
|
+
aggregations: aggregationValues,
|
|
67897
|
+
/** Flat aggregation pick list shared by all slots; always contains every non-empty `aggregations` entry. */
|
|
68054
67898
|
aggregationOptions,
|
|
68055
67899
|
aggregationDescriptionOptions: cleanedAggregations,
|
|
68056
67900
|
sort: cleanedSort,
|
|
68057
67901
|
sortOptions,
|
|
68058
67902
|
chartType,
|
|
68059
67903
|
chartTypeOptions: chartTypes,
|
|
68060
|
-
/**
|
|
68061
|
-
|
|
68062
|
-
/**
|
|
68063
|
-
|
|
67904
|
+
/** Selected tabular columns in display order. */
|
|
67905
|
+
columns: tableColumnValues,
|
|
67906
|
+
/** Pivot table columns only allow label and format changes. */
|
|
67907
|
+
columnStructureEditsLocked: isPivotTableChart,
|
|
67908
|
+
/** Optional rich operations; simple selection updates use `setReport({ columns })`. */
|
|
67909
|
+
columnActions,
|
|
68064
67910
|
/** Schema columns for current datasources — pool for the table column picker. */
|
|
68065
67911
|
columnOptions: tableColumnPickerPoolOptions,
|
|
68066
67912
|
xAxis: chartAxes.xAxis,
|
|
@@ -68087,13 +67933,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68087
67933
|
hasTableDrivenColumnOrder,
|
|
68088
67934
|
filters: filtersForQueryBuilder,
|
|
68089
67935
|
filterQueryBuilderProps,
|
|
68090
|
-
/**
|
|
68091
|
-
* Draft → Apply lifecycle for react-querybuilder (flat keys):
|
|
68092
|
-
* `<QueryBuilder key={filterDraftKey} {...filterDraftQueryBuilderProps} />`
|
|
68093
|
-
* plus `isFilterDraftDirty` / `isFilterDraftEmpty` /
|
|
68094
|
-
* `commitFilterDraft` / `resetFilterDraft` / `seedFilterDraft`.
|
|
68095
|
-
*/
|
|
68096
|
-
...filterDraft,
|
|
68097
67936
|
/** True while `report-builder-unique-values` runs for filter value options (not chart/table load). */
|
|
68098
67937
|
filterUniqueValuesLoading,
|
|
68099
67938
|
limit,
|
|
@@ -68101,7 +67940,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68101
67940
|
chartTypes,
|
|
68102
67941
|
columnsOptions: tableColumnPickerPoolOptions,
|
|
68103
67942
|
tableColumnOptions: tableColumnPickerPoolOptions,
|
|
68104
|
-
tableColumns,
|
|
68105
67943
|
setReport,
|
|
68106
67944
|
saveChanges,
|
|
68107
67945
|
setFilters,
|
|
@@ -68119,7 +67957,7 @@ function ChatChartCard({
|
|
|
68119
67957
|
ButtonComponent = MemoizedButton
|
|
68120
67958
|
}) {
|
|
68121
67959
|
const {
|
|
68122
|
-
|
|
67960
|
+
columns,
|
|
68123
67961
|
columnOptions,
|
|
68124
67962
|
groupRowsBy,
|
|
68125
67963
|
groupRowsByOptions,
|
|
@@ -68133,20 +67971,10 @@ function ChatChartCard({
|
|
|
68133
67971
|
loading,
|
|
68134
67972
|
setReport
|
|
68135
67973
|
} = useReport(reportId);
|
|
68136
|
-
const
|
|
68137
|
-
|
|
68138
|
-
|
|
68139
|
-
|
|
68140
|
-
const tableName = String(option?.tableName ?? "").trim();
|
|
68141
|
-
const fieldName = String(option?.field ?? "").trim() || String(option?.label ?? "").trim() || value;
|
|
68142
|
-
return {
|
|
68143
|
-
value,
|
|
68144
|
-
label: tableName ? `${tableName}.${fieldName}` : fieldName
|
|
68145
|
-
};
|
|
68146
|
-
}).filter(
|
|
68147
|
-
(option) => Boolean(option)
|
|
68148
|
-
);
|
|
68149
|
-
}, [columnOptions]);
|
|
67974
|
+
const selectedColumnValues = useMemo33(
|
|
67975
|
+
() => columns.map((column) => column.value),
|
|
67976
|
+
[columns]
|
|
67977
|
+
);
|
|
68150
67978
|
return /* @__PURE__ */ jsxs64(
|
|
68151
67979
|
"div",
|
|
68152
67980
|
{
|
|
@@ -68182,7 +68010,7 @@ function ChatChartCard({
|
|
|
68182
68010
|
padding: 16
|
|
68183
68011
|
},
|
|
68184
68012
|
children: [
|
|
68185
|
-
JSON.stringify(
|
|
68013
|
+
JSON.stringify(columns, null, 2),
|
|
68186
68014
|
/* @__PURE__ */ jsxs64(
|
|
68187
68015
|
"label",
|
|
68188
68016
|
{
|
|
@@ -68199,13 +68027,24 @@ function ChatChartCard({
|
|
|
68199
68027
|
"select",
|
|
68200
68028
|
{
|
|
68201
68029
|
multiple: true,
|
|
68202
|
-
size: Math.min(10, Math.max(4,
|
|
68203
|
-
value:
|
|
68030
|
+
size: Math.min(10, Math.max(4, columnOptions.length || 4)),
|
|
68031
|
+
value: selectedColumnValues,
|
|
68204
68032
|
onChange: (event) => {
|
|
68205
|
-
const
|
|
68206
|
-
(
|
|
68033
|
+
const selectedByValue = new Map(
|
|
68034
|
+
columns.map((column) => [column.value, column])
|
|
68035
|
+
);
|
|
68036
|
+
const optionByValue = new Map(
|
|
68037
|
+
columnOptions.map((option) => [option.value, option])
|
|
68207
68038
|
);
|
|
68208
|
-
setReport({
|
|
68039
|
+
setReport({
|
|
68040
|
+
columns: Array.from(event.target.selectedOptions).map(
|
|
68041
|
+
(selectedOption) => selectedByValue.get(selectedOption.value) ?? {
|
|
68042
|
+
value: selectedOption.value,
|
|
68043
|
+
label: optionByValue.get(selectedOption.value)?.label ?? selectedOption.value,
|
|
68044
|
+
format: ""
|
|
68045
|
+
}
|
|
68046
|
+
)
|
|
68047
|
+
});
|
|
68209
68048
|
},
|
|
68210
68049
|
style: {
|
|
68211
68050
|
width: 200,
|
|
@@ -68215,7 +68054,7 @@ function ChatChartCard({
|
|
|
68215
68054
|
padding: 8,
|
|
68216
68055
|
background: "#fff"
|
|
68217
68056
|
},
|
|
68218
|
-
children:
|
|
68057
|
+
children: columnOptions.map((option) => /* @__PURE__ */ jsx87("option", { value: option.value, children: option.label }, option.value))
|
|
68219
68058
|
}
|
|
68220
68059
|
)
|
|
68221
68060
|
]
|
|
@@ -68241,28 +68080,27 @@ function ChatChartCard({
|
|
|
68241
68080
|
onChange: (e) => setReport({ groupColumnsBy: e.target.value ?? "" })
|
|
68242
68081
|
}
|
|
68243
68082
|
),
|
|
68244
|
-
|
|
68083
|
+
aggregations.map((value, index) => /* @__PURE__ */ jsx87(
|
|
68245
68084
|
SelectComponent,
|
|
68246
68085
|
{
|
|
68247
|
-
value
|
|
68248
|
-
label:
|
|
68086
|
+
value,
|
|
68087
|
+
label: `Aggregation ${index + 1}`,
|
|
68249
68088
|
width: 200,
|
|
68250
|
-
options:
|
|
68089
|
+
options: aggregationOptions,
|
|
68251
68090
|
onChange: (e) => setReport({
|
|
68252
|
-
aggregations:
|
|
68091
|
+
aggregations: aggregations.map(
|
|
68092
|
+
(aggregation, i) => i === index ? e.target.value ?? "" : aggregation
|
|
68093
|
+
)
|
|
68253
68094
|
})
|
|
68254
68095
|
},
|
|
68255
|
-
|
|
68096
|
+
`aggregation-${index}`
|
|
68256
68097
|
)),
|
|
68257
68098
|
/* @__PURE__ */ jsx87(
|
|
68258
68099
|
ButtonComponent,
|
|
68259
68100
|
{
|
|
68260
68101
|
label: "Add aggregation",
|
|
68261
68102
|
onClick: () => setReport({
|
|
68262
|
-
aggregations:
|
|
68263
|
-
index: aggregations.length,
|
|
68264
|
-
value: "count transactions"
|
|
68265
|
-
}
|
|
68103
|
+
aggregations: [...aggregations, "count:transactions"]
|
|
68266
68104
|
})
|
|
68267
68105
|
}
|
|
68268
68106
|
),
|
|
@@ -68400,7 +68238,7 @@ function ToolCallBlock({ toolCall }) {
|
|
|
68400
68238
|
);
|
|
68401
68239
|
}
|
|
68402
68240
|
function ToolCallResult({ content }) {
|
|
68403
|
-
const [expanded, setExpanded] =
|
|
68241
|
+
const [expanded, setExpanded] = useState42(false);
|
|
68404
68242
|
if (!content) return null;
|
|
68405
68243
|
const isLong = content.length > 300;
|
|
68406
68244
|
const displayed = isLong && !expanded ? content.slice(0, 300) + "..." : content;
|
|
@@ -68455,14 +68293,14 @@ function Chat({
|
|
|
68455
68293
|
const [client] = useContext37(ClientContext);
|
|
68456
68294
|
const { getToken } = useContext37(FetchContext);
|
|
68457
68295
|
const { tenants } = useContext37(TenantContext);
|
|
68458
|
-
const [messages, setMessages] =
|
|
68459
|
-
const [input, setInput] =
|
|
68460
|
-
const [inputError, setInputError] =
|
|
68461
|
-
const [isLoading, setIsLoading] =
|
|
68462
|
-
const [model, setModel] =
|
|
68463
|
-
const containerRef =
|
|
68464
|
-
const textareaRef =
|
|
68465
|
-
const abortControllerRef =
|
|
68296
|
+
const [messages, setMessages] = useState42([]);
|
|
68297
|
+
const [input, setInput] = useState42("");
|
|
68298
|
+
const [inputError, setInputError] = useState42("");
|
|
68299
|
+
const [isLoading, setIsLoading] = useState42(false);
|
|
68300
|
+
const [model, setModel] = useState42("gemini-3-flash-preview");
|
|
68301
|
+
const containerRef = useRef25(null);
|
|
68302
|
+
const textareaRef = useRef25(null);
|
|
68303
|
+
const abortControllerRef = useRef25(null);
|
|
68466
68304
|
useEffect32(() => {
|
|
68467
68305
|
if (!containerRef.current) {
|
|
68468
68306
|
return;
|
|
@@ -68896,6 +68734,150 @@ function Chat({
|
|
|
68896
68734
|
);
|
|
68897
68735
|
}
|
|
68898
68736
|
|
|
68737
|
+
// src/hooks/useReportFilterDraft.ts
|
|
68738
|
+
import { useCallback as useCallback6, useMemo as useMemo34, useRef as useRef26, useState as useState43 } from "react";
|
|
68739
|
+
var normalizeOperatorKey = (operator) => String(operator ?? "").trim().toLowerCase().replace(/[_\s]+/g, "");
|
|
68740
|
+
var defaultFilterRuleValueForOperator = (operator) => {
|
|
68741
|
+
const key = normalizeOperatorKey(operator);
|
|
68742
|
+
if (key === "in" || key === "notin") {
|
|
68743
|
+
return [];
|
|
68744
|
+
}
|
|
68745
|
+
return "";
|
|
68746
|
+
};
|
|
68747
|
+
var EMPTY_COMMITTED_FILTERS = {
|
|
68748
|
+
combinator: "and",
|
|
68749
|
+
rules: []
|
|
68750
|
+
};
|
|
68751
|
+
var hashString2 = (input) => {
|
|
68752
|
+
let hash = 2166136261;
|
|
68753
|
+
for (let i = 0; i < input.length; i++) {
|
|
68754
|
+
hash ^= input.charCodeAt(i);
|
|
68755
|
+
hash = Math.imul(hash, 16777619);
|
|
68756
|
+
}
|
|
68757
|
+
return String(hash >>> 0);
|
|
68758
|
+
};
|
|
68759
|
+
var fieldCatalogSignature = (fields) => {
|
|
68760
|
+
const names = fields.map((field) => String(field.name ?? "").trim()).filter(Boolean).sort();
|
|
68761
|
+
return `${names.length}:${hashString2(names.join("\0"))}`;
|
|
68762
|
+
};
|
|
68763
|
+
var committedFiltersSignature = (committed) => {
|
|
68764
|
+
try {
|
|
68765
|
+
return hashString2(
|
|
68766
|
+
JSON.stringify(stripQueryBuilderTransientFields(committed))
|
|
68767
|
+
);
|
|
68768
|
+
} catch {
|
|
68769
|
+
return "unserializable";
|
|
68770
|
+
}
|
|
68771
|
+
};
|
|
68772
|
+
function useReportFilterDraft(args) {
|
|
68773
|
+
const { reportId, committedFilters, queryBuilderProps, setFilters } = args;
|
|
68774
|
+
const committed = isQueryBuilderDisplayGroup(committedFilters) ? committedFilters : EMPTY_COMMITTED_FILTERS;
|
|
68775
|
+
const committedRef = useRef26(committed);
|
|
68776
|
+
committedRef.current = committed;
|
|
68777
|
+
const setFiltersRef = useRef26(setFilters);
|
|
68778
|
+
setFiltersRef.current = setFilters;
|
|
68779
|
+
const lastNonEmptyFieldsRef = useRef26([]);
|
|
68780
|
+
const prevReportIdForFieldsRef = useRef26(reportId);
|
|
68781
|
+
if (prevReportIdForFieldsRef.current !== reportId) {
|
|
68782
|
+
prevReportIdForFieldsRef.current = reportId;
|
|
68783
|
+
lastNonEmptyFieldsRef.current = [];
|
|
68784
|
+
}
|
|
68785
|
+
if (queryBuilderProps.fields.length > 0) {
|
|
68786
|
+
lastNonEmptyFieldsRef.current = queryBuilderProps.fields;
|
|
68787
|
+
}
|
|
68788
|
+
const effectiveFields = queryBuilderProps.fields.length > 0 ? queryBuilderProps.fields : lastNonEmptyFieldsRef.current;
|
|
68789
|
+
const committedSignature = useMemo34(
|
|
68790
|
+
() => committedFiltersSignature(committed),
|
|
68791
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `committed` normalizes null to a stable constant
|
|
68792
|
+
[committedFilters]
|
|
68793
|
+
);
|
|
68794
|
+
const fieldsSignature = useMemo34(
|
|
68795
|
+
() => fieldCatalogSignature(effectiveFields),
|
|
68796
|
+
[effectiveFields]
|
|
68797
|
+
);
|
|
68798
|
+
const [resetEpoch, setResetEpoch] = useState43(0);
|
|
68799
|
+
const [draftQuery, setDraftQuery] = useState43(committed);
|
|
68800
|
+
const [hasUnappliedFilterChanges, setHasUnappliedFilterChanges] = useState43(false);
|
|
68801
|
+
const draftResetKey = `${reportId}|${committedSignature}|${resetEpoch}`;
|
|
68802
|
+
const prevDraftResetKeyRef = useRef26(draftResetKey);
|
|
68803
|
+
if (prevDraftResetKeyRef.current !== draftResetKey) {
|
|
68804
|
+
prevDraftResetKeyRef.current = draftResetKey;
|
|
68805
|
+
setDraftQuery(committed);
|
|
68806
|
+
if (hasUnappliedFilterChanges) setHasUnappliedFilterChanges(false);
|
|
68807
|
+
}
|
|
68808
|
+
const filterDraftKey = `${draftResetKey}|${fieldsSignature}`;
|
|
68809
|
+
const handleQueryChange = useCallback6((next) => {
|
|
68810
|
+
if (!isQueryBuilderDisplayGroup(next)) return;
|
|
68811
|
+
const nextGroup = next;
|
|
68812
|
+
setDraftQuery(nextGroup);
|
|
68813
|
+
const nextDirty = areQueryBuilderFilterDraftsDirty(
|
|
68814
|
+
nextGroup,
|
|
68815
|
+
committedRef.current
|
|
68816
|
+
);
|
|
68817
|
+
setHasUnappliedFilterChanges(
|
|
68818
|
+
(prev) => prev === nextDirty ? prev : nextDirty
|
|
68819
|
+
);
|
|
68820
|
+
}, []);
|
|
68821
|
+
const applyFilterDraft = useCallback6(() => {
|
|
68822
|
+
setFiltersRef.current(draftQuery);
|
|
68823
|
+
}, [draftQuery]);
|
|
68824
|
+
const resetFilterDraft = useCallback6(() => {
|
|
68825
|
+
setDraftQuery(committedRef.current);
|
|
68826
|
+
setHasUnappliedFilterChanges(false);
|
|
68827
|
+
setResetEpoch((epoch) => epoch + 1);
|
|
68828
|
+
}, []);
|
|
68829
|
+
const getDefaultValue = useCallback6(
|
|
68830
|
+
(rule) => defaultFilterRuleValueForOperator(rule?.operator),
|
|
68831
|
+
[]
|
|
68832
|
+
);
|
|
68833
|
+
const filterDraftQueryBuilderProps = useMemo34(
|
|
68834
|
+
() => ({
|
|
68835
|
+
...queryBuilderProps,
|
|
68836
|
+
fields: effectiveFields,
|
|
68837
|
+
// Uncontrolled: react-querybuilder owns the draft; only read at mount,
|
|
68838
|
+
// while state keeps the next mount hydrated from the latest edits.
|
|
68839
|
+
defaultQuery: draftQuery,
|
|
68840
|
+
onQueryChange: handleQueryChange,
|
|
68841
|
+
addRuleToNewGroups: true,
|
|
68842
|
+
getDefaultValue
|
|
68843
|
+
}),
|
|
68844
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- filterDraftKey covers draftRef resets
|
|
68845
|
+
[
|
|
68846
|
+
queryBuilderProps,
|
|
68847
|
+
effectiveFields,
|
|
68848
|
+
draftQuery,
|
|
68849
|
+
handleQueryChange,
|
|
68850
|
+
getDefaultValue,
|
|
68851
|
+
filterDraftKey
|
|
68852
|
+
]
|
|
68853
|
+
);
|
|
68854
|
+
return {
|
|
68855
|
+
filterDraftKey,
|
|
68856
|
+
filterDraftQueryBuilderProps,
|
|
68857
|
+
hasUnappliedFilterChanges,
|
|
68858
|
+
applyFilterDraft,
|
|
68859
|
+
resetFilterDraft
|
|
68860
|
+
};
|
|
68861
|
+
}
|
|
68862
|
+
|
|
68863
|
+
// src/hooks/useReportQueryBuilder.ts
|
|
68864
|
+
function useReportQueryBuilder(args) {
|
|
68865
|
+
const draft = useReportFilterDraft({
|
|
68866
|
+
reportId: args.reportId ?? "",
|
|
68867
|
+
committedFilters: args.filters,
|
|
68868
|
+
queryBuilderProps: args.queryBuilderProps,
|
|
68869
|
+
setFilters: args.onApply
|
|
68870
|
+
});
|
|
68871
|
+
return {
|
|
68872
|
+
key: draft.filterDraftKey,
|
|
68873
|
+
props: draft.filterDraftQueryBuilderProps,
|
|
68874
|
+
hasUnappliedChanges: draft.hasUnappliedFilterChanges,
|
|
68875
|
+
apply: draft.applyFilterDraft,
|
|
68876
|
+
discard: draft.resetFilterDraft,
|
|
68877
|
+
reset: draft.resetFilterDraft
|
|
68878
|
+
};
|
|
68879
|
+
}
|
|
68880
|
+
|
|
68899
68881
|
// src/ReportDetail.tsx
|
|
68900
68882
|
import {
|
|
68901
68883
|
useContext as useContext38,
|
|
@@ -70030,7 +70012,6 @@ export {
|
|
|
70030
70012
|
Table_default as Table,
|
|
70031
70013
|
ThemeContext,
|
|
70032
70014
|
areQueryBuilderFilterDraftsDirty,
|
|
70033
|
-
buildSeededFilterQuery,
|
|
70034
70015
|
countFilterRules,
|
|
70035
70016
|
defaultFilterRuleValueForOperator,
|
|
70036
70017
|
downloadCSV,
|
|
@@ -70055,6 +70036,7 @@ export {
|
|
|
70055
70036
|
useQuill,
|
|
70056
70037
|
useReport,
|
|
70057
70038
|
useReportBuilder,
|
|
70039
|
+
useReportQueryBuilder,
|
|
70058
70040
|
useReports,
|
|
70059
70041
|
useTenants,
|
|
70060
70042
|
useVirtualTables
|