@perses-dev/components 0.55.0-beta.8 → 0.55.0-rc.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.
Files changed (108) hide show
  1. package/dist/DragAndDrop/DragAndDropList.d.ts +10 -2
  2. package/dist/DragAndDrop/DragAndDropList.d.ts.map +1 -1
  3. package/dist/DragAndDrop/DragAndDropList.js +6 -4
  4. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  5. package/dist/EChart/EChart.d.ts +1 -1
  6. package/dist/EChart/EChart.d.ts.map +1 -1
  7. package/dist/EChart/EChart.js +12 -25
  8. package/dist/EChart/EChart.js.map +1 -1
  9. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.d.ts +27 -0
  10. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.d.ts.map +1 -0
  11. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +239 -0
  12. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -0
  13. package/dist/ExemplarMetadata/index.d.ts +2 -0
  14. package/dist/ExemplarMetadata/index.d.ts.map +1 -0
  15. package/dist/{utils/component-ids.js → ExemplarMetadata/index.js} +2 -15
  16. package/dist/ExemplarMetadata/index.js.map +1 -0
  17. package/dist/FormatControls/FormatControls.d.ts.map +1 -1
  18. package/dist/FormatControls/FormatControls.js +42 -4
  19. package/dist/FormatControls/FormatControls.js.map +1 -1
  20. package/dist/FormatControls/UnitSelector.js +4 -4
  21. package/dist/FormatControls/UnitSelector.js.map +1 -1
  22. package/dist/Legend/TableLegend.d.ts.map +1 -1
  23. package/dist/Legend/TableLegend.js +2 -1
  24. package/dist/Legend/TableLegend.js.map +1 -1
  25. package/dist/LinksEditor/LinkEditorForm.d.ts +1 -0
  26. package/dist/LinksEditor/LinkEditorForm.d.ts.map +1 -1
  27. package/dist/LinksEditor/LinkEditorForm.js +1 -0
  28. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  29. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -1
  30. package/dist/OptionsEditorLayout/OptionsEditorControl.js +2 -3
  31. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  32. package/dist/SettingsAutocomplete/SettingsAutocomplete.d.ts.map +1 -1
  33. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +6 -3
  34. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  35. package/dist/Table/Table.d.ts.map +1 -1
  36. package/dist/Table/Table.js +3 -0
  37. package/dist/Table/Table.js.map +1 -1
  38. package/dist/Table/TableToolbar.d.ts.map +1 -1
  39. package/dist/Table/TableToolbar.js +1 -0
  40. package/dist/Table/TableToolbar.js.map +1 -1
  41. package/dist/Table/VirtualizedTable.d.ts +1 -1
  42. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  43. package/dist/Table/VirtualizedTable.js +10 -19
  44. package/dist/Table/VirtualizedTable.js.map +1 -1
  45. package/dist/Table/model/table-model.d.ts +6 -2
  46. package/dist/Table/model/table-model.d.ts.map +1 -1
  47. package/dist/Table/model/table-model.js.map +1 -1
  48. package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -3
  49. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  50. package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
  51. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  52. package/dist/TimeRangeSelector/TimeRangeSelector.js +4 -4
  53. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  54. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  55. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +27 -16
  56. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  57. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  58. package/dist/TimeSeriesTooltip/utils.js +6 -2
  59. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  60. package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
  61. package/dist/TransformsEditor/TransformEditor.js +89 -0
  62. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  63. package/dist/controls/TextField.d.ts.map +1 -1
  64. package/dist/controls/TextField.js +15 -10
  65. package/dist/controls/TextField.js.map +1 -1
  66. package/dist/index.d.ts +1 -0
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +1 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/model/custom.d.ts +22 -0
  71. package/dist/model/custom.d.ts.map +1 -0
  72. package/dist/model/custom.js +243 -0
  73. package/dist/model/custom.js.map +1 -0
  74. package/dist/model/index.d.ts +1 -0
  75. package/dist/model/index.d.ts.map +1 -1
  76. package/dist/model/index.js +1 -0
  77. package/dist/model/index.js.map +1 -1
  78. package/dist/model/transforms.d.ts +22 -1
  79. package/dist/model/transforms.d.ts.map +1 -1
  80. package/dist/model/transforms.js +2 -1
  81. package/dist/model/transforms.js.map +1 -1
  82. package/dist/model/units.d.ts +12 -10
  83. package/dist/model/units.d.ts.map +1 -1
  84. package/dist/model/units.js +33 -28
  85. package/dist/model/units.js.map +1 -1
  86. package/dist/utils/index.d.ts +0 -2
  87. package/dist/utils/index.d.ts.map +1 -1
  88. package/dist/utils/index.js +0 -2
  89. package/dist/utils/index.js.map +1 -1
  90. package/dist/utils/text.d.ts.map +1 -1
  91. package/dist/utils/text.js +14 -18
  92. package/dist/utils/text.js.map +1 -1
  93. package/dist/utils/transform-data.d.ts +5 -0
  94. package/dist/utils/transform-data.d.ts.map +1 -1
  95. package/dist/utils/transform-data.js +96 -0
  96. package/dist/utils/transform-data.js.map +1 -1
  97. package/dist/utils/variable-interpolation.d.ts +11 -0
  98. package/dist/utils/variable-interpolation.d.ts.map +1 -1
  99. package/dist/utils/variable-interpolation.js +64 -0
  100. package/dist/utils/variable-interpolation.js.map +1 -1
  101. package/package.json +3 -3
  102. package/dist/utils/component-ids.d.ts +0 -8
  103. package/dist/utils/component-ids.d.ts.map +0 -1
  104. package/dist/utils/component-ids.js.map +0 -1
  105. package/dist/utils/memo.d.ts +0 -13
  106. package/dist/utils/memo.d.ts.map +0 -1
  107. package/dist/utils/memo.js +0 -50
  108. package/dist/utils/memo.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/controls/TextField.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 { TextFieldProps as MuiTextFieldProps } from '@mui/material';\nimport { TextField as MuiTextField } from '@mui/material';\nimport debounce from 'lodash/debounce';\nimport type { ChangeEvent, ForwardedRef } from 'react';\nimport { forwardRef, useCallback, useMemo, useState } from 'react';\n\ntype TextFieldProps = Omit<MuiTextFieldProps, 'onChange'> & { debounceMs?: number; onChange?: (value: string) => void };\n\nexport const TextField = forwardRef(function (\n { debounceMs = 250, value, onChange, ...props }: TextFieldProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [currentValue, setCurrentValue] = useState(value);\n\n function handleChange(event: ChangeEvent<HTMLInputElement>): void {\n setCurrentValue(event.target.value);\n debounceFn(event.target.value);\n }\n\n const handleDebounceFn = useCallback(\n (inputValue: string) => {\n onChange?.(inputValue);\n },\n [onChange],\n );\n\n const debounceFn = useMemo(() => debounce(handleDebounceFn, debounceMs), [debounceMs, handleDebounceFn]);\n\n return <MuiTextField ref={ref} value={currentValue} onChange={handleChange} {...props} />;\n});\nTextField.displayName = 'TextField';\n"],"names":["TextField","MuiTextField","debounce","forwardRef","useCallback","useMemo","useState","debounceMs","value","onChange","props","ref","currentValue","setCurrentValue","handleChange","event","target","debounceFn","handleDebounceFn","inputValue","displayName"],"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,aAAaC,YAAY,QAAQ,gBAAgB;AAC1D,OAAOC,cAAc,kBAAkB;AAEvC,SAASC,UAAU,EAAEC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAInE,OAAO,MAAMN,0BAAYG,WAAW,SAClC,EAAEI,aAAa,GAAG,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGC,OAAuB,EAC/DC,GAAiC;IAEjC,MAAM,CAACC,cAAcC,gBAAgB,GAAGP,SAASE;IAEjD,SAASM,aAAaC,KAAoC;QACxDF,gBAAgBE,MAAMC,MAAM,CAACR,KAAK;QAClCS,WAAWF,MAAMC,MAAM,CAACR,KAAK;IAC/B;IAEA,MAAMU,mBAAmBd,YACvB,CAACe;QACCV,WAAWU;IACb,GACA;QAACV;KAAS;IAGZ,MAAMQ,aAAaZ,QAAQ,IAAMH,SAASgB,kBAAkBX,aAAa;QAACA;QAAYW;KAAiB;IAEvG,qBAAO,KAACjB;QAAaU,KAAKA;QAAKH,OAAOI;QAAcH,UAAUK;QAAe,GAAGJ,KAAK;;AACvF,GAAG;AACHV,UAAUoB,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../src/controls/TextField.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 { TextFieldProps as MuiTextFieldProps } from '@mui/material';\nimport { TextField as MuiTextField } from '@mui/material';\nimport type { DebouncedFunc } from 'lodash';\nimport debounce from 'lodash/debounce';\nimport type { ChangeEvent, ForwardedRef } from 'react';\nimport { forwardRef, useCallback, useLayoutEffect, useRef, useState } from 'react';\n\ntype TextFieldProps = Omit<MuiTextFieldProps, 'onChange'> & { debounceMs?: number; onChange?: (value: string) => void };\n\nexport const TextField = forwardRef(function (\n { debounceMs = 250, value, onChange, ...props }: TextFieldProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [currentValue, setCurrentValue] = useState(value);\n\n const onChangeRef = useRef(onChange);\n useLayoutEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n\n const debounceRef = useRef<DebouncedFunc<(inputValue: string) => void> | null>(null);\n useLayoutEffect(() => {\n const debounceFn = debounce((inputValue: string) => onChangeRef.current?.(inputValue), debounceMs);\n debounceRef.current = debounceFn;\n return (): void => debounceFn.cancel();\n }, [debounceMs]);\n\n const handleChange = useCallback((event: ChangeEvent<HTMLInputElement>): void => {\n setCurrentValue(event.target.value);\n debounceRef.current?.(event.target.value);\n }, []);\n\n return <MuiTextField ref={ref} value={currentValue} onChange={handleChange} {...props} />;\n});\nTextField.displayName = 'TextField';\n"],"names":["TextField","MuiTextField","debounce","forwardRef","useCallback","useLayoutEffect","useRef","useState","debounceMs","value","onChange","props","ref","currentValue","setCurrentValue","onChangeRef","current","debounceRef","debounceFn","inputValue","cancel","handleChange","event","target","displayName"],"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,aAAaC,YAAY,QAAQ,gBAAgB;AAE1D,OAAOC,cAAc,kBAAkB;AAEvC,SAASC,UAAU,EAAEC,WAAW,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAInF,OAAO,MAAMP,0BAAYG,WAAW,SAClC,EAAEK,aAAa,GAAG,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGC,OAAuB,EAC/DC,GAAiC;IAEjC,MAAM,CAACC,cAAcC,gBAAgB,GAAGP,SAASE;IAEjD,MAAMM,cAAcT,OAAOI;IAC3BL,gBAAgB;QACdU,YAAYC,OAAO,GAAGN;IACxB,GAAG;QAACA;KAAS;IAEb,MAAMO,cAAcX,OAA2D;IAC/ED,gBAAgB;QACd,MAAMa,aAAahB,SAAS,CAACiB,aAAuBJ,YAAYC,OAAO,GAAGG,aAAaX;QACvFS,YAAYD,OAAO,GAAGE;QACtB,OAAO,IAAYA,WAAWE,MAAM;IACtC,GAAG;QAACZ;KAAW;IAEf,MAAMa,eAAejB,YAAY,CAACkB;QAChCR,gBAAgBQ,MAAMC,MAAM,CAACd,KAAK;QAClCQ,YAAYD,OAAO,GAAGM,MAAMC,MAAM,CAACd,KAAK;IAC1C,GAAG,EAAE;IAEL,qBAAO,KAACR;QAAaW,KAAKA;QAAKH,OAAOI;QAAcH,UAAUW;QAAe,GAAGV,KAAK;;AACvF,GAAG;AACHX,UAAUwB,WAAW,GAAG"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './ColorPicker';
