@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.
- package/dist/AlignSelector/AlignSelector.js +115 -25
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/CodeEditor/CodeEditor.d.ts +19 -0
- package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
- package/dist/CodeEditor/CodeEditor.js +122 -0
- package/dist/CodeEditor/CodeEditor.js.map +1 -0
- package/dist/ColorPicker/ColorPicker.js +153 -61
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +147 -52
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/DensitySelector/DensitySelector.js +53 -20
- package/dist/DensitySelector/DensitySelector.js.map +1 -1
- package/dist/Dialog/Dialog.d.ts +3 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +202 -49
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +184 -113
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +131 -52
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +51 -26
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +75 -15
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +179 -90
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +14 -4
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
- package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
- package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
- package/dist/FormEditor/FormActions.js +88 -14
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.js +246 -99
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.js +90 -25
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +105 -42
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/JSONEditor.d.ts +2 -6
- package/dist/JSONEditor.d.ts.map +1 -1
- package/dist/JSONEditor.js +24 -37
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +77 -27
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +184 -82
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +54 -9
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +46 -16
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +184 -48
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +90 -48
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +2 -2
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +148 -67
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.js +61 -19
- package/dist/ModeSelector/ModeSelector.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +71 -27
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/RepeatGrid/RepeatGrid.js +117 -45
- package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelector.js +51 -18
- package/dist/SortSelector/SortSelector.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +109 -25
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +46 -15
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +3 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +410 -158
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +15 -4
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +294 -107
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +101 -32
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +15 -4
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +15 -4
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.js +119 -62
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +33 -9
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +5 -4
- package/dist/Table/TableToolbar.d.ts.map +1 -1
- package/dist/Table/TableToolbar.js +172 -100
- package/dist/Table/TableToolbar.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +11 -11
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +442 -204
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +27 -7
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.js +57 -32
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +86 -69
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +44 -15
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +33 -1
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -210
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeZoneSelector.js +131 -36
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +830 -334
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +170 -59
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
- package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
- package/dist/YAMLEditor/YAMLEditor.js +41 -0
- package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
- package/dist/YAMLEditor/index.d.ts +2 -0
- package/dist/YAMLEditor/index.d.ts.map +1 -0
- package/dist/YAMLEditor/index.js +15 -0
- package/dist/YAMLEditor/index.js.map +1 -0
- package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
- package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
- package/dist/YAMLEditor/yaml-utils.js +52 -0
- package/dist/YAMLEditor/yaml-utils.js.map +1 -0
- package/dist/YAxisLabel.js +64 -20
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/context/ChartsProvider.js +32 -16
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +110 -61
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +170 -66
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +101 -44
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +35 -14
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +86 -25
- package/dist/controls/TextField.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/browser-storage.js +64 -34
- package/dist/utils/browser-storage.js.map +1 -1
- package/package.json +15 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingEditor.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 { Grid2Props as GridProps, StackProps } from '@mui/material';\nimport { IconButton, MenuItem, Stack, TextField, Tooltip, Typography, Grid2 as Grid } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport type { FC } from 'react';\n\nimport { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';\nimport type { ValueMapping } from '../model';\n\ninterface ValueMappingConditionEditorProps extends Omit<StackProps, 'onChange'> {\n mapping: ValueMapping;\n onChange: (condition: ValueMapping) => void;\n}\n\nconst ConditionEditor: FC<ValueMappingConditionEditorProps> = ({ mapping, onChange, ...props }) => {\n switch (mapping.kind) {\n case 'Value':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"Value\"\n placeholder=\"Exact value\"\n value={mapping.spec?.value ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, value: e.target.value },\n })\n }\n fullWidth\n />\n </Stack>\n );\n case 'Range':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"From\"\n placeholder=\"Start of range\"\n value={mapping.spec?.from ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, from: e.target.value === '' ? undefined : +e.target.value },\n })\n }\n fullWidth\n />\n <TextField\n label=\"To\"\n placeholder=\"End of range (inclusive)\"\n value={mapping.spec?.to ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, to: e.target.value === '' ? undefined : +e.target.value },\n })\n }\n fullWidth\n />\n </Stack>\n );\n case 'Regex':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"Regular Expression\"\n placeholder=\"JavaScript regular expression\"\n value={mapping.spec?.pattern ?? ''}\n onChange={(e) => onChange({ ...mapping, spec: { ...mapping.spec, pattern: e.target.value } })}\n fullWidth\n />\n </Stack>\n );\n case 'Misc':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n select\n label=\"Value\"\n value={mapping.spec?.value ?? ''}\n onChange={(e) => onChange({ ...mapping, spec: { value: e.target.value } } as ValueMapping)}\n SelectProps={{\n renderValue: (selected) => {\n switch (selected) {\n case 'empty':\n return 'Empty';\n case 'null':\n return 'Null';\n case 'NaN':\n return 'NaN';\n case 'true':\n return 'True';\n case 'false':\n return 'False';\n default:\n return String(selected);\n }\n },\n }}\n fullWidth\n >\n <MenuItem value=\"empty\">\n <Stack>\n <Typography>Empty</Typography>\n <Typography variant=\"caption\">Matches empty string</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"null\">\n <Stack>\n <Typography>Null</Typography>\n <Typography variant=\"caption\">Matches null or undefined</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"NaN\">\n <Stack>\n <Typography>NaN</Typography>\n <Typography variant=\"caption\">Matches Not a Number value</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"true\">\n <Stack>\n <Typography>True</Typography>\n <Typography variant=\"caption\">Matches true boolean</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"false\">\n <Stack>\n <Typography>False</Typography>\n <Typography variant=\"caption\">Matches false boolean</Typography>\n </Stack>\n </MenuItem>\n </TextField>\n </Stack>\n );\n default:\n return null;\n }\n};\nexport interface ValueMappingEditorProps extends Omit<GridProps, 'onChange'> {\n mapping: ValueMapping;\n onChange: (mapping: ValueMapping) => void;\n onDelete: () => void;\n}\n\nexport const ValueMappingEditor: FC<ValueMappingEditorProps> = ({ mapping, onChange, onDelete, ...props }) => {\n const handleColorChange = (color?: string): void => {\n onChange({\n ...mapping,\n spec: {\n ...mapping.spec,\n result: {\n ...mapping.spec.result,\n color,\n },\n },\n } as ValueMapping);\n };\n return (\n <Grid container spacing={2} {...props}>\n <Grid size={{ xs: 5 }}>\n <Stack direction=\"row\" gap={1} width=\"100%\">\n <TextField\n select\n label=\"Type\"\n value={mapping.kind}\n onChange={(e) => onChange({ ...mapping, kind: e.target.value } as ValueMapping)}\n required\n sx={{ width: '120px' }}\n >\n <MenuItem value=\"Value\">\n <Stack>\n <Typography>Value</Typography>\n {mapping.kind !== 'Value' && <Typography variant=\"caption\">Matches an exact text value</Typography>}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Range\">\n <Stack>\n <Typography>Range</Typography>\n {mapping.kind !== 'Range' && (\n <Typography variant=\"caption\">Matches against a numerical range</Typography>\n )}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Regex\">\n <Stack>\n <Typography>Regex</Typography>\n {mapping.kind !== 'Regex' && (\n <Typography variant=\"caption\">Matches against a regular expression</Typography>\n )}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Misc\">\n <Stack>\n <Typography>Misc</Typography>\n {mapping.kind !== 'Misc' && (\n <Typography variant=\"caption\">Matches against empty, null and NaN values</Typography>\n )}\n </Stack>\n </MenuItem>\n </TextField>\n <ConditionEditor\n width=\"100%\"\n mapping={mapping}\n onChange={(updatedMapping) => onChange({ ...mapping, ...updatedMapping })}\n />\n </Stack>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <TextField\n label=\"Display text\"\n value={mapping.spec?.result?.value ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: {\n ...mapping.spec,\n result: {\n ...mapping.spec?.result,\n value: e.target.value,\n },\n },\n } as ValueMapping)\n }\n fullWidth\n />\n </Grid>\n <Grid size={{ xs: 1 }}>\n <Stack direction=\"row\" justifyContent=\"center\" gap={1}>\n {mapping.spec?.result?.color ? (\n <OptionsColorPicker\n label=\"Color\"\n color={mapping.spec.result.color ?? '#000'}\n onColorChange={handleColorChange}\n onClear={() => handleColorChange(undefined)}\n />\n ) : (\n <IconButton onClick={() => handleColorChange('#000')}>\n <PlusIcon />\n </IconButton>\n )}\n </Stack>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"end\">\n <Tooltip title=\"Remove mapping settings\" placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n </Grid>\n </Grid>\n );\n};\n"],"names":["IconButton","MenuItem","Stack","TextField","Tooltip","Typography","Grid2","Grid","DeleteIcon","PlusIcon","OptionsColorPicker","ConditionEditor","mapping","onChange","props","kind","gap","direction","label","placeholder","value","spec","e","target","fullWidth","from","undefined","to","pattern","select","SelectProps","renderValue","selected","String","variant","ValueMappingEditor","onDelete","handleColorChange","color","result","container","spacing","size","xs","width","required","sx","updatedMapping","justifyContent","onColorChange","onClear","onClick","textAlign","title","placement","marginLeft"],"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,UAAU,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,SAASC,IAAI,QAAQ,gBAAgB;AAC3G,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,cAAc,uBAAuB;AAG5C,SAASC,kBAAkB,QAAQ,uCAAoC;AAQvE,MAAMC,kBAAwD,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGC,OAAO;IAC5F,OAAQF,QAAQG,IAAI;QAClB,KAAK;YACH,qBACE,KAACb;gBAAMc,KAAK;gBAAGC,WAAU;gBAAO,GAAGH,KAAK;0BACtC,cAAA,KAACX;oBACCe,OAAM;oBACNC,aAAY;oBACZC,OAAOR,QAAQS,IAAI,EAAED,SAAS;oBAC9BP,UAAU,CAACS,IACTT,SAAS;4BACP,GAAGD,OAAO;4BACVS,MAAM;gCAAE,GAAGT,QAAQS,IAAI;gCAAED,OAAOE,EAAEC,MAAM,CAACH,KAAK;4BAAC;wBACjD;oBAEFI,SAAS;;;QAIjB,KAAK;YACH,qBACE,MAACtB;gBAAMc,KAAK;gBAAGC,WAAU;gBAAO,GAAGH,KAAK;;kCACtC,KAACX;wBACCe,OAAM;wBACNC,aAAY;wBACZC,OAAOR,QAAQS,IAAI,EAAEI,QA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CACvB;4BACF;wBACF;oBAEFI,SAAS;;;0BAGb,KAACjB;gBAAKmC,MAAM;oBAAEC,IAAI;gBAAE;0BAClB,cAAA,KAACzC;oBAAMe,WAAU;oBAAM+B,gBAAe;oBAAShC,KAAK;8BACjDJ,QAAQS,IAAI,EAAEkB,QAAQD,sBACrB,KAAC5B;wBACCQ,OAAM;wBACNoB,OAAO1B,QAAQS,IAAI,CAACkB,MAAM,CAACD,KAAK,IAAI;wBACpCW,eAAeZ;wBACfa,SAAS,IAAMb,kBAAkBX;uCAGnC,KAAC1B;wBAAWmD,SAAS,IAAMd,kBAAkB;kCAC3C,cAAA,KAAC5B;;;;0BAKT,KAACF;gBAAKmC,MAAM;oBAAEC,IAAI;gBAAE;gBAAGS,WAAU;0BAC/B,cAAA,KAAChD;oBAAQiD,OAAM;oBAA0BC,WAAU;8BACjD,cAAA,KAACtD;wBAAW0C,MAAK;wBAAQI,IAAI;4BAAES,YAAY;wBAAO;wBAAGJ,SAASf;kCAC5D,cAAA,KAAC5B;;;;;;AAMb,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingEditor.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 { Grid2Props as GridProps, StackProps } from '@mui/material';\nimport { IconButton, MenuItem, Stack, TextField, Tooltip, Typography, Grid2 as Grid } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport type { FC } from 'react';\n\nimport { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';\nimport type { ValueMapping } from '../model';\n\ninterface ValueMappingConditionEditorProps extends Omit<StackProps, 'onChange'> {\n mapping: ValueMapping;\n onChange: (condition: ValueMapping) => void;\n}\n\nconst ConditionEditor: FC<ValueMappingConditionEditorProps> = ({ mapping, onChange, ...props }) => {\n switch (mapping.kind) {\n case 'Value':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"Value\"\n placeholder=\"Exact value\"\n value={mapping.spec?.value ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, value: e.target.value },\n })\n }\n fullWidth\n />\n </Stack>\n );\n case 'Range':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"From\"\n placeholder=\"Start of range\"\n value={mapping.spec?.from ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, from: e.target.value === '' ? undefined : +e.target.value },\n })\n }\n fullWidth\n />\n <TextField\n label=\"To\"\n placeholder=\"End of range (inclusive)\"\n value={mapping.spec?.to ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, to: e.target.value === '' ? undefined : +e.target.value },\n })\n }\n fullWidth\n />\n </Stack>\n );\n case 'Regex':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"Regular Expression\"\n placeholder=\"JavaScript regular expression\"\n value={mapping.spec?.pattern ?? ''}\n onChange={(e) => onChange({ ...mapping, spec: { ...mapping.spec, pattern: e.target.value } })}\n fullWidth\n />\n </Stack>\n );\n case 'Misc':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n select\n label=\"Value\"\n value={mapping.spec?.value ?? ''}\n onChange={(e) => onChange({ ...mapping, spec: { value: e.target.value } } as ValueMapping)}\n SelectProps={{\n renderValue: (selected) => {\n switch (selected) {\n case 'empty':\n return 'Empty';\n case 'null':\n return 'Null';\n case 'NaN':\n return 'NaN';\n case 'true':\n return 'True';\n case 'false':\n return 'False';\n default:\n return String(selected);\n }\n },\n }}\n fullWidth\n >\n <MenuItem value=\"empty\">\n <Stack>\n <Typography>Empty</Typography>\n <Typography variant=\"caption\">Matches empty string</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"null\">\n <Stack>\n <Typography>Null</Typography>\n <Typography variant=\"caption\">Matches null or undefined</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"NaN\">\n <Stack>\n <Typography>NaN</Typography>\n <Typography variant=\"caption\">Matches Not a Number value</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"true\">\n <Stack>\n <Typography>True</Typography>\n <Typography variant=\"caption\">Matches true boolean</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"false\">\n <Stack>\n <Typography>False</Typography>\n <Typography variant=\"caption\">Matches false boolean</Typography>\n </Stack>\n </MenuItem>\n </TextField>\n </Stack>\n );\n default:\n return null;\n }\n};\nexport interface ValueMappingEditorProps extends Omit<GridProps, 'onChange'> {\n mapping: ValueMapping;\n onChange: (mapping: ValueMapping) => void;\n onDelete: () => void;\n}\n\nexport const ValueMappingEditor: FC<ValueMappingEditorProps> = ({ mapping, onChange, onDelete, ...props }) => {\n const handleColorChange = (color?: string): void => {\n onChange({\n ...mapping,\n spec: {\n ...mapping.spec,\n result: {\n ...mapping.spec.result,\n color,\n },\n },\n } as ValueMapping);\n };\n return (\n <Grid container spacing={2} {...props}>\n <Grid size={{ xs: 5 }}>\n <Stack direction=\"row\" gap={1} width=\"100%\">\n <TextField\n select\n label=\"Type\"\n value={mapping.kind}\n onChange={(e) => onChange({ ...mapping, kind: e.target.value } as ValueMapping)}\n required\n sx={{ width: '120px' }}\n >\n <MenuItem value=\"Value\">\n <Stack>\n <Typography>Value</Typography>\n {mapping.kind !== 'Value' && <Typography variant=\"caption\">Matches an exact text value</Typography>}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Range\">\n <Stack>\n <Typography>Range</Typography>\n {mapping.kind !== 'Range' && (\n <Typography variant=\"caption\">Matches against a numerical range</Typography>\n )}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Regex\">\n <Stack>\n <Typography>Regex</Typography>\n {mapping.kind !== 'Regex' && (\n <Typography variant=\"caption\">Matches against a regular expression</Typography>\n )}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Misc\">\n <Stack>\n <Typography>Misc</Typography>\n {mapping.kind !== 'Misc' && (\n <Typography variant=\"caption\">Matches against empty, null and NaN values</Typography>\n )}\n </Stack>\n </MenuItem>\n </TextField>\n <ConditionEditor\n width=\"100%\"\n mapping={mapping}\n onChange={(updatedMapping) => onChange({ ...mapping, ...updatedMapping })}\n />\n </Stack>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <TextField\n label=\"Display text\"\n value={mapping.spec?.result?.value ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: {\n ...mapping.spec,\n result: {\n ...mapping.spec?.result,\n value: e.target.value,\n },\n },\n } as ValueMapping)\n }\n fullWidth\n />\n </Grid>\n <Grid size={{ xs: 1 }}>\n <Stack direction=\"row\" justifyContent=\"center\" gap={1}>\n {mapping.spec?.result?.color ? (\n <OptionsColorPicker\n label=\"Color\"\n color={mapping.spec.result.color ?? '#000'}\n onColorChange={handleColorChange}\n onClear={() => handleColorChange(undefined)}\n />\n ) : (\n <IconButton onClick={() => handleColorChange('#000')}>\n <PlusIcon />\n </IconButton>\n )}\n </Stack>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"end\">\n <Tooltip title=\"Remove mapping settings\" placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n </Grid>\n </Grid>\n );\n};\n"],"names":["IconButton","MenuItem","Stack","TextField","Tooltip","Typography","Grid2","Grid","DeleteIcon","PlusIcon","OptionsColorPicker","ConditionEditor","ValueMappingEditor"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2G7D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c as _c } from "react-compiler-runtime";
|
|
2
3
|
// Copyright The Perses Authors
|
|
3
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -15,104 +16,230 @@ import { Button, Divider, Stack, Typography, Grid2 as Grid } from "@mui/material
|
|
|
15
16
|
import AddIcon from "mdi-material-ui/Plus";
|
|
16
17
|
import { useState } from "react";
|
|
17
18
|
import { ValueMappingEditor } from "./ValueMappingEditor.js";
|
|
18
|
-
export const ValueMappingsEditor = (
|
|
19
|
+
export const ValueMappingsEditor = (t0)=>{
|
|
20
|
+
const $ = _c(31);
|
|
21
|
+
const { mappings, onChange } = t0;
|
|
19
22
|
const [valueMappings, setValueMappings] = useState(mappings);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[0] !== onChange || $[1] !== valueMappings) {
|
|
25
|
+
t1 = function handleValueMappingChange(index, mapping) {
|
|
26
|
+
const updatedValueMapings = [
|
|
27
|
+
...valueMappings
|
|
28
|
+
];
|
|
29
|
+
updatedValueMapings[index] = mapping;
|
|
30
|
+
setValueMappings(updatedValueMapings);
|
|
31
|
+
onChange(updatedValueMapings);
|
|
32
|
+
};
|
|
33
|
+
$[0] = onChange;
|
|
34
|
+
$[1] = valueMappings;
|
|
35
|
+
$[2] = t1;
|
|
36
|
+
} else {
|
|
37
|
+
t1 = $[2];
|
|
27
38
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const handleValueMappingChange = t1;
|
|
40
|
+
let t2;
|
|
41
|
+
if ($[3] !== onChange || $[4] !== valueMappings) {
|
|
42
|
+
t2 = function handleAddValueMappingEditor() {
|
|
43
|
+
const updatedValueMapings_0 = [
|
|
44
|
+
...valueMappings
|
|
45
|
+
];
|
|
46
|
+
updatedValueMapings_0.push({
|
|
47
|
+
kind: "Value",
|
|
48
|
+
spec: {
|
|
49
|
+
result: {
|
|
50
|
+
value: ""
|
|
51
|
+
}
|
|
37
52
|
}
|
|
38
|
-
}
|
|
53
|
+
});
|
|
54
|
+
setValueMappings(updatedValueMapings_0);
|
|
55
|
+
onChange(updatedValueMapings_0);
|
|
56
|
+
};
|
|
57
|
+
$[3] = onChange;
|
|
58
|
+
$[4] = valueMappings;
|
|
59
|
+
$[5] = t2;
|
|
60
|
+
} else {
|
|
61
|
+
t2 = $[5];
|
|
62
|
+
}
|
|
63
|
+
const handleAddValueMappingEditor = t2;
|
|
64
|
+
let t3;
|
|
65
|
+
if ($[6] !== onChange || $[7] !== valueMappings) {
|
|
66
|
+
t3 = function handleValueMappingDelete(index_0) {
|
|
67
|
+
const updatedValueMapings_1 = [
|
|
68
|
+
...valueMappings
|
|
69
|
+
];
|
|
70
|
+
updatedValueMapings_1.splice(index_0, 1);
|
|
71
|
+
setValueMappings(updatedValueMapings_1);
|
|
72
|
+
onChange(updatedValueMapings_1);
|
|
73
|
+
};
|
|
74
|
+
$[6] = onChange;
|
|
75
|
+
$[7] = valueMappings;
|
|
76
|
+
$[8] = t3;
|
|
77
|
+
} else {
|
|
78
|
+
t3 = $[8];
|
|
79
|
+
}
|
|
80
|
+
const handleValueMappingDelete = t3;
|
|
81
|
+
let t4;
|
|
82
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
83
|
+
t4 = /*#__PURE__*/ _jsx(Grid, {
|
|
84
|
+
size: {
|
|
85
|
+
xs: 5
|
|
86
|
+
},
|
|
87
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
88
|
+
variant: "subtitle1",
|
|
89
|
+
children: "Condition"
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
$[9] = t4;
|
|
93
|
+
} else {
|
|
94
|
+
t4 = $[9];
|
|
95
|
+
}
|
|
96
|
+
let t5;
|
|
97
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
98
|
+
t5 = /*#__PURE__*/ _jsx(Grid, {
|
|
99
|
+
size: {
|
|
100
|
+
xs: 4
|
|
101
|
+
},
|
|
102
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
103
|
+
variant: "subtitle1",
|
|
104
|
+
children: "Display Text"
|
|
105
|
+
})
|
|
39
106
|
});
|
|
40
|
-
|
|
41
|
-
|
|
107
|
+
$[10] = t5;
|
|
108
|
+
} else {
|
|
109
|
+
t5 = $[10];
|
|
42
110
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
111
|
+
let t6;
|
|
112
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
113
|
+
t6 = {
|
|
114
|
+
xs: 1
|
|
115
|
+
};
|
|
116
|
+
$[11] = t6;
|
|
117
|
+
} else {
|
|
118
|
+
t6 = $[11];
|
|
50
119
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
size: {
|
|
60
|
-
xs: 5
|
|
61
|
-
},
|
|
62
|
-
children: /*#__PURE__*/ _jsx(Typography, {
|
|
63
|
-
variant: "subtitle1",
|
|
64
|
-
children: "Condition"
|
|
65
|
-
})
|
|
66
|
-
}),
|
|
67
|
-
/*#__PURE__*/ _jsx(Grid, {
|
|
68
|
-
size: {
|
|
69
|
-
xs: 4
|
|
70
|
-
},
|
|
71
|
-
children: /*#__PURE__*/ _jsx(Typography, {
|
|
72
|
-
variant: "subtitle1",
|
|
73
|
-
children: "Display Text"
|
|
74
|
-
})
|
|
75
|
-
}),
|
|
76
|
-
/*#__PURE__*/ _jsx(Grid, {
|
|
77
|
-
size: {
|
|
78
|
-
xs: 1
|
|
79
|
-
},
|
|
80
|
-
textAlign: "center",
|
|
81
|
-
children: /*#__PURE__*/ _jsx(Typography, {
|
|
82
|
-
variant: "subtitle1",
|
|
83
|
-
children: "Color"
|
|
84
|
-
})
|
|
85
|
-
}),
|
|
86
|
-
/*#__PURE__*/ _jsx(Grid, {
|
|
87
|
-
size: {
|
|
88
|
-
xs: 1
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
]
|
|
92
|
-
}),
|
|
93
|
-
/*#__PURE__*/ _jsx(Stack, {
|
|
94
|
-
gap: 1.5,
|
|
95
|
-
divider: /*#__PURE__*/ _jsx(Divider, {
|
|
96
|
-
flexItem: true,
|
|
97
|
-
orientation: "horizontal"
|
|
98
|
-
}),
|
|
99
|
-
children: valueMappings.map((mapping, i)=>/*#__PURE__*/ _jsx(ValueMappingEditor, {
|
|
100
|
-
mapping: mapping,
|
|
101
|
-
onChange: (updatedMapping)=>handleValueMappingChange(i, updatedMapping),
|
|
102
|
-
onDelete: ()=>handleValueMappingDelete(i)
|
|
103
|
-
}, i))
|
|
104
|
-
}),
|
|
105
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
106
|
-
variant: "contained",
|
|
107
|
-
startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
|
|
108
|
-
sx: {
|
|
109
|
-
marginTop: 1
|
|
110
|
-
},
|
|
111
|
-
onClick: handleAddValueMappingEditor,
|
|
112
|
-
children: "Add value mappings"
|
|
120
|
+
let t7;
|
|
121
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
122
|
+
t7 = /*#__PURE__*/ _jsx(Grid, {
|
|
123
|
+
size: t6,
|
|
124
|
+
textAlign: "center",
|
|
125
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
126
|
+
variant: "subtitle1",
|
|
127
|
+
children: "Color"
|
|
113
128
|
})
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
});
|
|
130
|
+
$[12] = t7;
|
|
131
|
+
} else {
|
|
132
|
+
t7 = $[12];
|
|
133
|
+
}
|
|
134
|
+
let t8;
|
|
135
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
136
|
+
t8 = /*#__PURE__*/ _jsxs(Grid, {
|
|
137
|
+
container: true,
|
|
138
|
+
spacing: 2,
|
|
139
|
+
children: [
|
|
140
|
+
t4,
|
|
141
|
+
t5,
|
|
142
|
+
t7,
|
|
143
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
144
|
+
size: {
|
|
145
|
+
xs: 1
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
$[13] = t8;
|
|
151
|
+
} else {
|
|
152
|
+
t8 = $[13];
|
|
153
|
+
}
|
|
154
|
+
let t9;
|
|
155
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
156
|
+
t9 = /*#__PURE__*/ _jsx(Divider, {
|
|
157
|
+
flexItem: true,
|
|
158
|
+
orientation: "horizontal"
|
|
159
|
+
});
|
|
160
|
+
$[14] = t9;
|
|
161
|
+
} else {
|
|
162
|
+
t9 = $[14];
|
|
163
|
+
}
|
|
164
|
+
let t10;
|
|
165
|
+
if ($[15] !== handleValueMappingChange || $[16] !== handleValueMappingDelete || $[17] !== valueMappings) {
|
|
166
|
+
let t11;
|
|
167
|
+
if ($[19] !== handleValueMappingChange || $[20] !== handleValueMappingDelete) {
|
|
168
|
+
t11 = (mapping_0, i)=>/*#__PURE__*/ _jsx(ValueMappingEditor, {
|
|
169
|
+
mapping: mapping_0,
|
|
170
|
+
onChange: (updatedMapping)=>handleValueMappingChange(i, updatedMapping),
|
|
171
|
+
onDelete: ()=>handleValueMappingDelete(i)
|
|
172
|
+
}, i);
|
|
173
|
+
$[19] = handleValueMappingChange;
|
|
174
|
+
$[20] = handleValueMappingDelete;
|
|
175
|
+
$[21] = t11;
|
|
176
|
+
} else {
|
|
177
|
+
t11 = $[21];
|
|
178
|
+
}
|
|
179
|
+
t10 = valueMappings.map(t11);
|
|
180
|
+
$[15] = handleValueMappingChange;
|
|
181
|
+
$[16] = handleValueMappingDelete;
|
|
182
|
+
$[17] = valueMappings;
|
|
183
|
+
$[18] = t10;
|
|
184
|
+
} else {
|
|
185
|
+
t10 = $[18];
|
|
186
|
+
}
|
|
187
|
+
let t11;
|
|
188
|
+
if ($[22] !== t10) {
|
|
189
|
+
t11 = /*#__PURE__*/ _jsx(Stack, {
|
|
190
|
+
gap: 1.5,
|
|
191
|
+
divider: t9,
|
|
192
|
+
children: t10
|
|
193
|
+
});
|
|
194
|
+
$[22] = t10;
|
|
195
|
+
$[23] = t11;
|
|
196
|
+
} else {
|
|
197
|
+
t11 = $[23];
|
|
198
|
+
}
|
|
199
|
+
let t12;
|
|
200
|
+
let t13;
|
|
201
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
202
|
+
t12 = /*#__PURE__*/ _jsx(AddIcon, {});
|
|
203
|
+
t13 = {
|
|
204
|
+
marginTop: 1
|
|
205
|
+
};
|
|
206
|
+
$[24] = t12;
|
|
207
|
+
$[25] = t13;
|
|
208
|
+
} else {
|
|
209
|
+
t12 = $[24];
|
|
210
|
+
t13 = $[25];
|
|
211
|
+
}
|
|
212
|
+
let t14;
|
|
213
|
+
if ($[26] !== handleAddValueMappingEditor) {
|
|
214
|
+
t14 = /*#__PURE__*/ _jsx(Button, {
|
|
215
|
+
variant: "contained",
|
|
216
|
+
startIcon: t12,
|
|
217
|
+
sx: t13,
|
|
218
|
+
onClick: handleAddValueMappingEditor,
|
|
219
|
+
children: "Add value mappings"
|
|
220
|
+
});
|
|
221
|
+
$[26] = handleAddValueMappingEditor;
|
|
222
|
+
$[27] = t14;
|
|
223
|
+
} else {
|
|
224
|
+
t14 = $[27];
|
|
225
|
+
}
|
|
226
|
+
let t15;
|
|
227
|
+
if ($[28] !== t11 || $[29] !== t14) {
|
|
228
|
+
t15 = /*#__PURE__*/ _jsxs(Stack, {
|
|
229
|
+
spacing: 1,
|
|
230
|
+
children: [
|
|
231
|
+
t8,
|
|
232
|
+
t11,
|
|
233
|
+
t14
|
|
234
|
+
]
|
|
235
|
+
});
|
|
236
|
+
$[28] = t11;
|
|
237
|
+
$[29] = t14;
|
|
238
|
+
$[30] = t15;
|
|
239
|
+
} else {
|
|
240
|
+
t15 = $[30];
|
|
241
|
+
}
|
|
242
|
+
return t15;
|
|
116
243
|
};
|
|
117
244
|
|
|
118
245
|
//# sourceMappingURL=ValueMappingsEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingsEditor.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 { Button, Divider, Stack, Typography, Grid2 as Grid } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport type { FC } from 'react';\nimport { useState } from 'react';\n\nimport type { ValueMapping } from '../model';\nimport { ValueMappingEditor } from './ValueMappingEditor';\n\nexport interface ValueMappingsEditorProps {\n mappings: ValueMapping[];\n onChange: (valueMappings: ValueMapping[]) => void;\n}\n\nexport const ValueMappingsEditor: FC<ValueMappingsEditorProps> = ({ mappings, onChange }) => {\n const [valueMappings, setValueMappings] = useState<ValueMapping[]>(mappings);\n\n function handleValueMappingChange(index: number, mapping: ValueMapping): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings[index] = mapping;\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleAddValueMappingEditor(): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.push({ kind: 'Value', spec: { result: { value: '' } } } as ValueMapping);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleValueMappingDelete(index: number): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.splice(index, 1);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n return (\n <Stack spacing={1}>\n <Grid container spacing={2}>\n <Grid size={{ xs: 5 }}>\n <Typography variant=\"subtitle1\">Condition</Typography>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <Typography variant=\"subtitle1\">Display Text</Typography>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"center\">\n <Typography variant=\"subtitle1\">Color</Typography>\n </Grid>\n <Grid size={{ xs: 1 }}></Grid>\n </Grid>\n <Stack gap={1.5} divider={<Divider flexItem orientation=\"horizontal\" />}>\n {valueMappings.map((mapping, i) => (\n <ValueMappingEditor\n key={i}\n mapping={mapping}\n onChange={(updatedMapping: ValueMapping) => handleValueMappingChange(i, updatedMapping)}\n onDelete={() => handleValueMappingDelete(i)}\n />\n ))}\n </Stack>\n\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleAddValueMappingEditor}>\n Add value mappings\n </Button>\n </Stack>\n );\n};\n"],"names":["Button","Divider","Stack","Typography","Grid2","Grid","AddIcon","useState","ValueMappingEditor","ValueMappingsEditor"
|
|
1
|
+
{"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingsEditor.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 { Button, Divider, Stack, Typography, Grid2 as Grid } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport type { FC } from 'react';\nimport { useState } from 'react';\n\nimport type { ValueMapping } from '../model';\nimport { ValueMappingEditor } from './ValueMappingEditor';\n\nexport interface ValueMappingsEditorProps {\n mappings: ValueMapping[];\n onChange: (valueMappings: ValueMapping[]) => void;\n}\n\nexport const ValueMappingsEditor: FC<ValueMappingsEditorProps> = ({ mappings, onChange }) => {\n const [valueMappings, setValueMappings] = useState<ValueMapping[]>(mappings);\n\n function handleValueMappingChange(index: number, mapping: ValueMapping): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings[index] = mapping;\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleAddValueMappingEditor(): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.push({ kind: 'Value', spec: { result: { value: '' } } } as ValueMapping);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleValueMappingDelete(index: number): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.splice(index, 1);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n return (\n <Stack spacing={1}>\n <Grid container spacing={2}>\n <Grid size={{ xs: 5 }}>\n <Typography variant=\"subtitle1\">Condition</Typography>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <Typography variant=\"subtitle1\">Display Text</Typography>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"center\">\n <Typography variant=\"subtitle1\">Color</Typography>\n </Grid>\n <Grid size={{ xs: 1 }}></Grid>\n </Grid>\n <Stack gap={1.5} divider={<Divider flexItem orientation=\"horizontal\" />}>\n {valueMappings.map((mapping, i) => (\n <ValueMappingEditor\n key={i}\n mapping={mapping}\n onChange={(updatedMapping: ValueMapping) => handleValueMappingChange(i, updatedMapping)}\n onDelete={() => handleValueMappingDelete(i)}\n />\n ))}\n </Stack>\n\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleAddValueMappingEditor}>\n Add value mappings\n </Button>\n </Stack>\n );\n};\n"],"names":["Button","Divider","Stack","Typography","Grid2","Grid","AddIcon","useState","ValueMappingEditor","ValueMappingsEditor"],"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,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAASC,IAAI,QAAQ,gBAAgB;AAClF,OAAOC,aAAa,uBAAuB;AAE3C,SAASC,QAAQ,QAAQ,QAAQ;AAGjC,SAASC,kBAAkB,QAAQ,0BAAuB;AAO1D,OAAO,MAAMC,sBAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsD/D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { CodeEditorProps } from '../CodeEditor/CodeEditor';
|
|
3
|
+
type YAMLEditorProps<T> = Omit<CodeEditorProps<T>, 'value'> & {
|
|
4
|
+
/**
|
|
5
|
+
* Initial content of the editor. Unlike JSONEditor, a string is used as is (raw YAML or JSON text),
|
|
6
|
+
* while any other value is serialized as YAML (1.1 schema). `undefined` gives an empty editor.
|
|
7
|
+
*/
|
|
8
|
+
value: T;
|
|
9
|
+
};
|
|
10
|
+
export declare function YAMLEditor<T>(props: YAMLEditorProps<T>): ReactElement;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=YAMLEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YAMLEditor.d.ts","sourceRoot":"","sources":["../../src/YAMLEditor/YAMLEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAMhE,KAAK,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IAC5D;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,YAAY,CAErE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c as _c } from "react-compiler-runtime";
|
|
3
|
+
// Copyright The Perses Authors
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
import { yaml } from "@codemirror/lang-yaml";
|
|
16
|
+
import { linter, lintGutter } from "@codemirror/lint";
|
|
17
|
+
import { CodeEditor } from "../CodeEditor/CodeEditor.js";
|
|
18
|
+
import { toYAMLText, yamlDiagnostics } from "./yaml-utils.js";
|
|
19
|
+
const YAML_EXTENSIONS = [
|
|
20
|
+
yaml(),
|
|
21
|
+
linter((view)=>yamlDiagnostics(view.state.doc.toString())),
|
|
22
|
+
lintGutter()
|
|
23
|
+
];
|
|
24
|
+
export function YAMLEditor(props) {
|
|
25
|
+
const $ = _c(2);
|
|
26
|
+
let t0;
|
|
27
|
+
if ($[0] !== props) {
|
|
28
|
+
t0 = /*#__PURE__*/ _jsx(CodeEditor, {
|
|
29
|
+
...props,
|
|
30
|
+
extensions: YAML_EXTENSIONS,
|
|
31
|
+
serialize: toYAMLText
|
|
32
|
+
});
|
|
33
|
+
$[0] = props;
|
|
34
|
+
$[1] = t0;
|
|
35
|
+
} else {
|
|
36
|
+
t0 = $[1];
|
|
37
|
+
}
|
|
38
|
+
return t0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=YAMLEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/YAMLEditor/YAMLEditor.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 { yaml } from '@codemirror/lang-yaml';\nimport { linter, lintGutter } from '@codemirror/lint';\nimport type { ReactElement } from 'react';\n\nimport type { CodeEditorProps } from '../CodeEditor/CodeEditor';\nimport { CodeEditor } from '../CodeEditor/CodeEditor';\nimport { toYAMLText, yamlDiagnostics } from './yaml-utils';\n\nconst YAML_EXTENSIONS = [yaml(), linter((view) => yamlDiagnostics(view.state.doc.toString())), lintGutter()];\n\ntype YAMLEditorProps<T> = Omit<CodeEditorProps<T>, 'value'> & {\n /**\n * Initial content of the editor. Unlike JSONEditor, a string is used as is (raw YAML or JSON text),\n * while any other value is serialized as YAML (1.1 schema). `undefined` gives an empty editor.\n */\n value: T;\n};\n\nexport function YAMLEditor<T>(props: YAMLEditorProps<T>): ReactElement {\n return <CodeEditor {...props} extensions={YAML_EXTENSIONS} serialize={toYAMLText} />;\n}\n"],"names":["yaml","linter","lintGutter","CodeEditor","toYAMLText","yamlDiagnostics","YAML_EXTENSIONS","view","state","doc","toString"],"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,IAAI,QAAQ,wBAAwB;AAC7C,SAASC,MAAM,EAAEC,UAAU,QAAQ,mBAAmB;AAItD,SAASC,UAAU,QAAQ,8BAA2B;AACtD,SAASC,UAAU,EAAEC,eAAe,QAAQ,kBAAe;AAE3D,MAAMC,kBAAkB;IAACN;IAAQC,OAAO,CAACM,OAASF,gBAAgBE,KAAKC,KAAK,CAACC,GAAG,CAACC,QAAQ;IAAMR;CAAa;AAU5G,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/YAMLEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export * from "./YAMLEditor.js";
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/YAMLEditor/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 './YAMLEditor';\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,kBAAe"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Diagnostic } from '@codemirror/lint';
|
|
2
|
+
/**
|
|
3
|
+
* Parse the given text as YAML and return a CodeMirror diagnostic for each syntax error and warning.
|
|
4
|
+
*/
|
|
5
|
+
export declare function yamlDiagnostics(text: string): Diagnostic[];
|
|
6
|
+
/**
|
|
7
|
+
* Convert the initial value given to the editor into YAML text. Strings are kept as is, so that
|
|
8
|
+
* already serialized content (YAML or JSON) is displayed untouched.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toYAMLText(value: unknown): string;
|
|
11
|
+
//# sourceMappingURL=yaml-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-utils.d.ts","sourceRoot":"","sources":["../../src/YAMLEditor/yaml-utils.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAUnD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQjD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { parseAllDocuments, stringify } from "yaml";
|
|
14
|
+
function toDiagnostic(text, problem, severity) {
|
|
15
|
+
const from = Math.min(problem.pos[0], text.length);
|
|
16
|
+
const to = Math.min(Math.max(problem.pos[1], from), text.length);
|
|
17
|
+
return {
|
|
18
|
+
from,
|
|
19
|
+
to,
|
|
20
|
+
severity,
|
|
21
|
+
message: problem.message
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse the given text as YAML and return a CodeMirror diagnostic for each syntax error and warning.
|
|
26
|
+
*/ export function yamlDiagnostics(text) {
|
|
27
|
+
const diagnostics = [];
|
|
28
|
+
// Pretty errors embed a code frame in the message, which is redundant with the lint underline.
|
|
29
|
+
for (const doc of parseAllDocuments(text, {
|
|
30
|
+
prettyErrors: false
|
|
31
|
+
})){
|
|
32
|
+
diagnostics.push(...doc.errors.map((error)=>toDiagnostic(text, error, 'error')));
|
|
33
|
+
diagnostics.push(...doc.warnings.map((warning)=>toDiagnostic(text, warning, 'warning')));
|
|
34
|
+
}
|
|
35
|
+
return diagnostics;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert the initial value given to the editor into YAML text. Strings are kept as is, so that
|
|
39
|
+
* already serialized content (YAML or JSON) is displayed untouched.
|
|
40
|
+
*/ export function toYAMLText(value) {
|
|
41
|
+
if (value === undefined) {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === 'string') {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return stringify(value, {
|
|
48
|
+
schema: 'yaml-1.1'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=yaml-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/YAMLEditor/yaml-utils.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 type { Diagnostic } from '@codemirror/lint';\nimport type { YAMLError, YAMLWarning } from 'yaml';\nimport { parseAllDocuments, stringify } from 'yaml';\n\nfunction toDiagnostic(text: string, problem: YAMLError | YAMLWarning, severity: Diagnostic['severity']): Diagnostic {\n const from = Math.min(problem.pos[0], text.length);\n const to = Math.min(Math.max(problem.pos[1], from), text.length);\n return { from, to, severity, message: problem.message };\n}\n\n/**\n * Parse the given text as YAML and return a CodeMirror diagnostic for each syntax error and warning.\n */\nexport function yamlDiagnostics(text: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n // Pretty errors embed a code frame in the message, which is redundant with the lint underline.\n for (const doc of parseAllDocuments(text, { prettyErrors: false })) {\n diagnostics.push(...doc.errors.map((error) => toDiagnostic(text, error, 'error')));\n diagnostics.push(...doc.warnings.map((warning) => toDiagnostic(text, warning, 'warning')));\n }\n return diagnostics;\n}\n\n/**\n * Convert the initial value given to the editor into YAML text. Strings are kept as is, so that\n * already serialized content (YAML or JSON) is displayed untouched.\n */\nexport function toYAMLText(value: unknown): string {\n if (value === undefined) {\n return '';\n }\n if (typeof value === 'string') {\n return value;\n }\n return stringify(value, { schema: 'yaml-1.1' });\n}\n"],"names":["parseAllDocuments","stringify","toDiagnostic","text","problem","severity","from","Math","min","pos","length","to","max","message","yamlDiagnostics","diagnostics","doc","prettyErrors","push","errors","map","error","warnings","warning","toYAMLText","value","undefined","schema"],"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;AAIjC,SAASA,iBAAiB,EAAEC,SAAS,QAAQ,OAAO;AAEpD,SAASC,aAAaC,IAAY,EAAEC,OAAgC,EAAEC,QAAgC;IACpG,MAAMC,OAAOC,KAAKC,GAAG,CAACJ,QAAQK,GAAG,CAAC,EAAE,EAAEN,KAAKO,MAAM;IACjD,MAAMC,KAAKJ,KAAKC,GAAG,CAACD,KAAKK,GAAG,CAACR,QAAQK,GAAG,CAAC,EAAE,EAAEH,OAAOH,KAAKO,MAAM;IAC/D,OAAO;QAAEJ;QAAMK;QAAIN;QAAUQ,SAAST,QAAQS,OAAO;IAAC;AACxD;AAEA;;CAEC,GACD,OAAO,SAASC,gBAAgBX,IAAY;IAC1C,MAAMY,cAA4B,EAAE;IACpC,+FAA+F;IAC/F,KAAK,MAAMC,OAAOhB,kBAAkBG,MAAM;QAAEc,cAAc;IAAM,GAAI;QAClEF,YAAYG,IAAI,IAAIF,IAAIG,MAAM,CAACC,GAAG,CAAC,CAACC,QAAUnB,aAAaC,MAAMkB,OAAO;QACxEN,YAAYG,IAAI,IAAIF,IAAIM,QAAQ,CAACF,GAAG,CAAC,CAACG,UAAYrB,aAAaC,MAAMoB,SAAS;IAChF;IACA,OAAOR;AACT;AAEA;;;CAGC,GACD,OAAO,SAASS,WAAWC,KAAc;IACvC,IAAIA,UAAUC,WAAW;QACvB,OAAO;IACT;IACA,IAAI,OAAOD,UAAU,UAAU;QAC7B,OAAOA;IACT;IACA,OAAOxB,UAAUwB,OAAO;QAAEE,QAAQ;IAAW;AAC/C"}
|