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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/AlignSelector/AlignSelector.js +115 -25
  2. package/dist/AlignSelector/AlignSelector.js.map +1 -1
  3. package/dist/CodeEditor/CodeEditor.d.ts +19 -0
  4. package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
  5. package/dist/CodeEditor/CodeEditor.js +122 -0
  6. package/dist/CodeEditor/CodeEditor.js.map +1 -0
  7. package/dist/ColorPicker/ColorPicker.js +153 -61
  8. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  9. package/dist/ColorPicker/OptionsColorPicker.js +147 -52
  10. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  11. package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
  12. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  13. package/dist/DensitySelector/DensitySelector.js +53 -20
  14. package/dist/DensitySelector/DensitySelector.js.map +1 -1
  15. package/dist/Dialog/Dialog.d.ts +3 -2
  16. package/dist/Dialog/Dialog.d.ts.map +1 -1
  17. package/dist/Dialog/Dialog.js +202 -49
  18. package/dist/Dialog/Dialog.js.map +1 -1
  19. package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
  20. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  21. package/dist/DragAndDrop/DragAndDropList.js +184 -113
  22. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  23. package/dist/DragAndDrop/DragButton.js +131 -52
  24. package/dist/DragAndDrop/DragButton.js.map +1 -1
  25. package/dist/DragAndDrop/DropIndicator.js +51 -26
  26. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  27. package/dist/Drawer/Drawer.js +75 -15
  28. package/dist/Drawer/Drawer.js.map +1 -1
  29. package/dist/EChart/EChart.js +179 -90
  30. package/dist/EChart/EChart.js.map +1 -1
  31. package/dist/ErrorAlert.js +14 -4
  32. package/dist/ErrorAlert.js.map +1 -1
  33. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
  34. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
  35. package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
  36. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  37. package/dist/FormEditor/FormActions.js +88 -14
  38. package/dist/FormEditor/FormActions.js.map +1 -1
  39. package/dist/FormatControls/FormatControls.js +246 -99
  40. package/dist/FormatControls/FormatControls.js.map +1 -1
  41. package/dist/FormatControls/UnitSelector.js +90 -25
  42. package/dist/FormatControls/UnitSelector.js.map +1 -1
  43. package/dist/InfoTooltip/InfoTooltip.js +105 -42
  44. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  45. package/dist/JSONEditor.d.ts +2 -6
  46. package/dist/JSONEditor.d.ts.map +1 -1
  47. package/dist/JSONEditor.js +24 -37
  48. package/dist/JSONEditor.js.map +1 -1
  49. package/dist/Legend/CompactLegend.js +77 -27
  50. package/dist/Legend/CompactLegend.js.map +1 -1
  51. package/dist/Legend/Legend.js +184 -82
  52. package/dist/Legend/Legend.js.map +1 -1
  53. package/dist/Legend/LegendColorBadge.js +54 -9
  54. package/dist/Legend/LegendColorBadge.js.map +1 -1
  55. package/dist/Legend/ListLegend.js +46 -16
  56. package/dist/Legend/ListLegend.js.map +1 -1
  57. package/dist/Legend/ListLegendItem.js +184 -48
  58. package/dist/Legend/ListLegendItem.js.map +1 -1
  59. package/dist/Legend/TableLegend.d.ts.map +1 -1
  60. package/dist/Legend/TableLegend.js +90 -48
  61. package/dist/Legend/TableLegend.js.map +1 -1
  62. package/dist/Legend/legend-model.d.ts +2 -2
  63. package/dist/Legend/legend-model.d.ts.map +1 -1
  64. package/dist/Legend/legend-model.js.map +1 -1
  65. package/dist/LinksEditor/LinkEditorForm.js +148 -67
  66. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  67. package/dist/ModeSelector/ModeSelector.js +61 -19
  68. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  69. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
  70. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  71. package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
  72. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  73. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
  74. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  75. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
  76. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  77. package/dist/Overlay/Overlay.js +71 -27
  78. package/dist/Overlay/Overlay.js.map +1 -1
  79. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
  80. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  81. package/dist/RepeatGrid/RepeatGrid.js +117 -45
  82. package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
  83. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
  84. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  85. package/dist/SortSelector/SortSelector.js +51 -18
  86. package/dist/SortSelector/SortSelector.js.map +1 -1
  87. package/dist/SortSelector/SortSelectorButtons.js +109 -25
  88. package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
  89. package/dist/Table/InnerTable.js +46 -15
  90. package/dist/Table/InnerTable.js.map +1 -1
  91. package/dist/Table/Table.d.ts +3 -1
  92. package/dist/Table/Table.d.ts.map +1 -1
  93. package/dist/Table/Table.js +410 -158
  94. package/dist/Table/Table.js.map +1 -1
  95. package/dist/Table/TableBody.js +15 -4
  96. package/dist/Table/TableBody.js.map +1 -1
  97. package/dist/Table/TableCell.js +294 -107
  98. package/dist/Table/TableCell.js.map +1 -1
  99. package/dist/Table/TableCheckbox.js +101 -32
  100. package/dist/Table/TableCheckbox.js.map +1 -1
  101. package/dist/Table/TableFoot.js +15 -4
  102. package/dist/Table/TableFoot.js.map +1 -1
  103. package/dist/Table/TableHead.js +15 -4
  104. package/dist/Table/TableHead.js.map +1 -1
  105. package/dist/Table/TableHeaderCell.js +119 -62
  106. package/dist/Table/TableHeaderCell.js.map +1 -1
  107. package/dist/Table/TableRow.js +33 -9
  108. package/dist/Table/TableRow.js.map +1 -1
  109. package/dist/Table/TableToolbar.d.ts +5 -4
  110. package/dist/Table/TableToolbar.d.ts.map +1 -1
  111. package/dist/Table/TableToolbar.js +172 -100
  112. package/dist/Table/TableToolbar.js.map +1 -1
  113. package/dist/Table/VirtualizedTable.d.ts +11 -11
  114. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  115. package/dist/Table/VirtualizedTable.js +442 -204
  116. package/dist/Table/VirtualizedTable.js.map +1 -1
  117. package/dist/Table/VirtualizedTableContainer.js +27 -7
  118. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  119. package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
  120. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
  121. package/dist/Table/hooks/useFuzzySearch.js +57 -32
  122. package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
  123. package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
  124. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  125. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
  126. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
  127. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +86 -69
  128. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  129. package/dist/Table/model/table-model.d.ts +44 -15
  130. package/dist/Table/model/table-model.d.ts.map +1 -1
  131. package/dist/Table/model/table-model.js +33 -1
  132. package/dist/Table/model/table-model.js.map +1 -1
  133. package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
  134. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  135. package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
  136. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  137. package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
  138. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  139. package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -210
  140. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
  142. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  143. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
  144. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  145. package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
  146. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  147. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
  148. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  149. package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
  150. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  151. package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
  152. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  153. package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
  154. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  155. package/dist/TimeZoneSelector.js +131 -36
  156. package/dist/TimeZoneSelector.js.map +1 -1
  157. package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
  158. package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  159. package/dist/TransformsEditor/TransformEditor.js +830 -334
  160. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  161. package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
  162. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  163. package/dist/TransformsEditor/TransformsEditor.js +170 -59
  164. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  165. package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
  166. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  167. package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
  168. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  169. package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
  170. package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
  171. package/dist/YAMLEditor/YAMLEditor.js +41 -0
  172. package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
  173. package/dist/YAMLEditor/index.d.ts +2 -0
  174. package/dist/YAMLEditor/index.d.ts.map +1 -0
  175. package/dist/YAMLEditor/index.js +15 -0
  176. package/dist/YAMLEditor/index.js.map +1 -0
  177. package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
  178. package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
  179. package/dist/YAMLEditor/yaml-utils.js +52 -0
  180. package/dist/YAMLEditor/yaml-utils.js.map +1 -0
  181. package/dist/YAxisLabel.js +64 -20
  182. package/dist/YAxisLabel.js.map +1 -1
  183. package/dist/context/ChartsProvider.js +32 -16
  184. package/dist/context/ChartsProvider.js.map +1 -1
  185. package/dist/context/ItemActionsProvider.js +110 -61
  186. package/dist/context/ItemActionsProvider.js.map +1 -1
  187. package/dist/context/SelectionProvider.js +170 -66
  188. package/dist/context/SelectionProvider.js.map +1 -1
  189. package/dist/context/SnackbarProvider.js +101 -44
  190. package/dist/context/SnackbarProvider.js.map +1 -1
  191. package/dist/context/TimeZoneProvider.js +35 -14
  192. package/dist/context/TimeZoneProvider.js.map +1 -1
  193. package/dist/controls/TextField.js +86 -25
  194. package/dist/controls/TextField.js.map +1 -1
  195. package/dist/index.d.ts +1 -0
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +1 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/utils/browser-storage.js +64 -34
  200. package/dist/utils/browser-storage.js.map +1 -1
  201. package/package.json +15 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ExemplarMetadata/ExemplarMetadataTooltip.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// 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 { Box, Divider, IconButton, Portal, Stack, Typography } from '@mui/material';\nimport type { Exemplar, Labels } from '@perses-dev/spec';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport type { ReactElement } from 'react';\nimport { Fragment } from 'react';\nimport useResizeObserver from 'use-resize-observer';\n\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport type { FormatOptions } from '../model/units';\nimport { formatValue } from '../model/units';\nimport {\n assembleTransform,\n getTooltipStyles,\n PIN_TOOLTIP_HELP_TEXT,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_WIDTH,\n UNPIN_TOOLTIP_HELP_TEXT,\n useMousePosition,\n} from '../TimeSeriesTooltip';\nimport type { CursorCoordinates } from '../TimeSeriesTooltip/tooltip-model';\n\nexport interface ExemplarMetadataTooltipProps {\n exemplar: Exemplar;\n seriesLabels?: Labels;\n /**\n * CSS selector of the element the tooltip should be portaled into (e.g. `#dashboard`).\n * Passed as-is to `document.querySelector`, so it must be a selector and not a bare element id.\n */\n containerId?: string;\n format?: FormatOptions;\n /**\n * Position where the tooltip has been pinned, or null when it follows the mouse.\n */\n pinnedPos: CursorCoordinates | null;\n enablePinning?: boolean;\n onUnpinClick?: () => void;\n}\n\n/**\n * Tooltip showing an exemplar's metadata (series labels, exemplar labels, value and timestamp).\n * Follows the mouse while hovering an exemplar marker and can be pinned in place, the same way\n * the annotation tooltip works.\n */\nexport function ExemplarMetadataTooltip({\n exemplar,\n seriesLabels,\n containerId,\n format,\n pinnedPos,\n enablePinning = true,\n onUnpinClick,\n}: ExemplarMetadataTooltipProps): ReactElement | null {\n const { formatWithUserTimeZone } = useTimeZone();\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver<HTMLDivElement>();\n\n const isPinned = pinnedPos !== null;\n if (!isPinned && mousePos === null) return null;\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n // Fall back to the pinned position: a pinned tooltip can render before any mousemove happened.\n const transform = assembleTransform(mousePos ?? pinnedPos, pinnedPos, height ?? 0, width ?? 0, containerElement);\n\n const { labels, value, timestamp } = exemplar;\n const formattedValue = formatValue(value, format);\n const date = new Date(timestamp);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n\n // Only sections with content take part in the layout, so no divider is left dangling\n // when a label set is empty.\n const sections: Array<{ key: string; content: ReactElement }> = [];\n if (seriesLabels && Object.keys(seriesLabels).length > 0) {\n sections.push({ key: 'series-labels', content: <LabelGrid title=\"Series labels\" labels={seriesLabels} /> });\n }\n if (Object.keys(labels).length > 0) {\n sections.push({ key: 'exemplar-labels', content: <LabelGrid title=\"Exemplar labels\" labels={labels} /> });\n }\n sections.push({\n key: 'value',\n content: (\n <Box>\n <Typography variant=\"overline\" component=\"div\">\n Value\n </Typography>\n <Typography fontWeight={700}>{formattedValue}</Typography>\n </Box>\n ),\n });\n\n return (\n <Portal container={containerElement}>\n <Box ref={tooltipRef} sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)} style={{ transform }}>\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box sx={{ display: 'flex', alignItems: 'center', paddingBottom: 0.5, width: '100%' }}>\n <Box sx={{ flexGrow: 1, minWidth: 0 }}>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </Box>\n {enablePinning && (\n <Stack direction=\"row\" alignItems=\"center\" sx={{ marginLeft: 1, flexShrink: 0 }}>\n <Typography sx={{ marginRight: 0.5, fontSize: 11, verticalAlign: 'middle' }}>\n {isPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT}\n </Typography>\n {isPinned ? (\n <IconButton\n aria-label={UNPIN_TOOLTIP_HELP_TEXT}\n onClick={() => {\n if (onUnpinClick !== undefined) onUnpinClick();\n }}\n sx={{ padding: 0, color: 'inherit' }}\n >\n <Pin sx={{ fontSize: 16 }} />\n </IconButton>\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n )}\n </Box>\n <Divider sx={(theme) => ({ width: '100%', borderColor: theme.palette.grey['500'] })} />\n </Box>\n <Stack spacing={1} sx={(theme) => ({ padding: theme.spacing(0.5, 2, 1.5, 2) })}>\n {sections.map((section, index) => (\n <Fragment key={section.key}>\n {index > 0 && <Divider sx={(theme) => ({ borderColor: theme.palette.grey['500'] })} />}\n {section.content}\n </Fragment>\n ))}\n </Stack>\n </Stack>\n </Box>\n </Portal>\n );\n}\n\nfunction LabelGrid({ title, labels }: { title: string; labels: Labels }): ReactElement {\n const entries = Object.entries(labels);\n return (\n <Box>\n <Typography variant=\"overline\" component=\"div\">\n {title}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n // The first column is sized by the longest label name, so all values line up\n // at the same horizontal position.\n gridTemplateColumns: 'minmax(0, max-content) minmax(0, 1fr)',\n columnGap: 0.5,\n rowGap: 0.25,\n }}\n >\n {entries.map(([labelName, labelValue]) => (\n <Fragment key={labelName}>\n <Typography sx={{ wordBreak: 'break-all' }}>{labelName}:</Typography>\n <Typography fontWeight={700} sx={{ wordBreak: 'break-all' }}>\n {labelValue}\n </Typography>\n </Fragment>\n ))}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","Divider","IconButton","Portal","Stack","Typography","Pin","PinOutline","Fragment","useResizeObserver","useTimeZone","formatValue","assembleTransform","getTooltipStyles","PIN_TOOLTIP_HELP_TEXT","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","UNPIN_TOOLTIP_HELP_TEXT","useMousePosition","ExemplarMetadataTooltip","exemplar","seriesLabels","containerId","format","pinnedPos","enablePinning","onUnpinClick","formatWithUserTimeZone","mousePos","height","width","ref","tooltipRef","isPinned","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","transform","labels","value","timestamp","formattedValue","date","Date","formattedDate","formattedTime","sections","Object","keys","length","push","key","content","LabelGrid","title","variant","component","fontWeight","container","sx","theme","style","spacing","maxWidth","padding","backgroundColor","palette","designSystem","grey","position","top","left","display","alignItems","paddingBottom","flexGrow","minWidth","color","common","white","strong","direction","marginLeft","flexShrink","marginRight","fontSize","verticalAlign","aria-label","onClick","borderColor","map","section","index","entries","gridTemplateColumns","columnGap","rowGap","labelName","labelValue","wordBreak"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAEpF,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,gBAAgB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a,SAAS;oBACT,6EAA6E;oBAC7E,mCAAmC;oBACnCsB,qBAAqB;oBACrBC,WAAW;oBACXC,QAAQ;gBACV;0BAECH,QAAQH,GAAG,CAAC,CAAC,CAACO,WAAWC,WAAW,iBACnC,MAAC7F;;0CACC,MAACH;gCAAWyD,IAAI;oCAAEwC,WAAW;gCAAY;;oCAAIF;oCAAU;;;0CACvD,KAAC/F;gCAAWuD,YAAY;gCAAKE,IAAI;oCAAEwC,WAAW;gCAAY;0CACvDD;;;uBAHUD;;;;AAUzB"}
