@economic/taco 2.46.5 → 2.46.7
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/charts/components/Area/AreaChart.d.ts +19 -0
- package/dist/charts/components/Bar/BarChart.d.ts +20 -0
- package/dist/charts/components/Donut/ActiveShape.d.ts +8 -0
- package/dist/charts/components/Donut/CenteredLabel.d.ts +11 -0
- package/dist/charts/components/Donut/DonutChart.d.ts +21 -0
- package/dist/charts/components/Donut/Legend.d.ts +13 -0
- package/dist/charts/components/Donut/util.d.ts +2 -0
- package/dist/charts/components/Legend.d.ts +16 -0
- package/dist/charts/components/Line/LineChart.d.ts +18 -0
- package/dist/charts/components/ResponsiveContainer.d.ts +5 -0
- package/dist/charts/components/Tooltip.d.ts +10 -0
- package/dist/charts/components/types.d.ts +5 -0
- package/dist/charts/utils/color.d.ts +3 -0
- package/dist/charts/utils/common.d.ts +37 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
- package/dist/components/Table3/features/useEditingState.d.ts +1 -1
- package/dist/components/Table3/features/useTableEditing.d.ts +4 -3
- package/dist/esm/index.css +18 -0
- package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js +67 -0
- package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js +120 -0
- package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js +47 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js +27 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js +170 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +164 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/util.js +5 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/util.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js +145 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js +65 -0
- package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js +10 -0
- package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js +44 -0
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/utils/color.js +24 -0
- package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/utils/common.js +34 -0
- package/dist/esm/packages/taco/src/charts/utils/common.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -33
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +4 -4
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +32 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +4 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +4 -0
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +5 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +6 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +5 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/colors.js +122 -0
- package/dist/esm/packages/taco/src/utils/colors.js.map +1 -0
- package/dist/index.css +18 -0
- package/dist/index.d.ts +5 -0
- package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
- package/dist/primitives/Table/Core/types.d.ts +1 -0
- package/dist/taco.cjs.development.js +881 -55
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +3 -3
- package/tailwind.config.js +3 -2
|
@@ -48,6 +48,7 @@ var setWith = _interopDefault(require('lodash/setWith'));
|
|
|
48
48
|
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
49
49
|
var Joyride = require('react-joyride');
|
|
50
50
|
var Joyride__default = _interopDefault(Joyride);
|
|
51
|
+
var Recharts = require('recharts');
|
|
51
52
|
|
|
52
53
|
const AVAILABLE_COLORS = ['green', 'yellow', 'red', 'blue', 'purple', 'brown', 'pink', 'orange', 'grey', 'transparent'];
|
|
53
54
|
const getColorByState = state => {
|
|
@@ -5245,7 +5246,7 @@ const getInputClasses = props => {
|
|
|
5245
5246
|
const disabled = props.disabled || !!props['aria-disabled'];
|
|
5246
5247
|
const readOnly = props.readOnly || !!props['aria-readonly'];
|
|
5247
5248
|
const invalid = props.invalid || !!props['aria-invalid'];
|
|
5248
|
-
return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus
|
|
5249
|
+
return cn('peer text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)] focus:yt-focus',
|
|
5249
5250
|
// hide the arrow controls on input[type=number]
|
|
5250
5251
|
'[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none', {
|
|
5251
5252
|
'bg-white': !props.highlighted && !readOnly,
|
|
@@ -12115,9 +12116,10 @@ const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props,
|
|
|
12115
12116
|
});
|
|
12116
12117
|
|
|
12117
12118
|
const RowContext = /*#__PURE__*/React__default.createContext({
|
|
12119
|
+
hideInternalColumns: false,
|
|
12120
|
+
hideRowActions: false,
|
|
12118
12121
|
isHovered: false,
|
|
12119
|
-
rowIndex: -1
|
|
12120
|
-
hideRowActions: false
|
|
12122
|
+
rowIndex: -1
|
|
12121
12123
|
});
|
|
12122
12124
|
|
|
12123
12125
|
/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */
|
|
@@ -12125,6 +12127,7 @@ function Row(props) {
|
|
|
12125
12127
|
const {
|
|
12126
12128
|
renderer: RowRenderer,
|
|
12127
12129
|
cellRenderer: CellRenderer,
|
|
12130
|
+
hideInternalColumns = false,
|
|
12128
12131
|
hideRowActions = false,
|
|
12129
12132
|
...displayRowProps
|
|
12130
12133
|
} = props;
|
|
@@ -12134,8 +12137,9 @@ function Row(props) {
|
|
|
12134
12137
|
const contextValue = React__default.useMemo(() => ({
|
|
12135
12138
|
isHovered,
|
|
12136
12139
|
rowIndex: props.index,
|
|
12140
|
+
hideInternalColumns,
|
|
12137
12141
|
hideRowActions
|
|
12138
|
-
}), [isHovered, props.index, hideRowActions]);
|
|
12142
|
+
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
|
12139
12143
|
if (props.row.original === undefined) {
|
|
12140
12144
|
return /*#__PURE__*/React__default.createElement(SkeletonRow, Object.assign({}, props));
|
|
12141
12145
|
}
|
|
@@ -12233,12 +12237,16 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
|
|
|
12233
12237
|
// rendered output
|
|
12234
12238
|
let style = {};
|
|
12235
12239
|
let content = null;
|
|
12236
|
-
|
|
12240
|
+
// bottom rows aren't virtualised (they're sticky) but we need to set the height
|
|
12241
|
+
if (rows.length || table.getBottomRows().length) {
|
|
12237
12242
|
style = {
|
|
12238
12243
|
height: totalSize,
|
|
12239
12244
|
paddingBottom,
|
|
12240
12245
|
paddingTop
|
|
12241
12246
|
};
|
|
12247
|
+
}
|
|
12248
|
+
// only render non sticky rows
|
|
12249
|
+
if (rows.length) {
|
|
12242
12250
|
content = virtualItems.map(virtualRow => {
|
|
12243
12251
|
// there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
|
|
12244
12252
|
if (!virtualRow) {
|
|
@@ -12396,9 +12404,9 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
|
12396
12404
|
table
|
|
12397
12405
|
} = context;
|
|
12398
12406
|
const {
|
|
12407
|
+
hideRowActions,
|
|
12399
12408
|
isHovered,
|
|
12400
|
-
rowIndex
|
|
12401
|
-
hideRowActions
|
|
12409
|
+
rowIndex
|
|
12402
12410
|
} = React__default.useContext(RowContext);
|
|
12403
12411
|
const tableMeta = table.options.meta;
|
|
12404
12412
|
const actions = tableMeta.rowActions.rowActions;
|
|
@@ -12438,6 +12446,12 @@ function Cell$1() {
|
|
|
12438
12446
|
const {
|
|
12439
12447
|
texts
|
|
12440
12448
|
} = useLocalization();
|
|
12449
|
+
const {
|
|
12450
|
+
hideInternalColumns
|
|
12451
|
+
} = React__default.useContext(RowContext);
|
|
12452
|
+
if (hideInternalColumns) {
|
|
12453
|
+
return null;
|
|
12454
|
+
}
|
|
12441
12455
|
return /*#__PURE__*/React__default.createElement(Icon, {
|
|
12442
12456
|
"aria-label": texts.table.columns.drag.tooltip,
|
|
12443
12457
|
name: "drag",
|
|
@@ -12486,7 +12500,13 @@ function Cell$2(context) {
|
|
|
12486
12500
|
const {
|
|
12487
12501
|
texts
|
|
12488
12502
|
} = useLocalization();
|
|
12503
|
+
const {
|
|
12504
|
+
hideInternalColumns
|
|
12505
|
+
} = React__default.useContext(RowContext);
|
|
12489
12506
|
const tableMeta = context.table.options.meta;
|
|
12507
|
+
if (hideInternalColumns) {
|
|
12508
|
+
return null;
|
|
12509
|
+
}
|
|
12490
12510
|
const hasExpandedRow = (_tableMeta$rowExpansi = (_tableMeta$rowExpansi2 = tableMeta.rowExpansion).rowExpansionRenderer) === null || _tableMeta$rowExpansi === void 0 ? void 0 : _tableMeta$rowExpansi.call(_tableMeta$rowExpansi2, context.row.original);
|
|
12491
12511
|
if (hasExpandedRow) {
|
|
12492
12512
|
const isActiveRow = tableMeta.rowActive.rowActiveIndex === context.row.index;
|
|
@@ -12576,10 +12596,11 @@ function Cell$3(context) {
|
|
|
12576
12596
|
table
|
|
12577
12597
|
} = context;
|
|
12578
12598
|
const {
|
|
12599
|
+
hideInternalColumns,
|
|
12579
12600
|
rowIndex
|
|
12580
12601
|
} = React__default.useContext(RowContext);
|
|
12581
12602
|
const tableMeta = table.options.meta;
|
|
12582
|
-
if (table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
|
12603
|
+
if (hideInternalColumns || table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
|
|
12583
12604
|
return null;
|
|
12584
12605
|
}
|
|
12585
12606
|
const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
|
|
@@ -13815,9 +13836,15 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
|
|
|
13815
13836
|
function EmptyStateBody(props) {
|
|
13816
13837
|
const {
|
|
13817
13838
|
emptyState: Placeholder,
|
|
13839
|
+
isReady,
|
|
13818
13840
|
reason,
|
|
13819
13841
|
...attributes
|
|
13820
13842
|
} = props;
|
|
13843
|
+
if (!isReady) {
|
|
13844
|
+
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
|
13845
|
+
className: "!auto-rows-fr"
|
|
13846
|
+
}));
|
|
13847
|
+
}
|
|
13821
13848
|
return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
|
|
13822
13849
|
className: "!auto-rows-fr"
|
|
13823
13850
|
}), /*#__PURE__*/React__default.createElement("tr", {
|
|
@@ -16815,7 +16842,7 @@ function Table(props) {
|
|
|
16815
16842
|
}
|
|
16816
16843
|
Table.Toolbar = TableToolbar;
|
|
16817
16844
|
Table.Grid = TableGrid;
|
|
16818
|
-
function
|
|
16845
|
+
function getEmptyStateReason(table) {
|
|
16819
16846
|
if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {
|
|
16820
16847
|
const state = table.instance.getState();
|
|
16821
16848
|
if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {
|
|
@@ -16838,7 +16865,7 @@ function TableGrid(props) {
|
|
|
16838
16865
|
const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
|
|
16839
16866
|
table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
|
|
16840
16867
|
} : undefined;
|
|
16841
|
-
const
|
|
16868
|
+
const emptyStateReason = getEmptyStateReason(table);
|
|
16842
16869
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("style", null, table.stylesheet), /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
|
|
16843
16870
|
id: table.id,
|
|
16844
16871
|
"data-table-font-size": table.meta.fontSize.size,
|
|
@@ -16859,9 +16886,10 @@ function TableGrid(props) {
|
|
|
16859
16886
|
key: props.id,
|
|
16860
16887
|
header: props,
|
|
16861
16888
|
scrollToIndex: table.renderer.scrollToIndex
|
|
16862
|
-
}))))))),
|
|
16889
|
+
}))))))), emptyStateReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
|
|
16863
16890
|
emptyState: props.table.props.emptyState,
|
|
16864
|
-
|
|
16891
|
+
isReady: table.meta.server.isEnabled ? table.meta.server.isReady : true,
|
|
16892
|
+
reason: emptyStateReason
|
|
16865
16893
|
})) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
|
|
16866
16894
|
enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
|
|
16867
16895
|
table: table.instance,
|
|
@@ -18505,9 +18533,9 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
|
18505
18533
|
const onClickOutside = event => {
|
|
18506
18534
|
if (tableMeta.editing.isEditing) {
|
|
18507
18535
|
const element = event.target;
|
|
18508
|
-
const
|
|
18536
|
+
const isTableOrIsInsideTable = element.tagName === 'TABLE' || element.tagName === 'TBODY' || element.getAttribute('data-taco') === 'backdrop' || element.getAttribute('data-table') === 'editing-toggle' || !document.body.contains(element) || isElementInsideOrTriggeredFromContainer(element, tableRef.current);
|
|
18509
18537
|
// users can click the white space below rows which could be inside the table, but a valid scenario to save
|
|
18510
|
-
if (!
|
|
18538
|
+
if (!isTableOrIsInsideTable) {
|
|
18511
18539
|
tableMeta.editing.saveChanges(table);
|
|
18512
18540
|
}
|
|
18513
18541
|
}
|
|
@@ -18658,7 +18686,7 @@ function reducer$2(state, action) {
|
|
|
18658
18686
|
}
|
|
18659
18687
|
};
|
|
18660
18688
|
}
|
|
18661
|
-
case '
|
|
18689
|
+
case 'insertTemporaryRow':
|
|
18662
18690
|
{
|
|
18663
18691
|
const {
|
|
18664
18692
|
value
|
|
@@ -18945,14 +18973,14 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
|
18945
18973
|
}
|
|
18946
18974
|
});
|
|
18947
18975
|
}
|
|
18948
|
-
function
|
|
18976
|
+
function insertTemporaryRow(data) {
|
|
18949
18977
|
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
|
|
18950
18978
|
const value = {
|
|
18951
18979
|
...data,
|
|
18952
18980
|
[rowIdentityAccessor]: newRowId
|
|
18953
18981
|
};
|
|
18954
18982
|
dispatch({
|
|
18955
|
-
type: '
|
|
18983
|
+
type: 'insertTemporaryRow',
|
|
18956
18984
|
rowId: newRowId,
|
|
18957
18985
|
payload: {
|
|
18958
18986
|
value
|
|
@@ -19046,12 +19074,42 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
|
19046
19074
|
discardChanges,
|
|
19047
19075
|
hasSaved,
|
|
19048
19076
|
// new rows
|
|
19049
|
-
|
|
19077
|
+
insertTemporaryRow,
|
|
19050
19078
|
temporaryRows: state.temporaryRows
|
|
19051
19079
|
};
|
|
19052
19080
|
}
|
|
19053
19081
|
|
|
19054
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentityAccessor, validator) {
|
|
19082
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
|
|
19083
|
+
const createRow = function (table, scrollToIndex, row) {
|
|
19084
|
+
try {
|
|
19085
|
+
if (!handleCreate) {
|
|
19086
|
+
return Promise.resolve();
|
|
19087
|
+
}
|
|
19088
|
+
const tableMeta = table.options.meta;
|
|
19089
|
+
return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
|
|
19090
|
+
if (!saved) {
|
|
19091
|
+
return;
|
|
19092
|
+
}
|
|
19093
|
+
const changeset = row !== null && row !== void 0 ? row : handleCreate();
|
|
19094
|
+
try {
|
|
19095
|
+
if (changeset) {
|
|
19096
|
+
const rowId = pendingChangesFns.insertTemporaryRow(changeset);
|
|
19097
|
+
table.getRow(rowId).pin('bottom');
|
|
19098
|
+
// set the active row to the new row before toggling editing on
|
|
19099
|
+
const temporaryRows = tableMeta.editing.temporaryRows;
|
|
19100
|
+
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
|
19101
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
|
19102
|
+
toggleEditing(true, table, scrollToIndex);
|
|
19103
|
+
setLastFocusedCellIndex(undefined);
|
|
19104
|
+
}
|
|
19105
|
+
} catch (error) {
|
|
19106
|
+
console.error(error);
|
|
19107
|
+
}
|
|
19108
|
+
});
|
|
19109
|
+
} catch (e) {
|
|
19110
|
+
return Promise.reject(e);
|
|
19111
|
+
}
|
|
19112
|
+
};
|
|
19055
19113
|
// used to switch the table into editing mode
|
|
19056
19114
|
const [isEditing, setEditing] = React__default.useState(false);
|
|
19057
19115
|
// used to switch the editing between "detailed" mode
|
|
@@ -19089,6 +19147,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentit
|
|
|
19089
19147
|
toggleEditing: isEnabled ? toggleEditing : () => undefined,
|
|
19090
19148
|
lastFocusedCellIndex,
|
|
19091
19149
|
setLastFocusedCellIndex,
|
|
19150
|
+
createRow,
|
|
19092
19151
|
createRowButtonRef,
|
|
19093
19152
|
...pendingChangesFns
|
|
19094
19153
|
};
|
|
@@ -19762,7 +19821,7 @@ const RENDERERS$1 = {
|
|
|
19762
19821
|
cell: Cell$5
|
|
19763
19822
|
};
|
|
19764
19823
|
function useTable3(props, ref) {
|
|
19765
|
-
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.rowIdentityAccessor, props.validator);
|
|
19824
|
+
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.rowIdentityAccessor, props.validator);
|
|
19766
19825
|
const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
|
|
19767
19826
|
// this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
|
|
19768
19827
|
const data = React__default.useMemo(() => {
|
|
@@ -19815,6 +19874,9 @@ function useTable3(props, ref) {
|
|
|
19815
19874
|
React__default.useEffect(() => {
|
|
19816
19875
|
if (table.ref.current) {
|
|
19817
19876
|
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
|
|
19877
|
+
if (props.onEditingCreate) {
|
|
19878
|
+
table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance, table.renderer.scrollToIndex, row);
|
|
19879
|
+
}
|
|
19818
19880
|
}
|
|
19819
19881
|
}, [table.ref.current]);
|
|
19820
19882
|
return table;
|
|
@@ -19972,10 +20034,9 @@ function Editing(props) {
|
|
|
19972
20034
|
}
|
|
19973
20035
|
|
|
19974
20036
|
function CreateNewRow(props) {
|
|
19975
|
-
var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum
|
|
20037
|
+
var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum;
|
|
19976
20038
|
const {
|
|
19977
20039
|
buttonRef,
|
|
19978
|
-
onEditingCreate: handleEditingCreate,
|
|
19979
20040
|
scrollToIndex,
|
|
19980
20041
|
table,
|
|
19981
20042
|
tableMeta,
|
|
@@ -19988,44 +20049,16 @@ function CreateNewRow(props) {
|
|
|
19988
20049
|
const temporaryRowId = (_temporaryRows$0$tabl = (_temporaryRows$ = temporaryRows[0]) === null || _temporaryRows$ === void 0 ? void 0 : _temporaryRows$[tableMeta.rowIdentityAccessor]) !== null && _temporaryRows$0$tabl !== void 0 ? _temporaryRows$0$tabl : '';
|
|
19989
20050
|
const isDisabled = !!table.getState().globalFilter || !!((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length) || !!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId);
|
|
19990
20051
|
const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
|
|
19991
|
-
const
|
|
20052
|
+
const handleCreate = function () {
|
|
19992
20053
|
try {
|
|
19993
|
-
if (
|
|
20054
|
+
if (isDisabled) {
|
|
19994
20055
|
return Promise.resolve();
|
|
19995
20056
|
}
|
|
19996
|
-
return Promise.resolve(tableMeta.editing.
|
|
19997
|
-
if (!saved) {
|
|
19998
|
-
return;
|
|
19999
|
-
}
|
|
20000
|
-
const changeset = row !== null && row !== void 0 ? row : handleEditingCreate();
|
|
20001
|
-
try {
|
|
20002
|
-
if (changeset) {
|
|
20003
|
-
const rowId = tableMeta.editing.createRow(changeset);
|
|
20004
|
-
table.getRow(rowId).pin('bottom');
|
|
20005
|
-
// set the active row to the new row before toggling editing on
|
|
20006
|
-
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
|
20007
|
-
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
|
20008
|
-
tableMeta.editing.toggleEditing(true, table, scrollToIndex);
|
|
20009
|
-
tableMeta.editing.setLastFocusedCellIndex(0);
|
|
20010
|
-
}
|
|
20011
|
-
} catch (error) {
|
|
20012
|
-
console.error(error);
|
|
20013
|
-
}
|
|
20014
|
-
});
|
|
20057
|
+
return Promise.resolve(tableMeta.editing.createRow(table, scrollToIndex)).then(function () {});
|
|
20015
20058
|
} catch (e) {
|
|
20016
20059
|
return Promise.reject(e);
|
|
20017
20060
|
}
|
|
20018
20061
|
};
|
|
20019
|
-
// allow programmatic access to creating rows from outside the table
|
|
20020
|
-
React__default.useEffect(() => {
|
|
20021
|
-
var _tableRef$current;
|
|
20022
|
-
if (tableRef !== null && tableRef !== void 0 && (_tableRef$current = tableRef.current) !== null && _tableRef$current !== void 0 && _tableRef$current.instance) {
|
|
20023
|
-
tableRef.current.instance.createRow = createRow;
|
|
20024
|
-
}
|
|
20025
|
-
}, [tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.instance, createRow]);
|
|
20026
|
-
const handleCreate = function () {
|
|
20027
|
-
return createRow();
|
|
20028
|
-
};
|
|
20029
20062
|
const shortcut = {
|
|
20030
20063
|
key: 'Enter',
|
|
20031
20064
|
meta: true
|
|
@@ -20148,7 +20181,7 @@ function TemporaryRow(props) {
|
|
|
20148
20181
|
className: className,
|
|
20149
20182
|
onKeyDown: handleKeyDown,
|
|
20150
20183
|
onKeyDownCapture: handleKeyDownCapture,
|
|
20151
|
-
|
|
20184
|
+
hideInternalColumns: true,
|
|
20152
20185
|
hideRowActions: !tableMeta.editing.isEditing
|
|
20153
20186
|
}))));
|
|
20154
20187
|
}
|
|
@@ -20190,7 +20223,6 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
|
20190
20223
|
tableRef: table3.ref
|
|
20191
20224
|
}), /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
|
20192
20225
|
buttonRef: table3.meta.editing.createRowButtonRef,
|
|
20193
|
-
onEditingCreate: props.onEditingCreate,
|
|
20194
20226
|
scrollToIndex: table3.renderer.scrollToIndex,
|
|
20195
20227
|
table: table3.instance,
|
|
20196
20228
|
tableMeta: table3.meta,
|
|
@@ -20431,6 +20463,796 @@ const Tour = props => {
|
|
|
20431
20463
|
};
|
|
20432
20464
|
Tour.Step = TourStep;
|
|
20433
20465
|
|
|
20466
|
+
// NOTE: this file is intentianally a js file so that it can be consumed by tailwind.config.js
|
|
20467
|
+
|
|
20468
|
+
const THEME_COLORS = {
|
|
20469
|
+
transparent: 'transparent',
|
|
20470
|
+
current: 'currentColor',
|
|
20471
|
+
white: '#fff',
|
|
20472
|
+
black: '#1c1c1c',
|
|
20473
|
+
brand: {
|
|
20474
|
+
vismaRed: '#E70641',
|
|
20475
|
+
paleOrange: '#FFF5E5',
|
|
20476
|
+
sunsetOrange: '#E89C2E',
|
|
20477
|
+
midnightBlue: '#29283E',
|
|
20478
|
+
coolBlue: '#F5F7F9'
|
|
20479
|
+
},
|
|
20480
|
+
grey: {
|
|
20481
|
+
lightest: '#fafafa',
|
|
20482
|
+
light: '#F6F6F6',
|
|
20483
|
+
DEFAULT: '#EBEBEB',
|
|
20484
|
+
dark: '#DDDDDD',
|
|
20485
|
+
darker: '#ACACAC',
|
|
20486
|
+
darkest: '#595959',
|
|
20487
|
+
darkNew: '#a5a6a9',
|
|
20488
|
+
50: '#fafafa',
|
|
20489
|
+
100: '#F6F6F6',
|
|
20490
|
+
200: '#EBEBEB',
|
|
20491
|
+
300: '#DDDDDD',
|
|
20492
|
+
500: '#ACACAC',
|
|
20493
|
+
700: '#595959',
|
|
20494
|
+
900: '#303030'
|
|
20495
|
+
},
|
|
20496
|
+
purple: {
|
|
20497
|
+
lightest: '#585c74',
|
|
20498
|
+
light: '#4b4f64',
|
|
20499
|
+
DEFAULT: '#3d4153',
|
|
20500
|
+
dark: '#353a48',
|
|
20501
|
+
darker: '#29283e',
|
|
20502
|
+
darkest: '#212032',
|
|
20503
|
+
darkNew_1: '#373647',
|
|
20504
|
+
darkNew_2: '#414050',
|
|
20505
|
+
100: '#EEE5FF',
|
|
20506
|
+
200: '#ddd1ff',
|
|
20507
|
+
300: '#CBBCFE',
|
|
20508
|
+
500: '#9270FA',
|
|
20509
|
+
700: '#6542D1',
|
|
20510
|
+
900: '#412970'
|
|
20511
|
+
},
|
|
20512
|
+
blue: {
|
|
20513
|
+
lightest: '#DEEBFF',
|
|
20514
|
+
light: '#75A0F5',
|
|
20515
|
+
DEFAULT: '#4573D2',
|
|
20516
|
+
dark: '#2B57B4',
|
|
20517
|
+
100: '#DEEBFF',
|
|
20518
|
+
200: '#AACCFF',
|
|
20519
|
+
300: '#75A0F5',
|
|
20520
|
+
500: '#4573D2',
|
|
20521
|
+
700: '#2B57B4',
|
|
20522
|
+
900: '#29283E'
|
|
20523
|
+
},
|
|
20524
|
+
red: {
|
|
20525
|
+
lightest: '#FFDAD2',
|
|
20526
|
+
light: '#E66568',
|
|
20527
|
+
DEFAULT: '#CE3F42',
|
|
20528
|
+
dark: '#950027',
|
|
20529
|
+
100: '#FFDAD2',
|
|
20530
|
+
200: '#f3a09d',
|
|
20531
|
+
300: '#E66568',
|
|
20532
|
+
500: '#CE3F42',
|
|
20533
|
+
700: '#950027',
|
|
20534
|
+
900: '#64001B'
|
|
20535
|
+
},
|
|
20536
|
+
green: {
|
|
20537
|
+
lightest: '#cdf0e7',
|
|
20538
|
+
light: '#52C7AB',
|
|
20539
|
+
DEFAULT: '#08AE87',
|
|
20540
|
+
dark: '#028465',
|
|
20541
|
+
100: '#cdf0e7',
|
|
20542
|
+
200: '#9be1ce',
|
|
20543
|
+
300: '#52C7AB',
|
|
20544
|
+
500: '#08AE87',
|
|
20545
|
+
700: '#028465',
|
|
20546
|
+
900: '#14493A'
|
|
20547
|
+
},
|
|
20548
|
+
yellow: {
|
|
20549
|
+
lightest: '#FFF1C3',
|
|
20550
|
+
light: '#FFD665',
|
|
20551
|
+
DEFAULT: '#FFBD3B',
|
|
20552
|
+
dark: '#e89c2e',
|
|
20553
|
+
100: '#FFF1C3',
|
|
20554
|
+
200: '#ffe494',
|
|
20555
|
+
300: '#FFD665',
|
|
20556
|
+
500: '#FFBD3B',
|
|
20557
|
+
700: '#e89c2e',
|
|
20558
|
+
900: '#733700'
|
|
20559
|
+
},
|
|
20560
|
+
pink: {
|
|
20561
|
+
100: '#FFE3F7',
|
|
20562
|
+
200: '#fcb9e9',
|
|
20563
|
+
300: '#F98EDB',
|
|
20564
|
+
500: '#E165BF',
|
|
20565
|
+
700: '#CF49AA',
|
|
20566
|
+
900: '#870062'
|
|
20567
|
+
},
|
|
20568
|
+
brown: {
|
|
20569
|
+
100: '#EEE0DA',
|
|
20570
|
+
200: '#DFCCC2',
|
|
20571
|
+
300: '#C4AB9E',
|
|
20572
|
+
500: '#93715D',
|
|
20573
|
+
700: '#73503B',
|
|
20574
|
+
900: '#45291F'
|
|
20575
|
+
},
|
|
20576
|
+
orange: {
|
|
20577
|
+
100: '#FFE3BB',
|
|
20578
|
+
200: '#FCCB80',
|
|
20579
|
+
300: '#FAB64D',
|
|
20580
|
+
500: '#F99702',
|
|
20581
|
+
700: '#EF7D00',
|
|
20582
|
+
900: '#4A2811'
|
|
20583
|
+
}
|
|
20584
|
+
};
|
|
20585
|
+
|
|
20586
|
+
const mapColor = (palette, prefix = '') => {
|
|
20587
|
+
return Object.keys(palette).reduce((accum, color) => {
|
|
20588
|
+
if (color === 'current') {
|
|
20589
|
+
return accum;
|
|
20590
|
+
} else if (typeof palette[color] === 'string') {
|
|
20591
|
+
return {
|
|
20592
|
+
...accum,
|
|
20593
|
+
[prefix ? color === 'DEFAULT' ? prefix : `${prefix}-${color}` : color]: palette[color]
|
|
20594
|
+
};
|
|
20595
|
+
} else {
|
|
20596
|
+
return {
|
|
20597
|
+
...accum,
|
|
20598
|
+
...mapColor(palette[color], color)
|
|
20599
|
+
};
|
|
20600
|
+
}
|
|
20601
|
+
}, {});
|
|
20602
|
+
};
|
|
20603
|
+
const colors = /*#__PURE__*/mapColor(THEME_COLORS);
|
|
20604
|
+
const getThemeColor = color => colors[color];
|
|
20605
|
+
|
|
20606
|
+
function Legend(props) {
|
|
20607
|
+
const {
|
|
20608
|
+
activeIndex,
|
|
20609
|
+
onMouseEnter,
|
|
20610
|
+
onMouseLeave,
|
|
20611
|
+
onClick,
|
|
20612
|
+
payload,
|
|
20613
|
+
layout,
|
|
20614
|
+
activeItems
|
|
20615
|
+
} = props;
|
|
20616
|
+
const [hoverIndex, setHoverIndex] = React.useState(null);
|
|
20617
|
+
const handleMouseEnter = (entry, index) => {
|
|
20618
|
+
setHoverIndex(index);
|
|
20619
|
+
if (activeItems[entry.dataKey]) onMouseEnter(entry, index);
|
|
20620
|
+
};
|
|
20621
|
+
const handleMouseLeave = () => {
|
|
20622
|
+
onMouseLeave();
|
|
20623
|
+
setHoverIndex(null);
|
|
20624
|
+
};
|
|
20625
|
+
const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
|
|
20626
|
+
appearance: "transparent",
|
|
20627
|
+
className: "text-grey-700"
|
|
20628
|
+
}, moreButtonText));
|
|
20629
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
20630
|
+
className: "mx-auto w-auto max-w-full overflow-hidden"
|
|
20631
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
20632
|
+
className: cn('mb-0 ml-0 flex justify-center', {
|
|
20633
|
+
'flex-col': layout === 'vertical'
|
|
20634
|
+
})
|
|
20635
|
+
}, /*#__PURE__*/React__default.createElement(OverflowGroup, {
|
|
20636
|
+
className: "w-full items-center py-1",
|
|
20637
|
+
moreButton: moreButton
|
|
20638
|
+
}, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement("span", {
|
|
20639
|
+
key: `${entry.dataKey}-${index}`,
|
|
20640
|
+
className: cn(' hover:bg-grey-100 cursor-pointer px-[8px] py-[2px] hover:rounded-[4px]', {
|
|
20641
|
+
'bg-grey-100 rounded': activeIndex === index
|
|
20642
|
+
}),
|
|
20643
|
+
onMouseEnter: () => handleMouseEnter(entry, index),
|
|
20644
|
+
onMouseLeave: handleMouseLeave,
|
|
20645
|
+
onClick: onClick ? () => onClick(entry) : undefined
|
|
20646
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20647
|
+
className: "text-grey-700 flex items-center gap-[4px]"
|
|
20648
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20649
|
+
className: cn('-mt-px ml-1 flex h-3 w-3 rounded-sm', {
|
|
20650
|
+
'border-grey-300 border !bg-white': !activeItems[entry.dataKey]
|
|
20651
|
+
}),
|
|
20652
|
+
style: {
|
|
20653
|
+
backgroundColor: entry.color
|
|
20654
|
+
}
|
|
20655
|
+
}, hoverIndex === index && activeItems[entry.dataKey] && (/*#__PURE__*/React__default.createElement(Icon, {
|
|
20656
|
+
name: "tick-bold",
|
|
20657
|
+
className: "!h-full !w-full text-white"
|
|
20658
|
+
}))), entry.value)))))));
|
|
20659
|
+
}
|
|
20660
|
+
|
|
20661
|
+
const Tooltip$2 = ({
|
|
20662
|
+
active,
|
|
20663
|
+
formatter,
|
|
20664
|
+
payload,
|
|
20665
|
+
style,
|
|
20666
|
+
singlePieDonutChart
|
|
20667
|
+
}) => {
|
|
20668
|
+
const getColor = entry => {
|
|
20669
|
+
var _ref, _entry$color;
|
|
20670
|
+
if (singlePieDonutChart) {
|
|
20671
|
+
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
|
20672
|
+
// and one with multiple pies.
|
|
20673
|
+
return getThemeColor(entry.payload.color);
|
|
20674
|
+
}
|
|
20675
|
+
return (_ref = (_entry$color = entry.color) !== null && _entry$color !== void 0 ? _entry$color : entry.payload.fill) !== null && _ref !== void 0 ? _ref : 'blue-500';
|
|
20676
|
+
};
|
|
20677
|
+
if (active && payload && payload.length) {
|
|
20678
|
+
return /*#__PURE__*/React__default.createElement("dl", {
|
|
20679
|
+
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)]",
|
|
20680
|
+
style: style
|
|
20681
|
+
}, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement(React__default.Fragment, {
|
|
20682
|
+
key: `${entry.name}-${index}`
|
|
20683
|
+
}, /*#__PURE__*/React__default.createElement("dt", {
|
|
20684
|
+
className: "text-grey-700 mb-0 flex items-center gap-1 font-normal"
|
|
20685
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20686
|
+
className: "-mt-px h-2.5 w-2.5 rounded-sm",
|
|
20687
|
+
style: {
|
|
20688
|
+
background: getColor(entry)
|
|
20689
|
+
}
|
|
20690
|
+
}),
|
|
20691
|
+
// We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
|
|
20692
|
+
// and one with multiple pies.
|
|
20693
|
+
singlePieDonutChart ? entry.payload.label : entry.name), /*#__PURE__*/React__default.createElement("dd", {
|
|
20694
|
+
className: "mb-0 text-right font-bold text-black "
|
|
20695
|
+
}, formatter ? formatter(entry.value) : entry.value)))));
|
|
20696
|
+
}
|
|
20697
|
+
return null;
|
|
20698
|
+
};
|
|
20699
|
+
|
|
20700
|
+
const getCartesianGridProps = () => ({
|
|
20701
|
+
vertical: false
|
|
20702
|
+
});
|
|
20703
|
+
const getXAxisProps = props => ({
|
|
20704
|
+
axisLine: false,
|
|
20705
|
+
dataKey: props.accessor,
|
|
20706
|
+
fontSize: 12,
|
|
20707
|
+
scale: props.xAxisScale,
|
|
20708
|
+
tickLine: false,
|
|
20709
|
+
tickFormatter: props.xAxisTickFormat
|
|
20710
|
+
});
|
|
20711
|
+
const getYAxisProps = props => ({
|
|
20712
|
+
axisLine: false,
|
|
20713
|
+
fontSize: 12,
|
|
20714
|
+
scale: props.yAxisScale,
|
|
20715
|
+
tickLine: false,
|
|
20716
|
+
tickFormatter: props.yAxisTickFormat
|
|
20717
|
+
});
|
|
20718
|
+
const getLegendProps = props => ({
|
|
20719
|
+
content: /*#__PURE__*/React__default.createElement(Legend, Object.assign({}, props))
|
|
20720
|
+
});
|
|
20721
|
+
const getTooltipProps = (props = undefined) => ({
|
|
20722
|
+
content: /*#__PURE__*/React__default.createElement(Tooltip$2, Object.assign({}, props)),
|
|
20723
|
+
wrapperStyle: {
|
|
20724
|
+
outline: 'none'
|
|
20725
|
+
}
|
|
20726
|
+
});
|
|
20727
|
+
|
|
20728
|
+
// A hacky fix for EC-50037 to make sure that Chart doesn't resize when it is inside a Card.
|
|
20729
|
+
const ResponsiveContainer = props => (/*#__PURE__*/React__default.createElement(Recharts.ResponsiveContainer, Object.assign({
|
|
20730
|
+
className: "!h-[calc(100%-1px)] !w-[calc(100%-1px)]"
|
|
20731
|
+
}, props)));
|
|
20732
|
+
|
|
20733
|
+
const Area = _ => null;
|
|
20734
|
+
const AreaChart = function AreaChart(externalProps) {
|
|
20735
|
+
const {
|
|
20736
|
+
children,
|
|
20737
|
+
data,
|
|
20738
|
+
formatter,
|
|
20739
|
+
...props
|
|
20740
|
+
} = externalProps;
|
|
20741
|
+
const [hoveredArea, setHoveredArea] = React.useState(null);
|
|
20742
|
+
const [activeAreas, setActiveAreas] = React.useState(() => {
|
|
20743
|
+
const areas = {};
|
|
20744
|
+
React__default.Children.forEach(children, child => {
|
|
20745
|
+
areas[child.props.accessor] = true;
|
|
20746
|
+
});
|
|
20747
|
+
return areas;
|
|
20748
|
+
});
|
|
20749
|
+
const handleLegendClick = entry => {
|
|
20750
|
+
setHoveredArea(null);
|
|
20751
|
+
setActiveAreas({
|
|
20752
|
+
...activeAreas,
|
|
20753
|
+
[entry.dataKey]: !activeAreas[entry.dataKey]
|
|
20754
|
+
});
|
|
20755
|
+
};
|
|
20756
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.AreaChart, {
|
|
20757
|
+
data: data,
|
|
20758
|
+
margin: {
|
|
20759
|
+
top: 10,
|
|
20760
|
+
right: 0,
|
|
20761
|
+
left: -25,
|
|
20762
|
+
bottom: 0
|
|
20763
|
+
}
|
|
20764
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(Recharts.XAxis, Object.assign({}, getXAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.YAxis, Object.assign({}, getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.Legend, Object.assign({}, getLegendProps({
|
|
20765
|
+
onClick: handleLegendClick,
|
|
20766
|
+
onMouseEnter: entry => setHoveredArea(entry.dataKey),
|
|
20767
|
+
onMouseLeave: () => setHoveredArea(null),
|
|
20768
|
+
activeItems: activeAreas
|
|
20769
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
|
20770
|
+
formatter: formatter
|
|
20771
|
+
})), React__default.Children.map(children, child => {
|
|
20772
|
+
var _child$props$color, _child$props$color2, _child$props$color3;
|
|
20773
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Area, {
|
|
20774
|
+
activeDot: {
|
|
20775
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
|
20776
|
+
},
|
|
20777
|
+
isAnimationActive: false,
|
|
20778
|
+
dataKey: child.props.accessor,
|
|
20779
|
+
dot: false,
|
|
20780
|
+
fill: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'grey-100'),
|
|
20781
|
+
name: child.props.label,
|
|
20782
|
+
strokeWidth: 2,
|
|
20783
|
+
stroke: getThemeColor((_child$props$color3 = child.props.color) !== null && _child$props$color3 !== void 0 ? _child$props$color3 : 'grey-300'),
|
|
20784
|
+
stackId: child.props.stackId,
|
|
20785
|
+
hide: !activeAreas[child.props.accessor],
|
|
20786
|
+
opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
|
|
20787
|
+
});
|
|
20788
|
+
})));
|
|
20789
|
+
};
|
|
20790
|
+
AreaChart.Area = Area;
|
|
20791
|
+
|
|
20792
|
+
const Bar$1 = _ => null;
|
|
20793
|
+
const getXAxisVerticalProps = props => ({
|
|
20794
|
+
...getXAxisProps(props),
|
|
20795
|
+
...{
|
|
20796
|
+
type: 'number',
|
|
20797
|
+
dataKey: undefined
|
|
20798
|
+
}
|
|
20799
|
+
});
|
|
20800
|
+
const getYAxisVerticalProps = props => ({
|
|
20801
|
+
...getYAxisProps(props),
|
|
20802
|
+
...{
|
|
20803
|
+
dataKey: props.accessor,
|
|
20804
|
+
type: 'category'
|
|
20805
|
+
}
|
|
20806
|
+
});
|
|
20807
|
+
const BarChart = function BarChart(externalProps) {
|
|
20808
|
+
const {
|
|
20809
|
+
children,
|
|
20810
|
+
data,
|
|
20811
|
+
formatter,
|
|
20812
|
+
layout = 'horizontal',
|
|
20813
|
+
...props
|
|
20814
|
+
} = externalProps;
|
|
20815
|
+
const [activeIndex, setActiveIndex] = React__default.useState(undefined);
|
|
20816
|
+
const [hoveredBar, setHoveredBar] = React.useState(null);
|
|
20817
|
+
const [activeBars, setActiveBars] = React.useState(() => {
|
|
20818
|
+
const keys = {};
|
|
20819
|
+
React__default.Children.forEach(children, child => {
|
|
20820
|
+
keys[child.props.accessor] = true;
|
|
20821
|
+
});
|
|
20822
|
+
return keys;
|
|
20823
|
+
});
|
|
20824
|
+
// Recharts doesn't provide a way for us to know if a stacked bar is at the top or the bottom,
|
|
20825
|
+
// so we can't set proper radiuses without some "magic"
|
|
20826
|
+
const stacks = {};
|
|
20827
|
+
React__default.Children.forEach(children, child => {
|
|
20828
|
+
if (child.props.stackId) {
|
|
20829
|
+
if (!stacks[child.props.stackId]) {
|
|
20830
|
+
stacks[child.props.stackId] = [child.props.accessor];
|
|
20831
|
+
} else {
|
|
20832
|
+
stacks[child.props.stackId].push(child.props.accessor);
|
|
20833
|
+
}
|
|
20834
|
+
}
|
|
20835
|
+
});
|
|
20836
|
+
const handleLegendClick = entry => {
|
|
20837
|
+
setHoveredBar(null);
|
|
20838
|
+
setActiveBars({
|
|
20839
|
+
...activeBars,
|
|
20840
|
+
[entry.dataKey]: !activeBars[entry.dataKey]
|
|
20841
|
+
});
|
|
20842
|
+
};
|
|
20843
|
+
const handleLegendHover = (entry, index) => {
|
|
20844
|
+
setHoveredBar(entry.dataKey);
|
|
20845
|
+
setActiveIndex(index);
|
|
20846
|
+
};
|
|
20847
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.BarChart, {
|
|
20848
|
+
layout: layout,
|
|
20849
|
+
data: data,
|
|
20850
|
+
margin: {
|
|
20851
|
+
top: 10,
|
|
20852
|
+
right: 0,
|
|
20853
|
+
left: layout === 'vertical' ? 0 : -25,
|
|
20854
|
+
bottom: 0
|
|
20855
|
+
},
|
|
20856
|
+
onMouseMove: chartState => setActiveIndex(chartState.activeTooltipIndex),
|
|
20857
|
+
onMouseLeave: () => setActiveIndex(undefined)
|
|
20858
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(Recharts.XAxis, Object.assign({}, layout === 'vertical' ? getXAxisVerticalProps(props) : getXAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.YAxis, Object.assign({}, layout === 'vertical' ? getYAxisVerticalProps(props) : getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.Legend, Object.assign({}, getLegendProps({
|
|
20859
|
+
onClick: handleLegendClick,
|
|
20860
|
+
onMouseEnter: handleLegendHover,
|
|
20861
|
+
onMouseLeave: () => setHoveredBar(null),
|
|
20862
|
+
activeItems: activeBars
|
|
20863
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
|
20864
|
+
formatter: formatter
|
|
20865
|
+
})), React__default.Children.map(children, child => (/*#__PURE__*/React__default.createElement(Recharts.Bar, {
|
|
20866
|
+
isAnimationActive: false,
|
|
20867
|
+
barSize: 16,
|
|
20868
|
+
dataKey: child.props.accessor,
|
|
20869
|
+
name: child.props.label,
|
|
20870
|
+
onMouseEnter: (_, index) => setActiveIndex(index),
|
|
20871
|
+
onMouseLeave: () => setActiveIndex(undefined),
|
|
20872
|
+
fill: getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`),
|
|
20873
|
+
radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
|
|
20874
|
+
stackId: child.props.stackId,
|
|
20875
|
+
style: child.props.stackId ? {
|
|
20876
|
+
stroke: '#fff',
|
|
20877
|
+
strokeWidth: '2px'
|
|
20878
|
+
} : undefined,
|
|
20879
|
+
hide: !activeBars[child.props.accessor]
|
|
20880
|
+
}, data.map((_, index) => (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
|
20881
|
+
key: `cell-${index}`,
|
|
20882
|
+
opacity: hoveredBar && child.props.accessor !== hoveredBar || activeIndex !== undefined && activeIndex !== index ? 0.3 : 1
|
|
20883
|
+
}))))))));
|
|
20884
|
+
};
|
|
20885
|
+
BarChart.Bar = Bar$1;
|
|
20886
|
+
const getBarRadius = (stacks, accessor, stackId, activeBars) => {
|
|
20887
|
+
if (stackId && Array.isArray(stacks[stackId])) {
|
|
20888
|
+
const length = stacks[stackId].length - 1;
|
|
20889
|
+
const index = stacks[stackId].indexOf(accessor);
|
|
20890
|
+
if (Object.entries(activeBars).filter(item => item[0] !== accessor).every(item => !item[1])) {
|
|
20891
|
+
return [3, 3, 0, 0];
|
|
20892
|
+
}
|
|
20893
|
+
if (activeBars[stacks[stackId][index + 1]] === false) {
|
|
20894
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length - 1 ? 0 : 3, index === length - 1 ? 0 : 3];
|
|
20895
|
+
}
|
|
20896
|
+
if (index !== 0 && index !== length) {
|
|
20897
|
+
return 0;
|
|
20898
|
+
}
|
|
20899
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length ? 0 : 3, index === length ? 0 : 3];
|
|
20900
|
+
}
|
|
20901
|
+
return 3;
|
|
20902
|
+
};
|
|
20903
|
+
|
|
20904
|
+
const Legend$1 = ({
|
|
20905
|
+
legendPosition,
|
|
20906
|
+
hoveredItem,
|
|
20907
|
+
selectedItem,
|
|
20908
|
+
data,
|
|
20909
|
+
onClick,
|
|
20910
|
+
setHoveredItem,
|
|
20911
|
+
formatter,
|
|
20912
|
+
total,
|
|
20913
|
+
visibleItems,
|
|
20914
|
+
label
|
|
20915
|
+
}) => {
|
|
20916
|
+
const isTotalLegendSelected = selectedItem.length === data.length;
|
|
20917
|
+
const isTotalLegendHovered = hoveredItem.length === data.length;
|
|
20918
|
+
const handleMouseLeave = () => setHoveredItem([]);
|
|
20919
|
+
const renderLegendItem = (entry, index) => {
|
|
20920
|
+
const isTotal = entry === null;
|
|
20921
|
+
// We can't use `isTotal` here because TypeScript is unable to infer the type when `entry` is not null.
|
|
20922
|
+
const itemData = entry === null ? {
|
|
20923
|
+
id: 'total',
|
|
20924
|
+
label,
|
|
20925
|
+
value: total,
|
|
20926
|
+
color: 'grey-300'
|
|
20927
|
+
} : entry;
|
|
20928
|
+
const isSelected = isTotal ? isTotalLegendSelected : selectedItem.includes(itemData.id);
|
|
20929
|
+
const isHovered = isTotal ? isTotalLegendHovered : hoveredItem.includes(itemData.id);
|
|
20930
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
20931
|
+
key: isTotal ? 'total' : `${itemData.label}-${index}`,
|
|
20932
|
+
className: cn('mr-2 flex cursor-pointer gap-2 rounded pl-0 pr-1', {
|
|
20933
|
+
'bg-grey-100': isHovered && (!isTotal || legendPosition === 'right'),
|
|
20934
|
+
'bg-grey-200': isSelected && (!isTotal || legendPosition === 'right')
|
|
20935
|
+
}),
|
|
20936
|
+
onClick: () => onClick(isTotal ? data : itemData),
|
|
20937
|
+
onMouseEnter: () => setHoveredItem(isTotal ? data.map(item => item.id) : [itemData.id]),
|
|
20938
|
+
onMouseLeave: handleMouseLeave
|
|
20939
|
+
}, legendPosition === 'bottom' ? (/*#__PURE__*/React__default.createElement("div", {
|
|
20940
|
+
className: "flex items-center gap-1"
|
|
20941
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20942
|
+
className: cn('ml-1 h-3 w-3 rounded-sm', {
|
|
20943
|
+
'border-grey-300 border !bg-white': !visibleItems[itemData.id]
|
|
20944
|
+
}),
|
|
20945
|
+
style: {
|
|
20946
|
+
backgroundColor: getThemeColor(itemData.color)
|
|
20947
|
+
}
|
|
20948
|
+
}, visibleItems[itemData.id] && isHovered && (/*#__PURE__*/React__default.createElement(Icon, {
|
|
20949
|
+
name: "tick-bold",
|
|
20950
|
+
className: "mb-2.5 !h-full !w-full text-white"
|
|
20951
|
+
}))), /*#__PURE__*/React__default.createElement("div", null, itemData.label))) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
20952
|
+
className: "ml-1 mt-1 h-9 w-2 rounded-[1px]",
|
|
20953
|
+
style: {
|
|
20954
|
+
backgroundColor: getThemeColor(itemData.color)
|
|
20955
|
+
}
|
|
20956
|
+
}), /*#__PURE__*/React__default.createElement("div", null, itemData.label, /*#__PURE__*/React__default.createElement("span", {
|
|
20957
|
+
className: "-mt-1 flex w-full text-lg font-bold"
|
|
20958
|
+
}, formatter ? formatter(itemData.value) : itemData.value)))));
|
|
20959
|
+
};
|
|
20960
|
+
const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
|
|
20961
|
+
appearance: "transparent",
|
|
20962
|
+
className: "text-grey-700"
|
|
20963
|
+
}, moreButtonText));
|
|
20964
|
+
const className = cn('flex-grow pl-4', {
|
|
20965
|
+
'w-full': legendPosition === 'bottom'
|
|
20966
|
+
});
|
|
20967
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
20968
|
+
className: className
|
|
20969
|
+
}, /*#__PURE__*/React__default.createElement("ul", {
|
|
20970
|
+
className: cn('mb-0 ml-0 mt-4 flex justify-center space-y-1', legendPosition === 'right' ? 'flex-col gap-1' : 'flex-row')
|
|
20971
|
+
}, legendPosition === 'right' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderLegendItem(null), data.map(renderLegendItem))) : (/*#__PURE__*/React__default.createElement(OverflowGroup, {
|
|
20972
|
+
className: "w-full items-center py-1",
|
|
20973
|
+
moreButton: moreButton
|
|
20974
|
+
}, data.map(renderLegendItem)))));
|
|
20975
|
+
};
|
|
20976
|
+
|
|
20977
|
+
const DONUT_WIDTH = 16;
|
|
20978
|
+
const HOVER_DONUT_WIDTH = 10;
|
|
20979
|
+
|
|
20980
|
+
const CenteredLabel = ({
|
|
20981
|
+
radius,
|
|
20982
|
+
legendPosition,
|
|
20983
|
+
label,
|
|
20984
|
+
total,
|
|
20985
|
+
formatter,
|
|
20986
|
+
showLegend
|
|
20987
|
+
}) => {
|
|
20988
|
+
const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
|
|
20989
|
+
const diameter = radius * 2;
|
|
20990
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
20991
|
+
className: "absolute mt-1 flex h-12 flex-col text-center",
|
|
20992
|
+
style: {
|
|
20993
|
+
top: `calc(${radius}px - (3rem / 2))`,
|
|
20994
|
+
left: legendPosition === 'right' ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,
|
|
20995
|
+
width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`
|
|
20996
|
+
}
|
|
20997
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
20998
|
+
className: "w-full truncate text-lg font-bold"
|
|
20999
|
+
}, formatter ? formatter(total) : total), label);
|
|
21000
|
+
};
|
|
21001
|
+
|
|
21002
|
+
const ActiveShape = props => {
|
|
21003
|
+
var _getThemeColor;
|
|
21004
|
+
const {
|
|
21005
|
+
cx,
|
|
21006
|
+
cy,
|
|
21007
|
+
id,
|
|
21008
|
+
innerRadius,
|
|
21009
|
+
onClick,
|
|
21010
|
+
outerRadius = 0,
|
|
21011
|
+
pieColors,
|
|
21012
|
+
startAngle,
|
|
21013
|
+
endAngle,
|
|
21014
|
+
fill
|
|
21015
|
+
} = props;
|
|
21016
|
+
return /*#__PURE__*/React__default.createElement("g", {
|
|
21017
|
+
onClick: () => onClick(id),
|
|
21018
|
+
className: cn({
|
|
21019
|
+
'cursor-pointer': !!onClick
|
|
21020
|
+
})
|
|
21021
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.Sector, {
|
|
21022
|
+
cx: cx,
|
|
21023
|
+
cy: cy,
|
|
21024
|
+
innerRadius: innerRadius,
|
|
21025
|
+
outerRadius: outerRadius,
|
|
21026
|
+
startAngle: startAngle,
|
|
21027
|
+
endAngle: endAngle,
|
|
21028
|
+
fill: fill
|
|
21029
|
+
}), /*#__PURE__*/React__default.createElement(Recharts.Sector, {
|
|
21030
|
+
cx: cx,
|
|
21031
|
+
cy: cy,
|
|
21032
|
+
startAngle: startAngle,
|
|
21033
|
+
endAngle: endAngle,
|
|
21034
|
+
innerRadius: outerRadius + 2,
|
|
21035
|
+
outerRadius: outerRadius + HOVER_DONUT_WIDTH,
|
|
21036
|
+
fill: id !== undefined ? (_getThemeColor = getThemeColor(pieColors[id])) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-500') : getThemeColor('blue-500'),
|
|
21037
|
+
opacity: 0.3
|
|
21038
|
+
}));
|
|
21039
|
+
};
|
|
21040
|
+
|
|
21041
|
+
const Segment = _ => null;
|
|
21042
|
+
const DonutChart = function DonutChart({
|
|
21043
|
+
children,
|
|
21044
|
+
formatter,
|
|
21045
|
+
onClick,
|
|
21046
|
+
showLegend = false,
|
|
21047
|
+
legendPosition = 'bottom',
|
|
21048
|
+
label
|
|
21049
|
+
}) {
|
|
21050
|
+
const ref = React__default.useRef(null);
|
|
21051
|
+
const [radius, setRadius] = React__default.useState(0);
|
|
21052
|
+
const [hoveredItem, setHoveredItem] = React__default.useState([]);
|
|
21053
|
+
// used for right legends
|
|
21054
|
+
const [selectedItem, setSelectedItem] = React__default.useState([]);
|
|
21055
|
+
// used for bottom legends
|
|
21056
|
+
const [visibleItems, setVisibleItems] = React__default.useState(() => {
|
|
21057
|
+
const keys = {};
|
|
21058
|
+
React__default.Children.forEach(children, child => {
|
|
21059
|
+
keys[child.props.id] = true;
|
|
21060
|
+
});
|
|
21061
|
+
return keys;
|
|
21062
|
+
});
|
|
21063
|
+
React__default.useEffect(() => {
|
|
21064
|
+
if (ref.current) {
|
|
21065
|
+
var _ref$current$parentEl;
|
|
21066
|
+
const rect = (_ref$current$parentEl = ref.current.parentElement) === null || _ref$current$parentEl === void 0 ? void 0 : _ref$current$parentEl.getBoundingClientRect();
|
|
21067
|
+
if (rect) {
|
|
21068
|
+
const width = showLegend ? rect.width / 2 : rect.width;
|
|
21069
|
+
const max = rect.height < width ? rect.height : width;
|
|
21070
|
+
setRadius(max / 2);
|
|
21071
|
+
}
|
|
21072
|
+
}
|
|
21073
|
+
}, [showLegend]);
|
|
21074
|
+
const diameter = radius * 2; // get dimensions of the parent container to find the max radius, so we can fill the container AND always have a 16px wide donut
|
|
21075
|
+
const data = React__default.Children.map(children, child => ({
|
|
21076
|
+
id: child.props.id,
|
|
21077
|
+
color: child.props.color,
|
|
21078
|
+
label: child.props.label,
|
|
21079
|
+
value: child.props.value
|
|
21080
|
+
}));
|
|
21081
|
+
const displayedData = data.filter(child => visibleItems[child.id]);
|
|
21082
|
+
const total = displayedData.reduce((accum, entry) => accum + entry.value, 0);
|
|
21083
|
+
const showTooltip = (!showLegend || legendPosition === 'bottom') && displayedData.length > 0;
|
|
21084
|
+
const handleLegendClick = entry => {
|
|
21085
|
+
if (legendPosition === 'bottom' && !Array.isArray(entry)) {
|
|
21086
|
+
setVisibleItems({
|
|
21087
|
+
...visibleItems,
|
|
21088
|
+
[entry.id]: !visibleItems[entry.id]
|
|
21089
|
+
});
|
|
21090
|
+
} else {
|
|
21091
|
+
const nextSelectedItem = Array.isArray(entry) ? entry.map(entryItem => entryItem.id) : [entry.id];
|
|
21092
|
+
// Using slice to avoid mutation of the react state 'selectedItem'
|
|
21093
|
+
const isCurrentSegmentActive = selectedItem.slice().sort().join(',') === nextSelectedItem.sort().join(',');
|
|
21094
|
+
if (onClick && !isCurrentSegmentActive) {
|
|
21095
|
+
onClick(entry);
|
|
21096
|
+
}
|
|
21097
|
+
setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
|
|
21098
|
+
}
|
|
21099
|
+
};
|
|
21100
|
+
const handlePieClick = React__default.useCallback(pieId => {
|
|
21101
|
+
if (onClick && pieId !== undefined) {
|
|
21102
|
+
const pieProps = displayedData.find(item => item.id === pieId);
|
|
21103
|
+
onClick(pieProps);
|
|
21104
|
+
}
|
|
21105
|
+
}, [onClick, displayedData]);
|
|
21106
|
+
const singlePieDonutChart = displayedData.length === 1;
|
|
21107
|
+
const activeShapeColor = React__default.useMemo(() => {
|
|
21108
|
+
const getSegmentColor = item => item.reduce((colors, itemId) => {
|
|
21109
|
+
const visibleHoveredItem = displayedData.find(dataItem => dataItem.id === itemId);
|
|
21110
|
+
if (visibleHoveredItem) {
|
|
21111
|
+
colors[visibleHoveredItem.id] = visibleHoveredItem.color;
|
|
21112
|
+
}
|
|
21113
|
+
return colors;
|
|
21114
|
+
}, {});
|
|
21115
|
+
const hoveredSegmentColor = getSegmentColor(hoveredItem);
|
|
21116
|
+
const selectedSegmentColor = getSegmentColor(selectedItem);
|
|
21117
|
+
return legendPosition === 'bottom' || hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
|
|
21118
|
+
}, [hoveredItem, selectedItem, legendPosition]);
|
|
21119
|
+
if (ref.current && !radius) {
|
|
21120
|
+
return null;
|
|
21121
|
+
}
|
|
21122
|
+
const getActiveIndex = () => {
|
|
21123
|
+
if (hoveredItem.length > 0) {
|
|
21124
|
+
return hoveredItem.map(itemId => displayedData.findIndex(element => element.id === itemId));
|
|
21125
|
+
}
|
|
21126
|
+
return selectedItem.map(selectedItemId => displayedData.findIndex(element => element.id === selectedItemId));
|
|
21127
|
+
};
|
|
21128
|
+
const content = () => {
|
|
21129
|
+
const elements = React__default.Children.toArray(children).filter(child => /*#__PURE__*/React__default.isValidElement(child) && visibleItems[child.props.id]);
|
|
21130
|
+
return elements.length > 0 ? elements.map((child, index) => {
|
|
21131
|
+
var _getThemeColor;
|
|
21132
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
|
21133
|
+
key: `cell-${index}`,
|
|
21134
|
+
name: child.props.label,
|
|
21135
|
+
fill: (_getThemeColor = getThemeColor(child.props.color)) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-300')
|
|
21136
|
+
});
|
|
21137
|
+
}) : (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
|
|
21138
|
+
key: "empty-chart",
|
|
21139
|
+
name: '',
|
|
21140
|
+
fill: getThemeColor('grey-200')
|
|
21141
|
+
}));
|
|
21142
|
+
};
|
|
21143
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
21144
|
+
className: cn('relative h-full w-full', {
|
|
21145
|
+
[`flex `]: showLegend,
|
|
21146
|
+
'flex-col items-center': legendPosition === 'bottom'
|
|
21147
|
+
}),
|
|
21148
|
+
ref: ref
|
|
21149
|
+
}, /*#__PURE__*/React__default.createElement(CenteredLabel, {
|
|
21150
|
+
radius: radius,
|
|
21151
|
+
legendPosition: legendPosition,
|
|
21152
|
+
label: label,
|
|
21153
|
+
total: total,
|
|
21154
|
+
formatter: formatter,
|
|
21155
|
+
showLegend: showLegend
|
|
21156
|
+
}), /*#__PURE__*/React__default.createElement(Recharts.PieChart, {
|
|
21157
|
+
data: data,
|
|
21158
|
+
height: diameter,
|
|
21159
|
+
width: diameter,
|
|
21160
|
+
style: {
|
|
21161
|
+
transform: 'rotate(90deg) scale(-1,1)'
|
|
21162
|
+
}
|
|
21163
|
+
}, showTooltip ? (/*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps({
|
|
21164
|
+
style: {
|
|
21165
|
+
transform: 'rotate(90deg) scale(-1,1)'
|
|
21166
|
+
},
|
|
21167
|
+
singlePieDonutChart
|
|
21168
|
+
})))) : null, /*#__PURE__*/React__default.createElement(Recharts.Pie, {
|
|
21169
|
+
isAnimationActive: false,
|
|
21170
|
+
activeIndex: getActiveIndex(),
|
|
21171
|
+
activeShape: /*#__PURE__*/React__default.createElement(ActiveShape, {
|
|
21172
|
+
pieColors: activeShapeColor,
|
|
21173
|
+
onClick: handlePieClick
|
|
21174
|
+
}),
|
|
21175
|
+
data: displayedData.length > 0 ? displayedData : [],
|
|
21176
|
+
dataKey: "value",
|
|
21177
|
+
innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
|
|
21178
|
+
onMouseEnter: segment => displayedData.length > 0 && setHoveredItem([segment.id]),
|
|
21179
|
+
onMouseLeave: () => setHoveredItem([]),
|
|
21180
|
+
outerRadius: radius - HOVER_DONUT_WIDTH,
|
|
21181
|
+
paddingAngle: 2,
|
|
21182
|
+
// Prevents the pie group element from being focusable
|
|
21183
|
+
rootTabIndex: -1
|
|
21184
|
+
}, content())), showLegend && (/*#__PURE__*/React__default.createElement(Legend$1, {
|
|
21185
|
+
data: data,
|
|
21186
|
+
visibleItems: visibleItems,
|
|
21187
|
+
onClick: handleLegendClick,
|
|
21188
|
+
total: total,
|
|
21189
|
+
setHoveredItem: setHoveredItem,
|
|
21190
|
+
label: label,
|
|
21191
|
+
legendPosition: legendPosition,
|
|
21192
|
+
hoveredItem: hoveredItem,
|
|
21193
|
+
selectedItem: selectedItem,
|
|
21194
|
+
formatter: formatter
|
|
21195
|
+
})));
|
|
21196
|
+
};
|
|
21197
|
+
DonutChart.Segment = Segment;
|
|
21198
|
+
|
|
21199
|
+
const Line$1 = _ => null;
|
|
21200
|
+
const LineChart = function LineChart(externalProps) {
|
|
21201
|
+
const {
|
|
21202
|
+
children,
|
|
21203
|
+
data,
|
|
21204
|
+
formatter,
|
|
21205
|
+
...props
|
|
21206
|
+
} = externalProps;
|
|
21207
|
+
const [hoveredLine, setHoveredLine] = React.useState(null);
|
|
21208
|
+
const [activeLines, setActiveLines] = React.useState(() => {
|
|
21209
|
+
const keys = {};
|
|
21210
|
+
React__default.Children.forEach(children, child => {
|
|
21211
|
+
keys[child.props.accessor] = true;
|
|
21212
|
+
});
|
|
21213
|
+
return keys;
|
|
21214
|
+
});
|
|
21215
|
+
const handleLegendClick = entry => {
|
|
21216
|
+
setHoveredLine(null);
|
|
21217
|
+
setActiveLines({
|
|
21218
|
+
...activeLines,
|
|
21219
|
+
[entry.dataKey]: !activeLines[entry.dataKey]
|
|
21220
|
+
});
|
|
21221
|
+
};
|
|
21222
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.LineChart, {
|
|
21223
|
+
data: data,
|
|
21224
|
+
margin: {
|
|
21225
|
+
top: 10,
|
|
21226
|
+
right: 0,
|
|
21227
|
+
left: -25,
|
|
21228
|
+
bottom: 0
|
|
21229
|
+
}
|
|
21230
|
+
}, /*#__PURE__*/React__default.createElement(Recharts.CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(Recharts.XAxis, Object.assign({}, getXAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.YAxis, Object.assign({}, getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Recharts.Legend, Object.assign({}, getLegendProps({
|
|
21231
|
+
onClick: handleLegendClick,
|
|
21232
|
+
onMouseEnter: entry => setHoveredLine(entry.dataKey),
|
|
21233
|
+
onMouseLeave: () => setHoveredLine(null),
|
|
21234
|
+
activeItems: activeLines
|
|
21235
|
+
}))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
|
|
21236
|
+
formatter: formatter
|
|
21237
|
+
})), React__default.Children.map(children, child => {
|
|
21238
|
+
var _child$props$color, _child$props$color2;
|
|
21239
|
+
return /*#__PURE__*/React__default.createElement(Recharts.Line, {
|
|
21240
|
+
activeDot: {
|
|
21241
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
|
21242
|
+
},
|
|
21243
|
+
dataKey: child.props.accessor,
|
|
21244
|
+
isAnimationActive: false,
|
|
21245
|
+
dot: false,
|
|
21246
|
+
name: child.props.label,
|
|
21247
|
+
stroke: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'blue-300'),
|
|
21248
|
+
strokeWidth: 2,
|
|
21249
|
+
hide: !activeLines[child.props.accessor],
|
|
21250
|
+
opacity: hoveredLine && child.props.accessor !== hoveredLine ? 0.3 : 1
|
|
21251
|
+
});
|
|
21252
|
+
})));
|
|
21253
|
+
};
|
|
21254
|
+
LineChart.Line = Line$1;
|
|
21255
|
+
|
|
20434
21256
|
const Button$4 = /*#__PURE__*/React__default.forwardRef(function Button(props, ref) {
|
|
20435
21257
|
const {
|
|
20436
21258
|
...attributes
|
|
@@ -21175,10 +21997,12 @@ const useOnClickOutside = (ref, callback) => {
|
|
|
21175
21997
|
exports.Accordion = Accordion;
|
|
21176
21998
|
exports.Alert = Alert;
|
|
21177
21999
|
exports.AlertDialog = AlertDialog;
|
|
22000
|
+
exports.AreaChart = AreaChart;
|
|
21178
22001
|
exports.Backdrop = Backdrop;
|
|
21179
22002
|
exports.Badge = Badge;
|
|
21180
22003
|
exports.BadgeIcon = BadgeIcon;
|
|
21181
22004
|
exports.Banner = Banner;
|
|
22005
|
+
exports.BarChart = BarChart;
|
|
21182
22006
|
exports.Base = Base;
|
|
21183
22007
|
exports.Button = Button$1;
|
|
21184
22008
|
exports.Calendar = Calendar$1;
|
|
@@ -21189,6 +22013,7 @@ exports.Combobox = Combobox;
|
|
|
21189
22013
|
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
|
21190
22014
|
exports.Datepicker = Datepicker;
|
|
21191
22015
|
exports.Dialog = Dialog;
|
|
22016
|
+
exports.DonutChart = DonutChart;
|
|
21192
22017
|
exports.Drawer = Drawer;
|
|
21193
22018
|
exports.Field = Field;
|
|
21194
22019
|
exports.Form = Form;
|
|
@@ -21200,6 +22025,7 @@ exports.Icon = Icon;
|
|
|
21200
22025
|
exports.IconButton = IconButton;
|
|
21201
22026
|
exports.Input = Input;
|
|
21202
22027
|
exports.Layout = Layout$1;
|
|
22028
|
+
exports.LineChart = LineChart;
|
|
21203
22029
|
exports.List = List$1;
|
|
21204
22030
|
exports.Listbox = Listbox;
|
|
21205
22031
|
exports.LocalizationContext = LocalizationContext;
|