@perses-dev/components 0.55.0 → 0.56.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/AlignSelector/AlignSelector.js +115 -25
  2. package/dist/AlignSelector/AlignSelector.js.map +1 -1
  3. package/dist/CodeEditor/CodeEditor.d.ts +19 -0
  4. package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
  5. package/dist/CodeEditor/CodeEditor.js +122 -0
  6. package/dist/CodeEditor/CodeEditor.js.map +1 -0
  7. package/dist/ColorPicker/ColorPicker.js +153 -61
  8. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  9. package/dist/ColorPicker/OptionsColorPicker.js +147 -52
  10. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  11. package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
  12. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  13. package/dist/DensitySelector/DensitySelector.js +53 -20
  14. package/dist/DensitySelector/DensitySelector.js.map +1 -1
  15. package/dist/Dialog/Dialog.d.ts +3 -2
  16. package/dist/Dialog/Dialog.d.ts.map +1 -1
  17. package/dist/Dialog/Dialog.js +202 -49
  18. package/dist/Dialog/Dialog.js.map +1 -1
  19. package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
  20. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  21. package/dist/DragAndDrop/DragAndDropList.js +184 -113
  22. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  23. package/dist/DragAndDrop/DragButton.js +131 -52
  24. package/dist/DragAndDrop/DragButton.js.map +1 -1
  25. package/dist/DragAndDrop/DropIndicator.js +51 -26
  26. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  27. package/dist/Drawer/Drawer.js +75 -15
  28. package/dist/Drawer/Drawer.js.map +1 -1
  29. package/dist/EChart/EChart.js +179 -90
  30. package/dist/EChart/EChart.js.map +1 -1
  31. package/dist/ErrorAlert.js +14 -4
  32. package/dist/ErrorAlert.js.map +1 -1
  33. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
  34. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
  35. package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
  36. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  37. package/dist/FormEditor/FormActions.js +88 -14
  38. package/dist/FormEditor/FormActions.js.map +1 -1
  39. package/dist/FormatControls/FormatControls.js +246 -99
  40. package/dist/FormatControls/FormatControls.js.map +1 -1
  41. package/dist/FormatControls/UnitSelector.js +90 -25
  42. package/dist/FormatControls/UnitSelector.js.map +1 -1
  43. package/dist/InfoTooltip/InfoTooltip.js +105 -42
  44. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  45. package/dist/JSONEditor.d.ts +2 -6
  46. package/dist/JSONEditor.d.ts.map +1 -1
  47. package/dist/JSONEditor.js +24 -37
  48. package/dist/JSONEditor.js.map +1 -1
  49. package/dist/Legend/CompactLegend.js +77 -27
  50. package/dist/Legend/CompactLegend.js.map +1 -1
  51. package/dist/Legend/Legend.js +184 -82
  52. package/dist/Legend/Legend.js.map +1 -1
  53. package/dist/Legend/LegendColorBadge.js +54 -9
  54. package/dist/Legend/LegendColorBadge.js.map +1 -1
  55. package/dist/Legend/ListLegend.js +46 -16
  56. package/dist/Legend/ListLegend.js.map +1 -1
  57. package/dist/Legend/ListLegendItem.js +184 -48
  58. package/dist/Legend/ListLegendItem.js.map +1 -1
  59. package/dist/Legend/TableLegend.d.ts.map +1 -1
  60. package/dist/Legend/TableLegend.js +90 -48
  61. package/dist/Legend/TableLegend.js.map +1 -1
  62. package/dist/Legend/legend-model.d.ts +2 -2
  63. package/dist/Legend/legend-model.d.ts.map +1 -1
  64. package/dist/Legend/legend-model.js.map +1 -1
  65. package/dist/LinksEditor/LinkEditorForm.js +148 -67
  66. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  67. package/dist/ModeSelector/ModeSelector.js +61 -19
  68. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  69. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
  70. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  71. package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
  72. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  73. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
  74. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  75. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
  76. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  77. package/dist/Overlay/Overlay.js +71 -27
  78. package/dist/Overlay/Overlay.js.map +1 -1
  79. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
  80. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  81. package/dist/RepeatGrid/RepeatGrid.js +117 -45
  82. package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
  83. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
  84. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  85. package/dist/SortSelector/SortSelector.js +51 -18
  86. package/dist/SortSelector/SortSelector.js.map +1 -1
  87. package/dist/SortSelector/SortSelectorButtons.js +109 -25
  88. package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
  89. package/dist/Table/InnerTable.js +46 -15
  90. package/dist/Table/InnerTable.js.map +1 -1
  91. package/dist/Table/Table.d.ts +3 -1
  92. package/dist/Table/Table.d.ts.map +1 -1
  93. package/dist/Table/Table.js +410 -158
  94. package/dist/Table/Table.js.map +1 -1
  95. package/dist/Table/TableBody.js +15 -4
  96. package/dist/Table/TableBody.js.map +1 -1
  97. package/dist/Table/TableCell.js +284 -107
  98. package/dist/Table/TableCell.js.map +1 -1
  99. package/dist/Table/TableCheckbox.js +101 -32
  100. package/dist/Table/TableCheckbox.js.map +1 -1
  101. package/dist/Table/TableFoot.js +15 -4
  102. package/dist/Table/TableFoot.js.map +1 -1
  103. package/dist/Table/TableHead.js +15 -4
  104. package/dist/Table/TableHead.js.map +1 -1
  105. package/dist/Table/TableHeaderCell.js +119 -62
  106. package/dist/Table/TableHeaderCell.js.map +1 -1
  107. package/dist/Table/TableRow.js +33 -9
  108. package/dist/Table/TableRow.js.map +1 -1
  109. package/dist/Table/TableToolbar.d.ts +5 -4
  110. package/dist/Table/TableToolbar.d.ts.map +1 -1
  111. package/dist/Table/TableToolbar.js +172 -100
  112. package/dist/Table/TableToolbar.js.map +1 -1
  113. package/dist/Table/VirtualizedTable.d.ts +11 -11
  114. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  115. package/dist/Table/VirtualizedTable.js +387 -219
  116. package/dist/Table/VirtualizedTable.js.map +1 -1
  117. package/dist/Table/VirtualizedTableContainer.js +27 -7
  118. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  119. package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
  120. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
  121. package/dist/Table/hooks/useFuzzySearch.js +57 -32
  122. package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
  123. package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
  124. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  125. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
  126. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
  127. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +74 -53
  128. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  129. package/dist/Table/model/table-model.d.ts +44 -15
  130. package/dist/Table/model/table-model.d.ts.map +1 -1
  131. package/dist/Table/model/table-model.js +33 -1
  132. package/dist/Table/model/table-model.js.map +1 -1
  133. package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
  134. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  135. package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
  136. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  137. package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
  138. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  139. package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -209
  140. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
  142. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  143. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
  144. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  145. package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
  146. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  147. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
  148. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  149. package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
  150. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  151. package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
  152. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  153. package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
  154. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  155. package/dist/TimeZoneSelector.js +131 -36
  156. package/dist/TimeZoneSelector.js.map +1 -1
  157. package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
  158. package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  159. package/dist/TransformsEditor/TransformEditor.js +830 -334
  160. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  161. package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
  162. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  163. package/dist/TransformsEditor/TransformsEditor.js +170 -59
  164. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  165. package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
  166. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  167. package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
  168. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  169. package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
  170. package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
  171. package/dist/YAMLEditor/YAMLEditor.js +41 -0
  172. package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
  173. package/dist/YAMLEditor/index.d.ts +2 -0
  174. package/dist/YAMLEditor/index.d.ts.map +1 -0
  175. package/dist/YAMLEditor/index.js +15 -0
  176. package/dist/YAMLEditor/index.js.map +1 -0
  177. package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
  178. package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
  179. package/dist/YAMLEditor/yaml-utils.js +52 -0
  180. package/dist/YAMLEditor/yaml-utils.js.map +1 -0
  181. package/dist/YAxisLabel.js +64 -20
  182. package/dist/YAxisLabel.js.map +1 -1
  183. package/dist/context/ChartsProvider.js +32 -16
  184. package/dist/context/ChartsProvider.js.map +1 -1
  185. package/dist/context/ItemActionsProvider.js +110 -61
  186. package/dist/context/ItemActionsProvider.js.map +1 -1
  187. package/dist/context/SelectionProvider.js +170 -66
  188. package/dist/context/SelectionProvider.js.map +1 -1
  189. package/dist/context/SnackbarProvider.js +101 -44
  190. package/dist/context/SnackbarProvider.js.map +1 -1
  191. package/dist/context/TimeZoneProvider.js +35 -14
  192. package/dist/context/TimeZoneProvider.js.map +1 -1
  193. package/dist/controls/TextField.js +86 -25
  194. package/dist/controls/TextField.js.map +1 -1
  195. package/dist/index.d.ts +1 -0
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +1 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/utils/browser-storage.js +64 -34
  200. package/dist/utils/browser-storage.js.map +1 -1
  201. package/package.json +12 -6
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { c as _c } from "react-compiler-runtime";
2
3
  // Copyright The Perses Authors