1
+ {"version":3,"sources":["../../src/ExemplarMetadata/ExemplarMetadataTooltip.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// 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 { Box, Divider, IconButton, Portal, Stack, Typography } from '@mui/material';\nimport type { Exemplar, Labels } from '@perses-dev/spec';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport type { ReactElement } from 'react';\nimport { Fragment } from 'react';\nimport { useResizeObserver } from 'use-resize-observer';\n\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport type { FormatOptions } from '../model/units';\nimport { formatValue } from '../model/units';\nimport {\n assembleTransform,\n getTooltipStyles,\n PIN_TOOLTIP_HELP_TEXT,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_WIDTH,\n UNPIN_TOOLTIP_HELP_TEXT,\n useMousePosition,\n} from '../TimeSeriesTooltip';\nimport type { CursorCoordinates } from '../TimeSeriesTooltip/tooltip-model';\n\nexport interface ExemplarMetadataTooltipProps {\n exemplar: Exemplar;\n seriesLabels?: Labels;\n /**\n * CSS selector of the element the tooltip should be portaled into (e.g. `#dashboard`).\n * Passed as-is to `document.querySelector`, so it must be a selector and not a bare element id.\n */\n containerId?: string;\n format?: FormatOptions;\n /**\n * Position where the tooltip has been pinned, or null when it follows the mouse.\n */\n pinnedPos: CursorCoordinates | null;\n enablePinning?: boolean;\n onUnpinClick?: () => void;\n}\n\n/**\n * Tooltip showing an exemplar's metadata (series labels, exemplar labels, value and timestamp).\n * Follows the mouse while hovering an exemplar marker and can be pinned in place, the same way\n * the annotation tooltip works.\n */\nexport function ExemplarMetadataTooltip({\n exemplar,\n seriesLabels,\n containerId,\n format,\n pinnedPos,\n enablePinning = true,\n onUnpinClick,\n}: ExemplarMetadataTooltipProps): ReactElement | null {\n const { formatWithUserTimeZone } = useTimeZone();\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver<HTMLDivElement>();\n\n const isPinned = pinnedPos !== null;\n if (!isPinned && mousePos === null) return null;\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n // Fall back to the pinned position: a pinned tooltip can render before any mousemove happened.\n const transform = assembleTransform(mousePos ?? pinnedPos, pinnedPos, height ?? 0, width ?? 0, containerElement);\n\n const { labels, value, timestamp } = exemplar;\n const formattedValue = formatValue(value, format);\n const date = new Date(timestamp);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n\n // Only sections with content take part in the layout, so no divider is left dangling\n // when a label set is empty.\n const sections: Array<{ key: string; content: ReactElement }> = [];\n if (seriesLabels && Object.keys(seriesLabels).length > 0) {\n sections.push({ key: 'series-labels', content: <LabelGrid title=\"Series labels\" labels={seriesLabels} /> });\n }\n if (Object.keys(labels).length > 0) {\n sections.push({ key: 'exemplar-labels', content: <LabelGrid title=\"Exemplar labels\" labels={labels} /> });\n }\n sections.push({\n key: 'value',\n content: (\n <Box>\n <Typography variant=\"overline\" component=\"div\">\n Value\n </Typography>\n <Typography fontWeight={700}>{formattedValue}</Typography>\n </Box>\n ),\n });\n\n return (\n <Portal container={containerElement}>\n <Box ref={tooltipRef} sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)} style={{ transform }}>\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box sx={{ display: 'flex', alignItems: 'center', paddingBottom: 0.5, width: '100%' }}>\n <Box sx={{ flexGrow: 1, minWidth: 0 }}>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </Box>\n {enablePinning && (\n <Stack direction=\"row\" alignItems=\"center\" sx={{ marginLeft: 1, flexShrink: 0 }}>\n <Typography sx={{ marginRight: 0.5, fontSize: 11, verticalAlign: 'middle' }}>\n {isPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT}\n </Typography>\n {isPinned ? (\n <IconButton\n aria-label={UNPIN_TOOLTIP_HELP_TEXT}\n onClick={() => {\n if (onUnpinClick !== undefined) onUnpinClick();\n }}\n sx={{ padding: 0, color: 'inherit' }}\n >\n <Pin sx={{ fontSize: 16 }} />\n </IconButton>\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n )}\n </Box>\n <Divider sx={(theme) => ({ width: '100%', borderColor: theme.palette.grey['500'] })} />\n </Box>\n <Stack spacing={1} sx={(theme) => ({ padding: theme.spacing(0.5, 2, 1.5, 2) })}>\n {sections.map((section, index) => (\n <Fragment key={section.key}>\n {index > 0 && <Divider sx={(theme) => ({ borderColor: theme.palette.grey['500'] })} />}\n {section.content}\n </Fragment>\n ))}\n </Stack>\n </Stack>\n </Box>\n </Portal>\n );\n}\n\nfunction LabelGrid({ title, labels }: { title: string; labels: Labels }): ReactElement {\n const entries = Object.entries(labels);\n return (\n <Box>\n <Typography variant=\"overline\" component=\"div\">\n {title}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n // The first column is sized by the longest label name, so all values line up\n // at the same horizontal position.\n gridTemplateColumns: 'minmax(0, max-content) minmax(0, 1fr)',\n columnGap: 0.5,\n rowGap: 0.25,\n }}\n >\n {entries.map(([labelName, labelValue]) => (\n <Fragment key={labelName}>\n <Typography sx={{ wordBreak: 'break-all' }}>{labelName}:</Typography>\n <Typography fontWeight={700} sx={{ wordBreak: 'break-all' }}>\n {labelValue}\n </Typography>\n </Fragment>\n ))}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","Divider","IconButton","Portal","Stack","Typography","Pin","PinOutline","Fragment","useResizeObserver","useTimeZone","formatValue","assembleTransform","getTooltipStyles","PIN_TOOLTIP_HELP_TEXT","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","UNPIN_TOOLTIP_HELP_TEXT","useMousePosition"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAEpF,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,gBAAgB,6BAA6B;AAEpD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,WAAW,QAAQ,iCAA8B;AAE1D,SAASC,WAAW,QAAQ,oBAAiB;AAC7C,SACEC,iBAAiB,EACjBC,gBAAgB,EAChBC,qBAAqB,EACrBC,yBAAyB,EACzBC,iBAAiB,EACjBC,uBAAuB,EACvBC,gBAAgB,QACX,gCAAuB;AAoB9B;;;;CAIC,GACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHP"}
@@ -11,114 +11,146 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { c as _c } from "react-compiler-runtime";
14
15
  import { OptionsEditorControl } from "../OptionsEditorLayout/index.js";
15
16
  import { SettingsAutocomplete } from "../SettingsAutocomplete/index.js";
16
17
  const FONT_SIZE_OPTIONS = [
17
18
  {
18
- id: 'default',
19
- label: 'Default',
19
+ id: "default",
20
+ label: "Default",
20
21
  value: undefined
21
22
  },
22
23
  {
23
- id: '12',
24
- label: '12',
24
+ id: "12",
25
+ label: "12",
25
26
  value: 12
26
27
  },
27
28
  {
28
- id: '14',
29
- label: '14',
29
+ id: "14",
30
+ label: "14",
30
31
  value: 14
31
32
  },
32
33
  {
33
- id: '16',
34
- label: '16',
34
+ id: "16",
35
+ label: "16",
35
36
  value: 16
36
37
  },
37
38
  {
38
- id: '20',
39
- label: '20',
39
+ id: "20",
40
+ label: "20",
40
41
  value: 20
41
42
  },
42
43
  {
43
- id: '24',
44
- label: '24',
44
+ id: "24",
45
+ label: "24",
45
46
  value: 24
46
47
  },
47
48
  {
48
- id: '28',
49
- label: '28',
49
+ id: "28",
50
+ label: "28",
50
51
  value: 28
51
52
  },
52
53
  {
53
- id: '32',
54
- label: '32',
54
+ id: "32",
55
+ label: "32",
55
56
  value: 32
56
57
  },
57
58
  {
58
- id: '36',
59
- label: '36',
59
+ id: "36",
60
+ label: "36",
60
61
  value: 36
61
62
  },
62
63
  {
63
- id: '40',
64
- label: '40',
64
+ id: "40",
65
+ label: "40",
65
66
  value: 40
66
67
  },
67
68
  {
68
- id: '48',
69
- label: '48',
69
+ id: "48",
70
+ label: "48",
70
71
  value: 48
71
72
  },
72
73
  {
73
- id: '56',
74
- label: '56',
74
+ id: "56",
75
+ label: "56",
75
76
  value: 56
76
77
  },
77
78
  {
78
- id: '64',
79
- label: '64',
79
+ id: "64",
80
+ label: "64",
80
81
  value: 64
81
82
  },
82
83
  {
83
- id: '72',
84
- label: '72',
84
+ id: "72",
85
+ label: "72",
85
86
  value: 72
86
87
  },
87
88
  {
88
- id: '96',
89
- label: '96',
89
+ id: "96",
90
+ label: "96",
90
91
  value: 96
91
92
  },
92
93
  {
93
- id: '128',
94
- label: '128',
94
+ id: "128",
95
+ label: "128",
95
96
  value: 128
96
97
  },
97
98
  {
98
- id: '160',
99
- label: '160',
99
+ id: "160",
100
+ label: "160",
100
101
  value: 160
101
102
  },
102
103
  {
103
- id: '192',
104
- label: '192',
104
+ id: "192",
105
+ label: "192",
105
106
  value: 192
106
107
  }
107
108
  ];
108
- export function FontSizeSelector({ value, onChange }) {
109
- const handleFontSizeChange = (_, { value })=>{
110
- onChange(value);
111
- };
112
- return /*#__PURE__*/ _jsx(OptionsEditorControl, {
113
- label: "Font Size",
114
- control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
115
- value: FONT_SIZE_OPTIONS.find((o)=>o.value === value),
116
- options: FONT_SIZE_OPTIONS,
117
- getOptionLabel: (o)=>o.label,
118
- onChange: handleFontSizeChange,
119
- disableClearable: true
120
- })
121
- });
109
+ export function FontSizeSelector(t0) {
110
+ const $ = _c(7);
111
+ const { value, onChange } = t0;
112
+ let t1;
113
+ if ($[0] !== onChange) {
114
+ t1 = (_, t2)=>{
115
+ const { value: value_0 } = t2;
116
+ onChange(value_0);
117
+ };
118
+ $[0] = onChange;
119
+ $[1] = t1;
120
+ } else {
121
+ t1 = $[1];
122
+ }
123
+ const handleFontSizeChange = t1;
124
+ let t2;
125
+ if ($[2] !== value) {
126
+ t2 = FONT_SIZE_OPTIONS.find((o)=>o.value === value);
127
+ $[2] = value;
128
+ $[3] = t2;
129
+ } else {
130
+ t2 = $[3];
131
+ }
132
+ let t3;
133
+ if ($[4] !== handleFontSizeChange || $[5] !== t2) {
134
+ t3 = /*#__PURE__*/ _jsx(OptionsEditorControl, {
135
+ label: "Font Size",
136
+ control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
137
+ value: t2,
138
+ options: FONT_SIZE_OPTIONS,
139
+ getOptionLabel: _temp,
140
+ onChange: handleFontSizeChange,
141
+ disableClearable: true
142
+ })
143
+ });
144
+ $[4] = handleFontSizeChange;
145
+ $[5] = t2;
146
+ $[6] = t3;
147
+ } else {
148
+ t3 = $[6];
149
+ }
150
+ return t3;
151
+ }
152
+ function _temp(o_0) {
153
+ return o_0.label;
122
154
  }
