@economic/taco 2.55.1-footer.0 → 2.57.0-charts.0
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/taco.cjs +637 -486
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.css +12 -6
- package/dist/taco.d.ts +112 -72
- package/dist/taco.js +637 -486
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
package/dist/taco.cjs
CHANGED
@@ -19628,8 +19628,8 @@ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOn
|
|
19628
19628
|
}
|
19629
19629
|
for (var i3 = 0; i3 < numBorders; i3++) {
|
19630
19630
|
var borderLabel = "border".concat(borders[i3], "Radius");
|
19631
|
-
var followRadius = getRadius(follow, borderLabel);
|
19632
|
-
var leadRadius = getRadius(lead, borderLabel);
|
19631
|
+
var followRadius = getRadius$1(follow, borderLabel);
|
19632
|
+
var leadRadius = getRadius$1(lead, borderLabel);
|
19633
19633
|
if (followRadius === void 0 && leadRadius === void 0)
|
19634
19634
|
continue;
|
19635
19635
|
followRadius || (followRadius = 0);
|
@@ -19648,7 +19648,7 @@ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOn
|
|
19648
19648
|
target.rotate = mix(follow.rotate || 0, lead.rotate || 0, progress2);
|
19649
19649
|
}
|
19650
19650
|
}
|
19651
|
-
function getRadius(values, radiusName) {
|
19651
|
+
function getRadius$1(values, radiusName) {
|
19652
19652
|
var _a;
|
19653
19653
|
return (_a = values[radiusName]) !== null && _a !== void 0 ? _a : values.borderRadius;
|
19654
19654
|
}
|
@@ -32012,10 +32012,9 @@ function useTableDataLoader(fetchPage, fetchAll, options = { pageSize: DEFAULT_P
|
|
32012
32012
|
const _lastUsedSearch = React.useRef();
|
32013
32013
|
const _lastUsedHiddenColumns = React.useRef([]);
|
32014
32014
|
const _lastUsedPageIndex = React.useRef();
|
32015
|
-
const _forceReset = React.useRef(false);
|
32016
32015
|
const loadPage = async (pageIndex, sorting, filters, hiddenColumns) => {
|
32017
32016
|
let reset = false;
|
32018
|
-
if (
|
32017
|
+
if (JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
|
32019
32018
|
_pendingPageRequests.current = {};
|
32020
32019
|
reset = true;
|
32021
32020
|
}
|
@@ -32024,7 +32023,6 @@ function useTableDataLoader(fetchPage, fetchAll, options = { pageSize: DEFAULT_P
|
|
32024
32023
|
} else {
|
32025
32024
|
_pendingPageRequests.current[pageIndex] = true;
|
32026
32025
|
}
|
32027
|
-
_forceReset.current = false;
|
32028
32026
|
_lastUsedPageIndex.current = pageIndex;
|
32029
32027
|
_lastUsedSorting.current = sorting;
|
32030
32028
|
_lastUsedFilters.current = filters;
|
@@ -32068,12 +32066,41 @@ function useTableDataLoader(fetchPage, fetchAll, options = { pageSize: DEFAULT_P
|
|
32068
32066
|
} catch {
|
32069
32067
|
}
|
32070
32068
|
};
|
32069
|
+
const reloadCurrentPages = async (pageIndex, sorting, filters, hiddenColumns) => {
|
32070
|
+
_lastUsedPageIndex.current;
|
32071
|
+
const pageIndexes = pageIndex === 0 ? [0, 1] : [pageIndex - 1, pageIndex];
|
32072
|
+
if (length.current !== void 0) {
|
32073
|
+
const pageCount = Math.ceil(length.current / pageSize);
|
32074
|
+
if (pageIndex + 1 < pageCount) {
|
32075
|
+
pageIndexes.push(pageIndex + 1);
|
32076
|
+
}
|
32077
|
+
}
|
32078
|
+
_pendingPageRequests.current = pageIndexes.reduce((accum, index2) => ({ ...accum, [index2]: true }), {});
|
32079
|
+
_lastUsedPageIndex.current = pageIndex;
|
32080
|
+
_lastUsedSorting.current = sorting;
|
32081
|
+
_lastUsedFilters.current = filters;
|
32082
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
32083
|
+
try {
|
32084
|
+
const responses = await Promise.all(
|
32085
|
+
pageIndexes.map((pageIndex2) => fetchPage(pageIndex2, pageSize, sorting, filters, hiddenColumns))
|
32086
|
+
);
|
32087
|
+
length.current = responses[0].length;
|
32088
|
+
const nextData = Array(length.current).fill(void 0);
|
32089
|
+
responses.forEach((response, index2) => {
|
32090
|
+
const startIndex = pageIndexes[index2] * pageSize;
|
32091
|
+
nextData.splice(startIndex, pageSize, ...response.data);
|
32092
|
+
});
|
32093
|
+
setData(nextData);
|
32094
|
+
} catch {
|
32095
|
+
} finally {
|
32096
|
+
_pendingPageRequests.current = {};
|
32097
|
+
}
|
32098
|
+
};
|
32071
32099
|
const invalidate = async () => {
|
32072
|
-
_forceReset.current = true;
|
32073
32100
|
if (_lastUsedSearch.current) {
|
32074
32101
|
return loadAll(_lastUsedSorting.current, _lastUsedFilters.current, _lastUsedHiddenColumns.current);
|
32075
32102
|
} else {
|
32076
|
-
return
|
32103
|
+
return reloadCurrentPages(
|
32077
32104
|
_lastUsedPageIndex.current ?? 0,
|
32078
32105
|
_lastUsedSorting.current,
|
32079
32106
|
_lastUsedFilters.current,
|
@@ -32085,7 +32112,12 @@ function useTableDataLoader(fetchPage, fetchAll, options = { pageSize: DEFAULT_P
|
|
32085
32112
|
if (_lastUsedSearch.current) {
|
32086
32113
|
return loadAll(sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);
|
32087
32114
|
} else {
|
32088
|
-
return
|
32115
|
+
return reloadCurrentPages(
|
32116
|
+
_lastUsedPageIndex.current ?? 0,
|
32117
|
+
sorting,
|
32118
|
+
_lastUsedFilters.current,
|
32119
|
+
_lastUsedHiddenColumns.current
|
32120
|
+
);
|
32089
32121
|
}
|
32090
32122
|
};
|
32091
32123
|
const handleFilter = async (filters) => {
|
@@ -32379,9 +32411,10 @@ function useTableSettingsListener(table, onChangeSettings) {
|
|
32379
32411
|
state.sorting
|
32380
32412
|
]);
|
32381
32413
|
}
|
32382
|
-
function useTableShortcutsListener(table, shortcuts) {
|
32414
|
+
function useTableShortcutsListener(table, tableRef, shortcuts, localShortcuts = false) {
|
32383
32415
|
const meta = table.options.meta;
|
32384
32416
|
const rows = table.getRowModel().rows;
|
32417
|
+
const listenerTarget = localShortcuts ? tableRef.current : document;
|
32385
32418
|
React.useEffect(() => {
|
32386
32419
|
const shortcutKeys = Object.keys(shortcuts ?? {});
|
32387
32420
|
const globalHandlers = [];
|
@@ -32414,18 +32447,38 @@ function useTableShortcutsListener(table, shortcuts) {
|
|
32414
32447
|
});
|
32415
32448
|
}
|
32416
32449
|
globalHandlers.forEach((handler) => {
|
32417
|
-
|
32450
|
+
listenerTarget == null ? void 0 : listenerTarget.addEventListener("keydown", handler);
|
32418
32451
|
});
|
32419
32452
|
return () => {
|
32420
32453
|
globalHandlers.forEach((handler) => {
|
32421
|
-
|
32454
|
+
listenerTarget == null ? void 0 : listenerTarget.removeEventListener("keydown", handler);
|
32422
32455
|
});
|
32423
32456
|
};
|
32424
32457
|
}, [shortcuts, meta.rowActive.rowActiveIndex, rows.length]);
|
32425
32458
|
}
|
32459
|
+
function useLazyDebouncedEffect(effect, deps, ms = 200) {
|
32460
|
+
const readyRef = React.useRef(false);
|
32461
|
+
const timeoutRef = React.useRef();
|
32462
|
+
React.useEffect(() => {
|
32463
|
+
if (readyRef.current) {
|
32464
|
+
timeoutRef.current = setTimeout(effect, ms);
|
32465
|
+
} else {
|
32466
|
+
readyRef.current = true;
|
32467
|
+
}
|
32468
|
+
return () => {
|
32469
|
+
clearTimeout(timeoutRef.current);
|
32470
|
+
};
|
32471
|
+
}, deps);
|
32472
|
+
React.useEffect(
|
32473
|
+
() => () => {
|
32474
|
+
readyRef.current = false;
|
32475
|
+
},
|
32476
|
+
[]
|
32477
|
+
);
|
32478
|
+
}
|
32426
32479
|
function useTableSortingListener$1(table, onSort) {
|
32427
32480
|
const sorting = table.getState().sorting;
|
32428
|
-
|
32481
|
+
useLazyDebouncedEffect(() => {
|
32429
32482
|
if (table.options.enableSorting && typeof onSort === "function") {
|
32430
32483
|
onSort(sorting);
|
32431
32484
|
if (table.options.enableRowSelection) {
|
@@ -32443,6 +32496,9 @@ function useTableServerLoadingListener(table, loadPage) {
|
|
32443
32496
|
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
32444
32497
|
const search = meta.search.enableGlobalFilter ? table.getState().globalFilter : void 0;
|
32445
32498
|
loadPage(0, sorting, columnFilters, hiddenColumns, search);
|
32499
|
+
if (meta.server._experimentalDataLoader2) {
|
32500
|
+
loadPage(1, sorting, columnFilters, hiddenColumns, search);
|
32501
|
+
}
|
32446
32502
|
}
|
32447
32503
|
}, []);
|
32448
32504
|
}
|
@@ -32462,7 +32518,7 @@ function useTableRowDrop(isEnabled = false, onRowDrop) {
|
|
32462
32518
|
};
|
32463
32519
|
}
|
32464
32520
|
const DEFAULT_EMPTY_ARRAY = [];
|
32465
|
-
function useTableManager(props, meta, internalColumns) {
|
32521
|
+
function useTableManager(props, ref, meta, internalColumns) {
|
32466
32522
|
var _a;
|
32467
32523
|
const localization = useLocalization();
|
32468
32524
|
const safeId = props.id.replace(".", "_");
|
@@ -32561,7 +32617,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
32561
32617
|
useTableSearchListener(instance);
|
32562
32618
|
useTableServerLoadingListener(instance, server.loadPage);
|
32563
32619
|
useTableSettingsListener(instance, setSettings);
|
32564
|
-
useTableShortcutsListener(instance, props.shortcuts);
|
32620
|
+
useTableShortcutsListener(instance, ref, props.shortcuts, props.enableLocalKeyboardShortcuts);
|
32565
32621
|
useTableSortingListener$1(instance, props.onChangeSort);
|
32566
32622
|
return {
|
32567
32623
|
id: safeId,
|
@@ -32751,9 +32807,10 @@ function getCellWidthPadding(fontSize) {
|
|
32751
32807
|
return "16px";
|
32752
32808
|
}
|
32753
32809
|
}
|
32754
|
-
function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
|
32810
|
+
function useTableGlobalShortcuts(table, tableRef, scrollToIndex, localShortcuts = false) {
|
32755
32811
|
const tableMeta = table.options.meta;
|
32756
32812
|
const rows = table.getRowModel().rows;
|
32813
|
+
const listenerTarget = localShortcuts ? tableRef.current : document;
|
32757
32814
|
React.useEffect(
|
32758
32815
|
() => {
|
32759
32816
|
const handleKeyDown = (event) => {
|
@@ -32768,9 +32825,9 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
|
|
32768
32825
|
tableMeta.rowClick.handleKeyDown(event, (_a = rows[tableMeta.rowActive.rowActiveIndex]) == null ? void 0 : _a.original);
|
32769
32826
|
}
|
32770
32827
|
};
|
32771
|
-
|
32828
|
+
listenerTarget == null ? void 0 : listenerTarget.addEventListener("keydown", handleKeyDown);
|
32772
32829
|
return () => {
|
32773
|
-
|
32830
|
+
listenerTarget == null ? void 0 : listenerTarget.removeEventListener("keydown", handleKeyDown);
|
32774
32831
|
};
|
32775
32832
|
},
|
32776
32833
|
// scrollToIndex function changes when row count changes, so it is important to update handlers
|
@@ -33614,7 +33671,7 @@ function RowWithServerLoading(props) {
|
|
33614
33671
|
}
|
33615
33672
|
const Skeleton = React.forwardRef(function Skeleton2(props, ref) {
|
33616
33673
|
const { cellsCount, index: index2 } = props;
|
33617
|
-
return /* @__PURE__ */ React.createElement("tr", { "data-row-index": index2, ref }, Array(cellsCount).fill(null).map((_, index22) => /* @__PURE__ */ React.createElement("td", { key: index22 }, /* @__PURE__ */ React.createElement("span", { className: "bg-grey-100 text-grey-700 h-4 w-full text-center text-xs" }))));
|
33674
|
+
return /* @__PURE__ */ React.createElement("tr", { "data-row-index": index2, "data-row-id": index2, ref }, Array(cellsCount).fill(null).map((_, index22) => /* @__PURE__ */ React.createElement("td", { key: index22 }, /* @__PURE__ */ React.createElement("span", { className: "bg-grey-100 text-grey-700 h-4 w-full text-center text-xs" }))));
|
33618
33675
|
});
|
33619
33676
|
function getScrollPaddingEndOffset(table) {
|
33620
33677
|
const tableMeta = table.options.meta;
|
@@ -34076,7 +34133,7 @@ const INTERNAL_RENDERERS = {
|
|
34076
34133
|
};
|
34077
34134
|
function useTable$1(props, externalRef, renderers, meta, options) {
|
34078
34135
|
const ref = useMergedRef(externalRef);
|
34079
|
-
const manager = useTableManager(props, meta, INTERNAL_RENDERERS);
|
34136
|
+
const manager = useTableManager(props, ref, meta, INTERNAL_RENDERERS);
|
34080
34137
|
const renderer2 = useTableRenderer(
|
34081
34138
|
renderers,
|
34082
34139
|
manager.instance,
|
@@ -34086,7 +34143,7 @@ function useTable$1(props, externalRef, renderers, meta, options) {
|
|
34086
34143
|
options
|
34087
34144
|
);
|
34088
34145
|
const { style, stylesheet } = useTableStyle(manager.id, manager.instance);
|
34089
|
-
useTableGlobalShortcuts(manager.instance, ref, renderer2.scrollToIndex);
|
34146
|
+
useTableGlobalShortcuts(manager.instance, ref, renderer2.scrollToIndex, props.enableLocalKeyboardShortcuts);
|
34090
34147
|
useTableRef(manager.instance, ref);
|
34091
34148
|
useTableRowActiveListener(manager.instance, ref);
|
34092
34149
|
return {
|
@@ -61506,7 +61563,7 @@ var symbolFactories = {
|
|
61506
61563
|
symbolTriangle,
|
61507
61564
|
symbolWye
|
61508
61565
|
};
|
61509
|
-
var RADIAN$
|
61566
|
+
var RADIAN$3 = Math.PI / 180;
|
61510
61567
|
var getSymbolFactory = function getSymbolFactory2(type) {
|
61511
61568
|
var name = "symbol".concat(upperFirst(type));
|
61512
61569
|
return symbolFactories[name] || symbolCircle;
|
@@ -61523,7 +61580,7 @@ var calculateAreaSize = function calculateAreaSize2(size2, sizeType, type) {
|
|
61523
61580
|
case "square":
|
61524
61581
|
return size2 * size2;
|
61525
61582
|
case "star": {
|
61526
|
-
var angle = 18 * RADIAN$
|
61583
|
+
var angle = 18 * RADIAN$3;
|
61527
61584
|
return 1.25 * size2 * size2 * (Math.tan(angle) - Math.tan(angle * 2) * Math.pow(Math.tan(angle), 2));
|
61528
61585
|
}
|
61529
61586
|
case "triangle":
|
@@ -63995,7 +64052,7 @@ function _iterableToArrayLimit$b(r2, l2) {
|
|
63995
64052
|
function _arrayWithHoles$c(arr) {
|
63996
64053
|
if (Array.isArray(arr)) return arr;
|
63997
64054
|
}
|
63998
|
-
var ResponsiveContainer
|
64055
|
+
var ResponsiveContainer = /* @__PURE__ */ React.forwardRef(function(_ref, ref) {
|
63999
64056
|
var aspect = _ref.aspect, _ref$initialDimension = _ref.initialDimension, initialDimension = _ref$initialDimension === void 0 ? {
|
64000
64057
|
width: -1,
|
64001
64058
|
height: -1
|
@@ -69133,7 +69190,7 @@ function _toPrimitive$y(t3, r2) {
|
|
69133
69190
|
}
|
69134
69191
|
return ("string" === r2 ? String : Number)(t3);
|
69135
69192
|
}
|
69136
|
-
var getLegendProps
|
69193
|
+
var getLegendProps = function getLegendProps2(_ref) {
|
69137
69194
|
var children = _ref.children, formattedGraphicalItems = _ref.formattedGraphicalItems, legendWidth = _ref.legendWidth, legendContent = _ref.legendContent;
|
69138
69195
|
var legendItem = findChildByType(children, Legend$2);
|
69139
69196
|
if (!legendItem) {
|
@@ -69476,7 +69533,7 @@ var getBarPosition = function getBarPosition2(_ref3) {
|
|
69476
69533
|
var appendOffsetOfLegend = function appendOffsetOfLegend2(offset2, _unused, props, legendBox) {
|
69477
69534
|
var children = props.children, width = props.width, margin = props.margin;
|
69478
69535
|
var legendWidth = width - (margin.left || 0) - (margin.right || 0);
|
69479
|
-
var legendProps = getLegendProps
|
69536
|
+
var legendProps = getLegendProps({
|
69480
69537
|
children,
|
69481
69538
|
legendWidth
|
69482
69539
|
});
|
@@ -70150,14 +70207,14 @@ function _iterableToArrayLimit$6(r2, l2) {
|
|
70150
70207
|
function _arrayWithHoles$7(arr) {
|
70151
70208
|
if (Array.isArray(arr)) return arr;
|
70152
70209
|
}
|
70153
|
-
var RADIAN$
|
70210
|
+
var RADIAN$2 = Math.PI / 180;
|
70154
70211
|
var radianToDegree = function radianToDegree2(angleInRadian) {
|
70155
70212
|
return angleInRadian * 180 / Math.PI;
|
70156
70213
|
};
|
70157
70214
|
var polarToCartesian = function polarToCartesian2(cx, cy, radius, angle) {
|
70158
70215
|
return {
|
70159
|
-
x: cx + Math.cos(-RADIAN$
|
70160
|
-
y: cy + Math.sin(-RADIAN$
|
70216
|
+
x: cx + Math.cos(-RADIAN$2 * angle) * radius,
|
70217
|
+
y: cy + Math.sin(-RADIAN$2 * angle) * radius
|
70161
70218
|
};
|
70162
70219
|
};
|
70163
70220
|
var getMaxRadius = function getMaxRadius2(width, height) {
|
@@ -70665,7 +70722,7 @@ var getAttrsOfCartesianLabel = function getAttrsOfCartesianLabel2(props) {
|
|
70665
70722
|
var isPolar = function isPolar2(viewBox) {
|
70666
70723
|
return "cx" in viewBox && isNumber(viewBox.cx);
|
70667
70724
|
};
|
70668
|
-
function Label(_ref4) {
|
70725
|
+
function Label$1(_ref4) {
|
70669
70726
|
var _ref4$offset = _ref4.offset, offset2 = _ref4$offset === void 0 ? 5 : _ref4$offset, restProps = _objectWithoutProperties$d(_ref4, _excluded$d);
|
70670
70727
|
var props = _objectSpread$s({
|
70671
70728
|
offset: offset2
|
@@ -70698,7 +70755,7 @@ function Label(_ref4) {
|
|
70698
70755
|
breakAll: textBreakAll
|
70699
70756
|
}), label);
|
70700
70757
|
}
|
70701
|
-
Label.displayName = "Label";
|
70758
|
+
Label$1.displayName = "Label";
|
70702
70759
|
var parseViewBox = function parseViewBox2(props) {
|
70703
70760
|
var cx = props.cx, cy = props.cy, angle = props.angle, startAngle = props.startAngle, endAngle = props.endAngle, r2 = props.r, radius = props.radius, innerRadius = props.innerRadius, outerRadius = props.outerRadius, x3 = props.x, y4 = props.y, top = props.top, left = props.left, width = props.width, height = props.height, clockWise = props.clockWise, labelViewBox = props.labelViewBox;
|
70704
70761
|
if (labelViewBox) {
|
@@ -70751,40 +70808,40 @@ var parseLabel = function parseLabel2(label, viewBox) {
|
|
70751
70808
|
return null;
|
70752
70809
|
}
|
70753
70810
|
if (label === true) {
|
70754
|
-
return /* @__PURE__ */ React.createElement(Label, {
|
70811
|
+
return /* @__PURE__ */ React.createElement(Label$1, {
|
70755
70812
|
key: "label-implicit",
|
70756
70813
|
viewBox
|
70757
70814
|
});
|
70758
70815
|
}
|
70759
70816
|
if (isNumOrStr(label)) {
|
70760
|
-
return /* @__PURE__ */ React.createElement(Label, {
|
70817
|
+
return /* @__PURE__ */ React.createElement(Label$1, {
|
70761
70818
|
key: "label-implicit",
|
70762
70819
|
viewBox,
|
70763
70820
|
value: label
|
70764
70821
|
});
|
70765
70822
|
}
|
70766
70823
|
if (/* @__PURE__ */ React.isValidElement(label)) {
|
70767
|
-
if (label.type === Label) {
|
70824
|
+
if (label.type === Label$1) {
|
70768
70825
|
return /* @__PURE__ */ React.cloneElement(label, {
|
70769
70826
|
key: "label-implicit",
|
70770
70827
|
viewBox
|
70771
70828
|
});
|
70772
70829
|
}
|
70773
|
-
return /* @__PURE__ */ React.createElement(Label, {
|
70830
|
+
return /* @__PURE__ */ React.createElement(Label$1, {
|
70774
70831
|
key: "label-implicit",
|
70775
70832
|
content: label,
|
70776
70833
|
viewBox
|
70777
70834
|
});
|
70778
70835
|
}
|
70779
70836
|
if (isFunction(label)) {
|
70780
|
-
return /* @__PURE__ */ React.createElement(Label, {
|
70837
|
+
return /* @__PURE__ */ React.createElement(Label$1, {
|
70781
70838
|
key: "label-implicit",
|
70782
70839
|
content: label,
|
70783
70840
|
viewBox
|
70784
70841
|
});
|
70785
70842
|
}
|
70786
70843
|
if (isObject(label)) {
|
70787
|
-
return /* @__PURE__ */ React.createElement(Label, _extends$o({
|
70844
|
+
return /* @__PURE__ */ React.createElement(Label$1, _extends$o({
|
70788
70845
|
viewBox
|
70789
70846
|
}, label, {
|
70790
70847
|
key: "label-implicit"
|
@@ -70799,7 +70856,7 @@ var renderCallByParent$1 = function renderCallByParent(parentProps, viewBox) {
|
|
70799
70856
|
}
|
70800
70857
|
var children = parentProps.children;
|
70801
70858
|
var parentViewBox = parseViewBox(parentProps);
|
70802
|
-
var explicitChildren = findAllByType(children, Label).map(function(child, index2) {
|
70859
|
+
var explicitChildren = findAllByType(children, Label$1).map(function(child, index2) {
|
70803
70860
|
return /* @__PURE__ */ React.cloneElement(child, {
|
70804
70861
|
viewBox: viewBox || parentViewBox,
|
70805
70862
|
// eslint-disable-next-line react/no-array-index-key
|
@@ -70812,8 +70869,8 @@ var renderCallByParent$1 = function renderCallByParent(parentProps, viewBox) {
|
|
70812
70869
|
var implicitLabel = parseLabel(parentProps.label, viewBox || parentViewBox);
|
70813
70870
|
return [implicitLabel].concat(_toConsumableArray$8(explicitChildren));
|
70814
70871
|
};
|
70815
|
-
Label.parseViewBox = parseViewBox;
|
70816
|
-
Label.renderCallByParent = renderCallByParent$1;
|
70872
|
+
Label$1.parseViewBox = parseViewBox;
|
70873
|
+
Label$1.renderCallByParent = renderCallByParent$1;
|
70817
70874
|
var lastExports = requireLast();
|
70818
70875
|
const last = /* @__PURE__ */ getDefaultExportFromCjs(lastExports);
|
70819
70876
|
function _typeof$w(o2) {
|
@@ -70950,11 +71007,11 @@ function LabelList(_ref) {
|
|
70950
71007
|
var idProps = isNil(id2) ? {} : {
|
70951
71008
|
id: "".concat(id2, "-").concat(index2)
|
70952
71009
|
};
|
70953
|
-
return /* @__PURE__ */ React.createElement(Label, _extends$n({}, filterProps(entry, true), others, idProps, {
|
71010
|
+
return /* @__PURE__ */ React.createElement(Label$1, _extends$n({}, filterProps(entry, true), others, idProps, {
|
70954
71011
|
parentViewBox: entry.parentViewBox,
|
70955
71012
|
value,
|
70956
71013
|
textBreakAll,
|
70957
|
-
viewBox: Label.parseViewBox(isNil(clockWise) ? entry : _objectSpread$r(_objectSpread$r({}, entry), {}, {
|
71014
|
+
viewBox: Label$1.parseViewBox(isNil(clockWise) ? entry : _objectSpread$r(_objectSpread$r({}, entry), {}, {
|
70958
71015
|
clockWise
|
70959
71016
|
})),
|
70960
71017
|
key: "label-".concat(index2),
|
@@ -71083,12 +71140,12 @@ var getDeltaAngle2 = function getDeltaAngle3(startAngle, endAngle) {
|
|
71083
71140
|
var getTangentCircle = function getTangentCircle2(_ref) {
|
71084
71141
|
var cx = _ref.cx, cy = _ref.cy, radius = _ref.radius, angle = _ref.angle, sign2 = _ref.sign, isExternal = _ref.isExternal, cornerRadius = _ref.cornerRadius, cornerIsExternal = _ref.cornerIsExternal;
|
71085
71142
|
var centerRadius = cornerRadius * (isExternal ? 1 : -1) + radius;
|
71086
|
-
var theta = Math.asin(cornerRadius / centerRadius) / RADIAN$
|
71143
|
+
var theta = Math.asin(cornerRadius / centerRadius) / RADIAN$2;
|
71087
71144
|
var centerAngle = cornerIsExternal ? angle : angle + sign2 * theta;
|
71088
71145
|
var center = polarToCartesian(cx, cy, centerRadius, centerAngle);
|
71089
71146
|
var circleTangency = polarToCartesian(cx, cy, radius, centerAngle);
|
71090
71147
|
var lineTangencyAngle = cornerIsExternal ? angle - sign2 * theta : angle;
|
71091
|
-
var lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN$
|
71148
|
+
var lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN$2), lineTangencyAngle);
|
71092
71149
|
return {
|
71093
71150
|
center,
|
71094
71151
|
circleTangency,
|
@@ -73668,7 +73725,7 @@ var PolarRadiusAxis = /* @__PURE__ */ function(_PureComponent) {
|
|
73668
73725
|
}
|
73669
73726
|
return /* @__PURE__ */ React.createElement(Layer, {
|
73670
73727
|
className: clsx("recharts-polar-radius-axis", this.props.className)
|
73671
|
-
}, axisLine && this.renderAxisLine(), tick && this.renderTicks(), Label.renderCallByParent(this.props, this.getViewBox()));
|
73728
|
+
}, axisLine && this.renderAxisLine(), tick && this.renderTicks(), Label$1.renderCallByParent(this.props, this.getViewBox()));
|
73672
73729
|
}
|
73673
73730
|
}], [{
|
73674
73731
|
key: "renderTickItem",
|
@@ -73838,7 +73895,7 @@ function _toPrimitive$l(t3, r2) {
|
|
73838
73895
|
}
|
73839
73896
|
return String(t3);
|
73840
73897
|
}
|
73841
|
-
var RADIAN = Math.PI / 180;
|
73898
|
+
var RADIAN$1 = Math.PI / 180;
|
73842
73899
|
var eps = 1e-5;
|
73843
73900
|
var PolarAngleAxis = /* @__PURE__ */ function(_PureComponent) {
|
73844
73901
|
function PolarAngleAxis2() {
|
@@ -73878,7 +73935,7 @@ var PolarAngleAxis = /* @__PURE__ */ function(_PureComponent) {
|
|
73878
73935
|
key: "getTickTextAnchor",
|
73879
73936
|
value: function getTickTextAnchor(data) {
|
73880
73937
|
var orientation = this.props.orientation;
|
73881
|
-
var cos2 = Math.cos(-data.coordinate * RADIAN);
|
73938
|
+
var cos2 = Math.cos(-data.coordinate * RADIAN$1);
|
73882
73939
|
var textAnchor;
|
73883
73940
|
if (cos2 > eps) {
|
73884
73941
|
textAnchor = orientation === "outer" ? "start" : "end";
|
@@ -74797,7 +74854,7 @@ var Pie = /* @__PURE__ */ function(_PureComponent) {
|
|
74797
74854
|
ref: function ref(_ref3) {
|
74798
74855
|
_this5.pieRef = _ref3;
|
74799
74856
|
}
|
74800
|
-
}, this.renderSectors(), label && this.renderLabels(sectors), Label.renderCallByParent(this.props, null, false), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, sectors, false));
|
74857
|
+
}, this.renderSectors(), label && this.renderLabels(sectors), Label$1.renderCallByParent(this.props, null, false), (!isAnimationActive || isAnimationFinished) && LabelList.renderCallByParent(this.props, sectors, false));
|
74801
74858
|
}
|
74802
74859
|
}], [{
|
74803
74860
|
key: "getDerivedStateFromProps",
|
@@ -77249,7 +77306,7 @@ function ReferenceLineImpl(props) {
|
|
77249
77306
|
});
|
77250
77307
|
return /* @__PURE__ */ React.createElement(Layer, {
|
77251
77308
|
className: clsx("recharts-reference-line", className)
|
77252
|
-
}, renderLine(shape, lineProps), Label.renderCallByParent(props, rectWithCoords({
|
77309
|
+
}, renderLine(shape, lineProps), Label$1.renderCallByParent(props, rectWithCoords({
|
77253
77310
|
x1,
|
77254
77311
|
y1,
|
77255
77312
|
x2: x22,
|
@@ -77462,7 +77519,7 @@ var ReferenceDot = /* @__PURE__ */ function(_React$Component) {
|
|
77462
77519
|
});
|
77463
77520
|
return /* @__PURE__ */ React.createElement(Layer, {
|
77464
77521
|
className: clsx("recharts-reference-dot", className)
|
77465
|
-
}, ReferenceDot2.renderDot(shape, dotProps), Label.renderCallByParent(this.props, {
|
77522
|
+
}, ReferenceDot2.renderDot(shape, dotProps), Label$1.renderCallByParent(this.props, {
|
77466
77523
|
x: cx - r2,
|
77467
77524
|
y: cy - r2,
|
77468
77525
|
width: 2 * r2,
|
@@ -77687,7 +77744,7 @@ var ReferenceArea = /* @__PURE__ */ function(_React$Component) {
|
|
77687
77744
|
className: clsx("recharts-reference-area", className)
|
77688
77745
|
}, ReferenceArea2.renderRect(shape, _objectSpread$7(_objectSpread$7({
|
77689
77746
|
clipPath
|
77690
|
-
}, filterProps(this.props, true)), rect)), Label.renderCallByParent(this.props, rect));
|
77747
|
+
}, filterProps(this.props, true)), rect)), Label$1.renderCallByParent(this.props, rect));
|
77691
77748
|
}
|
77692
77749
|
}]);
|
77693
77750
|
}(React.Component);
|
@@ -78370,7 +78427,7 @@ var CartesianAxis = /* @__PURE__ */ function(_Component) {
|
|
78370
78427
|
ref: function ref(_ref2) {
|
78371
78428
|
_this3.layerReference = _ref2;
|
78372
78429
|
}
|
78373
|
-
}, axisLine && this.renderAxisLine(), this.renderTicks(finalTicks, this.state.fontSize, this.state.letterSpacing), Label.renderCallByParent(this.props));
|
78430
|
+
}, axisLine && this.renderAxisLine(), this.renderTicks(finalTicks, this.state.fontSize, this.state.letterSpacing), Label$1.renderCallByParent(this.props));
|
78374
78431
|
}
|
78375
78432
|
}], [{
|
78376
78433
|
key: "renderTickItem",
|
@@ -81903,7 +81960,7 @@ var generateCategoricalChart = function generateCategoricalChart2(_ref6) {
|
|
81903
81960
|
var _this$props2 = _this.props, children = _this$props2.children, width = _this$props2.width, height = _this$props2.height;
|
81904
81961
|
var margin = _this.props.margin || {};
|
81905
81962
|
var legendWidth = width - (margin.left || 0) - (margin.right || 0);
|
81906
|
-
var props = getLegendProps
|
81963
|
+
var props = getLegendProps({
|
81907
81964
|
children,
|
81908
81965
|
formattedGraphicalItems,
|
81909
81966
|
legendWidth,
|
@@ -82668,7 +82725,7 @@ var BarChart$1 = generateCategoricalChart({
|
|
82668
82725
|
}],
|
82669
82726
|
formatAxisMap: formatAxisMap2
|
82670
82727
|
});
|
82671
|
-
var PieChart = generateCategoricalChart({
|
82728
|
+
var PieChart$1 = generateCategoricalChart({
|
82672
82729
|
chartName: "PieChart",
|
82673
82730
|
GraphicalChild: Pie,
|
82674
82731
|
validateTooltipEventTypes: ["item"],
|
@@ -82704,6 +82761,79 @@ var AreaChart$1 = generateCategoricalChart({
|
|
82704
82761
|
}],
|
82705
82762
|
formatAxisMap: formatAxisMap2
|
82706
82763
|
});
|
82764
|
+
function getAxisProps(scale2, tickFormatter, dataKey) {
|
82765
|
+
return {
|
82766
|
+
axisLine: false,
|
82767
|
+
dataKey,
|
82768
|
+
fontSize: 11,
|
82769
|
+
scale: scale2,
|
82770
|
+
tickLine: false,
|
82771
|
+
tickMargin: 8,
|
82772
|
+
tickFormatter
|
82773
|
+
};
|
82774
|
+
}
|
82775
|
+
function ChartContainer(props) {
|
82776
|
+
const { onSetWidth: handleSetWidth, ...attributes } = props;
|
82777
|
+
const ref = React.useRef(null);
|
82778
|
+
React.useLayoutEffect(() => {
|
82779
|
+
if (ref.current && typeof handleSetWidth === "function") {
|
82780
|
+
const rect = ref.current.getBoundingClientRect();
|
82781
|
+
handleSetWidth(rect.width);
|
82782
|
+
}
|
82783
|
+
}, [ref]);
|
82784
|
+
const className = clsx("flex justify-center mx-auto", attributes.className);
|
82785
|
+
return /* @__PURE__ */ React.createElement("div", { ...attributes, className, ref }, /* @__PURE__ */ React.createElement(ResponsiveContainer, null, props.children));
|
82786
|
+
}
|
82787
|
+
function Tooltip(props) {
|
82788
|
+
const { active, payload = [], style, title } = props;
|
82789
|
+
if (active && payload.length) {
|
82790
|
+
return /* @__PURE__ */ React.createElement("div", { className: "border-grey-300 z-20 flex flex-col gap-y-1 rounded-md border bg-white px-2 py-1.5 text-xs shadow-sm" }, title ? /* @__PURE__ */ React.createElement("span", { className: "font-bold" }, title) : null, /* @__PURE__ */ React.createElement("dl", { className: "m-0 grid grid-cols-[max-content_max-content] gap-x-4 gap-y-0.5", style }, payload.map((entry, index2) => {
|
82791
|
+
const color2 = entry.color ?? entry.payload.color;
|
82792
|
+
const formatter = entry.formatter ?? entry.payload.formatter;
|
82793
|
+
const unit2 = entry.unit ?? entry.payload.unit;
|
82794
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, { key: `${entry.name}-${index2}` }, /* @__PURE__ */ React.createElement("dt", { className: "text-grey-700 mb-0 flex items-center gap-1 font-normal" }, /* @__PURE__ */ React.createElement("span", { className: "-mt-px h-2.5 w-2.5 rounded-sm", style: { background: color2 } }), entry.name), /* @__PURE__ */ React.createElement("dd", { className: "mb-0 text-right font-bold tabular-nums text-black" }, (formatter == null ? void 0 : formatter(entry.value ?? "", entry.name ?? "", entry, index2, entry.payload)) ?? entry.value, " ", unit2 ? /* @__PURE__ */ React.createElement("span", { className: "text-grey-700" }, unit2) : null));
|
82795
|
+
})));
|
82796
|
+
}
|
82797
|
+
return null;
|
82798
|
+
}
|
82799
|
+
function Legend$1(props) {
|
82800
|
+
const { hoverIndex, items, onHover: handleHover, onToggle: handleToggle } = props;
|
82801
|
+
const handleMouseEnter = (item, index2) => {
|
82802
|
+
if (item.isHidden) {
|
82803
|
+
return;
|
82804
|
+
}
|
82805
|
+
handleHover(index2);
|
82806
|
+
};
|
82807
|
+
const handleMouseLeave = () => handleHover(void 0);
|
82808
|
+
const handleClick = (item) => {
|
82809
|
+
if (!item.isHidden) {
|
82810
|
+
handleHover(void 0);
|
82811
|
+
}
|
82812
|
+
handleToggle(item.dataKey);
|
82813
|
+
};
|
82814
|
+
const moreButton = (moreButtonText) => /* @__PURE__ */ React.createElement(Button$4, { appearance: "transparent", className: "text-grey-700 !h-5 !min-h-[1.25rem] !px-1.5 text-xs" }, moreButtonText);
|
82815
|
+
return /* @__PURE__ */ React.createElement(OverflowGroup, { className: "w-full gap-x-1", moreButton }, items.map((item, index2) => {
|
82816
|
+
const className = clsx("mr-1 flex h-3 w-3 rounded-sm", {
|
82817
|
+
[`bg-${item.color}`]: !item.isHidden,
|
82818
|
+
border: item.isHidden
|
82819
|
+
});
|
82820
|
+
return /* @__PURE__ */ React.createElement(
|
82821
|
+
"button",
|
82822
|
+
{
|
82823
|
+
key: item.label,
|
82824
|
+
className: "hover:bg-grey-200 focus-visible:yt-focus flex items-center rounded px-1 !text-xs",
|
82825
|
+
onClick: (event) => {
|
82826
|
+
event == null ? void 0 : event.preventDefault();
|
82827
|
+
handleClick(item);
|
82828
|
+
},
|
82829
|
+
onMouseEnter: () => handleMouseEnter(item, index2),
|
82830
|
+
onMouseLeave: () => handleMouseLeave()
|
82831
|
+
},
|
82832
|
+
/* @__PURE__ */ React.createElement("span", { className }, hoverIndex === index2 ? /* @__PURE__ */ React.createElement(Icon$1, { name: "tick-bold", className: clsx("!h-full !w-full", { "text-white": !item.isHidden }) }) : null),
|
82833
|
+
item.label
|
82834
|
+
);
|
82835
|
+
}));
|
82836
|
+
}
|
82707
82837
|
const THEME_COLORS = {
|
82708
82838
|
transparent: "transparent",
|
82709
82839
|
current: "currentColor",
|
@@ -82839,266 +82969,291 @@ const mapColor = (palette, prefix2 = "") => {
|
|
82839
82969
|
}, {});
|
82840
82970
|
};
|
82841
82971
|
const colors = mapColor(THEME_COLORS);
|
82842
|
-
const getThemeColor = (color2) => colors[color2];
|
82843
|
-
|
82844
|
-
const
|
82845
|
-
const
|
82846
|
-
|
82847
|
-
|
82848
|
-
|
82849
|
-
|
82850
|
-
|
82851
|
-
|
82852
|
-
|
82853
|
-
|
82854
|
-
const moreButton = (moreButtonText) => /* @__PURE__ */ React.createElement(Button$4, { appearance: "transparent", className: "text-grey-700" }, moreButtonText);
|
82855
|
-
return /* @__PURE__ */ React.createElement("div", { className: "mx-auto w-auto max-w-full overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: clsx("mb-0 ml-0 flex justify-center", { "flex-col": layout === "vertical" }) }, /* @__PURE__ */ React.createElement(OverflowGroup, { className: "w-full items-center py-1", moreButton }, payload.map((entry, index2) => /* @__PURE__ */ React.createElement(
|
82856
|
-
"span",
|
82857
|
-
{
|
82858
|
-
key: `${entry.dataKey}-${index2}`,
|
82859
|
-
className: clsx(" hover:bg-grey-100 cursor-pointer px-[8px] py-[2px] hover:rounded-[4px]", {
|
82860
|
-
"bg-grey-100 rounded": activeIndex === index2
|
82861
|
-
}),
|
82862
|
-
onMouseEnter: () => handleMouseEnter(entry, index2),
|
82863
|
-
onMouseLeave: handleMouseLeave,
|
82864
|
-
onClick: onClick ? () => onClick(entry) : void 0
|
82865
|
-
},
|
82866
|
-
/* @__PURE__ */ React.createElement("span", { className: "text-grey-700 flex items-center gap-[4px]" }, /* @__PURE__ */ React.createElement(
|
82867
|
-
"span",
|
82868
|
-
{
|
82869
|
-
className: clsx("-mt-px ml-1 flex h-3 w-3 rounded-sm", {
|
82870
|
-
"border-grey-300 border !bg-white": !activeItems[entry.dataKey]
|
82871
|
-
}),
|
82872
|
-
style: { backgroundColor: entry.color }
|
82873
|
-
},
|
82874
|
-
hoverIndex === index2 && activeItems[entry.dataKey] && /* @__PURE__ */ React.createElement(Icon$1, { name: "tick-bold", className: "!h-full !w-full text-white" })
|
82875
|
-
), entry.value)
|
82876
|
-
)))));
|
82877
|
-
}
|
82878
|
-
const Tooltip = ({ active, formatter, payload, style, singlePieDonutChart }) => {
|
82879
|
-
const getColor = (entry) => {
|
82880
|
-
if (singlePieDonutChart) {
|
82881
|
-
return getThemeColor(entry.payload.color);
|
82972
|
+
const getThemeColor = (color2, def = "") => colors[color2 ?? def];
|
82973
|
+
const getInverseThemeColor = (themeColor) => {
|
82974
|
+
const [color2, number2] = String(themeColor).split("-");
|
82975
|
+
const shade = Number(number2);
|
82976
|
+
if (shade) {
|
82977
|
+
if (shade > 500) {
|
82978
|
+
return getThemeColor(`${color2}-100`);
|
82979
|
+
} else {
|
82980
|
+
if (shade === 500 && (color2 === "red" || color2 === "blue" || color2 === "brown" || color2 === "purple" || color2 === "green")) {
|
82981
|
+
return "white";
|
82982
|
+
}
|
82983
|
+
return getThemeColor(`${color2}-900`);
|
82882
82984
|
}
|
82883
|
-
return entry.color ?? entry.payload.fill ?? "blue-500";
|
82884
|
-
};
|
82885
|
-
if (active && payload && payload.length) {
|
82886
|
-
return /* @__PURE__ */ React.createElement(
|
82887
|
-
"dl",
|
82888
|
-
{
|
82889
|
-
className: "z-20 grid grid-cols-[max-content_max-content] gap-x-4 rounded-md bg-white p-4 text-xs shadow-[0px_0px_1px_rgba(0,0,0,0.1),_0px_6px_18px_rgba(47,51,68,0.2)]",
|
82890
|
-
style
|
82891
|
-
},
|
82892
|
-
payload.map((entry, index2) => /* @__PURE__ */ React.createElement(React.Fragment, { key: `${entry.name}-${index2}` }, /* @__PURE__ */ React.createElement(
|
82893
|
-
"dt",
|
82894
|
-
{ className: "text-grey-700 mb-0 flex items-center gap-1 font-normal" },
|
82895
|
-
/* @__PURE__ */ React.createElement("span", { className: "-mt-px h-2.5 w-2.5 rounded-sm", style: { background: getColor(entry) } }),
|
82896
|
-
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
82897
|
-
// and one with multiple pies.
|
82898
|
-
singlePieDonutChart ? entry.payload.label : entry.name
|
82899
|
-
), /* @__PURE__ */ React.createElement("dd", { className: "mb-0 text-right font-bold text-black " }, formatter ? formatter(entry.value) : entry.value)))
|
82900
|
-
);
|
82901
82985
|
}
|
82902
|
-
return
|
82986
|
+
return color2 === "black" ? "white" : "black";
|
82903
82987
|
};
|
82904
|
-
|
82905
|
-
|
82906
|
-
|
82907
|
-
const
|
82908
|
-
|
82909
|
-
|
82910
|
-
|
82911
|
-
|
82912
|
-
|
82913
|
-
|
82914
|
-
|
82915
|
-
|
82916
|
-
|
82917
|
-
|
82918
|
-
|
82919
|
-
tickLine: false,
|
82920
|
-
tickFormatter: props.yAxisTickFormat
|
82921
|
-
});
|
82922
|
-
const getLegendProps2 = (props) => ({
|
82923
|
-
content: /* @__PURE__ */ React.createElement(Legend$1, { ...props })
|
82924
|
-
});
|
82925
|
-
const getTooltipProps = (props = void 0) => ({
|
82926
|
-
content: /* @__PURE__ */ React.createElement(Tooltip, { ...props }),
|
82927
|
-
wrapperStyle: { outline: "none" }
|
82928
|
-
});
|
82929
|
-
const ResponsiveContainer = (props) => /* @__PURE__ */ React.createElement(ResponsiveContainer$1, { className: "!h-[calc(100%-1px)] !w-[calc(100%-1px)]", ...props });
|
82930
|
-
const Area = (_) => null;
|
82931
|
-
const AreaChart = function AreaChart2(externalProps) {
|
82932
|
-
const { children, data, formatter, ...props } = externalProps;
|
82933
|
-
const [hoveredArea, setHoveredArea] = React.useState(null);
|
82934
|
-
const [activeAreas, setActiveAreas] = React.useState(() => {
|
82935
|
-
const areas = {};
|
82936
|
-
React.Children.forEach(children, (child) => {
|
82937
|
-
areas[child.props.accessor] = true;
|
82988
|
+
function useChart(children, options) {
|
82989
|
+
const [activeIndex, setActiveIndex] = React.useState();
|
82990
|
+
const [hiddenItems, toggleItem] = useChartDataHiddenState();
|
82991
|
+
const localization = useLocalization();
|
82992
|
+
const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale).format(value);
|
82993
|
+
const { items, shapes } = React.useMemo(() => {
|
82994
|
+
const items2 = React.Children.toArray(children).filter((child) => React.isValidElement(child)).map((child) => {
|
82995
|
+
const dataKey = child.props.dataKey ?? child.props.label;
|
82996
|
+
return {
|
82997
|
+
...child.props,
|
82998
|
+
dataKey,
|
82999
|
+
formatter: child.props.formatter ?? (options == null ? void 0 : options.formatter) ?? defaultFormatter2,
|
83000
|
+
isHidden: !!hiddenItems[dataKey],
|
83001
|
+
unit: child.props.unit ?? (options == null ? void 0 : options.unit)
|
83002
|
+
};
|
82938
83003
|
});
|
82939
|
-
|
82940
|
-
|
82941
|
-
|
82942
|
-
|
82943
|
-
|
82944
|
-
|
82945
|
-
|
82946
|
-
|
82947
|
-
|
82948
|
-
|
82949
|
-
|
82950
|
-
|
82951
|
-
|
82952
|
-
|
82953
|
-
|
82954
|
-
|
82955
|
-
|
82956
|
-
|
82957
|
-
|
82958
|
-
|
82959
|
-
fill: getThemeColor(child.props.color ?? "blue-300")
|
82960
|
-
},
|
82961
|
-
isAnimationActive: false,
|
82962
|
-
dataKey: child.props.accessor,
|
82963
|
-
dot: false,
|
82964
|
-
fill: getThemeColor(child.props.color ?? "grey-100"),
|
82965
|
-
name: child.props.label,
|
82966
|
-
strokeWidth: 2,
|
82967
|
-
stroke: getThemeColor(child.props.color ?? "grey-300"),
|
82968
|
-
stackId: child.props.stackId,
|
82969
|
-
hide: !activeAreas[child.props.accessor],
|
82970
|
-
opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
|
82971
|
-
}
|
82972
|
-
))));
|
82973
|
-
};
|
82974
|
-
AreaChart.Area = Area;
|
82975
|
-
const Bar = (_) => null;
|
82976
|
-
const getXAxisVerticalProps = (props) => ({
|
82977
|
-
...getXAxisProps(props),
|
82978
|
-
...{ type: "number", dataKey: void 0 }
|
82979
|
-
});
|
82980
|
-
const getYAxisVerticalProps = (props) => ({
|
82981
|
-
...getYAxisProps(props),
|
82982
|
-
...{ dataKey: props.accessor, type: "category" }
|
82983
|
-
});
|
82984
|
-
const BarChart = function BarChart2(externalProps) {
|
82985
|
-
const { children, data, formatter, layout = "horizontal", ...props } = externalProps;
|
82986
|
-
const [activeIndex, setActiveIndex] = React.useState(void 0);
|
82987
|
-
const [hoveredBar, setHoveredBar] = React.useState(null);
|
82988
|
-
const [activeBars, setActiveBars] = React.useState(() => {
|
82989
|
-
const keys2 = {};
|
82990
|
-
React.Children.forEach(children, (child) => {
|
82991
|
-
keys2[child.props.accessor] = true;
|
83004
|
+
const shapes2 = items2.filter((item) => !hiddenItems[item.dataKey]).map((item) => {
|
83005
|
+
const color2 = getThemeColor(item.color, "blue-500");
|
83006
|
+
return {
|
83007
|
+
activeDot: {
|
83008
|
+
strokeWidth: 1
|
83009
|
+
},
|
83010
|
+
color: color2,
|
83011
|
+
dataKey: item.dataKey,
|
83012
|
+
dot: {
|
83013
|
+
fillOpacity: 0.6
|
83014
|
+
},
|
83015
|
+
isAnimationActive: false,
|
83016
|
+
fill: color2,
|
83017
|
+
fillOpacity: 0.65,
|
83018
|
+
formatter: item.formatter,
|
83019
|
+
name: item.label,
|
83020
|
+
stroke: color2,
|
83021
|
+
strokeWidth: 1.5,
|
83022
|
+
unit: item.unit
|
83023
|
+
};
|
82992
83024
|
});
|
82993
|
-
return
|
82994
|
-
});
|
82995
|
-
|
82996
|
-
|
82997
|
-
|
82998
|
-
|
82999
|
-
|
83025
|
+
return { items: items2, shapes: shapes2 };
|
83026
|
+
}, [children, hiddenItems]);
|
83027
|
+
return { items, shapes, activeIndex, setActiveIndex, toggleItem };
|
83028
|
+
}
|
83029
|
+
function useChartDataHiddenState() {
|
83030
|
+
const [state, setState] = React.useState({});
|
83031
|
+
function toggle(name) {
|
83032
|
+
setState((currentState) => {
|
83033
|
+
const nextState = { ...currentState };
|
83034
|
+
if (currentState[name]) {
|
83035
|
+
delete nextState[name];
|
83000
83036
|
} else {
|
83001
|
-
|
83037
|
+
nextState[name] = true;
|
83002
83038
|
}
|
83003
|
-
|
83004
|
-
|
83005
|
-
|
83006
|
-
|
83007
|
-
|
83008
|
-
|
83009
|
-
const
|
83010
|
-
|
83011
|
-
|
83012
|
-
|
83013
|
-
|
83014
|
-
|
83039
|
+
return nextState;
|
83040
|
+
});
|
83041
|
+
}
|
83042
|
+
return [state, toggle];
|
83043
|
+
}
|
83044
|
+
function AreaChart(props) {
|
83045
|
+
const {
|
83046
|
+
children,
|
83047
|
+
data,
|
83048
|
+
dataKey,
|
83049
|
+
showDots = false,
|
83050
|
+
showLegend = false,
|
83051
|
+
showXAxis = true,
|
83052
|
+
showYAxis = false,
|
83053
|
+
stacked = false,
|
83054
|
+
tooltipTitle,
|
83055
|
+
type = "natural",
|
83056
|
+
xAxisScale,
|
83057
|
+
xAxisTickFormatter,
|
83058
|
+
yAxisScale,
|
83059
|
+
yAxisTickFormatter,
|
83060
|
+
...attributes
|
83061
|
+
} = props;
|
83062
|
+
const className = clsx("aspect-video", attributes.className);
|
83063
|
+
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83064
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-area" }, /* @__PURE__ */ React.createElement(
|
83065
|
+
AreaChart$1,
|
83015
83066
|
{
|
83016
|
-
layout,
|
83017
83067
|
data,
|
83018
|
-
margin: {
|
83019
|
-
|
83020
|
-
onMouseLeave: () => setActiveIndex(void 0)
|
83068
|
+
margin: { bottom: 10, left: 10, right: 10, top: 10 },
|
83069
|
+
stackOffset: stacked === "expand" ? "expand" : void 0
|
83021
83070
|
},
|
83022
|
-
/* @__PURE__ */ React.createElement(CartesianGrid, {
|
83071
|
+
/* @__PURE__ */ React.createElement(CartesianGrid, { vertical: false }),
|
83072
|
+
/* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, { title: tooltipTitle }) }),
|
83023
83073
|
/* @__PURE__ */ React.createElement(
|
83024
83074
|
XAxis,
|
83025
83075
|
{
|
83026
|
-
...
|
83076
|
+
...getAxisProps(xAxisScale, xAxisTickFormatter, dataKey),
|
83077
|
+
hide: !showXAxis
|
83027
83078
|
}
|
83028
83079
|
),
|
83080
|
+
/* @__PURE__ */ React.createElement(YAxis, { ...getAxisProps(yAxisScale, yAxisTickFormatter), hide: !showYAxis }),
|
83081
|
+
shapes.map((shape) => /* @__PURE__ */ React.createElement(
|
83082
|
+
Area$1,
|
83083
|
+
{
|
83084
|
+
key: shape.dataKey,
|
83085
|
+
...shape,
|
83086
|
+
dot: showDots ? shape.dot : false,
|
83087
|
+
stackId: stacked ? "stack" : void 0,
|
83088
|
+
type
|
83089
|
+
}
|
83090
|
+
))
|
83091
|
+
)), showLegend ? /* @__PURE__ */ React.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83092
|
+
}
|
83093
|
+
function Area(_) {
|
83094
|
+
return null;
|
83095
|
+
}
|
83096
|
+
AreaChart.Area = Area;
|
83097
|
+
const BAR_WIDTH = 20;
|
83098
|
+
function BarChart(props) {
|
83099
|
+
const isHorizontal = props.layout === "horizontal";
|
83100
|
+
const {
|
83101
|
+
children,
|
83102
|
+
data,
|
83103
|
+
dataKey,
|
83104
|
+
showLabels = false,
|
83105
|
+
showLegend = false,
|
83106
|
+
showXAxis = !isHorizontal,
|
83107
|
+
showYAxis = isHorizontal,
|
83108
|
+
stacked = false,
|
83109
|
+
xAxisScale,
|
83110
|
+
xAxisTickFormatter,
|
83111
|
+
yAxisScale,
|
83112
|
+
yAxisTickFormatter,
|
83113
|
+
...attributes
|
83114
|
+
} = props;
|
83115
|
+
const className = clsx("aspect-video", attributes.className);
|
83116
|
+
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83117
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-bar" }, /* @__PURE__ */ React.createElement(
|
83118
|
+
BarChart$1,
|
83119
|
+
{
|
83120
|
+
data,
|
83121
|
+
barCategoryGap: "15%",
|
83122
|
+
barGap: "7.5%",
|
83123
|
+
margin: { bottom: 10, left: isHorizontal ? -15 : 10, right: 10, top: 10 },
|
83124
|
+
layout: isHorizontal ? "vertical" : void 0,
|
83125
|
+
stackOffset: stacked === "expand" ? "expand" : void 0
|
83126
|
+
},
|
83127
|
+
/* @__PURE__ */ React.createElement(CartesianGrid, { horizontal: !isHorizontal, vertical: false }),
|
83128
|
+
/* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, null) }),
|
83029
83129
|
/* @__PURE__ */ React.createElement(
|
83030
|
-
|
83130
|
+
XAxis,
|
83031
83131
|
{
|
83032
|
-
...
|
83132
|
+
...getAxisProps(xAxisScale, xAxisTickFormatter, isHorizontal ? void 0 : dataKey),
|
83133
|
+
hide: !showXAxis,
|
83134
|
+
type: isHorizontal ? "number" : void 0
|
83033
83135
|
}
|
83034
83136
|
),
|
83035
83137
|
/* @__PURE__ */ React.createElement(
|
83036
|
-
|
83138
|
+
YAxis,
|
83037
83139
|
{
|
83038
|
-
...
|
83039
|
-
|
83040
|
-
|
83041
|
-
onMouseLeave: () => setHoveredBar(null),
|
83042
|
-
activeItems: activeBars
|
83043
|
-
})
|
83140
|
+
...getAxisProps(yAxisScale, yAxisTickFormatter, isHorizontal ? dataKey : void 0),
|
83141
|
+
hide: !showYAxis,
|
83142
|
+
type: isHorizontal ? "category" : void 0
|
83044
83143
|
}
|
83045
83144
|
),
|
83046
|
-
/* @__PURE__ */ React.createElement(
|
83047
|
-
React.Children.map(children, (child) => /* @__PURE__ */ React.createElement(
|
83145
|
+
shapes.map((shape, index2) => /* @__PURE__ */ React.createElement(
|
83048
83146
|
Bar$1,
|
83049
83147
|
{
|
83050
|
-
|
83051
|
-
|
83052
|
-
|
83053
|
-
|
83054
|
-
|
83055
|
-
|
83056
|
-
|
83057
|
-
radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
|
83058
|
-
stackId: child.props.stackId,
|
83059
|
-
style: child.props.stackId ? { stroke: "#fff", strokeWidth: "2px" } : void 0,
|
83060
|
-
hide: !activeBars[child.props.accessor]
|
83148
|
+
key: shape.dataKey,
|
83149
|
+
...shape,
|
83150
|
+
activeBar: { fillOpacity: 1, strokeWidth: 0 },
|
83151
|
+
strokeWidth: 0,
|
83152
|
+
maxBarSize: BAR_WIDTH,
|
83153
|
+
radius: getRadius(index2, shapes.length, !!stacked, isHorizontal),
|
83154
|
+
stackId: stacked ? "stack" : void 0
|
83061
83155
|
},
|
83062
|
-
|
83063
|
-
|
83156
|
+
showLabels ? /* @__PURE__ */ React.createElement(
|
83157
|
+
LabelList,
|
83064
83158
|
{
|
83065
|
-
|
83066
|
-
|
83159
|
+
position: isHorizontal ? "insideRight" : "top",
|
83160
|
+
formatter: shape.formatter,
|
83161
|
+
offset: isHorizontal ? 6 : 8,
|
83162
|
+
fill: isHorizontal ? getInverseThemeColor(shape.color ?? "") : "black",
|
83163
|
+
fontSize: 11
|
83067
83164
|
}
|
83068
|
-
)
|
83165
|
+
) : null
|
83069
83166
|
))
|
83070
|
-
));
|
83071
|
-
}
|
83072
|
-
|
83073
|
-
|
83074
|
-
|
83075
|
-
|
83076
|
-
const index2 = stacks[stackId].indexOf(accessor);
|
83077
|
-
if (Object.entries(activeBars).filter((item) => item[0] !== accessor).every((item) => !item[1])) {
|
83078
|
-
return [3, 3, 0, 0];
|
83167
|
+
)), showLegend ? /* @__PURE__ */ React.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83168
|
+
}
|
83169
|
+
function getRadius(index2, length, stacked, isHorizontal) {
|
83170
|
+
if (stacked) {
|
83171
|
+
if (index2 === 0) {
|
83172
|
+
return isHorizontal ? [3, 0, 0, 3] : [0, 0, 3, 3];
|
83079
83173
|
}
|
83080
|
-
if (
|
83081
|
-
return
|
83174
|
+
if (index2 === length - 1) {
|
83175
|
+
return isHorizontal ? [0, 3, 3, 0] : [3, 3, 0, 0];
|
83082
83176
|
}
|
83083
|
-
|
83084
|
-
return 0;
|
83085
|
-
}
|
83086
|
-
return [index2 === 0 ? 0 : 3, index2 === 0 ? 0 : 3, index2 === length ? 0 : 3, index2 === length ? 0 : 3];
|
83177
|
+
return 0;
|
83087
83178
|
}
|
83088
83179
|
return 3;
|
83089
|
-
}
|
83090
|
-
|
83091
|
-
|
83092
|
-
|
83093
|
-
|
83094
|
-
|
83095
|
-
|
83096
|
-
|
83097
|
-
|
83098
|
-
|
83099
|
-
|
83100
|
-
|
83101
|
-
}
|
83180
|
+
}
|
83181
|
+
function Bar(_) {
|
83182
|
+
return null;
|
83183
|
+
}
|
83184
|
+
BarChart.Bar = Bar;
|
83185
|
+
const PIE_ACTIVE_WIDTH = 10;
|
83186
|
+
const PIE_ACTIVE_WIDTH_OFFSET = 2;
|
83187
|
+
function usePieChart(children, options) {
|
83188
|
+
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children, options);
|
83189
|
+
const [radius, _setRadius] = React.useState(0);
|
83190
|
+
function setRadius(width) {
|
83191
|
+
_setRadius((width - 2 * (PIE_ACTIVE_WIDTH + PIE_ACTIVE_WIDTH_OFFSET)) / 2);
|
83192
|
+
}
|
83193
|
+
const pieProps = {
|
83194
|
+
activeIndex,
|
83195
|
+
activeShape: (props) => /* @__PURE__ */ React.createElement(ActiveShape$1, { ...props }),
|
83196
|
+
children: shapes.map((shape) => /* @__PURE__ */ React.createElement(Cell, { key: shape.dataKey, color: shape.color, fill: shape.fill })),
|
83197
|
+
// data props
|
83198
|
+
data: items.filter((item) => !item.isHidden),
|
83199
|
+
dataKey: "value",
|
83200
|
+
nameKey: "label",
|
83201
|
+
// style props
|
83202
|
+
isAnimationActive: false,
|
83203
|
+
startAngle: 90,
|
83204
|
+
endAngle: -270,
|
83205
|
+
stroke: "0",
|
83206
|
+
labelLine: false,
|
83207
|
+
outerRadius: radius
|
83208
|
+
};
|
83209
|
+
return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem, shapes };
|
83210
|
+
}
|
83211
|
+
const PIE_CHART_HOVER = 10;
|
83212
|
+
const PIE_CHART_HOVER_OFFSET = 2;
|
83213
|
+
function ActiveShape$1(props) {
|
83214
|
+
const { outerRadius = 0, ...attributes } = props;
|
83215
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Sector, { ...attributes, outerRadius }), /* @__PURE__ */ React.createElement(
|
83216
|
+
Sector,
|
83217
|
+
{
|
83218
|
+
...attributes,
|
83219
|
+
innerRadius: outerRadius + PIE_CHART_HOVER_OFFSET,
|
83220
|
+
outerRadius: outerRadius + PIE_CHART_HOVER,
|
83221
|
+
opacity: 0.4
|
83222
|
+
}
|
83223
|
+
));
|
83224
|
+
}
|
83225
|
+
const DONUT_WIDTH$1 = 20;
|
83226
|
+
function DonutChart(props) {
|
83227
|
+
const { children, formatter, showLegend = false, showTotal = false, tooltipTitle, unit: unit2, ...attributes } = props;
|
83228
|
+
const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(children, {
|
83229
|
+
formatter,
|
83230
|
+
unit: unit2
|
83231
|
+
});
|
83232
|
+
const className = clsx("aspect-square", attributes.className);
|
83233
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, showTotal ? /* @__PURE__ */ React.createElement(
|
83234
|
+
Total,
|
83235
|
+
{
|
83236
|
+
formatter,
|
83237
|
+
items,
|
83238
|
+
unit: unit2,
|
83239
|
+
style: { top: radius / 2 - 2, width: radius + DONUT_WIDTH$1 }
|
83240
|
+
}
|
83241
|
+
) : null, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-donut", onSetWidth: setRadius }, /* @__PURE__ */ React.createElement(PieChart$1, null, /* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, { title: tooltipTitle }) }), /* @__PURE__ */ React.createElement(Pie, { ...pieProps, innerRadius: radius - DONUT_WIDTH$1 }))), showLegend ? /* @__PURE__ */ React.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83242
|
+
}
|
83243
|
+
function Segment$2(_) {
|
83244
|
+
return null;
|
83245
|
+
}
|
83246
|
+
DonutChart.Segment = Segment$2;
|
83247
|
+
function Total(props) {
|
83248
|
+
const { formatter, items, unit: unit2, ...attributes } = props;
|
83249
|
+
const localization = useLocalization();
|
83250
|
+
const total = React.useMemo(() => {
|
83251
|
+
const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
|
83252
|
+
return (formatter == null ? void 0 : formatter(total2)) ?? new Intl.NumberFormat(localization.locale).format(total2);
|
83253
|
+
}, [items]);
|
83254
|
+
return /* @__PURE__ */ React.createElement("div", { ...attributes, className: "absolute-center-x flex aspect-square flex-col items-center justify-center rounded-full" }, /* @__PURE__ */ React.createElement("span", { className: "truncate text-2xl font-bold tabular-nums" }, total), unit2 ? /* @__PURE__ */ React.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null);
|
83255
|
+
}
|
83256
|
+
const Legend = ({ hoveredItem, selectedItem, data, onClick, setHoveredItem, formatter, total, label }) => {
|
83102
83257
|
const isTotalLegendSelected = selectedItem.length === data.length;
|
83103
83258
|
const isTotalLegendHovered = hoveredItem.length === data.length;
|
83104
83259
|
const handleMouseLeave = () => setHoveredItem([]);
|
@@ -83112,49 +83267,22 @@ const Legend = ({
|
|
83112
83267
|
{
|
83113
83268
|
key: isTotal ? "total" : `${itemData.label}-${index2}`,
|
83114
83269
|
className: clsx("mr-2 flex cursor-pointer gap-2 rounded pl-0 pr-1", {
|
83115
|
-
"bg-grey-100": isHovered
|
83116
|
-
"bg-grey-200": isSelected
|
83270
|
+
"bg-grey-100": isHovered,
|
83271
|
+
"bg-grey-200": isSelected
|
83117
83272
|
}),
|
83118
83273
|
onClick: () => onClick(isTotal ? data : itemData),
|
83119
83274
|
onMouseEnter: () => setHoveredItem(isTotal ? data.map((item) => item.id) : [itemData.id]),
|
83120
83275
|
onMouseLeave: handleMouseLeave
|
83121
83276
|
},
|
83122
|
-
|
83123
|
-
|
83124
|
-
{
|
83125
|
-
className: clsx("ml-1 h-3 w-3 rounded-sm", {
|
83126
|
-
"border-grey-300 border !bg-white": !visibleItems[itemData.id]
|
83127
|
-
}),
|
83128
|
-
style: { backgroundColor: getThemeColor(itemData.color) }
|
83129
|
-
},
|
83130
|
-
visibleItems[itemData.id] && isHovered && /* @__PURE__ */ React.createElement(Icon$1, { name: "tick-bold", className: "mb-2.5 !h-full !w-full text-white" })
|
83131
|
-
), /* @__PURE__ */ React.createElement("div", null, itemData.label)) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
83132
|
-
"span",
|
83133
|
-
{
|
83134
|
-
className: "ml-1 mt-1 h-9 w-2 rounded-[1px]",
|
83135
|
-
style: { backgroundColor: getThemeColor(itemData.color) }
|
83136
|
-
}
|
83137
|
-
), /* @__PURE__ */ React.createElement("div", null, itemData.label, /* @__PURE__ */ React.createElement("span", { className: "-mt-1 flex w-full text-lg font-bold" }, formatter ? formatter(itemData.value) : itemData.value)))
|
83277
|
+
/* @__PURE__ */ React.createElement("span", { className: "ml-1 mt-1 h-9 w-2 rounded-[1px]", style: { backgroundColor: getThemeColor(itemData.color) } }),
|
83278
|
+
/* @__PURE__ */ React.createElement("div", null, itemData.label, /* @__PURE__ */ React.createElement("span", { className: "-mt-1 flex w-full text-lg font-bold" }, formatter ? formatter(itemData.value) : itemData.value))
|
83138
83279
|
);
|
83139
83280
|
};
|
83140
|
-
|
83141
|
-
const className = clsx("flex-grow pl-4", {
|
83142
|
-
"w-full": legendPosition === "bottom"
|
83143
|
-
});
|
83144
|
-
return /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(
|
83145
|
-
"ul",
|
83146
|
-
{
|
83147
|
-
className: clsx(
|
83148
|
-
"mb-0 ml-0 mt-4 flex justify-center space-y-1",
|
83149
|
-
legendPosition === "right" ? "flex-col gap-1" : "flex-row"
|
83150
|
-
)
|
83151
|
-
},
|
83152
|
-
legendPosition === "right" ? /* @__PURE__ */ React.createElement(React.Fragment, null, renderLegendItem(null), data.map(renderLegendItem)) : /* @__PURE__ */ React.createElement(OverflowGroup, { className: "w-full items-center py-1", moreButton }, data.map(renderLegendItem))
|
83153
|
-
));
|
83281
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex-grow pl-4" }, /* @__PURE__ */ React.createElement("ul", { className: "mb-0 ml-0 mt-4 flex flex-col justify-center gap-1 space-y-1" }, renderLegendItem(null), data.map(renderLegendItem)));
|
83154
83282
|
};
|
83155
|
-
const DONUT_WIDTH =
|
83283
|
+
const DONUT_WIDTH = 24;
|
83156
83284
|
const HOVER_DONUT_WIDTH = 10;
|
83157
|
-
const CenteredLabel = ({ radius,
|
83285
|
+
const CenteredLabel = ({ radius, label, total, formatter }) => {
|
83158
83286
|
const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
|
83159
83287
|
const diameter = radius * 2;
|
83160
83288
|
return /* @__PURE__ */ React.createElement(
|
@@ -83164,8 +83292,8 @@ const CenteredLabel = ({ radius, legendPosition, label, total, formatter, showLe
|
|
83164
83292
|
style: {
|
83165
83293
|
top: `calc(${radius}px - (3rem / 2))`,
|
83166
83294
|
// h-12 is 3rem
|
83167
|
-
left:
|
83168
|
-
width:
|
83295
|
+
left: `${totalInset}px`,
|
83296
|
+
width: `${diameter - 2 * totalInset}px`
|
83169
83297
|
}
|
83170
83298
|
},
|
83171
83299
|
/* @__PURE__ */ React.createElement("span", { className: "w-full truncate text-lg font-bold" }, formatter ? formatter(total) : total),
|
@@ -83194,42 +83322,28 @@ const ActiveShape = (props) => {
|
|
83194
83322
|
endAngle,
|
83195
83323
|
innerRadius: outerRadius + 2,
|
83196
83324
|
outerRadius: outerRadius + HOVER_DONUT_WIDTH,
|
83197
|
-
fill: id2 !== void 0 ? getThemeColor(pieColors[id2]
|
83198
|
-
opacity: 0.
|
83325
|
+
fill: id2 !== void 0 ? getThemeColor(pieColors[id2], "blue-500") : getThemeColor("blue-500"),
|
83326
|
+
opacity: 0.4
|
83199
83327
|
}
|
83200
83328
|
));
|
83201
83329
|
};
|
83202
|
-
const Segment = (_) => null;
|
83203
|
-
const
|
83204
|
-
children,
|
83205
|
-
formatter,
|
83206
|
-
onClick,
|
83207
|
-
showLegend = false,
|
83208
|
-
legendPosition = "bottom",
|
83209
|
-
label
|
83210
|
-
}) {
|
83330
|
+
const Segment$1 = (_) => null;
|
83331
|
+
const LegacyDonutChart = function LegacyDonutChart2({ children, formatter, onClick, label }) {
|
83211
83332
|
const ref = React.useRef(null);
|
83212
83333
|
const [radius, setRadius] = React.useState(0);
|
83213
83334
|
const [hoveredItem, setHoveredItem] = React.useState([]);
|
83214
83335
|
const [selectedItem, setSelectedItem] = React.useState([]);
|
83215
|
-
const [visibleItems, setVisibleItems] = React.useState(() => {
|
83216
|
-
const keys2 = {};
|
83217
|
-
React.Children.forEach(children, (child) => {
|
83218
|
-
keys2[child.props.id] = true;
|
83219
|
-
});
|
83220
|
-
return keys2;
|
83221
|
-
});
|
83222
83336
|
React.useEffect(() => {
|
83223
83337
|
var _a;
|
83224
83338
|
if (ref.current) {
|
83225
83339
|
const rect = (_a = ref.current.parentElement) == null ? void 0 : _a.getBoundingClientRect();
|
83226
83340
|
if (rect) {
|
83227
|
-
const width =
|
83341
|
+
const width = rect.width / 2;
|
83228
83342
|
const max2 = rect.height < width ? rect.height : width;
|
83229
83343
|
setRadius(max2 / 2);
|
83230
83344
|
}
|
83231
83345
|
}
|
83232
|
-
}, [
|
83346
|
+
}, [ref.current]);
|
83233
83347
|
const diameter = radius * 2;
|
83234
83348
|
const data = React.Children.map(children, (child) => ({
|
83235
83349
|
id: child.props.id,
|
@@ -83237,34 +83351,27 @@ const DonutChart = function DonutChart2({
|
|
83237
83351
|
label: child.props.label,
|
83238
83352
|
value: child.props.value
|
83239
83353
|
}));
|
83240
|
-
const
|
83241
|
-
const total = displayedData.reduce((accum, entry) => accum + entry.value, 0);
|
83242
|
-
const showTooltip = (!showLegend || legendPosition === "bottom") && displayedData.length > 0;
|
83354
|
+
const total = data.reduce((accum, entry) => accum + entry.value, 0);
|
83243
83355
|
const handleLegendClick = (entry) => {
|
83244
|
-
|
83245
|
-
|
83246
|
-
|
83247
|
-
|
83248
|
-
const isCurrentSegmentActive = selectedItem.slice().sort().join(",") === nextSelectedItem.sort().join(",");
|
83249
|
-
if (onClick && !isCurrentSegmentActive) {
|
83250
|
-
onClick(entry);
|
83251
|
-
}
|
83252
|
-
setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
|
83356
|
+
const nextSelectedItem = Array.isArray(entry) ? entry.map((entryItem) => entryItem.id) : [entry.id];
|
83357
|
+
const isCurrentSegmentActive = selectedItem.slice().sort().join(",") === nextSelectedItem.sort().join(",");
|
83358
|
+
if (onClick && !isCurrentSegmentActive) {
|
83359
|
+
onClick(entry);
|
83253
83360
|
}
|
83361
|
+
setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
|
83254
83362
|
};
|
83255
83363
|
const handlePieClick = React.useCallback(
|
83256
83364
|
(pieId) => {
|
83257
83365
|
if (onClick && pieId !== void 0) {
|
83258
|
-
const pieProps =
|
83366
|
+
const pieProps = data.find((item) => item.id === pieId);
|
83259
83367
|
onClick(pieProps);
|
83260
83368
|
}
|
83261
83369
|
},
|
83262
|
-
[onClick,
|
83370
|
+
[onClick, data]
|
83263
83371
|
);
|
83264
|
-
const singlePieDonutChart = displayedData.length === 1;
|
83265
83372
|
const activeShapeColor = React.useMemo(() => {
|
83266
83373
|
const getSegmentColor = (item) => item.reduce((colors2, itemId) => {
|
83267
|
-
const visibleHoveredItem =
|
83374
|
+
const visibleHoveredItem = data.find((dataItem) => dataItem.id === itemId);
|
83268
83375
|
if (visibleHoveredItem) {
|
83269
83376
|
colors2[visibleHoveredItem.id] = visibleHoveredItem.color;
|
83270
83377
|
}
|
@@ -83272,20 +83379,20 @@ const DonutChart = function DonutChart2({
|
|
83272
83379
|
}, {});
|
83273
83380
|
const hoveredSegmentColor = getSegmentColor(hoveredItem);
|
83274
83381
|
const selectedSegmentColor = getSegmentColor(selectedItem);
|
83275
|
-
return
|
83276
|
-
}, [hoveredItem, selectedItem
|
83382
|
+
return hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
|
83383
|
+
}, [hoveredItem, selectedItem]);
|
83277
83384
|
if (ref.current && !radius) {
|
83278
83385
|
return null;
|
83279
83386
|
}
|
83280
83387
|
const getActiveIndex = () => {
|
83281
83388
|
if (hoveredItem.length > 0) {
|
83282
|
-
return hoveredItem.map((itemId) =>
|
83389
|
+
return hoveredItem.map((itemId) => data.findIndex((element) => element.id === itemId));
|
83283
83390
|
}
|
83284
|
-
return selectedItem.map((selectedItemId) =>
|
83391
|
+
return selectedItem.map((selectedItemId) => data.findIndex((element) => element.id === selectedItemId));
|
83285
83392
|
};
|
83286
83393
|
const content = () => {
|
83287
83394
|
const elements = React.Children.toArray(children).filter(
|
83288
|
-
(child) => React.isValidElement(child)
|
83395
|
+
(child) => React.isValidElement(child)
|
83289
83396
|
);
|
83290
83397
|
return elements.length > 0 ? elements.map((child, index2) => {
|
83291
83398
|
return /* @__PURE__ */ React.createElement(
|
@@ -83298,112 +83405,112 @@ const DonutChart = function DonutChart2({
|
|
83298
83405
|
);
|
83299
83406
|
}) : /* @__PURE__ */ React.createElement(Cell, { key: "empty-chart", name: "", fill: getThemeColor("grey-200") });
|
83300
83407
|
};
|
83301
|
-
return /* @__PURE__ */ React.createElement(
|
83302
|
-
|
83408
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative flex h-full w-full", ref }, /* @__PURE__ */ React.createElement(CenteredLabel, { radius, label, total, formatter }), /* @__PURE__ */ React.createElement(PieChart$1, { data, height: diameter, width: diameter, style: { transform: "rotate(90deg) scale(-1,1)" } }, /* @__PURE__ */ React.createElement(
|
83409
|
+
Pie,
|
83303
83410
|
{
|
83304
|
-
|
83305
|
-
|
83306
|
-
|
83307
|
-
|
83308
|
-
|
83411
|
+
isAnimationActive: false,
|
83412
|
+
activeIndex: getActiveIndex(),
|
83413
|
+
activeShape: /* @__PURE__ */ React.createElement(ActiveShape, { pieColors: activeShapeColor, onClick: handlePieClick }),
|
83414
|
+
data: data.length > 0 ? data : [],
|
83415
|
+
dataKey: "value",
|
83416
|
+
innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
|
83417
|
+
onMouseEnter: (segment) => data.length > 0 && setHoveredItem([segment.id]),
|
83418
|
+
onMouseLeave: () => setHoveredItem([]),
|
83419
|
+
outerRadius: radius - HOVER_DONUT_WIDTH,
|
83420
|
+
stroke: "0",
|
83421
|
+
rootTabIndex: -1
|
83422
|
+
},
|
83423
|
+
content()
|
83424
|
+
)), /* @__PURE__ */ React.createElement(
|
83425
|
+
Legend,
|
83426
|
+
{
|
83427
|
+
data,
|
83428
|
+
onClick: handleLegendClick,
|
83429
|
+
total,
|
83430
|
+
setHoveredItem,
|
83431
|
+
label,
|
83432
|
+
hoveredItem,
|
83433
|
+
selectedItem,
|
83434
|
+
formatter
|
83435
|
+
}
|
83436
|
+
));
|
83437
|
+
};
|
83438
|
+
LegacyDonutChart.Segment = Segment$1;
|
83439
|
+
function LineChart(props) {
|
83440
|
+
const {
|
83441
|
+
children,
|
83442
|
+
data,
|
83443
|
+
dataKey,
|
83444
|
+
showDots = false,
|
83445
|
+
showLegend = false,
|
83446
|
+
showXAxis = true,
|
83447
|
+
showYAxis = false,
|
83448
|
+
tooltipTitle,
|
83449
|
+
type = "natural",
|
83450
|
+
xAxisScale,
|
83451
|
+
xAxisTickFormatter,
|
83452
|
+
yAxisScale,
|
83453
|
+
yAxisTickFormatter,
|
83454
|
+
...attributes
|
83455
|
+
} = props;
|
83456
|
+
const className = clsx("aspect-video", attributes.className);
|
83457
|
+
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
|
83458
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-area" }, /* @__PURE__ */ React.createElement(
|
83459
|
+
LineChart$1,
|
83460
|
+
{
|
83461
|
+
data,
|
83462
|
+
margin: { bottom: 10, left: 10, right: 10, top: 10 }
|
83309
83463
|
},
|
83464
|
+
/* @__PURE__ */ React.createElement(CartesianGrid, { vertical: false }),
|
83465
|
+
/* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, { title: tooltipTitle }) }),
|
83310
83466
|
/* @__PURE__ */ React.createElement(
|
83311
|
-
|
83467
|
+
XAxis,
|
83312
83468
|
{
|
83313
|
-
|
83314
|
-
|
83315
|
-
label,
|
83316
|
-
total,
|
83317
|
-
formatter,
|
83318
|
-
showLegend
|
83469
|
+
...getAxisProps(xAxisScale, xAxisTickFormatter, dataKey),
|
83470
|
+
hide: !showXAxis
|
83319
83471
|
}
|
83320
83472
|
),
|
83321
|
-
/* @__PURE__ */ React.createElement(
|
83322
|
-
|
83323
|
-
|
83324
|
-
|
83325
|
-
|
83326
|
-
|
83327
|
-
|
83328
|
-
|
83329
|
-
|
83330
|
-
|
83331
|
-
|
83332
|
-
|
83333
|
-
|
83334
|
-
activeShape: /* @__PURE__ */ React.createElement(ActiveShape, { pieColors: activeShapeColor, onClick: handlePieClick }),
|
83335
|
-
data: displayedData.length > 0 ? displayedData : [],
|
83336
|
-
dataKey: "value",
|
83337
|
-
innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
|
83338
|
-
onMouseEnter: (segment) => displayedData.length > 0 && setHoveredItem([segment.id]),
|
83339
|
-
onMouseLeave: () => setHoveredItem([]),
|
83340
|
-
outerRadius: radius - HOVER_DONUT_WIDTH,
|
83341
|
-
paddingAngle: 2,
|
83342
|
-
rootTabIndex: -1
|
83343
|
-
},
|
83344
|
-
content()
|
83345
|
-
)),
|
83346
|
-
showLegend && /* @__PURE__ */ React.createElement(
|
83347
|
-
Legend,
|
83348
|
-
{
|
83349
|
-
data,
|
83350
|
-
visibleItems,
|
83351
|
-
onClick: handleLegendClick,
|
83352
|
-
total,
|
83353
|
-
setHoveredItem,
|
83354
|
-
label,
|
83355
|
-
legendPosition,
|
83356
|
-
hoveredItem,
|
83357
|
-
selectedItem,
|
83358
|
-
formatter
|
83359
|
-
}
|
83360
|
-
)
|
83361
|
-
);
|
83362
|
-
};
|
83363
|
-
DonutChart.Segment = Segment;
|
83364
|
-
const Line = (_) => null;
|
83365
|
-
const LineChart = function LineChart2(externalProps) {
|
83366
|
-
const { children, data, formatter, ...props } = externalProps;
|
83367
|
-
const [hoveredLine, setHoveredLine] = React.useState(null);
|
83368
|
-
const [activeLines, setActiveLines] = React.useState(() => {
|
83369
|
-
const keys2 = {};
|
83370
|
-
React.Children.forEach(children, (child) => {
|
83371
|
-
keys2[child.props.accessor] = true;
|
83372
|
-
});
|
83373
|
-
return keys2;
|
83473
|
+
/* @__PURE__ */ React.createElement(YAxis, { ...getAxisProps(yAxisScale, yAxisTickFormatter), hide: !showYAxis }),
|
83474
|
+
shapes.map((shape) => /* @__PURE__ */ React.createElement(Line$1, { key: shape.dataKey, ...shape, dot: showDots ? shape.dot : false, type }))
|
83475
|
+
)), showLegend ? /* @__PURE__ */ React.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83476
|
+
}
|
83477
|
+
function Line(_) {
|
83478
|
+
return null;
|
83479
|
+
}
|
83480
|
+
LineChart.Line = Line;
|
83481
|
+
function PieChart(props) {
|
83482
|
+
const { children, formatter, showLabels = false, showLegend = false, tooltipTitle, unit: unit2, ...attributes } = props;
|
83483
|
+
const { pieProps, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(children, {
|
83484
|
+
formatter,
|
83485
|
+
unit: unit2
|
83374
83486
|
});
|
83375
|
-
const
|
83376
|
-
|
83377
|
-
|
83378
|
-
|
83379
|
-
return
|
83380
|
-
|
83381
|
-
|
83382
|
-
|
83383
|
-
|
83384
|
-
|
83385
|
-
|
83386
|
-
|
83387
|
-
|
83388
|
-
|
83389
|
-
|
83390
|
-
|
83487
|
+
const className = clsx("aspect-square", attributes.className);
|
83488
|
+
return /* @__PURE__ */ React.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React.createElement(ChartContainer, { ...attributes, className, "data-taco": "chart-pie", onSetWidth: setRadius }, /* @__PURE__ */ React.createElement(PieChart$1, null, /* @__PURE__ */ React.createElement(Tooltip$1, { content: /* @__PURE__ */ React.createElement(Tooltip, { title: tooltipTitle }) }), /* @__PURE__ */ React.createElement(Pie, { ...pieProps, label: showLabels ? /* @__PURE__ */ React.createElement(Label, null) : void 0 }))), showLegend ? /* @__PURE__ */ React.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
|
83489
|
+
}
|
83490
|
+
function Segment(_) {
|
83491
|
+
return null;
|
83492
|
+
}
|
83493
|
+
PieChart.Segment = Segment;
|
83494
|
+
const RADIAN = Math.PI / 180;
|
83495
|
+
function Label(props) {
|
83496
|
+
var _a, _b;
|
83497
|
+
const { cx, cy, midAngle, name, innerRadius, outerRadius } = props;
|
83498
|
+
const radius = innerRadius + (outerRadius - innerRadius) * 0.7;
|
83499
|
+
const x3 = cx + radius * Math.cos(-midAngle * RADIAN);
|
83500
|
+
const y4 = cy + radius * Math.sin(-midAngle * RADIAN);
|
83501
|
+
return /* @__PURE__ */ React.createElement(
|
83502
|
+
"text",
|
83391
83503
|
{
|
83392
|
-
|
83393
|
-
|
83394
|
-
|
83395
|
-
|
83396
|
-
|
83397
|
-
|
83398
|
-
|
83399
|
-
|
83400
|
-
|
83401
|
-
|
83402
|
-
opacity: hoveredLine && child.props.accessor !== hoveredLine ? 0.3 : 1
|
83403
|
-
}
|
83404
|
-
))));
|
83405
|
-
};
|
83406
|
-
LineChart.Line = Line;
|
83504
|
+
x: x3,
|
83505
|
+
y: y4,
|
83506
|
+
fontSize: 12,
|
83507
|
+
fill: getInverseThemeColor(((_b = (_a = props.payload) == null ? void 0 : _a.payload) == null ? void 0 : _b.color) ?? ""),
|
83508
|
+
textAnchor: "middle",
|
83509
|
+
dominantBaseline: "middle"
|
83510
|
+
},
|
83511
|
+
name
|
83512
|
+
);
|
83513
|
+
}
|
83407
83514
|
const Button3 = React.forwardRef(function Button23(props, ref) {
|
83408
83515
|
const { ...attributes } = props;
|
83409
83516
|
const className = clsx(getButtonClasses(), props.className);
|
@@ -84007,43 +84114,57 @@ Navigation24.Link = Link3;
|
|
84007
84114
|
Navigation24.Section = Section;
|
84008
84115
|
Navigation24.Content = Content;
|
84009
84116
|
const DATASET_SIZE_MULTIPLIER = 15;
|
84117
|
+
function getDataKey(sorting, filters, hiddenColumns, search) {
|
84118
|
+
return [JSON.stringify(sorting), JSON.stringify(filters), JSON.stringify(hiddenColumns), JSON.stringify(search)].join("_");
|
84119
|
+
}
|
84010
84120
|
function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_PAGE_SIZE$1 }) {
|
84011
84121
|
const { pageSize } = options;
|
84012
84122
|
const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;
|
84013
84123
|
const length = React.useRef(0);
|
84014
84124
|
const [data, setData] = React.useState({ rows: [], pages: [], cache: {}, lastFetchedPage: void 0 });
|
84015
84125
|
const _pendingPageRequests = React.useRef({});
|
84016
|
-
const _lastRequestId = React.useRef();
|
84017
84126
|
const _lastUsedSorting = React.useRef([]);
|
84018
84127
|
const _lastUsedFilters = React.useRef([]);
|
84019
|
-
const _lastUsedSearch = React.useRef();
|
84020
84128
|
const _lastUsedHiddenColumns = React.useRef([]);
|
84021
|
-
|
84022
|
-
|
84023
|
-
|
84024
|
-
|
84025
|
-
|
84026
|
-
|
84027
|
-
|
84129
|
+
const _lastUsedSearch = React.useRef();
|
84130
|
+
async function loadPage(pageIndex, sorting, filters, hiddenColumns, search) {
|
84131
|
+
const hasDataChanged = JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) || JSON.stringify(hiddenColumns) !== JSON.stringify(_lastUsedHiddenColumns.current) || search !== _lastUsedSearch.current;
|
84132
|
+
if (hasDataChanged) {
|
84133
|
+
_lastUsedSorting.current = sorting;
|
84134
|
+
_lastUsedFilters.current = filters;
|
84135
|
+
_lastUsedSearch.current = search;
|
84136
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
84137
|
+
_pendingPageRequests.current = {};
|
84138
|
+
} else {
|
84139
|
+
if (_pendingPageRequests.current[pageIndex]) {
|
84140
|
+
return;
|
84141
|
+
}
|
84142
|
+
if (data.cache[pageIndex] && data.cache[pageIndex][0]) {
|
84143
|
+
return;
|
84144
|
+
}
|
84028
84145
|
}
|
84029
|
-
const
|
84030
|
-
_pendingPageRequests.current[pageIndex] =
|
84146
|
+
const dataKey = getDataKey(sorting, filters, hiddenColumns, search);
|
84147
|
+
_pendingPageRequests.current[pageIndex] = dataKey;
|
84031
84148
|
try {
|
84032
|
-
_lastRequestId.current = requestId;
|
84033
84149
|
const response = await fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search);
|
84150
|
+
if (dataKey !== _pendingPageRequests.current[pageIndex]) {
|
84151
|
+
return;
|
84152
|
+
}
|
84034
84153
|
length.current = response.length;
|
84035
84154
|
setData((currentData) => {
|
84036
|
-
if (_lastRequestId.current !== requestId) {
|
84037
|
-
return currentData;
|
84038
|
-
}
|
84039
84155
|
const direction = getDirection(pageIndex, currentData.pages);
|
84040
|
-
const nextPages = getPages(
|
84156
|
+
const nextPages = getPages(
|
84157
|
+
pageIndex,
|
84158
|
+
currentData.lastFetchedPage,
|
84159
|
+
hasDataChanged ? [] : currentData.pages,
|
84160
|
+
direction
|
84161
|
+
);
|
84041
84162
|
_lastUsedSorting.current = sorting;
|
84042
84163
|
_lastUsedFilters.current = filters;
|
84043
84164
|
_lastUsedSearch.current = search;
|
84044
84165
|
_lastUsedHiddenColumns.current = hiddenColumns;
|
84045
84166
|
let nextCache;
|
84046
|
-
if (
|
84167
|
+
if (hasDataChanged || !direction) {
|
84047
84168
|
nextCache = nextPages.reduce((acc, p2) => ({ ...acc, [p2]: Array(pageSize).fill(void 0) }), {});
|
84048
84169
|
} else {
|
84049
84170
|
nextCache = { ...currentData.cache };
|
@@ -84062,7 +84183,9 @@ function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_
|
|
84062
84183
|
lastFetchedPage: pageIndex
|
84063
84184
|
};
|
84064
84185
|
});
|
84065
|
-
|
84186
|
+
requestAnimationFrame(() => {
|
84187
|
+
delete _pendingPageRequests.current[pageIndex];
|
84188
|
+
});
|
84066
84189
|
} catch {
|
84067
84190
|
}
|
84068
84191
|
}
|
@@ -84093,35 +84216,61 @@ function useTableDataLoader2(fetchPage, fetchAll, options = { pageSize: DEFAULT_
|
|
84093
84216
|
_pendingPageRequests.current = {};
|
84094
84217
|
}
|
84095
84218
|
};
|
84219
|
+
async function reloadCurrentPages(currentPageIndex, sorting, filters, hiddenColumns, search) {
|
84220
|
+
const index2 = data.pages.indexOf(currentPageIndex);
|
84221
|
+
const pageIndexes = [data.pages[index2 - 1], currentPageIndex, data.pages[index2 + 1]].filter((x3) => x3 !== void 0);
|
84222
|
+
const dataKey = getDataKey(sorting, filters, hiddenColumns, search);
|
84223
|
+
_pendingPageRequests.current = pageIndexes.reduce((accum, index22) => ({ ...accum, [index22]: dataKey }), {});
|
84224
|
+
try {
|
84225
|
+
const responses = await Promise.all(
|
84226
|
+
pageIndexes.map((pageIndex) => fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search))
|
84227
|
+
);
|
84228
|
+
length.current = responses[0].length;
|
84229
|
+
const nextPages = pageIndexes;
|
84230
|
+
_lastUsedSorting.current = sorting;
|
84231
|
+
_lastUsedFilters.current = filters;
|
84232
|
+
_lastUsedSearch.current = search;
|
84233
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
84234
|
+
const nextCache = nextPages.reduce(
|
84235
|
+
(acc, p2, index22) => ({ ...acc, [p2]: responses[index22].data }),
|
84236
|
+
{}
|
84237
|
+
);
|
84238
|
+
const rows = Object.values(nextCache).reduce((acc, p2) => acc.concat(p2), []);
|
84239
|
+
setData({
|
84240
|
+
cache: nextCache,
|
84241
|
+
pages: nextPages,
|
84242
|
+
rows,
|
84243
|
+
lastFetchedPage: pageIndexes[pageIndexes.length - 1]
|
84244
|
+
});
|
84245
|
+
requestAnimationFrame(() => {
|
84246
|
+
_pendingPageRequests.current = {};
|
84247
|
+
});
|
84248
|
+
} catch {
|
84249
|
+
}
|
84250
|
+
}
|
84096
84251
|
const invalidate = async () => {
|
84097
|
-
|
84098
|
-
return loadPage(
|
84252
|
+
return reloadCurrentPages(
|
84099
84253
|
getCurrentPage(data.pages),
|
84100
84254
|
_lastUsedSorting.current,
|
84101
84255
|
_lastUsedFilters.current,
|
84102
84256
|
_lastUsedHiddenColumns.current,
|
84103
|
-
_lastUsedSearch.current
|
84104
|
-
true
|
84257
|
+
_lastUsedSearch.current
|
84105
84258
|
);
|
84106
84259
|
};
|
84107
84260
|
const handleSort = async (sorting) => {
|
84108
|
-
|
84109
|
-
return loadPage(
|
84261
|
+
return reloadCurrentPages(
|
84110
84262
|
getCurrentPage(data.pages),
|
84111
84263
|
sorting,
|
84112
84264
|
_lastUsedFilters.current,
|
84113
84265
|
_lastUsedHiddenColumns.current,
|
84114
|
-
_lastUsedSearch.current
|
84115
|
-
true
|
84266
|
+
_lastUsedSearch.current
|
84116
84267
|
);
|
84117
84268
|
};
|
84118
84269
|
const handleFilter = async (filters, hiddenColumns) => {
|
84119
|
-
|
84120
|
-
return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);
|
84270
|
+
return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current);
|
84121
84271
|
};
|
84122
84272
|
const handleSearch = async (search, hiddenColumns) => {
|
84123
|
-
|
84124
|
-
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);
|
84273
|
+
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search);
|
84125
84274
|
};
|
84126
84275
|
return [
|
84127
84276
|
{
|
@@ -84230,6 +84379,7 @@ exports.Icon = Icon$1;
|
|
84230
84379
|
exports.IconButton = IconButton;
|
84231
84380
|
exports.Input = Input;
|
84232
84381
|
exports.Layout = Layout;
|
84382
|
+
exports.LegacyDonutChart = LegacyDonutChart;
|
84233
84383
|
exports.LineChart = LineChart;
|
84234
84384
|
exports.List = List$1;
|
84235
84385
|
exports.Listbox = Listbox;
|
@@ -84243,6 +84393,7 @@ exports.Navigation2 = Navigation24;
|
|
84243
84393
|
exports.OverflowGroup = OverflowGroup;
|
84244
84394
|
exports.PaginatedTable = PaginatedTable;
|
84245
84395
|
exports.Pagination = Pagination;
|
84396
|
+
exports.PieChart = PieChart;
|
84246
84397
|
exports.Popover = Popover;
|
84247
84398
|
exports.Progress = Progress;
|
84248
84399
|
exports.Provider = Provider;
|