@perses-dev/components 0.55.1 → 0.56.0-beta.1

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 +294 -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 +442 -204
  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 +86 -69
  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 -210
  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 +15 -8
@@ -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 { forwardRef, useMemo, useRef } from "react";
17
+ import { forwardRef, 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";
@@ -29,10 +30,31 @@ import { VirtualizedTableContainer } from "./VirtualizedTableContainer.js";
29
30
  // TableVirtuoso never remounts its internal components due to a changed prop.
30
31
  // Props that vary per-render are passed via the `context` prop instead.
31
32
  const VirtuosoTableComponents = {
32
- Scroller: /*#__PURE__*/ forwardRef(({ context: _, ...props }, ref)=>/*#__PURE__*/ _jsx(VirtualizedTableContainer, {
33
- ...props,
34
- ref: ref
35
- })),
33
+ Scroller: /*#__PURE__*/ forwardRef((t0, ref)=>{
34
+ const $ = _c(5);
35
+ let props;
36
+ if ($[0] !== t0) {
37
+ const { context: _, ...t1 } = t0;
38
+ props = t1;
39
+ $[0] = t0;
40
+ $[1] = props;
41
+ } else {
42
+ props = $[1];
43
+ }
44
+ let t1;
45
+ if ($[2] !== props || $[3] !== ref) {
46
+ t1 = /*#__PURE__*/ _jsx(VirtualizedTableContainer, {
47
+ ...props,
48
+ ref: ref
49
+ });
50
+ $[2] = props;
51
+ $[3] = ref;
52
+ $[4] = t1;
53
+ } else {
54
+ t1 = $[4];
55
+ }
56
+ return t1;
57
+ }),
36
58
  Table: ({ context, ...props })=>/*#__PURE__*/ _jsx(InnerTable, {
37
59
  ...props,
38
60
  width: context.width,
@@ -40,14 +62,56 @@ const VirtuosoTableComponents = {
40
62
  onKeyDown: context.onTableKeyDown,
41
63
  onBlur: context.onTableBlur
42
64
  }),
43
- TableHead: /*#__PURE__*/ forwardRef(({ context: _, ...props }, ref)=>/*#__PURE__*/ _jsx(TableHead, {
44
- ...props,
45
- ref: ref
46
- })),
47
- TableFoot: /*#__PURE__*/ forwardRef(({ context: _, ...props }, ref)=>/*#__PURE__*/ _jsx(TableFoot, {
48
- ...props,
49
- ref: ref
50
- })),
65
+ TableHead: /*#__PURE__*/ forwardRef((t0, ref)=>{
66
+ const $ = _c(5);
67
+ let props;
68
+ if ($[0] !== t0) {
69
+ const { context: _, ...t1 } = t0;
70
+ props = t1;
71
+ $[0] = t0;
72
+ $[1] = props;
73
+ } else {
74
+ props = $[1];
75
+ }
76
+ let t1;
77
+ if ($[2] !== props || $[3] !== ref) {
78
+ t1 = /*#__PURE__*/ _jsx(TableHead, {
79
+ ...props,
80
+ ref: ref
81
+ });
82
+ $[2] = props;
83
+ $[3] = ref;
84
+ $[4] = t1;
85
+ } else {
86
+ t1 = $[4];
87
+ }
88
+ return t1;
89
+ }),
90
+ TableFoot: /*#__PURE__*/ forwardRef((t0, ref)=>{
91
+ const $ = _c(5);
92
+ let props;
93
+ if ($[0] !== t0) {
94
+ const { context: _, ...t1 } = t0;
95
+ props = t1;
96
+ $[0] = t0;
97
+ $[1] = props;
98
+ } else {
99
+ props = $[1];
100
+ }
101
+ let t1;
102
+ if ($[2] !== props || $[3] !== ref) {
103
+ t1 = /*#__PURE__*/ _jsx(TableFoot, {
104
+ ...props,
105
+ ref: ref
106
+ });
107
+ $[2] = props;
108
+ $[3] = ref;
109
+ $[4] = t1;
110
+ } else {
111
+ t1 = $[4];
112
+ }
113
+ return t1;
114
+ }),
51
115
  TableRow: ({ item, context, ...props })=>{
52
116
  if (!item) {
53
117
  return null;
@@ -58,7 +122,7 @@ const VirtuosoTableComponents = {
58
122
  };
59
123
  return /*#__PURE__*/ _jsx(TableRow, {
60
124
  ...props,
61
- onClick: (e)=>context.onRowClick(e, item.id),
125
+ onClick: (e)=>context.onRowClick(e, item),
62
126
  density: context.density,
63
127
  onMouseOver: (e)=>{
64
128
  context.onRowMouseOver?.(e, rowEventOpts);
@@ -68,41 +132,112 @@ const VirtuosoTableComponents = {
68
132
  }
69
133
  });
70
134
  },
71
- TableBody: /*#__PURE__*/ forwardRef(({ context: _, ...props }, ref)=>/*#__PURE__*/ _jsx(TableBody, {
72
- ...props,
73
- ref: ref
74
- }))
135
+ TableBody: /*#__PURE__*/ forwardRef((t0, ref)=>{
136
+ const $ = _c(5);
137
+ let props;
138
+ if ($[0] !== t0) {
139
+ const { context: _, ...t1 } = t0;
140
+ props = t1;
141
+ $[0] = t0;
142
+ $[1] = props;
143
+ } else {
144
+ props = $[1];
145
+ }
146
+ let t1;
147
+ if ($[2] !== props || $[3] !== ref) {
148
+ t1 = /*#__PURE__*/ _jsx(TableBody, {
149
+ ...props,
150
+ ref: ref
151
+ });
152
+ $[2] = props;
153
+ $[3] = ref;
154
+ $[4] = t1;
155
+ } else {
156
+ t1 = $[4];
157
+ }
158
+ return t1;
159
+ })
75
160
  };
76
161
  // Separating out the virtualized table because we may want a paginated table
77
162
  // in the future that does not need virtualization, and we'd likely lay them
78
163
  // out differently.
79
- export function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs, pagination, onPaginationChange, rowCount, toolbarConfig }) {
80
- 'use no memo'; // TanStack Table row and column getters read mutable state behind stable identities.
164
+ export function VirtualizedTable(t0) {
165
+ const $ = _c(65);
166
+ const { width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, table, cellConfigs, pagination, onPaginationChange, toolbarConfig } = t0;
167
+ let t1;
168
+ if ($[0] !== table) {
169
+ t1 = table.getRowModel();
170
+ $[0] = table;
171
+ $[1] = t1;
172
+ } else {
173
+ t1 = $[1];
174
+ }
175
+ const rows = t1.rows;
176
+ let t2;
177
+ if ($[2] !== table) {
178
+ t2 = table.getVisibleFlatColumns();
179
+ $[2] = table;
180
+ $[3] = t2;
181
+ } else {
182
+ t2 = $[3];
183
+ }
184
+ const columnCount = t2.length;
81
185
  const virtuosoRef = useRef(null);
82
- // Use a ref for these values because they are only needed for keyboard
83
- // focus interactions and setting them on state will lead to a significant
84
- // amount of unnecessary re-renders.
85
- const visibleRange = useRef({
86
- startIndex: 0,
87
- endIndex: 0
88
- });
89
- const setVisibleRange = (newVisibleRange)=>{
90
- visibleRange.current = newVisibleRange;
91
- };
92
- const keyboardNav = useVirtualizedTableKeyboardNav({
93
- visibleRange: visibleRange,
94
- virtualTable: virtuosoRef,
95
- // We add 1 here for the header.
96
- maxRows: rows.length + 1,
97
- maxColumns: columns.length
98
- });
99
- const getFocusState = (cellPosition)=>{
100
- if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {
101
- return keyboardNav.isActive ? 'trigger-focus' : 'focus-next';
102
- }
103
- return 'none';
104
- };
105
- const tableContext = useMemo(()=>({
186
+ let t3;
187
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
188
+ t3 = {
189
+ startIndex: 0,
190
+ endIndex: 0
191
+ };
192
+ $[4] = t3;
193
+ } else {
194
+ t3 = $[4];
195
+ }
196
+ const visibleRange = useRef(t3);
197
+ let t4;
198
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
199
+ t4 = (newVisibleRange)=>{
200
+ visibleRange.current = newVisibleRange;
201
+ };
202
+ $[5] = t4;
203
+ } else {
204
+ t4 = $[5];
205
+ }
206
+ const setVisibleRange = t4;
207
+ const t5 = rows.length + 1;
208
+ let t6;
209
+ if ($[6] !== columnCount || $[7] !== t5) {
210
+ t6 = {
211
+ visibleRange,
212
+ virtualTable: virtuosoRef,
213
+ maxRows: t5,
214
+ maxColumns: columnCount
215
+ };
216
+ $[6] = columnCount;
217
+ $[7] = t5;
218
+ $[8] = t6;
219
+ } else {
220
+ t6 = $[8];
221
+ }
222
+ const keyboardNav = useVirtualizedTableKeyboardNav(t6);
223
+ let t7;
224
+ if ($[9] !== keyboardNav.activeCell || $[10] !== keyboardNav.isActive) {
225
+ t7 = (cellPosition)=>{
226
+ if (cellPosition.row === keyboardNav.activeCell.row && cellPosition.column === keyboardNav.activeCell.column) {
227
+ return keyboardNav.isActive ? "trigger-focus" : "focus-next";
228
+ }
229
+ return "none";
230
+ };
231
+ $[9] = keyboardNav.activeCell;
232
+ $[10] = keyboardNav.isActive;
233
+ $[11] = t7;
234
+ } else {
235
+ t7 = $[11];
236
+ }
237
+ const getFocusState = t7;
238
+ let t8;
239
+ if ($[12] !== density || $[13] !== keyboardNav.onTableBlur || $[14] !== keyboardNav.onTableKeyDown || $[15] !== onRowClick || $[16] !== onRowMouseOut || $[17] !== onRowMouseOver || $[18] !== width) {
240
+ t8 = {
106
241
  width,
107
242
  density,
108
243
  onTableKeyDown: keyboardNav.onTableKeyDown,
@@ -110,179 +245,282 @@ export function VirtualizedTable({ width, height, density, defaultColumnWidth, d
110
245
  onRowClick,
111
246
  onRowMouseOver,
112
247
  onRowMouseOut
113
- }), [
114
- width,
115
- density,
116
- keyboardNav.onTableKeyDown,
117
- keyboardNav.onTableBlur,
118
- onRowClick,
119
- onRowMouseOver,
120
- onRowMouseOut
121
- ]);
122
- const handleChangePage = (_event, newPage)=>{
123
- if (!pagination || !onPaginationChange) return;
124
- onPaginationChange({
125
- ...pagination,
126
- pageIndex: newPage
127
- });
128
- };
129
- const handleChangeRowsPerPage = (event)=>{
130
- if (!pagination || !onPaginationChange) return;
131
- onPaginationChange({
132
- pageIndex: 0,
133
- pageSize: parseInt(event.target.value, 10)
134
- });
135
- };
136
- /**
137
- * Instead of calling `column.getSize()` on every render for every header
138
- * and especially every data cell (very expensive),
139
- * we calculate all column sizes once per render at the root table level
140
- * and pass the column sizes down as CSS variables to the <table> element.
141
- */ const columnSizeVars = {};
142
- headers.forEach((headerGroup)=>{
143
- headerGroup.headers.filter((header)=>header.column.getCanResize()).forEach((header)=>{
144
- columnSizeVars[`--header-${header.id}-size`] = header.getSize();
145
- columnSizeVars[`--col-${header.column.id}-size`] = header.column.getSize();
248
+ };
249
+ $[12] = density;
250
+ $[13] = keyboardNav.onTableBlur;
251
+ $[14] = keyboardNav.onTableKeyDown;
252
+ $[15] = onRowClick;
253
+ $[16] = onRowMouseOut;
254
+ $[17] = onRowMouseOver;
255
+ $[18] = width;
256
+ $[19] = t8;
257
+ } else {
258
+ t8 = $[19];
259
+ }
260
+ const tableContext = t8;
261
+ let t9;
262
+ if ($[20] !== onPaginationChange || $[21] !== pagination) {
263
+ t9 = (_event, newPage)=>{
264
+ if (!pagination || !onPaginationChange) {
265
+ return;
266
+ }
267
+ onPaginationChange({
268
+ ...pagination,
269
+ pageIndex: newPage
270
+ });
271
+ };
272
+ $[20] = onPaginationChange;
273
+ $[21] = pagination;
274
+ $[22] = t9;
275
+ } else {
276
+ t9 = $[22];
277
+ }
278
+ const handleChangePage = t9;
279
+ let t10;
280
+ if ($[23] !== onPaginationChange || $[24] !== pagination) {
281
+ t10 = (event)=>{
282
+ if (!pagination || !onPaginationChange) {
283
+ return;
284
+ }
285
+ onPaginationChange({
286
+ pageIndex: 0,
287
+ pageSize: parseInt(event.target.value, 10)
288
+ });
289
+ };
290
+ $[23] = onPaginationChange;
291
+ $[24] = pagination;
292
+ $[25] = t10;
293
+ } else {
294
+ t10 = $[25];
295
+ }
296
+ const handleChangeRowsPerPage = t10;
297
+ let columnSizeVars;
298
+ if ($[26] !== table) {
299
+ columnSizeVars = {};
300
+ table.getHeaderGroups().forEach((headerGroup)=>{
301
+ headerGroup.headers.filter(_temp).forEach((header_0)=>{
302
+ columnSizeVars[`--header-${header_0.id}-size`] = header_0.getSize();
303
+ columnSizeVars[`--col-${header_0.column.id}-size`] = header_0.column.getSize();
304
+ });
146
305
  });
147
- });
148
- return /*#__PURE__*/ _jsxs(Box, {
149
- style: {
306
+ $[26] = table;
307
+ $[27] = columnSizeVars;
308
+ } else {
309
+ columnSizeVars = $[27];
310
+ }
311
+ let t11;
312
+ if ($[28] !== columnSizeVars || $[29] !== height || $[30] !== width) {
313
+ t11 = {
150
314
  width,
151
315
  height,
152
316
  ...columnSizeVars
153
- },
154
- children: [
155
- /*#__PURE__*/ _jsx(TableToolbar, {
156
- ...toolbarConfig,
157
- width: width
158
- }),
159
- /*#__PURE__*/ _jsx(TableVirtuoso, {
160
- ref: virtuosoRef,
161
- data: rows,
162
- components: VirtuosoTableComponents,
163
- context: tableContext,
164
- // Note: this value is impacted by overscan. See this issue if overscan
165
- // is added.
166
- // https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138
167
- rangeChanged: setVisibleRange,
168
- fixedHeaderContent: ()=>{
169
- return /*#__PURE__*/ _jsx(_Fragment, {
170
- children: headers.map((headerGroup)=>{
171
- return /*#__PURE__*/ _jsx(TableRow, {
172
- density: density,
173
- children: headerGroup.headers.map((header, i, headers)=>{
174
- const column = header.column;
175
- const position = {
176
- row: 0,
177
- column: i
178
- };
179
- const isSorted = column.getIsSorted();
180
- const nextSorting = column.getNextSortingOrder();
181
- return /*#__PURE__*/ _jsx(TableHeaderCell, {
182
- onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
183
- sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
184
- nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
185
- width: header.column.getCanResize() ? `calc(var(--header-${header?.id}-size) * 1px)` : column.getSize() || defaultColumnWidth,
186
- defaultColumnHeight: defaultColumnHeight,
187
- align: column.columnDef.meta?.align,
188
- variant: "head",
189
- density: density,
190
- description: column.columnDef.meta?.headerDescription,
191
- focusState: getFocusState(position),
192
- onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
193
- isFirstColumn: i === 0,
194
- isLastColumn: i === headers.length - 1,
195
- resizeConfig: header.column.getCanResize() ? {
196
- resizeHandler: header.getResizeHandler(),
197
- resetSizeHandler: header.column.resetSize,
198
- isResizing: header.column.getIsResizing()
199
- } : undefined,
200
- children: flexRender(column.columnDef.header, header.getContext())
201
- }, header.id);
202
- })
203
- }, headerGroup.id);
204
- })
205
- });
206
- },
207
- fixedFooterContent: pagination ? ()=>/*#__PURE__*/ _jsx(MuiTableRow, {
208
- sx: {
209
- backgroundColor: (theme)=>theme.palette.background.default
210
- },
211
- children: /*#__PURE__*/ _jsx(TablePagination, {
212
- colSpan: columns.length,
213
- count: rowCount,
214
- page: pagination.pageIndex,
215
- rowsPerPage: pagination.pageSize,
216
- onPageChange: handleChangePage,
217
- onRowsPerPageChange: handleChangeRowsPerPage
218
- })
219
- }) : undefined,
220
- itemContent: (index)=>{
221
- const row = rows[index];
222
- if (!row) {
223
- return null;
224
- }
225
- return /*#__PURE__*/ _jsx(_Fragment, {
226
- children: row.getVisibleCells().map((cell, i, cells)=>{
317
+ };
318
+ $[28] = columnSizeVars;
319
+ $[29] = height;
320
+ $[30] = width;
321
+ $[31] = t11;
322
+ } else {
323
+ t11 = $[31];
324
+ }
325
+ let t12;
326
+ if ($[32] !== toolbarConfig || $[33] !== width) {
327
+ t12 = /*#__PURE__*/ _jsx(TableToolbar, {
328
+ ...toolbarConfig,
329
+ width: width
330
+ });
331
+ $[32] = toolbarConfig;
332
+ $[33] = width;
333
+ $[34] = t12;
334
+ } else {
335
+ t12 = $[34];
336
+ }
337
+ let t13;
338
+ if ($[35] !== defaultColumnHeight || $[36] !== defaultColumnWidth || $[37] !== density || $[38] !== getFocusState || $[39] !== keyboardNav || $[40] !== table) {
339
+ t13 = ()=>/*#__PURE__*/ _jsx(_Fragment, {
340
+ children: table.getHeaderGroups().map((headerGroup_0)=>/*#__PURE__*/ _jsx(TableRow, {
341
+ density: density,
342
+ children: headerGroup_0.headers.map((header_1, i, headers)=>{
343
+ const column = header_1.column;
227
344
  const position = {
228
- row: index + 1,
345
+ row: 0,
229
346
  column: i
230
347
  };
231
- const cellContext = cell.getContext();
232
- const cellConfig = cellConfigs?.[cellContext.cell.id];
233
- const cellRenderFn = cell.column.columnDef.cell;
234
- const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
235
- /*
236
- IMPORTANT:
237
- If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)
238
- Components have no access to any context (Which is intentional and correct)
239
- We may want to add parameters to a link from neighboring cells in the future as well.
240
- 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)
241
- */ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
242
- let description = undefined;
243
- if (typeof cellDescriptionDef === 'function') {
244
- // If the cell description is a function, set the value using
245
- // the function.
246
- description = cellDescriptionDef(cellContext);
247
- } else if (cellDescriptionDef && typeof cellContent === 'string') {
248
- // If the cell description is `true` AND the cell content is
249
- // a string (and thus viable as a `title` attribute), use the
250
- // cell content.
251
- description = cellContent;
252
- }
253
- /* this has been specifically added for the data link,
254
- therefore, non string and numeric values should be excluded
255
- */ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(([_, value])=>[
256
- 'string',
257
- 'number'
258
- ].includes(typeof value)).reduce((acc, [key, value])=>({
259
- ...acc,
260
- [key]: String(value)
261
- }), {});
262
- return /*#__PURE__*/ _jsx(TableCell, {
263
- "data-testid": cell.id,
264
- title: description || cellConfig?.text || cellContent,
265
- width: cell.column.getCanResize() ? `calc(var(--col-${cell.column.id}-size) * 1px)` : cell.column.getSize() || defaultColumnWidth,
348
+ const isSorted = column.getIsSorted();
349
+ const nextSorting = column.getNextSortingOrder();
350
+ return /*#__PURE__*/ _jsx(TableHeaderCell, {
351
+ onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
352
+ sortDirection: typeof isSorted === "string" ? isSorted : undefined,
353
+ nextSortDirection: typeof nextSorting === "string" ? nextSorting : undefined,
354
+ width: header_1.column.getCanResize() ? `calc(var(--header-${header_1?.id}-size) * 1px)` : column.getSize() || defaultColumnWidth,
266
355
  defaultColumnHeight: defaultColumnHeight,
267
- align: cell.column.columnDef.meta?.align,
356
+ align: column.columnDef.meta?.align,
357
+ variant: "head",
268
358
  density: density,
359
+ description: column.columnDef.meta?.headerDescription,
269
360
  focusState: getFocusState(position),
270
361
  onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
271
362
  isFirstColumn: i === 0,
272
- isLastColumn: i === cells.length - 1,
273
- description: description,
274
- color: cellConfig?.textColor ?? undefined,
275
- backgroundColor: cellConfig?.backgroundColor ?? undefined,
276
- dataLink: cell.column.columnDef.meta?.dataLink,
277
- adjacentCellsValuesMap: adjacentCellsValuesMap,
278
- children: cellConfig?.text || cellContent
279
- }, cell.id);
363
+ isLastColumn: i === headers.length - 1,
364
+ resizeConfig: header_1.column.getCanResize() ? {
365
+ resizeHandler: header_1.getResizeHandler(),
366
+ resetSizeHandler: ()=>header_1.column.resetSize(),
367
+ isResizing: header_1.column.getIsResizing()
368
+ } : undefined,
369
+ children: flexRender(column.columnDef.header, header_1.getContext())
370
+ }, header_1.id);
280
371
  })
281
- });
282
- }
283
- })
284
- ]
285
- });
372
+ }, headerGroup_0.id))
373
+ });
374
+ $[35] = defaultColumnHeight;
375
+ $[36] = defaultColumnWidth;
376
+ $[37] = density;
377
+ $[38] = getFocusState;
378
+ $[39] = keyboardNav;
379
+ $[40] = table;
380
+ $[41] = t13;
381
+ } else {
382
+ t13 = $[41];
383
+ }
384
+ let t14;
385
+ if ($[42] !== handleChangePage || $[43] !== handleChangeRowsPerPage || $[44] !== pagination || $[45] !== table) {
386
+ t14 = pagination ? ()=>/*#__PURE__*/ _jsx(MuiTableRow, {
387
+ sx: {
388
+ backgroundColor: _temp2
389
+ },
390
+ children: /*#__PURE__*/ _jsx(TablePagination, {
391
+ colSpan: table.getVisibleFlatColumns().length,
392
+ count: table.getRowCount(),
393
+ page: pagination.pageIndex,
394
+ rowsPerPage: pagination.pageSize,
395
+ onPageChange: handleChangePage,
396
+ onRowsPerPageChange: handleChangeRowsPerPage
397
+ })
398
+ }) : undefined;
399
+ $[42] = handleChangePage;
400
+ $[43] = handleChangeRowsPerPage;
401
+ $[44] = pagination;
402
+ $[45] = table;
403
+ $[46] = t14;
404
+ } else {
405
+ t14 = $[46];
406
+ }
407
+ let t15;
408
+ if ($[47] !== cellConfigs || $[48] !== defaultColumnHeight || $[49] !== defaultColumnWidth || $[50] !== density || $[51] !== getFocusState || $[52] !== keyboardNav || $[53] !== table) {
409
+ t15 = (index)=>{
410
+ const row = table.getRowModel().rows[index];
411
+ if (!row) {
412
+ return null;
413
+ }
414
+ return /*#__PURE__*/ _jsx(_Fragment, {
415
+ children: row.getVisibleCells().map((cell, i_0, cells)=>{
416
+ const position_0 = {
417
+ row: index + 1,
418
+ column: i_0
419
+ };
420
+ const cellContext = cell.getContext();
421
+ const cellConfig = cellConfigs?.[cellContext.cell.id];
422
+ const cellRenderFn = cell.column.columnDef.cell;
423
+ const cellContent = typeof cellRenderFn === "function" ? cellRenderFn(cellContext) : null;
424
+ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
425
+ let description = undefined;
426
+ if (typeof cellDescriptionDef === "function") {
427
+ description = cellDescriptionDef(cellContext);
428
+ } else {
429
+ if (cellDescriptionDef && typeof cellContent === "string") {
430
+ description = cellContent;
431
+ }
432
+ }
433
+ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(_temp3).reduce(_temp4, {});
434
+ return /*#__PURE__*/ _jsx(TableCell, {
435
+ "data-testid": cell.id,
436
+ title: description || cellConfig?.text || cellContent,
437
+ width: cell.column.getCanResize() ? `calc(var(--col-${cell.column.id}-size) * 1px)` : cell.column.getSize() || defaultColumnWidth,
438
+ defaultColumnHeight: defaultColumnHeight,
439
+ align: cell.column.columnDef.meta?.align,
440
+ density: density,
441
+ focusState: getFocusState(position_0),
442
+ onFocusTrigger: ()=>keyboardNav.onCellFocus(position_0),
443
+ isFirstColumn: i_0 === 0,
444
+ isLastColumn: i_0 === cells.length - 1,
445
+ description: description,
446
+ color: cellConfig?.textColor ?? undefined,
447
+ backgroundColor: cellConfig?.backgroundColor ?? undefined,
448
+ dataLink: cell.column.columnDef.meta?.dataLink,
449
+ adjacentCellsValuesMap: adjacentCellsValuesMap,
450
+ children: cellConfig?.text || cellContent
451
+ }, cell.id);
452
+ })
453
+ });
454
+ };
455
+ $[47] = cellConfigs;
456
+ $[48] = defaultColumnHeight;
457
+ $[49] = defaultColumnWidth;
458
+ $[50] = density;
459
+ $[51] = getFocusState;
460
+ $[52] = keyboardNav;
461
+ $[53] = table;
462
+ $[54] = t15;
463
+ } else {
464
+ t15 = $[54];
465
+ }
466
+ let t16;
467
+ if ($[55] !== rows || $[56] !== t13 || $[57] !== t14 || $[58] !== t15 || $[59] !== tableContext) {
468
+ t16 = /*#__PURE__*/ _jsx(TableVirtuoso, {
469
+ ref: virtuosoRef,
470
+ data: rows,
471
+ components: VirtuosoTableComponents,
472
+ context: tableContext,
473
+ rangeChanged: setVisibleRange,
474
+ fixedHeaderContent: t13,
475
+ fixedFooterContent: t14,
476
+ itemContent: t15
477
+ });
478
+ $[55] = rows;
479
+ $[56] = t13;
480
+ $[57] = t14;
481
+ $[58] = t15;
482
+ $[59] = tableContext;
483
+ $[60] = t16;
484
+ } else {
485
+ t16 = $[60];
486
+ }
487
+ let t17;
488
+ if ($[61] !== t11 || $[62] !== t12 || $[63] !== t16) {
489
+ t17 = /*#__PURE__*/ _jsxs(Box, {
490
+ style: t11,
491
+ children: [
492
+ t12,
493
+ t16
494
+ ]
495
+ });
496
+ $[61] = t11;
497
+ $[62] = t12;
498
+ $[63] = t16;
499
+ $[64] = t17;
500
+ } else {
501
+ t17 = $[64];
502
+ }
503
+ return t17;
504
+ }
505
+ function _temp4(acc, t0) {
506
+ const [key, value_0] = t0;
507
+ return {
508
+ ...acc,
509
+ [key]: String(value_0)
510
+ };
511
+ }
512
+ function _temp3(t0) {
513
+ const [, value] = t0;
514
+ return [
515
+ "string",
516
+ "number"
517
+ ].includes(typeof value);
518
+ }
519
+ function _temp2(theme) {
520
+ return theme.palette.background.default;
521
+ }
522
+ function _temp(header) {
523
+ return header.column.getCanResize();
286
524
  }
287
525
 
288
526
  //# sourceMappingURL=VirtualizedTable.js.map