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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/AlignSelector/AlignSelector.js +115 -25
  2. package/dist/AlignSelector/AlignSelector.js.map +1 -1
  3. package/dist/CodeEditor/CodeEditor.d.ts +19 -0
  4. package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
  5. package/dist/CodeEditor/CodeEditor.js +122 -0
  6. package/dist/CodeEditor/CodeEditor.js.map +1 -0
  7. package/dist/ColorPicker/ColorPicker.js +153 -61
  8. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  9. package/dist/ColorPicker/OptionsColorPicker.js +147 -52
  10. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  11. package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
  12. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  13. package/dist/DensitySelector/DensitySelector.js +53 -20
  14. package/dist/DensitySelector/DensitySelector.js.map +1 -1
  15. package/dist/Dialog/Dialog.d.ts +3 -2
  16. package/dist/Dialog/Dialog.d.ts.map +1 -1
  17. package/dist/Dialog/Dialog.js +202 -49
  18. package/dist/Dialog/Dialog.js.map +1 -1
  19. package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
  20. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  21. package/dist/DragAndDrop/DragAndDropList.js +184 -113
  22. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  23. package/dist/DragAndDrop/DragButton.js +131 -52
  24. package/dist/DragAndDrop/DragButton.js.map +1 -1
  25. package/dist/DragAndDrop/DropIndicator.js +51 -26
  26. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  27. package/dist/Drawer/Drawer.js +75 -15
  28. package/dist/Drawer/Drawer.js.map +1 -1
  29. package/dist/EChart/EChart.js +179 -90
  30. package/dist/EChart/EChart.js.map +1 -1
  31. package/dist/ErrorAlert.js +14 -4
  32. package/dist/ErrorAlert.js.map +1 -1
  33. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
  34. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
  35. package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
  36. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  37. package/dist/FormEditor/FormActions.js +88 -14
  38. package/dist/FormEditor/FormActions.js.map +1 -1
  39. package/dist/FormatControls/FormatControls.js +246 -99
  40. package/dist/FormatControls/FormatControls.js.map +1 -1
  41. package/dist/FormatControls/UnitSelector.js +90 -25
  42. package/dist/FormatControls/UnitSelector.js.map +1 -1
  43. package/dist/InfoTooltip/InfoTooltip.js +105 -42
  44. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  45. package/dist/JSONEditor.d.ts +2 -6
  46. package/dist/JSONEditor.d.ts.map +1 -1
  47. package/dist/JSONEditor.js +24 -37
  48. package/dist/JSONEditor.js.map +1 -1
  49. package/dist/Legend/CompactLegend.js +77 -27
  50. package/dist/Legend/CompactLegend.js.map +1 -1
  51. package/dist/Legend/Legend.js +184 -82
  52. package/dist/Legend/Legend.js.map +1 -1
  53. package/dist/Legend/LegendColorBadge.js +54 -9
  54. package/dist/Legend/LegendColorBadge.js.map +1 -1
  55. package/dist/Legend/ListLegend.js +46 -16
  56. package/dist/Legend/ListLegend.js.map +1 -1
  57. package/dist/Legend/ListLegendItem.js +184 -48
  58. package/dist/Legend/ListLegendItem.js.map +1 -1
  59. package/dist/Legend/TableLegend.d.ts.map +1 -1
  60. package/dist/Legend/TableLegend.js +90 -48
  61. package/dist/Legend/TableLegend.js.map +1 -1
  62. package/dist/Legend/legend-model.d.ts +2 -2
  63. package/dist/Legend/legend-model.d.ts.map +1 -1
  64. package/dist/Legend/legend-model.js.map +1 -1
  65. package/dist/LinksEditor/LinkEditorForm.js +148 -67
  66. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  67. package/dist/ModeSelector/ModeSelector.js +61 -19
  68. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  69. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
  70. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  71. package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
  72. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  73. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
  74. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  75. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
  76. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  77. package/dist/Overlay/Overlay.js +71 -27
  78. package/dist/Overlay/Overlay.js.map +1 -1
  79. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
  80. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  81. package/dist/RepeatGrid/RepeatGrid.js +117 -45
  82. package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
  83. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
  84. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  85. package/dist/SortSelector/SortSelector.js +51 -18
  86. package/dist/SortSelector/SortSelector.js.map +1 -1
  87. package/dist/SortSelector/SortSelectorButtons.js +109 -25
  88. package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
  89. package/dist/Table/InnerTable.js +46 -15
  90. package/dist/Table/InnerTable.js.map +1 -1
  91. package/dist/Table/Table.d.ts +3 -1
  92. package/dist/Table/Table.d.ts.map +1 -1
  93. package/dist/Table/Table.js +410 -158
  94. package/dist/Table/Table.js.map +1 -1
  95. package/dist/Table/TableBody.js +15 -4
  96. package/dist/Table/TableBody.js.map +1 -1
  97. package/dist/Table/TableCell.js +294 -107
  98. package/dist/Table/TableCell.js.map +1 -1
  99. package/dist/Table/TableCheckbox.js +101 -32
  100. package/dist/Table/TableCheckbox.js.map +1 -1
  101. package/dist/Table/TableFoot.js +15 -4
  102. package/dist/Table/TableFoot.js.map +1 -1
  103. package/dist/Table/TableHead.js +15 -4
  104. package/dist/Table/TableHead.js.map +1 -1
  105. package/dist/Table/TableHeaderCell.js +119 -62
  106. package/dist/Table/TableHeaderCell.js.map +1 -1
  107. package/dist/Table/TableRow.js +33 -9
  108. package/dist/Table/TableRow.js.map +1 -1
  109. package/dist/Table/TableToolbar.d.ts +5 -4
  110. package/dist/Table/TableToolbar.d.ts.map +1 -1
  111. package/dist/Table/TableToolbar.js +172 -100
  112. package/dist/Table/TableToolbar.js.map +1 -1
  113. package/dist/Table/VirtualizedTable.d.ts +11 -11
  114. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  115. package/dist/Table/VirtualizedTable.js +442 -204
  116. package/dist/Table/VirtualizedTable.js.map +1 -1
  117. package/dist/Table/VirtualizedTableContainer.js +27 -7
  118. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  119. package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
  120. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
  121. package/dist/Table/hooks/useFuzzySearch.js +57 -32
  122. package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
  123. package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
  124. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  125. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
  126. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
  127. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +86 -69
  128. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  129. package/dist/Table/model/table-model.d.ts +44 -15
  130. package/dist/Table/model/table-model.d.ts.map +1 -1
  131. package/dist/Table/model/table-model.js +33 -1
  132. package/dist/Table/model/table-model.js.map +1 -1
  133. package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
  134. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  135. package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
  136. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  137. package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
  138. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  139. package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -210
  140. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
  142. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  143. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
  144. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  145. package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
  146. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  147. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
  148. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  149. package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
  150. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  151. package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
  152. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  153. package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
  154. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  155. package/dist/TimeZoneSelector.js +131 -36
  156. package/dist/TimeZoneSelector.js.map +1 -1
  157. package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
  158. package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  159. package/dist/TransformsEditor/TransformEditor.js +830 -334
  160. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  161. package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
  162. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  163. package/dist/TransformsEditor/TransformsEditor.js +170 -59
  164. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  165. package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
  166. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  167. package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
  168. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  169. package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
  170. package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
  171. package/dist/YAMLEditor/YAMLEditor.js +41 -0
  172. package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
  173. package/dist/YAMLEditor/index.d.ts +2 -0
  174. package/dist/YAMLEditor/index.d.ts.map +1 -0
  175. package/dist/YAMLEditor/index.js +15 -0
  176. package/dist/YAMLEditor/index.js.map +1 -0
  177. package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
  178. package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
  179. package/dist/YAMLEditor/yaml-utils.js +52 -0
  180. package/dist/YAMLEditor/yaml-utils.js.map +1 -0
  181. package/dist/YAxisLabel.js +64 -20
  182. package/dist/YAxisLabel.js.map +1 -1
  183. package/dist/context/ChartsProvider.js +32 -16
  184. package/dist/context/ChartsProvider.js.map +1 -1
  185. package/dist/context/ItemActionsProvider.js +110 -61
  186. package/dist/context/ItemActionsProvider.js.map +1 -1
  187. package/dist/context/SelectionProvider.js +170 -66
  188. package/dist/context/SelectionProvider.js.map +1 -1
  189. package/dist/context/SnackbarProvider.js +101 -44
  190. package/dist/context/SnackbarProvider.js.map +1 -1
  191. package/dist/context/TimeZoneProvider.js +35 -14
  192. package/dist/context/TimeZoneProvider.js.map +1 -1
  193. package/dist/controls/TextField.js +86 -25
  194. package/dist/controls/TextField.js.map +1 -1
  195. package/dist/index.d.ts +1 -0
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +1 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/utils/browser-storage.js +64 -34
  200. package/dist/utils/browser-storage.js.map +1 -1
  201. package/package.json +15 -8
