@perses-dev/components 0.30.0 → 0.31.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 (150) hide show
  1. package/dist/Legend/CompactLegend.d.ts +6 -4
  2. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  3. package/dist/Legend/CompactLegend.js +4 -1
  4. package/dist/Legend/CompactLegend.js.map +1 -1
  5. package/dist/Legend/Legend.d.ts +11 -9
  6. package/dist/Legend/Legend.d.ts.map +1 -1
  7. package/dist/Legend/Legend.js +45 -11
  8. package/dist/Legend/Legend.js.map +1 -1
  9. package/dist/Legend/ListLegend.d.ts +5 -8
  10. package/dist/Legend/ListLegend.d.ts.map +1 -1
  11. package/dist/Legend/ListLegend.js +34 -99
  12. package/dist/Legend/ListLegend.js.map +1 -1
  13. package/dist/Legend/ListLegendItem.d.ts +8 -8
  14. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  15. package/dist/Legend/ListLegendItem.js +9 -12
  16. package/dist/Legend/ListLegendItem.js.map +1 -1
  17. package/dist/LineChart/LineChart.d.ts +2 -1
  18. package/dist/LineChart/LineChart.d.ts.map +1 -1
  19. package/dist/LineChart/LineChart.js +31 -22
  20. package/dist/LineChart/LineChart.js.map +1 -1
  21. package/dist/Table/InnerTable.d.ts +9 -0
  22. package/dist/Table/InnerTable.d.ts.map +1 -0
  23. package/dist/Table/InnerTable.js +38 -0
  24. package/dist/Table/InnerTable.js.map +1 -0
  25. package/dist/Table/Table.d.ts +10 -0
  26. package/dist/Table/Table.d.ts.map +1 -0
  27. package/dist/Table/Table.js +101 -0
  28. package/dist/Table/Table.js.map +1 -0
  29. package/dist/Table/TableBody.d.ts +6 -0
  30. package/dist/Table/TableBody.d.ts.map +1 -0
  31. package/dist/Table/TableBody.js +23 -0
  32. package/dist/Table/TableBody.js.map +1 -0
  33. package/dist/Table/TableCell.d.ts +18 -0
  34. package/dist/Table/TableCell.d.ts.map +1 -0
  35. package/dist/Table/TableCell.js +91 -0
  36. package/dist/Table/TableCell.js.map +1 -0
  37. package/dist/Table/TableCheckbox.d.ts +9 -0
  38. package/dist/Table/TableCheckbox.d.ts.map +1 -0
  39. package/dist/Table/TableCheckbox.js +49 -0
  40. package/dist/Table/TableCheckbox.js.map +1 -0
  41. package/dist/Table/TableHead.d.ts +6 -0
  42. package/dist/Table/TableHead.d.ts.map +1 -0
  43. package/dist/Table/TableHead.js +23 -0
  44. package/dist/Table/TableHead.js.map +1 -0
  45. package/dist/Table/TableRow.d.ts +9 -0
  46. package/dist/Table/TableRow.d.ts.map +1 -0
  47. package/dist/Table/TableRow.js +29 -0
  48. package/dist/Table/TableRow.js.map +1 -0
  49. package/dist/Table/VirtualizedTable.d.ts +11 -0
  50. package/dist/Table/VirtualizedTable.d.ts.map +1 -0
  51. package/dist/Table/VirtualizedTable.js +152 -0
  52. package/dist/Table/VirtualizedTable.js.map +1 -0
  53. package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
  54. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
  55. package/dist/Table/VirtualizedTableContainer.js +24 -0
  56. package/dist/Table/VirtualizedTableContainer.js.map +1 -0
  57. package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
  58. package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
  59. package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
  60. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
  61. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
  62. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
  63. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
  64. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
  65. package/dist/Table/index.d.ts +4 -0
  66. package/dist/Table/index.d.ts.map +1 -0
  67. package/dist/Table/index.js +16 -0
  68. package/dist/Table/index.js.map +1 -0
  69. package/dist/Table/model/table-model.d.ts +83 -0
  70. package/dist/Table/model/table-model.d.ts.map +1 -0
  71. package/dist/Table/model/table-model.js +73 -0
  72. package/dist/Table/model/table-model.js.map +1 -0
  73. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
  74. package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
  75. package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
  76. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  77. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +2 -1
  78. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
  79. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +60 -15
  80. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
  81. package/dist/TimeSeriesTooltip/TooltipContent.d.ts +5 -3
  82. package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
  83. package/dist/TimeSeriesTooltip/TooltipContent.js +79 -42
  84. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  85. package/dist/TimeSeriesTooltip/index.d.ts +1 -1
  86. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  87. package/dist/TimeSeriesTooltip/index.js +1 -1
  88. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  89. package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
  90. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
  91. package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
  92. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
  93. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +8 -4
  94. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  95. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -2
  96. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  97. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  98. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  99. package/dist/TimeSeriesTooltip/utils.js +4 -3
  100. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  101. package/dist/cjs/Legend/CompactLegend.js +4 -1
  102. package/dist/cjs/Legend/Legend.js +45 -11
  103. package/dist/cjs/Legend/ListLegend.js +33 -98
  104. package/dist/cjs/Legend/ListLegendItem.js +8 -11
  105. package/dist/cjs/LineChart/LineChart.js +31 -22
  106. package/dist/cjs/Table/InnerTable.js +44 -0
  107. package/dist/cjs/Table/Table.js +102 -0
  108. package/dist/cjs/Table/TableBody.js +29 -0
  109. package/dist/cjs/Table/TableCell.js +97 -0
  110. package/dist/cjs/Table/TableCheckbox.js +55 -0
  111. package/dist/cjs/Table/TableHead.js +29 -0
  112. package/dist/cjs/Table/TableRow.js +35 -0
  113. package/dist/cjs/Table/VirtualizedTable.js +155 -0
  114. package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
  115. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
  116. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
  117. package/dist/cjs/Table/index.js +33 -0
  118. package/dist/cjs/Table/model/table-model.js +80 -0
  119. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
  120. package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +57 -12
  121. package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +83 -41
  122. package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
  123. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
  124. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +11 -3
  125. package/dist/cjs/TimeSeriesTooltip/utils.js +3 -2
  126. package/dist/cjs/context/SnackbarProvider.js +66 -0
  127. package/dist/cjs/index.js +2 -0
  128. package/dist/cjs/model/legend.js +7 -1
  129. package/dist/cjs/theme/palette/grey.js +6 -2
  130. package/dist/context/SnackbarProvider.d.ts +23 -0
  131. package/dist/context/SnackbarProvider.d.ts.map +1 -0
  132. package/dist/context/SnackbarProvider.js +59 -0
  133. package/dist/context/SnackbarProvider.js.map +1 -0
  134. package/dist/index.d.ts +2 -0
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +2 -0
  137. package/dist/index.js.map +1 -1
  138. package/dist/model/legend.d.ts +10 -2
  139. package/dist/model/legend.d.ts.map +1 -1
  140. package/dist/model/legend.js +5 -0
  141. package/dist/model/legend.js.map +1 -1
  142. package/dist/theme/palette/grey.d.ts.map +1 -1
  143. package/dist/theme/palette/grey.js +6 -2
  144. package/dist/theme/palette/grey.js.map +1 -1
  145. package/package.json +6 -6
  146. package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
  147. package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
  148. package/dist/TimeSeriesTooltip/focused-series.js +0 -110
  149. package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
  150. package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -116