123
155
 
124
156
  //# sourceMappingURL=FontSizeSelector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FontSizeSelector/FontSizeSelector.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 type { ReactElement } from 'react';\n\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nconst FONT_SIZE_OPTIONS = [\n { id: 'default', label: 'Default', value: undefined },\n { id: '12', label: '12', value: 12 },\n { id: '14', label: '14', value: 14 },\n { id: '16', label: '16', value: 16 },\n { id: '20', label: '20', value: 20 },\n { id: '24', label: '24', value: 24 },\n { id: '28', label: '28', value: 28 },\n { id: '32', label: '32', value: 32 },\n { id: '36', label: '36', value: 36 },\n { id: '40', label: '40', value: 40 },\n { id: '48', label: '48', value: 48 },\n { id: '56', label: '56', value: 56 },\n { id: '64', label: '64', value: 64 },\n { id: '72', label: '72', value: 72 },\n { id: '96', label: '96', value: 96 },\n { id: '128', label: '128', value: 128 },\n { id: '160', label: '160', value: 160 },\n { id: '192', label: '192', value: 192 },\n];\n\nexport type FontSizeOption = number | undefined;\n\nexport interface FontSizeSelectorProps {\n value: FontSizeOption;\n onChange: (fontSize: FontSizeOption) => void;\n}\n\nexport function FontSizeSelector({ value, onChange }: FontSizeSelectorProps): ReactElement {\n const handleFontSizeChange = (_: unknown, { value }: { value: FontSizeOption }): void => {\n onChange(value);\n };\n\n return (\n <OptionsEditorControl\n label=\"Font Size\"\n control={\n <SettingsAutocomplete\n value={FONT_SIZE_OPTIONS.find((o) => o.value === value)}\n options={FONT_SIZE_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={handleFontSizeChange}\n disableClearable\n />\n }\n />\n );\n}\n"],"names":["OptionsEditorControl","SettingsAutocomplete","FONT_SIZE_OPTIONS","id","label","value","undefined","FontSizeSelector","onChange","handleFontSizeChange","_","control","find","o","options","getOptionLabel","disableClearable"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,6EAA6E;AAC7E,sEAAs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ACV;YACCI,OAAOH,kBAAkBU,IAAI,CAAC,CAACC,IAAMA,EAAER,KAAK,KAAKA;YACjDS,SAASZ;YACTa,gBAAgB,CAACF,IAAMA,EAAET,KAAK;YAC9BI,UAAUC;YACVO,gBAAgB;;;AAK1B"}