3
4
  // Licensed under the Apache License, Version 2.0 (the "License");
4
5
  // you may not use this file except in compliance with the License.
@@ -13,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
13
14
  // limitations under the License.
14
15
  import { Box, TablePagination, TableRow as MuiTableRow } from "@mui/material";
15
16
  import { flexRender } from "@tanstack/react-table";
16
- import { useMemo, useRef } from "react";
17
+ import { useRef } from "react";
17
18
  import { TableVirtuoso } from "react-virtuoso";
18
19
  import { useVirtualizedTableKeyboardNav } from "./hooks/useVirtualizedTableKeyboardNav.js";
19
20
  import { InnerTable } from "./InnerTable.js";
@@ -28,243 +29,410 @@ import { VirtualizedTableContainer } from "./VirtualizedTableContainer.js";
28
29
  // Separating out the virtualized table because we may want a paginated table
29
30
  // in the future that does not need virtualization, and we'd likely lay them
30
31
  // out differently.
31
- export function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs, pagination, onPaginationChange, rowCount, toolbarConfig }) {
32
- 'use no memo'; // TanStack Table row and column getters read mutable state behind stable identities.
32
+ export function VirtualizedTable(t0) {
33
+ const $ = _c(71);
34
+ const { width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, table, cellConfigs, pagination, onPaginationChange, toolbarConfig } = t0;
35
+ let t1;
36
+ if ($[0] !== table) {
37
+ t1 = table.getRowModel();
38
+ $[0] = table;
39
+ $[1] = t1;
40
+ } else {
41
+ t1 = $[1];
42
+ }
43
+ const rows = t1.rows;
44
+ let t2;
45
+ if ($[2] !== table) {
46
+ t2 = table.getVisibleFlatColumns();
47
+ $[2] = table;
48
+ $[3] = t2;
49
+ } else {
50
+ t2 = $[3];
51
+ }
52
+ const columnCount = t2.length;
33
53
  const virtuosoRef = useRef(null);
34
- // Use a ref for these values because they are only needed for keyboard
35
- // focus interactions and setting them on state will lead to a significant
36
- // amount of unnecessary re-renders.
37
- const visibleRange = useRef({
38
- startIndex: 0,
39
- endIndex: 0
40
- });
41
- const setVisibleRange = (newVisibleRange)=>{
42
- visibleRange.current = newVisibleRange;
43
- };
44
- const keyboardNav = useVirtualizedTableKeyboardNav({
45
- visibleRange: visibleRange,
46
- virtualTable: virtuosoRef,
47
- // We add 1 here for the header.
48
- maxRows: rows.length + 1,
49
- maxColumns: columns.length
50
- });
51
- const getFocusState = (cellPosition)=>{
52
- if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {
53
- return keyboardNav.isActive ? 'trigger-focus' : 'focus-next';
54
- }
55
- return 'none';
56
- };
57
- const VirtuosoTableComponents = useMemo(()=>{
58
- return {
54
+ let t3;
55
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
56
+ t3 = {
57
+ startIndex: 0,
58
+ endIndex: 0
59
+ };
60
+ $[4] = t3;
61
+ } else {
62
+ t3 = $[4];
63
+ }
64
+ const visibleRange = useRef(t3);
65
+ let t4;
66
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
67
+ t4 = (newVisibleRange)=>{
68
+ visibleRange.current = newVisibleRange;
69
+ };
70
+ $[5] = t4;
71
+ } else {
72
+ t4 = $[5];
73
+ }
74
+ const setVisibleRange = t4;
75
+ const t5 = rows.length + 1;
76
+ let t6;
77
+ if ($[6] !== columnCount || $[7] !== t5) {
78
+ t6 = {
79
+ visibleRange,
80
+ virtualTable: virtuosoRef,
81
+ maxRows: t5,
82
+ maxColumns: columnCount
83
+ };
84
+ $[6] = columnCount;
85
+ $[7] = t5;
86
+ $[8] = t6;
87
+ } else {
88
+ t6 = $[8];
89
+ }
90
+ const keyboardNav = useVirtualizedTableKeyboardNav(t6);
91
+ let t7;
92
+ if ($[9] !== keyboardNav.activeCell || $[10] !== keyboardNav.isActive) {
93
+ t7 = (cellPosition)=>{
94
+ if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {
95
+ return keyboardNav.isActive ? "trigger-focus" : "focus-next";
96
+ }
97
+ return "none";
98
+ };
99
+ $[9] = keyboardNav.activeCell;
100
+ $[10] = keyboardNav.isActive;
101
+ $[11] = t7;
102
+ } else {
103
+ t7 = $[11];
104
+ }
105
+ const getFocusState = t7;
106
+ let t8;
107
+ if ($[12] !== density || $[13] !== keyboardNav.onTableBlur || $[14] !== keyboardNav.onTableKeyDown || $[15] !== width) {
108
+ t8 = (props)=>/*#__PURE__*/ _jsx(InnerTable, {
109
+ ...props,
110
+ width: width,
111
+ density: density,
112
+ onKeyDown: keyboardNav.onTableKeyDown,
113
+ onBlur: keyboardNav.onTableBlur
114
+ });
115
+ $[12] = density;
116
+ $[13] = keyboardNav.onTableBlur;
117
+ $[14] = keyboardNav.onTableKeyDown;
118
+ $[15] = width;
119
+ $[16] = t8;
120
+ } else {
121
+ t8 = $[16];
122
+ }
123
+ let t9;
124
+ if ($[17] !== density || $[18] !== onRowClick || $[19] !== onRowMouseOut || $[20] !== onRowMouseOver || $[21] !== rows) {
125
+ t9 = (t10)=>{
126
+ const { item: _item, ...props_0 } = t10;
127
+ const index = props_0["data-index"];
128
+ const row = rows[index];
129
+ if (!row) {
130
+ return null;
131
+ }
132
+ const rowEventOpts = {
133
+ id: row.id,
134
+ index: row.index
135
+ };
136
+ return /*#__PURE__*/ _jsx(TableRow, {
137
+ ...props_0,
138
+ onClick: (e)=>onRowClick(e, row),
139
+ density: density,
140
+ onMouseOver: (e_0)=>{
141
+ onRowMouseOver?.(e_0, rowEventOpts);
142
+ },
143
+ onMouseOut: (e_1)=>{
144
+ onRowMouseOut?.(e_1, rowEventOpts);
145
+ }
146
+ });
147
+ };
148
+ $[17] = density;
149
+ $[18] = onRowClick;
150
+ $[19] = onRowMouseOut;
151
+ $[20] = onRowMouseOver;
152
+ $[21] = rows;
153
+ $[22] = t9;
154
+ } else {
155
+ t9 = $[22];
156
+ }
157
+ let t10;
158
+ if ($[23] !== t8 || $[24] !== t9) {
159
+ t10 = {
59
160
  Scroller: VirtualizedTableContainer,
60
- Table: (props)=>{
61
- return /*#__PURE__*/ _jsx(InnerTable, {
62
- ...props,
63
- width: width,
64
- density: density,
65
- onKeyDown: keyboardNav.onTableKeyDown,
66
- onBlur: keyboardNav.onTableBlur
67
- });
68
- },
161
+ Table: t8,
69
162
  TableHead,
70
163
  TableFoot,
71
- TableRow: ({ item: _item, ...props })=>{
72
- const index = props['data-index'];
73
- const row = rows[index];
74
- if (!row) {
75
- return null;
76
- }
77
- const rowEventOpts = {
78
- id: row.id,
79
- index: row.index
80
- };
81
- return /*#__PURE__*/ _jsx(TableRow, {
82
- ...props,
83
- onClick: (e)=>onRowClick(e, row.id),
84
- density: density,
85
- onMouseOver: (e)=>{
86
- onRowMouseOver?.(e, rowEventOpts);
87
- },
88
- onMouseOut: (e)=>{
89
- onRowMouseOut?.(e, rowEventOpts);
90
- }
91
- });
92
- },
164
+ TableRow: t9,
93
165
  TableBody
94
166
  };
95
- }, [
96
- density,
97
- keyboardNav.onTableKeyDown,
98
- keyboardNav.onTableBlur,
99
- onRowClick,
100
- onRowMouseOut,
101
- onRowMouseOver,
102
- rows,
103
- width
104
- ]);
105
- const handleChangePage = (_event, newPage)=>{
106
- if (!pagination || !onPaginationChange) return;
107
- onPaginationChange({
108
- ...pagination,
109
- pageIndex: newPage
110
- });
111
- };
112
- const handleChangeRowsPerPage = (event)=>{
113
- if (!pagination || !onPaginationChange) return;
114
- onPaginationChange({
115
- pageIndex: 0,
116
- pageSize: parseInt(event.target.value, 10)
117
- });
118
- };
119
- /**
120
- * Instead of calling `column.getSize()` on every render for every header
121
- * and especially every data cell (very expensive),
122
- * we calculate all column sizes once per render at the root table level
123
- * and pass the column sizes down as CSS variables to the <table> element.
124
- */ const columnSizeVars = {};
125
- headers.forEach((headerGroup)=>{
126
- headerGroup.headers.filter((header)=>header.column.getCanResize()).forEach((header)=>{
127
- columnSizeVars[`--header-${header.id}-size`] = header.getSize();
128
- columnSizeVars[`--col-${header.column.id}-size`] = header.column.getSize();
167
+ $[23] = t8;
168
+ $[24] = t9;
169
+ $[25] = t10;
170
+ } else {
171
+ t10 = $[25];
172
+ }
173
+ const VirtuosoTableComponents = t10;
174
+ let t11;
175
+ if ($[26] !== onPaginationChange || $[27] !== pagination) {
176
+ t11 = (_event, newPage)=>{
177
+ if (!pagination || !onPaginationChange) {
178
+ return;
179
+ }
180
+ onPaginationChange({
181
+ ...pagination,
182
+ pageIndex: newPage
183
+ });
184
+ };
185
+ $[26] = onPaginationChange;
186
+ $[27] = pagination;
187
+ $[28] = t11;
188
+ } else {
189
+ t11 = $[28];
190
+ }
191
+ const handleChangePage = t11;
192
+ let t12;
193
+ if ($[29] !== onPaginationChange || $[30] !== pagination) {
194
+ t12 = (event)=>{
195
+ if (!pagination || !onPaginationChange) {
196
+ return;
197
+ }
198
+ onPaginationChange({
199
+ pageIndex: 0,
200
+ pageSize: parseInt(event.target.value, 10)
201
+ });
202
+ };
203
+ $[29] = onPaginationChange;
204
+ $[30] = pagination;
205
+ $[31] = t12;
206
+ } else {
207
+ t12 = $[31];
208
+ }
209
+ const handleChangeRowsPerPage = t12;
210
+ let columnSizeVars;
211
+ if ($[32] !== table) {
212
+ columnSizeVars = {};
213
+ table.getHeaderGroups().forEach((headerGroup)=>{
214
+ headerGroup.headers.filter(_temp).forEach((header_0)=>{
215
+ columnSizeVars[`--header-${header_0.id}-size`] = header_0.getSize();
216
+ columnSizeVars[`--col-${header_0.column.id}-size`] = header_0.column.getSize();
217
+ });
129
218
  });
130
- });
131
- return /*#__PURE__*/ _jsxs(Box, {
132
- style: {
219
+ $[32] = table;
220
+ $[33] = columnSizeVars;
221
+ } else {
222
+ columnSizeVars = $[33];
223
+ }
224
+ let t13;
225
+ if ($[34] !== columnSizeVars || $[35] !== height || $[36] !== width) {
226
+ t13 = {
133
227
  width,
134
228
  height,
135
229
  ...columnSizeVars
136
- },
137
- children: [
138
- /*#__PURE__*/ _jsx(TableToolbar, {
139
- ...toolbarConfig,
140
- width: width
141
- }),
142
- /*#__PURE__*/ _jsx(TableVirtuoso, {
143
- ref: virtuosoRef,
144
- totalCount: rows.length,
145
- components: VirtuosoTableComponents,
146
- // Note: this value is impacted by overscan. See this issue if overscan
147
- // is added.
148
- // https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138
149
- rangeChanged: setVisibleRange,
150
- fixedHeaderContent: ()=>{
151
- return /*#__PURE__*/ _jsx(_Fragment, {
152
- children: headers.map((headerGroup)=>{
153
- return /*#__PURE__*/ _jsx(TableRow, {
154
- density: density,
155
- children: headerGroup.headers.map((header, i, headers)=>{
156
- const column = header.column;
157
- const position = {
158
- row: 0,
159
- column: i
160
- };
161
- const isSorted = column.getIsSorted();
162
- const nextSorting = column.getNextSortingOrder();
163
- return /*#__PURE__*/ _jsx(TableHeaderCell, {
164
- onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
165
- sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
166
- nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
167
- width: header.column.getCanResize() ? `calc(var(--header-${header?.id}-size) * 1px)` : column.getSize() || defaultColumnWidth,
168
- defaultColumnHeight: defaultColumnHeight,
169
- align: column.columnDef.meta?.align,
170
- variant: "head",
171
- density: density,
172
- description: column.columnDef.meta?.headerDescription,
173
- focusState: getFocusState(position),
174
- onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
175
- isFirstColumn: i === 0,
176
- isLastColumn: i === headers.length - 1,
177
- resizeConfig: header.column.getCanResize() ? {
178
- resizeHandler: header.getResizeHandler(),
179
- resetSizeHandler: header.column.resetSize,
180
- isResizing: header.column.getIsResizing()
181
- } : undefined,
182
- children: flexRender(column.columnDef.header, header.getContext())
183
- }, header.id);
184
- })
185
- }, headerGroup.id);
186
- })
187
- });
188
- },
189
- fixedFooterContent: pagination ? ()=>/*#__PURE__*/ _jsx(MuiTableRow, {
190
- sx: {
191
- backgroundColor: (theme)=>theme.palette.background.default
192
- },
193
- children: /*#__PURE__*/ _jsx(TablePagination, {
194
- colSpan: columns.length,
195
- count: rowCount,
196
- page: pagination.pageIndex,
197
- rowsPerPage: pagination.pageSize,
198
- onPageChange: handleChangePage,
199
- onRowsPerPageChange: handleChangeRowsPerPage
200
- })
201
- }) : undefined,
202
- itemContent: (index)=>{
203
- const row = rows[index];
204
- if (!row) {
205
- return null;
206
- }
207
- return /*#__PURE__*/ _jsx(_Fragment, {
208
- children: row.getVisibleCells().map((cell, i, cells)=>{
230
+ };
231
+ $[34] = columnSizeVars;
232
+ $[35] = height;
233
+ $[36] = width;
234
+ $[37] = t13;
235
+ } else {
236
+ t13 = $[37];
237
+ }
238
+ let t14;
239
+ if ($[38] !== toolbarConfig || $[39] !== width) {
240
+ t14 = /*#__PURE__*/ _jsx(TableToolbar, {
241
+ ...toolbarConfig,
242
+ width: width
243
+ });
244
+ $[38] = toolbarConfig;
245
+ $[39] = width;
246
+ $[40] = t14;
247
+ } else {
248
+ t14 = $[40];
249
+ }
250
+ let t15;
251
+ if ($[41] !== defaultColumnHeight || $[42] !== defaultColumnWidth || $[43] !== density || $[44] !== getFocusState || $[45] !== keyboardNav || $[46] !== table) {
252
+ t15 = ()=>/*#__PURE__*/ _jsx(_Fragment, {
253
+ children: table.getHeaderGroups().map((headerGroup_0)=>/*#__PURE__*/ _jsx(TableRow, {
254
+ density: density,
255
+ children: headerGroup_0.headers.map((header_1, i, headers)=>{
256
+ const column = header_1.column;
209
257
  const position = {
210
- row: index + 1,
258
+ row: 0,
211
259
  column: i
212
260
  };
213
- const cellContext = cell.getContext();
214
- const cellConfig = cellConfigs?.[cellContext.cell.id];
215
- const cellRenderFn = cell.column.columnDef.cell;
216
- const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
217
- /*
218
- IMPORTANT:
219
- If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)
220
- Components have no access to any context (Which is intentional and correct)
221
- We may want to add parameters to a link from neighboring cells in the future as well.
222
- If this is the case, the value of the neighboring cells should be read from here and be replaced. (Bing discussed at the moment, not decided yet)
223
- */ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
224
- let description = undefined;
225
- if (typeof cellDescriptionDef === 'function') {
226
- // If the cell description is a function, set the value using
227
- // the function.
228
- description = cellDescriptionDef(cellContext);
229
- } else if (cellDescriptionDef && typeof cellContent === 'string') {
230
- // If the cell description is `true` AND the cell content is
231
- // a string (and thus viable as a `title` attribute), use the
232
- // cell content.
233
- description = cellContent;
234
- }
235
- /* this has been specifically added for the data link,
236
- therefore, non string and numeric values should be excluded
237
- */ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(([_, value])=>[
238
- 'string',
239
- 'number'
240
- ].includes(typeof value)).reduce((acc, [key, value])=>({
241
- ...acc,
242
- [key]: String(value)
243
- }), {});
244
- return /*#__PURE__*/ _jsx(TableCell, {
245
- "data-testid": cell.id,
246
- title: description || cellConfig?.text || cellContent,
247
- width: cell.column.getCanResize() ? `calc(var(--col-${cell.column.id}-size) * 1px)` : cell.column.getSize() || defaultColumnWidth,
261
+ const isSorted = column.getIsSorted();
262
+ const nextSorting = column.getNextSortingOrder();
263
+ return /*#__PURE__*/ _jsx(TableHeaderCell, {
264
+ onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
265
+ sortDirection: typeof isSorted === "string" ? isSorted : undefined,
266
+ nextSortDirection: typeof nextSorting === "string" ? nextSorting : undefined,
267
+ width: header_1.column.getCanResize() ? `calc(var(--header-${header_1?.id}-size) * 1px)` : column.getSize() || defaultColumnWidth,
248
268
  defaultColumnHeight: defaultColumnHeight,
249
- align: cell.column.columnDef.meta?.align,
269
+ align: column.columnDef.meta?.align,
270
+ variant: "head",
250
271
  density: density,
272
+ description: column.columnDef.meta?.headerDescription,
251
273
  focusState: getFocusState(position),
252
274
  onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
253
275
  isFirstColumn: i === 0,
254
- isLastColumn: i === cells.length - 1,
255
- description: description,
256
- color: cellConfig?.textColor ?? undefined,
257
- backgroundColor: cellConfig?.backgroundColor ?? undefined,
258
- dataLink: cell.column.columnDef.meta?.dataLink,
259
- adjacentCellsValuesMap: adjacentCellsValuesMap,
260
- children: cellConfig?.text || cellContent
261
- }, cell.id);
276
+ isLastColumn: i === headers.length - 1,
277
+ resizeConfig: header_1.column.getCanResize() ? {
278
+ resizeHandler: header_1.getResizeHandler(),
279
+ resetSizeHandler: ()=>header_1.column.resetSize(),
280
+ isResizing: header_1.column.getIsResizing()
281
+ } : undefined,
282
+ children: flexRender(column.columnDef.header, header_1.getContext())
283
+ }, header_1.id);
262
284
  })
263
- });
264
- }
265
- })
266
- ]
267
- });
285
+ }, headerGroup_0.id))
286
+ });
287
+ $[41] = defaultColumnHeight;
288
+ $[42] = defaultColumnWidth;
289
+ $[43] = density;
290
+ $[44] = getFocusState;
291
+ $[45] = keyboardNav;
292
+ $[46] = table;
293
+ $[47] = t15;
294
+ } else {
295
+ t15 = $[47];
296
+ }
297
+ let t16;
298
+ if ($[48] !== handleChangePage || $[49] !== handleChangeRowsPerPage || $[50] !== pagination || $[51] !== table) {
299
+ t16 = pagination ? ()=>/*#__PURE__*/ _jsx(MuiTableRow, {
300
+ sx: {
301
+ backgroundColor: _temp2
302
+ },
303
+ children: /*#__PURE__*/ _jsx(TablePagination, {
304
+ colSpan: table.getVisibleFlatColumns().length,
305
+ count: table.getRowCount(),
306
+ page: pagination.pageIndex,
307
+ rowsPerPage: pagination.pageSize,
308
+ onPageChange: handleChangePage,
309
+ onRowsPerPageChange: handleChangeRowsPerPage
310
+ })
311
+ }) : undefined;
312
+ $[48] = handleChangePage;
313
+ $[49] = handleChangeRowsPerPage;
314
+ $[50] = pagination;
315
+ $[51] = table;
316
+ $[52] = t16;
317
+ } else {
318
+ t16 = $[52];
319
+ }
320
+ let t17;
321
+ if ($[53] !== cellConfigs || $[54] !== defaultColumnHeight || $[55] !== defaultColumnWidth || $[56] !== density || $[57] !== getFocusState || $[58] !== keyboardNav || $[59] !== table) {
322
+ t17 = (index_0)=>{
323
+ const row_0 = table.getRowModel().rows[index_0];
324
+ if (!row_0) {
325
+ return null;
326
+ }
327
+ return /*#__PURE__*/ _jsx(_Fragment, {
328
+ children: row_0.getVisibleCells().map((cell, i_0, cells)=>{
329
+ const position_0 = {
330
+ row: index_0 + 1,
331
+ column: i_0
332
+ };
333
+ const cellContext = cell.getContext();
334
+ const cellConfig = cellConfigs?.[cellContext.cell.id];
335
+ const cellRenderFn = cell.column.columnDef.cell;
336
+ const cellContent = typeof cellRenderFn === "function" ? cellRenderFn(cellContext) : null;
337
+ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
338
+ let description = undefined;
339
+ if (typeof cellDescriptionDef === "function") {
340
+ description = cellDescriptionDef(cellContext);
341
+ } else {
342
+ if (cellDescriptionDef && typeof cellContent === "string") {
343
+ description = cellContent;
344
+ }
345
+ }
346
+ const adjacentCellsValuesMap = Object.entries(row_0.original)?.filter(_temp3).reduce(_temp4, {});
347
+ return /*#__PURE__*/ _jsx(TableCell, {
348
+ "data-testid": cell.id,
349
+ title: description || cellConfig?.text || cellContent,
350
+ width: cell.column.getCanResize() ? `calc(var(--col-${cell.column.id}-size) * 1px)` : cell.column.getSize() || defaultColumnWidth,
351
+ defaultColumnHeight: defaultColumnHeight,
352
+ align: cell.column.columnDef.meta?.align,
353
+ density: density,
354
+ focusState: getFocusState(position_0),
355
+ onFocusTrigger: ()=>keyboardNav.onCellFocus(position_0),
356
+ isFirstColumn: i_0 === 0,
357
+ isLastColumn: i_0 === cells.length - 1,
358
+ description: description,
359
+ color: cellConfig?.textColor ?? undefined,
360
+ backgroundColor: cellConfig?.backgroundColor ?? undefined,
361
+ dataLink: cell.column.columnDef.meta?.dataLink,
362
+ adjacentCellsValuesMap: adjacentCellsValuesMap,
363
+ children: cellConfig?.text || cellContent
364
+ }, cell.id);
365
+ })
366
+ });
367
+ };
368
+ $[53] = cellConfigs;
369
+ $[54] = defaultColumnHeight;
370
+ $[55] = defaultColumnWidth;
371
+ $[56] = density;
372
+ $[57] = getFocusState;
373
+ $[58] = keyboardNav;
374
+ $[59] = table;
375
+ $[60] = t17;
376
+ } else {
377
+ t17 = $[60];
378
+ }
379
+ let t18;
380
+ if ($[61] !== VirtuosoTableComponents || $[62] !== rows.length || $[63] !== t15 || $[64] !== t16 || $[65] !== t17) {
381
+ t18 = /*#__PURE__*/ _jsx(TableVirtuoso, {
382
+ ref: virtuosoRef,
383
+ totalCount: rows.length,
384
+ components: VirtuosoTableComponents,
385
+ rangeChanged: setVisibleRange,
386
+ fixedHeaderContent: t15,
387
+ fixedFooterContent: t16,
388
+ itemContent: t17
389
+ });
390
+ $[61] = VirtuosoTableComponents;
391
+ $[62] = rows.length;
392
+ $[63] = t15;
393
+ $[64] = t16;
394
+ $[65] = t17;
395
+ $[66] = t18;
396
+ } else {
397
+ t18 = $[66];
398
+ }
399
+ let t19;
400
+ if ($[67] !== t13 || $[68] !== t14 || $[69] !== t18) {
401
+ t19 = /*#__PURE__*/ _jsxs(Box, {
402
+ style: t13,
403
+ children: [
404
+ t14,
405
+ t18
406
+ ]
407
+ });
408
+ $[67] = t13;
409
+ $[68] = t14;
410
+ $[69] = t18;
411
+ $[70] = t19;
412
+ } else {
413
+ t19 = $[70];
414
+ }
415
+ return t19;
416
+ }
417
+ function _temp4(acc, t0) {
418
+ const [key, value_0] = t0;
419
+ return {
420
+ ...acc,
421
+ [key]: String(value_0)
422
+ };
423
+ }
424
+ function _temp3(t0) {
425
+ const [, value] = t0;
426
+ return [
427
+ "string",
428
+ "number"
429
+ ].includes(typeof value);
430
+ }
431
+ function _temp2(theme) {
432
+ return theme.palette.background.default;
433
+ }
434
+ function _temp(header) {
435
+ return header.column.getCanResize();
268
436
  }
269
437
 
270
438
  //# sourceMappingURL=VirtualizedTable.js.map