@@ -18,9 +18,10 @@ export interface LineChartProps {
18
18
  grid?: GridComponentOption;
19
19
  legend?: LegendComponentOption;
20
20
  tooltipConfig?: TooltipConfig;
21
+ noDataVariant?: 'chart' | 'message';
21
22
  onDataZoom?: (e: ZoomEventData) => void;
22
23
  onDoubleClick?: (e: MouseEvent) => void;
23
24
  __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;
24
25
  }
25
- export declare function LineChart({ height, data, yAxis, unit, grid, legend, tooltipConfig, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride, }: LineChartProps): JSX.Element;
26
+ export declare function LineChart({ height, data, yAxis, unit, grid, legend, tooltipConfig, noDataVariant, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride, }: LineChartProps): JSX.Element;
26
27
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":"AAaA,OAAc,EAAE,UAAU,EAA6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AmB,EAEnB,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,OAAO,EAA0E,aAAa,EAAE,MAAM,SAAS,CAAC;AAgBhH,oBAAY,aAAa,GAAG;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,oCAAoC,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,iBAAiB,CAAC;CAC1F;AAED,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,aAAoC,EACpC,aAAyB,EACzB,UAAU,EACV,aAAa,EACb,oCAAoC,GACrC,EAAE,cAAc,eAoKhB"}
@@ -18,7 +18,6 @@ import { LineChart as EChartsLineChart } from 'echarts/charts';
18
18
  import { GridComponent, DataZoomComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TitleComponent, ToolboxComponent, TooltipComponent, LegendComponent } from 'echarts/components';
19
19
  import { CanvasRenderer } from 'echarts/renderers';
20
20
  import { EChart } from '../EChart';
21
- import { OPTIMIZED_MODE_SERIES_LIMIT } from '../model/graph';
22
21
  import { useChartsTheme } from '../context/ChartsThemeProvider';
23
22
  import { TimeSeriesTooltip } from '../TimeSeriesTooltip';
24
23
  import { useTimeZone } from '../context/TimeZoneProvider';
@@ -38,12 +37,12 @@ use([
38
37
  ]);