1
+ {"version":3,"sources":["../../src/FontSizeSelector/FontSizeSelector.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 type { ReactElement } from 'react';\n\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nconst FONT_SIZE_OPTIONS = [\n { id: 'default', label: 'Default', value: undefined },\n { id: '12', label: '12', value: 12 },\n { id: '14', label: '14', value: 14 },\n { id: '16', label: '16', value: 16 },\n { id: '20', label: '20', value: 20 },\n { id: '24', label: '24', value: 24 },\n { id: '28', label: '28', value: 28 },\n { id: '32', label: '32', value: 32 },\n { id: '36', label: '36', value: 36 },\n { id: '40', label: '40', value: 40 },\n { id: '48', label: '48', value: 48 },\n { id: '56', label: '56', value: 56 },\n { id: '64', label: '64', value: 64 },\n { id: '72', label: '72', value: 72 },\n { id: '96', label: '96', value: 96 },\n { id: '128', label: '128', value: 128 },\n { id: '160', label: '160', value: 160 },\n { id: '192', label: '192', value: 192 },\n];\n\nexport type FontSizeOption = number | undefined;\n\nexport interface FontSizeSelectorProps {\n value: FontSizeOption;\n onChange: (fontSize: FontSizeOption) => void;\n}\n\nexport function FontSizeSelector({ value, onChange }: FontSizeSelectorProps): ReactElement {\n const handleFontSizeChange = (_: unknown, { value }: { value: FontSizeOption }): void => {\n onChange(value);\n };\n\n return (\n <OptionsEditorControl\n label=\"Font Size\"\n control={\n <SettingsAutocomplete\n value={FONT_SIZE_OPTIONS.find((o) => o.value === value)}\n options={FONT_SIZE_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={handleFontSizeChange}\n disableClearable\n />\n }\n />\n );\n}\n"],"names":["OptionsEditorControl","SettingsAutocomplete","FONT_SIZE_OPTIONS","id","label","value","undefined"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,6EAA6E;AAC7E,sEAAsE;AACtE,iCAAiC;;;AAIjC,SAASA,oBAAoB,QAAQ,kCAAyB;AAC9D,SAASC,oBAAoB,QAAQ,mCAA0B;AAE/D,MAAMC,oBAAoB;IACxB;QAAEC,IAAI;QAAWC,OAAO;QAAWC,OAAOC;IAAU;IACpD;QAAEH,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAMC,OAAO;QAAMC,OAAO;IAAG;IACnC;QAAEF,IAAI;QAAOC,OAAO;QAAOC,OAAO;IAAI;IACtC;QAAEF,IAAI;QAAOC,OAAO;QAAOC,OAAO;IAAI;IACtC;QAAEF,IAAI;QAAOC,OAAO;QAAOC,OAAO;IAAI;CACvC;AASD,OAAO"}
@@ -11,21 +11,64 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { c as _c } from "react-compiler-runtime";
14
15
  import { Button, Divider, Stack } from "@mui/material";
15
- export function FormActions({ action, submitText = 'Save', cancelText = 'Cancel', isReadonly, isValid, onActionChange, onSubmit, onDelete, onCancel, ...props }) {
16
- return /*#__PURE__*/ _jsx(Stack, {
17
- direction: "row",
18
- gap: 1,
19
- sx: {
20
- marginLeft: 'auto'
21
- },
22
- ...props,
23
- children: action === 'read' ? /*#__PURE__*/ _jsxs(_Fragment, {
16
+ export function FormActions(t0) {
17
+ const $ = _c(25);
18
+ let action;
19
+ let isReadonly;
20
+ let isValid;
21
+ let onActionChange;
22
+ let onCancel;
23
+ let onDelete;
24
+ let onSubmit;
25
+ let props;
26
+ let t1;
27
+ let t2;
28
+ if ($[0] !== t0) {
29
+ ({ action, submitText: t1, cancelText: t2, isReadonly, isValid, onActionChange, onSubmit, onDelete, onCancel, ...props } = t0);
30
+ $[0] = t0;
31
+ $[1] = action;
32
+ $[2] = isReadonly;
33
+ $[3] = isValid;
34
+ $[4] = onActionChange;
35
+ $[5] = onCancel;
36
+ $[6] = onDelete;
37
+ $[7] = onSubmit;
38
+ $[8] = props;
39
+ $[9] = t1;
40
+ $[10] = t2;
41
+ } else {
42
+ action = $[1];
43
+ isReadonly = $[2];
44
+ isValid = $[3];
45
+ onActionChange = $[4];
46
+ onCancel = $[5];
47
+ onDelete = $[6];
48
+ onSubmit = $[7];
49
+ props = $[8];
50
+ t1 = $[9];
51
+ t2 = $[10];
52
+ }
53
+ const submitText = t1 === undefined ? "Save" : t1;
54
+ const cancelText = t2 === undefined ? "Cancel" : t2;
55
+ let t3;
56
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
57
+ t3 = {
58
+ marginLeft: "auto"
59
+ };
60
+ $[11] = t3;
61
+ } else {
62
+ t3 = $[11];
63
+ }
64
+ let t4;
65
+ if ($[12] !== action || $[13] !== cancelText || $[14] !== isReadonly || $[15] !== isValid || $[16] !== onActionChange || $[17] !== onCancel || $[18] !== onDelete || $[19] !== onSubmit || $[20] !== submitText) {
66
+ t4 = action === "read" ? /*#__PURE__*/ _jsxs(_Fragment, {
24
67
  children: [
25
68
  onActionChange && /*#__PURE__*/ _jsx(Button, {
26
69
  disabled: isReadonly,
27
70
  variant: "contained",
28
- onClick: ()=>onActionChange('update'),
71
+ onClick: ()=>onActionChange("update"),
29
72
  children: "Edit"
30
73
  }),
31
74
  onDelete && /*#__PURE__*/ _jsx(Button, {
@@ -39,8 +82,8 @@ export function FormActions({ action, submitText = 'Save', cancelText = 'Cancel'
39
82
  orientation: "vertical",
40
83
  flexItem: true,
41
84
  sx: {
42
- borderColor: (theme)=>theme.palette.grey['500'],
43
- '&.MuiDivider-root': {
85
+ borderColor: _temp,
86
+ "&.MuiDivider-root": {
44
87
  marginLeft: 2,
45
88
  marginRight: 1
46
89
  }
@@ -68,8 +111,39 @@ export function FormActions({ action, submitText = 'Save', cancelText = 'Cancel'
68
111
  children: cancelText
69
112
  })
70
113
  ]
71
- })
72
- });
114
+ });
115
+ $[12] = action;
116
+ $[13] = cancelText;
117
+ $[14] = isReadonly;
118
+ $[15] = isValid;
119
+ $[16] = onActionChange;
120
+ $[17] = onCancel;
121
+ $[18] = onDelete;
122
+ $[19] = onSubmit;
123
+ $[20] = submitText;
124
+ $[21] = t4;
125
+ } else {
126
+ t4 = $[21];
127
+ }
128
+ let t5;
129
+ if ($[22] !== props || $[23] !== t4) {
130
+ t5 = /*#__PURE__*/ _jsx(Stack, {
131
+ direction: "row",
132
+ gap: 1,
133
+ sx: t3,
134
+ ...props,
135
+ children: t4
136
+ });
137
+ $[22] = props;
138
+ $[23] = t4;
139
+ $[24] = t5;
140
+ } else {
141
+ t5 = $[24];
142
+ }
143
+ return t5;
144
+ }
145
+ function _temp(theme) {
146
+ return theme.palette.grey["500"];
73
147
  }
74
148
 
75
149
  //# sourceMappingURL=FormActions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FormEditor/FormActions.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 type { StackProps } from '@mui/material';\nimport { Button, Divider, Stack } from '@mui/material';\nimport type { Action } from '@perses-dev/client';\nimport type { ReactElement } from 'react';\n\nexport interface FormActionsProps extends StackProps {\n action: Action;\n submitText?: string;\n cancelText?: string;\n isReadonly?: boolean;\n isValid?: boolean;\n onActionChange?: (action: Action) => void;\n onSubmit?: () => void;\n onDelete?: () => void;\n onCancel?: () => void;\n}\n\nexport function FormActions({\n action,\n submitText = 'Save',\n cancelText = 'Cancel',\n isReadonly,\n isValid,\n onActionChange,\n onSubmit,\n onDelete,\n onCancel,\n ...props\n}: FormActionsProps): ReactElement {\n return (\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }} {...props}>\n {action === 'read' ? (\n <>\n {onActionChange && (\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => onActionChange('update')}>\n Edit\n </Button>\n )}\n {onDelete && (\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n )}\n {onCancel && (onSubmit || onDelete) && (\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={{\n borderColor: (theme) => theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n }}\n />\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n ) : (\n <>\n {onSubmit && (\n <Button variant=\"contained\" disabled={!isValid} onClick={onSubmit}>\n {submitText}\n </Button>\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["Button","Divider","Stack","FormActions","action","submitText","cancelText","isReadonly","isValid","onActionChange","onSubmit","onDelete","onCancel","props","direction","gap","sx","marginLeft","disabled","variant","onClick","color","orientation","flexItem","borderColor","theme","palette","grey","marginRight"],"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;;AAGjC,SAASA,MAAM,EAAEC,OAAO,EAAEC,KAAK,QAAQ,gBAAgB;AAgBvD,OAAO,SAASC,YAAY,EAC1BC,MAAM,EACNC,aAAa,MAAM,EACnBC,aAAa,QAAQ,EACrBC,UAAU,EACVC,OAAO,EACPC,cAAc,EACdC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACR,GAAGC,OACc;IACjB,qBACE,KAACX;QAAMY,WAAU;QAAMC,KAAK;QAAGC,IAAI;YAAEC,YAAY;QAAO;QAAI,GAAGJ,KAAK;kBACjET,WAAW,uBACV;;gBACGK,gCACC,KAACT;oBAAOkB,UAAUX;oBAAYY,SAAQ;oBAAYC,SAAS,IAAMX,eAAe;8BAAW;;gBAI5FE,0BACC,KAACX;oBAAOqB,OAAM;oBAAQH,UAAUX;oBAAYY,SAAQ;oBAAWC,SAAST;8BAAU;;gBAInFC,YAAaF,CAAAA,YAAYC,QAAO,mBAC/B,KAACV;oBACCqB,aAAY;oBACZC,QAAQ;oBACRP,IAAI;wBACFQ,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;wBACjD,qBAAqB;4BACnBV,YAAY;4BACZW,aAAa;wBACf;oBACF;;gBAGHhB,0BACC,KAACZ;oBAAOqB,OAAM;oBAAYF,SAAQ;oBAAWC,SAASR;8BACnDN;;;2BAKP;;gBACGI,0BACC,KAACV;oBAAOmB,SAAQ;oBAAYD,UAAU,CAACV;oBAASY,SAASV;8BACtDL;;gBAGJO,0BACC,KAACZ;oBAAOqB,OAAM;oBAAYF,SAAQ;oBAAWC,SAASR;8BACnDN;;;;;AAOf"}
1
+ {"version":3,"sources":["../../src/FormEditor/FormActions.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 type { StackProps } from '@mui/material';\nimport { Button, Divider, Stack } from '@mui/material';\nimport type { Action } from '@perses-dev/client';\nimport type { ReactElement } from 'react';\n\nexport interface FormActionsProps extends StackProps {\n action: Action;\n submitText?: string;\n cancelText?: string;\n isReadonly?: boolean;\n isValid?: boolean;\n onActionChange?: (action: Action) => void;\n onSubmit?: () => void;\n onDelete?: () => void;\n onCancel?: () => void;\n}\n\nexport function FormActions({\n action,\n submitText = 'Save',\n cancelText = 'Cancel',\n isReadonly,\n isValid,\n onActionChange,\n onSubmit,\n onDelete,\n onCancel,\n ...props\n}: FormActionsProps): ReactElement {\n return (\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }} {...props}>\n {action === 'read' ? (\n <>\n {onActionChange && (\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => onActionChange('update')}>\n Edit\n </Button>\n )}\n {onDelete && (\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n )}\n {onCancel && (onSubmit || onDelete) && (\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={{\n borderColor: (theme) => theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n }}\n />\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n ) : (\n <>\n {onSubmit && (\n <Button variant=\"contained\" disabled={!isValid} onClick={onSubmit}>\n {submitText}\n </Button>\n )}\n {onCancel && (\n <Button color=\"secondary\" variant=\"outlined\" onClick={onCancel}>\n {cancelText}\n </Button>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["Button","Divider","Stack"],"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;;;AAGjC,SAASA,MAAM,EAAEC,OAAO,EAAEC,KAAK,QAAQ,gBAAgB;AAgBvD,OAAO"}