@perses-dev/components 0.55.0-rc.1 → 0.56.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +284 -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 +387 -219
- 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 +74 -53
- 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 -209
- 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/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js +5 -2
- package/dist/utils/time-series-data.js.map +1 -1
- package/package.json +13 -7
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { c as _c } from "react-compiler-runtime";
|
|
14
15
|
import { Switch, TextField } from "@mui/material";
|
|
15
16
|
import { isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues, supportsCustomLabel } from "../model/index.js";
|
|
16
17
|
import { OptionsEditorControl } from "../OptionsEditorLayout/index.js";
|
|
@@ -18,132 +19,278 @@ import { SettingsAutocomplete } from "../SettingsAutocomplete/index.js";
|
|
|
18
19
|
import { UnitSelector } from "./UnitSelector.js";
|
|
19
20
|
const DECIMAL_PLACES_OPTIONS = [
|
|
20
21
|
{
|
|
21
|
-
id:
|
|
22
|
-
label:
|
|
22
|
+
id: "default",
|
|
23
|
+
label: "Default",
|
|
23
24
|
decimalPlaces: undefined
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
|
-
id:
|
|
27
|
-
label:
|
|
27
|
+
id: "0",
|
|
28
|
+
label: "0",
|
|
28
29
|
decimalPlaces: 0
|
|
29
30
|
},
|
|
30
31
|
{
|
|
31
|
-
id:
|
|
32
|
-
label:
|
|
32
|
+
id: "1",
|
|
33
|
+
label: "1",
|
|
33
34
|
decimalPlaces: 1
|
|
34
35
|
},
|
|
35
36
|
{
|
|
36
|
-
id:
|
|
37
|
-
label:
|
|
37
|
+
id: "2",
|
|
38
|
+
label: "2",
|
|
38
39
|
decimalPlaces: 2
|
|
39
40
|
},
|
|
40
41
|
{
|
|
41
|
-
id:
|
|
42
|
-
label:
|
|
42
|
+
id: "3",
|
|
43
|
+
label: "3",
|
|
43
44
|
decimalPlaces: 3
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
|
-
id:
|
|
47
|
-
label:
|
|
47
|
+
id: "4",
|
|
48
|
+
label: "4",
|
|
48
49
|
decimalPlaces: 4
|
|
49
50
|
}
|
|
50
51
|
];
|
|
51
52
|
function getOptionByDecimalPlaces(decimalPlaces) {
|
|
52
53
|
return DECIMAL_PLACES_OPTIONS.find((o)=>o.decimalPlaces === decimalPlaces);
|
|
53
54
|
}
|
|
54
|
-
export function FormatControls(
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
export function FormatControls(t0) {
|
|
56
|
+
const $ = _c(49);
|
|
57
|
+
const { value, onChange, disabled: t1 } = t0;
|
|
58
|
+
const disabled = t1 === undefined ? false : t1;
|
|
59
|
+
let t2;
|
|
60
|
+
if ($[0] !== value) {
|
|
61
|
+
t2 = isUnitWithDecimalPlaces(value);
|
|
62
|
+
$[0] = value;
|
|
63
|
+
$[1] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t2 = $[1];
|
|
66
|
+
}
|
|
67
|
+
const hasDecimalPlaces = t2;
|
|
68
|
+
let t3;
|
|
69
|
+
if ($[2] !== value) {
|
|
70
|
+
t3 = isUnitWithShortValues(value);
|
|
71
|
+
$[2] = value;
|
|
72
|
+
$[3] = t3;
|
|
73
|
+
} else {
|
|
74
|
+
t3 = $[3];
|
|
75
|
+
}
|
|
76
|
+
const hasShortValues = t3;
|
|
77
|
+
let t4;
|
|
78
|
+
if ($[4] !== onChange || $[5] !== value.customLabel) {
|
|
79
|
+
t4 = (newValue)=>{
|
|
80
|
+
const next = newValue || {
|
|
81
|
+
unit: "decimal"
|
|
82
|
+
};
|
|
83
|
+
const customLabel = value.customLabel?.trim();
|
|
84
|
+
if (customLabel && supportsCustomLabel(next.unit)) {
|
|
85
|
+
onChange({
|
|
86
|
+
...next,
|
|
87
|
+
customLabel: value.customLabel
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
onChange(next);
|
|
60
92
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
$[4] = onChange;
|
|
94
|
+
$[5] = value.customLabel;
|
|
95
|
+
$[6] = t4;
|
|
96
|
+
} else {
|
|
97
|
+
t4 = $[6];
|
|
98
|
+
}
|
|
99
|
+
const handleUnitChange = t4;
|
|
100
|
+
let t5;
|
|
101
|
+
if ($[7] !== value.unit) {
|
|
102
|
+
t5 = supportsCustomLabel(value.unit);
|
|
103
|
+
$[7] = value.unit;
|
|
104
|
+
$[8] = t5;
|
|
105
|
+
} else {
|
|
106
|
+
t5 = $[8];
|
|
107
|
+
}
|
|
108
|
+
const showCustomLabel = t5;
|
|
109
|
+
let t6;
|
|
110
|
+
if ($[9] !== hasDecimalPlaces || $[10] !== onChange || $[11] !== value) {
|
|
111
|
+
t6 = (t7)=>{
|
|
112
|
+
const { decimalPlaces } = t7;
|
|
113
|
+
if (hasDecimalPlaces) {
|
|
114
|
+
onChange({
|
|
115
|
+
...value,
|
|
116
|
+
decimalPlaces
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
$[9] = hasDecimalPlaces;
|
|
121
|
+
$[10] = onChange;
|
|
122
|
+
$[11] = value;
|
|
123
|
+
$[12] = t6;
|
|
124
|
+
} else {
|
|
125
|
+
t6 = $[12];
|
|
126
|
+
}
|
|
127
|
+
const handleDecimalPlacesChange = t6;
|
|
128
|
+
let t7;
|
|
129
|
+
if ($[13] !== hasShortValues || $[14] !== onChange || $[15] !== value) {
|
|
130
|
+
t7 = (_, checked)=>{
|
|
131
|
+
if (hasShortValues) {
|
|
132
|
+
onChange({
|
|
133
|
+
...value,
|
|
134
|
+
shortValues: checked
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
$[13] = hasShortValues;
|
|
139
|
+
$[14] = onChange;
|
|
140
|
+
$[15] = value;
|
|
141
|
+
$[16] = t7;
|
|
142
|
+
} else {
|
|
143
|
+
t7 = $[16];
|
|
144
|
+
}
|
|
145
|
+
const handleShortValuesChange = t7;
|
|
146
|
+
let t8;
|
|
147
|
+
if ($[17] !== onChange || $[18] !== value) {
|
|
148
|
+
t8 = (raw)=>{
|
|
149
|
+
if (raw === "") {
|
|
150
|
+
const { customLabel: _removed, ...rest } = value;
|
|
151
|
+
onChange(rest);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
83
154
|
onChange({
|
|
84
155
|
...value,
|
|
85
|
-
|
|
156
|
+
customLabel: raw
|
|
86
157
|
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
158
|
+
};
|
|
159
|
+
$[17] = onChange;
|
|
160
|
+
$[18] = value;
|
|
161
|
+
$[19] = t8;
|
|
162
|
+
} else {
|
|
163
|
+
t8 = $[19];
|
|
164
|
+
}
|
|
165
|
+
const handleCustomLabelChange = t8;
|
|
166
|
+
let t9;
|
|
167
|
+
if ($[20] !== hasShortValues || $[21] !== value.shortValues) {
|
|
168
|
+
t9 = hasShortValues ? shouldShortenValues(value.shortValues) : false;
|
|
169
|
+
$[20] = hasShortValues;
|
|
170
|
+
$[21] = value.shortValues;
|
|
171
|
+
$[22] = t9;
|
|
172
|
+
} else {
|
|
173
|
+
t9 = $[22];
|
|
174
|
+
}
|
|
175
|
+
const t10 = !hasShortValues;
|
|
176
|
+
let t11;
|
|
177
|
+
if ($[23] !== handleShortValuesChange || $[24] !== t10 || $[25] !== t9) {
|
|
178
|
+
t11 = /*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
179
|
+
label: "Short values",
|
|
180
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
181
|
+
checked: t9,
|
|
182
|
+
onChange: handleShortValuesChange,
|
|
183
|
+
disabled: t10
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
$[23] = handleShortValuesChange;
|
|
187
|
+
$[24] = t10;
|
|
188
|
+
$[25] = t9;
|
|
189
|
+
$[26] = t11;
|
|
190
|
+
} else {
|
|
191
|
+
t11 = $[26];
|
|
192
|
+
}
|
|
193
|
+
let t12;
|
|
194
|
+
if ($[27] !== disabled || $[28] !== handleUnitChange || $[29] !== value) {
|
|
195
|
+
t12 = /*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
196
|
+
label: "Unit",
|
|
197
|
+
control: /*#__PURE__*/ _jsx(UnitSelector, {
|
|
198
|
+
value: value,
|
|
199
|
+
onChange: handleUnitChange,
|
|
200
|
+
disabled: disabled
|
|
201
|
+
})
|
|
99
202
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/*#__PURE__*/ _jsx(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
size: "small",
|
|
123
|
-
fullWidth: true,
|
|
124
|
-
value: value.customLabel ?? '',
|
|
125
|
-
onChange: (e)=>handleCustomLabelChange(e.target.value),
|
|
126
|
-
placeholder: "Optional display override (e.g. pnr/mn)",
|
|
127
|
-
disabled: disabled,
|
|
128
|
-
inputProps: {
|
|
129
|
-
'aria-label': 'custom unit label',
|
|
130
|
-
maxLength: 32
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
}),
|
|
134
|
-
/*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
135
|
-
label: "Decimals",
|
|
136
|
-
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
137
|
-
value: getOptionByDecimalPlaces(value.decimalPlaces),
|
|
138
|
-
options: DECIMAL_PLACES_OPTIONS,
|
|
139
|
-
getOptionLabel: (o)=>o.label,
|
|
140
|
-
onChange: (_, value)=>handleDecimalPlacesChange(value),
|
|
141
|
-
disabled: !hasDecimalPlaces,
|
|
142
|
-
disableClearable: true
|
|
143
|
-
})
|
|
203
|
+
$[27] = disabled;
|
|
204
|
+
$[28] = handleUnitChange;
|
|
205
|
+
$[29] = value;
|
|
206
|
+
$[30] = t12;
|
|
207
|
+
} else {
|
|
208
|
+
t12 = $[30];
|
|
209
|
+
}
|
|
210
|
+
let t13;
|
|
211
|
+
if ($[31] !== disabled || $[32] !== handleCustomLabelChange || $[33] !== showCustomLabel || $[34] !== value.customLabel) {
|
|
212
|
+
t13 = showCustomLabel && /*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
213
|
+
label: "Custom label",
|
|
214
|
+
control: /*#__PURE__*/ _jsx(TextField, {
|
|
215
|
+
size: "small",
|
|
216
|
+
fullWidth: true,
|
|
217
|
+
value: value.customLabel ?? "",
|
|
218
|
+
onChange: (e)=>handleCustomLabelChange(e.target.value),
|
|
219
|
+
placeholder: "Optional display override (e.g. pnr/mn)",
|
|
220
|
+
disabled: disabled,
|
|
221
|
+
inputProps: {
|
|
222
|
+
"aria-label": "custom unit label",
|
|
223
|
+
maxLength: 32
|
|
224
|
+
}
|
|
144
225
|
})
|
|
145
|
-
|
|
146
|
-
|
|
226
|
+
});
|
|
227
|
+
$[31] = disabled;
|
|
228
|
+
$[32] = handleCustomLabelChange;
|
|
229
|
+
$[33] = showCustomLabel;
|
|
230
|
+
$[34] = value.customLabel;
|
|
231
|
+
$[35] = t13;
|
|
232
|
+
} else {
|
|
233
|
+
t13 = $[35];
|
|
234
|
+
}
|
|
235
|
+
let t14;
|
|
236
|
+
if ($[36] !== value.decimalPlaces) {
|
|
237
|
+
t14 = getOptionByDecimalPlaces(value.decimalPlaces);
|
|
238
|
+
$[36] = value.decimalPlaces;
|
|
239
|
+
$[37] = t14;
|
|
240
|
+
} else {
|
|
241
|
+
t14 = $[37];
|
|
242
|
+
}
|
|
243
|
+
let t15;
|
|
244
|
+
if ($[38] !== handleDecimalPlacesChange) {
|
|
245
|
+
t15 = (__0, value_0)=>handleDecimalPlacesChange(value_0);
|
|
246
|
+
$[38] = handleDecimalPlacesChange;
|
|
247
|
+
$[39] = t15;
|
|
248
|
+
} else {
|
|
249
|
+
t15 = $[39];
|
|
250
|
+
}
|
|
251
|
+
const t16 = !hasDecimalPlaces;
|
|
252
|
+
let t17;
|
|
253
|
+
if ($[40] !== t14 || $[41] !== t15 || $[42] !== t16) {
|
|
254
|
+
t17 = /*#__PURE__*/ _jsx(OptionsEditorControl, {
|
|
255
|
+
label: "Decimals",
|
|
256
|
+
control: /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
257
|
+
value: t14,
|
|
258
|
+
options: DECIMAL_PLACES_OPTIONS,
|
|
259
|
+
getOptionLabel: _temp,
|
|
260
|
+
onChange: t15,
|
|
261
|
+
disabled: t16,
|
|
262
|
+
disableClearable: true
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
$[40] = t14;
|
|
266
|
+
$[41] = t15;
|
|
267
|
+
$[42] = t16;
|
|
268
|
+
$[43] = t17;
|
|
269
|
+
} else {
|
|
270
|
+
t17 = $[43];
|
|
271
|
+
}
|
|
272
|
+
let t18;
|
|
273
|
+
if ($[44] !== t11 || $[45] !== t12 || $[46] !== t13 || $[47] !== t17) {
|
|
274
|
+
t18 = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
275
|
+
children: [
|
|
276
|
+
t11,
|
|
277
|
+
t12,
|
|
278
|
+
t13,
|
|
279
|
+
t17
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
$[44] = t11;
|
|
283
|
+
$[45] = t12;
|
|
284
|
+
$[46] = t13;
|
|
285
|
+
$[47] = t17;
|
|
286
|
+
$[48] = t18;
|
|
287
|
+
} else {
|
|
288
|
+
t18 = $[48];
|
|
289
|
+
}
|
|
290
|
+
return t18;
|
|
291
|
+
}
|
|
292
|
+
function _temp(o) {
|
|
293
|
+
return o.label;
|
|
147
294
|
}
|
|
148
295
|
|
|
149
296
|
//# sourceMappingURL=FormatControls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/FormatControls/FormatControls.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.\nimport type { SwitchProps } from '@mui/material';\nimport { Switch, TextField } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nimport type { FormatOptions } from '../model';\nimport { isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues, supportsCustomLabel } from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\nimport { UnitSelector } from './UnitSelector';\n\nexport interface FormatControlsProps {\n value: FormatOptions;\n onChange: (unit: FormatOptions) => void;\n disabled?: boolean;\n}\n\nconst DECIMAL_PLACES_OPTIONS: Array<{ id: string; label: string; decimalPlaces?: number }> = [\n { id: 'default', label: 'Default', decimalPlaces: undefined },\n { id: '0', label: '0', decimalPlaces: 0 },\n { id: '1', label: '1', decimalPlaces: 1 },\n { id: '2', label: '2', decimalPlaces: 2 },\n { id: '3', label: '3', decimalPlaces: 3 },\n { id: '4', label: '4', decimalPlaces: 4 },\n];\n\nfunction getOptionByDecimalPlaces(\n decimalPlaces?: number,\n): { id: string; label: string; decimalPlaces?: number } | undefined {\n return DECIMAL_PLACES_OPTIONS.find((o) => o.decimalPlaces === decimalPlaces);\n}\n\nexport function FormatControls({ value, onChange, disabled = false }: FormatControlsProps): ReactElement {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasShortValues = isUnitWithShortValues(value);\n\n const handleUnitChange = (newValue: FormatOptions | undefined): void => {\n const next = newValue || { unit: 'decimal' };\n const customLabel = value.customLabel?.trim();\n // Keep label only when the new unit supports customLabel (whitelist).\n if (customLabel && supportsCustomLabel(next.unit)) {\n onChange({ ...next, customLabel: value.customLabel });\n return;\n }\n onChange(next);\n };\n\n const showCustomLabel = supportsCustomLabel(value.unit);\n\n const handleDecimalPlacesChange = ({\n decimalPlaces,\n }: {\n id: string;\n label: string;\n decimalPlaces?: number;\n }): void => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimalPlaces: decimalPlaces,\n });\n }\n };\n\n const handleShortValuesChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasShortValues) {\n onChange({\n ...value,\n shortValues: checked,\n });\n }\n };\n\n const handleCustomLabelChange = (raw: string): void => {\n // Keep raw input while typing (spaces allowed). Trim only when clearing / display.\n if (raw === '') {\n const { customLabel: _removed, ...rest } = value;\n onChange(rest as FormatOptions);\n return;\n }\n onChange({ ...value, customLabel: raw });\n };\n\n return (\n <>\n <OptionsEditorControl\n label=\"Short values\"\n control={\n <Switch\n checked={hasShortValues ? shouldShortenValues(value.shortValues) : false}\n onChange={handleShortValuesChange}\n disabled={!hasShortValues}\n />\n }\n />\n <OptionsEditorControl\n label=\"Unit\"\n control={<UnitSelector value={value} onChange={handleUnitChange} disabled={disabled} />}\n />\n {showCustomLabel && (\n <OptionsEditorControl\n label=\"Custom label\"\n control={\n <TextField\n size=\"small\"\n fullWidth\n value={value.customLabel ?? ''}\n onChange={(e) => handleCustomLabelChange(e.target.value)}\n placeholder=\"Optional display override (e.g. pnr/mn)\"\n disabled={disabled}\n inputProps={{ 'aria-label': 'custom unit label', maxLength: 32 }}\n />\n }\n />\n )}\n <OptionsEditorControl\n label=\"Decimals\"\n control={\n <SettingsAutocomplete\n value={getOptionByDecimalPlaces(value.decimalPlaces)}\n options={DECIMAL_PLACES_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={(_, value) => handleDecimalPlacesChange(value)}\n disabled={!hasDecimalPlaces}\n disableClearable\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","TextField","isUnitWithDecimalPlaces","isUnitWithShortValues","shouldShortenValues","supportsCustomLabel","OptionsEditorControl","SettingsAutocomplete","UnitSelector","DECIMAL_PLACES_OPTIONS","id","label","decimalPlaces","undefined","getOptionByDecimalPlaces","find","o"
|
|
1
|
+
{"version":3,"sources":["../../src/FormatControls/FormatControls.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.\nimport type { SwitchProps } from '@mui/material';\nimport { Switch, TextField } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nimport type { FormatOptions } from '../model';\nimport { isUnitWithDecimalPlaces, isUnitWithShortValues, shouldShortenValues, supportsCustomLabel } from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\nimport { UnitSelector } from './UnitSelector';\n\nexport interface FormatControlsProps {\n value: FormatOptions;\n onChange: (unit: FormatOptions) => void;\n disabled?: boolean;\n}\n\nconst DECIMAL_PLACES_OPTIONS: Array<{ id: string; label: string; decimalPlaces?: number }> = [\n { id: 'default', label: 'Default', decimalPlaces: undefined },\n { id: '0', label: '0', decimalPlaces: 0 },\n { id: '1', label: '1', decimalPlaces: 1 },\n { id: '2', label: '2', decimalPlaces: 2 },\n { id: '3', label: '3', decimalPlaces: 3 },\n { id: '4', label: '4', decimalPlaces: 4 },\n];\n\nfunction getOptionByDecimalPlaces(\n decimalPlaces?: number,\n): { id: string; label: string; decimalPlaces?: number } | undefined {\n return DECIMAL_PLACES_OPTIONS.find((o) => o.decimalPlaces === decimalPlaces);\n}\n\nexport function FormatControls({ value, onChange, disabled = false }: FormatControlsProps): ReactElement {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasShortValues = isUnitWithShortValues(value);\n\n const handleUnitChange = (newValue: FormatOptions | undefined): void => {\n const next = newValue || { unit: 'decimal' };\n const customLabel = value.customLabel?.trim();\n // Keep label only when the new unit supports customLabel (whitelist).\n if (customLabel && supportsCustomLabel(next.unit)) {\n onChange({ ...next, customLabel: value.customLabel });\n return;\n }\n onChange(next);\n };\n\n const showCustomLabel = supportsCustomLabel(value.unit);\n\n const handleDecimalPlacesChange = ({\n decimalPlaces,\n }: {\n id: string;\n label: string;\n decimalPlaces?: number;\n }): void => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimalPlaces: decimalPlaces,\n });\n }\n };\n\n const handleShortValuesChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasShortValues) {\n onChange({\n ...value,\n shortValues: checked,\n });\n }\n };\n\n const handleCustomLabelChange = (raw: string): void => {\n // Keep raw input while typing (spaces allowed). Trim only when clearing / display.\n if (raw === '') {\n const { customLabel: _removed, ...rest } = value;\n onChange(rest as FormatOptions);\n return;\n }\n onChange({ ...value, customLabel: raw });\n };\n\n return (\n <>\n <OptionsEditorControl\n label=\"Short values\"\n control={\n <Switch\n checked={hasShortValues ? shouldShortenValues(value.shortValues) : false}\n onChange={handleShortValuesChange}\n disabled={!hasShortValues}\n />\n }\n />\n <OptionsEditorControl\n label=\"Unit\"\n control={<UnitSelector value={value} onChange={handleUnitChange} disabled={disabled} />}\n />\n {showCustomLabel && (\n <OptionsEditorControl\n label=\"Custom label\"\n control={\n <TextField\n size=\"small\"\n fullWidth\n value={value.customLabel ?? ''}\n onChange={(e) => handleCustomLabelChange(e.target.value)}\n placeholder=\"Optional display override (e.g. pnr/mn)\"\n disabled={disabled}\n inputProps={{ 'aria-label': 'custom unit label', maxLength: 32 }}\n />\n }\n />\n )}\n <OptionsEditorControl\n label=\"Decimals\"\n control={\n <SettingsAutocomplete\n value={getOptionByDecimalPlaces(value.decimalPlaces)}\n options={DECIMAL_PLACES_OPTIONS}\n getOptionLabel={(o) => o.label}\n onChange={(_, value) => handleDecimalPlacesChange(value)}\n disabled={!hasDecimalPlaces}\n disableClearable\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","TextField","isUnitWithDecimalPlaces","isUnitWithShortValues","shouldShortenValues","supportsCustomLabel","OptionsEditorControl","SettingsAutocomplete","UnitSelector","DECIMAL_PLACES_OPTIONS","id","label","decimalPlaces","undefined","getOptionByDecimalPlaces","find","o"],"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,SAAS,QAAQ,gBAAgB;AAIlD,SAASC,uBAAuB,EAAEC,qBAAqB,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,oBAAW;AACpH,SAASC,oBAAoB,QAAQ,kCAAyB;AAC9D,SAASC,oBAAoB,QAAQ,mCAA0B;AAC/D,SAASC,YAAY,QAAQ,oBAAiB;AAQ9C,MAAMC,yBAAuF;IAC3F;QAAEC,IAAI;QAAWC,OAAO;QAAWC,eAAeC;IAAU;IAC5D;QAAEH,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;IACxC;QAAEF,IAAI;QAAKC,OAAO;QAAKC,eAAe;IAAE;CACzC;AAED,SAASE,yBACPF,aAAa;IAEb,OAAOH,uBAAuBM,IAAI,CAAC,CAACC,IAAMA,EAAEJ,aAAa,KAAKA;AAChE;AAEA,OAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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.
|
|
@@ -19,31 +20,65 @@ const KIND_OPTIONS = Object.entries(UNIT_CONFIG).map(([id, config])=>{
|
|
|
19
20
|
return {
|
|
20
21
|
...config,
|
|
21
22
|
id: id,
|
|
22
|
-
group: config.group ||
|
|
23
|
+
group: config.group || "Decimal"
|
|
23
24
|
};
|
|
24
25
|
}).filter((config)=>!config.disableSelectorOption);
|
|
25
|
-
export function UnitSelector(
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
value
|
|
38
|
-
|
|
26
|
+
export function UnitSelector(t0) {
|
|
27
|
+
const $ = _c(19);
|
|
28
|
+
let onChange;
|
|
29
|
+
let otherProps;
|
|
30
|
+
let t1;
|
|
31
|
+
let value;
|
|
32
|
+
if ($[0] !== t0) {
|
|
33
|
+
({ value, onChange, disabled: t1, ...otherProps } = t0);
|
|
34
|
+
$[0] = t0;
|
|
35
|
+
$[1] = onChange;
|
|
36
|
+
$[2] = otherProps;
|
|
37
|
+
$[3] = t1;
|
|
38
|
+
$[4] = value;
|
|
39
|
+
} else {
|
|
40
|
+
onChange = $[1];
|
|
41
|
+
otherProps = $[2];
|
|
42
|
+
t1 = $[3];
|
|
43
|
+
value = $[4];
|
|
44
|
+
}
|
|
45
|
+
const disabled = t1 === undefined ? false : t1;
|
|
46
|
+
const unitConfig = UNIT_CONFIG[value?.unit || "decimal"];
|
|
47
|
+
let t2;
|
|
48
|
+
if ($[5] !== onChange) {
|
|
49
|
+
t2 = (_, newValue)=>{
|
|
50
|
+
if (newValue === null) {
|
|
51
|
+
onChange(undefined);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
onChange({
|
|
55
|
+
unit: newValue.id
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
$[5] = onChange;
|
|
59
|
+
$[6] = t2;
|
|
60
|
+
} else {
|
|
61
|
+
t2 = $[6];
|
|
62
|
+
}
|
|
63
|
+
const handleChange = t2;
|
|
64
|
+
const t3 = value?.unit || "decimal";
|
|
65
|
+
let t4;
|
|
66
|
+
if ($[7] !== t3 || $[8] !== unitConfig) {
|
|
67
|
+
t4 = {
|
|
68
|
+
id: t3,
|
|
39
69
|
...unitConfig
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
70
|
+
};
|
|
71
|
+
$[7] = t3;
|
|
72
|
+
$[8] = unitConfig;
|
|
73
|
+
$[9] = t4;
|
|
74
|
+
} else {
|
|
75
|
+
t4 = $[9];
|
|
76
|
+
}
|
|
77
|
+
let t5;
|
|
78
|
+
if ($[10] !== disabled || $[11] !== onChange) {
|
|
79
|
+
t5 = (t6)=>{
|
|
80
|
+
const { InputProps, ...params } = t6;
|
|
81
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
47
82
|
...params,
|
|
48
83
|
slotProps: {
|
|
49
84
|
input: {
|
|
@@ -68,9 +103,39 @@ export function UnitSelector({ value, onChange, disabled = false, ...otherProps
|
|
|
68
103
|
})
|
|
69
104
|
}
|
|
70
105
|
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
$[10] = disabled;
|
|
109
|
+
$[11] = onChange;
|
|
110
|
+
$[12] = t5;
|
|
111
|
+
} else {
|
|
112
|
+
t5 = $[12];
|
|
113
|
+
}
|
|
114
|
+
let t6;
|
|
115
|
+
if ($[13] !== disabled || $[14] !== handleChange || $[15] !== otherProps || $[16] !== t4 || $[17] !== t5) {
|
|
116
|
+
t6 = /*#__PURE__*/ _jsx(SettingsAutocomplete, {
|
|
117
|
+
value: t4,
|
|
118
|
+
options: KIND_OPTIONS,
|
|
119
|
+
groupBy: _temp,
|
|
120
|
+
onChange: handleChange,
|
|
121
|
+
disabled: disabled,
|
|
122
|
+
disableClearable: true,
|
|
123
|
+
renderInput: t5,
|
|
124
|
+
...otherProps
|
|
125
|
+
});
|
|
126
|
+
$[13] = disabled;
|
|
127
|
+
$[14] = handleChange;
|
|
128
|
+
$[15] = otherProps;
|
|
129
|
+
$[16] = t4;
|
|
130
|
+
$[17] = t5;
|
|
131
|
+
$[18] = t6;
|
|
132
|
+
} else {
|
|
133
|
+
t6 = $[18];
|
|
134
|
+
}
|
|
135
|
+
return t6;
|
|
136
|
+
}
|
|
137
|
+
function _temp(option) {
|
|
138
|
+
return option.group ?? "Decimal";
|
|
74
139
|
}
|
|
75
140
|
|
|
76
141
|
//# sourceMappingURL=UnitSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/FormatControls/UnitSelector.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 { IconButton, InputAdornment, TextField } from '@mui/material';\nimport ClearIcon from 'mdi-material-ui/Close';\nimport type { ReactElement } from 'react';\n\nimport type { FormatOptions, UnitConfig } from '../model';\nimport { UNIT_CONFIG } from '../model';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nexport interface UnitSelectorProps {\n value?: FormatOptions;\n onChange: (format: FormatOptions | undefined) => void;\n disabled?: boolean;\n}\n\ntype AutocompleteUnitOption = UnitConfig & {\n id: NonNullable<FormatOptions['unit']>;\n};\n\nconst KIND_OPTIONS: readonly AutocompleteUnitOption[] = Object.entries(UNIT_CONFIG)\n .map<AutocompleteUnitOption>(([id, config]) => {\n return {\n ...config,\n id: id as AutocompleteUnitOption['id'],\n group: config.group || 'Decimal',\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nexport function UnitSelector({ value, onChange, disabled = false, ...otherProps }: UnitSelectorProps): ReactElement {\n const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];\n\n const handleChange = (_: unknown, newValue: AutocompleteUnitOption | null): void => {\n if (newValue === null) {\n onChange(undefined);\n return;\n }\n onChange({ unit: newValue.id } as FormatOptions);\n };\n\n return (\n <SettingsAutocomplete<AutocompleteUnitOption, false, true>\n value={{ id: value?.unit || 'decimal', ...unitConfig }}\n options={KIND_OPTIONS}\n groupBy={(option) => option.group ?? 'Decimal'}\n onChange={handleChange}\n disabled={disabled}\n disableClearable\n renderInput={({ InputProps, ...params }) => (\n <TextField\n {...params}\n slotProps={{\n input: {\n ...InputProps,\n endAdornment: (\n <>\n {InputProps.endAdornment}\n <InputAdornment position=\"end\">\n <IconButton\n size=\"small\"\n aria-label=\"clear unit\"\n onClick={() => onChange(undefined)}\n disabled={disabled}\n tabIndex={-1}\n >\n <ClearIcon fontSize=\"small\" />\n </IconButton>\n </InputAdornment>\n </>\n ),\n },\n }}\n />\n )}\n {...otherProps}\n />\n );\n}\n"],"names":["IconButton","InputAdornment","TextField","ClearIcon","UNIT_CONFIG","SettingsAutocomplete","KIND_OPTIONS","Object","entries","map","id","config","group","filter","disableSelectorOption"
|
|
1
|
+
{"version":3,"sources":["../../src/FormatControls/UnitSelector.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 { IconButton, InputAdornment, TextField } from '@mui/material';\nimport ClearIcon from 'mdi-material-ui/Close';\nimport type { ReactElement } from 'react';\n\nimport type { FormatOptions, UnitConfig } from '../model';\nimport { UNIT_CONFIG } from '../model';\nimport { SettingsAutocomplete } from '../SettingsAutocomplete';\n\nexport interface UnitSelectorProps {\n value?: FormatOptions;\n onChange: (format: FormatOptions | undefined) => void;\n disabled?: boolean;\n}\n\ntype AutocompleteUnitOption = UnitConfig & {\n id: NonNullable<FormatOptions['unit']>;\n};\n\nconst KIND_OPTIONS: readonly AutocompleteUnitOption[] = Object.entries(UNIT_CONFIG)\n .map<AutocompleteUnitOption>(([id, config]) => {\n return {\n ...config,\n id: id as AutocompleteUnitOption['id'],\n group: config.group || 'Decimal',\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nexport function UnitSelector({ value, onChange, disabled = false, ...otherProps }: UnitSelectorProps): ReactElement {\n const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];\n\n const handleChange = (_: unknown, newValue: AutocompleteUnitOption | null): void => {\n if (newValue === null) {\n onChange(undefined);\n return;\n }\n onChange({ unit: newValue.id } as FormatOptions);\n };\n\n return (\n <SettingsAutocomplete<AutocompleteUnitOption, false, true>\n value={{ id: value?.unit || 'decimal', ...unitConfig }}\n options={KIND_OPTIONS}\n groupBy={(option) => option.group ?? 'Decimal'}\n onChange={handleChange}\n disabled={disabled}\n disableClearable\n renderInput={({ InputProps, ...params }) => (\n <TextField\n {...params}\n slotProps={{\n input: {\n ...InputProps,\n endAdornment: (\n <>\n {InputProps.endAdornment}\n <InputAdornment position=\"end\">\n <IconButton\n size=\"small\"\n aria-label=\"clear unit\"\n onClick={() => onChange(undefined)}\n disabled={disabled}\n tabIndex={-1}\n >\n <ClearIcon fontSize=\"small\" />\n </IconButton>\n </InputAdornment>\n </>\n ),\n },\n }}\n />\n )}\n {...otherProps}\n />\n );\n}\n"],"names":["IconButton","InputAdornment","TextField","ClearIcon","UNIT_CONFIG","SettingsAutocomplete","KIND_OPTIONS","Object","entries","map","id","config","group","filter","disableSelectorOption"],"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,UAAU,EAAEC,cAAc,EAAEC,SAAS,QAAQ,gBAAgB;AACtE,OAAOC,eAAe,wBAAwB;AAI9C,SAASC,WAAW,QAAQ,oBAAW;AACvC,SAASC,oBAAoB,QAAQ,mCAA0B;AAY/D,MAAMC,eAAkDC,OAAOC,OAAO,CAACJ,aACpEK,GAAG,CAAyB,CAAC,CAACC,IAAIC,OAAO;IACxC,OAAO;QACL,GAAGA,MAAM;QACTD,IAAIA;QACJE,OAAOD,OAAOC,KAAK,IAAI;IACzB;AACF,GACCC,MAAM,CAAC,CAACF,SAAW,CAACA,OAAOG,qBAAqB;AAEnD,OAAO"}
|