@perses-dev/components 0.54.0-beta.1 → 0.54.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/FormEditor/FormActions.js +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.js +1 -1
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +1 -1
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +18 -4
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +25 -12
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +20 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +56 -24
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +13 -1
- package/dist/Table/TableToolbar.d.ts.map +1 -1
- package/dist/Table/TableToolbar.js +15 -4
- package/dist/Table/TableToolbar.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +6 -4
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +151 -128
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +1 -1
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +5 -3
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.js +32 -13
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +42 -2
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +37 -19
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeZoneSelector.js +1 -1
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/Legend/TableLegend.js +16 -2
- package/dist/cjs/Table/Table.js +24 -11
- package/dist/cjs/Table/TableHeaderCell.js +54 -22
- package/dist/cjs/Table/TableToolbar.js +13 -2
- package/dist/cjs/Table/VirtualizedTable.js +150 -127
- package/dist/cjs/Table/hooks/useFuzzySearch.js +30 -11
- package/dist/cjs/Table/model/table-model.js +43 -19
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -0
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/value-mapping.js +16 -0
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/format.js +20 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +17 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/request-interpolation.d.ts +1 -1
- package/dist/utils/request-interpolation.d.ts.map +1 -1
- package/dist/utils/request-interpolation.js.map +1 -1
- package/package.json +3 -2
|
@@ -35,7 +35,7 @@ const _TableCell = require("./TableCell");
|
|
|
35
35
|
const _VirtualizedTableContainer = require("./VirtualizedTableContainer");
|
|
36
36
|
const _useVirtualizedTableKeyboardNav = require("./hooks/useVirtualizedTableKeyboardNav");
|
|
37
37
|
const _TableFoot = require("./TableFoot");
|
|
38
|
-
function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs, pagination, onPaginationChange, rowCount, toolbarConfig }) {
|
|
38
|
+
function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, columnSizing, columnSizingInfo, cellConfigs, pagination, onPaginationChange, rowCount, toolbarConfig }) {
|
|
39
39
|
const virtuosoRef = (0, _react.useRef)(null);
|
|
40
40
|
// Use a ref for these values because they are only needed for keyboard
|
|
41
41
|
// focus interactions and setting them on state will lead to a significant
|
|
@@ -123,139 +123,162 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultC
|
|
|
123
123
|
pageSize: parseInt(event.target.value, 10)
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Instead of calling `column.getSize()` on every render for every header
|
|
128
|
+
* and especially every data cell (very expensive),
|
|
129
|
+
* we will calculate all column sizes at once at the root table level in a useMemo
|
|
130
|
+
* and pass the column sizes down as CSS variables to the <table> element.
|
|
131
|
+
*/ const columnSizeVars = (0, _react.useMemo)(()=>{
|
|
132
|
+
const colSizes = {};
|
|
133
|
+
headers.forEach((headerGroup)=>{
|
|
134
|
+
headerGroup.headers.filter((header)=>header.column.getCanResize()).forEach((header)=>{
|
|
135
|
+
colSizes[`--header-${header.id}-size`] = header.getSize();
|
|
136
|
+
colSizes[`--col-${header.column.id}-size`] = header.column.getSize();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return colSizes;
|
|
140
|
+
// We want to recalculate column sizes whenever column sizes or column resizing info changes.
|
|
141
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
+
}, [
|
|
143
|
+
columnSizingInfo,
|
|
144
|
+
columnSizing,
|
|
145
|
+
headers
|
|
146
|
+
]);
|
|
147
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
148
|
+
style: {
|
|
149
|
+
width,
|
|
150
|
+
height,
|
|
151
|
+
...columnSizeVars
|
|
152
|
+
},
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_TableToolbar.TableToolbar, {
|
|
155
|
+
...toolbarConfig,
|
|
156
|
+
width: width
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactvirtuoso.TableVirtuoso, {
|
|
159
|
+
ref: virtuosoRef,
|
|
160
|
+
totalCount: rows.length,
|
|
161
|
+
components: VirtuosoTableComponents,
|
|
162
|
+
// Note: this value is impacted by overscan. See this issue if overscan
|
|
163
|
+
// is added.
|
|
164
|
+
// https://github.com/petyosi/react-virtuoso/issues/118#issuecomment-642156138
|
|
165
|
+
rangeChanged: setVisibleRange,
|
|
166
|
+
fixedHeaderContent: ()=>{
|
|
167
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
168
|
+
children: headers.map((headerGroup)=>{
|
|
169
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableRow.TableRow, {
|
|
170
|
+
density: density,
|
|
171
|
+
children: headerGroup.headers.map((header, i, headers)=>{
|
|
172
|
+
const column = header.column;
|
|
173
|
+
const position = {
|
|
174
|
+
row: 0,
|
|
175
|
+
column: i
|
|
176
|
+
};
|
|
177
|
+
const isSorted = column.getIsSorted();
|
|
178
|
+
const nextSorting = column.getNextSortingOrder();
|
|
179
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableHeaderCell.TableHeaderCell, {
|
|
180
|
+
onSort: column.getCanSort() ? column.getToggleSortingHandler() : undefined,
|
|
181
|
+
sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
|
|
182
|
+
nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
|
|
183
|
+
width: header.column.getCanResize() ? `calc(var(--header-${header?.id}-size) * 1px)` : column.getSize() || defaultColumnWidth,
|
|
184
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
185
|
+
align: column.columnDef.meta?.align,
|
|
186
|
+
variant: "head",
|
|
187
|
+
density: density,
|
|
188
|
+
description: column.columnDef.meta?.headerDescription,
|
|
189
|
+
focusState: getFocusState(position),
|
|
190
|
+
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
191
|
+
isFirstColumn: i === 0,
|
|
192
|
+
isLastColumn: i === headers.length - 1,
|
|
193
|
+
resizeConfig: header.column.getCanResize() ? {
|
|
194
|
+
resizeHandler: header.getResizeHandler(),
|
|
195
|
+
resetSizeHandler: header.column.resetSize,
|
|
196
|
+
isResizing: header.column.getIsResizing()
|
|
197
|
+
} : undefined,
|
|
198
|
+
children: (0, _reacttable.flexRender)(column.columnDef.header, header.getContext())
|
|
199
|
+
}, header.id);
|
|
200
|
+
})
|
|
201
|
+
}, headerGroup.id);
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
fixedFooterContent: pagination ? ()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableRow, {
|
|
206
|
+
sx: {
|
|
207
|
+
backgroundColor: (theme)=>theme.palette.background.default
|
|
208
|
+
},
|
|
209
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TablePagination, {
|
|
210
|
+
colSpan: columns.length,
|
|
211
|
+
count: rowCount,
|
|
212
|
+
page: pagination.pageIndex,
|
|
213
|
+
rowsPerPage: pagination.pageSize,
|
|
214
|
+
onPageChange: handleChangePage,
|
|
215
|
+
onRowsPerPageChange: handleChangeRowsPerPage
|
|
216
|
+
})
|
|
217
|
+
}) : undefined,
|
|
218
|
+
itemContent: (index)=>{
|
|
219
|
+
const row = rows[index];
|
|
220
|
+
if (!row) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
224
|
+
children: row.getVisibleCells().map((cell, i, cells)=>{
|
|
225
|
+
const position = {
|
|
226
|
+
row: index + 1,
|
|
227
|
+
column: i
|
|
228
|
+
};
|
|
229
|
+
const cellContext = cell.getContext();
|
|
230
|
+
const cellConfig = cellConfigs?.[cellContext.cell.id];
|
|
231
|
+
const cellRenderFn = cell.column.columnDef.cell;
|
|
232
|
+
const cellContent = typeof cellRenderFn === 'function' ? cellRenderFn(cellContext) : null;
|
|
233
|
+
/*
|
|
210
234
|
IMPORTANT:
|
|
211
235
|
If Variables exist in the link, they should have been translated by the plugin already. (Being developed at the moment)
|
|
212
236
|
Components have no access to any context (Which is intentional and correct)
|
|
213
237
|
We may want to add parameters to a link from neighboring cells in the future as well.
|
|
214
238
|
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)
|
|
215
239
|
*/ const cellDescriptionDef = cell.column.columnDef.meta?.cellDescription;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
240
|
+
let description = undefined;
|
|
241
|
+
if (typeof cellDescriptionDef === 'function') {
|
|
242
|
+
// If the cell description is a function, set the value using
|
|
243
|
+
// the function.
|
|
244
|
+
description = cellDescriptionDef(cellContext);
|
|
245
|
+
} else if (cellDescriptionDef && typeof cellContent === 'string') {
|
|
246
|
+
// If the cell description is `true` AND the cell content is
|
|
247
|
+
// a string (and thus viable as a `title` attribute), use the
|
|
248
|
+
// cell content.
|
|
249
|
+
description = cellContent;
|
|
250
|
+
}
|
|
251
|
+
/* this has been specifically added for the data link,
|
|
228
252
|
therefore, non string and numeric values should be excluded
|
|
229
253
|
*/ const adjacentCellsValuesMap = Object.entries(row.original)?.filter(([_, value])=>[
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
})
|
|
254
|
+
'string',
|
|
255
|
+
'number'
|
|
256
|
+
].includes(typeof value)).reduce((acc, [key, value])=>({
|
|
257
|
+
...acc,
|
|
258
|
+
[key]: String(value)
|
|
259
|
+
}), {});
|
|
260
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableCell.TableCell, {
|
|
261
|
+
"data-testid": cell.id,
|
|
262
|
+
title: description || cellConfig?.text || cellContent,
|
|
263
|
+
width: cell.column.getCanResize() ? `calc(var(--col-${cell.column.id}-size) * 1px)` : cell.column.getSize() || defaultColumnWidth,
|
|
264
|
+
defaultColumnHeight: defaultColumnHeight,
|
|
265
|
+
align: cell.column.columnDef.meta?.align,
|
|
266
|
+
density: density,
|
|
267
|
+
focusState: getFocusState(position),
|
|
268
|
+
onFocusTrigger: ()=>keyboardNav.onCellFocus(position),
|
|
269
|
+
isFirstColumn: i === 0,
|
|
270
|
+
isLastColumn: i === cells.length - 1,
|
|
271
|
+
description: description,
|
|
272
|
+
color: cellConfig?.textColor ?? undefined,
|
|
273
|
+
backgroundColor: cellConfig?.backgroundColor ?? undefined,
|
|
274
|
+
dataLink: cell.column.columnDef.meta?.dataLink,
|
|
275
|
+
adjacentCellsValuesMap: adjacentCellsValuesMap,
|
|
276
|
+
children: cellConfig?.text || cellContent
|
|
277
|
+
}, cell.id);
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
]
|
|
260
283
|
});
|
|
261
284
|
}
|
|
@@ -23,26 +23,45 @@ Object.defineProperty(exports, "useFuzzySearch", {
|
|
|
23
23
|
const _reacttable = require("@tanstack/react-table");
|
|
24
24
|
const _matchsorterutils = require("@tanstack/match-sorter-utils");
|
|
25
25
|
const _react = require("react");
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
26
|
+
const getFuzzyFilterFunction = (threshold)=>(row, columnId, value, addMeta)=>{
|
|
27
|
+
const itemRank = (0, _matchsorterutils.rankItem)(row.getValue(columnId), value, {
|
|
28
|
+
threshold: _matchsorterutils.rankings[threshold]
|
|
29
|
+
});
|
|
30
|
+
addMeta({
|
|
31
|
+
itemRank
|
|
32
|
+
});
|
|
33
|
+
return itemRank.passed;
|
|
34
|
+
};
|
|
35
|
+
function useFuzzySearch(isSearchEnabled, threshold, expanded, setExpanded) {
|
|
34
36
|
const [globalFilter, setGlobalFilter] = (0, _react.useState)('');
|
|
37
|
+
const [prevExpandedState, setPrevExpandedState] = (0, _react.useState)(expanded);
|
|
38
|
+
// expand all rows when a search query is entered, and restore previous expansion state when the query is cleared
|
|
39
|
+
const handleGlobalFilterChange = (0, _react.useCallback)((value)=>{
|
|
40
|
+
setGlobalFilter((prev)=>{
|
|
41
|
+
if (!prev) {
|
|
42
|
+
setPrevExpandedState(expanded);
|
|
43
|
+
setExpanded(true);
|
|
44
|
+
} else if (prev && !value) {
|
|
45
|
+
setExpanded(prevExpandedState);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
});
|
|
49
|
+
}, [
|
|
50
|
+
expanded,
|
|
51
|
+
prevExpandedState,
|
|
52
|
+
setExpanded
|
|
53
|
+
]);
|
|
35
54
|
return {
|
|
36
55
|
globalFilter,
|
|
37
|
-
setGlobalFilter,
|
|
56
|
+
setGlobalFilter: handleGlobalFilterChange,
|
|
38
57
|
fuzzySearchOptions: {
|
|
39
58
|
filterFns: {
|
|
40
|
-
fuzzy:
|
|
59
|
+
fuzzy: getFuzzyFilterFunction(threshold)
|
|
41
60
|
},
|
|
42
61
|
globalFilterFn: isSearchEnabled ? 'fuzzy' : undefined,
|
|
43
62
|
getFilteredRowModel: isSearchEnabled ? (0, _reacttable.getFilteredRowModel)() : undefined,
|
|
44
63
|
filterFromLeafRows: isSearchEnabled,
|
|
45
|
-
onGlobalFilterChange:
|
|
64
|
+
onGlobalFilterChange: handleGlobalFilterChange
|
|
46
65
|
}
|
|
47
66
|
};
|
|
48
67
|
}
|
|
@@ -24,6 +24,12 @@ _export(exports, {
|
|
|
24
24
|
get DEFAULT_COLUMN_HEIGHT () {
|
|
25
25
|
return DEFAULT_COLUMN_HEIGHT;
|
|
26
26
|
},
|
|
27
|
+
get DEFAULT_COLUMN_MAX_WIDTH () {
|
|
28
|
+
return DEFAULT_COLUMN_MAX_WIDTH;
|
|
29
|
+
},
|
|
30
|
+
get DEFAULT_COLUMN_MIN_WIDTH () {
|
|
31
|
+
return DEFAULT_COLUMN_MIN_WIDTH;
|
|
32
|
+
},
|
|
27
33
|
get DEFAULT_COLUMN_WIDTH () {
|
|
28
34
|
return DEFAULT_COLUMN_WIDTH;
|
|
29
35
|
},
|
|
@@ -35,6 +41,8 @@ _export(exports, {
|
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
43
|
const DEFAULT_COLUMN_WIDTH = 150;
|
|
44
|
+
const DEFAULT_COLUMN_MIN_WIDTH = 60;
|
|
45
|
+
const DEFAULT_COLUMN_MAX_WIDTH = 1000;
|
|
38
46
|
const DEFAULT_COLUMN_HEIGHT = 40;
|
|
39
47
|
function calculateTableCellHeight(lineHeight, paddingY) {
|
|
40
48
|
// Doing a bunch of math to enforce height to avoid weirdness with mismatched
|
|
@@ -78,27 +86,16 @@ function getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstCol
|
|
|
78
86
|
lineHeight: lineHeight
|
|
79
87
|
};
|
|
80
88
|
}
|
|
81
|
-
function persesColumnsToTanstackColumns(columns) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// Taking from a recommendation in this github discussion:
|
|
87
|
-
// https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326
|
|
88
|
-
const sizeProps = width === 'auto' || width === undefined ? {
|
|
89
|
-
// All zero values are used as shorthand for "auto" when rendering
|
|
90
|
-
// because it makes it easy to fall back. (e.g. `row.size || "auto"`)
|
|
91
|
-
size: 0,
|
|
92
|
-
minSize: 0,
|
|
93
|
-
maxSize: 0
|
|
94
|
-
} : {
|
|
95
|
-
size: width
|
|
96
|
-
};
|
|
97
|
-
const result = {
|
|
89
|
+
function persesColumnsToTanstackColumns(columns, defaultColumnConfig) {
|
|
90
|
+
return columns.map(({ width, align, headerDescription, cellDescription, enableSorting, dataLink, enableResizing, ...otherProps })=>{
|
|
91
|
+
const isResizingEnabled = enableResizing ?? defaultColumnConfig?.enableResizing ?? false;
|
|
92
|
+
const sizeProps = width === 'auto' || width === undefined ? getDefaultSizeProps(isResizingEnabled, defaultColumnConfig?.minWidth, defaultColumnConfig?.maxWidth) : getUserProvidedSizeProps(isResizingEnabled, width, defaultColumnConfig?.minWidth, defaultColumnConfig?.maxWidth);
|
|
93
|
+
return {
|
|
98
94
|
...otherProps,
|
|
99
95
|
...sizeProps,
|
|
100
96
|
// Default sorting to false, so it is very explicitly set per column.
|
|
101
97
|
enableSorting: !!enableSorting,
|
|
98
|
+
enableResizing: isResizingEnabled,
|
|
102
99
|
// Open-ended store for extra metadata in TanStack Table, so you can bake
|
|
103
100
|
// in your own features.
|
|
104
101
|
meta: {
|
|
@@ -108,7 +105,34 @@ function persesColumnsToTanstackColumns(columns) {
|
|
|
108
105
|
dataLink
|
|
109
106
|
}
|
|
110
107
|
};
|
|
111
|
-
return result;
|
|
112
108
|
});
|
|
113
|
-
|
|
109
|
+
}
|
|
110
|
+
function getUserProvidedSizeProps(isResizingEnabled, width, minWidth, maxWidth) {
|
|
111
|
+
// When resizing is enabled, we need to set min and max size to ensure the column can be resized within a reasonable range.
|
|
112
|
+
return isResizingEnabled ? {
|
|
113
|
+
size: width,
|
|
114
|
+
minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,
|
|
115
|
+
maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH
|
|
116
|
+
} : {
|
|
117
|
+
size: width
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function getDefaultSizeProps(isResizingEnabled, minWidth, maxWidth) {
|
|
121
|
+
return isResizingEnabled ? {
|
|
122
|
+
// When resizing is enabled, we need to set a default size for the column
|
|
123
|
+
// so that relative value can be calculated when resizing and column is visible.
|
|
124
|
+
size: DEFAULT_COLUMN_WIDTH,
|
|
125
|
+
minSize: minWidth ?? DEFAULT_COLUMN_MIN_WIDTH,
|
|
126
|
+
maxSize: maxWidth ?? DEFAULT_COLUMN_MAX_WIDTH
|
|
127
|
+
} : // the space in a table. We translate our custom "auto" setting to 0 size
|
|
128
|
+
// for these columns, so it is easy to fall back to auto when rendering.
|
|
129
|
+
// Taking from a recommendation in this github discussion:
|
|
130
|
+
// https://github.com/TanStack/table/discussions/4179#discussioncomment-3631326
|
|
131
|
+
{
|
|
132
|
+
// All zero values are used as shorthand for "auto" when rendering
|
|
133
|
+
// because it makes it easy to fall back. (e.g. `row.size || "auto"`)
|
|
134
|
+
size: 0,
|
|
135
|
+
minSize: 0,
|
|
136
|
+
maxSize: 0
|
|
137
|
+
};
|
|
114
138
|
}
|
|
@@ -29,6 +29,7 @@ const _react = require("react");
|
|
|
29
29
|
const _context = require("../context");
|
|
30
30
|
const _timeZoneOption = require("../model/timeZoneOption");
|
|
31
31
|
const _SettingsAutocomplete = require("../SettingsAutocomplete");
|
|
32
|
+
const _format = require("../utils/format");
|
|
32
33
|
const _DateTimeRangePicker = require("./DateTimeRangePicker");
|
|
33
34
|
const _utils = require("./utils");
|
|
34
35
|
function _interop_require_default(obj) {
|
|
@@ -55,6 +56,8 @@ function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTim
|
|
|
55
56
|
const [tzAnchorEl, setTzAnchorEl] = (0, _react.useState)(null);
|
|
56
57
|
const tzOpen = Boolean(tzAnchorEl);
|
|
57
58
|
const tzLabel = tzOptions.find((o)=>o.value === timeZone)?.display ?? timeZone;
|
|
59
|
+
const tzOffset = (0, _format.getGMTOffset)(timeZone);
|
|
60
|
+
const localOffset = (0, _format.getGMTOffset)('local');
|
|
58
61
|
const tzAutocompleteOptions = tzOptions.map((o)=>({
|
|
59
62
|
id: o.value,
|
|
60
63
|
label: o.display
|
|
@@ -140,6 +143,26 @@ function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTim
|
|
|
140
143
|
value: (0, _utils.formatTimeRange)(value, timeZone),
|
|
141
144
|
onClick: ()=>setOpen(!open),
|
|
142
145
|
IconComponent: _Calendar.default,
|
|
146
|
+
renderValue: ()=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
147
|
+
direction: "row",
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
spacing: 1,
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
152
|
+
children: timeOptions.find((opt)=>(0, _utils.formatTimeRange)(opt.value, timeZone) === (0, _utils.formatTimeRange)(value, timeZone))?.display ?? (0, _utils.formatTimeRange)(value, timeZone)
|
|
153
|
+
}),
|
|
154
|
+
tzOffset !== localOffset && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
155
|
+
sx: {
|
|
156
|
+
typography: 'caption',
|
|
157
|
+
color: 'text.secondary'
|
|
158
|
+
},
|
|
159
|
+
children: [
|
|
160
|
+
"· ",
|
|
161
|
+
tzOffset
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
143
166
|
inputProps: {
|
|
144
167
|
'aria-label': `Select time range. Currently set to ${value}`
|
|
145
168
|
},
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -34,6 +34,7 @@ _export_star(require("./utils"), exports);
|
|
|
34
34
|
_export_star(require("./types"), exports);
|
|
35
35
|
_export_star(require("./thresholds"), exports);
|
|
36
36
|
_export_star(require("./transforms"), exports);
|
|
37
|
+
_export_star(require("./value-mapping"), exports);
|
|
37
38
|
function _export_star(from, to) {
|
|
38
39
|
Object.keys(from).forEach(function(k) {
|
|
39
40
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -30,7 +30,7 @@ require("@fontsource/inter/900.css");
|
|
|
30
30
|
const fontWeightLight = 300;
|
|
31
31
|
const fontWeightRegular = 400;
|
|
32
32
|
const fontWeightMedium = 600;
|
|
33
|
-
const fontWeightBold =
|
|
33
|
+
const fontWeightBold = 700;
|
|
34
34
|
const typography = {
|
|
35
35
|
fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
36
36
|
fontWeightLight,
|
package/dist/cjs/utils/format.js
CHANGED
|
@@ -32,6 +32,9 @@ _export(exports, {
|
|
|
32
32
|
},
|
|
33
33
|
get getFormattedAxisLabel () {
|
|
34
34
|
return getFormattedAxisLabel;
|
|
35
|
+
},
|
|
36
|
+
get getGMTOffset () {
|
|
37
|
+
return getGMTOffset;
|
|
35
38
|
}
|
|
36
39
|
});
|
|
37
40
|
const _tz = require("@date-fns/tz");
|
|
@@ -66,6 +69,23 @@ function formatWithTimeZone(date, formatString, timeZone) {
|
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
}
|
|
72
|
+
function getGMTOffset(timeZone) {
|
|
73
|
+
const lower = timeZone?.toLowerCase();
|
|
74
|
+
const resolvedTimeZone = !timeZone || lower === 'local' || lower === 'browser' ? Intl.DateTimeFormat().resolvedOptions().timeZone : lower === 'utc' ? 'UTC' : timeZone;
|
|
75
|
+
try {
|
|
76
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
77
|
+
timeZone: resolvedTimeZone,
|
|
78
|
+
timeZoneName: 'shortOffset'
|
|
79
|
+
});
|
|
80
|
+
const parts = formatter.formatToParts(new Date());
|
|
81
|
+
const tzPart = parts.find((p)=>p.type === 'timeZoneName');
|
|
82
|
+
const value = tzPart?.value ?? '';
|
|
83
|
+
if (value === 'GMT') return 'GMT+0';
|
|
84
|
+
return value;
|
|
85
|
+
} catch {
|
|
86
|
+
return 'GMT+0';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
69
89
|
function getFormattedAxisLabel(rangeMs) {
|
|
70
90
|
const dayMs = 86400000;
|
|
71
91
|
const monthMs = 2629440000;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import React, { createContext, useContext, useMemo, useState } from 'react';
|
|
15
15
|
export function ChartsProvider(props) {
|
|
16
16
|
const { children, chartsTheme, enablePinning = false, enableSyncGrouping = true } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/ChartsProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, ReactElement, useContext, useMemo, useState } from 'react';\nimport { PersesChartsTheme } from '../model';\nimport { CursorCoordinates } from '../TimeSeriesTooltip';\n\nexport interface ChartsProviderProps {\n chartsTheme: PersesChartsTheme;\n enablePinning?: boolean;\n enableSyncGrouping?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface SharedChartsState {\n chartsTheme: PersesChartsTheme;\n enablePinning: boolean;\n enableSyncGrouping: boolean;\n lastTooltipPinnedCoords: CursorCoordinates | null;\n setLastTooltipPinnedCoords: (lastTooltipPinnedCoords: CursorCoordinates | null) => void;\n}\n\nexport function ChartsProvider(props: ChartsProviderProps): ReactElement {\n const { children, chartsTheme, enablePinning = false, enableSyncGrouping = true } = props;\n\n const [lastTooltipPinnedCoords, setLastTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n\n const ctx = useMemo(() => {\n return {\n chartsTheme,\n enablePinning,\n lastTooltipPinnedCoords,\n enableSyncGrouping,\n setLastTooltipPinnedCoords,\n };\n }, [chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords]);\n\n return <ChartsThemeContext.Provider value={ctx}>{children}</ChartsThemeContext.Provider>;\n}\n\nexport const ChartsThemeContext = createContext<SharedChartsState | undefined>(undefined);\n\nexport function useChartsContext(): SharedChartsState {\n const ctx = useContext(ChartsThemeContext);\n if (ctx === undefined) {\n throw new Error('No ChartsThemeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useChartsTheme(): PersesChartsTheme {\n const ctx = useChartsContext();\n return ctx.chartsTheme;\n}\n"],"names":["React","createContext","useContext","useMemo","useState","ChartsProvider","props","children","chartsTheme","enablePinning","enableSyncGrouping","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","ctx","ChartsThemeContext","Provider","value","undefined","useChartsContext","Error","useChartsTheme"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../src/context/ChartsProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, ReactElement, useContext, useMemo, useState } from 'react';\nimport { PersesChartsTheme } from '../model';\nimport { CursorCoordinates } from '../TimeSeriesTooltip';\n\nexport interface ChartsProviderProps {\n chartsTheme: PersesChartsTheme;\n enablePinning?: boolean;\n enableSyncGrouping?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface SharedChartsState {\n chartsTheme: PersesChartsTheme;\n enablePinning: boolean;\n enableSyncGrouping: boolean;\n lastTooltipPinnedCoords: CursorCoordinates | null;\n setLastTooltipPinnedCoords: (lastTooltipPinnedCoords: CursorCoordinates | null) => void;\n}\n\nexport function ChartsProvider(props: ChartsProviderProps): ReactElement {\n const { children, chartsTheme, enablePinning = false, enableSyncGrouping = true } = props;\n\n const [lastTooltipPinnedCoords, setLastTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n\n const ctx = useMemo(() => {\n return {\n chartsTheme,\n enablePinning,\n lastTooltipPinnedCoords,\n enableSyncGrouping,\n setLastTooltipPinnedCoords,\n };\n }, [chartsTheme, enablePinning, enableSyncGrouping, lastTooltipPinnedCoords, setLastTooltipPinnedCoords]);\n\n return <ChartsThemeContext.Provider value={ctx}>{children}</ChartsThemeContext.Provider>;\n}\n\nexport const ChartsThemeContext = createContext<SharedChartsState | undefined>(undefined);\n\nexport function useChartsContext(): SharedChartsState {\n const ctx = useContext(ChartsThemeContext);\n if (ctx === undefined) {\n throw new Error('No ChartsThemeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useChartsTheme(): PersesChartsTheme {\n const ctx = useChartsContext();\n return ctx.chartsTheme;\n}\n"],"names":["React","createContext","useContext","useMemo","useState","ChartsProvider","props","children","chartsTheme","enablePinning","enableSyncGrouping","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","ctx","ChartsThemeContext","Provider","value","undefined","useChartsContext","Error","useChartsTheme"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,SAASC,aAAa,EAAgBC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAmB1F,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,gBAAgB,KAAK,EAAEC,qBAAqB,IAAI,EAAE,GAAGJ;IAEpF,MAAM,CAACK,yBAAyBC,2BAA2B,GAAGR,SAAmC;IAEjG,MAAMS,MAAMV,QAAQ;QAClB,OAAO;YACLK;YACAC;YACAE;YACAD;YACAE;QACF;IACF,GAAG;QAACJ;QAAaC;QAAeC;QAAoBC;QAAyBC;KAA2B;IAExG,qBAAO,KAACE,mBAAmBC,QAAQ;QAACC,OAAOH;kBAAMN;;AACnD;AAEA,OAAO,MAAMO,mCAAqBb,cAA6CgB,WAAW;AAE1F,OAAO,SAASC;IACd,MAAML,MAAMX,WAAWY;IACvB,IAAID,QAAQI,WAAW;QACrB,MAAM,IAAIE,MAAM;IAClB;IACA,OAAON;AACT;AAEA,OAAO,SAASO;IACd,MAAMP,MAAMK;IACZ,OAAOL,IAAIL,WAAW;AACxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
15
15
|
const ItemActionsContext = /*#__PURE__*/ createContext(undefined);
|
|
16
16
|
export function ItemActionsProvider({ children }) {
|