3
3
  export * from './ContentWithLegend';
4
4
  export * from './controls';
5
5
  export * from './Dialog';
6
+ export * from './ExemplarMetadata';
6
7
  export * from './DensitySelector';
7
8
  export * from './DragAndDrop';
8
9
  export * from './Drawer';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAA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7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ export * from "./ColorPicker/index.js";
15
15
  export * from "./ContentWithLegend/index.js";
16
16
  export * from "./controls/index.js";
17
17
  export * from "./Dialog/index.js";
18
+ export * from "./ExemplarMetadata/index.js";
18
19
  export * from "./DensitySelector/index.js";
19
20
  export * from "./DragAndDrop/index.js";
20
21
  export * from "./Drawer/index.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/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 './AlignSelector';\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './controls';\nexport * from './Dialog';\nexport * from './DensitySelector';\nexport * from './DragAndDrop';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './FormEditor';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LinksEditor';\nexport * from './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './Overlay';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeRangeSelector';\nexport * from './TimeZoneSelector';\nexport * from './TimeSeriesTooltip';\nexport * from './ToolbarIconButton';\nexport * from './FormatControls';\nexport * from './YAxisLabel';\nexport * from './context';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './TransformsEditor';\nexport * from './RefreshIntervalPicker';\nexport * from './RepeatGrid';\nexport * from './ValueMappingEditor';\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,2BAAkB;AAChC,cAAc,yBAAgB;AAC9B,cAAc,+BAAsB;AACpC,cAAc,sBAAa;AAC3B,cAAc,oBAAW;AACzB,cAAc,6BAAoB;AAClC,cAAc,yBAAgB;AAC9B,cAAc,oBAAW;AACzB,cAAc,oBAAW;AACzB,cAAc,kBAAe;AAC7B,cAAc,qBAAkB;AAChC,cAAc,8BAAqB;AACnC,cAAc,wBAAe;AAC7B,cAAc,yBAAgB;AAC9B,cAAc,kBAAe;AAC7B,cAAc,oBAAW;AACzB,cAAc,yBAAgB;AAC9B,cAAc,0BAAiB;AAC/B,cAAc,iCAAwB;AACtC,cAAc,qBAAY;AAC1B,cAAc,kCAAyB;AACvC,cAAc,0BAAiB;AAC/B,cAAc,mBAAU;AACxB,cAAc,8BAAqB;AACnC,cAAc,+BAAsB;AACpC,cAAc,wBAAqB;AACnC,cAAc,+BAAsB;AACpC,cAAc,+BAAsB;AACpC,cAAc,4BAAmB;AACjC,cAAc,kBAAe;AAC7B,cAAc,qBAAY;AAC1B,cAAc,mBAAU;AACxB,cAAc,mBAAU;AACxB,cAAc,wBAAe;AAC7B,cAAc,mBAAU;AACxB,cAAc,8BAAqB;AACnC,cAAc,mCAA0B;AACxC,cAAc,wBAAe;AAC7B,cAAc,gCAAuB"}
