@economic/taco 2.45.0-alpha.2 → 2.45.0-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. package/dist/charts/components/Area/AreaChart.d.ts +19 -0
  2. package/dist/charts/components/Bar/BarChart.d.ts +20 -0
  3. package/dist/charts/components/Donut/ActiveShape.d.ts +8 -0
  4. package/dist/charts/components/Donut/CenteredLabel.d.ts +11 -0
  5. package/dist/charts/components/Donut/DonutChart.d.ts +21 -0
  6. package/dist/charts/components/Donut/Legend.d.ts +13 -0
  7. package/dist/charts/components/Donut/util.d.ts +2 -0
  8. package/dist/charts/components/Legend.d.ts +16 -0
  9. package/dist/charts/components/Line/LineChart.d.ts +18 -0
  10. package/dist/charts/components/ResponsiveContainer.d.ts +5 -0
  11. package/dist/charts/components/Tooltip.d.ts +10 -0
  12. package/dist/charts/components/types.d.ts +5 -0
  13. package/dist/charts/utils/color.d.ts +3 -0
  14. package/dist/charts/utils/common.d.ts +37 -0
  15. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
  16. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -2
  17. package/dist/components/Table3/features/useEditingState.d.ts +1 -1
  18. package/dist/components/Table3/features/useTableEditing.d.ts +4 -3
  19. package/dist/esm/index.css +18 -0
  20. package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js +67 -0
  21. package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js.map +1 -0
  22. package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js +120 -0
  23. package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js.map +1 -0
  24. package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js +47 -0
  25. package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js.map +1 -0
  26. package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js +27 -0
  27. package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js.map +1 -0
  28. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js +170 -0
  29. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -0
  30. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +164 -0
  31. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -0
  32. package/dist/esm/packages/taco/src/charts/components/Donut/util.js +5 -0
  33. package/dist/esm/packages/taco/src/charts/components/Donut/util.js.map +1 -0
  34. package/dist/esm/packages/taco/src/charts/components/Legend.js +145 -0
  35. package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -0
  36. package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js +65 -0
  37. package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js.map +1 -0
  38. package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js +10 -0
  39. package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js.map +1 -0
  40. package/dist/esm/packages/taco/src/charts/components/Tooltip.js +44 -0
  41. package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -0
  42. package/dist/esm/packages/taco/src/charts/utils/color.js +24 -0
  43. package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -0
  44. package/dist/esm/packages/taco/src/charts/utils/common.js +34 -0
  45. package/dist/esm/packages/taco/src/charts/utils/common.js.map +1 -0
  46. package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
  47. package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Button/util.js +1 -1
  49. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -4
  52. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
  54. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
  56. package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
  57. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
  58. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
  60. package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -1
  61. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  62. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +2 -2
  64. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -32
  66. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +1 -1
  68. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
  69. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +4 -4
  70. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
  71. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +32 -1
  72. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  73. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +7 -5
  74. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  75. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +16 -4
  76. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  77. package/dist/esm/packages/taco/src/index.js +4 -0
  78. package/dist/esm/packages/taco/src/index.js.map +1 -1
  79. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
  80. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +10 -5
  81. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  82. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +6 -0
  83. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
  84. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +23 -16
  85. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  86. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +4 -3
  87. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  88. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
  89. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
  90. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +7 -0
  91. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
  92. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -1
  93. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
  94. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +4 -1
  95. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  96. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +3 -1
  97. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  98. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
  99. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
  100. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +5 -1
  101. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  102. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  103. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
  104. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
  105. package/dist/esm/packages/taco/tailwind.colors.js +122 -0
  106. package/dist/esm/packages/taco/tailwind.colors.js.map +1 -0
  107. package/dist/index.css +18 -0
  108. package/dist/index.d.ts +5 -0
  109. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
  110. package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
  111. package/dist/primitives/Table/Core/types.d.ts +1 -0
  112. package/dist/taco.cjs.development.js +942 -105
  113. package/dist/taco.cjs.development.js.map +1 -1
  114. package/dist/taco.cjs.production.min.js +1 -1
  115. package/dist/taco.cjs.production.min.js.map +1 -1
  116. package/package.json +18 -16
  117. package/tailwind.colors.js +121 -0
  118. package/tailwind.config.js +3 -2
  119. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