39
38
  export function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfig ={
40
39
  wrapLabels: true
41
- } , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }) {
40
+ } , noDataVariant ='message' , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }) {
42
41
  var ref;
43
42
  const chartsTheme = useChartsTheme();
44
43
  const chartRef = useRef();
45
44
  const [showTooltip, setShowTooltip] = useState(true);
46
- const [pinTooltip, setPinTooltip] = useState(false);
45
+ const [isTooltipPinned, setIsTooltipPinned] = useState(false);
47
46
  const { timeZone } = useTimeZone();
48
47
  const handleEvents = useMemo(()=>{
49
48
  return {
@@ -51,7 +50,7 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
51
50
  if (onDataZoom === undefined) {
52
51
  setTimeout(()=>{
53
52
  // workaround so unpin happens after click event
54
- setPinTooltip(false);
53
+ setIsTooltipPinned(false);
55
54
  }, 10);
56
55
  }
57
56
  if (onDataZoom === undefined || params.batch[0] === undefined) return;
@@ -75,13 +74,13 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
75
74
  }, [
76
75
  data,
77
76
  onDataZoom,
78
- setPinTooltip
77
+ setIsTooltipPinned
79
78
  ]);
80
79
  if (chartRef.current !== undefined) {
81
80
  enableDataZoom(chartRef.current);
82
81
  }
83
82
  const handleOnDoubleClick = (e)=>{
84
- setPinTooltip(false);
83
+ setIsTooltipPinned(false);
85
84
  // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
86
85
  if (onDoubleClick === undefined) {
87
86
  if (chartRef.current !== undefined) {
@@ -94,9 +93,9 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
94
93
  const { noDataOption } = chartsTheme;
95
94
  const option = useMemo(()=>{
96
95
  if (data.timeSeries === undefined) return {};
97
- if (data.timeSeries === null || data.timeSeries.length === 0) return noDataOption;
98
- // show symbols and axisPointer dashed line on hover
99
- const isOptimizedMode = data.timeSeries.length > OPTIMIZED_MODE_SERIES_LIMIT;
96
+ // The "chart" `noDataVariant` is only used when the `timeSeries` is an
97
+ // empty array because a `null` value will throw an error.
98
+ if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
100
99
  var _rangeMs;
101
100
  const rangeMs = (_rangeMs = data.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : getDateRange(data.xAxis);
102
101
  const option = {
@@ -114,13 +113,17 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
114
113
  yAxis: getYAxes(yAxis, unit),
115
114
  animation: false,
116
115
  tooltip: {
117
- show: !isOptimizedMode,
116
+ show: true,
118
117
  trigger: 'axis',
119
- showContent: false,
120
- axisPointer: {
121
- type: isOptimizedMode ? 'none' : 'line',
122
- z: 0
123
- }
118
+ showContent: false
119
+ },
120
+ // https://echarts.apache.org/en/option.html#axisPointer
121
+ axisPointer: {
122
+ type: 'line',
123
+ z: 0,
124
+ triggerEmphasis: false,
125
+ triggerTooltip: false,
126
+ snap: true
124
127
  },
125
128
  toolbox: {
126
129
  feature: {
@@ -145,17 +148,21 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
145
148
  legend,
146
149
  noDataOption,
147
150
  timeZone,
148
- __experimentalEChartsOptionsOverride
151
+ __experimentalEChartsOptionsOverride,
152
+ noDataVariant
149
153
  ]);
150
154
  return /*#__PURE__*/ _jsxs(Box, {
151
155
  sx: {
152
156
  height
153
157
  },
154
- onClick: ()=>{
155
- setPinTooltip((current)=>!current);
158
+ onClick: (e)=>{
159
+ // Pin and unpin when clicking on chart canvas but not tooltip text.
160
+ if (e.target instanceof HTMLCanvasElement) {
161
+ setIsTooltipPinned((current)=>!current);
162
+ }
156
163
  },
157
164
  onMouseDown: (e)=>{
158
- // hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels
165
+ // Hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels.
159
166
  if (e.target instanceof HTMLCanvasElement) {
160
167
  setShowTooltip(false);
161
168
  }
@@ -165,7 +172,6 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
165
172
  },
166
173
  onMouseLeave: ()=>{
167
174
  setShowTooltip(false);
168
- setPinTooltip(false);
169
175
  },
170
176
  onMouseEnter: ()=>{
171
177
  setShowTooltip(true);
@@ -179,8 +185,11 @@ export function LineChart({ height , data , yAxis , unit , grid , legend , toolt
179
185
  chartRef: chartRef,
180
186
  chartData: data,
181
187
  wrapLabels: tooltipConfig.wrapLabels,
182
- pinTooltip: pinTooltip,
183
- unit: unit
188
+ isTooltipPinned: isTooltipPinned,
189
+ unit: unit,
190
+ onUnpinClick: ()=>{
191
+ setIsTooltipPinned(false);
192
+ }
184
193
  }),
185
194
  /*#__PURE__*/ _jsx(EChart, {
186
195
  sx: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2023 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, { MouseEvent, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { EChartsDataFormat, OPTIMIZED_MODE_SERIES_LIMIT } from '../model/graph';\nimport { UnitOptions } from '../model/units';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { TimeSeriesTooltip } from '../TimeSeriesTooltip';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart, ZoomEventData } from './utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n CanvasRenderer,\n]);\n\nexport type TooltipConfig = {\n wrapLabels: boolean;\n hidden?: boolean;\n};\n\nexport interface LineChartProps {\n /**\n * Height of the chart\n */\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n tooltipConfig?: TooltipConfig;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport function LineChart({\n height,\n data,\n yAxis,\n unit,\n grid,\n legend,\n tooltipConfig = { wrapLabels: true },\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n}: LineChartProps) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [pinTooltip, setPinTooltip] = useState<boolean>(false);\n const { timeZone } = useTimeZone();\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setPinTooltip(false);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n // TODO: use legendselectchanged event to fix tooltip when legend selected\n };\n }, [data, onDataZoom, setPinTooltip]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const handleOnDoubleClick = (e: MouseEvent) => {\n setPinTooltip(false);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n };\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.timeSeries === undefined) return {};\n if (data.timeSeries === null || data.timeSeries.length === 0) return noDataOption;\n\n // show symbols and axisPointer dashed line on hover\n const isOptimizedMode = data.timeSeries.length > OPTIMIZED_MODE_SERIES_LIMIT;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs, timeZone);\n },\n },\n },\n yAxis: getYAxes(yAxis, unit),\n animation: false,\n tooltip: {\n show: !isOptimizedMode,\n trigger: 'axis',\n showContent: false, // echarts tooltip content hidden since we use custom tooltip instead\n axisPointer: {\n type: isOptimizedMode ? 'none' : 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n },\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n return option;\n }, [data, yAxis, unit, grid, legend, noDataOption, timeZone, __experimentalEChartsOptionsOverride]);\n\n return (\n <Box\n sx={{ height }}\n onClick={() => {\n setPinTooltip((current) => !current);\n }}\n onMouseDown={(e) => {\n // hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels\n if (e.target instanceof HTMLCanvasElement) {\n setShowTooltip(false);\n }\n }}\n onMouseUp={() => {\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n setPinTooltip(false);\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={handleOnDoubleClick}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead */}\n {showTooltip === true &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeSeriesTooltip\n chartRef={chartRef}\n chartData={data}\n wrapLabels={tooltipConfig.wrapLabels}\n pinTooltip={pinTooltip}\n unit={unit}\n />\n )}\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n />\n </Box>\n );\n}\n"],"names":["React","useMemo","useRef","useState","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","CanvasRenderer","EChart","OPTIMIZED_MODE_SERIES_LIMIT","useChartsTheme","TimeSeriesTooltip","useTimeZone","enableDataZoom","getDateRange","getFormattedDate","getYAxes","restoreChart","height","data","yAxis","unit","grid","legend","tooltipConfig","wrapLabels","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","option","chartsTheme","chartRef","showTooltip","setShowTooltip","pinTooltip","setPinTooltip","timeZone","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","current","handleOnDoubleClick","e","noDataOption","timeSeries","isOptimizedMode","rangeMs","series","type","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","z","toolbox","feature","dataZoom","icon","yAxisIndex","sx","onClick","onMouseDown","target","HTMLCanvasElement","onMouseUp","onMouseLeave","onMouseEnter","hidden","chartData","width","theme","echartsTheme","onEvents","_instance"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAgBC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACrE,SAASC,GAAG,QAAQ,eAAe,CAAC;AASpC,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,QAAQ,gBAAgB,CAAC;AAC/D,SACEC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,QACV,oBAAoB,CAAC;AAC5B,SAASC,cAAc,QAAQ,mBAAmB,CAAC;AACnD,SAASC,MAAM,QAAsB,WAAW,CAAC;AACjD,SAA4BC,2BAA2B,QAAQ,gBAAgB,CAAC;AAEhF,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,i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AAO,KAAKd,SAAS,EAAE;gBAClC3B,cAAc,CAACkB,QAAQ,CAACuB,OAAO,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD3B,aAAa,EAAE4B,mBAAmB;;YAGjCvB,WAAW,KAAK,IAAI,IACnB,CAAA,CAACH,GAAc,GAAdA,MAAM,CAACwC,OAAO,cAAdxC,GAAc,WAAwC,GAAvD,KAAA,CAAuD,GAAtDA,GAAc,CAA6B2C,WAAW,CAAA,KAAK,KAAK,IACjEhD,aAAa,CAACgE,MAAM,KAAK,IAAI,kBAC3B,KAAC7E,iBAAiB;gBAChBoB,QAAQ,EAAEA,QAAQ;gBAClB0D,SAAS,EAAEtE,IAAI;gBACfM,UAAU,EAAED,aAAa,CAACC,UAAU;gBACpCS,UAAU,EAAEA,UAAU;gBACtBb,IAAI,EAAEA,IAAI;cACV,AACH;0BACH,KAACb,MAAM;gBACLwE,EAAE,EAAE;oBACFU,KAAK,EAAE,MAAM;oBACbxE,MAAM,EAAE,MAAM;iBACf;gBACDW,MAAM,EAAEA,MAAM;gBACd8D,KAAK,EAAE7D,WAAW,CAAC8D,YAAY;gBAC/BC,QAAQ,EAAExD,YAAY;gBACtByD,SAAS,EAAE/D,QAAQ;cACnB;;MACE,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/LineChart/LineChart.tsx"],"sourcesContent":["// Copyright 2023 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, { MouseEvent, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n LegendComponentOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport {\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { EChartsDataFormat } from '../model/graph';\nimport { UnitOptions } from '../model/units';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { TimeSeriesTooltip } from '../TimeSeriesTooltip';\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport { enableDataZoom, getDateRange, getFormattedDate, getYAxes, restoreChart, ZoomEventData } from './utils';\n\nuse([\n EChartsLineChart,\n GridComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n LegendComponent,\n CanvasRenderer,\n]);\n\nexport type TooltipConfig = {\n wrapLabels: boolean;\n hidden?: boolean;\n};\n\nexport interface LineChartProps {\n /**\n * Height of the chart\n */\n height: number;\n data: EChartsDataFormat;\n yAxis?: YAXisComponentOption;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n legend?: LegendComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport function LineChart({\n height,\n data,\n yAxis,\n unit,\n grid,\n legend,\n tooltipConfig = { wrapLabels: true },\n noDataVariant = 'message',\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n}: LineChartProps) {\n const chartsTheme = useChartsTheme();\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [isTooltipPinned, setIsTooltipPinned] = useState<boolean>(false);\n const { timeZone } = useTimeZone();\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setIsTooltipPinned(false);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const startIndex = params.batch[0].startValue ?? 0;\n const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;\n const xAxisStartValue = data.xAxis[startIndex];\n const xAxisEndValue = data.xAxis[endIndex];\n\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n startIndex,\n endIndex,\n };\n onDataZoom(zoomEvent);\n }\n },\n // TODO: use legendselectchanged event to fix tooltip when legend selected\n };\n }, [data, onDataZoom, setIsTooltipPinned]);\n\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n\n const handleOnDoubleClick = (e: MouseEvent) => {\n setIsTooltipPinned(false);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n };\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.timeSeries === undefined) return {};\n\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data.timeSeries === null || (data.timeSeries.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n const rangeMs = data.rangeMs ?? getDateRange(data.xAxis);\n\n const option: EChartsCoreOption = {\n series: data.timeSeries,\n xAxis: {\n type: 'category',\n data: data.xAxis,\n max: data.xAxisMax,\n axisLabel: {\n formatter: (value: number) => {\n return getFormattedDate(value, rangeMs, timeZone);\n },\n },\n },\n yAxis: getYAxes(yAxis, unit),\n animation: false,\n tooltip: {\n show: true,\n trigger: 'axis',\n showContent: false, // echarts tooltip content hidden since we use custom tooltip instead\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: true,\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n legend,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n return option;\n }, [data, yAxis, unit, grid, legend, noDataOption, timeZone, __experimentalEChartsOptionsOverride, noDataVariant]);\n\n return (\n <Box\n sx={{ height }}\n onClick={(e) => {\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (e.target instanceof HTMLCanvasElement) {\n setIsTooltipPinned((current) => !current);\n }\n }}\n onMouseDown={(e) => {\n // Hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels.\n if (e.target instanceof HTMLCanvasElement) {\n setShowTooltip(false);\n }\n }}\n onMouseUp={() => {\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={handleOnDoubleClick}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead */}\n {showTooltip === true &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeSeriesTooltip\n chartRef={chartRef}\n chartData={data}\n wrapLabels={tooltipConfig.wrapLabels}\n isTooltipPinned={isTooltipPinned}\n unit={unit}\n onUnpinClick={() => {\n setIsTooltipPinned(false);\n }}\n />\n )}\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n />\n </Box>\n );\n}\n"],"names":["React","useMemo","useRef","useState","Box","use","LineChart","EChartsLineChart","GridComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","LegendComponent","CanvasRenderer","EChart","useChartsTheme","TimeSeriesTooltip","useTimeZone","enableDataZoom","getDateRange","getFormattedDate","getYAxes","restoreChart","height","data","yAxis","unit","grid","legend","tooltipConfig","wrapLabels","noDataVariant","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","option","chartsTheme","chartRef","showTooltip","setShowTooltip","isTooltipPinned","setIsTooltipPinned","timeZone","handleEvents","datazoom","params","undefined","setTimeout","batch","startIndex","startValue","endIndex","endValue","xAxis","length","xAxisStartValue","xAxisEndValue","zoomEvent","start","end","current","handleOnDoubleClick","e","noDataOption","timeSeries","rangeMs","series","type","max","xAxisMax","axisLabel","formatter","value","animation","tooltip","show","trigger","showContent","axisPointer","z","triggerEmphasis","triggerTooltip","snap","toolbox","feature","dataZoom","icon","yAxisIndex","sx","onClick","target","HTMLCanvasElement","onMouseDown","onMouseUp","onMouseLeave","onMouseEnter","hidden","chartData","onUnpinClick","width","theme","echartsTheme","onEvents","_instance"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAgBC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACrE,SAASC,GAAG,QAAQ,eAAe,CAAC;AASpC,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,QAAQ,gBAAgB,CAAC;AAC/D,SACEC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjB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,CACN;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { TableProps as MuiTableProps } from '@mui/material';
3
+ import { TableDensity } from './model/table-model';
4
+ declare type InnerTableProps = Omit<MuiTableProps, 'size'> & {
5
+ density: TableDensity;
6
+ };
7
+ export declare const InnerTable: import("react").ForwardRefExoticComponent<Pick<InnerTableProps, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "slot" | "summary" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "width" | "border" | "bgcolor" | "padding" | "align" | "cellPadding" | "cellSpacing" | "frame" | "rules" | "density" | "stickyHeader"> & import("react").RefAttributes<HTMLTableElement>>;
8
+ export {};
9
+ //# sourceMappingURL=InnerTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InnerTable.d.ts","sourceRoot":"","sources":["../../src/Table/InnerTable.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA6B,UAAU,IAAI,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AASnD,aAAK,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;IACnD,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAOF,eAAO,MAAM,UAAU,8yJAerB,CAAC"}
@@ -0,0 +1,38 @@
1
+ // Copyright 2023 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Table as MuiTable, styled } from '@mui/material';
15
+ import { forwardRef } from 'react';
16
+ const StyledMuiTable = styled(MuiTable)(({ theme })=>({
17
+ // This value is needed to have a consistent table layout when scrolling.
18
+ tableLayout: 'fixed',
19
+ borderCollapse: 'separate',
20
+ backgroundColor: theme.palette.background.paper
21
+ }));
22
+ const TABLE_DENSITY_CONFIG = {
23
+ compact: 'small',
24
+ standard: 'medium'
25
+ };
26
+ export const InnerTable = /*#__PURE__*/ forwardRef(function InnerTable({ density , width , ...otherProps }, ref) {
27
+ return /*#__PURE__*/ _jsx(StyledMuiTable, {
28
+ ...otherProps,
29
+ tabIndex: -1,
30
+ size: TABLE_DENSITY_CONFIG[density],
31
+ ref: ref,
32
+ sx: {
33
+ width: width
34
+ }
35
+ });
36
+ });
37
+
38
+ //# sourceMappingURL=InnerTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Table/InnerTable.tsx"],"sourcesContent":["// Copyright 2023 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 { Table as MuiTable, styled, TableProps as MuiTableProps } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { TableDensity } from './model/table-model';\n\nconst StyledMuiTable = styled(MuiTable)(({ theme }) => ({\n // This value is needed to have a consistent table layout when scrolling.\n tableLayout: 'fixed',\n borderCollapse: 'separate',\n backgroundColor: theme.palette.background.paper,\n}));\n\ntype InnerTableProps = Omit<MuiTableProps, 'size'> & {\n density: TableDensity;\n};\n\nconst TABLE_DENSITY_CONFIG: Record<TableDensity, MuiTableProps['size']> = {\n compact: 'small',\n standard: 'medium',\n};\n\nexport const InnerTable = forwardRef<HTMLTableElement, InnerTableProps>(function InnerTable(\n { density, width, ...otherProps },\n ref\n) {\n return (\n <StyledMuiTable\n {...otherProps}\n tabIndex={-1}\n size={TABLE_DENSITY_CONFIG[density]}\n ref={ref}\n sx={{\n width: width,\n }}\n />\n );\n});\n"],"names":["Table","MuiTable","styled","forwardRef","StyledMuiTable","theme","tableLayout","borderCollapse","backgroundColor","palette","background","paper","TABLE_DENSITY_CONFIG","compact","standard","InnerTable","density","width","otherProps","ref","tabIndex","size","sx"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,QAAqC,eAAe,CAAC;AACvF,SAASC,UAAU,QAAQ,OAAO,CAAC;AAGnC,MAAMC,cAAc,GAAGF,MAAM,CAACD,QAAQ,CAAC,CAAC,CAAC,EAAEI,KAAK,CAAA,EAAE,GAAM,CAAA;QACtD,yEAAyE;QACzEC,WAAW,EAAE,OAAO;QACpBC,cAAc,EAAE,UAAU;QAC1BC,eAAe,EAAEH,KAAK,CAACI,OAAO,CAACC,UAAU,CAACC,KAAK;KAChD,CAAA,AAAC,CAAC,AAAC;AAMJ,MAAMC,oBAAoB,GAAgD;IACxEC,OAAO,EAAE,OAAO;IAChBC,QAAQ,EAAE,QAAQ;CACnB,AAAC;AAEF,OAAO,MAAMC,UAAU,iBAAGZ,UAAU,CAAoC,SAASY,UAAU,CACzF,EAAEC,OAAO,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGC,UAAU,EAAE,EACjCC,GAAG,EACH;IACA,qBACE,KAACf,cAAc;QACZ,GAAGc,UAAU;QACdE,QAAQ,EAAE,CAAC,CAAC;QACZC,IAAI,EAAET,oBAAoB,CAACI,OAAO,CAAC;QACnCG,GAAG,EAAEA,GAAG;QACRG,EAAE,EAAE;YACFL,KAAK,EAAEA,KAAK;SACb;MACD,CACF;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { TableProps } from './model/table-model';
3
+ /**
4
+ * Component used to render tabular data in Perses use cases. This component is
5
+ * **not** intended to be a general use data table for use cases unrelated to Perses.
6
+ *
7
+ * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**
8
+ */
9
+ export declare function Table<TableData>({ data, columns, density, checkboxSelection, onRowSelectionChange, getCheckboxColor, getRowId, rowSelection, ...otherProps }: TableProps<TableData>): JSX.Element;
10
+ //# sourceMappingURL=Table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table/Table.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,UAAU,EAAkC,MAAM,qBAAqB,CAAC;AAMjF;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,EAC/B,IAAI,EACJ,OAAO,EACP,OAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,QAA6B,EAC7B,YAAiB,EACjB,GAAG,UAAU,EACd,EAAE,UAAU,CAAC,SAAS,CAAC,eA+EvB"}
@@ -0,0 +1,101 @@
1
+ // Copyright 2023 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
15
+ import { useTheme } from '@mui/material';
16
+ import { useCallback, useMemo } from 'react';
17
+ import { VirtualizedTable } from './VirtualizedTable';
18
+ import { TableCheckbox } from './TableCheckbox';
19
+ import { persesColumnsToTanstackColumns } from './model/table-model';
20
+ const DEFAULT_GET_ROW_ID = (data, index)=>{
21
+ return `${index}`;
22
+ };
23
+ /**
24
+ * Component used to render tabular data in Perses use cases. This component is
25
+ * **not** intended to be a general use data table for use cases unrelated to Perses.
26
+ *
27
+ * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**
28
+ */ export function Table({ data , columns , density ='standard' , checkboxSelection , onRowSelectionChange , getCheckboxColor , getRowId =DEFAULT_GET_ROW_ID , rowSelection ={} , ...otherProps }) {
29
+ const theme = useTheme();
30
+ const handleRowSelectionChange = (rowSelectionUpdater)=>{
31
+ const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
32
+ onRowSelectionChange === null || onRowSelectionChange === void 0 ? void 0 : onRowSelectionChange(newRowSelection);
33
+ };
34
+ const checkboxColumn = useMemo(()=>{
35
+ return {
36
+ id: 'checkboxRowSelect',
37
+ size: 32,
38
+ header: ({ table })=>{
39
+ return /*#__PURE__*/ _jsx(TableCheckbox, {
40
+ checked: table.getIsAllRowsSelected(),
41
+ indeterminate: table.getIsSomeRowsSelected(),
42
+ onChange: table.getToggleAllRowsSelectedHandler(),
43
+ color: theme.palette.text.primary,
44
+ density: density
45
+ });
46
+ },
47
+ cell: ({ row })=>{
48
+ return /*#__PURE__*/ _jsx(TableCheckbox, {
49
+ checked: row.getIsSelected(),
50
+ indeterminate: row.getIsSomeSelected(),
51
+ onChange: (e)=>{
52
+ row.getToggleSelectedHandler()(e);
53
+ },
54
+ color: getCheckboxColor === null || getCheckboxColor === void 0 ? void 0 : getCheckboxColor(row.original),
55
+ density: density
56
+ });
57
+ }
58
+ };
59
+ }, [
60
+ density,
61
+ getCheckboxColor,
62
+ theme.palette.text.primary
63
+ ]);
64
+ const tableColumns = useMemo(()=>{
65
+ const initTableColumns = persesColumnsToTanstackColumns(columns);
66
+ if (checkboxSelection) {
67
+ initTableColumns.unshift(checkboxColumn);
68
+ }
69
+ return initTableColumns;
70
+ }, [
71
+ checkboxColumn,
72
+ checkboxSelection,
73
+ columns
74
+ ]);
75
+ const table = useReactTable({
76
+ data,
77
+ columns: tableColumns,
78
+ getRowId,
79
+ getCoreRowModel: getCoreRowModel(),
80
+ enableRowSelection: !!checkboxSelection,
81
+ onRowSelectionChange: handleRowSelectionChange,
82
+ state: {
83
+ rowSelection
84
+ }
85
+ });
86
+ const handleRowClick = useCallback((rowId)=>{
87
+ table.getRow(rowId).toggleSelected();
88
+ }, [
89
+ table
90
+ ]);
91
+ return /*#__PURE__*/ _jsx(VirtualizedTable, {
92
+ ...otherProps,
93
+ density: density,
94
+ onRowClick: handleRowClick,
95
+ rows: table.getRowModel().rows,
96
+ columns: table.getAllFlatColumns(),
97
+ headers: table.getHeaderGroups()
98
+ });
99
+ }
100
+
101
+ //# sourceMappingURL=Table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Table/Table.tsx"],"sourcesContent":["// Copyright 2023 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 { useReactTable, getCoreRowModel, ColumnDef, RowSelectionState, OnChangeFn } from '@tanstack/react-table';\nimport { useTheme } from '@mui/material';\nimport { useCallback, useMemo } from 'react';\nimport { VirtualizedTable } from './VirtualizedTable';\nimport { TableCheckbox } from './TableCheckbox';\nimport { TableProps, persesColumnsToTanstackColumns } from './model/table-model';\n\nconst DEFAULT_GET_ROW_ID = (data: unknown, index: number) => {\n return `${index}`;\n};\n\n/**\n * Component used to render tabular data in Perses use cases. This component is\n * **not** intended to be a general use data table for use cases unrelated to Perses.\n *\n * **Note: This component is currently experimental and is likely to have significant breaking changes in the near future. Use with caution outside of the core Perses codebase.**\n */\nexport function Table<TableData>({\n data,\n columns,\n density = 'standard',\n checkboxSelection,\n onRowSelectionChange,\n getCheckboxColor,\n getRowId = DEFAULT_GET_ROW_ID,\n rowSelection = {},\n ...otherProps\n}: TableProps<TableData>) {\n const theme = useTheme();\n\n const handleRowSelectionChange: OnChangeFn<RowSelectionState> = (rowSelectionUpdater) => {\n const newRowSelection =\n typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;\n onRowSelectionChange?.(newRowSelection);\n };\n\n const checkboxColumn: ColumnDef<TableData> = useMemo(() => {\n return {\n id: 'checkboxRowSelect',\n size: 32,\n header: ({ table }) => {\n return (\n <TableCheckbox\n checked={table.getIsAllRowsSelected()}\n indeterminate={table.getIsSomeRowsSelected()}\n onChange={table.getToggleAllRowsSelectedHandler()}\n color={theme.palette.text.primary}\n density={density}\n />\n );\n },\n cell: ({ row }) => {\n return (\n <TableCheckbox\n checked={row.getIsSelected()}\n indeterminate={row.getIsSomeSelected()}\n onChange={(e) => {\n row.getToggleSelectedHandler()(e);\n }}\n color={getCheckboxColor?.(row.original)}\n density={density}\n />\n );\n },\n };\n }, [density, getCheckboxColor, theme.palette.text.primary]);\n\n const tableColumns: Array<ColumnDef<TableData>> = useMemo(() => {\n const initTableColumns = persesColumnsToTanstackColumns(columns);\n\n if (checkboxSelection) {\n initTableColumns.unshift(checkboxColumn);\n }\n\n return initTableColumns;\n }, [checkboxColumn, checkboxSelection, columns]);\n\n const table = useReactTable({\n data,\n columns: tableColumns,\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n enableRowSelection: !!checkboxSelection,\n onRowSelectionChange: handleRowSelectionChange,\n state: {\n rowSelection,\n },\n });\n\n const handleRowClick = useCallback(\n (rowId: string) => {\n table.getRow(rowId).toggleSelected();\n },\n [table]\n );\n\n return (\n <VirtualizedTable\n {...otherProps}\n density={density}\n onRowClick={handleRowClick}\n rows={table.getRowModel().rows}\n columns={table.getAllFlatColumns()}\n headers={table.getHeaderGroups()}\n />\n );\n}\n"],"names":["useReactTable","getCoreRowModel","useTheme","useCallback","useMemo","VirtualizedTable","TableCheckbox","persesColumnsToTanstackColumns","DEFAULT_GET_ROW_ID","data","index","Table","columns","density","checkboxSelection","onRowSelectionChange","getCheckboxColor","getRowId","rowSelection","otherProps","theme","handleRowSelectionChange","rowSelectionUpdater","newRowSelection","checkboxColumn","id","size","header","table","checked","getIsAllRowsSelected","indeterminate","getIsSomeRowsSelected","onChange","getToggleAllRowsSelectedHandler","color","palette","text","primary","cell","row","getIsSelected","getIsSomeSelected","e","getToggleSelectedHandler","original","tableColumns","initTableColumns","unshift","enableRowSelection","state","handleRowClick","rowId","getRow","toggleSelected","onRowClick","rows","getRowModel","getAllFlatColumns","headers","getHeaderGroups"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,aAAa,EAAEC,eAAe,QAAkD,uBAAuB,CAAC;AACjH,SAASC,QAAQ,QAAQ,eAAe,C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QACvCC,oBAAoB,EAAEM,wBAAwB;QAC9C6B,KAAK,EAAE;YACLhC,YAAY;SACb;KACF,CAAC,AAAC;IAEH,MAAMiC,cAAc,GAAGhD,WAAW,CAChC,CAACiD,KAAa,GAAK;QACjBxB,KAAK,CAACyB,MAAM,CAACD,KAAK,CAAC,CAACE,cAAc,EAAE,CAAC;IACvC,CAAC,EACD;QAAC1B,KAAK;KAAC,CACR,AAAC;IAEF,qBACE,KAACvB,gBAAgB;QACd,GAAGc,UAAU;QACdN,OAAO,EAAEA,OAAO;QAChB0C,UAAU,EAAEJ,cAAc;QAC1BK,IAAI,EAAE5B,KAAK,CAAC6B,WAAW,EAAE,CAACD,IAAI;QAC9B5C,OAAO,EAAEgB,KAAK,CAAC8B,iBAAiB,EAAE;QAClCC,OAAO,EAAE/B,KAAK,CAACgC,eAAe,EAAE;MAChC,CACF;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { TableBodyProps as MuiTableBodyProps } from '@mui/material';
3
+ declare type TableBodyProps = MuiTableBodyProps;
4
+ export declare const TableBody: import("react").ForwardRefExoticComponent<Pick<TableBodyProps, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("react").RefAttributes<HTMLTableSectionElement>>;
5
+ export {};
6
+ //# sourceMappingURL=TableBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableBody.d.ts","sourceRoot":"","sources":["../../src/Table/TableBody.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA6B,cAAc,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAG/F,aAAK,cAAc,GAAG,iBAAiB,CAAC;AAExC,eAAO,MAAM,SAAS,gqJAEpB,CAAC"}
@@ -0,0 +1,23 @@
1
+ // Copyright 2023 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { TableBody as MuiTableBody } from '@mui/material';
15
+ import { forwardRef } from 'react';
16
+ export const TableBody = /*#__PURE__*/ forwardRef(function TableBody(props, ref) {
17
+ return /*#__PURE__*/ _jsx(MuiTableBody, {
18
+ ...props,
19
+ ref: ref
20
+ });
21
+ });
22
+
23
+ //# sourceMappingURL=TableBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Table/TableBody.tsx"],"sourcesContent":["// Copyright 2023 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 { TableBody as MuiTableBody, TableBodyProps as MuiTableBodyProps } from '@mui/material';\nimport { forwardRef } from 'react';\n\ntype TableBodyProps = MuiTableBodyProps;\n\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(function TableBody(props, ref) {\n return <MuiTableBody {...props} ref={ref} />;\n});\n"],"names":["TableBody","MuiTableBody","forwardRef","props","ref"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,SAAS,IAAIC,YAAY,QAA6C,eAAe,CAAC;AAC/F,SAASC,UAAU,QAAQ,OAAO,CAAC;AAInC,OAAO,MAAMF,SAAS,iBAAGE,UAAU,CAA0C,SAASF,SAAS,CAACG,KAAK,EAAEC,GAAG,EAAE;IAC1G,qBAAO,KAACH,YAAY;QAAE,GAAGE,KAAK;QAAEC,GAAG,EAAEA,GAAG;MAAI,CAAC;AAC/C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { TableCellProps as MuiTableCellProps } from '@mui/material';
3
+ import { TableDensity } from './model/table-model';
4
+ export interface TableCellProps extends Omit<MuiTableCellProps, 'tabIndex'> {
5
+ density: TableDensity;
6
+ /**
7
+ * How the cell should behave related to focus.
8
+ * - `trigger-focus`: the cell should be auto-focused when it renders.
9
+ * - `focus-next`: the cell should have tabindex="0", so that it will be
10
+ * focused the next time someone tabs with a keyboard.
11
+ * - `none`: the cell should have tabindex="-1", so it is not focused by
12
+ * keyboard interactions at this time.
13
+ */
14
+ focusState?: 'trigger-focus' | 'focus-next' | 'none';
15
+ onFocusTrigger?: (e: React.MouseEvent<HTMLTableCellElement> | React.KeyboardEvent<HTMLTableCellElement>) => void;
16
+ }
17
+ export declare function TableCell({ children, density, variant, width, focusState, onFocusTrigger, ...otherProps }: TableCellProps): JSX.Element;
18
+ //# sourceMappingURL=TableCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../src/Table/TableCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAqC,cAAc,IAAI,iBAAiB,EAAiB,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAmBvE,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACzE,OAAO,EAAE,YAAY,CAAC;IAEtB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,MAAM,CAAC;IACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;CAClH;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,UAAmB,EACnB,cAAc,EACd,GAAG,UAAU,EACd,EAAE,cAAc,eAqEhB"}
@@ -0,0 +1,91 @@
1
+ // Copyright 2023 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { TableCell as MuiTableCell, styled, Box, useTheme } from '@mui/material';
15
+ import { useEffect, useRef } from 'react';
16
+ import { getTableCellLayout } from './model/table-model';
17
+ const StyledMuiTableCell = styled(MuiTableCell)(({ theme })=>({
18
+ padding: 0,
19
+ backgroundColor: 'inherit',
20
+ '&.MuiTableCell-head': {
21
+ // Important to avoid scrolling behind the header showing through.
22
+ backgroundColor: theme.palette.background.paper
23
+ },
24
+ '&:focus-visible': {
25
+ outline: `solid 1px ${theme.palette.primary.main}`,
26
+ // Move inward a little to avoid getting cut off when focusing on items
27
+ // at the edge of the table.
28
+ outlineOffset: '-1px',
29
+ borderRadius: 0
30
+ }
31
+ }));
32
+ export function TableCell({ children , density , variant , width , focusState ='none' , onFocusTrigger , ...otherProps }) {
33
+ const theme = useTheme();
34
+ const elRef = useRef();
35
+ const isHeader = variant === 'head';
36
+ useEffect(()=>{
37
+ if (focusState === 'trigger-focus' && elRef.current) {
38
+ elRef.current.focus();
39
+ }
40
+ }, [
41
+ focusState
42
+ ]);
43
+ const handleFocus = (e)=>{
44
+ var ref;
45
+ // From https://zellwk.com/blog/keyboard-focusable-elements/
46
+ const nestedFocusTarget = (ref = e.currentTarget) === null || ref === void 0 ? void 0 : ref.querySelector('a[href], button, input, textarea, select, details');
47
+ if (nestedFocusTarget) {
48
+ // If the cell has a focusable child, focus it instead. Mostly used for
49
+ // checkbox cells, but could have other uses.
50
+ nestedFocusTarget.focus();
51
+ }
52
+ };
53
+ const handleInteractionFocusTrigger = (e)=>{
54
+ // We use `onClick` and `onKeyUp` events instead of `onFocus` because of
55
+ // some ordering issues with when the browser calls events and how this
56
+ // plays with the triggering of focus with keyboard interactions.
57
+ // These report that a focus event happened, so we can adjust the current
58
+ // tabindex and focuses to the right cell.
59
+ onFocusTrigger === null || onFocusTrigger === void 0 ? void 0 : onFocusTrigger(e);
60
+ };
61
+ return /*#__PURE__*/ _jsx(StyledMuiTableCell, {
62
+ ...otherProps,
63
+ // Modify the tab index based on the currently focused cell. It's important
64
+ // to avoid having tabindex 0 on everything because it essentially traps
65
+ // a keyboard user in the table until they hit "tab" for every single
66
+ // cell.
67
+ tabIndex: focusState !== 'none' ? 0 : -1,
68
+ onFocus: handleFocus,
69
+ onClick: handleInteractionFocusTrigger,
70
+ onKeyUp: handleInteractionFocusTrigger,
71
+ sx: {
72
+ width: width,
73
+ borderBottom: isHeader ? (theme)=>`solid 1px ${theme.palette.grey[100]}` : `solid 1px ${theme.palette.grey[50]}`
74
+ },
75
+ ref: elRef,
76
+ children: /*#__PURE__*/ _jsx(Box, {
77
+ sx: {
78
+ ...getTableCellLayout(theme, density),
79
+ position: 'relative',
80
+ // Text truncation. Currently enforced on all cells. We may control
81
+ // this with a prop on column config in the future.
82
+ whiteSpace: 'nowrap',
83
+ overflow: 'hidden',
84
+ textOverflow: 'ellipsis'
85
+ },
86
+ children: children
87
+ })
88
+ });
89
+ }
90
+
91
+ //# sourceMappingURL=TableCell.js.map