@perses-dev/components 0.8.0 → 0.9.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 (131) hide show
  1. package/dist/Drawer/Drawer.d.ts +3 -4
  2. package/dist/Drawer/Drawer.d.ts.map +1 -1
  3. package/dist/Drawer/Drawer.js +35 -1
  4. package/dist/Drawer/Drawer.js.map +1 -0
  5. package/dist/Drawer/index.js +15 -1
  6. package/dist/Drawer/index.js.map +1 -0
  7. package/dist/EChart.d.ts.map +1 -1
  8. package/dist/EChart.js +142 -1
  9. package/dist/EChart.js.map +1 -0
  10. package/dist/ErrorAlert.js +25 -1
  11. package/dist/ErrorAlert.js.map +1 -0
  12. package/dist/ErrorBoundary.js +16 -1
  13. package/dist/ErrorBoundary.js.map +1 -0
  14. package/dist/GaugeChart/GaugeChart.js +172 -1
  15. package/dist/GaugeChart/GaugeChart.js.map +1 -0
  16. package/dist/GaugeChart/index.js +15 -1
  17. package/dist/GaugeChart/index.js.map +1 -0
  18. package/dist/InfoTooltip/InfoTooltip.js +79 -1
  19. package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
  20. package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
  21. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
  22. package/dist/InfoTooltip/index.js +15 -1
  23. package/dist/InfoTooltip/index.js.map +1 -0
  24. package/dist/LineChart/LineChart.js +198 -1
  25. package/dist/LineChart/LineChart.js.map +1 -0
  26. package/dist/LineChart/index.js +15 -1
  27. package/dist/LineChart/index.js.map +1 -0
  28. package/dist/LineChart/utils.js +63 -1
  29. package/dist/LineChart/utils.js.map +1 -0
  30. package/dist/StatChart/StatChart.js +121 -1
  31. package/dist/StatChart/StatChart.js.map +1 -0
  32. package/dist/StatChart/StatChart.test.js +82 -1
  33. package/dist/StatChart/StatChart.test.js.map +1 -0
  34. package/dist/StatChart/index.js +15 -1
  35. package/dist/StatChart/index.js.map +1 -0
  36. package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
  37. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
  38. package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
  39. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
  40. package/dist/TimeRangeSelector/index.js +16 -1
  41. package/dist/TimeRangeSelector/index.js.map +1 -0
  42. package/dist/TimeRangeSelector/utils.js +36 -1
  43. package/dist/TimeRangeSelector/utils.js.map +1 -0
  44. package/dist/Tooltip/SeriesInfo.js +143 -1
  45. package/dist/Tooltip/SeriesInfo.js.map +1 -0
  46. package/dist/Tooltip/SeriesMarker.js +33 -1
  47. package/dist/Tooltip/SeriesMarker.js.map +1 -0
  48. package/dist/Tooltip/Tooltip.js +72 -1
  49. package/dist/Tooltip/Tooltip.js.map +1 -0
  50. package/dist/Tooltip/TooltipContent.js +89 -1
  51. package/dist/Tooltip/TooltipContent.js.map +1 -0
  52. package/dist/Tooltip/focused-series.js +108 -1
  53. package/dist/Tooltip/focused-series.js.map +1 -0
  54. package/dist/Tooltip/focused-series.test.js +75 -1
  55. package/dist/Tooltip/focused-series.test.js.map +1 -0
  56. package/dist/Tooltip/index.js +16 -1
  57. package/dist/Tooltip/index.js.map +1 -0
  58. package/dist/Tooltip/tooltip-model.js +80 -1
  59. package/dist/Tooltip/tooltip-model.js.map +1 -0
  60. package/dist/Tooltip/utils.js +46 -1
  61. package/dist/Tooltip/utils.js.map +1 -0
  62. package/dist/cjs/Drawer/Drawer.js +26 -13
  63. package/dist/cjs/Drawer/index.js +16 -17
  64. package/dist/cjs/EChart.js +114 -89
  65. package/dist/cjs/ErrorAlert.js +16 -12
  66. package/dist/cjs/ErrorBoundary.js +10 -6
  67. package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
  68. package/dist/cjs/GaugeChart/index.js +16 -17
  69. package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
  70. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
  71. package/dist/cjs/InfoTooltip/index.js +16 -17
  72. package/dist/cjs/LineChart/LineChart.js +122 -87
  73. package/dist/cjs/LineChart/index.js +16 -17
  74. package/dist/cjs/LineChart/utils.js +23 -23
  75. package/dist/cjs/StatChart/StatChart.js +107 -46
  76. package/dist/cjs/StatChart/StatChart.test.js +65 -21
  77. package/dist/cjs/StatChart/index.js +16 -17
  78. package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
  79. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
  80. package/dist/cjs/TimeRangeSelector/index.js +17 -18
  81. package/dist/cjs/TimeRangeSelector/utils.js +19 -16
  82. package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
  83. package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
  84. package/dist/cjs/Tooltip/Tooltip.js +95 -67
  85. package/dist/cjs/Tooltip/TooltipContent.js +76 -31
  86. package/dist/cjs/Tooltip/focused-series.js +40 -36
  87. package/dist/cjs/Tooltip/focused-series.test.js +36 -16
  88. package/dist/cjs/Tooltip/index.js +17 -18
  89. package/dist/cjs/Tooltip/tooltip-model.js +46 -30
  90. package/dist/cjs/Tooltip/utils.js +13 -16
  91. package/dist/cjs/context/ChartsThemeProvider.js +65 -13
  92. package/dist/cjs/index.js +27 -28
  93. package/dist/cjs/model/graph.js +10 -5
  94. package/dist/cjs/model/index.js +18 -19
  95. package/dist/cjs/model/theme.js +4 -2
  96. package/dist/cjs/model/units.js +68 -51
  97. package/dist/cjs/test/index.js +16 -17
  98. package/dist/cjs/test/render.js +22 -12
  99. package/dist/cjs/test/setup-tests.js +4 -2
  100. package/dist/cjs/utils/combine-sx.js +15 -16
  101. package/dist/cjs/utils/index.js +17 -18
  102. package/dist/cjs/utils/theme-gen.js +64 -55
  103. package/dist/cjs/utils/theme-gen.test.js +14 -12
  104. package/dist/context/ChartsThemeProvider.js +36 -1
  105. package/dist/context/ChartsThemeProvider.js.map +1 -0
  106. package/dist/index.js +26 -1
  107. package/dist/index.js.map +1 -0
  108. package/dist/model/graph.js +15 -1
  109. package/dist/model/graph.js.map +1 -0
  110. package/dist/model/index.js +17 -1
  111. package/dist/model/index.js.map +1 -0
  112. package/dist/model/theme.js +15 -1
  113. package/dist/model/theme.js.map +1 -0
  114. package/dist/model/units.d.ts.map +1 -1
  115. package/dist/model/units.js +196 -1
  116. package/dist/model/units.js.map +1 -0
  117. package/dist/test/index.js +15 -1
  118. package/dist/test/index.js.map +1 -0
  119. package/dist/test/render.js +32 -1
  120. package/dist/test/render.js.map +1 -0
  121. package/dist/test/setup-tests.js +18 -1
  122. package/dist/test/setup-tests.js.map +1 -0
  123. package/dist/utils/combine-sx.js +27 -1
  124. package/dist/utils/combine-sx.js.map +1 -0
  125. package/dist/utils/index.js +16 -1
  126. package/dist/utils/index.js.map +1 -0
  127. package/dist/utils/theme-gen.js +183 -1
  128. package/dist/utils/theme-gen.js.map +1 -0
  129. package/dist/utils/theme-gen.test.js +196 -1
  130. package/dist/utils/theme-gen.test.js.map +1 -0
  131. package/package.json +8 -4
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/units.ts"],"sourcesContent":["// Copyright 2022 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 { Duration, milliseconds } from 'date-fns';\nimport { round } from 'mathjs';\n\nexport const DEFAULT_DECIMAL_PLACES = 2;\n\nexport type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions | BytesUnitOptions;\n\nexport function formatValue(value: number, unitOptions?: UnitOptions): string {\n if (unitOptions === undefined) {\n return value.toString();\n }\n\n if (isDecimalUnit(unitOptions)) {\n return formatDecimal(value, unitOptions);\n }\n\n if (isTimeUnit(unitOptions)) {\n return formatTime(value, unitOptions);\n }\n\n if (isPercentUnit(unitOptions)) {\n return formatPercent(value, unitOptions);\n }\n\n if (isBytesUnit(unitOptions)) {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n return formatBytes(value, decimals);\n }\n\n const exhaustive: never = unitOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\n/* Time Unit Conversion */\nconst timeUnitKinds = ['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Days', 'Weeks', 'Months', 'Years'] as const;\nconst timeUnitKindsSet = new Set<string>(timeUnitKinds);\n\ntype TimeUnitOptions = {\n kind: typeof timeUnitKinds[number];\n};\n\nfunction isTimeUnit(unitOptions: UnitOptions): unitOptions is TimeUnitOptions {\n return timeUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatTime(value: number, unitOptions: TimeUnitOptions): string {\n // Create a Duration from the value based on what time unit it is\n const duration: Duration = {};\n switch (unitOptions.kind) {\n case 'Milliseconds':\n duration.seconds = value / 1000;\n break;\n case 'Seconds':\n duration.seconds = value;\n break;\n case 'Minutes':\n duration.minutes = value;\n break;\n case 'Hours':\n duration.hours = value;\n break;\n case 'Days':\n duration.days = value;\n break;\n case 'Weeks':\n duration.weeks = value;\n break;\n case 'Months':\n duration.months = value;\n break;\n case 'Years':\n duration.years = value;\n break;\n default: {\n const exhaustive: never = unitOptions.kind;\n throw new Error(`Unknown time unit type ${exhaustive}`);\n }\n }\n\n // Find the largest whole time unit we can display the value in and use it\n const ms = milliseconds(duration);\n const seconds = ms / 1000;\n if (seconds < 1) {\n return `${ms.toFixed()} milliseconds`;\n }\n\n const minutes = seconds / 60;\n if (minutes < 1) {\n return `${seconds.toFixed()} seconds`;\n }\n\n const hours = minutes / 60;\n if (hours < 1) {\n return `${minutes.toFixed()} minutes`;\n }\n\n const days = hours / 24;\n if (days < 1) {\n return `${hours.toFixed()} hours`;\n }\n\n const weeks = days / 7;\n if (weeks < 1) {\n return `${days.toFixed()} days`;\n }\n\n const years = weeks / 52;\n if (years < 1) {\n return `${weeks.toFixed()} weeks`;\n }\n\n return `${years.toFixed()} years`;\n}\n\n/* Percent Unit Conversion */\nconst percentUnitKinds = ['Percent', 'PercentDecimal', '%'] as const;\nconst percentUnitKindsSet = new Set<string>(percentUnitKinds);\n\ntype PercentUnitOptions = {\n kind: typeof percentUnitKinds[number];\n decimal_places?: number;\n};\n\nfunction isPercentUnit(unitOptions: UnitOptions): unitOptions is PercentUnitOptions {\n return percentUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatPercent(value: number, unitOptions: PercentUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.kind === 'PercentDecimal') {\n value = value * 100;\n }\n\n return value.toFixed(decimals) + '%';\n}\n\n/* Decimal Unit Conversion */\nconst decimalUnitKinds = ['Decimal'] as const;\nconst decimalUnitKindsSet = new Set<string>(decimalUnitKinds);\n\ntype DecimalUnitOptions = {\n kind: typeof decimalUnitKinds[number];\n decimal_places?: number;\n abbreviate?: boolean;\n};\n\nfunction isDecimalUnit(unitOptions: UnitOptions): unitOptions is DecimalUnitOptions {\n return decimalUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatDecimal(value: number, unitOptions: DecimalUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.abbreviate === true) {\n return abbreviateLargeNumber(value, decimals);\n }\n\n const formatParams: Intl.NumberFormatOptions = {\n style: 'decimal',\n minimumFractionDigits: 0,\n maximumFractionDigits: decimals,\n useGrouping: true,\n };\n const decimalFormatter = new Intl.NumberFormat('en-US', formatParams);\n return decimalFormatter.format(value);\n}\n\n/**\n * Takes large numbers and abbreviates them with the appropriate suffix\n * 10123 -> 10.123k\n * 1000000 -> 1M\n */\nexport function abbreviateLargeNumber(num: number, decimals = 2) {\n const modifier = (n: number) => round(n, decimals);\n return formatNumber(num, modifier);\n}\n\n/**\n * Takes large numbers, rounds and abbreviates them with the appropriate suffix\n * Add modifier to run on output value prior to unit being added (defaults to rounding)\n */\nexport function formatNumber(num: number, modifier?: (n: number) => number): string {\n const fn = modifier ?? Math.round;\n\n return num >= 1e12\n ? fn(num / 1e12) + 'T'\n : num >= 1e9\n ? fn(num / 1e9) + 'B'\n : num >= 1e6\n ? fn(num / 1e6) + 'M'\n : num >= 1e3\n ? fn(num / 1e3) + 'K'\n : num.toString();\n}\n\n/* Bytes Unit Conversion */\nconst bytesUnitKinds = ['Bytes'] as const;\nconst bytesUnitKindsSet = new Set<string>(bytesUnitKinds);\n\ntype BytesUnitOptions = {\n kind: typeof bytesUnitKinds[number];\n decimal_places?: number;\n};\n\nfunction isBytesUnit(unitOptions: UnitOptions): unitOptions is BytesUnitOptions {\n return bytesUnitKindsSet.has(unitOptions.kind);\n}\n\n// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript/18650828#18650828\nfunction formatBytes(bytes: number, decimals = 2) {\n if (bytes === 0) return '0 Bytes';\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n // Math.max(0, ...) ensures that we don't return -1 as a value for the index.\n // Why? When the number of bytes are between -1 and 1, Math.floor(Math.log(bytes)/Math.log(1024)) returns -1.\n const i = Math.max(0, Math.floor(Math.log(bytes) / Math.log(k)));\n\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n}\n"],"names":["milliseconds","round","DEFAULT_DECIMAL_PLACES","formatValue","value","unitOptions","undefined","toString","isDecimalUnit","formatDecimal","isTimeUnit","formatTime","isPercentUnit","formatPercent","isBytesUnit","decimals","decimal_places","formatBytes","exhaustive","Error","timeUnitKinds","timeUnitKindsSet","Set","has","kind","duration","seconds","minutes","hours","days","weeks","months","years","ms","toFixed","percentUnitKinds","percentUnitKindsSet","decimalUnitKinds","decimalUnitKindsSet","abbreviate","abbreviateLargeNumber","formatParams","style","minimumFractionDigits","maximumFractionDigits","useGrouping","decimalFormatter","Intl","NumberFormat","format","num","modifier","n","formatNumber","fn","Math","bytesUnitKinds","bytesUnitKindsSet","bytes","k","dm","sizes","i","max","floor","log","parseFloat","pow"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAmBA,YAAY,QAAQ,UAAU,CAAC;AAClD,SAASC,KAAK,QAAQ,QAAQ,CAAC;AAE/B,OAAO,MAAMC,sBAAsB,GAAG,CAAC,CAAC;AAIxC,OAAO,SAASC,WAAW,CAACC,KAAa,EAAEC,WAAyB,EAAU;IAC5E,IAAIA,WAAW,KAAKC,SAAS,EAAE;QAC7B,OAAOF,KAAK,CAACG,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,IAAIC,aAAa,CAACH,WAAW,CAAC,EAAE;QAC9B,OAAOI,aAAa,CAACL,KAAK,EAAEC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,IAAIK,UAAU,CAACL,WAAW,CAAC,EAAE;QAC3B,OAAOM,UAAU,CAACP,KAAK,EAAEC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,IAAIO,aAAa,CAACP,WAAW,CAAC,EAAE;QAC9B,OAAOQ,aAAa,CAACT,KAAK,EAAEC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,IAAIS,WAAW,CAACT,WAAW,CAAC,EAAE;YACXA,eAA0B;QAA3C,MAAMU,QAAQ,GAAGV,CAAAA,eAA0B,GAA1BA,WAAW,CAACW,cAAc,cAA1BX,eAA0B,cAA1BA,eAA0B,GAAIH,sBAAsB,AAAC;QACtE,OAAOe,WAAW,CAAC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ensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './render';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/index.ts"],"sourcesContent":["// Copyright 2022 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 './render';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU,CAAC"}
@@ -1 +1,32 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{render}from"@testing-library/react";import{QueryClient,QueryClientProvider}from"react-query";const queryClient=new QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}});export function renderWithContext(e,r){return render(_jsx(QueryClientProvider,{client:queryClient,children:e}),r)}
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { render } from '@testing-library/react';
15
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
16
+ const queryClient = new QueryClient({
17
+ defaultOptions: {
18
+ queries: {
19
+ refetchOnWindowFocus: false
20
+ }
21
+ }
22
+ });
23
+ /**
24
+ * Test helper to render a React component with some common app-level providers wrapped around it.
25
+ */ export function renderWithContext(ui, options) {
26
+ return render(/*#__PURE__*/ _jsx(QueryClientProvider, {
27
+ client: queryClient,
28
+ children: ui
29
+ }), options);
30
+ }
31
+
32
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2022 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 { render, RenderOptions } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n\nconst queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>) {\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","queryClient","defaultOptions","queries","refetchOnWindowFocus","renderWithContext","ui","options","client"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAuB,wBAAwB,CAAC;AAC/D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AAEzE,MAAMC,WAAW,GAAG,IAAIF,WAAW,CAAC;IAAEG,cAAc,EAAE;QAAEC,OAAO,EAAE;YAAEC,oBAAoB,EAAE,KAAK;SAAE;KAAE;CAAE,CAAC,AAAC;AAEtG;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,EAAsB,EAAEC,OAAwC,EAAE;IAClG,OAAOT,MAAM,eAAC,KAACE,mBAAmB;QAACQ,MAAM,EAAEP,WAAW;kBAAGK,EAAE;MAAuB,EAAEC,OAAO,CAAC,CAAC;AAC/F,CAAC"}
@@ -1 +1,18 @@
1
- import"@testing-library/jest-dom/extend-expect";jest.mock("echarts/core");
1
+ // Copyright 2022 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
+ // Add testing library assertions
14
+ import '@testing-library/jest-dom/extend-expect';
15
+ // Always mock e-charts during tests since we don't have a proper canvas in jsdom
16
+ jest.mock('echarts/core');
17
+
18
+ //# sourceMappingURL=setup-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2022 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// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,iCAAiC;AACjC,OAAO,yCAAyC,CAAC;AAEjD,iFAAiF;AACjFA,IAAI,CAACC,IAAI,CAAC,cAAc,CAAC,CAAC"}
@@ -1 +1,27 @@
1
- export function combineSx(...r){return r.flatMap((r=>void 0===r?[]:Array.isArray(r)?r:[r]))}
1
+ // Copyright 2022 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
+ * Combines sx props from multiple sources. Useful when creating a component and
15
+ * you want consumers to be able to provide SxProps that should be combined with
16
+ * some built-in styles.
17
+ */ export function combineSx(...sxProps) {
18
+ return sxProps.flatMap((sx)=>{
19
+ if (sx === undefined) return [];
20
+ if (Array.isArray(sx)) return sx;
21
+ return [
22
+ sx
23
+ ];
24
+ });
25
+ }
26
+
27
+ //# sourceMappingURL=combine-sx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/combine-sx.ts"],"sourcesContent":["// Copyright 2022 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 { SxProps, Theme } from '@mui/material';\n\n/**\n * Combines sx props from multiple sources. Useful when creating a component and\n * you want consumers to be able to provide SxProps that should be combined with\n * some built-in styles.\n */\nexport function combineSx(...sxProps: Array<SxProps<Theme> | undefined>): SxProps<Theme> {\n return sxProps.flatMap((sx) => {\n if (sx === undefined) return [];\n if (Array.isArray(sx)) return sx;\n return [sx];\n });\n}\n"],"names":["combineSx","sxProps","flatMap","sx","undefined","Array","isArray"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC;;;;CAIC,GACD,OAAO,SAASA,SAAS,CAAC,GAAGC,OAAO,AAAmC,EAAkB;IACvF,OAAOA,OAAO,CAACC,OAAO,CAAC,CAACC,EAAE,GAAK;QAC7B,IAAIA,EAAE,KAAKC,SAAS,EAAE,OAAO,EAAE,CAAC;QAChC,IAAIC,KAAK,CAACC,OAAO,CAACH,EAAE,CAAC,EAAE,OAAOA,EAAE,CAAC;QACjC,OAAO;YAACA,EAAE;SAAC,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1,16 @@
1
- export*from"./combine-sx";export*from"./theme-gen";
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './combine-sx';
14
+ export * from './theme-gen';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2022 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 './combine-sx';\nexport * from './theme-gen';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -1 +1,183 @@
1
- import merge from"lodash/merge";const DEFAULT_TEXT_COLOR="#222";export function generateChartsTheme(e,t,o){var l,i,a,r,n,s;const h=null!==(i=null===(l=t.palette.text)||void 0===l?void 0:l.primary)&&void 0!==i?i:"#222",d={title:{show:!1},textStyle:{color:h,fontFamily:t.typography.fontFamily,fontSize:12},grid:{top:5,right:20,bottom:0,left:20,containLabel:!0},color:["#8dd3c7","#bebada","#fb8072","#80b1d3","#fdb462"],categoryAxis:{show:!0,axisLabel:{show:!0,color:h,margin:15},axisTick:{show:!1,length:6,lineStyle:{color:t.palette.grey[600]}},axisLine:{show:!0,lineStyle:{color:t.palette.grey[600]}},splitLine:{show:!0,lineStyle:{width:.5,color:t.palette.grey[300],opacity:.6}},splitArea:{show:!1,areaStyle:{color:[t.palette.grey[300]]}}},valueAxis:{show:!0,axisLabel:{color:h,margin:12},axisLine:{show:!1},splitLine:{show:!0,lineStyle:{width:.5,color:t.palette.grey[300],opacity:.6}}},legend:{orient:"horizontal",textStyle:{color:h},pageTextStyle:{color:t.palette.grey[600]},pageIconColor:null===(r=null===(a=null==t?void 0:t.palette)||void 0===a?void 0:a.action)||void 0===r?void 0:r.active,pageIconInactiveColor:null===(s=null===(n=null==t?void 0:t.palette)||void 0===n?void 0:n.action)||void 0===s?void 0:s.disabled},toolbox:{show:!0,top:10,right:10,iconStyle:{borderColor:h}},tooltip:{},line:{showSymbol:!1,symbol:"circle",symbolSize:4,smooth:!1,lineStyle:{width:1},emphasis:{lineStyle:{width:1.5}}},bar:{barMaxWidth:150,itemStyle:{borderWidth:0,borderColor:t.palette.grey[300]}},gauge:{detail:{fontSize:18,fontWeight:600,valueAnimation:!1},splitLine:{distance:0,length:4,lineStyle:{width:1}},splitNumber:12}};return{themeName:e,echartsTheme:merge(d,o),noDataOption:{title:{show:!0,textStyle:{color:h,fontSize:16,fontWeight:400},text:"No data",left:"center",top:"center"},xAxis:{show:!1},yAxis:{show:!1}},sparkline:{width:2,color:"#1976d2"}}}
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { merge } from 'lodash-es';
14
+ const DEFAULT_TEXT_COLOR = '#222';
15
+ export function generateChartsTheme(themeName, muiTheme, echartsTheme) {
16
+ var ref, ref1, ref2, ref3, ref4;
17
+ var ref5;
18
+ const primaryTextColor = (ref5 = (ref = muiTheme.palette.text) === null || ref === void 0 ? void 0 : ref.primary) !== null && ref5 !== void 0 ? ref5 : DEFAULT_TEXT_COLOR;
19
+ const muiConvertedTheme = {
20
+ title: {
21
+ show: false
22
+ },
23
+ textStyle: {
24
+ color: primaryTextColor,
25
+ fontFamily: muiTheme.typography.fontFamily,
26
+ fontSize: 12
27
+ },
28
+ grid: {
29
+ top: 5,
30
+ right: 20,
31
+ bottom: 0,
32
+ left: 20,
33
+ containLabel: true
34
+ },
35
+ color: [
36
+ '#8dd3c7',
37
+ '#bebada',
38
+ '#fb8072',
39
+ '#80b1d3',
40
+ '#fdb462'
41
+ ],
42
+ categoryAxis: {
43
+ show: true,
44
+ axisLabel: {
45
+ show: true,
46
+ color: primaryTextColor,
47
+ margin: 15
48
+ },
49
+ axisTick: {
50
+ show: false,
51
+ length: 6,
52
+ lineStyle: {
53
+ color: muiTheme.palette.grey[600]
54
+ }
55
+ },
56
+ axisLine: {
57
+ show: true,
58
+ lineStyle: {
59
+ color: muiTheme.palette.grey[600]
60
+ }
61
+ },
62
+ splitLine: {
63
+ show: true,
64
+ lineStyle: {
65
+ width: 0.5,
66
+ color: muiTheme.palette.grey[300],
67
+ opacity: 0.6
68
+ }
69
+ },
70
+ splitArea: {
71
+ show: false,
72
+ areaStyle: {
73
+ color: [
74
+ muiTheme.palette.grey[300]
75
+ ]
76
+ }
77
+ }
78
+ },
79
+ valueAxis: {
80
+ show: true,
81
+ axisLabel: {
82
+ color: primaryTextColor,
83
+ margin: 12
84
+ },
85
+ axisLine: {
86
+ show: false
87
+ },
88
+ splitLine: {
89
+ show: true,
90
+ lineStyle: {
91
+ width: 0.5,
92
+ color: muiTheme.palette.grey[300],
93
+ opacity: 0.6
94
+ }
95
+ }
96
+ },
97
+ legend: {
98
+ orient: 'horizontal',
99
+ textStyle: {
100
+ color: primaryTextColor
101
+ },
102
+ pageTextStyle: {
103
+ color: muiTheme.palette.grey[600]
104
+ },
105
+ pageIconColor: muiTheme === null || muiTheme === void 0 ? void 0 : (ref1 = muiTheme.palette) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.action) === null || ref2 === void 0 ? void 0 : ref2.active,
106
+ pageIconInactiveColor: muiTheme === null || muiTheme === void 0 ? void 0 : (ref3 = muiTheme.palette) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.action) === null || ref4 === void 0 ? void 0 : ref4.disabled
107
+ },
108
+ toolbox: {
109
+ show: true,
110
+ top: 10,
111
+ right: 10,
112
+ iconStyle: {
113
+ borderColor: primaryTextColor
114
+ }
115
+ },
116
+ tooltip: {},
117
+ line: {
118
+ showSymbol: false,
119
+ symbol: 'circle',
120
+ symbolSize: 4,
121
+ smooth: false,
122
+ lineStyle: {
123
+ width: 1
124
+ },
125
+ emphasis: {
126
+ lineStyle: {
127
+ width: 1.5
128
+ }
129
+ }
130
+ },
131
+ bar: {
132
+ barMaxWidth: 150,
133
+ itemStyle: {
134
+ borderWidth: 0,
135
+ borderColor: muiTheme.palette.grey[300]
136
+ }
137
+ },
138
+ gauge: {
139
+ detail: {
140
+ fontSize: 18,
141
+ fontWeight: 600,
142
+ valueAnimation: false
143
+ },
144
+ splitLine: {
145
+ distance: 0,
146
+ length: 4,
147
+ lineStyle: {
148
+ width: 1
149
+ }
150
+ },
151
+ splitNumber: 12
152
+ }
153
+ };
154
+ return {
155
+ themeName,
156
+ echartsTheme: merge(muiConvertedTheme, echartsTheme),
157
+ noDataOption: {
158
+ title: {
159
+ show: true,
160
+ textStyle: {
161
+ color: primaryTextColor,
162
+ fontSize: 16,
163
+ fontWeight: 400
164
+ },
165
+ text: 'No data',
166
+ left: 'center',
167
+ top: 'center'
168
+ },
169
+ xAxis: {
170
+ show: false
171
+ },
172
+ yAxis: {
173
+ show: false
174
+ }
175
+ },
176
+ sparkline: {
177
+ width: 2,
178
+ color: '#1976d2'
179
+ }
180
+ };
181
+ }
182
+
183
+ //# sourceMappingURL=theme-gen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/theme-gen.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { merge } from 'lodash-es';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(\n themeName: string,\n muiTheme: MuiTheme,\n echartsTheme: EChartsTheme\n): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n color: ['#8dd3c7', '#bebada', '#fb8072', '#80b1d3', '#fdb462'],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {},\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return {\n themeName,\n echartsTheme: merge(muiConvertedTheme, echartsTheme),\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n // TODO: add thresholdColors to theme\n };\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","themeName","muiTheme","echartsTheme","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","line","showSymbol","symbol","symbolSize","smooth","emphasis","bar","barMaxWidth","itemStyle","borderWidth","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","noDataOption","xAxis","yAxis","sparkline"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,KAAK,QAAQ,WAAW,CAAC;AAGlC,MAAMC,kBAAkB,GAAG,MAAM,AAAC;AAKlC,OAAO,SAASC,mBAAmB,CACjCC,SAAiB,EACjBC,QAAkB,EAClBC,YAA0B,EACP;QACMD,GAAqB,EAgF3BA,IAAiB,QACTA,IAAiB;QAjFnBA,IAA8B;IAAvD,MAAME,gBAAgB,GAAGF,CAAAA,IAA8B,GAA9BA,CAAAA,GAAqB,GAArBA,QAAQ,CAACG,OAAO,CAACC,IAAI,cAArBJ,GAAqB,WAAS,GAA9BA,KAAAA,CAA8B,GAA9BA,GAAqB,CAAEK,OAAO,cAA9BL,IAA8B,cAA9BA,IAA8B,GAAIH,kBAAkB,AAAC;IAE9E,MAAMS,iBAAiB,GAAiB;QACtCC,KAAK,EAAE;YACLC,IAAI,EAAE,KAAK;SACZ;QACDC,SAAS,EAAE;YACTC,KAAK,EAAER,gBAAgB;YACvBS,UAAU,EAAEX,QAAQ,CAACY,UAAU,CAACD,UAAU;YAC1CE,QAAQ,EAAE,EAAE;SACb;QACDC,IAAI,EAAE;YACJC,GAAG,EAAE,CAAC;YACNC,KAAK,EAAE,EAAE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B,SAAS,EAAE;oBACTI,KAAK,EAAE,GAAG;iBACX;aACF;SACF;QACDuB,GAAG,EAAE;YACHC,WAAW,EAAE,GAAG;YAChBC,SAAS,EAAE;gBACTC,WAAW,EAAE,CAAC;gBACdX,WAAW,EAAE5C,QAAQ,CAACG,OAAO,CAACuB,IAAI,CAAC,GAAG,CAAC;aACxC;SACF;QACD8B,KAAK,EAAE;YACLC,MAAM,EAAE;gBACN5C,QAAQ,EAAE,EAAE;gBACZ6C,UAAU,EAAE,GAAG;gBACfC,cAAc,EAAE,KAAK;aACtB;YACD/B,SAAS,EAAE;gBACTgC,QAAQ,EAAE,CAAC;gBACXpC,MAAM,EAAE,CAAC;gBACTC,SAAS,EAAE;oBACTI,KAAK,EAAE,CAAC;iBACT;aACF;YACDgC,WAAW,EAAE,EAAE;SAChB;KACF,AAAC;IAEF,OAAO;QACL9D,SAAS;QACTE,YAAY,EAAEL,KAAK,CAACU,iBAAiB,EAAEL,YAAY,CAAC;QACpD6D,YAAY,EAAE;YACZvD,KAAK,EAAE;gBACLC,IAAI,EAAE,IAAI;gBACVC,SAAS,EAAE;oBACTC,KAAK,EAAER,gBAAgB;oBACvBW,QAAQ,EAAE,EAAE;oBACZ6C,UAAU,EAAE,GAAG;iBAChB;gBACDtD,IAAI,EAAE,SAAS;gBACfc,IAAI,EAAE,QAAQ;gBACdH,GAAG,EAAE,QAAQ;aACd;YACDgD,KAAK,EAAE;gBACLvD,IAAI,EAAE,KAAK;aACZ;YACDwD,KAAK,EAAE;gBACLxD,IAAI,EAAE,KAAK;aACZ;SACF;QACDyD,SAAS,EAAE;YACTpC,KAAK,EAAE,CAAC;YACRnB,KAAK,EAAE,SAAS;SACjB;KAEF,CAAC;AACJ,CAAC"}
@@ -1 +1,196 @@
1
- import{createTheme}from"@mui/material";import{generateChartsTheme}from"./theme-gen";describe("generateChartsTheme",(()=>{const n=createTheme({}),e=generateChartsTheme("perses",n,{legend:{textStyle:{color:"yellow"}},line:{showSymbol:!0,smooth:!0}});it("should return perses specific charts theme from converted MUI theme",(()=>{expect(e).toMatchInlineSnapshot('\n Object {\n "echartsTheme": Object {\n "bar": Object {\n "barMaxWidth": 150,\n "itemStyle": Object {\n "borderColor": "#e0e0e0",\n "borderWidth": 0,\n },\n },\n "categoryAxis": Object {\n "axisLabel": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "margin": 15,\n "show": true,\n },\n "axisLine": Object {\n "lineStyle": Object {\n "color": "#757575",\n },\n "show": true,\n },\n "axisTick": Object {\n "length": 6,\n "lineStyle": Object {\n "color": "#757575",\n },\n "show": false,\n },\n "show": true,\n "splitArea": Object {\n "areaStyle": Object {\n "color": Array [\n "#e0e0e0",\n ],\n },\n "show": false,\n },\n "splitLine": Object {\n "lineStyle": Object {\n "color": "#e0e0e0",\n "opacity": 0.6,\n "width": 0.5,\n },\n "show": true,\n },\n },\n "color": Array [\n "#8dd3c7",\n "#bebada",\n "#fb8072",\n "#80b1d3",\n "#fdb462",\n ],\n "gauge": Object {\n "detail": Object {\n "fontSize": 18,\n "fontWeight": 600,\n "valueAnimation": false,\n },\n "splitLine": Object {\n "distance": 0,\n "length": 4,\n "lineStyle": Object {\n "width": 1,\n },\n },\n "splitNumber": 12,\n },\n "grid": Object {\n "bottom": 0,\n "containLabel": true,\n "left": 20,\n "right": 20,\n "top": 5,\n },\n "legend": Object {\n "orient": "horizontal",\n "pageIconColor": "rgba(0, 0, 0, 0.54)",\n "pageIconInactiveColor": "rgba(0, 0, 0, 0.26)",\n "pageTextStyle": Object {\n "color": "#757575",\n },\n "textStyle": Object {\n "color": "yellow",\n },\n },\n "line": Object {\n "emphasis": Object {\n "lineStyle": Object {\n "width": 1.5,\n },\n },\n "lineStyle": Object {\n "width": 1,\n },\n "showSymbol": true,\n "smooth": true,\n "symbol": "circle",\n "symbolSize": 4,\n },\n "textStyle": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif",\n "fontSize": 12,\n },\n "title": Object {\n "show": false,\n },\n "toolbox": Object {\n "iconStyle": Object {\n "borderColor": "rgba(0, 0, 0, 0.87)",\n },\n "right": 10,\n "show": true,\n "top": 10,\n },\n "tooltip": Object {},\n "valueAxis": Object {\n "axisLabel": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "margin": 12,\n },\n "axisLine": Object {\n "show": false,\n },\n "show": true,\n "splitLine": Object {\n "lineStyle": Object {\n "color": "#e0e0e0",\n "opacity": 0.6,\n "width": 0.5,\n },\n "show": true,\n },\n },\n },\n "noDataOption": Object {\n "title": Object {\n "left": "center",\n "show": true,\n "text": "No data",\n "textStyle": Object {\n "color": "rgba(0, 0, 0, 0.87)",\n "fontSize": 16,\n "fontWeight": 400,\n },\n "top": "center",\n },\n "xAxis": Object {\n "show": false,\n },\n "yAxis": Object {\n "show": false,\n },\n },\n "sparkline": Object {\n "color": "#1976d2",\n "width": 2,\n },\n "themeName": "perses",\n }\n ')}))}));
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { createTheme } from '@mui/material';
14
+ import { generateChartsTheme } from './theme-gen';
15
+ describe('generateChartsTheme', ()=>{
16
+ const muiTheme = createTheme({});
17
+ const echartsThemeOverrides = {
18
+ legend: {
19
+ textStyle: {
20
+ color: 'yellow'
21
+ }
22
+ },
23
+ line: {
24
+ showSymbol: true,
25
+ smooth: true
26
+ }
27
+ };
28
+ const chartsTheme = generateChartsTheme('perses', muiTheme, echartsThemeOverrides);
29
+ it('should return perses specific charts theme from converted MUI theme', ()=>{
30
+ expect(chartsTheme).toMatchInlineSnapshot(`
31
+ Object {
32
+ "echartsTheme": Object {
33
+ "bar": Object {
34
+ "barMaxWidth": 150,
35
+ "itemStyle": Object {
36
+ "borderColor": "#e0e0e0",
37
+ "borderWidth": 0,
38
+ },
39
+ },
40
+ "categoryAxis": Object {
41
+ "axisLabel": Object {
42
+ "color": "rgba(0, 0, 0, 0.87)",
43
+ "margin": 15,
44
+ "show": true,
45
+ },
46
+ "axisLine": Object {
47
+ "lineStyle": Object {
48
+ "color": "#757575",
49
+ },
50
+ "show": true,
51
+ },
52
+ "axisTick": Object {
53
+ "length": 6,
54
+ "lineStyle": Object {
55
+ "color": "#757575",
56
+ },
57
+ "show": false,
58
+ },
59
+ "show": true,
60
+ "splitArea": Object {
61
+ "areaStyle": Object {
62
+ "color": Array [
63
+ "#e0e0e0",
64
+ ],
65
+ },
66
+ "show": false,
67
+ },
68
+ "splitLine": Object {
69
+ "lineStyle": Object {
70
+ "color": "#e0e0e0",
71
+ "opacity": 0.6,
72
+ "width": 0.5,
73
+ },
74
+ "show": true,
75
+ },
76
+ },
77
+ "color": Array [
78
+ "#8dd3c7",
79
+ "#bebada",
80
+ "#fb8072",
81
+ "#80b1d3",
82
+ "#fdb462",
83
+ ],
84
+ "gauge": Object {
85
+ "detail": Object {
86
+ "fontSize": 18,
87
+ "fontWeight": 600,
88
+ "valueAnimation": false,
89
+ },
90
+ "splitLine": Object {
91
+ "distance": 0,
92
+ "length": 4,
93
+ "lineStyle": Object {
94
+ "width": 1,
95
+ },
96
+ },
97
+ "splitNumber": 12,
98
+ },
99
+ "grid": Object {
100
+ "bottom": 0,
101
+ "containLabel": true,
102
+ "left": 20,
103
+ "right": 20,
104
+ "top": 5,
105
+ },
106
+ "legend": Object {
107
+ "orient": "horizontal",
108
+ "pageIconColor": "rgba(0, 0, 0, 0.54)",
109
+ "pageIconInactiveColor": "rgba(0, 0, 0, 0.26)",
110
+ "pageTextStyle": Object {
111
+ "color": "#757575",
112
+ },
113
+ "textStyle": Object {
114
+ "color": "yellow",
115
+ },
116
+ },
117
+ "line": Object {
118
+ "emphasis": Object {
119
+ "lineStyle": Object {
120
+ "width": 1.5,
121
+ },
122
+ },
123
+ "lineStyle": Object {
124
+ "width": 1,
125
+ },
126
+ "showSymbol": true,
127
+ "smooth": true,
128
+ "symbol": "circle",
129
+ "symbolSize": 4,
130
+ },
131
+ "textStyle": Object {
132
+ "color": "rgba(0, 0, 0, 0.87)",
133
+ "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif",
134
+ "fontSize": 12,
135
+ },
136
+ "title": Object {
137
+ "show": false,
138
+ },
139
+ "toolbox": Object {
140
+ "iconStyle": Object {
141
+ "borderColor": "rgba(0, 0, 0, 0.87)",
142
+ },
143
+ "right": 10,
144
+ "show": true,
145
+ "top": 10,
146
+ },
147
+ "tooltip": Object {},
148
+ "valueAxis": Object {
149
+ "axisLabel": Object {
150
+ "color": "rgba(0, 0, 0, 0.87)",
151
+ "margin": 12,
152
+ },
153
+ "axisLine": Object {
154
+ "show": false,
155
+ },
156
+ "show": true,
157
+ "splitLine": Object {
158
+ "lineStyle": Object {
159
+ "color": "#e0e0e0",
160
+ "opacity": 0.6,
161
+ "width": 0.5,
162
+ },
163
+ "show": true,
164
+ },
165
+ },
166
+ },
167
+ "noDataOption": Object {
168
+ "title": Object {
169
+ "left": "center",
170
+ "show": true,
171
+ "text": "No data",
172
+ "textStyle": Object {
173
+ "color": "rgba(0, 0, 0, 0.87)",
174
+ "fontSize": 16,
175
+ "fontWeight": 400,
176
+ },
177
+ "top": "center",
178
+ },
179
+ "xAxis": Object {
180
+ "show": false,
181
+ },
182
+ "yAxis": Object {
183
+ "show": false,
184
+ },
185
+ },
186
+ "sparkline": Object {
187
+ "color": "#1976d2",
188
+ "width": 2,
189
+ },
190
+ "themeName": "perses",
191
+ }
192
+ `);
193
+ });
194
+ });
195
+
196
+ //# sourceMappingURL=theme-gen.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/theme-gen.test.ts"],"sourcesContent":["// Copyright 2022 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 { createTheme } from '@mui/material';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\nimport { generateChartsTheme } from './theme-gen';\n\ndescribe('generateChartsTheme', () => {\n const muiTheme = createTheme({});\n const echartsThemeOverrides: EChartsTheme = {\n legend: {\n textStyle: {\n color: 'yellow',\n },\n },\n line: {\n showSymbol: true,\n smooth: true,\n },\n };\n const chartsTheme: PersesChartsTheme = generateChartsTheme('perses', muiTheme, echartsThemeOverrides);\n\n it('should return perses specific charts theme from converted MUI theme', () => {\n expect(chartsTheme).toMatchInlineSnapshot(`\n Object {\n \"echartsTheme\": Object {\n \"bar\": Object {\n \"barMaxWidth\": 150,\n \"itemStyle\": Object {\n \"borderColor\": \"#e0e0e0\",\n \"borderWidth\": 0,\n },\n },\n \"categoryAxis\": Object {\n \"axisLabel\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"margin\": 15,\n \"show\": true,\n },\n \"axisLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#757575\",\n },\n \"show\": true,\n },\n \"axisTick\": Object {\n \"length\": 6,\n \"lineStyle\": Object {\n \"color\": \"#757575\",\n },\n \"show\": false,\n },\n \"show\": true,\n \"splitArea\": Object {\n \"areaStyle\": Object {\n \"color\": Array [\n \"#e0e0e0\",\n ],\n },\n \"show\": false,\n },\n \"splitLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#e0e0e0\",\n \"opacity\": 0.6,\n \"width\": 0.5,\n },\n \"show\": true,\n },\n },\n \"color\": Array [\n \"#8dd3c7\",\n \"#bebada\",\n \"#fb8072\",\n \"#80b1d3\",\n \"#fdb462\",\n ],\n \"gauge\": Object {\n \"detail\": Object {\n \"fontSize\": 18,\n \"fontWeight\": 600,\n \"valueAnimation\": false,\n },\n \"splitLine\": Object {\n \"distance\": 0,\n \"length\": 4,\n \"lineStyle\": Object {\n \"width\": 1,\n },\n },\n \"splitNumber\": 12,\n },\n \"grid\": Object {\n \"bottom\": 0,\n \"containLabel\": true,\n \"left\": 20,\n \"right\": 20,\n \"top\": 5,\n },\n \"legend\": Object {\n \"orient\": \"horizontal\",\n \"pageIconColor\": \"rgba(0, 0, 0, 0.54)\",\n \"pageIconInactiveColor\": \"rgba(0, 0, 0, 0.26)\",\n \"pageTextStyle\": Object {\n \"color\": \"#757575\",\n },\n \"textStyle\": Object {\n \"color\": \"yellow\",\n },\n },\n \"line\": Object {\n \"emphasis\": Object {\n \"lineStyle\": Object {\n \"width\": 1.5,\n },\n },\n \"lineStyle\": Object {\n \"width\": 1,\n },\n \"showSymbol\": true,\n \"smooth\": true,\n \"symbol\": \"circle\",\n \"symbolSize\": 4,\n },\n \"textStyle\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"fontFamily\": \"\\\\\"Roboto\\\\\", \\\\\"Helvetica\\\\\", \\\\\"Arial\\\\\", sans-serif\",\n \"fontSize\": 12,\n },\n \"title\": Object {\n \"show\": false,\n },\n \"toolbox\": Object {\n \"iconStyle\": Object {\n \"borderColor\": \"rgba(0, 0, 0, 0.87)\",\n },\n \"right\": 10,\n \"show\": true,\n \"top\": 10,\n },\n \"tooltip\": Object {},\n \"valueAxis\": Object {\n \"axisLabel\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"margin\": 12,\n },\n \"axisLine\": Object {\n \"show\": false,\n },\n \"show\": true,\n \"splitLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#e0e0e0\",\n \"opacity\": 0.6,\n \"width\": 0.5,\n },\n \"show\": true,\n },\n },\n },\n \"noDataOption\": Object {\n \"title\": Object {\n \"left\": \"center\",\n \"show\": true,\n \"text\": \"No data\",\n \"textStyle\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"fontSize\": 16,\n \"fontWeight\": 400,\n },\n \"top\": \"center\",\n },\n \"xAxis\": Object {\n \"show\": false,\n },\n \"yAxis\": Object {\n \"show\": false,\n },\n },\n \"sparkline\": Object {\n \"color\": \"#1976d2\",\n \"width\": 2,\n },\n \"themeName\": \"perses\",\n }\n `);\n });\n});\n"],"names":["createTheme","generateChartsTheme","describe","muiTheme","echartsThemeOverrides","legend","textStyle","color","line","showSymbol","smooth","chartsTheme","it","expect","toMatchInlineSnapshot"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,eAAe,CAAC;AAE5C,SAASC,mBAAmB,QAAQ,aAAa,CAAC;AAElDC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,QAAQ,GAAGH,WAAW,CAAC,EAAE,CAAC,AAAC;IACjC,MAAMI,qBAAqB,GAAiB;QAC1CC,MAAM,EAAE;YACNC,SAAS,EAAE;gBACTC,KAAK,EAAE,QAAQ;aAChB;SACF;QACDC,IAAI,EAAE;YACJC,UAAU,EAAE,IAAI;YAChBC,MAAM,EAAE,IAAI;SACb;KACF,AAAC;IACF,MAAMC,WAAW,GAAsBV,mBAAmB,CAAC,QAAQ,EAAEE,QAAQ,EAAEC,qBAAqB,CAAC,AAAC;IAEtGQ,EAAE,CAAC,qEAAqE,EAAE,IAAM;QAC9EC,MAAM,CAACF,WAAW,CAAC,CAACG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkK3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}