@perses-dev/components 0.53.0-rc.0 → 0.53.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/AlignSelector/index.js +1 -1
- package/dist/AlignSelector/index.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ColorPicker/index.js +1 -1
- package/dist/ColorPicker/index.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/index.js +1 -1
- package/dist/ContentWithLegend/index.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/DensitySelector/DensitySelector.js +1 -1
- package/dist/DensitySelector/DensitySelector.js.map +1 -1
- package/dist/DensitySelector/index.js +1 -1
- package/dist/DensitySelector/index.js.map +1 -1
- package/dist/Dialog/Dialog.js +1 -1
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/Dialog/index.js +1 -1
- package/dist/Dialog/index.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/DragAndDrop/index.js +1 -1
- package/dist/DragAndDrop/index.js.map +1 -1
- package/dist/DragAndDrop/model.js +1 -1
- package/dist/DragAndDrop/model.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/Drawer/index.js +1 -1
- package/dist/Drawer/index.js.map +1 -1
- package/dist/EChart/EChart.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/EChart/index.js +1 -1
- package/dist/EChart/index.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/ErrorBoundary.js +1 -1
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.js +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
- package/dist/FontSizeSelector/index.js +1 -1
- package/dist/FontSizeSelector/index.js.map +1 -1
- package/dist/FormEditor/FormActions.js +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormEditor/index.js +1 -1
- package/dist/FormEditor/index.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +10 -23
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.d.ts +9 -0
- package/dist/FormatControls/UnitSelector.d.ts.map +1 -0
- package/dist/FormatControls/UnitSelector.js +47 -0
- package/dist/FormatControls/UnitSelector.js.map +1 -0
- package/dist/FormatControls/index.d.ts +1 -0
- package/dist/FormatControls/index.d.ts.map +1 -1
- package/dist/FormatControls/index.js +2 -1
- package/dist/FormatControls/index.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +1 -1
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/InfoTooltip/index.js +1 -1
- package/dist/InfoTooltip/index.js.map +1 -1
- package/dist/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +1 -1
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.js +1 -1
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/index.js +1 -1
- package/dist/Legend/index.js.map +1 -1
- package/dist/Legend/legend-model.js +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/LinksEditor/index.js +1 -1
- package/dist/LinksEditor/index.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.js +1 -1
- package/dist/ModeSelector/ModeSelector.js.map +1 -1
- package/dist/ModeSelector/index.js +1 -1
- package/dist/ModeSelector/index.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +5 -2
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/OptionsEditorLayout/index.js +1 -1
- package/dist/OptionsEditorLayout/index.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/Overlay/index.js +1 -1
- package/dist/Overlay/index.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/RefreshIntervalPicker/index.js +1 -1
- package/dist/RefreshIntervalPicker/index.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +16 -3
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SettingsAutocomplete/index.js +1 -1
- package/dist/SettingsAutocomplete/index.js.map +1 -1
- package/dist/SortSelector/SortSelector.js +1 -1
- package/dist/SortSelector/SortSelector.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/SortSelector/index.js +1 -1
- package/dist/SortSelector/index.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +31 -7
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.d.ts +4 -2
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +27 -5
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.js +1 -1
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +19 -3
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +1 -1
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/Table/index.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +16 -6
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +4 -3
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/ThresholdsEditor/index.js +1 -1
- package/dist/ThresholdsEditor/index.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +2 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +21 -33
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +6 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +140 -19
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeRangeSelector/index.js +1 -1
- package/dist/TimeRangeSelector/index.js.map +1 -1
- package/dist/TimeRangeSelector/utils.js +1 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +4 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +6 -3
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +1 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +3 -14
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +80 -58
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +1 -1
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/TimeZoneSelector.d.ts +16 -0
- package/dist/TimeZoneSelector.d.ts.map +1 -0
- package/dist/TimeZoneSelector.js +58 -0
- package/dist/TimeZoneSelector.js.map +1 -0
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/ToolbarIconButton/index.js +1 -1
- package/dist/ToolbarIconButton/index.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/TransformsEditor/index.js +1 -1
- package/dist/TransformsEditor/index.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/index.js +1 -1
- package/dist/ValueMappingEditor/index.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/cjs/AlignSelector/AlignSelector.js +1 -1
- package/dist/cjs/AlignSelector/index.js +1 -1
- package/dist/cjs/ColorPicker/ColorPicker.js +1 -1
- package/dist/cjs/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/cjs/ColorPicker/index.js +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/cjs/ContentWithLegend/index.js +1 -1
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +1 -1
- package/dist/cjs/DensitySelector/DensitySelector.js +1 -1
- package/dist/cjs/DensitySelector/index.js +1 -1
- package/dist/cjs/Dialog/Dialog.js +1 -1
- package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/cjs/Dialog/index.js +1 -1
- package/dist/cjs/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/cjs/DragAndDrop/DragButton.js +1 -1
- package/dist/cjs/DragAndDrop/DropIndicator.js +1 -1
- package/dist/cjs/DragAndDrop/index.js +1 -1
- package/dist/cjs/DragAndDrop/model.js +1 -1
- package/dist/cjs/Drawer/Drawer.js +1 -1
- package/dist/cjs/Drawer/index.js +1 -1
- package/dist/cjs/EChart/EChart.js +1 -1
- package/dist/cjs/EChart/index.js +1 -1
- package/dist/cjs/ErrorAlert.js +1 -1
- package/dist/cjs/ErrorBoundary.js +1 -1
- package/dist/cjs/FontSizeSelector/FontSizeSelector.js +1 -1
- package/dist/cjs/FontSizeSelector/index.js +1 -1
- package/dist/cjs/FormEditor/FormActions.js +1 -1
- package/dist/cjs/FormEditor/index.js +1 -1
- package/dist/cjs/FormatControls/FormatControls.js +9 -22
- package/dist/cjs/FormatControls/UnitSelector.js +55 -0
- package/dist/cjs/FormatControls/index.js +2 -1
- package/dist/cjs/InfoTooltip/InfoTooltip.js +1 -1
- package/dist/cjs/InfoTooltip/index.js +1 -1
- package/dist/cjs/JSONEditor.js +1 -1
- package/dist/cjs/Legend/CompactLegend.js +1 -1
- package/dist/cjs/Legend/Legend.js +1 -1
- package/dist/cjs/Legend/LegendColorBadge.js +1 -1
- package/dist/cjs/Legend/ListLegend.js +1 -1
- package/dist/cjs/Legend/ListLegendItem.js +1 -1
- package/dist/cjs/Legend/TableLegend.js +1 -1
- package/dist/cjs/Legend/index.js +1 -1
- package/dist/cjs/Legend/legend-model.js +1 -1
- package/dist/cjs/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/cjs/LinksEditor/LinksEditor.js +1 -1
- package/dist/cjs/LinksEditor/index.js +1 -1
- package/dist/cjs/ModeSelector/ModeSelector.js +1 -1
- package/dist/cjs/ModeSelector/index.js +1 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +5 -2
- package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/cjs/OptionsEditorLayout/index.js +1 -1
- package/dist/cjs/Overlay/Overlay.js +1 -1
- package/dist/cjs/Overlay/index.js +1 -1
- package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/cjs/RefreshIntervalPicker/index.js +1 -1
- package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +16 -3
- package/dist/cjs/SettingsAutocomplete/index.js +1 -1
- package/dist/cjs/SortSelector/SortSelector.js +1 -1
- package/dist/cjs/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/cjs/SortSelector/index.js +1 -1
- package/dist/cjs/Table/InnerTable.js +1 -1
- package/dist/cjs/Table/Table.js +29 -5
- package/dist/cjs/Table/TableBody.js +1 -1
- package/dist/cjs/Table/TableCell.js +25 -3
- package/dist/cjs/Table/TableCheckbox.js +1 -1
- package/dist/cjs/Table/TableFoot.js +1 -1
- package/dist/cjs/Table/TableHead.js +1 -1
- package/dist/cjs/Table/TableHeaderCell.js +1 -1
- package/dist/cjs/Table/TableRow.js +1 -1
- package/dist/cjs/Table/VirtualizedTable.js +19 -3
- package/dist/cjs/Table/VirtualizedTableContainer.js +1 -1
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +1 -1
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +1 -1
- package/dist/cjs/Table/index.js +1 -1
- package/dist/cjs/Table/model/table-model.js +4 -3
- package/dist/cjs/ThresholdsEditor/ThresholdInput.js +1 -1
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/cjs/ThresholdsEditor/index.js +1 -1
- package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +20 -32
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +139 -18
- package/dist/cjs/TimeRangeSelector/index.js +1 -1
- package/dist/cjs/TimeRangeSelector/utils.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +3 -2
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +6 -3
- package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +80 -58
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/utils.js +1 -1
- package/dist/cjs/TimeZoneSelector.js +63 -0
- package/dist/cjs/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/cjs/ToolbarIconButton/index.js +1 -1
- package/dist/cjs/TransformsEditor/TransformEditor.js +1 -1
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +1 -1
- package/dist/cjs/TransformsEditor/TransformsEditor.js +1 -1
- package/dist/cjs/TransformsEditor/index.js +1 -1
- package/dist/cjs/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/cjs/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/cjs/ValueMappingEditor/index.js +1 -1
- package/dist/cjs/YAxisLabel.js +1 -1
- package/dist/cjs/context/ChartsProvider.js +1 -1
- package/dist/cjs/context/ItemActionsProvider.js +111 -0
- package/dist/cjs/context/SelectionProvider.js +128 -0
- package/dist/cjs/context/SnackbarProvider.js +1 -1
- package/dist/cjs/context/TimeZoneProvider.js +1 -1
- package/dist/cjs/context/index.js +3 -1
- package/dist/cjs/controls/TextField.js +1 -1
- package/dist/cjs/controls/index.js +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/model/graph.js +1 -1
- package/dist/cjs/model/index.js +2 -1
- package/dist/cjs/model/theme.js +1 -1
- package/dist/cjs/model/timeOption.js +1 -1
- package/dist/cjs/model/timeZoneOption.js +34 -0
- package/dist/cjs/test/index.js +1 -1
- package/dist/cjs/test/render.js +1 -1
- package/dist/cjs/test/setup-tests.js +1 -1
- package/dist/cjs/test-utils/index.js +1 -1
- package/dist/cjs/test-utils/theme.js +1 -1
- package/dist/cjs/theme/component-overrides/alert.js +1 -1
- package/dist/cjs/theme/component-overrides/paper.js +1 -1
- package/dist/cjs/theme/index.js +1 -1
- package/dist/cjs/theme/palette/background.js +1 -1
- package/dist/cjs/theme/palette/colors/blue.js +1 -1
- package/dist/cjs/theme/palette/colors/common.js +1 -1
- package/dist/cjs/theme/palette/colors/green.js +1 -1
- package/dist/cjs/theme/palette/colors/grey.js +1 -1
- package/dist/cjs/theme/palette/colors/index.js +1 -1
- package/dist/cjs/theme/palette/colors/orange.js +1 -1
- package/dist/cjs/theme/palette/colors/purple.js +1 -1
- package/dist/cjs/theme/palette/colors/red.js +1 -1
- package/dist/cjs/theme/palette/colors/types.js +1 -1
- package/dist/cjs/theme/palette/error.js +1 -1
- package/dist/cjs/theme/palette/grey.js +1 -1
- package/dist/cjs/theme/palette/index.js +1 -1
- package/dist/cjs/theme/palette/palette-options.js +1 -1
- package/dist/cjs/theme/palette/primary.js +1 -1
- package/dist/cjs/theme/palette/secondary.js +1 -1
- package/dist/cjs/theme/palette/success.js +1 -1
- package/dist/cjs/theme/palette/text.js +1 -1
- package/dist/cjs/theme/palette/warning.js +1 -1
- package/dist/cjs/theme/theme.js +1 -1
- package/dist/cjs/theme/types/ThemeExtension.d.js +1 -1
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/axis.js +80 -5
- package/dist/cjs/utils/browser-storage.js +1 -1
- package/dist/cjs/utils/chart-actions.js +1 -1
- package/dist/cjs/utils/combine-sx.js +1 -1
- package/dist/cjs/utils/component-ids.js +1 -1
- package/dist/cjs/utils/data-field-interpolation.js +230 -0
- package/dist/cjs/utils/format.js +1 -1
- package/dist/cjs/utils/index.js +5 -2
- package/dist/cjs/utils/mathjs.js +1 -1
- package/dist/cjs/utils/memo.js +1 -1
- package/dist/cjs/utils/selection-interpolation.js +69 -0
- package/dist/cjs/utils/theme-gen.js +1 -1
- package/dist/cjs/utils/variable-interpolation.js +192 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.d.ts +25 -0
- package/dist/context/ItemActionsProvider.d.ts.map +1 -0
- package/dist/context/ItemActionsProvider.js +95 -0
- package/dist/context/ItemActionsProvider.js.map +1 -0
- package/dist/context/SelectionProvider.d.ts +34 -0
- package/dist/context/SelectionProvider.d.ts.map +1 -0
- package/dist/context/SelectionProvider.js +120 -0
- package/dist/context/SelectionProvider.js.map +1 -0
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +3 -1
- package/dist/context/index.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- package/dist/controls/index.js +1 -1
- package/dist/controls/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/model/graph.js +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +2 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/theme.d.ts +1 -0
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/timeOption.js +1 -1
- package/dist/model/timeOption.js.map +1 -1
- package/dist/model/timeZoneOption.d.ts +10 -0
- package/dist/model/timeZoneOption.d.ts.map +1 -0
- package/dist/model/timeZoneOption.js +29 -0
- package/dist/model/timeZoneOption.js.map +1 -0
- package/dist/test/index.js +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/theme.js +1 -1
- package/dist/test-utils/theme.js.map +1 -1
- package/dist/theme/component-overrides/alert.js +1 -1
- package/dist/theme/component-overrides/alert.js.map +1 -1
- package/dist/theme/component-overrides/paper.js +1 -1
- package/dist/theme/component-overrides/paper.js.map +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/palette/background.js +1 -1
- package/dist/theme/palette/background.js.map +1 -1
- package/dist/theme/palette/colors/blue.js +1 -1
- package/dist/theme/palette/colors/blue.js.map +1 -1
- package/dist/theme/palette/colors/common.js +1 -1
- package/dist/theme/palette/colors/common.js.map +1 -1
- package/dist/theme/palette/colors/green.js +1 -1
- package/dist/theme/palette/colors/green.js.map +1 -1
- package/dist/theme/palette/colors/grey.js +1 -1
- package/dist/theme/palette/colors/grey.js.map +1 -1
- package/dist/theme/palette/colors/index.js +1 -1
- package/dist/theme/palette/colors/index.js.map +1 -1
- package/dist/theme/palette/colors/orange.js +1 -1
- package/dist/theme/palette/colors/orange.js.map +1 -1
- package/dist/theme/palette/colors/purple.js +1 -1
- package/dist/theme/palette/colors/purple.js.map +1 -1
- package/dist/theme/palette/colors/red.js +1 -1
- package/dist/theme/palette/colors/red.js.map +1 -1
- package/dist/theme/palette/colors/types.js +1 -1
- package/dist/theme/palette/colors/types.js.map +1 -1
- package/dist/theme/palette/error.js +1 -1
- package/dist/theme/palette/error.js.map +1 -1
- package/dist/theme/palette/grey.js +1 -1
- package/dist/theme/palette/grey.js.map +1 -1
- package/dist/theme/palette/index.js +1 -1
- package/dist/theme/palette/index.js.map +1 -1
- package/dist/theme/palette/palette-options.js +1 -1
- package/dist/theme/palette/palette-options.js.map +1 -1
- package/dist/theme/palette/primary.js +1 -1
- package/dist/theme/palette/primary.js.map +1 -1
- package/dist/theme/palette/secondary.js +1 -1
- package/dist/theme/palette/secondary.js.map +1 -1
- package/dist/theme/palette/success.js +1 -1
- package/dist/theme/palette/success.js.map +1 -1
- package/dist/theme/palette/text.js +1 -1
- package/dist/theme/palette/text.js.map +1 -1
- package/dist/theme/palette/warning.js +1 -1
- package/dist/theme/palette/warning.js.map +1 -1
- package/dist/theme/theme.js +1 -1
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/types/ThemeExtension.d.js +1 -1
- package/dist/theme/types/ThemeExtension.d.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/utils/axis.d.ts +18 -0
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +79 -3
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/browser-storage.js +1 -1
- package/dist/utils/browser-storage.js.map +1 -1
- package/dist/utils/chart-actions.js +1 -1
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/combine-sx.js +1 -1
- package/dist/utils/combine-sx.js.map +1 -1
- package/dist/utils/component-ids.js +1 -1
- package/dist/utils/component-ids.js.map +1 -1
- package/dist/utils/data-field-interpolation.d.ts +84 -0
- package/dist/utils/data-field-interpolation.d.ts.map +1 -0
- package/dist/utils/data-field-interpolation.js +239 -0
- package/dist/utils/data-field-interpolation.js.map +1 -0
- package/dist/utils/format.js +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mathjs.js +1 -1
- package/dist/utils/mathjs.js.map +1 -1
- package/dist/utils/memo.js +1 -1
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/selection-interpolation.d.ts +32 -0
- package/dist/utils/selection-interpolation.d.ts.map +1 -0
- package/dist/utils/selection-interpolation.js +77 -0
- package/dist/utils/selection-interpolation.js.map +1 -0
- package/dist/utils/theme-gen.js +1 -1
- package/dist/utils/theme-gen.js.map +1 -1
- package/dist/utils/variable-interpolation.d.ts +71 -0
- package/dist/utils/variable-interpolation.d.ts.map +1 -0
- package/dist/utils/variable-interpolation.js +176 -0
- package/dist/utils/variable-interpolation.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { interpolate, InterpolationFormat } from './variable-interpolation';
|
|
14
|
+
// Regex patterns for data field interpolation
|
|
15
|
+
// Matches: ${__data.fields["fieldName"]} or ${__data.fields['fieldName']} or ${__data.fields.fieldName} with optional format ${__data.fields["fieldName"]:format}
|
|
16
|
+
const SINGLE_FIELD_REGEX = /\$\{__data\.fields(?:\[(?:"|')([^"']+)(?:"|')\]|\.([a-zA-Z_][a-zA-Z0-9_]*))(?::([a-z]+))?\}/g;
|
|
17
|
+
// Matches: ${__data[0].fields["fieldName"]} or ${__data[0].fields['fieldName']} for indexed access
|
|
18
|
+
const INDEXED_FIELD_REGEX = /\$\{__data\[(\d+)\]\.fields\[(?:"|')([^"']+)(?:"|')\]\}/g;
|
|
19
|
+
// Matches: ${__data.index}
|
|
20
|
+
const DATA_INDEX_REGEX = /\$\{__data\.index\}/g;
|
|
21
|
+
// Matches: ${__data.count}
|
|
22
|
+
const DATA_COUNT_REGEX = /\$\{__data\.count\}/g;
|
|
23
|
+
// Matches: ${__data} or ${__data:format} or '${__data:format}' or "${__data:format}"
|
|
24
|
+
const FULL_DATA_REGEX = /("|')?\$\{__data(?::([a-z]+))?\}("|')?/g;
|
|
25
|
+
/**
|
|
26
|
+
* Get field value from a data item, converting to string.
|
|
27
|
+
* Supports nested field access using dot notation in field names (e.g., "foo.bar" accesses item.foo.bar).
|
|
28
|
+
* For backward compatibility, first checks if the exact key exists before attempting nested access.
|
|
29
|
+
*/ function getFieldValue(item, fieldName) {
|
|
30
|
+
// First, try direct property access (for backward compatibility with literal dot keys)
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(item, fieldName)) {
|
|
32
|
+
const value = item[fieldName];
|
|
33
|
+
if (value === undefined || value === null) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'object') {
|
|
37
|
+
return JSON.stringify(value);
|
|
38
|
+
}
|
|
39
|
+
return String(value);
|
|
40
|
+
}
|
|
41
|
+
// If not found and contains dots, try nested access
|
|
42
|
+
if (fieldName.includes('.')) {
|
|
43
|
+
const parts = fieldName.split('.');
|
|
44
|
+
let current = item;
|
|
45
|
+
for (const part of parts){
|
|
46
|
+
if (current === null || current === undefined) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
if (typeof current !== 'object') {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
current = current[part];
|
|
53
|
+
}
|
|
54
|
+
if (current === undefined || current === null) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
if (typeof current === 'object') {
|
|
58
|
+
return JSON.stringify(current);
|
|
59
|
+
}
|
|
60
|
+
return String(current);
|
|
61
|
+
}
|
|
62
|
+
// Field not found
|
|
63
|
+
return '';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parse format string to InterpolationFormat enum
|
|
67
|
+
*/ export function parseFormat(format) {
|
|
68
|
+
if (!format) return undefined;
|
|
69
|
+
const lowerFormat = format.toLowerCase();
|
|
70
|
+
return Object.values(InterpolationFormat).find((f)=>f === lowerFormat);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Replace data field placeholders in a template string with values from a single data item.
|
|
74
|
+
*
|
|
75
|
+
* Supports:
|
|
76
|
+
* - ${__data.fields["fieldName"]} - field value from the item (URL encoded by default)
|
|
77
|
+
* - ${__data.fields["fieldName"]:format} - field value with format specifier
|
|
78
|
+
* - ${__data.index} - current index (0-based) if provided in options
|
|
79
|
+
* - ${__data.count} - total count if provided in options
|
|
80
|
+
* - ${__data} - full data array
|
|
81
|
+
* - ${__data:format} - full data array with format specifier
|
|
82
|
+
*
|
|
83
|
+
* @param template - The template string with placeholders
|
|
84
|
+
* @param item - The data item containing field values
|
|
85
|
+
* @param options - Optional configuration for replacement behavior
|
|
86
|
+
* @returns InterpolationResult with the interpolated text and any errors
|
|
87
|
+
*/ export function replaceDataFields(template, item, options = {}) {
|
|
88
|
+
const { urlEncode = true, index, count } = options;
|
|
89
|
+
let result = template;
|
|
90
|
+
const errors = [];
|
|
91
|
+
// Replace ${__data.index} if provided
|
|
92
|
+
if (index !== undefined) {
|
|
93
|
+
result = result.replaceAll(DATA_INDEX_REGEX, String(index));
|
|
94
|
+
}
|
|
95
|
+
// Replace ${__data.count} if provided
|
|
96
|
+
if (count !== undefined) {
|
|
97
|
+
result = result.replaceAll(DATA_COUNT_REGEX, String(count));
|
|
98
|
+
}
|
|
99
|
+
// Replace full data placeholder with optional format: ${__data} or ${__data:format}
|
|
100
|
+
result = result.replaceAll(FULL_DATA_REGEX, (_match, _leadingQuote, format, _trailingQuote)=>{
|
|
101
|
+
const interpolationFormat = parseFormat(format) ?? InterpolationFormat.RAW;
|
|
102
|
+
let interpolationResult = '';
|
|
103
|
+
if (interpolationFormat === InterpolationFormat.JSON) {
|
|
104
|
+
interpolationResult = JSON.stringify(item);
|
|
105
|
+
} else {
|
|
106
|
+
interpolationResult = interpolate(Object.values(item).map((v)=>JSON.stringify(v)), '', interpolationFormat);
|
|
107
|
+
}
|
|
108
|
+
return interpolationResult;
|
|
109
|
+
});
|
|
110
|
+
// Reset regex lastIndex
|
|
111
|
+
SINGLE_FIELD_REGEX.lastIndex = 0;
|
|
112
|
+
// Replace __data.fields["fieldName"] or __data.fields.fieldName patterns
|
|
113
|
+
result = result.replaceAll(SINGLE_FIELD_REGEX, (_match, bracketField, dotField, format)=>{
|
|
114
|
+
const fieldName = bracketField ?? dotField ?? '';
|
|
115
|
+
const value = getFieldValue(item, fieldName);
|
|
116
|
+
if (value === '' && item[fieldName] === undefined) {
|
|
117
|
+
errors.push(`Field "${fieldName}" not found in data`);
|
|
118
|
+
}
|
|
119
|
+
const interpolationFormat = parseFormat(format);
|
|
120
|
+
if (interpolationFormat) {
|
|
121
|
+
return interpolate([
|
|
122
|
+
value
|
|
123
|
+
], fieldName, interpolationFormat);
|
|
124
|
+
}
|
|
125
|
+
if (urlEncode) {
|
|
126
|
+
// override: disable urlEncode for RAW format
|
|
127
|
+
if (interpolationFormat === InterpolationFormat.RAW) {
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
// avoid double encoding for queryparam and percentencode formats
|
|
131
|
+
if (interpolationFormat !== InterpolationFormat.QUERYPARAM && interpolationFormat !== InterpolationFormat.PERCENTENCODE) {
|
|
132
|
+
return encodeURIComponent(value);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
text: result,
|
|
139
|
+
errors: errors.length > 0 ? errors : undefined
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Replace data field placeholders in a template string with values from multiple data items (batch mode).
|
|
144
|
+
*
|
|
145
|
+
* Supports:
|
|
146
|
+
* - ${__data[0].fields["fieldName"]} - field value from specific item by index
|
|
147
|
+
* - ${__data.fields["fieldName"]} - aggregated field values (defaults to CSV format)
|
|
148
|
+
* - ${__data.fields["fieldName"]:csv} - aggregated field values with format specifier
|
|
149
|
+
* - ${__data.count} - total number of items
|
|
150
|
+
* - ${__data} - full data array
|
|
151
|
+
* - ${__data:format} - full data array with format specifier
|
|
152
|
+
*
|
|
153
|
+
* @param template - The template string with placeholders
|
|
154
|
+
* @param items - Array of data items containing field values
|
|
155
|
+
* @param options - Optional configuration for replacement behavior
|
|
156
|
+
* @returns InterpolationResult with the interpolated text and any errors
|
|
157
|
+
*/ export function replaceDataFieldsBatch(template, items, options = {}) {
|
|
158
|
+
const { urlEncode = true } = options;
|
|
159
|
+
let result = template;
|
|
160
|
+
const errors = [];
|
|
161
|
+
// Replace __data.count with items length
|
|
162
|
+
result = result.replaceAll(DATA_COUNT_REGEX, String(items.length));
|
|
163
|
+
// Reset regex lastIndex
|
|
164
|
+
INDEXED_FIELD_REGEX.lastIndex = 0;
|
|
165
|
+
SINGLE_FIELD_REGEX.lastIndex = 0;
|
|
166
|
+
// Replace full data placeholder with optional format
|
|
167
|
+
result = result.replaceAll(FULL_DATA_REGEX, (_match, leadingQuote, format, trailingQuote)=>{
|
|
168
|
+
const interpolationFormat = parseFormat(format) ?? InterpolationFormat.RAW;
|
|
169
|
+
const interpolationResult = interpolate(Object.values(items).map((e)=>JSON.stringify(e)), '', interpolationFormat);
|
|
170
|
+
if (!leadingQuote || !trailingQuote) {
|
|
171
|
+
// preserve quotes as they were not surrounding the full_data pattern
|
|
172
|
+
return `${leadingQuote ?? ''}${interpolationResult}${trailingQuote ?? ''}`;
|
|
173
|
+
}
|
|
174
|
+
return interpolationResult;
|
|
175
|
+
});
|
|
176
|
+
// Replace indexed access: ${__data[0].fields["fieldName"]} or ${__data[0].fields['fieldName']}
|
|
177
|
+
result = result.replaceAll(INDEXED_FIELD_REGEX, (match, indexStr, fieldName)=>{
|
|
178
|
+
const idx = parseInt(indexStr, 10);
|
|
179
|
+
if (idx < 0 || idx >= items.length) {
|
|
180
|
+
errors.push(`Index ${idx} out of bounds (0-${items.length - 1})`);
|
|
181
|
+
return match;
|
|
182
|
+
}
|
|
183
|
+
const value = getFieldValue(items[idx], fieldName);
|
|
184
|
+
if (value === '' && items[idx][fieldName] === undefined) {
|
|
185
|
+
errors.push(`Field "${fieldName}" not found in data at index ${idx}`);
|
|
186
|
+
}
|
|
187
|
+
return urlEncode ? encodeURIComponent(value) : value;
|
|
188
|
+
});
|
|
189
|
+
// Replace aggregated access with format: ${__data.fields["fieldName"]:csv} or ${__data.fields.fieldName:csv}
|
|
190
|
+
result = result.replaceAll(SINGLE_FIELD_REGEX, (_match, bracketField, dotField, format)=>{
|
|
191
|
+
const fieldName = bracketField ?? dotField ?? '';
|
|
192
|
+
const values = items.map((item)=>getFieldValue(item, fieldName));
|
|
193
|
+
const interpolationFormat = parseFormat(format) || InterpolationFormat.CSV;
|
|
194
|
+
return interpolate(values, fieldName, interpolationFormat);
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
text: result,
|
|
198
|
+
errors: errors.length > 0 ? errors : undefined
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Check if a template contains batch-only patterns (indexed access or format specifiers)
|
|
203
|
+
*/ export function hasBatchPatterns(template) {
|
|
204
|
+
// Reset regex lastIndex
|
|
205
|
+
INDEXED_FIELD_REGEX.lastIndex = 0;
|
|
206
|
+
return INDEXED_FIELD_REGEX.test(template) || /\$\{__data\.fields(?:\[["'][^"']+["']\]|\.[a-zA-Z_][a-zA-Z0-9_]*):[a-z]+\}/.test(template);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Check if a template contains indexed access patterns
|
|
210
|
+
*/ export function hasIndexedPatterns(template) {
|
|
211
|
+
INDEXED_FIELD_REGEX.lastIndex = 0;
|
|
212
|
+
return INDEXED_FIELD_REGEX.test(template);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Check if a template contains data field patterns
|
|
216
|
+
*/ export function hasDataFieldPatterns(template) {
|
|
217
|
+
SINGLE_FIELD_REGEX.lastIndex = 0;
|
|
218
|
+
INDEXED_FIELD_REGEX.lastIndex = 0;
|
|
219
|
+
return SINGLE_FIELD_REGEX.test(template) || INDEXED_FIELD_REGEX.test(template);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Extract all field names referenced in a template
|
|
223
|
+
*/ export function extractFieldNames(template) {
|
|
224
|
+
const fields = new Set();
|
|
225
|
+
// Reset regex lastIndex
|
|
226
|
+
SINGLE_FIELD_REGEX.lastIndex = 0;
|
|
227
|
+
INDEXED_FIELD_REGEX.lastIndex = 0;
|
|
228
|
+
let match;
|
|
229
|
+
while((match = SINGLE_FIELD_REGEX.exec(template)) !== null){
|
|
230
|
+
// Group 1 is bracket notation, group 2 is dot notation
|
|
231
|
+
fields.add(match[1] ?? match[2]);
|
|
232
|
+
}
|
|
233
|
+
while((match = INDEXED_FIELD_REGEX.exec(template)) !== null){
|
|
234
|
+
fields.add(match[2]);
|
|
235
|
+
}
|
|
236
|
+
return Array.from(fields);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
//# sourceMappingURL=data-field-interpolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/data-field-interpolation.ts"],"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 { interpolate, InterpolationFormat } from './variable-interpolation';\n\n/**\n * Data item with its fields (used for selection/row data)\n */\nexport type DataItem = Record<string, unknown>;\n\n/**\n * Result of interpolation with data fields\n */\nexport interface InterpolationResult {\n text: string;\n errors?: string[];\n}\n\n/**\n * Options for data field replacement\n */\nexport interface ReplaceDataFieldsOptions {\n /**\n * Whether to URL encode values. Defaults to true.\n */\n urlEncode?: boolean;\n /**\n * Current index (0-based) for ${__data.index} replacement.\n */\n index?: number;\n /**\n * Total count for ${__data.count} replacement.\n */\n count?: number;\n}\n\n// Regex patterns for data field interpolation\n// Matches: ${__data.fields[\"fieldName\"]} or ${__data.fields['fieldName']} or ${__data.fields.fieldName} with optional format ${__data.fields[\"fieldName\"]:format}\nconst SINGLE_FIELD_REGEX =\n /\\$\\{__data\\.fields(?:\\[(?:\"|')([^\"']+)(?:\"|')\\]|\\.([a-zA-Z_][a-zA-Z0-9_]*))(?::([a-z]+))?\\}/g;\n\n// Matches: ${__data[0].fields[\"fieldName\"]} or ${__data[0].fields['fieldName']} for indexed access\nconst INDEXED_FIELD_REGEX = /\\$\\{__data\\[(\\d+)\\]\\.fields\\[(?:\"|')([^\"']+)(?:\"|')\\]\\}/g;\n\n// Matches: ${__data.index}\nconst DATA_INDEX_REGEX = /\\$\\{__data\\.index\\}/g;\n\n// Matches: ${__data.count}\nconst DATA_COUNT_REGEX = /\\$\\{__data\\.count\\}/g;\n\n// Matches: ${__data} or ${__data:format} or '${__data:format}' or \"${__data:format}\"\nconst FULL_DATA_REGEX = /(\"|')?\\$\\{__data(?::([a-z]+))?\\}(\"|')?/g;\n\n/**\n * Get field value from a data item, converting to string.\n * Supports nested field access using dot notation in field names (e.g., \"foo.bar\" accesses item.foo.bar).\n * For backward compatibility, first checks if the exact key exists before attempting nested access.\n */\nfunction getFieldValue(item: DataItem, fieldName: string): string {\n // First, try direct property access (for backward compatibility with literal dot keys)\n if (Object.prototype.hasOwnProperty.call(item, fieldName)) {\n const value = item[fieldName];\n if (value === undefined || value === null) {\n return '';\n }\n if (typeof value === 'object') {\n return JSON.stringify(value);\n }\n return String(value);\n }\n\n // If not found and contains dots, try nested access\n if (fieldName.includes('.')) {\n const parts = fieldName.split('.');\n let current: unknown = item;\n\n for (const part of parts) {\n if (current === null || current === undefined) {\n return '';\n }\n if (typeof current !== 'object') {\n return '';\n }\n current = (current as Record<string, unknown>)[part];\n }\n\n if (current === undefined || current === null) {\n return '';\n }\n if (typeof current === 'object') {\n return JSON.stringify(current);\n }\n return String(current);\n }\n\n // Field not found\n return '';\n}\n\n/**\n * Parse format string to InterpolationFormat enum\n */\nexport function parseFormat(format: string | undefined): InterpolationFormat | undefined {\n if (!format) return undefined;\n const lowerFormat = format.toLowerCase();\n return Object.values(InterpolationFormat).find((f) => f === lowerFormat);\n}\n\n/**\n * Replace data field placeholders in a template string with values from a single data item.\n *\n * Supports:\n * - ${__data.fields[\"fieldName\"]} - field value from the item (URL encoded by default)\n * - ${__data.fields[\"fieldName\"]:format} - field value with format specifier\n * - ${__data.index} - current index (0-based) if provided in options\n * - ${__data.count} - total count if provided in options\n * - ${__data} - full data array\n * - ${__data:format} - full data array with format specifier\n *\n * @param template - The template string with placeholders\n * @param item - The data item containing field values\n * @param options - Optional configuration for replacement behavior\n * @returns InterpolationResult with the interpolated text and any errors\n */\nexport function replaceDataFields(\n template: string,\n item: DataItem,\n options: ReplaceDataFieldsOptions = {}\n): InterpolationResult {\n const { urlEncode = true, index, count } = options;\n let result = template;\n const errors: string[] = [];\n\n // Replace ${__data.index} if provided\n if (index !== undefined) {\n result = result.replaceAll(DATA_INDEX_REGEX, String(index));\n }\n\n // Replace ${__data.count} if provided\n if (count !== undefined) {\n result = result.replaceAll(DATA_COUNT_REGEX, String(count));\n }\n\n // Replace full data placeholder with optional format: ${__data} or ${__data:format}\n result = result.replaceAll(\n FULL_DATA_REGEX,\n (_match, _leadingQuote: string | undefined, format: string | undefined, _trailingQuote: string | undefined) => {\n const interpolationFormat = parseFormat(format) ?? InterpolationFormat.RAW;\n let interpolationResult: string = '';\n\n if (interpolationFormat === InterpolationFormat.JSON) {\n interpolationResult = JSON.stringify(item);\n } else {\n interpolationResult = interpolate(\n Object.values(item).map((v) => JSON.stringify(v)),\n '',\n interpolationFormat\n );\n }\n\n return interpolationResult;\n }\n );\n\n // Reset regex lastIndex\n SINGLE_FIELD_REGEX.lastIndex = 0;\n\n // Replace __data.fields[\"fieldName\"] or __data.fields.fieldName patterns\n result = result.replaceAll(\n SINGLE_FIELD_REGEX,\n (_match, bracketField: string | undefined, dotField: string | undefined, format: string | undefined) => {\n const fieldName = bracketField ?? dotField ?? '';\n const value = getFieldValue(item, fieldName);\n if (value === '' && item[fieldName] === undefined) {\n errors.push(`Field \"${fieldName}\" not found in data`);\n }\n const interpolationFormat = parseFormat(format);\n if (interpolationFormat) {\n return interpolate([value], fieldName, interpolationFormat);\n }\n\n if (urlEncode) {\n // override: disable urlEncode for RAW format\n if (interpolationFormat === InterpolationFormat.RAW) {\n return value;\n }\n\n // avoid double encoding for queryparam and percentencode formats\n if (\n interpolationFormat !== InterpolationFormat.QUERYPARAM &&\n interpolationFormat !== InterpolationFormat.PERCENTENCODE\n ) {\n return encodeURIComponent(value);\n }\n }\n\n return value;\n }\n );\n\n return { text: result, errors: errors.length > 0 ? errors : undefined };\n}\n\n/**\n * Replace data field placeholders in a template string with values from multiple data items (batch mode).\n *\n * Supports:\n * - ${__data[0].fields[\"fieldName\"]} - field value from specific item by index\n * - ${__data.fields[\"fieldName\"]} - aggregated field values (defaults to CSV format)\n * - ${__data.fields[\"fieldName\"]:csv} - aggregated field values with format specifier\n * - ${__data.count} - total number of items\n * - ${__data} - full data array\n * - ${__data:format} - full data array with format specifier\n *\n * @param template - The template string with placeholders\n * @param items - Array of data items containing field values\n * @param options - Optional configuration for replacement behavior\n * @returns InterpolationResult with the interpolated text and any errors\n */\nexport function replaceDataFieldsBatch(\n template: string,\n items: DataItem[],\n options: ReplaceDataFieldsOptions = {}\n): InterpolationResult {\n const { urlEncode = true } = options;\n let result = template;\n const errors: string[] = [];\n\n // Replace __data.count with items length\n result = result.replaceAll(DATA_COUNT_REGEX, String(items.length));\n\n // Reset regex lastIndex\n INDEXED_FIELD_REGEX.lastIndex = 0;\n SINGLE_FIELD_REGEX.lastIndex = 0;\n\n // Replace full data placeholder with optional format\n result = result.replaceAll(\n FULL_DATA_REGEX,\n (_match, leadingQuote: string | undefined, format: string | undefined, trailingQuote: string | undefined) => {\n const interpolationFormat = parseFormat(format) ?? InterpolationFormat.RAW;\n\n const interpolationResult = interpolate(\n Object.values(items).map((e) => JSON.stringify(e)),\n '',\n interpolationFormat\n );\n\n if (!leadingQuote || !trailingQuote) {\n // preserve quotes as they were not surrounding the full_data pattern\n return `${leadingQuote ?? ''}${interpolationResult}${trailingQuote ?? ''}`;\n }\n\n return interpolationResult;\n }\n );\n\n // Replace indexed access: ${__data[0].fields[\"fieldName\"]} or ${__data[0].fields['fieldName']}\n result = result.replaceAll(INDEXED_FIELD_REGEX, (match, indexStr: string, fieldName: string) => {\n const idx = parseInt(indexStr, 10);\n if (idx < 0 || idx >= items.length) {\n errors.push(`Index ${idx} out of bounds (0-${items.length - 1})`);\n return match;\n }\n const value = getFieldValue(items[idx]!, fieldName);\n if (value === '' && items[idx]![fieldName] === undefined) {\n errors.push(`Field \"${fieldName}\" not found in data at index ${idx}`);\n }\n return urlEncode ? encodeURIComponent(value) : value;\n });\n\n // Replace aggregated access with format: ${__data.fields[\"fieldName\"]:csv} or ${__data.fields.fieldName:csv}\n result = result.replaceAll(\n SINGLE_FIELD_REGEX,\n (_match, bracketField: string | undefined, dotField: string | undefined, format: string | undefined) => {\n const fieldName = bracketField ?? dotField ?? '';\n const values = items.map((item) => getFieldValue(item, fieldName));\n const interpolationFormat = parseFormat(format) || InterpolationFormat.CSV;\n return interpolate(values, fieldName, interpolationFormat);\n }\n );\n\n return { text: result, errors: errors.length > 0 ? errors : undefined };\n}\n\n/**\n * Check if a template contains batch-only patterns (indexed access or format specifiers)\n */\nexport function hasBatchPatterns(template: string): boolean {\n // Reset regex lastIndex\n INDEXED_FIELD_REGEX.lastIndex = 0;\n return (\n INDEXED_FIELD_REGEX.test(template) ||\n /\\$\\{__data\\.fields(?:\\[[\"'][^\"']+[\"']\\]|\\.[a-zA-Z_][a-zA-Z0-9_]*):[a-z]+\\}/.test(template)\n );\n}\n\n/**\n * Check if a template contains indexed access patterns\n */\nexport function hasIndexedPatterns(template: string): boolean {\n INDEXED_FIELD_REGEX.lastIndex = 0;\n return INDEXED_FIELD_REGEX.test(template);\n}\n\n/**\n * Check if a template contains data field patterns\n */\nexport function hasDataFieldPatterns(template: string): boolean {\n SINGLE_FIELD_REGEX.lastIndex = 0;\n INDEXED_FIELD_REGEX.lastIndex = 0;\n return SINGLE_FIELD_REGEX.test(template) || INDEXED_FIELD_REGEX.test(template);\n}\n\n/**\n * Extract all field names referenced in a template\n */\nexport function extractFieldNames(template: string): string[] {\n const fields = new Set<string>();\n\n // Reset regex lastIndex\n SINGLE_FIELD_REGEX.lastIndex = 0;\n INDEXED_FIELD_REGEX.lastIndex = 0;\n\n let match;\n while ((match = SINGLE_FIELD_REGEX.exec(template)) !== null) {\n // Group 1 is bracket notation, group 2 is dot notation\n fields.add(match[1] ?? match[2]!);\n }\n while ((match = INDEXED_FIELD_REGEX.exec(template)) !== null) {\n fields.add(match[2]!);\n }\n\n return Array.from(fields);\n}\n"],"names":["interpolate","InterpolationFormat","SINGLE_FIELD_REGEX","INDEXED_FIELD_REGEX","DATA_INDEX_REGEX","DATA_COUNT_REGEX","FULL_DATA_REGEX","getFieldValue","item","fieldName","Object","prototype","hasOwnProperty","call","value","undefined","JSON","stringify","String","includes","parts","split","current","part","parseFormat","format","lowerFormat","toLowerCase","values","find","f","replaceDataFields","template","options","urlEncode","index","count","result","errors","replaceAll","_match","_leadingQuote","_trailingQuote","interpolationFormat","RAW","interpolationResult","map","v","lastIndex","bracketField","dotField","push","QUERYPARAM","PERCENTENCODE","encodeURIComponent","text","length","replaceDataFieldsBatch","items","leadingQuote","trailingQuote","e","match","indexStr","idx","parseInt","CSV","hasBatchPatterns","test","hasIndexedPatterns","hasDataFieldPatterns","extractFieldNames","fields","Set","exec","add","Array","from"],"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;AAE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,SAASsC,qBAAqBtC,QAAgB;IACnD9B,mBAAmB8C,SAAS,GAAG;IAC/B7C,oBAAoB6C,SAAS,GAAG;IAChC,OAAO9C,mBAAmBkE,IAAI,CAACpC,aAAa7B,oBAAoBiE,IAAI,CAACpC;AACvE;AAEA;;CAEC,GACD,OAAO,SAASuC,kBAAkBvC,QAAgB;IAChD,MAAMwC,SAAS,IAAIC;IAEnB,wBAAwB;IACxBvE,mBAAmB8C,SAAS,GAAG;IAC/B7C,oBAAoB6C,SAAS,GAAG;IAEhC,IAAIc;IACJ,MAAO,AAACA,CAAAA,QAAQ5D,mBAAmBwE,IAAI,CAAC1C,SAAQ,MAAO,KAAM;QAC3D,uDAAuD;QACvDwC,OAAOG,GAAG,CAACb,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE;IACjC;IACA,MAAO,AAACA,CAAAA,QAAQ3D,oBAAoBuE,IAAI,CAAC1C,SAAQ,MAAO,KAAM;QAC5DwC,OAAOG,GAAG,CAACb,KAAK,CAAC,EAAE;IACrB;IAEA,OAAOc,MAAMC,IAAI,CAACL;AACpB"}
|
package/dist/utils/format.js
CHANGED
package/dist/utils/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/format.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/utils/format.ts"],"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 { formatInTimeZone } from 'date-fns-tz';\nimport { format } from 'date-fns';\n\nexport function dateFormatOptionsWithTimeZone(\n dateFormatOptions: Intl.DateTimeFormatOptions,\n timeZone?: string\n): Intl.DateTimeFormatOptions {\n /*\n * if timeZone is provided, and is not local|browser,\n * then set timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, default to browser timeZone setting\n */\n if (timeZone) {\n const lowerTimeZone = timeZone.toLowerCase();\n if (lowerTimeZone !== 'local' && lowerTimeZone !== 'browser') {\n return {\n ...dateFormatOptions,\n timeZone: lowerTimeZone === 'utc' ? 'UTC' : timeZone,\n };\n }\n }\n return dateFormatOptions;\n}\n\nexport function formatWithTimeZone(date: Date, formatString: string, timeZone?: string): string {\n /*\n * if timeZone is provided, and is not local|browser,\n * then format using timeZone option (recognize UTC regardless of uppercase/lowercase)\n * otherwise, format without timeZone option, defaulting to browser timeZone setting\n */\n const lowerTimeZone = timeZone?.toLowerCase();\n if (!timeZone || lowerTimeZone === 'local' || lowerTimeZone === 'browser') {\n return format(date, formatString);\n } else {\n return formatInTimeZone(date, lowerTimeZone === 'utc' ? 'UTC' : timeZone, formatString);\n }\n}\n\n// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter\nexport function getFormattedAxisLabel(rangeMs: number):\n | string\n | {\n month: '{MMM}';\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}';\n day: '{MM}/{dd}';\n } {\n const dayMs = 86400000;\n const monthMs = 2629440000;\n const yearMs = 31536000000;\n\n // more than 5 years\n if (rangeMs > yearMs * 5) {\n return '{yyyy}';\n }\n\n // more than 2 years\n if (rangeMs > yearMs * 2) {\n return '{MMM} {yyyy}';\n }\n\n // between 5 days to 6 months\n if (rangeMs > dayMs * 5 && rangeMs < monthMs * 6) {\n return '{MM}/{dd}'; // 12/01\n }\n\n // between 2 and 5 days\n if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 5) {\n return '{MM}/{dd} {HH}:{mm}'; // 12/01 12:30\n }\n\n return {\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}',\n month: '{MMM}', // Jan, Feb, ...\n day: '{MM}/{dd}',\n };\n}\n\ninterface FormattedDateTime {\n formattedDate: string;\n formattedTime: string;\n}\n\nexport const getDateAndTime = (timeMs?: number): FormattedDateTime => {\n if (!timeMs) {\n return { formattedDate: '', formattedTime: '' };\n }\n const date = new Date(timeMs);\n const formattedDate = format(date, 'MMM dd, yyyy - ');\n const formattedTime = format(date, 'HH:mm:ss');\n return {\n formattedDate,\n formattedTime,\n };\n};\n"],"names":["formatInTimeZone","format","dateFormatOptionsWithTimeZone","dateFormatOptions","timeZone","lowerTimeZone","toLowerCase","formatWithTimeZone","date","formatString","getFormattedAxisLabel","rangeMs","dayMs","monthMs","yearMs","year","month","day","getDateAndTime","timeMs","formattedDate","formattedTime","Date"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,gBAAgB,QAAQ,cAAc;AAC/C,SAASC,MAAM,QAAQ,WAAW;AAElC,OAAO,SAASC,8BACdC,iBAA6C,EAC7CC,QAAiB;IAEjB;;;;GAIC,GACD,IAAIA,UAAU;QACZ,MAAMC,gBAAgBD,SAASE,WAAW;QAC1C,IAAID,kBAAkB,WAAWA,kBAAkB,WAAW;YAC5D,OAAO;gBACL,GAAGF,iBAAiB;gBACpBC,UAAUC,kBAAkB,QAAQ,QAAQD;YAC9C;QACF;IACF;IACA,OAAOD;AACT;AAEA,OAAO,SAASI,mBAAmBC,IAAU,EAAEC,YAAoB,EAAEL,QAAiB;IACpF;;;;GAIC,GACD,MAAMC,gBAAgBD,UAAUE;IAChC,IAAI,CAACF,YAAYC,kBAAkB,WAAWA,kBAAkB,WAAW;QACzE,OAAOJ,OAAOO,MAAMC;IACtB,OAAO;QACL,OAAOT,iBAAiBQ,MAAMH,kBAAkB,QAAQ,QAAQD,UAAUK;IAC5E;AACF;AAEA,sEAAsE;AACtE,OAAO,SAASC,sBAAsBC,OAAe;IAOnD,MAAMC,QAAQ;IACd,MAAMC,UAAU;IAChB,MAAMC,SAAS;IAEf,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,oBAAoB;IACpB,IAAIH,UAAUG,SAAS,GAAG;QACxB,OAAO;IACT;IAEA,6BAA6B;IAC7B,IAAIH,UAAUC,QAAQ,KAAKD,UAAUE,UAAU,GAAG;QAChD,OAAO,aAAa,QAAQ;IAC9B;IAEA,uBAAuB;IACvB,IAAIF,UAAUC,QAAQ,KAAKD,WAAWC,QAAQ,GAAG;QAC/C,OAAO,uBAAuB,cAAc;IAC9C;IAEA,OAAO;QACLG,MAAM;QACNC,OAAO;QACPC,KAAK;IACP;AACF;AAOA,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,IAAI,CAACA,QAAQ;QACX,OAAO;YAAEC,eAAe;YAAIC,eAAe;QAAG;IAChD;IACA,MAAMb,OAAO,IAAIc,KAAKH;IACtB,MAAMC,gBAAgBnB,OAAOO,MAAM;IACnC,MAAMa,gBAAgBpB,OAAOO,MAAM;IACnC,OAAO;QACLY;QACAC;IACF;AACF,EAAE"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ export * from './browser-storage';
|
|
|
3
3
|
export * from './chart-actions';
|
|
4
4
|
export * from './combine-sx';
|
|
5
5
|
export * from './component-ids';
|
|
6
|
+
export * from './data-field-interpolation';
|
|
6
7
|
export * from './format';
|
|
7
|
-
export * from './theme-gen';
|
|
8
8
|
export * from './memo';
|
|
9
|
+
export * from './selection-interpolation';
|
|
10
|
+
export * from './theme-gen';
|
|
11
|
+
export * from './variable-interpolation';
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -15,8 +15,11 @@ export * from './browser-storage';
|
|
|
15
15
|
export * from './chart-actions';
|
|
16
16
|
export * from './combine-sx';
|
|
17
17
|
export * from './component-ids';
|
|
18
|
+
export * from './data-field-interpolation';
|
|
18
19
|
export * from './format';
|
|
19
|
-
export * from './theme-gen';
|
|
20
20
|
export * from './memo';
|
|
21
|
+
export * from './selection-interpolation';
|
|
22
|
+
export * from './theme-gen';
|
|
23
|
+
export * from './variable-interpolation';
|
|
21
24
|
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"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\nexport * from './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './data-field-interpolation';\nexport * from './format';\nexport * from './memo';\nexport * from './selection-interpolation';\nexport * from './theme-gen';\nexport * from './variable-interpolation';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,4BAA4B;AAC1C,cAAc,cAAc;AAC5B,cAAc,2BAA2B"}
|
package/dist/utils/mathjs.js
CHANGED
package/dist/utils/mathjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/mathjs.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/utils/mathjs.ts"],"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 { roundDependencies, create } from 'mathjs';\n\n// This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)\nconst { round } = create({ roundDependencies });\nexport { round };\n"],"names":["roundDependencies","create","round"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,iBAAiB,EAAEC,MAAM,QAAQ,SAAS;AAEnD,uHAAuH;AACvH,MAAM,EAAEC,KAAK,EAAE,GAAGD,OAAO;IAAED;AAAkB;AAC7C,SAASE,KAAK,GAAG"}
|
package/dist/utils/memo.js
CHANGED
package/dist/utils/memo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/memo.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../src/utils/memo.ts"],"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 { useRef, DependencyList } from 'react';\nimport isEqual from 'lodash/isEqual';\n\ntype MemoRef<T> = {\n value: T;\n deps: DependencyList;\n};\n\n/**\n * Like React's useMemo, but guarantees the value will only be recalulated if\n * a dependency changes. Uses strict equality (===) for comparison. (React's\n * useMemo does not offer this guarantee, it's only a performance optimization).\n */\nexport function useMemoized<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n\n let areEqual = true;\n for (let i = 0; i < deps.length; i++) {\n if (ref.current?.deps[i] !== deps[i]) {\n areEqual = false;\n break;\n }\n }\n\n if (ref.current === undefined || areEqual === false) {\n ref.current = { value: factory(), deps: deps };\n }\n\n return ref.current.value;\n}\n\n/**\n * Like React's useMemo, except it does a deep equality comparison with lodash's\n * isEqual on the dependency list.\n */\nexport function useDeepMemo<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {\n ref.current = { value: factory(), deps };\n }\n return ref.current.value;\n}\n"],"names":["useRef","isEqual","useMemoized","factory","deps","ref","areEqual","i","length","current","undefined","value","useDeepMemo"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,QAAwB,QAAQ;AAC/C,OAAOC,aAAa,iBAAiB;AAOrC;;;;CAIC,GACD,OAAO,SAASC,YAAeC,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IAEZ,IAAIM,WAAW;IACf,IAAK,IAAIC,IAAI,GAAGA,IAAIH,KAAKI,MAAM,EAAED,IAAK;QACpC,IAAIF,IAAII,OAAO,EAAEL,IAAI,CAACG,EAAE,KAAKH,IAAI,CAACG,EAAE,EAAE;YACpCD,WAAW;YACX;QACF;IACF;IAEA,IAAID,IAAII,OAAO,KAAKC,aAAaJ,aAAa,OAAO;QACnDD,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC,MAAMA;QAAK;IAC/C;IAEA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B;AAEA;;;CAGC,GACD,OAAO,SAASC,YAAeT,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IACZ,IAAIK,IAAII,OAAO,KAAKC,aAAaT,QAAQG,MAAMC,IAAII,OAAO,CAACL,IAAI,MAAM,OAAO;QAC1EC,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC;QAAK;IACzC;IACA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DataItem, InterpolationResult } from './data-field-interpolation';
|
|
2
|
+
import { VariableStateMap } from './variable-interpolation';
|
|
3
|
+
export type SelectionItem = DataItem;
|
|
4
|
+
/**
|
|
5
|
+
* Interpolate selection data into a template string for individual mode.
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - ${__data.fields["fieldName"]} - field value from the item
|
|
9
|
+
* - ${__data.index} - current selection index (0-based)
|
|
10
|
+
* - ${__data.count} - total number of selections
|
|
11
|
+
*
|
|
12
|
+
* @param template - The template string with placeholders
|
|
13
|
+
* @param item - The current selection item data
|
|
14
|
+
* @param index - The current selection index (0-based)
|
|
15
|
+
* @param count - Total number of selections
|
|
16
|
+
* @param variableState - Optional dashboard variable state for additional interpolation
|
|
17
|
+
*/
|
|
18
|
+
export declare function interpolateSelectionIndividual(template: string, item: SelectionItem, index: number, count: number, variableState?: VariableStateMap): InterpolationResult;
|
|
19
|
+
/**
|
|
20
|
+
* Interpolate selection data into a template string for batch mode.
|
|
21
|
+
*
|
|
22
|
+
* Supports:
|
|
23
|
+
* - ${__data[0].fields["fieldName"]} - field value from specific item by index
|
|
24
|
+
* - ${__data.fields["fieldName"]:csv} - aggregated field values with format specifier
|
|
25
|
+
* - ${__data.count} - total number of selections
|
|
26
|
+
*
|
|
27
|
+
* @param template - The template string with placeholders
|
|
28
|
+
* @param items - Array of all selection items
|
|
29
|
+
* @param variableState - Optional dashboard variable state for additional interpolation
|
|
30
|
+
*/
|
|
31
|
+
export declare function interpolateSelectionBatch(template: string, items: SelectionItem[], variableState?: VariableStateMap): InterpolationResult;
|
|
32
|
+
//# sourceMappingURL=selection-interpolation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-interpolation.d.ts","sourceRoot":"","sources":["../../src/utils/selection-interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAA6C,MAAM,4BAA4B,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAoB,MAAM,0BAA0B,CAAC;AAE9E,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;AAErC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,gBAAgB,GAC/B,mBAAmB,CAerB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,aAAa,EAAE,EACtB,aAAa,CAAC,EAAE,gBAAgB,GAC/B,mBAAmB,CAerB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { replaceDataFields, replaceDataFieldsBatch } from './data-field-interpolation';
|
|
14
|
+
import { replaceVariables } from './variable-interpolation';
|
|
15
|
+
/**
|
|
16
|
+
* Interpolate selection data into a template string for individual mode.
|
|
17
|
+
*
|
|
18
|
+
* Supports:
|
|
19
|
+
* - ${__data.fields["fieldName"]} - field value from the item
|
|
20
|
+
* - ${__data.index} - current selection index (0-based)
|
|
21
|
+
* - ${__data.count} - total number of selections
|
|
22
|
+
*
|
|
23
|
+
* @param template - The template string with placeholders
|
|
24
|
+
* @param item - The current selection item data
|
|
25
|
+
* @param index - The current selection index (0-based)
|
|
26
|
+
* @param count - Total number of selections
|
|
27
|
+
* @param variableState - Optional dashboard variable state for additional interpolation
|
|
28
|
+
*/ export function interpolateSelectionIndividual(template, item, index, count, variableState) {
|
|
29
|
+
// Replace __data patterns using shared utility (includes __data.index and __data.count)
|
|
30
|
+
const dataFieldResult = replaceDataFields(template, item, {
|
|
31
|
+
index,
|
|
32
|
+
count
|
|
33
|
+
});
|
|
34
|
+
let result = dataFieldResult.text;
|
|
35
|
+
const errors = [];
|
|
36
|
+
if (dataFieldResult.errors) {
|
|
37
|
+
errors.push(...dataFieldResult.errors.map((e)=>e.replace('in data', 'in selection data')));
|
|
38
|
+
}
|
|
39
|
+
// Apply dashboard variable interpolation if provided
|
|
40
|
+
if (variableState) {
|
|
41
|
+
result = replaceVariables(result, variableState);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
text: result,
|
|
45
|
+
errors: errors.length > 0 ? errors : undefined
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Interpolate selection data into a template string for batch mode.
|
|
50
|
+
*
|
|
51
|
+
* Supports:
|
|
52
|
+
* - ${__data[0].fields["fieldName"]} - field value from specific item by index
|
|
53
|
+
* - ${__data.fields["fieldName"]:csv} - aggregated field values with format specifier
|
|
54
|
+
* - ${__data.count} - total number of selections
|
|
55
|
+
*
|
|
56
|
+
* @param template - The template string with placeholders
|
|
57
|
+
* @param items - Array of all selection items
|
|
58
|
+
* @param variableState - Optional dashboard variable state for additional interpolation
|
|
59
|
+
*/ export function interpolateSelectionBatch(template, items, variableState) {
|
|
60
|
+
// Replace __data patterns using shared utility (includes __data.count)
|
|
61
|
+
const dataFieldResult = replaceDataFieldsBatch(template, items);
|
|
62
|
+
let result = dataFieldResult.text;
|
|
63
|
+
const errors = [];
|
|
64
|
+
if (dataFieldResult.errors) {
|
|
65
|
+
errors.push(...dataFieldResult.errors.map((e)=>e.replace('in data', 'in selection data')));
|
|
66
|
+
}
|
|
67
|
+
// Apply dashboard variable interpolation if provided
|
|
68
|
+
if (variableState) {
|
|
69
|
+
result = replaceVariables(result, variableState);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
text: result,
|
|
73
|
+
errors: errors.length > 0 ? errors : undefined
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=selection-interpolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/selection-interpolation.ts"],"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 { DataItem, InterpolationResult, replaceDataFields, replaceDataFieldsBatch } from './data-field-interpolation';\nimport { VariableStateMap, replaceVariables } from './variable-interpolation';\n\nexport type SelectionItem = DataItem;\n\n/**\n * Interpolate selection data into a template string for individual mode.\n *\n * Supports:\n * - ${__data.fields[\"fieldName\"]} - field value from the item\n * - ${__data.index} - current selection index (0-based)\n * - ${__data.count} - total number of selections\n *\n * @param template - The template string with placeholders\n * @param item - The current selection item data\n * @param index - The current selection index (0-based)\n * @param count - Total number of selections\n * @param variableState - Optional dashboard variable state for additional interpolation\n */\nexport function interpolateSelectionIndividual(\n template: string,\n item: SelectionItem,\n index: number,\n count: number,\n variableState?: VariableStateMap\n): InterpolationResult {\n // Replace __data patterns using shared utility (includes __data.index and __data.count)\n const dataFieldResult = replaceDataFields(template, item, { index, count });\n let result = dataFieldResult.text;\n const errors: string[] = [];\n if (dataFieldResult.errors) {\n errors.push(...dataFieldResult.errors.map((e) => e.replace('in data', 'in selection data')));\n }\n\n // Apply dashboard variable interpolation if provided\n if (variableState) {\n result = replaceVariables(result, variableState);\n }\n\n return { text: result, errors: errors.length > 0 ? errors : undefined };\n}\n\n/**\n * Interpolate selection data into a template string for batch mode.\n *\n * Supports:\n * - ${__data[0].fields[\"fieldName\"]} - field value from specific item by index\n * - ${__data.fields[\"fieldName\"]:csv} - aggregated field values with format specifier\n * - ${__data.count} - total number of selections\n *\n * @param template - The template string with placeholders\n * @param items - Array of all selection items\n * @param variableState - Optional dashboard variable state for additional interpolation\n */\nexport function interpolateSelectionBatch(\n template: string,\n items: SelectionItem[],\n variableState?: VariableStateMap\n): InterpolationResult {\n // Replace __data patterns using shared utility (includes __data.count)\n const dataFieldResult = replaceDataFieldsBatch(template, items);\n let result = dataFieldResult.text;\n const errors: string[] = [];\n if (dataFieldResult.errors) {\n errors.push(...dataFieldResult.errors.map((e) => e.replace('in data', 'in selection data')));\n }\n\n // Apply dashboard variable interpolation if provided\n if (variableState) {\n result = replaceVariables(result, variableState);\n }\n\n return { text: result, errors: errors.length > 0 ? errors : undefined };\n}\n"],"names":["replaceDataFields","replaceDataFieldsBatch","replaceVariables","interpolateSelectionIndividual","template","item","index","count","variableState","dataFieldResult","result","text","errors","push","map","e","replace","length","undefined","interpolateSelectionBatch","items"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAwCA,iBAAiB,EAAEC,sBAAsB,QAAQ,6BAA6B;AACtH,SAA2BC,gBAAgB,QAAQ,2BAA2B;AAI9E;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASC,+BACdC,QAAgB,EAChBC,IAAmB,EACnBC,KAAa,EACbC,KAAa,EACbC,aAAgC;IAEhC,wFAAwF;IACxF,MAAMC,kBAAkBT,kBAAkBI,UAAUC,MAAM;QAAEC;QAAOC;IAAM;IACzE,IAAIG,SAASD,gBAAgBE,IAAI;IACjC,MAAMC,SAAmB,EAAE;IAC3B,IAAIH,gBAAgBG,MAAM,EAAE;QAC1BA,OAAOC,IAAI,IAAIJ,gBAAgBG,MAAM,CAACE,GAAG,CAAC,CAACC,IAAMA,EAAEC,OAAO,CAAC,WAAW;IACxE;IAEA,qDAAqD;IACrD,IAAIR,eAAe;QACjBE,SAASR,iBAAiBQ,QAAQF;IACpC;IAEA,OAAO;QAAEG,MAAMD;QAAQE,QAAQA,OAAOK,MAAM,GAAG,IAAIL,SAASM;IAAU;AACxE;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,0BACdf,QAAgB,EAChBgB,KAAsB,EACtBZ,aAAgC;IAEhC,uEAAuE;IACvE,MAAMC,kBAAkBR,uBAAuBG,UAAUgB;IACzD,IAAIV,SAASD,gBAAgBE,IAAI;IACjC,MAAMC,SAAmB,EAAE;IAC3B,IAAIH,gBAAgBG,MAAM,EAAE;QAC1BA,OAAOC,IAAI,IAAIJ,gBAAgBG,MAAM,CAACE,GAAG,CAAC,CAACC,IAAMA,EAAEC,OAAO,CAAC,WAAW;IACxE;IAEA,qDAAqD;IACrD,IAAIR,eAAe;QACjBE,SAASR,iBAAiBQ,QAAQF;IACpC;IAEA,OAAO;QAAEG,MAAMD;QAAQE,QAAQA,OAAOK,MAAM,GAAG,IAAIL,SAASM;IAAU;AACxE"}
|
package/dist/utils/theme-gen.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/theme-gen.ts"],"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 { Theme } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(\n muiTheme: MuiTheme,\n persesChartsThemeOverride: Partial<PersesChartsTheme>\n): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n // Accessible categorical palette from: https://davidmathlogic.com/colorblind\n color: [\n '#56B4E9', // lt blue\n '#009E73', // med green\n '#0072B2', // dk blue\n '#CC79A7', // lt purple\n '#F0E442', // yellow\n '#E69F00', // orange\n '#D55E00', // red\n ],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.4,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n timeAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.4,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {\n backgroundColor: muiTheme.palette.designSystem?.grey[800],\n borderColor: muiTheme.palette.designSystem?.grey[800],\n textStyle: {\n color: '#fff',\n fontSize: 11,\n },\n },\n axisPointer: {\n lineStyle: {\n color: muiTheme.palette.grey[500],\n },\n },\n markLine: {\n symbol: 'none',\n symbolSize: 0,\n itemStyle: {\n color: muiTheme.palette.grey[500],\n },\n lineStyle: {\n type: 'dashed',\n width: 1,\n },\n },\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderRadius: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n label: {\n show: false,\n color: primaryTextColor,\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return merge(\n {\n echartsTheme: muiConvertedTheme,\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n container: {\n padding: {\n default: parseInt(muiTheme.spacing(1.5), 10),\n },\n },\n thresholds: {\n defaultColor: muiTheme.palette.success.main,\n palette: ['#FFCC00', muiTheme.palette.warning.main, muiTheme.palette.error.main],\n },\n },\n persesChartsThemeOverride\n );\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","muiTheme","persesChartsThemeOverride","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","timeAxis","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","backgroundColor","designSystem","axisPointer","markLine","symbol","symbolSize","itemStyle","type","line","showSymbol","smooth","emphasis","bar","barMaxWidth","borderWidth","borderRadius","label","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","echartsTheme","noDataOption","xAxis","yAxis","sparkline","container","padding","default","parseInt","spacing","thresholds","defaultColor","success","main","warning","error"],"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;AAGjC,OAAOA,WAAW,eAAe;AAGjC,MAAMC,qBAAqB;AAK3B,OAAO,SAASC,oBACdC,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AAM;gBACNzB,OAAO;YACT;QACF;QACA0B,MAAM;YACJC,YAAY;YACZL,QAAQ;YACRC,YAAY;YACZK,QAAQ;YACRhC,WAAW;gBACTI,OAAO;YACT;YACA6B,UAAU;gBACRjC,WAAW;oBACTI,OAAO;gBACT;YACF;QACF;QACA8B,KAAK;YACHC,aAAa;YACbP,WAAW;gBACTQ,aAAa;gBACbC,cAAc;gBACdjB,aAAa7C,SAASG,OAAO,CAACuB,IAAI,CAAC,IAAI;YACzC;YACAqC,OAAO;gBACLvD,MAAM;gBACNE,OAAOR;YACT;QACF;QACA8D,OAAO;YACLC,QAAQ;gBACNpD,UAAU;gBACVqD,YAAY;gBACZC,gBAAgB;YAClB;YACAvC,WAAW;gBACTwC,UAAU;gBACV5C,QAAQ;gBACRC,WAAW;oBACTI,OAAO;gBACT;YACF;YACAwC,aAAa;QACf;IACF;IAEA,OAAOxE,MACL;QACEyE,cAAchE;QACdiE,cAAc;YACZhE,OAAO;gBACLC,MAAM;gBACNC,WAAW;oBACTC,OAAOR;oBACPW,UAAU;oBACVqD,YAAY;gBACd;gBACA9D,MAAM;gBACNc,MAAM;gBACNH,KAAK;YACP;YACAyD,OAAO;gBACLhE,MAAM;YACR;YACAiE,OAAO;gBACLjE,MAAM;YACR;QACF;QACAkE,WAAW;YACT7C,OAAO;YACPnB,OAAO;QACT;QACAiE,WAAW;YACTC,SAAS;gBACPC,SAASC,SAAS9E,SAAS+E,OAAO,CAAC,MAAM;YAC3C;QACF;QACAC,YAAY;YACVC,cAAcjF,SAASG,OAAO,CAAC+E,OAAO,CAACC,IAAI;YAC3ChF,SAAS;gBAAC;gBAAWH,SAASG,OAAO,CAACiF,OAAO,CAACD,IAAI;gBAAEnF,SAASG,OAAO,CAACkF,KAAK,CAACF,IAAI;aAAC;QAClF;IACF,GACAlF;AAEJ"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/theme-gen.ts"],"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 { Theme } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(\n muiTheme: MuiTheme,\n persesChartsThemeOverride: Partial<PersesChartsTheme>\n): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n // Accessible categorical palette from: https://davidmathlogic.com/colorblind\n color: [\n '#56B4E9', // lt blue\n '#009E73', // med green\n '#0072B2', // dk blue\n '#CC79A7', // lt purple\n '#F0E442', // yellow\n '#E69F00', // orange\n '#D55E00', // red\n ],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.4,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n timeAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.4,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {\n backgroundColor: muiTheme.palette.designSystem?.grey[800],\n borderColor: muiTheme.palette.designSystem?.grey[800],\n textStyle: {\n color: '#fff',\n fontSize: 11,\n },\n },\n axisPointer: {\n lineStyle: {\n color: muiTheme.palette.grey[500],\n },\n },\n markLine: {\n symbol: 'none',\n symbolSize: 0,\n itemStyle: {\n color: muiTheme.palette.grey[500],\n },\n lineStyle: {\n type: 'dashed',\n width: 1,\n },\n },\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderRadius: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n label: {\n show: false,\n color: primaryTextColor,\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return merge(\n {\n echartsTheme: muiConvertedTheme,\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n container: {\n padding: {\n default: parseInt(muiTheme.spacing(1.5), 10),\n },\n },\n thresholds: {\n defaultColor: muiTheme.palette.success.main,\n palette: ['#FFCC00', muiTheme.palette.warning.main, muiTheme.palette.error.main],\n },\n },\n persesChartsThemeOverride\n );\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","muiTheme","persesChartsThemeOverride","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","timeAxis","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","backgroundColor","designSystem","axisPointer","markLine","symbol","symbolSize","itemStyle","type","line","showSymbol","smooth","emphasis","bar","barMaxWidth","borderWidth","borderRadius","label","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","echartsTheme","noDataOption","xAxis","yAxis","sparkline","container","padding","default","parseInt","spacing","thresholds","defaultColor","success","main","warning","error"],"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,OAAOA,WAAW,eAAe;AAGjC,MAAMC,qBAAqB;AA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