@@ -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 => {
@@ -4038,33 +4039,25 @@ const Accordion = props => {
4038
4039
  const context = React__default.useMemo(() => ({
4039
4040
  as
4040
4041
  }), [as]);
4041
- const type = typeof defaultId === 'string' || typeof id === 'string' ? 'single' : 'multiple';
4042
4042
  let valueProps;
4043
4043
  if (defaultId) {
4044
- valueProps = type === 'single' ? {
4045
- type: 'single',
4046
- defaultValue: defaultId
4047
- } : {
4048
- type: 'multiple',
4049
- defaultValue: defaultId
4044
+ valueProps = {
4045
+ defaultValue: defaultId || undefined
4050
4046
  };
4051
4047
  } else {
4052
- valueProps = type === 'single' ? {
4053
- type: 'single',
4054
- onValueChange: onChange,
4055
- value: id || undefined
4056
- } : {
4057
- type: 'multiple',
4048
+ valueProps = {
4058
4049
  onValueChange: onChange,
4059
4050
  value: id || undefined
4060
4051
  };
4061
4052
  }
4053
+ const type = typeof valueProps.defaultValue === 'string' || typeof valueProps.value === 'string' ? 'single' : 'multiple';
4062
4054
  const className = cn('divide-y divide-grey-200', props.className);
4063
4055
  return /*#__PURE__*/React__default.createElement(AccordionContext.Provider, {
4064
4056
  value: context
4065
4057
  }, /*#__PURE__*/React__default.createElement(AccordionPrimitive.Root, Object.assign({}, otherProps, valueProps, {
4066
4058
  "data-taco": "accordion",
4067
- className: className
4059
+ className: className,
4060
+ type: type
4068
4061
  })));
4069
4062
  };
4070
4063
  Accordion.Item = Item;
@@ -4385,7 +4378,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
4385
4378
  });
4386
4379
 
4387
4380
  const getButtonClasses = () => {
4388
- return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center focus-visible:yt-focus aria-disabled:cursor-not-allowed';
4381
+ return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center focus-visible:yt-focus data-[state=instant-open]:yt-focus aria-disabled:cursor-not-allowed';
4389
4382
  };
4390
4383
  const getAppearanceClasses = (value, icon = false) => {
4391
4384
  switch (value) {
@@ -5254,7 +5247,7 @@ const getInputClasses = props => {
5254
5247
  const disabled = props.disabled || !!props['aria-disabled'];
5255
5248
  const readOnly = props.readOnly || !!props['aria-readonly'];
5256
5249
  const invalid = props.invalid || !!props['aria-invalid'];
5257
- 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-visible:yt-focus',
5250
+ 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',
5258
5251
  // hide the arrow controls on input[type=number]
5259
5252
  '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none', {
5260
5253
  'bg-white': !props.highlighted && !readOnly,
@@ -5758,13 +5751,7 @@ const searchForString = (child, value, strategy = 'includes') => {
5758
5751
  }
5759
5752
  return searchForString((_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.children, value, strategy);
5760
5753
  } else {
5761
- const childLowerCase = child.toString().toLowerCase();
5762
- const valueLowerCase = String(value).toLowerCase();
5763
- if (strategy === 'startsWith') {
5764
- return childLowerCase.startsWith(valueLowerCase);
5765
- } else {
5766
- return childLowerCase.includes(valueLowerCase);
5767
- }
5754
+ return child.toString().toLowerCase()[strategy](String(value).toLowerCase());
5768
5755
  }
5769
5756
  } catch {
5770
5757
  return false;
@@ -12130,9 +12117,10 @@ const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props,
12130
12117
  });
12131
12118
 
12132
12119
  const RowContext = /*#__PURE__*/React__default.createContext({
12120
+ hideInternalColumns: false,
12121
+ hideRowActions: false,
12133
12122
  isHovered: false,
12134
- rowIndex: -1,
12135
- hideRowActions: false
12123
+ rowIndex: -1
12136
12124
  });
12137
12125
 
12138
12126
  /* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */
@@ -12140,6 +12128,7 @@ function Row(props) {
12140
12128
  const {
12141
12129
  renderer: RowRenderer,
12142
12130
  cellRenderer: CellRenderer,
12131
+ hideInternalColumns = false,
12143
12132
  hideRowActions = false,
12144
12133
  ...displayRowProps
12145
12134
  } = props;
@@ -12149,8 +12138,9 @@ function Row(props) {
12149
12138
  const contextValue = React__default.useMemo(() => ({
12150
12139
  isHovered,
12151
12140
  rowIndex: props.index,
12141
+ hideInternalColumns,
12152
12142
  hideRowActions
12153
- }), [isHovered, props.index, hideRowActions]);
12143
+ }), [isHovered, props.index, hideInternalColumns, hideRowActions]);
12154
12144
  if (props.row.original === undefined) {
12155
12145
  return /*#__PURE__*/React__default.createElement(SkeletonRow, Object.assign({}, props));
12156
12146
  }
@@ -12248,12 +12238,16 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
12248
12238
  // rendered output
12249
12239
  let style = {};
12250
12240
  let content = null;
12251
- if (rows.length) {
12241
+ // bottom rows aren't virtualised (they're sticky) but we need to set the height
12242
+ if (rows.length || table.getBottomRows().length) {
12252
12243
  style = {
12253
12244
  height: totalSize,
12254
12245
  paddingBottom,
12255
12246
  paddingTop
12256
12247
  };
12248
+ }
12249
+ // only render non sticky rows
12250
+ if (rows.length) {
12257
12251
  content = virtualItems.map(virtualRow => {
12258
12252
  // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
12259
12253
  if (!virtualRow) {
@@ -12411,9 +12405,9 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
12411
12405
  table
12412
12406
  } = context;
12413
12407
  const {
12408
+ hideRowActions,
12414
12409
  isHovered,
12415
- rowIndex,
12416
- hideRowActions
12410
+ rowIndex
12417
12411
  } = React__default.useContext(RowContext);
12418
12412
  const tableMeta = table.options.meta;
12419
12413
  const actions = tableMeta.rowActions.rowActions;
@@ -12421,7 +12415,8 @@ const Cell = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
12421
12415
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
12422
12416
  const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;
12423
12417
  const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;
12424
- if (!hideRowActions && actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
12418
+ const isRowGrouped = row.getIsGrouped();
12419
+ if (!hideRowActions && !isRowGrouped && actions !== null && actions !== void 0 && actions.length && (isActiveRow || isHovered && !isHoverStatePaused && !isResizingColumn)) {
12425
12420
  return /*#__PURE__*/React__default.createElement(Actions$1, {
12426
12421
  actions: actions,
12427
12422
  actionsLength: actionsLength,
@@ -12452,6 +12447,12 @@ function Cell$1() {
12452
12447
  const {
12453
12448
  texts
12454
12449
  } = useLocalization();
12450
+ const {
12451
+ hideInternalColumns
12452
+ } = React__default.useContext(RowContext);
12453
+ if (hideInternalColumns) {
12454
+ return null;
12455
+ }
12455
12456
  return /*#__PURE__*/React__default.createElement(Icon, {
12456
12457
  "aria-label": texts.table.columns.drag.tooltip,
12457
12458
  name: "drag",
@@ -12500,7 +12501,13 @@ function Cell$2(context) {
12500
12501
  const {
12501
12502
  texts
12502
12503
  } = useLocalization();
12504
+ const {
12505
+ hideInternalColumns
12506
+ } = React__default.useContext(RowContext);
12503
12507
  const tableMeta = context.table.options.meta;
12508
+ if (hideInternalColumns) {
12509
+ return null;
12510
+ }
12504
12511
  const hasExpandedRow = (_tableMeta$rowExpansi = (_tableMeta$rowExpansi2 = tableMeta.rowExpansion).rowExpansionRenderer) === null || _tableMeta$rowExpansi === void 0 ? void 0 : _tableMeta$rowExpansi.call(_tableMeta$rowExpansi2, context.row.original);
12505
12512
  if (hasExpandedRow) {
12506
12513
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === context.row.index;
@@ -12590,10 +12597,11 @@ function Cell$3(context) {
12590
12597
  table
12591
12598
  } = context;
12592
12599
  const {
12600
+ hideInternalColumns,
12593
12601
  rowIndex
12594
12602
  } = React__default.useContext(RowContext);
12595
12603
  const tableMeta = table.options.meta;
12596
- if (table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
12604
+ if (hideInternalColumns || table.options.enableGrouping && (_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length && !row.getIsGrouped()) {
12597
12605
  return null;
12598
12606
  }
12599
12607
  const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
@@ -12797,7 +12805,9 @@ function GroupedCell(props) {
12797
12805
  } = React__default.useContext(RowContext);
12798
12806
  const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;
12799
12807
  const canShowActions = isActiveRow || isHovered && !tableMeta.rowActive.isHoverStatePaused;
12800
- const colSpan = cell.row.getVisibleCells().filter(c => !isInternalColumn(c.column.id)).length - 1;
12808
+ // Set colSpan based on the count of visible cells, including '__actions' and non-internal columns, so that
12809
+ // rowGroupActions aligns with rowActions.
12810
+ const colSpan = cell.row.getVisibleCells().filter(c => c.column.id === '__actions' || !isInternalColumn(c.column.id)).length - 1;
12801
12811
  const content = (_ref = (_columnMeta$renderer = (_columnMeta$renderer2 = columnMeta.renderer) === null || _columnMeta$renderer2 === void 0 ? void 0 : _columnMeta$renderer2.call(columnMeta, cell.getValue(), cell.row.original)) !== null && _columnMeta$renderer !== void 0 ? _columnMeta$renderer : cell.getValue()) !== null && _ref !== void 0 ? _ref : null;
12802
12812
  const subRows = cell.getContext().row.subRows.map(row => row.original);
12803
12813
  return /*#__PURE__*/React__default.createElement(MemoedGroupedCell, Object.assign({}, attributes, {
@@ -12822,21 +12832,26 @@ const MemoedGroupedCell = /*#__PURE__*/React__default.memo(function MemoedGroupe
12822
12832
  table,
12823
12833
  ...attributes
12824
12834
  } = props;
12825
- return /*#__PURE__*/React__default.createElement("td", Object.assign({}, attributes, {
12826
- ref: cellRef,
12827
- style: {
12828
- gridColumn: `span ${colSpan} / span ${colSpan}`
12829
- }
12830
- }), /*#__PURE__*/React__default.createElement("span", {
12831
- className: "grow"
12832
- }, children), rowActions !== null && rowActions !== void 0 && rowActions.length && canShowActions ? (/*#__PURE__*/React__default.createElement(Actions$1, {
12833
- actions: rowActions,
12834
- actionsLength: 4,
12835
- data: subRows,
12836
- isActiveRow: true,
12837
- rowId: rowId,
12838
- table: table
12839
- })) : null);
12835
+ return (
12836
+ /*#__PURE__*/
12837
+ // pr-1 is needed to align group row actions with row actions in sibling rows, if present
12838
+ React__default.createElement("td", Object.assign({}, attributes, {
12839
+ className: "!pr-1",
12840
+ ref: cellRef,
12841
+ style: {
12842
+ gridColumn: `span ${colSpan} / span ${colSpan}`
12843
+ }
12844
+ }), /*#__PURE__*/React__default.createElement("span", {
12845
+ className: "grow"
12846
+ }, children), rowActions !== null && rowActions !== void 0 && rowActions.length && canShowActions ? (/*#__PURE__*/React__default.createElement(Actions$1, {
12847
+ actions: rowActions,
12848
+ actionsLength: 4,
12849
+ data: subRows,
12850
+ isActiveRow: true,
12851
+ rowId: rowId,
12852
+ table: table
12853
+ })) : null)
12854
+ );
12840
12855
  });
12841
12856
 
12842
12857
  function Cell$4(props) {
@@ -12979,10 +12994,13 @@ const DisplayRow = /*#__PURE__*/React__default.memo(function DisplayRow(props) {
12979
12994
  'hover:cursor-grab': tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== 'function',
12980
12995
  'hover:cursor-pointer': typeof attributes.onClick === 'function'
12981
12996
  });
12997
+ const isGrouped = row.getIsGrouped();
12982
12998
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tr", Object.assign({}, attributes, {
12983
12999
  className: className,
12984
13000
  ref: ref
12985
- }), children, row.getVisibleCells().map((cell, cellIndex) => (/*#__PURE__*/React__default.createElement(Cell$4, {
13001
+ }), children, row.getVisibleCells()
13002
+ // Filter out the row actions cell from rendering in Grouped Row
13003
+ .filter(cell => !(isGrouped && cell.column.id === '__actions')).map((cell, cellIndex) => (/*#__PURE__*/React__default.createElement(Cell$4, {
12986
13004
  key: cell.id,
12987
13005
  cell: cell,
12988
13006
  index: cellIndex,
@@ -13819,9 +13837,15 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
13819
13837
  function EmptyStateBody(props) {
13820
13838
  const {
13821
13839
  emptyState: Placeholder,
13840
+ isReady,
13822
13841
  reason,
13823
13842
  ...attributes
13824
13843
  } = props;
13844
+ if (!isReady) {
13845
+ return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
13846
+ className: "!auto-rows-fr"
13847
+ }));
13848
+ }
13825
13849
  return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
13826
13850
  className: "!auto-rows-fr"
13827
13851
  }), /*#__PURE__*/React__default.createElement("tr", {
@@ -16820,7 +16844,7 @@ function Table(props) {
16820
16844
  }
16821
16845
  Table.Toolbar = TableToolbar;
16822
16846
  Table.Grid = TableGrid;
16823
- function getFilterReason(table) {
16847
+ function getEmptyStateReason(table) {
16824
16848
  if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {
16825
16849
  const state = table.instance.getState();
16826
16850
  if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {
@@ -16843,7 +16867,7 @@ function TableGrid(props) {
16843
16867
  const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
16844
16868
  table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
16845
16869
  } : undefined;
16846
- const filterReason = getFilterReason(table);
16870
+ const emptyStateReason = getEmptyStateReason(table);
16847
16871
  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, {
16848
16872
  id: table.id,
16849
16873
  "data-table-font-size": table.meta.fontSize.size,
@@ -16859,14 +16883,19 @@ function TableGrid(props) {
16859
16883
  style: table.style,
16860
16884
  tabIndex: -1
16861
16885
  }), /*#__PURE__*/React__default.createElement("thead", null, table.instance.getHeaderGroups().map(headerGroup => (/*#__PURE__*/React__default.createElement("tr", {
16862
- key: headerGroup.id
16886
+ key: headerGroup.id,
16887
+ onFocus: event => {
16888
+ // prevents rowActive.handleFocus from running when clicking on column-header menus.
16889
+ event.stopPropagation();
16890
+ }
16863
16891
  }, headerGroup.headers.map(props => (/*#__PURE__*/React__default.createElement(Header$5, {
16864
16892
  key: props.id,
16865
16893
  header: props,
16866
16894
  scrollToIndex: table.renderer.scrollToIndex
16867
- }))))))), filterReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
16895
+ }))))))), emptyStateReason ? (/*#__PURE__*/React__default.createElement(EmptyStateBody, {
16868
16896
  emptyState: props.table.props.emptyState,
16869
- reason: filterReason
16897
+ isReady: table.meta.server.isEnabled ? table.meta.server.isReady : true,
16898
+ reason: emptyStateReason
16870
16899
  })) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
16871
16900
  enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
16872
16901
  table: table.instance,
@@ -18479,11 +18508,13 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
18479
18508
  // store the last row active index, otherwise everytime tableMeta.editing.saveChanges changes the hook runs again
18480
18509
  const lastRowActiveIndexRef = React__default.useRef(tableMeta.rowActive.rowActiveIndex);
18481
18510
  useLazyEffect(() => {
18482
- if (tableMeta.editing.isEditing && lastRowActiveIndexRef.current !== undefined && tableMeta.rowActive.rowActiveIndex !== lastRowActiveIndexRef.current) {
18511
+ if (tableMeta.rowActive.rowActiveIndex !== lastRowActiveIndexRef.current) {
18483
18512
  lastRowActiveIndexRef.current = tableMeta.rowActive.rowActiveIndex;
18484
- tableMeta.editing.saveChanges(table);
18513
+ if (tableMeta.editing.isEditing && lastRowActiveIndexRef.current !== undefined) {
18514
+ tableMeta.editing.saveChanges(table);
18515
+ }
18485
18516
  }
18486
- }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.saveChanges]);
18517
+ }, [tableMeta.rowActive.rowActiveIndex]);
18487
18518
  // show a warning if the user navigates away without triggering save, such as using the browser back/forward button
18488
18519
  const hasChanges = tableMeta.editing.hasChanges();
18489
18520
  React__default.useEffect(() => {
@@ -18509,9 +18540,9 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
18509
18540
  const onClickOutside = event => {
18510
18541
  if (tableMeta.editing.isEditing) {
18511
18542
  const element = event.target;
18512
- const insideTable = element.getAttribute('data-taco') === 'backdrop' || element.getAttribute('data-table') === 'editing-toggle' || isElementInsideOrTriggeredFromContainer(element, tableRef.current);
18543
+ 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);
18513
18544
  // users can click the white space below rows which could be inside the table, but a valid scenario to save
18514
- if (!insideTable || element.tagName === 'TABLE' || element.tagName === 'TBODY') {
18545
+ if (!isTableOrIsInsideTable) {
18515
18546
  tableMeta.editing.saveChanges(table);
18516
18547
  }
18517
18548
  }
@@ -18662,7 +18693,7 @@ function reducer$2(state, action) {
18662
18693
  }
18663
18694
  };
18664
18695
  }
18665
- case 'createRow':
18696
+ case 'insertTemporaryRow':
18666
18697
  {
18667
18698
  const {
18668
18699
  value
@@ -18949,14 +18980,14 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
18949
18980
  }
18950
18981
  });
18951
18982
  }
18952
- function createRow(data) {
18983
+ function insertTemporaryRow(data) {
18953
18984
  const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
18954
18985
  const value = {
18955
18986
  ...data,
18956
18987
  [rowIdentityAccessor]: newRowId
18957
18988
  };
18958
18989
  dispatch({
18959
- type: 'createRow',
18990
+ type: 'insertTemporaryRow',
18960
18991
  rowId: newRowId,
18961
18992
  payload: {
18962
18993
  value
@@ -19050,12 +19081,42 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
19050
19081
  discardChanges,
19051
19082
  hasSaved,
19052
19083
  // new rows
19053
- createRow,
19084
+ insertTemporaryRow,
19054
19085
  temporaryRows: state.temporaryRows
19055
19086
  };
19056
19087
  }
19057
19088
 
19058
- function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentityAccessor, validator) {
19089
+ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
19090
+ const createRow = function (table, scrollToIndex, row) {
19091
+ try {
19092
+ if (!handleCreate) {
19093
+ return Promise.resolve();
19094
+ }
19095
+ const tableMeta = table.options.meta;
19096
+ return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
19097
+ if (!saved) {
19098
+ return;
19099
+ }
19100
+ const changeset = row !== null && row !== void 0 ? row : handleCreate();
19101
+ try {
19102
+ if (changeset) {
19103
+ const rowId = pendingChangesFns.insertTemporaryRow(changeset);
19104
+ table.getRow(rowId).pin('bottom');
19105
+ // set the active row to the new row before toggling editing on
19106
+ const temporaryRows = tableMeta.editing.temporaryRows;
19107
+ const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
19108
+ tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
19109
+ toggleEditing(true, table, scrollToIndex);
19110
+ setLastFocusedCellIndex(undefined);
19111
+ }
19112
+ } catch (error) {
19113
+ console.error(error);
19114
+ }
19115
+ });
19116
+ } catch (e) {
19117
+ return Promise.reject(e);
19118
+ }
19119
+ };
19059
19120
  // used to switch the table into editing mode
19060
19121
  const [isEditing, setEditing] = React__default.useState(false);
19061
19122
  // used to switch the editing between "detailed" mode
@@ -19093,6 +19154,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, rowIdentit
19093
19154
  toggleEditing: isEnabled ? toggleEditing : () => undefined,
19094
19155
  lastFocusedCellIndex,
19095
19156
  setLastFocusedCellIndex,
19157
+ createRow,
19096
19158
  createRowButtonRef,
19097
19159
  ...pendingChangesFns
19098
19160
  };
@@ -19617,7 +19679,7 @@ function DiscardChangesConfirmationDialog(props) {
19617
19679
  }, texts.table3.editing.clearChangesConfirmationDialog.confirm))))));
19618
19680
  }
19619
19681
 
19620
- function EditingActionMenu(props) {
19682
+ function EditingActionsMenu(props) {
19621
19683
  const {
19622
19684
  hasChanges,
19623
19685
  hasErrors,
@@ -19769,7 +19831,7 @@ const RENDERERS$1 = {
19769
19831
  cell: Cell$5
19770
19832
  };
19771
19833
  function useTable3(props, ref) {
19772
- const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.rowIdentityAccessor, props.validator);
19834
+ const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.rowIdentityAccessor, props.validator);
19773
19835
  const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
19774
19836
  // this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
19775
19837
  const data = React__default.useMemo(() => {
@@ -19786,10 +19848,19 @@ function useTable3(props, ref) {
19786
19848
  // Display EditingActionMenu instead of row actions while editing
19787
19849
  rowActions: editing.isEditing ? [(_, rowId, table) => {
19788
19850
  const tableMeta = table.options.meta;
19789
- return /*#__PURE__*/React__default.createElement(EditingActionMenu, {
19851
+ return /*#__PURE__*/React__default.createElement(EditingActionsMenu, {
19790
19852
  hasChanges: editing.hasChanges(rowId),
19791
19853
  hasErrors: editing.hasRowErrors(rowId),
19792
- onDiscard: () => editing.discardChanges(rowId, table),
19854
+ onDiscard: () => {
19855
+ if (editing.temporaryRows.length) {
19856
+ tableMeta.rowActive.setRowActiveIndex(undefined);
19857
+ setTimeout(() => {
19858
+ var _editing$createRowBut;
19859
+ return (_editing$createRowBut = editing.createRowButtonRef.current) === null || _editing$createRowBut === void 0 ? void 0 : _editing$createRowBut.focus();
19860
+ }, 50);
19861
+ }
19862
+ editing.discardChanges(rowId, table);
19863
+ },
19793
19864
  onEditingSave: function () {
19794
19865
  try {
19795
19866
  return Promise.resolve(editing.saveChanges(table, rowId)).then(function () {});
@@ -19813,6 +19884,9 @@ function useTable3(props, ref) {
19813
19884
  React__default.useEffect(() => {
19814
19885
  if (table.ref.current) {
19815
19886
  table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
19887
+ if (props.onEditingCreate) {
19888
+ table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance, table.renderer.scrollToIndex, row);
19889
+ }
19816
19890
  }
19817
19891
  }, [table.ref.current]);
19818
19892
  return table;
@@ -19973,7 +20047,6 @@ function CreateNewRow(props) {
19973
20047
  var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum;
19974
20048
  const {
19975
20049
  buttonRef,
19976
- onEditingCreate: handleEditingCreate,
19977
20050
  scrollToIndex,
19978
20051
  table,
19979
20052
  tableMeta,
@@ -19986,46 +20059,19 @@ function CreateNewRow(props) {
19986
20059
  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 : '';
19987
20060
  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);
19988
20061
  const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
19989
- const createRow = function (row) {
20062
+ const handleCreate = function () {
19990
20063
  try {
19991
- if (!handleEditingCreate || isDisabled) {
20064
+ if (isDisabled) {
19992
20065
  return Promise.resolve();
19993
20066
  }
19994
- return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
19995
- if (!saved) {
19996
- return;
19997
- }
19998
- const changeset = row !== null && row !== void 0 ? row : handleEditingCreate();
19999
- try {
20000
- if (changeset) {
20001
- const rowId = tableMeta.editing.createRow(changeset);
20002
- table.getRow(rowId).pin('bottom');
20003
- // set the active row to the new row before toggling editing on
20004
- const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
20005
- tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
20006
- tableMeta.editing.toggleEditing(true, table, scrollToIndex);
20007
- tableMeta.editing.setLastFocusedCellIndex(0);
20008
- }
20009
- } catch (error) {
20010
- console.error(error);
20011
- }
20012
- });
20067
+ return Promise.resolve(tableMeta.editing.createRow(table, scrollToIndex)).then(function () {});
20013
20068
  } catch (e) {
20014
20069
  return Promise.reject(e);
20015
20070
  }
20016
20071
  };
20017
- // allow programmatic access to creating rows from outside the table
20018
- React__default.useEffect(() => {
20019
- if (tableRef.current) {
20020
- tableRef.current.instance.createRow = createRow;
20021
- }
20022
- }, [tableRef.current, createRow]);
20023
- const handleCreate = function () {
20024
- return createRow();
20025
- };
20026
20072
  const shortcut = {
20027
20073
  key: 'Enter',
20028
- shift: true
20074
+ meta: true
20029
20075
  };
20030
20076
  let tooltip;
20031
20077
  if (isSaving) {
@@ -20145,7 +20191,7 @@ function TemporaryRow(props) {
20145
20191
  className: className,
20146
20192
  onKeyDown: handleKeyDown,
20147
20193
  onKeyDownCapture: handleKeyDownCapture,
20148
- // Row actions should only be hidden on temporary rows when editing is turned off
20194
+ hideInternalColumns: true,
20149
20195
  hideRowActions: !tableMeta.editing.isEditing
20150
20196
  }))));
20151
20197
  }
@@ -20187,7 +20233,6 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
20187
20233
  tableRef: table3.ref
20188
20234
  }), /*#__PURE__*/React__default.createElement(CreateNewRow, {
20189
20235
  buttonRef: table3.meta.editing.createRowButtonRef,
20190
- onEditingCreate: props.onEditingCreate,
20191
20236
  scrollToIndex: table3.renderer.scrollToIndex,
20192
20237
  table: table3.instance,
20193
20238
  tableMeta: table3.meta,
@@ -20428,6 +20473,796 @@ const Tour = props => {
20428
20473
  };
20429
20474
  Tour.Step = TourStep;
20430
20475
 
20476
+ // NOTE: this file is intentianally a js file so that it can be consumed by tailwind.config.js
20477
+
20478
+ const THEME_COLORS = {
20479
+ transparent: 'transparent',
20480
+ current: 'currentColor',
20481
+ white: '#fff',
20482
+ black: '#1c1c1c',
20483
+ brand: {
20484
+ vismaRed: '#E70641',
20485
+ paleOrange: '#FFF5E5',
20486
+ sunsetOrange: '#E89C2E',
20487
+ midnightBlue: '#29283E',
20488
+ coolBlue: '#F5F7F9'
20489
+ },
20490
+ grey: {
20491
+ lightest: '#fafafa',
20492
+ light: '#F6F6F6',
20493
+ DEFAULT: '#EBEBEB',
20494
+ dark: '#DDDDDD',
20495
+ darker: '#ACACAC',
20496
+ darkest: '#595959',
20497
+ darkNew: '#a5a6a9',
20498
+ 50: '#fafafa',
20499
+ 100: '#F6F6F6',
20500
+ 200: '#EBEBEB',
20501
+ 300: '#DDDDDD',
20502
+ 500: '#ACACAC',
20503
+ 700: '#595959',
20504
+ 900: '#303030'
20505
+ },
20506
+ purple: {
20507
+ lightest: '#585c74',
20508
+ light: '#4b4f64',
20509
+ DEFAULT: '#3d4153',
20510
+ dark: '#353a48',
20511
+ darker: '#29283e',
20512
+ darkest: '#212032',
20513
+ darkNew_1: '#373647',
20514
+ darkNew_2: '#414050',
20515
+ 100: '#EEE5FF',
20516
+ 200: '#ddd1ff',
20517
+ 300: '#CBBCFE',
20518
+ 500: '#9270FA',
20519
+ 700: '#6542D1',
20520
+ 900: '#412970'
20521
+ },
20522
+ blue: {
20523
+ lightest: '#DEEBFF',
20524
+ light: '#75A0F5',
20525
+ DEFAULT: '#4573D2',
20526
+ dark: '#2B57B4',
20527
+ 100: '#DEEBFF',
20528
+ 200: '#AACCFF',
20529
+ 300: '#75A0F5',
20530
+ 500: '#4573D2',
20531
+ 700: '#2B57B4',
20532
+ 900: '#29283E'
20533
+ },
20534
+ red: {
20535
+ lightest: '#FFDAD2',
20536
+ light: '#E66568',
20537
+ DEFAULT: '#CE3F42',
20538
+ dark: '#950027',
20539
+ 100: '#FFDAD2',
20540
+ 200: '#f3a09d',
20541
+ 300: '#E66568',
20542
+ 500: '#CE3F42',
20543
+ 700: '#950027',
20544
+ 900: '#64001B'
20545
+ },
20546
+ green: {
20547
+ lightest: '#cdf0e7',
20548
+ light: '#52C7AB',
20549
+ DEFAULT: '#08AE87',
20550
+ dark: '#028465',
20551
+ 100: '#cdf0e7',
20552
+ 200: '#9be1ce',
20553
+ 300: '#52C7AB',
20554
+ 500: '#08AE87',
20555
+ 700: '#028465',
20556
+ 900: '#14493A'
20557
+ },
20558
+ yellow: {
20559
+ lightest: '#FFF1C3',
20560
+ light: '#FFD665',
20561
+ DEFAULT: '#FFBD3B',
20562
+ dark: '#e89c2e',
20563
+ 100: '#FFF1C3',
20564
+ 200: '#ffe494',
20565
+ 300: '#FFD665',
20566
+ 500: '#FFBD3B',
20567
+ 700: '#e89c2e',
20568
+ 900: '#733700'
20569
+ },
20570
+ pink: {
20571
+ 100: '#FFE3F7',
20572
+ 200: '#fcb9e9',
20573
+ 300: '#F98EDB',
20574
+ 500: '#E165BF',
20575
+ 700: '#CF49AA',
20576
+ 900: '#870062'
20577
+ },
20578
+ brown: {
20579
+ 100: '#EEE0DA',
20580
+ 200: '#DFCCC2',
20581
+ 300: '#C4AB9E',
20582
+ 500: '#93715D',
20583
+ 700: '#73503B',
20584
+ 900: '#45291F'
20585
+ },
20586
+ orange: {
20587
+ 100: '#FFE3BB',
20588
+ 200: '#FCCB80',
20589
+ 300: '#FAB64D',
20590
+ 500: '#F99702',
20591
+ 700: '#EF7D00',
20592
+ 900: '#4A2811'
20593
+ }
20594
+ };
20595
+
20596
+ const mapColor = (palette, prefix = '') => {
20597
+ return Object.keys(palette).reduce((accum, color) => {
20598
+ if (color === 'current') {
20599
+ return accum;
20600
+ } else if (typeof palette[color] === 'string') {
20601
+ return {
20602
+ ...accum,
20603
+ [prefix ? color === 'DEFAULT' ? prefix : `${prefix}-${color}` : color]: palette[color]
20604
+ };
20605
+ } else {
20606
+ return {
20607
+ ...accum,
20608
+ ...mapColor(palette[color], color)
20609
+ };
20610
+ }
20611
+ }, {});
20612
+ };
20613
+ const colors = /*#__PURE__*/mapColor(THEME_COLORS);
20614
+ const getThemeColor = color => colors[color];
20615
+
20616
+ function Legend(props) {
20617
+ const {
20618
+ activeIndex,
20619
+ onMouseEnter,
20620
+ onMouseLeave,
20621
+ onClick,
20622
+ payload,
20623
+ layout,
20624
+ activeItems
20625
+ } = props;
20626
+ const [hoverIndex, setHoverIndex] = React.useState(null);
20627
+ const handleMouseEnter = (entry, index) => {
20628
+ setHoverIndex(index);
20629
+ if (activeItems[entry.dataKey]) onMouseEnter(entry, index);
20630
+ };
20631
+ const handleMouseLeave = () => {
20632
+ onMouseLeave();
20633
+ setHoverIndex(null);
20634
+ };
20635
+ const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
20636
+ appearance: "transparent",
20637
+ className: "text-grey-700"
20638
+ }, moreButtonText));
20639
+ return /*#__PURE__*/React__default.createElement("div", {
20640
+ className: "mx-auto w-auto max-w-full overflow-hidden"
20641
+ }, /*#__PURE__*/React__default.createElement("div", {
20642
+ className: cn('mb-0 ml-0 flex justify-center', {
20643
+ 'flex-col': layout === 'vertical'
20644
+ })
20645
+ }, /*#__PURE__*/React__default.createElement(OverflowGroup, {
20646
+ className: "w-full items-center py-1",
20647
+ moreButton: moreButton
20648
+ }, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement("span", {
20649
+ key: `${entry.dataKey}-${index}`,
20650
+ className: cn(' hover:bg-grey-100 cursor-pointer px-[8px] py-[2px] hover:rounded-[4px]', {
20651
+ 'bg-grey-100 rounded': activeIndex === index
20652
+ }),
20653
+ onMouseEnter: () => handleMouseEnter(entry, index),
20654
+ onMouseLeave: handleMouseLeave,
20655
+ onClick: onClick ? () => onClick(entry) : undefined
20656
+ }, /*#__PURE__*/React__default.createElement("span", {
20657
+ className: "text-grey-700 flex items-center gap-[4px]"
20658
+ }, /*#__PURE__*/React__default.createElement("span", {
20659
+ className: cn('-mt-px ml-1 flex h-3 w-3 rounded-sm', {
20660
+ 'border-grey-300 border !bg-white': !activeItems[entry.dataKey]
20661
+ }),
20662
+ style: {
20663
+ backgroundColor: entry.color
20664
+ }
20665
+ }, hoverIndex === index && activeItems[entry.dataKey] && (/*#__PURE__*/React__default.createElement(Icon, {
20666
+ name: "tick-bold",
20667
+ className: "!h-full !w-full text-white"
20668
+ }))), entry.value)))))));
20669
+ }
20670
+
20671
+ const Tooltip$2 = ({
20672
+ active,
20673
+ formatter,
20674
+ payload,
20675
+ style,
20676
+ singlePieDonutChart
20677
+ }) => {
20678
+ const getColor = entry => {
20679
+ var _ref, _entry$color;
20680
+ if (singlePieDonutChart) {
20681
+ // We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
20682
+ // and one with multiple pies.
20683
+ return getThemeColor(entry.payload.color);
20684
+ }
20685
+ return (_ref = (_entry$color = entry.color) !== null && _entry$color !== void 0 ? _entry$color : entry.payload.fill) !== null && _ref !== void 0 ? _ref : 'blue-500';
20686
+ };
20687
+ if (active && payload && payload.length) {
20688
+ return /*#__PURE__*/React__default.createElement("dl", {
20689
+ 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)]",
20690
+ style: style
20691
+ }, payload.map((entry, index) => (/*#__PURE__*/React__default.createElement(React__default.Fragment, {
20692
+ key: `${entry.name}-${index}`
20693
+ }, /*#__PURE__*/React__default.createElement("dt", {
20694
+ className: "text-grey-700 mb-0 flex items-center gap-1 font-normal"
20695
+ }, /*#__PURE__*/React__default.createElement("span", {
20696
+ className: "-mt-px h-2.5 w-2.5 rounded-sm",
20697
+ style: {
20698
+ background: getColor(entry)
20699
+ }
20700
+ }),
20701
+ // We use entry.payload.label because the payload structure differs between a Donut chart with a single pie
20702
+ // and one with multiple pies.
20703
+ singlePieDonutChart ? entry.payload.label : entry.name), /*#__PURE__*/React__default.createElement("dd", {
20704
+ className: "mb-0 text-right font-bold text-black "
20705
+ }, formatter ? formatter(entry.value) : entry.value)))));
20706
+ }
20707
+ return null;
20708
+ };
20709
+
20710
+ const getCartesianGridProps = () => ({
20711
+ vertical: false
20712
+ });
20713
+ const getXAxisProps = props => ({
20714
+ axisLine: false,
20715
+ dataKey: props.accessor,
20716
+ fontSize: 12,
20717
+ scale: props.xAxisScale,
20718
+ tickLine: false,
20719
+ tickFormatter: props.xAxisTickFormat
20720
+ });
20721
+ const getYAxisProps = props => ({
20722
+ axisLine: false,
20723
+ fontSize: 12,
20724
+ scale: props.yAxisScale,
20725
+ tickLine: false,
20726
+ tickFormatter: props.yAxisTickFormat
20727
+ });
20728
+ const getLegendProps = props => ({
20729
+ content: /*#__PURE__*/React__default.createElement(Legend, Object.assign({}, props))
20730
+ });
20731
+ const getTooltipProps = (props = undefined) => ({
20732
+ content: /*#__PURE__*/React__default.createElement(Tooltip$2, Object.assign({}, props)),
20733
+ wrapperStyle: {
20734
+ outline: 'none'
20735
+ }
20736
+ });
20737
+
20738
+ // A hacky fix for EC-50037 to make sure that Chart doesn't resize when it is inside a Card.
20739
+ const ResponsiveContainer = props => (/*#__PURE__*/React__default.createElement(Recharts.ResponsiveContainer, Object.assign({
20740
+ className: "!h-[calc(100%-1px)] !w-[calc(100%-1px)]"
20741
+ }, props)));
20742
+
20743
+ const Area = _ => null;
20744
+ const AreaChart = function AreaChart(externalProps) {
20745
+ const {
20746
+ children,
20747
+ data,
20748
+ formatter,
20749
+ ...props
20750
+ } = externalProps;
20751
+ const [hoveredArea, setHoveredArea] = React.useState(null);
20752
+ const [activeAreas, setActiveAreas] = React.useState(() => {
20753
+ const areas = {};
20754
+ React__default.Children.forEach(children, child => {
20755
+ areas[child.props.accessor] = true;
20756
+ });
20757
+ return areas;
20758
+ });
20759
+ const handleLegendClick = entry => {
20760
+ setHoveredArea(null);
20761
+ setActiveAreas({
20762
+ ...activeAreas,
20763
+ [entry.dataKey]: !activeAreas[entry.dataKey]
20764
+ });
20765
+ };
20766
+ return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.AreaChart, {
20767
+ data: data,
20768
+ margin: {
20769
+ top: 10,
20770
+ right: 0,
20771
+ left: -25,
20772
+ bottom: 0
20773
+ }
20774
+ }, /*#__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({
20775
+ onClick: handleLegendClick,
20776
+ onMouseEnter: entry => setHoveredArea(entry.dataKey),
20777
+ onMouseLeave: () => setHoveredArea(null),
20778
+ activeItems: activeAreas
20779
+ }))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
20780
+ formatter: formatter
20781
+ })), React__default.Children.map(children, child => {
20782
+ var _child$props$color, _child$props$color2, _child$props$color3;
20783
+ return /*#__PURE__*/React__default.createElement(Recharts.Area, {
20784
+ activeDot: {
20785
+ fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
20786
+ },
20787
+ isAnimationActive: false,
20788
+ dataKey: child.props.accessor,
20789
+ dot: false,
20790
+ fill: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'grey-100'),
20791
+ name: child.props.label,
20792
+ strokeWidth: 2,
20793
+ stroke: getThemeColor((_child$props$color3 = child.props.color) !== null && _child$props$color3 !== void 0 ? _child$props$color3 : 'grey-300'),
20794
+ stackId: child.props.stackId,
20795
+ hide: !activeAreas[child.props.accessor],
20796
+ opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
20797
+ });
20798
+ })));
20799
+ };
20800
+ AreaChart.Area = Area;
20801
+
20802
+ const Bar$1 = _ => null;
20803
+ const getXAxisVerticalProps = props => ({
20804
+ ...getXAxisProps(props),
20805
+ ...{
20806
+ type: 'number',
20807
+ dataKey: undefined
20808
+ }
20809
+ });
20810
+ const getYAxisVerticalProps = props => ({
20811
+ ...getYAxisProps(props),
20812
+ ...{
20813
+ dataKey: props.accessor,
20814
+ type: 'category'
20815
+ }
20816
+ });
20817
+ const BarChart = function BarChart(externalProps) {
20818
+ const {
20819
+ children,
20820
+ data,
20821
+ formatter,
20822
+ layout = 'horizontal',
20823
+ ...props
20824
+ } = externalProps;
20825
+ const [activeIndex, setActiveIndex] = React__default.useState(undefined);
20826
+ const [hoveredBar, setHoveredBar] = React__default.useState(null);
20827
+ const [activeBars, setActiveBars] = React__default.useState(() => {
20828
+ const keys = {};
20829
+ React__default.Children.forEach(children, child => {
20830
+ keys[child.props.accessor] = true;
20831
+ });
20832
+ return keys;
20833
+ });
20834
+ // Recharts doesn't provide a way for us to know if a stacked bar is at the top or the bottom,
20835
+ // so we can't set proper radiuses without some "magic"
20836
+ const stacks = {};
20837
+ React__default.Children.forEach(children, child => {
20838
+ if (child.props.stackId) {
20839
+ if (!stacks[child.props.stackId]) {
20840
+ stacks[child.props.stackId] = [child.props.accessor];
20841
+ } else {
20842
+ stacks[child.props.stackId].push(child.props.accessor);
20843
+ }
20844
+ }
20845
+ });
20846
+ const handleLegendClick = entry => {
20847
+ setHoveredBar(null);
20848
+ setActiveBars({
20849
+ ...activeBars,
20850
+ [entry.dataKey]: !activeBars[entry.dataKey]
20851
+ });
20852
+ };
20853
+ const handleLegendHover = (entry, index) => {
20854
+ setHoveredBar(entry.dataKey);
20855
+ setActiveIndex(index);
20856
+ };
20857
+ return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.BarChart, {
20858
+ layout: layout,
20859
+ data: data,
20860
+ margin: {
20861
+ top: 10,
20862
+ right: 0,
20863
+ left: layout === 'vertical' ? 0 : -25,
20864
+ bottom: 0
20865
+ },
20866
+ onMouseMove: chartState => setActiveIndex(chartState.activeTooltipIndex),
20867
+ onMouseLeave: () => setActiveIndex(undefined)
20868
+ }, /*#__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({
20869
+ onClick: handleLegendClick,
20870
+ onMouseEnter: handleLegendHover,
20871
+ onMouseLeave: () => setHoveredBar(null),
20872
+ activeItems: activeBars
20873
+ }))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
20874
+ formatter: formatter
20875
+ })), React__default.Children.map(children, child => (/*#__PURE__*/React__default.createElement(Recharts.Bar, {
20876
+ isAnimationActive: false,
20877
+ barSize: 16,
20878
+ dataKey: child.props.accessor,
20879
+ name: child.props.label,
20880
+ onMouseEnter: (_, index) => setActiveIndex(index),
20881
+ onMouseLeave: () => setActiveIndex(undefined),
20882
+ fill: getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`),
20883
+ radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
20884
+ stackId: child.props.stackId,
20885
+ style: child.props.stackId ? {
20886
+ stroke: '#fff',
20887
+ strokeWidth: '2px'
20888
+ } : undefined,
20889
+ hide: !activeBars[child.props.accessor]
20890
+ }, data.map((_, index) => (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
20891
+ key: `cell-${index}`,
20892
+ opacity: hoveredBar && child.props.accessor !== hoveredBar || activeIndex !== undefined && activeIndex !== index ? 0.3 : 1
20893
+ }))))))));
20894
+ };
20895
+ BarChart.Bar = Bar$1;
20896
+ const getBarRadius = (stacks, accessor, stackId, activeBars) => {
20897
+ if (stackId && Array.isArray(stacks[stackId])) {
20898
+ const length = stacks[stackId].length - 1;
20899
+ const index = stacks[stackId].indexOf(accessor);
20900
+ if (Object.entries(activeBars).filter(item => item[0] !== accessor).every(item => !item[1])) {
20901
+ return [3, 3, 0, 0];
20902
+ }
20903
+ if (activeBars[stacks[stackId][index + 1]] === false) {
20904
+ return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length - 1 ? 0 : 3, index === length - 1 ? 0 : 3];
20905
+ }
20906
+ if (index !== 0 && index !== length) {
20907
+ return 0;
20908
+ }
20909
+ return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length ? 0 : 3, index === length ? 0 : 3];
20910
+ }
20911
+ return 3;
20912
+ };
20913
+
20914
+ const Legend$1 = ({
20915
+ legendPosition,
20916
+ hoveredItem,
20917
+ selectedItem,
20918
+ data,
20919
+ onClick,
20920
+ setHoveredItem,
20921
+ formatter,
20922
+ total,
20923
+ visibleItems,
20924
+ label
20925
+ }) => {
20926
+ const isTotalLegendSelected = selectedItem.length === data.length;
20927
+ const isTotalLegendHovered = hoveredItem.length === data.length;
20928
+ const handleMouseLeave = () => setHoveredItem([]);
20929
+ const renderLegendItem = (entry, index) => {
20930
+ const isTotal = entry === null;
20931
+ // We can't use `isTotal` here because TypeScript is unable to infer the type when `entry` is not null.
20932
+ const itemData = entry === null ? {
20933
+ id: 'total',
20934
+ label,
20935
+ value: total,
20936
+ color: 'grey-300'
20937
+ } : entry;
20938
+ const isSelected = isTotal ? isTotalLegendSelected : selectedItem.includes(itemData.id);
20939
+ const isHovered = isTotal ? isTotalLegendHovered : hoveredItem.includes(itemData.id);
20940
+ return /*#__PURE__*/React__default.createElement("li", {
20941
+ key: isTotal ? 'total' : `${itemData.label}-${index}`,
20942
+ className: cn('mr-2 flex cursor-pointer gap-2 rounded pl-0 pr-1', {
20943
+ 'bg-grey-100': isHovered && (!isTotal || legendPosition === 'right'),
20944
+ 'bg-grey-200': isSelected && (!isTotal || legendPosition === 'right')
20945
+ }),
20946
+ onClick: () => onClick(isTotal ? data : itemData),
20947
+ onMouseEnter: () => setHoveredItem(isTotal ? data.map(item => item.id) : [itemData.id]),
20948
+ onMouseLeave: handleMouseLeave
20949
+ }, legendPosition === 'bottom' ? (/*#__PURE__*/React__default.createElement("div", {
20950
+ className: "flex items-center gap-1"
20951
+ }, /*#__PURE__*/React__default.createElement("span", {
20952
+ className: cn('ml-1 h-3 w-3 rounded-sm', {
20953
+ 'border-grey-300 border !bg-white': !visibleItems[itemData.id]
20954
+ }),
20955
+ style: {
20956
+ backgroundColor: getThemeColor(itemData.color)
20957
+ }
20958
+ }, visibleItems[itemData.id] && isHovered && (/*#__PURE__*/React__default.createElement(Icon, {
20959
+ name: "tick-bold",
20960
+ className: "mb-2.5 !h-full !w-full text-white"
20961
+ }))), /*#__PURE__*/React__default.createElement("div", null, itemData.label))) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
20962
+ className: "ml-1 mt-1 h-9 w-2 rounded-[1px]",
20963
+ style: {
20964
+ backgroundColor: getThemeColor(itemData.color)
20965
+ }
20966
+ }), /*#__PURE__*/React__default.createElement("div", null, itemData.label, /*#__PURE__*/React__default.createElement("span", {
20967
+ className: "-mt-1 flex w-full text-lg font-bold"
20968
+ }, formatter ? formatter(itemData.value) : itemData.value)))));
20969
+ };
20970
+ const moreButton = moreButtonText => (/*#__PURE__*/React__default.createElement(Button$1, {
20971
+ appearance: "transparent",
20972
+ className: "text-grey-700"
20973
+ }, moreButtonText));
20974
+ const className = cn('flex-grow pl-4', {
20975
+ 'w-full': legendPosition === 'bottom'
20976
+ });
20977
+ return /*#__PURE__*/React__default.createElement("div", {
20978
+ className: className
20979
+ }, /*#__PURE__*/React__default.createElement("ul", {
20980
+ className: cn('mb-0 ml-0 mt-4 flex justify-center space-y-1', legendPosition === 'right' ? 'flex-col gap-1' : 'flex-row')
20981
+ }, legendPosition === 'right' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderLegendItem(null), data.map(renderLegendItem))) : (/*#__PURE__*/React__default.createElement(OverflowGroup, {
20982
+ className: "w-full items-center py-1",
20983
+ moreButton: moreButton
20984
+ }, data.map(renderLegendItem)))));
20985
+ };
20986
+
20987
+ const DONUT_WIDTH = 16;
20988
+ const HOVER_DONUT_WIDTH = 10;
20989
+
20990
+ const CenteredLabel = ({
20991
+ radius,
20992
+ legendPosition,
20993
+ label,
20994
+ total,
20995
+ formatter,
20996
+ showLegend
20997
+ }) => {
20998
+ const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
20999
+ const diameter = radius * 2;
21000
+ return /*#__PURE__*/React__default.createElement("div", {
21001
+ className: "absolute mt-1 flex h-12 flex-col text-center",
21002
+ style: {
21003
+ top: `calc(${radius}px - (3rem / 2))`,
21004
+ left: legendPosition === 'right' ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,
21005
+ width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`
21006
+ }
21007
+ }, /*#__PURE__*/React__default.createElement("span", {
21008
+ className: "w-full truncate text-lg font-bold"
21009
+ }, formatter ? formatter(total) : total), label);
21010
+ };
21011
+
21012
+ const ActiveShape = props => {
21013
+ var _getThemeColor;
21014
+ const {
21015
+ cx,
21016
+ cy,
21017
+ id,
21018
+ innerRadius,
21019
+ onClick,
21020
+ outerRadius = 0,
21021
+ pieColors,
21022
+ startAngle,
21023
+ endAngle,
21024
+ fill
21025
+ } = props;
21026
+ return /*#__PURE__*/React__default.createElement("g", {
21027
+ onClick: () => onClick(id),
21028
+ className: cn({
21029
+ 'cursor-pointer': !!onClick
21030
+ })
21031
+ }, /*#__PURE__*/React__default.createElement(Recharts.Sector, {
21032
+ cx: cx,
21033
+ cy: cy,
21034
+ innerRadius: innerRadius,
21035
+ outerRadius: outerRadius,
21036
+ startAngle: startAngle,
21037
+ endAngle: endAngle,
21038
+ fill: fill
21039
+ }), /*#__PURE__*/React__default.createElement(Recharts.Sector, {
21040
+ cx: cx,
21041
+ cy: cy,
21042
+ startAngle: startAngle,
21043
+ endAngle: endAngle,
21044
+ innerRadius: outerRadius + 2,
21045
+ outerRadius: outerRadius + HOVER_DONUT_WIDTH,
21046
+ fill: id !== undefined ? (_getThemeColor = getThemeColor(pieColors[id])) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-500') : getThemeColor('blue-500'),
21047
+ opacity: 0.3
21048
+ }));
21049
+ };
21050
+
21051
+ const Segment = _ => null;
21052
+ const DonutChart = function DonutChart({
21053
+ children,
21054
+ formatter,
21055
+ onClick,
21056
+ showLegend = false,
21057
+ legendPosition = 'bottom',
21058
+ label
21059
+ }) {
21060
+ const ref = React__default.useRef(null);
21061
+ const [radius, setRadius] = React__default.useState(0);
21062
+ const [hoveredItem, setHoveredItem] = React__default.useState([]);
21063
+ // used for right legends
21064
+ const [selectedItem, setSelectedItem] = React__default.useState([]);
21065
+ // used for bottom legends
21066
+ const [visibleItems, setVisibleItems] = React__default.useState(() => {
21067
+ const keys = {};
21068
+ React__default.Children.forEach(children, child => {
21069
+ keys[child.props.id] = true;
21070
+ });
21071
+ return keys;
21072
+ });
21073
+ React__default.useEffect(() => {
21074
+ if (ref.current) {
21075
+ var _ref$current$parentEl;
21076
+ const rect = (_ref$current$parentEl = ref.current.parentElement) === null || _ref$current$parentEl === void 0 ? void 0 : _ref$current$parentEl.getBoundingClientRect();
21077
+ if (rect) {
21078
+ const width = showLegend ? rect.width / 2 : rect.width;
21079
+ const max = rect.height < width ? rect.height : width;
21080
+ setRadius(max / 2);
21081
+ }
21082
+ }
21083
+ }, [showLegend]);
21084
+ 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
21085
+ const data = React__default.Children.map(children, child => ({
21086
+ id: child.props.id,
21087
+ color: child.props.color,
21088
+ label: child.props.label,
21089
+ value: child.props.value
21090
+ }));
21091
+ const displayedData = data.filter(child => visibleItems[child.id]);
21092
+ const total = displayedData.reduce((accum, entry) => accum + entry.value, 0);
21093
+ const showTooltip = (!showLegend || legendPosition === 'bottom') && displayedData.length > 0;
21094
+ const handleLegendClick = entry => {
21095
+ if (legendPosition === 'bottom' && !Array.isArray(entry)) {
21096
+ setVisibleItems({
21097
+ ...visibleItems,
21098
+ [entry.id]: !visibleItems[entry.id]
21099
+ });
21100
+ } else {
21101
+ const nextSelectedItem = Array.isArray(entry) ? entry.map(entryItem => entryItem.id) : [entry.id];
21102
+ // Using slice to avoid mutation of the react state 'selectedItem'
21103
+ const isCurrentSegmentActive = selectedItem.slice().sort().join(',') === nextSelectedItem.sort().join(',');
21104
+ if (onClick && !isCurrentSegmentActive) {
21105
+ onClick(entry);
21106
+ }
21107
+ setSelectedItem(isCurrentSegmentActive ? [] : nextSelectedItem);
21108
+ }
21109
+ };
21110
+ const handlePieClick = React__default.useCallback(pieId => {
21111
+ if (onClick && pieId !== undefined) {
21112
+ const pieProps = displayedData.find(item => item.id === pieId);
21113
+ onClick(pieProps);
21114
+ }
21115
+ }, [onClick, displayedData]);
21116
+ const singlePieDonutChart = displayedData.length === 1;
21117
+ const activeShapeColor = React__default.useMemo(() => {
21118
+ const getSegmentColor = item => item.reduce((colors, itemId) => {
21119
+ const visibleHoveredItem = displayedData.find(dataItem => dataItem.id === itemId);
21120
+ if (visibleHoveredItem) {
21121
+ colors[visibleHoveredItem.id] = visibleHoveredItem.color;
21122
+ }
21123
+ return colors;
21124
+ }, {});
21125
+ const hoveredSegmentColor = getSegmentColor(hoveredItem);
21126
+ const selectedSegmentColor = getSegmentColor(selectedItem);
21127
+ return legendPosition === 'bottom' || hoveredItem.length !== 0 ? hoveredSegmentColor : selectedSegmentColor;
21128
+ }, [hoveredItem, selectedItem, legendPosition]);
21129
+ if (ref.current && !radius) {
21130
+ return null;
21131
+ }
21132
+ const getActiveIndex = () => {
21133
+ if (hoveredItem.length > 0) {
21134
+ return hoveredItem.map(itemId => displayedData.findIndex(element => element.id === itemId));
21135
+ }
21136
+ return selectedItem.map(selectedItemId => displayedData.findIndex(element => element.id === selectedItemId));
21137
+ };
21138
+ const content = () => {
21139
+ const elements = React__default.Children.toArray(children).filter(child => /*#__PURE__*/React__default.isValidElement(child) && visibleItems[child.props.id]);
21140
+ return elements.length > 0 ? elements.map((child, index) => {
21141
+ var _getThemeColor;
21142
+ return /*#__PURE__*/React__default.createElement(Recharts.Cell, {
21143
+ key: `cell-${index}`,
21144
+ name: child.props.label,
21145
+ fill: (_getThemeColor = getThemeColor(child.props.color)) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-300')
21146
+ });
21147
+ }) : (/*#__PURE__*/React__default.createElement(Recharts.Cell, {
21148
+ key: "empty-chart",
21149
+ name: '',
21150
+ fill: getThemeColor('grey-200')
21151
+ }));
21152
+ };
21153
+ return /*#__PURE__*/React__default.createElement("div", {
21154
+ className: cn('relative h-full w-full', {
21155
+ [`flex `]: showLegend,
21156
+ 'flex-col items-center': legendPosition === 'bottom'
21157
+ }),
21158
+ ref: ref
21159
+ }, /*#__PURE__*/React__default.createElement(CenteredLabel, {
21160
+ radius: radius,
21161
+ legendPosition: legendPosition,
21162
+ label: label,
21163
+ total: total,
21164
+ formatter: formatter,
21165
+ showLegend: showLegend
21166
+ }), /*#__PURE__*/React__default.createElement(Recharts.PieChart, {
21167
+ data: data,
21168
+ height: diameter,
21169
+ width: diameter,
21170
+ style: {
21171
+ transform: 'rotate(90deg) scale(-1,1)'
21172
+ }
21173
+ }, showTooltip ? (/*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps({
21174
+ style: {
21175
+ transform: 'rotate(90deg) scale(-1,1)'
21176
+ },
21177
+ singlePieDonutChart
21178
+ })))) : null, /*#__PURE__*/React__default.createElement(Recharts.Pie, {
21179
+ isAnimationActive: false,
21180
+ activeIndex: getActiveIndex(),
21181
+ activeShape: /*#__PURE__*/React__default.createElement(ActiveShape, {
21182
+ pieColors: activeShapeColor,
21183
+ onClick: handlePieClick
21184
+ }),
21185
+ data: displayedData.length > 0 ? displayedData : [],
21186
+ dataKey: "value",
21187
+ innerRadius: radius - HOVER_DONUT_WIDTH - DONUT_WIDTH,
21188
+ onMouseEnter: segment => displayedData.length > 0 && setHoveredItem([segment.id]),
21189
+ onMouseLeave: () => setHoveredItem([]),
21190
+ outerRadius: radius - HOVER_DONUT_WIDTH,
21191
+ paddingAngle: 2,
21192
+ // Prevents the pie group element from being focusable
21193
+ rootTabIndex: -1
21194
+ }, content())), showLegend && (/*#__PURE__*/React__default.createElement(Legend$1, {
21195
+ data: data,
21196
+ visibleItems: visibleItems,
21197
+ onClick: handleLegendClick,
21198
+ total: total,
21199
+ setHoveredItem: setHoveredItem,
21200
+ label: label,
21201
+ legendPosition: legendPosition,
21202
+ hoveredItem: hoveredItem,
21203
+ selectedItem: selectedItem,
21204
+ formatter: formatter
21205
+ })));
21206
+ };
21207
+ DonutChart.Segment = Segment;
21208
+
21209
+ const Line$1 = _ => null;
21210
+ const LineChart = function LineChart(externalProps) {
21211
+ const {
21212
+ children,
21213
+ data,
21214
+ formatter,
21215
+ ...props
21216
+ } = externalProps;
21217
+ const [hoveredLine, setHoveredLine] = React.useState(null);
21218
+ const [activeLines, setActiveLines] = React.useState(() => {
21219
+ const keys = {};
21220
+ React__default.Children.forEach(children, child => {
21221
+ keys[child.props.accessor] = true;
21222
+ });
21223
+ return keys;
21224
+ });
21225
+ const handleLegendClick = entry => {
21226
+ setHoveredLine(null);
21227
+ setActiveLines({
21228
+ ...activeLines,
21229
+ [entry.dataKey]: !activeLines[entry.dataKey]
21230
+ });
21231
+ };
21232
+ return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(Recharts.LineChart, {
21233
+ data: data,
21234
+ margin: {
21235
+ top: 10,
21236
+ right: 0,
21237
+ left: -25,
21238
+ bottom: 0
21239
+ }
21240
+ }, /*#__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({
21241
+ onClick: handleLegendClick,
21242
+ onMouseEnter: entry => setHoveredLine(entry.dataKey),
21243
+ onMouseLeave: () => setHoveredLine(null),
21244
+ activeItems: activeLines
21245
+ }))), /*#__PURE__*/React__default.createElement(Recharts.Tooltip, Object.assign({}, getTooltipProps(), {
21246
+ formatter: formatter
21247
+ })), React__default.Children.map(children, child => {
21248
+ var _child$props$color, _child$props$color2;
21249
+ return /*#__PURE__*/React__default.createElement(Recharts.Line, {
21250
+ activeDot: {
21251
+ fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
21252
+ },
21253
+ dataKey: child.props.accessor,
21254
+ isAnimationActive: false,
21255
+ dot: false,
21256
+ name: child.props.label,
21257
+ stroke: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'blue-300'),
21258
+ strokeWidth: 2,
21259
+ hide: !activeLines[child.props.accessor],
21260
+ opacity: hoveredLine && child.props.accessor !== hoveredLine ? 0.3 : 1
21261
+ });
21262
+ })));
21263
+ };
21264
+ LineChart.Line = Line$1;
21265
+
20431
21266
  const Button$4 = /*#__PURE__*/React__default.forwardRef(function Button(props, ref) {
20432
21267
  const {
20433
21268
  ...attributes
@@ -20700,15 +21535,13 @@ const AgreementDisplay = props => {
20700
21535
  }));
20701
21536
  };
20702
21537
 
20703
- const Container$1 = ({
20704
- children
20705
- }) => {
21538
+ const Container$1 = props => {
20706
21539
  return /*#__PURE__*/React__default.createElement("div", {
20707
21540
  className: "-ml-2 flex flex-shrink-0 flex-grow-0 items-center gap-2 pr-2 xl:ml-auto xl:w-64",
20708
21541
  "data-taco": "header-agreements"
20709
21542
  }, /*#__PURE__*/React__default.createElement("span", {
20710
21543
  className: "hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex"
20711
- }), children);
21544
+ }), props.children);
20712
21545
  };
20713
21546
  function AgreementSelector(props) {
20714
21547
  const {
@@ -21174,10 +22007,12 @@ const useOnClickOutside = (ref, callback) => {
21174
22007
  exports.Accordion = Accordion;
21175
22008
  exports.Alert = Alert;
21176
22009
  exports.AlertDialog = AlertDialog;
22010
+ exports.AreaChart = AreaChart;
21177
22011
  exports.Backdrop = Backdrop;
21178
22012
  exports.Badge = Badge;
21179
22013
  exports.BadgeIcon = BadgeIcon;
21180
22014
  exports.Banner = Banner;
22015
+ exports.BarChart = BarChart;
21181
22016
  exports.Base = Base;
21182
22017
  exports.Button = Button$1;
21183
22018
  exports.Calendar = Calendar$1;
@@ -21188,6 +22023,7 @@ exports.Combobox = Combobox;
21188
22023
  exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
21189
22024
  exports.Datepicker = Datepicker;
21190
22025
  exports.Dialog = Dialog;
22026
+ exports.DonutChart = DonutChart;
21191
22027
  exports.Drawer = Drawer;
21192
22028
  exports.Field = Field;
21193
22029
  exports.Form = Form;
@@ -21199,6 +22035,7 @@ exports.Icon = Icon;
21199
22035
  exports.IconButton = IconButton;
21200
22036
  exports.Input = Input;
21201
22037
  exports.Layout = Layout$1;
22038
+ exports.LineChart = LineChart;
21202
22039
  exports.List = List$1;
21203
22040
  exports.Listbox = Listbox;
21204
22041
  exports.LocalizationContext = LocalizationContext;