@@ -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: 'default',
22
- label: 'Default',
22
+ id: "default",
23
+ label: "Default",
23
24
  decimalPlaces: undefined
24
25
  },
25
26
  {
26
- id: '0',
27
- label: '0',
27
+ id: "0",
28
+ label: "0",
28
29
  decimalPlaces: 0
29
30
  },
30
31
  {
31
- id: '1',
32
- label: '1',
32
+ id: "1",
33
+ label: "1",
33
34
  decimalPlaces: 1
34
35
  },
35
36
  {
36
- id: '2',
37
- label: '2',
37
+ id: "2",
38
+ label: "2",
38
39
  decimalPlaces: 2
39
40
  },
40
41
  {
41
- id: '3',
42
- label: '3',
42
+ id: "3",
43
+ label: "3",
43
44
  decimalPlaces: 3
44
45
  },
45
46
  {
46
- id: '4',
47
- label: '4',
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({ value, onChange, disabled = false }) {
55
- const hasDecimalPlaces = isUnitWithDecimalPlaces(value);
56
- const hasShortValues = isUnitWithShortValues(value);
57
- const handleUnitChange = (newValue)=>{
58
- const next = newValue || {
59
- unit: 'decimal'
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
- const customLabel = value.customLabel?.trim();
62
- // Keep label only when the new unit supports customLabel (whitelist).
63
- if (customLabel && supportsCustomLabel(next.unit)) {
64
- onChange({
65
- ...next,
66
- customLabel: value.customLabel
67
- });
68
- return;
69
- }
70
- onChange(next);
71
- };
72
- const showCustomLabel = supportsCustomLabel(value.unit);
73
- const handleDecimalPlacesChange = ({ decimalPlaces })=>{
74
- if (hasDecimalPlaces) {
75
- onChange({
76
- ...value,
77
- decimalPlaces: decimalPlaces
78
- });
79
- }
80
- };
81
- const handleShortValuesChange = (_, checked)=>{
82
- if (hasShortValues) {
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
- shortValues: checked
156
+ customLabel: raw
86
157
  });
87
- }
88
- };
89
- const handleCustomLabelChange = (raw)=>{
90
- // Keep raw input while typing (spaces allowed). Trim only when clearing / display.
91
- if (raw === '') {
92
- const { customLabel: _removed, ...rest } = value;
93
- onChange(rest);
94
- return;
95
- }
96
- onChange({
97
- ...value,
98
- customLabel: raw
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
- return /*#__PURE__*/ _jsxs(_Fragment, {
102
- children: [
103
- /*#__PURE__*/ _jsx(OptionsEditorControl, {
104
- label: "Short values",
105
- control: /*#__PURE__*/ _jsx(Switch, {
106
- checked: hasShortValues ? shouldShortenValues(value.shortValues) : false,
107
- onChange: handleShortValuesChange,
108
- disabled: !hasShortValues
109
- })
110
- }),
111
- /*#__PURE__*/ _jsx(OptionsEditorControl, {
112
- label: "Unit",
113
- control: /*#__PURE__*/ _jsx(UnitSelector, {
114
- value: value,
115
- onChange: handleUnitChange,
116
- disabled: disabled
117
- })
118
- }),
119
- showCustomLabel && /*#__PURE__*/ _jsx(OptionsEditorControl, {
120
- label: "Custom label",
121
- control: /*#__PURE__*/ _jsx(TextField, {
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","FormatControls","value","onChange","disabled","hasDecimalPlaces","hasShortValues","handleUnitChange","newValue","next","unit","customLabel","trim","showCustomLabel","handleDecimalPlacesChange","handleShortValuesChange","_","checked","shortValues","handleCustomLabelChange","raw","_removed","rest","control","size","fullWidth","e","target","placeholder","inputProps","maxLength","options","getOptionLabel","disableClearable"],"mappings":"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"}
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 || 'Decimal'
23
+ group: config.group || "Decimal"
23
24
  };
24
25
  }).filter((config)=>!config.disableSelectorOption);
25
- export function UnitSelector({ value, onChange, disabled = false, ...otherProps }) {
26
- const unitConfig = UNIT_CONFIG[value?.unit || 'decimal'];
27
- const handleChange = (_, newValue)=>{
28
- if (newValue === null) {
29
- onChange(undefined);
30
- return;
31
- }
32
- onChange({
33
- unit: newValue.id
34
- });
35
- };
36
- return /*#__PURE__*/ _jsx(SettingsAutocomplete, {
37
- value: {
38
- id: value?.unit || 'decimal',
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
- options: KIND_OPTIONS,
42
- groupBy: (option)=>option.group ?? 'Decimal',
43
- onChange: handleChange,
44
- disabled: disabled,
45
- disableClearable: true,
46
- renderInput: ({ InputProps, ...params })=>/*#__PURE__*/ _jsx(TextField, {
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
- ...otherProps
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","UnitSelector","value","onChange","disabled","otherProps","unitConfig","unit","handleChange","_","newValue","undefined","options","groupBy","option","disableClearable","renderInput","InputProps","params","slotProps","input","endAdornment","position","size","aria-label","onClick","tabIndex","fontSize"],"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,SAASC,aAAa,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,KAAK,EAAE,GAAGC,YAA+B;IAClG,MAAMC,aAAahB,WAAW,CAACY,OAAOK,QAAQ,UAAU;IAExD,MAAMC,eAAe,CAACC,GAAYC;QAChC,IAAIA,aAAa,MAAM;YACrBP,SAASQ;YACT;QACF;QACAR,SAAS;YAAEI,MAAMG,SAASd,EAAE;QAAC;IAC/B;IAEA,qBACE,KAACL;QACCW,OAAO;YAAEN,IAAIM,OAAOK,QAAQ;YAAW,GAAGD,UAAU;QAAC;QACrDM,SAASpB;QACTqB,SAAS,CAACC,SAAWA,OAAOhB,KAAK,IAAI;QACrCK,UAAUK;QACVJ,UAAUA;QACVW,gBAAgB;QAChBC,aAAa,CAAC,EAAEC,UAAU,EAAE,GAAGC,QAAQ,iBACrC,KAAC9B;gBACE,GAAG8B,MAAM;gBACVC,WAAW;oBACTC,OAAO;wBACL,GAAGH,UAAU;wBACbI,4BACE;;gCACGJ,WAAWI,YAAY;8CACxB,KAAClC;oCAAemC,UAAS;8CACvB,cAAA,KAACpC;wCACCqC,MAAK;wCACLC,cAAW;wCACXC,SAAS,IAAMtB,SAASQ;wCACxBP,UAAUA;wCACVsB,UAAU,CAAC;kDAEX,cAAA,KAACrC;4CAAUsC,UAAS;;;;;;oBAK9B;gBACF;;QAGH,GAAGtB,UAAU;;AAGpB"}
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"}