1
+ {"version":3,"sources":["../src/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 './AlignSelector';\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './controls';\nexport * from './Dialog';\nexport * from './ExemplarMetadata';\nexport * from './DensitySelector';\nexport * from './DragAndDrop';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './FormEditor';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LinksEditor';\nexport * from './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './Overlay';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeRangeSelector';\nexport * from './TimeZoneSelector';\nexport * from './TimeSeriesTooltip';\nexport * from './ToolbarIconButton';\nexport * from './FormatControls';\nexport * from './YAxisLabel';\nexport * from './context';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './TransformsEditor';\nexport * from './RefreshIntervalPicker';\nexport * from './RepeatGrid';\nexport * from './ValueMappingEditor';\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,2BAAkB;AAChC,cAAc,yBAAgB;AAC9B,cAAc,+BAAsB;AACpC,cAAc,sBAAa;AAC3B,cAAc,oBAAW;AACzB,cAAc,8BAAqB;AACnC,cAAc,6BAAoB;AAClC,cAAc,yBAAgB;AAC9B,cAAc,oBAAW;AACzB,cAAc,oBAAW;AACzB,cAAc,kBAAe;AAC7B,cAAc,qBAAkB;AAChC,cAAc,8BAAqB;AACnC,cAAc,wBAAe;AAC7B,cAAc,yBAAgB;AAC9B,cAAc,kBAAe;AAC7B,cAAc,oBAAW;AACzB,cAAc,yBAAgB;AAC9B,cAAc,0BAAiB;AAC/B,cAAc,iCAAwB;AACtC,cAAc,qBAAY;AAC1B,cAAc,kCAAyB;AACvC,cAAc,0BAAiB;AAC/B,cAAc,mBAAU;AACxB,cAAc,8BAAqB;AACnC,cAAc,+BAAsB;AACpC,cAAc,wBAAqB;AACnC,cAAc,+BAAsB;AACpC,cAAc,+BAAsB;AACpC,cAAc,4BAAmB;AACjC,cAAc,kBAAe;AAC7B,cAAc,qBAAY;AAC1B,cAAc,mBAAU;AACxB,cAAc,mBAAU;AACxB,cAAc,wBAAe;AAC7B,cAAc,mBAAU;AACxB,cAAc,8BAAqB;AACnC,cAAc,mCAA0B;AACxC,cAAc,wBAAe;AAC7B,cAAc,gCAAuB"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Optional display override on standard formats.
3
+ * `unit` remains the stable key (multi-axis, maps, UI config);
4
+ * `customLabel` only changes the text shown after the scaled quantity.
5
+ *
6
+ * Data sizes (bytes/bits): keep SI/IEC scale (Ki, Mi, K, M, …) and replace the
7
+ * base unit — e.g. "1.46 KiB" + "prout" → "1.46 Ki prout" (not "gigaprout").
8
+ * Dates stay untouched (structured timestamps).
9
+ */
10
+ export type WithCustomLabel = {
11
+ customLabel?: string;
12
+ };
13
+ /**
14
+ * Whether FormatControls / formatValue should honor customLabel for this unit key.
15
+ */
16
+ export declare function supportsCustomLabel(unit?: string): boolean;
17
+ /**
18
+ * If customLabel is set and the unit is supported, replace the standard unit text
19
+ * with the display label. Dates leave `formatted` unchanged.
20
+ */
21
+ export declare function applyCustomLabel(formatted: string, customLabel?: string, unit?: string): string;
22
+ //# sourceMappingURL=custom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/model/custom.ts"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAgEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAK1D;AAKD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAwD/F"}
@@ -0,0 +1,243 @@
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
+ /**
14
+ * Optional display override on standard formats.
15
+ * `unit` remains the stable key (multi-axis, maps, UI config);
16
+ * `customLabel` only changes the text shown after the scaled quantity.
17
+ *
18
+ * Data sizes (bytes/bits): keep SI/IEC scale (Ki, Mi, K, M, …) and replace the
19
+ * base unit — e.g. "1.46 KiB" + "prout" → "1.46 Ki prout" (not "gigaprout").
20
+ * Dates stay untouched (structured timestamps).
21
+ */ /** Units where customLabel is not applied (unstructured / identity formats). */ const CUSTOM_LABEL_EXCLUDED_UNITS = new Set([
22
+ 'datetime-iso',
23
+ 'datetime-us',
24
+ 'datetime-local',
25
+ 'date-iso',
26
+ 'date-us',
27
+ 'date-local',
28
+ 'time-local',
29
+ 'time-iso',
30
+ 'time-us',
31
+ 'relative-time',
32
+ 'unix-timestamp',
33
+ 'unix-timestamp-ms'
34
+ ]);
35
+ const DATA_SIZE_UNITS = new Set([
36
+ 'bytes',
37
+ 'decbytes',
38
+ 'bits',
39
+ 'decbits',
40
+ 'bytes/sec',
41
+ 'decbytes/sec',
42
+ 'bits/sec',
43
+ 'decbits/sec'
44
+ ]);
45
+ const CURRENCY_UNITS = new Set([
46
+ 'usd',
47
+ 'eur',
48
+ 'gbp',
49
+ 'jpy',
50
+ 'cny',
51
+ 'cad',
52
+ 'aud',
53
+ 'chf',
54
+ 'hkd',
55
+ 'sgd',
56
+ 'sek',
57
+ 'krw',
58
+ 'nok',
59
+ 'nzd',
60
+ 'inr',
61
+ 'mxn',
62
+ 'twd',
63
+ 'zar',
64
+ 'brl',
65
+ 'dkk',
66
+ 'pln',
67
+ 'thb',
68
+ 'ils',
69
+ 'czk',
70
+ 'clp',
71
+ 'php',
72
+ 'aed',
73
+ 'cop',
74
+ 'sar',
75
+ 'myr',
76
+ 'ron',
77
+ 'afn'
78
+ ]);
79
+ /**
80
+ * Whether FormatControls / formatValue should honor customLabel for this unit key.
81
+ */ export function supportsCustomLabel(unit) {
82
+ if (!unit) {
83
+ return true;
84
+ }
85
+ return !CUSTOM_LABEL_EXCLUDED_UNITS.has(unit);
86
+ }
87
+ /** Sign + number (grouped / scientific). */ const LEADING_NUMBER = /^[+-]?(?:\d{1,3}(?:,\d{3})*|\d+)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
88
+ /**
89
+ * If customLabel is set and the unit is supported, replace the standard unit text
90
+ * with the display label. Dates leave `formatted` unchanged.
91
+ */ export function applyCustomLabel(formatted, customLabel, unit) {
92
+ const label = customLabel?.trim();
93
+ if (!label) {
94
+ return formatted;
95
+ }
96
+ if (!supportsCustomLabel(unit)) {
97
+ return formatted;
98
+ }
99
+ if (unit && DATA_SIZE_UNITS.has(unit)) {
100
+ return applyDataSizeCustomLabel(formatted, label);
101
+ }
102
+ if (unit && CURRENCY_UNITS.has(unit)) {
103
+ return applyCurrencyCustomLabel(formatted, label);
104
+ }
105
+ // formatTime zero sentinel
106
+ if (formatted === '0s') {
107
+ return `0 ${label}`;
108
+ }
109
+ // Percent: "12.3%" → "12.3 load"
110
+ if (unit === 'percent' || unit === 'percent-decimal') {
111
+ if (formatted.endsWith('%')) {
112
+ return `${formatted.slice(0, -1).trimEnd()} ${label}`;
113
+ }
114
+ }
115
+ // Temperature: "11°C" / "52°F"
116
+ if (unit === 'celsius' && formatted.endsWith('°C')) {
117
+ return `${formatted.slice(0, -2).trimEnd()} ${label}`;
118
+ }
119
+ if (unit === 'fahrenheit' && formatted.endsWith('°F')) {
120
+ return `${formatted.slice(0, -2).trimEnd()} ${label}`;
121
+ }
122
+ // Exact unit-key suffix: "10 ops/sec", "1.5K ops/sec"
123
+ if (unit && formatted.endsWith(` ${unit}`)) {
124
+ return `${formatted.slice(0, -(unit.length + 1))} ${label}`;
125
+ }
126
+ // Time units: Intl narrow often glues the suffix ("1ms", "1μs") with no space — the
127
+ // generic leadingQuantity path can leave "ms" if a consumer re-appends a label, and
128
+ // the bare append fallback would yield "1ms prout". Strip known time tokens first.
129
+ if (unit && TIME_FORMAT_UNITS.has(unit)) {
130
+ return applyTimeCustomLabel(formatted, label);
131
+ }
132
+ // Decimal / throughput fallback: keep leading quantity only
133
+ const qty = leadingQuantity(formatted);
134
+ if (qty !== null) {
135
+ return `${qty} ${label}`;
136
+ }
137
+ return `${formatted} ${label}`;
138
+ }
139
+ /** Time format unit keys (formatTime / Intl unit style). */ const TIME_FORMAT_UNITS = new Set([
140
+ 'nanoseconds',
141
+ 'microseconds',
142
+ 'milliseconds',
143
+ 'seconds',
144
+ 'minutes',
145
+ 'hours',
146
+ 'days',
147
+ 'weeks',
148
+ 'months',
149
+ 'years'
150
+ ]);
151
+ /**
152
+ * Replace formatTime output with custom label.
153
+ * Handles glued narrow units (1ms, 500µs), spaced long forms (1 month), and
154
+ * multi-part strings (1d255ms) by keeping only the leading quantity (+ compact K/M/B/T).
155
+ */ function applyTimeCustomLabel(formatted, label) {
156
+ const body = formatted.trim();
157
+ if (body === '0s' || body === '0') {
158
+ return `0 ${label}`;
159
+ }
160
+ // Strip trailing time tokens (repeat for compound "1d 2h", "1d255ms").
161
+ // Long names → multi-letter narrow (ms before m|s) → single-letter. One µ only (not µs|μs).
162
+ let stripped = body.replace(/\u03bc/g, '\u00b5'); // Greek μ → micro sign µ (Intl variants)
163
+ const timeToken = /(?:\s*)(?:milliseconds?|microseconds?|nanoseconds?|seconds?|minutes?|hours?|days?|weeks?|months?|years?|ms|us|ns|µs|[ywdhms])$/i;
164
+ let guard = 0;
165
+ while(timeToken.test(stripped) && guard++ < 8){
166
+ stripped = stripped.replace(timeToken, '').trimEnd();
167
+ }
168
+ if (stripped !== '' && stripped !== body) {
169
+ // Prefer full numeric head (incl. decimals / compact) from stripped body
170
+ const qty = leadingQuantity(stripped) ?? stripped;
171
+ return `${qty} ${label}`;
172
+ }
173
+ const qty = leadingQuantity(body);
174
+ if (qty !== null) {
175
+ return `${qty} ${label}`;
176
+ }
177
+ return `${body} ${label}`;
178
+ }
179
+ /**
180
+ * Bytes/bits (+ optional /s|/sec): keep scale (Ki, Mi, K, M, …), replace base unit.
181
+ * "1.46 KiB" + prout → "1.46 Ki prout"
182
+ * "1.5 KB/s" + wire → "1.5 K wire/s"
183
+ * "500 bytes" + prout → "500 prout"
184
+ */ function applyDataSizeCustomLabel(formatted, label) {
185
+ let rate = '';
186
+ let body = formatted.trim();
187
+ const rateM = body.match(/(\/s(?:ec)?)$/i);
188
+ if (rateM?.[1]) {
189
+ rate = rateM[1];
190
+ body = body.slice(0, -rate.length).trimEnd();
191
+ }
192
+ // Long form: "500 bytes", "1,500 bits"
193
+ const long = body.match(/^(.+?)\s+(bytes?|bits?)$/i);
194
+ if (long?.[1]) {
195
+ return `${long[1].trim()} ${label}${rate}`;
196
+ }
197
+ // Short form: "1.46 KiB", "1.5 KB", "1.46 Kib", "1.5 Kb" (optional space before scale)
198
+ const short = body.match(/^(.+?)\s*([KMGTPE]i?)\s*([Bb])$/);
199
+ if (short?.[1] && short[2]) {
200
+ return `${short[1].trim()} ${short[2]} ${label}${rate}`;
201
+ }
202
+ const qty = leadingQuantity(body);
203
+ if (qty !== null) {
204
+ return `${qty} ${label}${rate}`;
205
+ }
206
+ return `${formatted} ${label}`;
207
+ }
208
+ /**
209
+ * Currency: drop symbol/code, keep amount + custom label.
210
+ * "$1,500" + credits → "1,500 credits"
211
+ */ function applyCurrencyCustomLabel(formatted, label) {
212
+ // Strip common leading/trailing currency symbols and ISO codes.
213
+ // Keep optional leading sign so "-$1.23" → "-1.23 credits" (not "-$1.23 credits").
214
+ let body = formatted.trim();
215
+ body = body.replace(/^([+-]?)\s*[^\d\s+-]+/, '$1'); // -$1.23 / $1.23 / €12.3
216
+ body = body.replace(/\s*[A-Z]{3}$/, ''); // trailing USD
217
+ body = body.trim();
218
+ const qty = leadingQuantity(body);
219
+ if (qty !== null) {
220
+ return `${body} ${label}`;
221
+ }
222
+ return `${body} ${label}`;
223
+ }
224
+ /**
225
+ * Numeric prefix of a formatted value, keeping SI compact (1.5K)
226
+ * but not unit letters glued to the number (500ms → 500, not 500m).
227
+ */ function leadingQuantity(formatted) {
228
+ const s = formatted.trimStart();
229
+ const num = s.match(LEADING_NUMBER);
230
+ if (!num?.[0]) {
231
+ return null;
232
+ }
233
+ const head = num[0];
234
+ const rest = s.slice(head.length);
235
+ // Compact decimal suffix K/M/B/T only when not starting a longer unit word (ms, min, …).
236
+ const compact = rest.match(/^([KMBT])(?=\s|$)/i);
237
+ if (compact) {
238
+ return head + compact[1];
239
+ }
240
+ return head;
241
+ }
242
+
243
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/custom.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\n/**\n * Optional display override on standard formats.\n * `unit` remains the stable key (multi-axis, maps, UI config);\n * `customLabel` only changes the text shown after the scaled quantity.\n *\n * Data sizes (bytes/bits): keep SI/IEC scale (Ki, Mi, K, M, …) and replace the\n * base unit — e.g. \"1.46 KiB\" + \"prout\" → \"1.46 Ki prout\" (not \"gigaprout\").\n * Dates stay untouched (structured timestamps).\n */\n\nexport type WithCustomLabel = {\n customLabel?: string;\n};\n\n/** Units where customLabel is not applied (unstructured / identity formats). */\nconst CUSTOM_LABEL_EXCLUDED_UNITS = new Set([\n 'datetime-iso',\n 'datetime-us',\n 'datetime-local',\n 'date-iso',\n 'date-us',\n 'date-local',\n 'time-local',\n 'time-iso',\n 'time-us',\n 'relative-time',\n 'unix-timestamp',\n 'unix-timestamp-ms',\n]);\n\nconst DATA_SIZE_UNITS = new Set([\n 'bytes',\n 'decbytes',\n 'bits',\n 'decbits',\n 'bytes/sec',\n 'decbytes/sec',\n 'bits/sec',\n 'decbits/sec',\n]);\n\nconst CURRENCY_UNITS = new Set([\n 'usd',\n 'eur',\n 'gbp',\n 'jpy',\n 'cny',\n 'cad',\n 'aud',\n 'chf',\n 'hkd',\n 'sgd',\n 'sek',\n 'krw',\n 'nok',\n 'nzd',\n 'inr',\n 'mxn',\n 'twd',\n 'zar',\n 'brl',\n 'dkk',\n 'pln',\n 'thb',\n 'ils',\n 'czk',\n 'clp',\n 'php',\n 'aed',\n 'cop',\n 'sar',\n 'myr',\n 'ron',\n 'afn',\n]);\n\n/**\n * Whether FormatControls / formatValue should honor customLabel for this unit key.\n */\nexport function supportsCustomLabel(unit?: string): boolean {\n if (!unit) {\n return true;\n }\n return !CUSTOM_LABEL_EXCLUDED_UNITS.has(unit);\n}\n\n/** Sign + number (grouped / scientific). */\nconst LEADING_NUMBER = /^[+-]?(?:\\d{1,3}(?:,\\d{3})*|\\d+)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?/;\n\n/**\n * If customLabel is set and the unit is supported, replace the standard unit text\n * with the display label. Dates leave `formatted` unchanged.\n */\nexport function applyCustomLabel(formatted: string, customLabel?: string, unit?: string): string {\n const label = customLabel?.trim();\n if (!label) {\n return formatted;\n }\n if (!supportsCustomLabel(unit)) {\n return formatted;\n }\n\n if (unit && DATA_SIZE_UNITS.has(unit)) {\n return applyDataSizeCustomLabel(formatted, label);\n }\n\n if (unit && CURRENCY_UNITS.has(unit)) {\n return applyCurrencyCustomLabel(formatted, label);\n }\n\n // formatTime zero sentinel\n if (formatted === '0s') {\n return `0 ${label}`;\n }\n\n // Percent: \"12.3%\" → \"12.3 load\"\n if (unit === 'percent' || unit === 'percent-decimal') {\n if (formatted.endsWith('%')) {\n return `${formatted.slice(0, -1).trimEnd()} ${label}`;\n }\n }\n\n // Temperature: \"11°C\" / \"52°F\"\n if (unit === 'celsius' && formatted.endsWith('°C')) {\n return `${formatted.slice(0, -2).trimEnd()} ${label}`;\n }\n if (unit === 'fahrenheit' && formatted.endsWith('°F')) {\n return `${formatted.slice(0, -2).trimEnd()} ${label}`;\n }\n\n // Exact unit-key suffix: \"10 ops/sec\", \"1.5K ops/sec\"\n if (unit && formatted.endsWith(` ${unit}`)) {\n return `${formatted.slice(0, -(unit.length + 1))} ${label}`;\n }\n\n // Time units: Intl narrow often glues the suffix (\"1ms\", \"1μs\") with no space — the\n // generic leadingQuantity path can leave \"ms\" if a consumer re-appends a label, and\n // the bare append fallback would yield \"1ms prout\". Strip known time tokens first.\n if (unit && TIME_FORMAT_UNITS.has(unit)) {\n return applyTimeCustomLabel(formatted, label);\n }\n\n // Decimal / throughput fallback: keep leading quantity only\n const qty = leadingQuantity(formatted);\n if (qty !== null) {\n return `${qty} ${label}`;\n }\n\n return `${formatted} ${label}`;\n}\n\n/** Time format unit keys (formatTime / Intl unit style). */\nconst TIME_FORMAT_UNITS = new Set([\n 'nanoseconds',\n 'microseconds',\n 'milliseconds',\n 'seconds',\n 'minutes',\n 'hours',\n 'days',\n 'weeks',\n 'months',\n 'years',\n]);\n\n/**\n * Replace formatTime output with custom label.\n * Handles glued narrow units (1ms, 500µs), spaced long forms (1 month), and\n * multi-part strings (1d255ms) by keeping only the leading quantity (+ compact K/M/B/T).\n */\nfunction applyTimeCustomLabel(formatted: string, label: string): string {\n const body = formatted.trim();\n if (body === '0s' || body === '0') {\n return `0 ${label}`;\n }\n\n // Strip trailing time tokens (repeat for compound \"1d 2h\", \"1d255ms\").\n // Long names → multi-letter narrow (ms before m|s) → single-letter. One µ only (not µs|μs).\n let stripped = body.replace(/\\u03bc/g, '\\u00b5'); // Greek μ → micro sign µ (Intl variants)\n const timeToken =\n /(?:\\s*)(?:milliseconds?|microseconds?|nanoseconds?|seconds?|minutes?|hours?|days?|weeks?|months?|years?|ms|us|ns|µs|[ywdhms])$/i;\n let guard = 0;\n while (timeToken.test(stripped) && guard++ < 8) {\n stripped = stripped.replace(timeToken, '').trimEnd();\n }\n if (stripped !== '' && stripped !== body) {\n // Prefer full numeric head (incl. decimals / compact) from stripped body\n const qty = leadingQuantity(stripped) ?? stripped;\n return `${qty} ${label}`;\n }\n\n const qty = leadingQuantity(body);\n if (qty !== null) {\n return `${qty} ${label}`;\n }\n return `${body} ${label}`;\n}\n\n/**\n * Bytes/bits (+ optional /s|/sec): keep scale (Ki, Mi, K, M, …), replace base unit.\n * \"1.46 KiB\" + prout → \"1.46 Ki prout\"\n * \"1.5 KB/s\" + wire → \"1.5 K wire/s\"\n * \"500 bytes\" + prout → \"500 prout\"\n */\nfunction applyDataSizeCustomLabel(formatted: string, label: string): string {\n let rate = '';\n let body = formatted.trim();\n const rateM = body.match(/(\\/s(?:ec)?)$/i);\n if (rateM?.[1]) {\n rate = rateM[1];\n body = body.slice(0, -rate.length).trimEnd();\n }\n\n // Long form: \"500 bytes\", \"1,500 bits\"\n const long = body.match(/^(.+?)\\s+(bytes?|bits?)$/i);\n if (long?.[1]) {\n return `${long[1].trim()} ${label}${rate}`;\n }\n\n // Short form: \"1.46 KiB\", \"1.5 KB\", \"1.46 Kib\", \"1.5 Kb\" (optional space before scale)\n const short = body.match(/^(.+?)\\s*([KMGTPE]i?)\\s*([Bb])$/);\n if (short?.[1] && short[2]) {\n return `${short[1].trim()} ${short[2]} ${label}${rate}`;\n }\n\n const qty = leadingQuantity(body);\n if (qty !== null) {\n return `${qty} ${label}${rate}`;\n }\n return `${formatted} ${label}`;\n}\n\n/**\n * Currency: drop symbol/code, keep amount + custom label.\n * \"$1,500\" + credits → \"1,500 credits\"\n */\nfunction applyCurrencyCustomLabel(formatted: string, label: string): string {\n // Strip common leading/trailing currency symbols and ISO codes.\n // Keep optional leading sign so \"-$1.23\" → \"-1.23 credits\" (not \"-$1.23 credits\").\n let body = formatted.trim();\n body = body.replace(/^([+-]?)\\s*[^\\d\\s+-]+/, '$1'); // -$1.23 / $1.23 / €12.3\n body = body.replace(/\\s*[A-Z]{3}$/, ''); // trailing USD\n body = body.trim();\n const qty = leadingQuantity(body);\n if (qty !== null) {\n return `${body} ${label}`;\n }\n return `${body} ${label}`;\n}\n\n/**\n * Numeric prefix of a formatted value, keeping SI compact (1.5K)\n * but not unit letters glued to the number (500ms → 500, not 500m).\n */\nfunction leadingQuantity(formatted: string): string | null {\n const s = formatted.trimStart();\n const num = s.match(LEADING_NUMBER);\n if (!num?.[0]) {\n return null;\n }\n const head = num[0];\n const rest = s.slice(head.length);\n\n // Compact decimal suffix K/M/B/T only when not starting a longer unit word (ms, min, …).\n const compact = rest.match(/^([KMBT])(?=\\s|$)/i);\n if (compact) {\n return head + compact[1];\n }\n\n return head;\n}\n"],"names":["CUSTOM_LABEL_EXCLUDED_UNITS","Set","DATA_SIZE_UNITS","CURRENCY_UNITS","supportsCustomLabel","unit","has","LEADING_NUMBER","applyCustomLabel","formatted","customLabel","label","trim","applyDataSizeCustomLabel","applyCurrencyCustomLabel","endsWith","slice","trimEnd","length","TIME_FORMAT_UNITS","applyTimeCustomLabel","qty","leadingQuantity","body","stripped","replace","timeToken","guard","test","rate","rateM","match","long","short","s","trimStart","num","head","rest","compact"],"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;;;;;;;;CAQC,GAMD,8EAA8E,GAC9E,MAAMA,8BAA8B,IAAIC,IAAI;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,kBAAkB,IAAID,IAAI;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAME,iBAAiB,IAAIF,IAAI;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;I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,GAAGE,KAAK,CAAC,EAAEZ,OAAO;IAC3B;IACA,OAAO,GAAGY,KAAK,CAAC,EAAEZ,OAAO;AAC3B;AAEA;;;CAGC,GACD,SAASW,gBAAgBb,SAAiB;IACxC,MAAMyB,IAAIzB,UAAU0B,SAAS;IAC7B,MAAMC,MAAMF,EAAEH,KAAK,CAACxB;IACpB,IAAI,CAAC6B,KAAK,CAAC,EAAE,EAAE;QACb,OAAO;IACT;IACA,MAAMC,OAAOD,GAAG,CAAC,EAAE;IACnB,MAAME,OAAOJ,EAAElB,KAAK,CAACqB,KAAKnB,MAAM;IAEhC,yFAAyF;IACzF,MAAMqB,UAAUD,KAAKP,KAAK,CAAC;IAC3B,IAAIQ,SAAS;QACX,OAAOF,OAAOE,OAAO,CAAC,EAAE;IAC1B;IAEA,OAAOF;AACT"}
@@ -12,6 +12,7 @@ export * from './percent';
12
12
  export * from './temperature';
13
13
  export * from './decimal';
14
14
  export * from './throughput';
15
+ export * from './custom';
15
16
  export * from './formatterCache';
16
17
  export * from './units';
17
18
  export * from './utils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
@@ -24,6 +24,7 @@ export * from "./percent.js";
24
24
  export * from "./temperature.js";
25
25
  export * from "./decimal.js";
26
26
  export * from "./throughput.js";
27
+ export * from "./custom.js";
27
28
  export * from "./formatterCache.js";
28
29
  export * from "./units.js";
29
30
  export * from "./utils.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/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 './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\nexport * from './action';\nexport * from './legend';\nexport * from './time';\nexport * from './bits';\nexport * from './bytes';\nexport * from './currency';\nexport * from './percent';\nexport * from './temperature';\nexport * from './decimal';\nexport * from './throughput';\nexport * from './formatterCache';\nexport * from './units';\nexport * from './utils';\nexport * from './types';\nexport * from './thresholds';\nexport * from './transforms';\nexport * from './value-mapping';\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,aAAU;AACxB,cAAc,aAAU;AACxB,cAAc,kBAAe;AAC7B,cAAc,sBAAmB;AACjC,cAAc,cAAW;AACzB,cAAc,cAAW;AACzB,cAAc,YAAS;AACvB,cAAc,YAAS;AACvB,cAAc,aAAU;AACxB,cAAc,gBAAa;AAC3B,cAAc,eAAY;AAC1B,cAAc,mBAAgB;AAC9B,cAAc,eAAY;AAC1B,cAAc,kBAAe;AAC7B,cAAc,sBAAmB;AACjC,cAAc,aAAU;AACxB,cAAc,aAAU;AACxB,cAAc,aAAU;AACxB,cAAc,kBAAe;AAC7B,cAAc,kBAAe;AAC7B,cAAc,qBAAkB"}
1
+ {"version":3,"sources":["../../src/model/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 './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\nexport * from './action';\nexport * from './legend';\nexport * from './time';\nexport * from './bits';\nexport * from './bytes';\nexport * from './currency';\nexport * from './percent';\nexport * from './temperature';\nexport * from './decimal';\nexport * from './throughput';\nexport * from './custom';\nexport * from './formatterCache';\nexport * from './units';\nexport * from './utils';\nexport * from './types';\nexport * from './thresholds';\nexport * from './transforms';\nexport * from './value-mapping';\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,aAAU;AACxB,cAAc,aAAU;AACxB,cAAc,kBAAe;AAC7B,cAAc,sBAAmB;AACjC,cAAc,cAAW;AACzB,cAAc,cAAW;AACzB,cAAc,YAAS;AACvB,cAAc,YAAS;AACvB,cAAc,aAAU;AACxB,cAAc,gBAAa;AAC3B,cAAc,eAAY;AAC1B,cAAc,mBAAgB;AAC9B,cAAc,eAAY;AAC1B,cAAc,kBAAe;AAC7B,cAAc,cAAW;AACzB,cAAc,sBAAmB;AACjC,cAAc,aAAU;AACxB,cAAc,aAAU;AACxB,cAAc,aAAU;AACxB,cAAc,kBAAe;AAC7B,cAAc,kBAAe;AAC7B,cAAc,qBAAkB"}
@@ -32,12 +32,33 @@ export interface MergeSeriesTransform {
32
32
  kind: 'MergeSeries';
33
33
  spec: TransformCommonSpec;
34
34
  }
35
- export type Transform = JoinByColumnValueTransform | MergeColumnsTransform | MergeIndexedColumnsTransform | MergeSeriesTransform | ExtractColumnFieldsTransform;
35
+ /**
36
+ * Pivot multi-series table rows into a time × label matrix
37
+ * (Grafana groupingToMatrix parity).
38
+ *
39
+ * Example: columnLabel=farm_short, rowField=timestamp
40
+ * → one row per timestamp, one column per farm_short value.
41
+ */
42
+ export interface PivotByLabelTransform {
43
+ kind: 'PivotByLabel';
44
+ spec: TransformCommonSpec & {
45
+ /** Label/column that becomes dynamic column headers (e.g. farm_short). */
46
+ columnLabel: string;
47
+ /** Field for row identity (default: timestamp). */
48
+ rowField?: string;
49
+ /** Value field name (default: value). */
50
+ valueField?: string;
51
+ /** Name of the row column after pivot (default: rowField). */
52
+ rowColumnName?: string;
53
+ };
54
+ }
55
+ export type Transform = JoinByColumnValueTransform | MergeColumnsTransform | MergeIndexedColumnsTransform | MergeSeriesTransform | ExtractColumnFieldsTransform | PivotByLabelTransform;
36
56
  export declare const TRANSFORM_TEXT: {
37
57
  JoinByColumnValue: string;
38
58
  MergeColumns: string;
39
59
  MergeIndexedColumns: string;
40
60
  MergeSeries: string;
41
61
  ExtractColumnFields: string;
62
+ PivotByLabel: string;
42
63
  };
43
64
  //# sourceMappingURL=transforms.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../../src/model/transforms.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,kBAAkB,GAAG,eAAe,CAAC;QAChE,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,mBAAmB,GAAG;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,MAAM,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,CAAC;IACpB,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,mBAAmB,GAAG;QAC1B,0EAA0E;QAC1E,WAAW,EAAE,MAAM,CAAC;QACpB,mDAAmD;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,yCAAyC;QACzC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,8DAA8D;QAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,MAAM,MAAM,SAAS,GACjB,0BAA0B,GAC1B,qBAAqB,GACrB,4BAA4B,GAC5B,oBAAoB,GACpB,4BAA4B,GAC5B,qBAAqB,CAAC;AAG1B,eAAO,MAAM,cAAc;IACzB,iBAAiB;IACjB,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,mBAAmB;IACnB,YAAY;CACb,CAAC"}
@@ -16,7 +16,8 @@ export const TRANSFORM_TEXT = {
16
16
  MergeColumns: 'Merge columns',
17
17
  MergeIndexedColumns: 'Merge indexed columns',
18
18
  MergeSeries: 'Merge series',
19
- ExtractColumnFields: 'Extract column fields'
19
+ ExtractColumnFields: 'Extract column fields',
20
+ PivotByLabel: 'Pivot by label'
20
21
  };
21
22
 
22
23
  //# sourceMappingURL=transforms.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/transforms.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 interface TransformCommonSpec {\n disabled?: boolean;\n}\n\nexport interface JoinByColumnValueTransform {\n kind: 'JoinByColumnValue';\n spec: TransformCommonSpec & {\n columns: string[];\n };\n}\n\nexport interface ExtractColumnFieldsTransform {\n kind: 'ExtractColumnFields';\n spec: TransformCommonSpec & {\n column: string;\n format: 'JSON' | 'Regex' | 'SplitByDelimiter' | 'KeyValuePairs';\n matcher?: string;\n };\n}\n\nexport interface MergeColumnsTransform {\n kind: 'MergeColumns';\n spec: TransformCommonSpec & {\n columns: string[];\n name: string;\n };\n}\n\nexport interface MergeIndexedColumnsTransform {\n kind: 'MergeIndexedColumns';\n spec: TransformCommonSpec & {\n column: string;\n };\n}\n\nexport interface MergeSeriesTransform {\n kind: 'MergeSeries';\n spec: TransformCommonSpec;\n}\n\nexport type Transform =\n | JoinByColumnValueTransform\n | MergeColumnsTransform\n | MergeIndexedColumnsTransform\n | MergeSeriesTransform\n | ExtractColumnFieldsTransform;\n\n// Can be moved somewhere else\nexport const TRANSFORM_TEXT = {\n JoinByColumnValue: 'Join by column value',\n MergeColumns: 'Merge columns',\n MergeIndexedColumns: 'Merge indexed columns',\n MergeSeries: 'Merge series',\n ExtractColumnFields: 'Extract column fields',\n};\n"],"names":["TRANSFORM_TEXT","JoinByColumnValue","MergeColumns","MergeIndexedColumns","MergeSeries","ExtractColumnFields"],"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;AAiDjC,8BAA8B;AAC9B,OAAO,MAAMA,iBAAiB;IAC5BC,mBAAmB;IACnBC,cAAc;IACdC,qBAAqB;IACrBC,aAAa;IACbC,qBAAqB;AACvB,EAAE"}
1
+ {"version":3,"sources":["../../src/model/transforms.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 interface TransformCommonSpec {\n disabled?: boolean;\n}\n\nexport interface JoinByColumnValueTransform {\n kind: 'JoinByColumnValue';\n spec: TransformCommonSpec & {\n columns: string[];\n };\n}\n\nexport interface ExtractColumnFieldsTransform {\n kind: 'ExtractColumnFields';\n spec: TransformCommonSpec & {\n column: string;\n format: 'JSON' | 'Regex' | 'SplitByDelimiter' | 'KeyValuePairs';\n matcher?: string;\n };\n}\n\nexport interface MergeColumnsTransform {\n kind: 'MergeColumns';\n spec: TransformCommonSpec & {\n columns: string[];\n name: string;\n };\n}\n\nexport interface MergeIndexedColumnsTransform {\n kind: 'MergeIndexedColumns';\n spec: TransformCommonSpec & {\n column: string;\n };\n}\n\nexport interface MergeSeriesTransform {\n kind: 'MergeSeries';\n spec: TransformCommonSpec;\n}\n\n/**\n * Pivot multi-series table rows into a time × label matrix\n * (Grafana groupingToMatrix parity).\n *\n * Example: columnLabel=farm_short, rowField=timestamp\n * → one row per timestamp, one column per farm_short value.\n */\nexport interface PivotByLabelTransform {\n kind: 'PivotByLabel';\n spec: TransformCommonSpec & {\n /** Label/column that becomes dynamic column headers (e.g. farm_short). */\n columnLabel: string;\n /** Field for row identity (default: timestamp). */\n rowField?: string;\n /** Value field name (default: value). */\n valueField?: string;\n /** Name of the row column after pivot (default: rowField). */\n rowColumnName?: string;\n };\n}\n\nexport type Transform =\n | JoinByColumnValueTransform\n | MergeColumnsTransform\n | MergeIndexedColumnsTransform\n | MergeSeriesTransform\n | ExtractColumnFieldsTransform\n | PivotByLabelTransform;\n\n// Can be moved somewhere else\nexport const TRANSFORM_TEXT = {\n JoinByColumnValue: 'Join by column value',\n MergeColumns: 'Merge columns',\n MergeIndexedColumns: 'Merge indexed columns',\n MergeSeries: 'Merge series',\n ExtractColumnFields: 'Extract column fields',\n PivotByLabel: 'Pivot by label',\n};\n"],"names":["TRANSFORM_TEXT","JoinByColumnValue","MergeColumns","MergeIndexedColumns","MergeSeries","ExtractColumnFields","PivotByLabel"],"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;AAuEjC,8BAA8B;AAC9B,OAAO,MAAMA,iBAAiB;IAC5BC,mBAAmB;IACnBC,cAAc;IACdC,qBAAqB;IACrBC,aAAa;IACbC,qBAAqB;IACrBC,cAAc;AAChB,EAAE"}
@@ -1,6 +1,7 @@
1
1
  import type { BitsFormatOptions } from './bits';
2
2
  import type { BytesFormatOptions } from './bytes';
3
3
  import type { CurrencyFormatOptions } from './currency';
4
+ import type { WithCustomLabel } from './custom';
4
5
  import type { DateFormatOptions } from './date';
5
6
  import type { DecimalFormatOptions } from './decimal';
6
7
  import type { PercentFormatOptions } from './percent';
@@ -79,7 +80,8 @@ export declare const UNIT_CONFIG: {
79
80
  readonly "writes/sec": UnitConfig;
80
81
  readonly years: UnitConfig;
81
82
  };
82
- export type FormatOptions = TimeFormatOptions | PercentFormatOptions | DecimalFormatOptions | BytesFormatOptions | BitsFormatOptions | ThroughputFormatOptions | CurrencyFormatOptions | TemperatureFormatOptions | DateFormatOptions;
83
+ /** Standard unit options plus optional display override (customLabel). */
84
+ export type FormatOptions = (TimeFormatOptions | PercentFormatOptions | DecimalFormatOptions | BytesFormatOptions | BitsFormatOptions | ThroughputFormatOptions | CurrencyFormatOptions | TemperatureFormatOptions | DateFormatOptions) & WithCustomLabel;
83
85
  type HasDecimalPlaces<UnitOpt> = UnitOpt extends {
84
86
  decimalPlaces?: number;
85
87
  } ? UnitOpt : never;
@@ -90,16 +92,16 @@ export declare function formatValue(value: number, formatOptions?: FormatOptions
90
92
  export declare function getUnitConfig(formatOptions: FormatOptions): UnitConfig;
91
93
  export declare function getUnitGroup(formatOptions: FormatOptions): UnitGroup;
92
94
  export declare function getUnitGroupConfig(formatOptions: FormatOptions): UnitGroupConfig;
93
- export declare function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions;
94
- export declare function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions;
95
- export declare function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions;
96
- export declare function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions;
97
- export declare function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions;
95
+ export declare function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions & WithCustomLabel;
96
+ export declare function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions & WithCustomLabel;
97
+ export declare function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions & WithCustomLabel;
98
+ export declare function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions & WithCustomLabel;
99
+ export declare function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions & WithCustomLabel;
98
100
  export declare function isUnitWithDecimalPlaces(formatOptions: FormatOptions): formatOptions is HasDecimalPlaces<FormatOptions>;
99
101
  export declare function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions>;
100
- export declare function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions;
101
- export declare function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions;
102
- export declare function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions;
103
- export declare function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions;
102
+ export declare function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions & WithCustomLabel;
103
+ export declare function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions & WithCustomLabel;
104
+ export declare function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions & WithCustomLabel;
105
+ export declare function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions & WithCustomLabel;
104
106
  export {};
105
107
  //# sourceMappingURL=units.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/model/units.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;GAMG;AAEH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAU1E,CAAC;AACF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUd,CAAC;AAEX,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,iBAAiB,GACjB,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CAIlD;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,cAAc,CAAC,aAAa,CAAC,CAIlH;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,uBAAuB,GAAG,eAAe,CAE5D;AAED,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,qBAAqB,GAAG,eAAe,CAErH;AAED,wBAAgB,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,iBAAiB,GAAG,eAAe,CAE7G;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,wBAAwB,GAAG,eAAe,CAE7D"}
@@ -13,6 +13,7 @@
13
13
  import { formatBits, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from "./bits.js";
14
14
  import { formatBytes, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from "./bytes.js";
15
15
  import { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG } from "./currency.js";
16
+ import { applyCustomLabel, supportsCustomLabel } from "./custom.js";
16
17
  import { formatDate, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from "./date.js";
17
18
  import { formatDecimal, DECIMAL_GROUP_CONFIG, DECIMAL_UNIT_CONFIG } from "./decimal.js";
18
19
  import { formatPercent, PERCENT_GROUP_CONFIG, PERCENT_UNIT_CONFIG } from "./percent.js";
@@ -51,39 +52,43 @@ export function formatValue(value, formatOptions) {
51
52
  if (!formatOptions) {
52
53
  return value.toString();
53
54
  }
55
+ let formatted;
54
56
  if (isBytesUnit(formatOptions)) {
55
- return formatBytes(value, formatOptions);
57
+ formatted = formatBytes(value, formatOptions);
58
+ } else if (isBitsUnit(formatOptions)) {
59
+ formatted = formatBits(value, formatOptions);
60
+ } else if (isDecimalUnit(formatOptions)) {
61
+ formatted = formatDecimal(value, formatOptions);
62
+ } else if (isPercentUnit(formatOptions)) {
63
+ formatted = formatPercent(value, formatOptions);
64
+ } else if (isTimeUnit(formatOptions)) {
65
+ formatted = formatTime(value, formatOptions);
66
+ } else if (isThroughputUnit(formatOptions)) {
67
+ formatted = formatThroughput(value, formatOptions);
68
+ } else if (isCurrencyUnit(formatOptions)) {
69
+ formatted = formatCurrency(value, formatOptions);
70
+ } else if (isDateUnit(formatOptions)) {
71
+ formatted = formatDate(value, formatOptions);
72
+ } else if (isTemperatureUnit(formatOptions)) {
73
+ formatted = formatTemperature(value, formatOptions);
74
+ } else {
75
+ const exhaustive = formatOptions;
76
+ throw new Error(`Unknown unit options ${exhaustive}`);
56
77
  }
57
- if (isBitsUnit(formatOptions)) {
58
- return formatBits(value, formatOptions);
59
- }
60
- if (isDecimalUnit(formatOptions)) {
61
- return formatDecimal(value, formatOptions);
62
- }
63
- if (isPercentUnit(formatOptions)) {
64
- return formatPercent(value, formatOptions);
65
- }
66
- if (isTimeUnit(formatOptions)) {
67
- return formatTime(value, formatOptions);
68
- }
69
- if (isThroughputUnit(formatOptions)) {
70
- return formatThroughput(value, formatOptions);
71
- }
72
- if (isCurrencyUnit(formatOptions)) {
73
- return formatCurrency(value, formatOptions);
74
- }
75
- if (isDateUnit(formatOptions)) {
76
- return formatDate(value, formatOptions);
77
- }
78
- if (isTemperatureUnit(formatOptions)) {
79
- return formatTemperature(value, formatOptions);
80
- }
81
- const exhaustive = formatOptions;
82
- throw new Error(`Unknown unit options ${exhaustive}`);
78
+ return applyCustomLabel(formatted, formatOptions.customLabel, formatOptions.unit);
83
79
  }
84
80
  export function getUnitConfig(formatOptions) {
85
81
  const unit = formatOptions.unit ?? 'decimal';
86
- return UNIT_CONFIG[unit];
82
+ const config = UNIT_CONFIG[unit];
83
+ const customLabel = formatOptions.customLabel?.trim();
84
+ // Only override display name when customLabel is supported for this unit key.
85
+ if (customLabel && supportsCustomLabel(unit)) {
86
+ return {
87
+ ...config,
88
+ label: customLabel
89
+ };
90
+ }
91
+ return config;
87
92
  }
88
93
  export function getUnitGroup(formatOptions) {
89
94
  return getUnitConfig(formatOptions).group ?? 'Decimal';