@perses-dev/plugin-system 0.21.1 → 0.23.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 (155) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +1 -1
  3. package/dist/cjs/components/CalculationSelector/index.js +1 -1
  4. package/dist/cjs/components/DatasourceSelect.js +1 -1
  5. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
  6. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +26 -86
  7. package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +1 -1
  8. package/dist/cjs/components/OptionsEditorTabs/index.js +1 -1
  9. package/dist/cjs/components/PluginEditor/PluginEditor.js +1 -1
  10. package/dist/cjs/components/PluginEditor/PluginEditor.test.js +1 -1
  11. package/dist/cjs/components/PluginEditor/index.js +1 -1
  12. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
  13. package/dist/cjs/components/PluginKindSelect.js +1 -1
  14. package/dist/cjs/components/PluginKindSelect.test.js +1 -1
  15. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  16. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +1 -1
  17. package/dist/cjs/components/PluginRegistry/index.js +1 -1
  18. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +1 -1
  19. package/dist/cjs/components/PluginSpecEditor.js +39 -5
  20. package/dist/cjs/components/PluginSpecEditor.test.js +31 -9
  21. package/dist/cjs/components/TimeSeriesQueryEditor.js +1 -1
  22. package/dist/cjs/components/index.js +1 -1
  23. package/dist/cjs/index.js +1 -1
  24. package/dist/cjs/model/calculations.js +1 -1
  25. package/dist/cjs/model/datasource.js +1 -1
  26. package/dist/cjs/model/index.js +1 -1
  27. package/dist/cjs/model/panels.js +7 -1
  28. package/dist/cjs/model/plugin-base.js +1 -1
  29. package/dist/cjs/model/plugin-loading.js +1 -1
  30. package/dist/cjs/model/plugins.js +1 -1
  31. package/dist/cjs/model/time-series-queries.js +1 -1
  32. package/dist/cjs/model/variables.js +1 -1
  33. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  34. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
  35. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +1 -1
  36. package/dist/cjs/runtime/datasources.js +10 -2
  37. package/dist/cjs/runtime/index.js +1 -1
  38. package/dist/cjs/runtime/plugin-registry.js +1 -1
  39. package/dist/cjs/runtime/template-variables.js +1 -1
  40. package/dist/cjs/runtime/time-series-queries.js +1 -1
  41. package/dist/cjs/test/index.js +1 -1
  42. package/dist/cjs/test/render.js +1 -1
  43. package/dist/cjs/test/setup-tests.js +1 -1
  44. package/dist/cjs/test/test-plugins/bert/index.js +33 -20
  45. package/dist/cjs/test/test-plugins/ernie/index.js +1 -1
  46. package/dist/cjs/test/test-plugins/index.js +1 -1
  47. package/dist/cjs/test-utils/index.js +1 -1
  48. package/dist/cjs/test-utils/mock-plugin-registry.js +1 -1
  49. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  50. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  51. package/dist/components/CalculationSelector/CalculationSelector.test.js +1 -1
  52. package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -1
  53. package/dist/components/CalculationSelector/index.js +1 -1
  54. package/dist/components/CalculationSelector/index.js.map +1 -1
  55. package/dist/components/DatasourceSelect.js +1 -1
  56. package/dist/components/DatasourceSelect.js.map +1 -1
  57. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -24
  58. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  59. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
  60. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  61. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +26 -86
  62. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -1
  63. package/dist/components/OptionsEditorTabs/TabPanel.js +1 -1
  64. package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -1
  65. package/dist/components/OptionsEditorTabs/index.js +1 -1
  66. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  67. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  68. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  69. package/dist/components/PluginEditor/PluginEditor.test.js +1 -1
  70. package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -1
  71. package/dist/components/PluginEditor/index.js +1 -1
  72. package/dist/components/PluginEditor/index.js.map +1 -1
  73. package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
  74. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  75. package/dist/components/PluginKindSelect.js +1 -1
  76. package/dist/components/PluginKindSelect.js.map +1 -1
  77. package/dist/components/PluginKindSelect.test.js +1 -1
  78. package/dist/components/PluginKindSelect.test.js.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  80. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  81. package/dist/components/PluginRegistry/PluginRegistry.test.js +1 -1
  82. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -1
  83. package/dist/components/PluginRegistry/index.js +1 -1
  84. package/dist/components/PluginRegistry/index.js.map +1 -1
  85. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  86. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  87. package/dist/components/PluginSpecEditor.d.ts.map +1 -1
  88. package/dist/components/PluginSpecEditor.js +40 -6
  89. package/dist/components/PluginSpecEditor.js.map +1 -1
  90. package/dist/components/PluginSpecEditor.test.js +31 -9
  91. package/dist/components/PluginSpecEditor.test.js.map +1 -1
  92. package/dist/components/TimeSeriesQueryEditor.js +1 -1
  93. package/dist/components/TimeSeriesQueryEditor.js.map +1 -1
  94. package/dist/components/index.js +1 -1
  95. package/dist/components/index.js.map +1 -1
  96. package/dist/index.js +1 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/model/calculations.js +1 -1
  99. package/dist/model/calculations.js.map +1 -1
  100. package/dist/model/datasource.js +1 -1
  101. package/dist/model/datasource.js.map +1 -1
  102. package/dist/model/index.js +1 -1
  103. package/dist/model/index.js.map +1 -1
  104. package/dist/model/panels.d.ts +14 -2
  105. package/dist/model/panels.d.ts.map +1 -1
  106. package/dist/model/panels.js +2 -2
  107. package/dist/model/panels.js.map +1 -1
  108. package/dist/model/plugin-base.d.ts +1 -1
  109. package/dist/model/plugin-base.d.ts.map +1 -1
  110. package/dist/model/plugin-base.js +1 -1
  111. package/dist/model/plugin-base.js.map +1 -1
  112. package/dist/model/plugin-loading.js +1 -1
  113. package/dist/model/plugin-loading.js.map +1 -1
  114. package/dist/model/plugins.js +1 -1
  115. package/dist/model/plugins.js.map +1 -1
  116. package/dist/model/time-series-queries.js +1 -1
  117. package/dist/model/time-series-queries.js.map +1 -1
  118. package/dist/model/variables.js +1 -1
  119. package/dist/model/variables.js.map +1 -1
  120. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  121. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  122. package/dist/runtime/TimeRangeProvider/index.js +1 -1
  123. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  124. package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
  125. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  126. package/dist/runtime/datasources.d.ts +4 -0
  127. package/dist/runtime/datasources.d.ts.map +1 -1
  128. package/dist/runtime/datasources.js +10 -1
  129. package/dist/runtime/datasources.js.map +1 -1
  130. package/dist/runtime/index.js +1 -1
  131. package/dist/runtime/index.js.map +1 -1
  132. package/dist/runtime/plugin-registry.js +1 -1
  133. package/dist/runtime/plugin-registry.js.map +1 -1
  134. package/dist/runtime/template-variables.js +1 -1
  135. package/dist/runtime/template-variables.js.map +1 -1
  136. package/dist/runtime/time-series-queries.js +1 -1
  137. package/dist/runtime/time-series-queries.js.map +1 -1
  138. package/dist/test/index.js +1 -1
  139. package/dist/test/index.js.map +1 -1
  140. package/dist/test/render.js +1 -1
  141. package/dist/test/render.js.map +1 -1
  142. package/dist/test/setup-tests.js +1 -1
  143. package/dist/test/setup-tests.js.map +1 -1
  144. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  145. package/dist/test/test-plugins/bert/index.js +33 -20
  146. package/dist/test/test-plugins/bert/index.js.map +1 -1
  147. package/dist/test/test-plugins/ernie/index.js +1 -1
  148. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  149. package/dist/test/test-plugins/index.js +1 -1
  150. package/dist/test/test-plugins/index.js.map +1 -1
  151. package/dist/test-utils/index.js +1 -1
  152. package/dist/test-utils/index.js.map +1 -1
  153. package/dist/test-utils/mock-plugin-registry.js +1 -1
  154. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  155. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -27,7 +27,7 @@ _export(exports, {
27
27
  const _jsxRuntime = require("react/jsx-runtime");
28
28
  const BertPanel1 = {
29
29
  PanelComponent: ()=>null,
30
- OptionsEditorComponent: function BertPanel1Editor({ value , onChange }) {
30
+ PanelQueryEditorComponent: function BertPanel1Editor({ value , onChange }) {
31
31
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
32
32
  children: [
33
33
  /*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
@@ -52,25 +52,38 @@ const BertPanel1 = {
52
52
  };
53
53
  const BertPanel2 = {
54
54
  PanelComponent: ()=>null,
55
- OptionsEditorComponent: function BertPanel2Editor({ value , onChange }) {
56
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
57
- children: [
58
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
59
- htmlFor: "editor-input",
60
- children: "BertPanel2 editor"
61
- }),
62
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
63
- type: "text",
64
- id: "editor-input",
65
- value: value.option2,
66
- onChange: (e)=>onChange({
67
- ...value,
68
- option2: e.target.value
55
+ panelOptionsEditorComponents: [
56
+ {
57
+ label: 'Settings',
58
+ content: function BertPanel2Editor({ value , onChange }) {
59
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
60
+ children: [
61
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
62
+ htmlFor: "editor-input",
63
+ children: "BertPanel2 editor"
64
+ }),
65
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
66
+ type: "text",
67
+ id: "editor-input",
68
+ value: value.option2,
69
+ onChange: (e)=>onChange({
70
+ ...value,
71
+ option2: e.target.value
72
+ })
69
73
  })
70
- })
71
- ]
72
- });
73
- },
74
+ ]
75
+ });
76
+ }
77
+ },
78
+ {
79
+ label: 'Custom Tab',
80
+ content: function Editor() {
81
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
82
+ children: "custom content"
83
+ });
84
+ }
85
+ }
86
+ ],
74
87
  createInitialOptions: ()=>({
75
88
  option2: ''
76
89
  })
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.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 { TextField, Autocomplete } from '@mui/material';\nimport { OptionsEditorControl } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '../../model/calculations';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps) {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption) => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <Autocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleCalculationChange}\n disableClearable\n ></Autocomplete>\n }\n />\n );\n}\n"],"names":["TextField","Autocomplete","OptionsEditorControl","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","isOptionEqualToValue","option","renderInput","params","disableClearable"],"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,SAAS,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACxD,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAC9D,SAASC,mBAAmB,QAA4C,0BAA0B,CAAC;AAGnG,MAAMC,YAAY,GAAoCC,MAAM,CAACC,OAAO,CAACH,mBAAmB,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAC9G,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,AAAC;AAOH,OAAO,SAASC,mBAAmB,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAA4B,EAAE;IACjF,MAAMC,uBAAuB,GAAG,CAACC,CAAU,EAAEC,QAAuC,GAAK;QACvFH,QAAQ,CAACG,QAAQ,CAACP,EAAE,CAAC,CAAC;IACxB,CAAC,AAAC;IAEF,MAAMQ,UAAU,GAAGb,mBAAmB,CAACQ,KAAK,CAAC,AAAC;IAE9C,qBACE,KAACT,oBAAoB;QACnBe,KAAK,EAAC,aAAa;QACnBC,OAAO,gBACL,KAACjB,YAAY;YACXU,KAAK,EAAE;gBACL,GAAGK,UAAU;gBACbR,EAAE,EAAEG,KAAK;aACV;YACDQ,OAAO,EAAEf,YAAY;YACrBgB,oBAAoB,EAAE,CAACC,MAAM,EAAEV,KAAK,GAAKU,MAAM,CAACb,EAAE,KAAKG,KAAK,CAACH,EAAE;YAC/Dc,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACvB,SAAS;oBAAE,GAAGuB,MAAM;kBAAI;YAClDX,QAAQ,EAAEC,uBAAuB;YACjCW,gBAAgB;UACF;MAElB,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"sourcesContent":["// Copyright 2023 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 { TextField, Autocomplete } from '@mui/material';\nimport { OptionsEditorControl } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '../../model/calculations';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps) {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption) => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <Autocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleCalculationChange}\n disableClearable\n ></Autocomplete>\n }\n />\n );\n}\n"],"names":["TextField","Autocomplete","OptionsEditorControl","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","isOptionEqualToValue","option","renderInput","params","disableClearable"],"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,SAAS,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACxD,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAC9D,SAASC,mBAAmB,QAA4C,0BAA0B,CAAC;AAGnG,MAAMC,YAAY,GAAoCC,MAAM,CAACC,OAAO,CAACH,mBAAmB,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAC9G,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,AAAC;AAOH,OAAO,SAASC,mBAAmB,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAA4B,EAAE;IACjF,MAAMC,uBAAuB,GAAG,CAACC,CAAU,EAAEC,QAAuC,GAAK;QACvFH,QAAQ,CAACG,QAAQ,CAACP,EAAE,CAAC,CAAC;IACxB,CAAC,AAAC;IAEF,MAAMQ,UAAU,GAAGb,mBAAmB,CAACQ,KAAK,CAAC,AAAC;IAE9C,qBACE,KAACT,oBAAoB;QACnBe,KAAK,EAAC,aAAa;QACnBC,OAAO,gBACL,KAACjB,YAAY;YACXU,KAAK,EAAE;gBACL,GAAGK,UAAU;gBACbR,EAAE,EAAEG,KAAK;aACV;YACDQ,OAAO,EAAEf,YAAY;YACrBgB,oBAAoB,EAAE,CAACC,MAAM,EAAEV,KAAK,GAAKU,MAAM,CAACb,EAAE,KAAKG,KAAK,CAACH,EAAE;YAC/Dc,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACvB,SAAS;oBAAE,GAAGuB,MAAM;kBAAI;YAClDX,QAAQ,EAAEC,uBAAuB;YACjCW,gBAAgB;UACF;MAElB,CACF;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.test.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, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { CalculationType } from '../../model/calculations';\nimport { CalculationSelector } from './CalculationSelector';\n\ndescribe('CalculationSelector', () => {\n const renderCalculationSelector = (value: CalculationType, onChange = jest.fn()) => {\n render(\n <div>\n <CalculationSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getCalculationSelector = () => {\n return screen.getByRole('combobox', { name: 'Calculation' });\n };\n\n it('can change the calculation by clicking', () => {\n const onChange = jest.fn();\n renderCalculationSelector('Last', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.click(calcSelector);\n const sumOption = screen.getByRole('option', {\n name: 'Sum',\n });\n userEvent.click(sumOption);\n\n expect(onChange).toHaveBeenCalledWith('Sum');\n });\n\n it('can change the calculation using a keyboard', () => {\n const onChange = jest.fn();\n renderCalculationSelector('First', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.tab();\n expect(calcSelector).toHaveFocus();\n\n userEvent.clear(calcSelector);\n userEvent.keyboard('first');\n screen.getByRole('option', {\n name: 'First',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith('First');\n });\n});\n"],"names":["render","screen","userEvent","CalculationSelector","describe","renderCalculationSelector","value","onChange","jest","fn","div","getCalculationSelector","getByRole","name","it","calcSelector","click","sumOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard"],"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,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,mBAAmB,QAAQ,uBAAuB,CAAC;AAE5DC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,yBAAyB,GAAG,CAACC,KAAsB,EAAEC,QAAQ,GAAGC,IAAI,CAACC,E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C;QAC5BtB,MAAM,CAACW,SAAS,CAAC,QAAQ,EAAE;YACzBC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QAEHX,SAAS,CAACqB,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAEvCL,MAAM,CAACX,QAAQ,CAAC,CAACY,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.test.tsx"],"sourcesContent":["// Copyright 2023 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, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { CalculationType } from '../../model/calculations';\nimport { CalculationSelector } from './CalculationSelector';\n\ndescribe('CalculationSelector', () => {\n const renderCalculationSelector = (value: CalculationType, onChange = jest.fn()) => {\n render(\n <div>\n <CalculationSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getCalculationSelector = () => {\n return screen.getByRole('combobox', { name: 'Calculation' });\n };\n\n it('can change the calculation by clicking', () => {\n const onChange = jest.fn();\n renderCalculationSelector('Last', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.click(calcSelector);\n const sumOption = screen.getByRole('option', {\n name: 'Sum',\n });\n userEvent.click(sumOption);\n\n expect(onChange).toHaveBeenCalledWith('Sum');\n });\n\n it('can change the calculation using a keyboard', () => {\n const onChange = jest.fn();\n renderCalculationSelector('First', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.tab();\n expect(calcSelector).toHaveFocus();\n\n userEvent.clear(calcSelector);\n userEvent.keyboard('first');\n screen.getByRole('option', {\n name: 'First',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith('First');\n });\n});\n"],"names":["render","screen","userEvent","CalculationSelector","describe","renderCalculationSelector","value","onChange","jest","fn","div","getCalculationSelector","getByRole","name","it","calcSelector","click","sumOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard"],"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,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,mBAAmB,QAAQ,uBAAuB,CAAC;AAE5DC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,yBAAyB,GAAG,CAACC,KAAsB,EAAEC,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,GAAK;QAClFT,MAAM,eACJ,KAACU,KAAG;sBACF,cAAA,KAACP,mBAAmB;gBAACG,KAAK,EAAEA,KAAK;gBAAEC,QAAQ,EAAEA,QAAQ;cAAI;UACrD,CACP,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMI,sBAAsB,GAAG,IAAM;QACnC,OAAOV,MAAM,CAACW,SAAS,CAAC,UAAU,EAAE;YAAEC,IAAI,EAAE,aAAa;SAAE,CAAC,CAAC;IAC/D,CAAC,AAAC;IAEFC,EAAE,CAAC,wCAAwC,EAAE,IAAM;QACjD,MAAMP,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,yBAAyB,CAAC,MAAM,EAAEE,QAAQ,CAAC,CAAC;QAE5C,MAAMQ,YAAY,GAAGJ,sBAAsB,EAAE,AAAC;QAC9CT,SAAS,CAACc,KAAK,CAACD,YAAY,CAAC,CAAC;QAC9B,MAAME,SAAS,GAAGhB,MAAM,CAACW,SAAS,CAAC,QAAQ,EAAE;YAC3CC,IAAI,EAAE,KAAK;SACZ,CAAC,AAAC;QACHX,SAAS,CAACc,KAAK,CAACC,SAAS,CAAC,CAAC;QAE3BC,MAAM,CAACX,QAAQ,CAAC,CAACY,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEHL,EAAE,CAAC,6CAA6C,EAAE,IAAM;QACtD,MAAMP,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,AAAC;QAC3BJ,yBAAyB,CAAC,OAAO,EAAEE,QAAQ,CAAC,CAAC;QAE7C,MAAMQ,YAAY,GAAGJ,sBAAsB,EAAE,AAAC;QAC9CT,SAAS,CAACkB,GAAG,EAAE,CAAC;QAChBF,MAAM,CAACH,YAAY,CAAC,CAACM,WAAW,EAAE,CAAC;QAEnCnB,SAAS,CAACoB,KAAK,CAACP,YAAY,CAAC,CAAC;QAC9Bb,SAAS,CAACqB,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5BtB,MAAM,CAACW,SAAS,CAAC,QAAQ,EAAE;YACzBC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QAEHX,SAAS,CAACqB,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAEvCL,MAAM,CAACX,QAAQ,CAAC,CAACY,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/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 './CalculationSelector';\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,uBAAuB,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/index.ts"],"sourcesContent":["// Copyright 2023 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 './CalculationSelector';\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,uBAAuB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/DatasourceSelect.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 { Select, SelectProps, MenuItem } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { useMemo } from 'react';\nimport { useListDatasources } from '../runtime';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface DatasourceSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelector;\n onChange: (next: DatasourceSelector) => void;\n datasourcePluginKind: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps) {\n const { datasourcePluginKind, value, onChange, ...others } = props;\n const { data, isLoading } = useListDatasources(datasourcePluginKind);\n\n // Convert the datasource list into menu items with name/value strings that the Select input can work with\n const menuItems = useMemo(() => {\n if (data === undefined) return [];\n return data.map((ds) => ({ name: ds.name, value: selectorToOptionValue(ds.selector) }));\n }, [data]);\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : selectorToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n {menuItems.map((menuItem) => (\n <MenuItem key={menuItem.value} value={menuItem.value}>\n {menuItem.name}\n </MenuItem>\n ))}\n </Select>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n// Given a DatasourceSelector, returns a string value like `{kind}_____{name}` that can be used as a Select input value\nfunction selectorToOptionValue(selector: DatasourceSelector): string {\n return [selector.kind, selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n// Given an option value name like `{kind}_____{name}`, returns a DatasourceSelector\nfunction optionValueToSelector(optionValue: string): DatasourceSelector {\n const [kind, name] = optionValue.split(OPTION_VALUE_DELIMITER);\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n"],"names":["Select","MenuItem","useMemo","useListDatasources","DatasourceSelect","props","datasourcePluginKind","value","onChange","others","data","isLoading","menuItems","undefined","map","ds","name","selectorToOptionValue","selector","optionValue","handleChange","e","next","optionValueToSelector","target","menuItem","OPTION_VALUE_DELIMITER","kind","join","split","Error"],"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,EAAeC,QAAQ,QAAQ,eAAe,CAAC;AAE9D,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,kBAAkB,QAAQ,YAAY,CAAC;AAYhD;;;CAGC,GACD,OAAO,SAASC,gBAAgB,CAACC,KAA4B,EAAE;IAC7D,MAAM,EAAEC,oBAAoB,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGJ,KAAK,AAAC;IACnE,MAAM,EAAEK,IAAI,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGR,kBAAkB,CAACG,oBAAoB,CAAC,AAAC;IAErE,0GAA0G;IAC1G,MAAMM,SAAS,GAAGV,OAAO,C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;AAED,oFAAoF;AACpF,SAASH,qBAAqB,CAACJ,WAAmB,EAAsB;IACtE,MAAM,CAACQ,IAAI,EAAEX,IAAI,CAAC,GAAGG,WAAW,CAACU,KAAK,CAACH,sBAAsB,CAAC,AAAC;IAC/D,IAAIC,IAAI,KAAKd,SAAS,IAAIG,IAAI,KAAKH,SAAS,EAAE;QAC5C,MAAM,IAAIiB,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,OAAO;QACLH,IAAI;QACJX,IAAI,EAAEA,IAAI,KAAK,EAAE,GAAGH,SAAS,GAAGG,IAAI;KACrC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/components/DatasourceSelect.tsx"],"sourcesContent":["// Copyright 2023 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 { Select, SelectProps, MenuItem } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { useMemo } from 'react';\nimport { useListDatasources } from '../runtime';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface DatasourceSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelector;\n onChange: (next: DatasourceSelector) => void;\n datasourcePluginKind: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps) {\n const { datasourcePluginKind, value, onChange, ...others } = props;\n const { data, isLoading } = useListDatasources(datasourcePluginKind);\n\n // Convert the datasource list into menu items with name/value strings that the Select input can work with\n const menuItems = useMemo(() => {\n if (data === undefined) return [];\n return data.map((ds) => ({ name: ds.name, value: selectorToOptionValue(ds.selector) }));\n }, [data]);\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : selectorToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n {menuItems.map((menuItem) => (\n <MenuItem key={menuItem.value} value={menuItem.value}>\n {menuItem.name}\n </MenuItem>\n ))}\n </Select>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n// Given a DatasourceSelector, returns a string value like `{kind}_____{name}` that can be used as a Select input value\nfunction selectorToOptionValue(selector: DatasourceSelector): string {\n return [selector.kind, selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n// Given an option value name like `{kind}_____{name}`, returns a DatasourceSelector\nfunction optionValueToSelector(optionValue: string): DatasourceSelector {\n const [kind, name] = optionValue.split(OPTION_VALUE_DELIMITER);\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n"],"names":["Select","MenuItem","useMemo","useListDatasources","DatasourceSelect","props","datasourcePluginKind","value","onChange","others","data","isLoading","menuItems","undefined","map","ds","name","selectorToOptionValue","selector","optionValue","handleChange","e","next","optionValueToSelector","target","menuItem","OPTION_VALUE_DELIMITER","kind","join","split","Error"],"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,SAAS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QAAQ;gBAAsBM,KAAK,EAAEkB,QAAQ,CAAClB,KAAK;0BACjDkB,QAAQ,CAACT,IAAI;eADDS,QAAQ,CAAClB,KAAK,CAElB,AACZ,CAAC;MACK,CACT;AACJ,CAAC;AAED,kDAAkD;AAClD,MAAMmB,sBAAsB,GAAG,OAAO,AAAC;AAEvC,uHAAuH;AACvH,SAAST,qBAAqB,CAACC,QAA4B,EAAU;QAC5CA,KAAa;IAApC,OAAO;QAACA,QAAQ,CAACS,IAAI;QAAET,CAAAA,KAAa,GAAbA,QAAQ,CAACF,IAAI,cAAbE,KAAa,cAAbA,KAAa,GAAI,EAAE;KAAC,CAACU,IAAI,CAACF,sBAAsB,CAAC,CAAC;AAC3E,CAAC;AAED,oFAAoF;AACpF,SAASH,qBAAqB,CAACJ,WAAmB,EAAsB;IACtE,MAAM,CAACQ,IAAI,EAAEX,IAAI,CAAC,GAAGG,WAAW,CAACU,KAAK,CAACH,sBAAsB,CAAC,AAAC;IAC/D,IAAIC,IAAI,KAAKd,SAAS,IAAIG,IAAI,KAAKH,SAAS,EAAE;QAC5C,MAAM,IAAIiB,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,OAAO;QACLH,IAAI;QACJX,IAAI,EAAEA,IAAI,KAAK,EAAE,GAAGH,SAAS,GAAGG,IAAI;KACrC,CAAC;AACJ,CAAC"}
@@ -1,34 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { TabProps } from '@mui/material';
3
- interface BaseTabConfig {
2
+ export declare type OptionsEditorTab = {
3
+ label: string;
4
4
  /**
5
5
  * Content rendered when the tab is active.
6
6
  */
7
7
  content: React.ReactNode;
8
- }
9
- interface OtherTabConfig extends BaseTabConfig {
10
- id: string;
11
- label: TabProps['label'];
12
- }
13
- declare type CommonTabId = 'query' | 'settings' | 'json';
14
- /**
15
- * Common tabs that are frequently used in the options editor across multiple
16
- * plugins. The label and display order of these tabs is not configurable to
17
- * avoid user experience inconsistencies across plugins.
18
- */
19
- declare type CommonTabs = {
20
- [property in CommonTabId]?: BaseTabConfig;
21
- };
22
- /**
23
- * Custom tabs specified for a given plugin. They are displayed after common
24
- * tabs.
25
- */
26
- declare type OtherTabs = {
27
- other?: OtherTabConfig[];
28
8
  };
29
9
  export declare type OptionsEditorTabsProps = {
30
- tabs: CommonTabs & OtherTabs;
10
+ tabs: OptionsEditorTab[];
31
11
  };
32
12
  export declare const OptionsEditorTabs: ({ tabs }: OptionsEditorTabsProps) => JSX.Element;
33
- export {};
34
13
  //# sourceMappingURL=OptionsEditorTabs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionsEditorTabs.d.ts","sourceRoot":"","sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAwB,MAAM,eAAe,CAAC;AAIpE,UAAU,aAAa;IACrB;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,UAAU,cAAe,SAAQ,aAAa;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED,aAAK,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAEjD;;;;GAIG;AACH,aAAK,UAAU,GAAG;KAAG,QAAQ,IAAI,WAAW,CAAC,CAAC,EAAE,aAAa;CAAE,CAAC;AAEhE;;;GAGG;AACH,aAAK,SAAS,GAAG;IACf,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC;AAEF,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9B,CAAC;AAcF,eAAO,MAAM,iBAAiB,aAAc,sBAAsB,gBAyDjE,CAAC"}
1
+ {"version":3,"file":"OptionsEditorTabs.d.ts","sourceRoot":"","sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.tsx"],"names":[],"mappings":";AAiBA,oBAAY,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,CAAC;AAEF,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,gBAAgB,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,sBAAsB,gBAgCjE,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -14,54 +14,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  import { Tab, Tabs, Box } from '@mui/material';
15
15
  import { useState } from 'react';
16
16
  import { TabPanel } from './TabPanel';
17
- // Configuration of the order and labeling for tabs across plugins to enforce a
18
- // consistent UX.
19
- const TAB_CONFIG = [
20
- {
21
- id: 'query',
22
- label: 'Query'
23
- },
24
- {
25
- id: 'settings',
26
- label: 'Settings'
27
- },
28
- // Custom tabs go between the visual common tabs and the raw JSON editor.
29
- 'other',
30
- {
31
- id: 'json',
32
- label: 'JSON'
33
- }
34
- ];
35
17
  export const OptionsEditorTabs = ({ tabs })=>{
36
18
  const [activeTab, setActiveTab] = useState(0);
37
19
  const handleChange = (_, newValue)=>{
38
20
  setActiveTab(newValue);
39
21
  };
40
- // Normalize the common tabs that are managed via constants in this file
41
- // and custom tabs that bring their own config into a consistent shape for
42
- // rendering.
43
- const normalizedTabs = TAB_CONFIG.reduce((combinedTabs, tabConfig)=>{
44
- // Custom tabs
45
- if (tabConfig === 'other') {
46
- const otherTabs = (tabs === null || tabs === void 0 ? void 0 : tabs.other) || [];
47
- return [
48
- ...combinedTabs,
49
- ...otherTabs
50
- ];
51
- }
52
- // Common tabs
53
- const commonTab = tabs[tabConfig.id];
54
- if (commonTab) {
55
- return [
56
- ...combinedTabs,
57
- {
58
- ...tabConfig,
59
- ...commonTab
60
- }
61
- ];
62
- }
63
- return combinedTabs;
64
- }, []);
65
22
  return /*#__PURE__*/ _jsxs(_Fragment, {
66
23
  children: [
67
24
  /*#__PURE__*/ _jsx(Box, {
@@ -73,21 +30,21 @@ export const OptionsEditorTabs = ({ tabs })=>{
73
30
  value: activeTab,
74
31
  onChange: handleChange,
75
32
  "aria-label": "Panel configuration tabs",
76
- children: normalizedTabs.map(({ id , label }, i)=>{
33
+ children: tabs.map(({ label }, i)=>{
77
34
  return /*#__PURE__*/ _jsx(Tab, {
78
35
  label: label,
79
36
  id: `options-editor-tab-${i}`,
80
37
  "aria-controls": `options-editor-tabpanel-${i}`
81
- }, id);
38
+ }, label);
82
39
  })
83
40
  })
84
41
  }),
85
- normalizedTabs.map(({ id , content }, i)=>{
42
+ tabs.map(({ label , content }, i)=>{
86
43
  return /*#__PURE__*/ _jsx(TabPanel, {
87
44
  value: activeTab,
88
45
  index: i,
89
46
  children: content
90
- }, id);
47
+ }, label);
91
48
  })
92
49
  ]
93
50
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.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 { Tab, TabProps, Tabs, TabsProps, Box } from '@mui/material';\nimport { useState } from 'react';\nimport { TabPanel } from './TabPanel';\n\ninterface BaseTabConfig {\n /**\n * Content rendered when the tab is active.\n */\n content: React.ReactNode;\n}\n\ninterface OtherTabConfig extends BaseTabConfig {\n id: string;\n label: TabProps['label'];\n}\n\ntype CommonTabId = 'query' | 'settings' | 'json';\n\n/**\n * Common tabs that are frequently used in the options editor across multiple\n * plugins. The label and display order of these tabs is not configurable to\n * avoid user experience inconsistencies across plugins.\n */\ntype CommonTabs = { [property in CommonTabId]?: BaseTabConfig };\n\n/**\n * Custom tabs specified for a given plugin. They are displayed after common\n * tabs.\n */\ntype OtherTabs = {\n other?: OtherTabConfig[];\n};\n\nexport type OptionsEditorTabsProps = {\n tabs: CommonTabs & OtherTabs;\n};\n\n// Configuration of the order and labeling for tabs across plugins to enforce a\n// consistent UX.\nconst TAB_CONFIG = [\n { id: 'query', label: 'Query' },\n { id: 'settings', label: 'Settings' },\n\n // Custom tabs go between the visual common tabs and the raw JSON editor.\n 'other',\n\n { id: 'json', label: 'JSON' },\n] as const;\n\nexport const OptionsEditorTabs = ({ tabs }: OptionsEditorTabsProps) => {\n const [activeTab, setActiveTab] = useState(0);\n\n const handleChange: TabsProps['onChange'] = (_, newValue) => {\n setActiveTab(newValue);\n };\n\n // Normalize the common tabs that are managed via constants in this file\n // and custom tabs that bring their own config into a consistent shape for\n // rendering.\n const normalizedTabs = TAB_CONFIG.reduce((combinedTabs, tabConfig) => {\n // Custom tabs\n if (tabConfig === 'other') {\n const otherTabs = tabs?.other || [];\n return [...combinedTabs, ...otherTabs];\n }\n\n // Common tabs\n const commonTab = tabs[tabConfig.id];\n if (commonTab) {\n return [\n ...combinedTabs,\n {\n ...tabConfig,\n ...commonTab,\n },\n ];\n }\n\n return combinedTabs;\n }, [] as OtherTabConfig[]);\n\n return (\n <>\n <Box sx={{ borderBottom: 1, borderColor: (theme) => theme.palette.divider }}>\n <Tabs value={activeTab} onChange={handleChange} aria-label=\"Panel configuration tabs\">\n {normalizedTabs.map(({ id, label }, i) => {\n return (\n <Tab\n key={id}\n label={label}\n id={`options-editor-tab-${i}`}\n aria-controls={`options-editor-tabpanel-${i}`}\n />\n );\n })}\n </Tabs>\n </Box>\n {normalizedTabs.map(({ id, content }, i) => {\n return (\n <TabPanel key={id} value={activeTab} index={i}>\n {content}\n </TabPanel>\n );\n })}\n </>\n );\n};\n"],"names":["Tab","Tabs","Box","useState","TabPanel","TAB_CONFIG","id","label","OptionsEditorTabs","tabs","activeTab","setActiveTab","handleChange","_","newValue","normalizedTabs","reduce","combinedTabs","tabConfig","otherTabs","other","commonTab","sx","borderBottom","borderColor","theme","palette","divider","value","onChange","aria-label","map","i","aria-controls","content","index"],"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,GAAG,EAAYC,IAAI,EAAaC,GAAG,QAAQ,eAAe,CAAC;AACpE,SAASC,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,QAAQ,QAAQ,YAAY,CAAC;AAmCtC,+EAA+E;AAC/E,iBAAiB;AACjB,MAAMC,UAAU,GAAG;IACjB;QAAEC,EAAE,EAAE,OAAO;QAAEC,KAAK,EAAE,OAAO;KAAE;IAC/B;QAAED,EAAE,EAAE,UAAU;QAAEC,KAAK,EAAE,UAAU;KAAE;IAErC,yEAAyE;IACzE,OAAO;IAEP;QAAED,EAAE,EAAE,MAAM;QAAEC,KAAK,EAAE,MAAM;KAAE;CAC9B,AAAS,AAAC;AAEX,OAAO,MAAMC,iBAAiB,GAAG,CAAC,EAAEC,IAAI,CAAA,EAA0B,GAAK;IACrE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGR,QAAQ,CAAC,CAAC,CAAC,AAAC;IAE9C,MAAMS,YAAY,GAA0B,CAACC,CAAC,EAAEC,QAAQ,GAAK;QAC3DH,YAAY,CAACG,QAAQ,CAAC,CAAC;IACzB,CAAC,AAAC;IAEF,wEAAwE;IACxE,0EAA0E;IAC1E,aAAa;IACb,MAAMC,cAAc,GAAGV,UAAU,CAACW,MAAM,C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AAA,EAAE,EAAEF,CAAC,GAAK;gBAC1C,qBACE,KAAC5B,QAAQ;oBAAUwB,KAAK,EAAElB,SAAS;oBAAEyB,KAAK,EAAEH,CAAC;8BAC1CE,OAAO;mBADK5B,EAAE,CAEN,CACX;YACJ,CAAC,CAAC;;MACD,CACH;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.tsx"],"sourcesContent":["// Copyright 2023 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 { Tab, Tabs, TabsProps, Box } from '@mui/material';\nimport { useState } from 'react';\nimport { TabPanel } from './TabPanel';\n\nexport type OptionsEditorTab = {\n label: string;\n /**\n * Content rendered when the tab is active.\n */\n content: React.ReactNode;\n};\n\nexport type OptionsEditorTabsProps = {\n tabs: OptionsEditorTab[];\n};\n\nexport const OptionsEditorTabs = ({ tabs }: OptionsEditorTabsProps) => {\n const [activeTab, setActiveTab] = useState(0);\n\n const handleChange: TabsProps['onChange'] = (_, newValue) => {\n setActiveTab(newValue);\n };\n\n return (\n <>\n <Box sx={{ borderBottom: 1, borderColor: (theme) => theme.palette.divider }}>\n <Tabs value={activeTab} onChange={handleChange} aria-label=\"Panel configuration tabs\">\n {tabs.map(({ label }, i) => {\n return (\n <Tab\n key={label}\n label={label}\n id={`options-editor-tab-${i}`}\n aria-controls={`options-editor-tabpanel-${i}`}\n />\n );\n })}\n </Tabs>\n </Box>\n {tabs.map(({ label, content }, i) => {\n return (\n <TabPanel key={label} value={activeTab} index={i}>\n {content}\n </TabPanel>\n );\n })}\n </>\n );\n};\n"],"names":["Tab","Tabs","Box","useState","TabPanel","OptionsEditorTabs","tabs","activeTab","setActiveTab","handleChange","_","newValue","sx","borderBottom","borderColor","theme","palette","divider","value","onChange","aria-label","map","label","i","id","aria-controls","content","index"],"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,GAAG,EAAEC,IAAI,EAAaC,GAAG,QAAQ,eAAe,CAAC;AAC1D,SAASC,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,QAAQ,QAAQ,YAAY,CAAC;AActC,OAAO,MAAMC,iBAAiB,GAAG,CAAC,EAAEC,IAAI,CAAA,EAA0B,GAAK;IACrE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGL,QAAQ,CAAC,CAAC,CAAC,AAAC;IAE9C,MAAMM,YAAY,GAA0B,CAACC,CAAC,EAAEC,QAAQ,GAAK;QAC3DH,YAAY,CAACG,QAAQ,CAAC,CAAC;IACzB,CAAC,AAAC;IAEF,qBACE;;0BACE,KAACT,GAAG;gBAACU,EAAE,EAAE;oBAAEC,YAAY,EAAE,CAAC;oBAAEC,WAAW,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACC,OAAO;iBAAE;0BACzE,cAAA,KAAChB,IAAI;oBAACiB,KAAK,EAAEX,SAAS;oBAAEY,QAAQ,EAAEV,YAAY;oBAAEW,YAAU,EAAC,0BAA0B;8BAClFd,IAAI,CAACe,GAAG,CAAC,CAAC,EAAEC,KAAK,CAAA,EAAE,EAAEC,CAAC,GAAK;wBAC1B,qBACE,KAACvB,GAAG;4BAEFsB,KAAK,EAAEA,KAAK;4BACZE,EAAE,EAAE,CAAC,mBAAmB,EAAED,CAAC,CAAC,CAAC;4BAC7BE,eAAa,EAAE,CAAC,wBAAwB,EAAEF,CAAC,CAAC,CAAC;2BAHxCD,KAAK,CAIV,CACF;oBACJ,CAAC,CAAC;kBACG;cACH;YACLhB,IAAI,CAACe,GAAG,CAAC,CAAC,EAAEC,KAAK,CAAA,EAAEI,OAAO,CAAA,EAAE,EAAEH,CAAC,GAAK;gBACnC,qBACE,KAACnB,QAAQ;oBAAac,KAAK,EAAEX,SAAS;oBAAEoB,KAAK,EAAEJ,CAAC;8BAC7CG,OAAO;mBADKJ,KAAK,CAET,CACX;YACJ,CAAC,CAAC;;MACD,CACH;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -15,46 +15,32 @@ import { screen, render, getAllByRole } from '@testing-library/react';
15
15
  import userEvent from '@testing-library/user-event';
16
16
  import { OptionsEditorTabs } from './OptionsEditorTabs';
17
17
  describe('OptionsEditorTabs', ()=>{
18
+ const mockTabs = [
19
+ {
20
+ label: 'Query',
21
+ content: /*#__PURE__*/ _jsx("div", {
22
+ children: "Edit query configuration"
23
+ })
24
+ },
25
+ {
26
+ label: 'Settings',
27
+ content: /*#__PURE__*/ _jsx("div", {
28
+ children: "Edit settings configuration"
29
+ })
30
+ },
31
+ {
32
+ label: 'JSON',
33
+ content: /*#__PURE__*/ _jsx("div", {
34
+ children: "JSON editor"
35
+ })
36
+ }
37
+ ];
18
38
  const renderTabs = (otherTabs)=>{
39
+ const tabs = otherTabs !== null && otherTabs !== void 0 ? otherTabs : mockTabs;
19
40
  render(/*#__PURE__*/ _jsx(OptionsEditorTabs, {
20
- tabs: {
21
- query: {
22
- content: /*#__PURE__*/ _jsx("div", {
23
- children: "Edit query configuration"
24
- })
25
- },
26
- settings: {
27
- content: /*#__PURE__*/ _jsx("div", {
28
- children: "Edit settings configuration"
29
- })
30
- },
31
- json: {
32
- content: /*#__PURE__*/ _jsx("div", {
33
- children: "JSON editor"
34
- })
35
- },
36
- other: otherTabs
37
- }
41
+ tabs: tabs
38
42
  }));
39
43
  };
40
- const renderCustomTabs = ()=>{
41
- renderTabs([
42
- {
43
- id: 'tableCols',
44
- label: 'Table columns',
45
- content: /*#__PURE__*/ _jsx("div", {
46
- children: "custom table column"
47
- })
48
- },
49
- {
50
- id: 'tableOpts',
51
- label: 'Table options',
52
- content: /*#__PURE__*/ _jsx("div", {
53
- children: "custom table options"
54
- })
55
- }
56
- ]);
57
- };
58
44
  it('renders all specified tabs in a tab list', ()=>{
59
45
  renderTabs();
60
46
  const tabList = screen.getByRole('tablist');
@@ -100,59 +86,13 @@ describe('OptionsEditorTabs', ()=>{
100
86
  const activeTabPanel = screen.getByRole('tabpanel');
101
87
  expect(activeTabPanel).toHaveTextContent('settings configuration');
102
88
  });
103
- it('renders custom tabs between visual tabs and json editor', ()=>{
104
- renderCustomTabs();
89
+ it('renders tabs in correct order', ()=>{
90
+ renderTabs();
105
91
  const tabList = screen.getByRole('tablist');
106
92
  const tabs = getAllByRole(tabList, 'tab');
107
- expect(tabs).toHaveLength(5);
93
+ expect(tabs).toHaveLength(3);
108
94
  expect(tabs[0]).toHaveTextContent('Query');
109
95
  expect(tabs[1]).toHaveTextContent('Settings');
110
- expect(tabs[2]).toHaveTextContent('Table column');
111
- expect(tabs[3]).toHaveTextContent('Table options');
112
- expect(tabs[4]).toHaveTextContent('JSON');
113
- });
114
- it('shows the correct content when selecting a custom tab', ()=>{
115
- renderCustomTabs();
116
- const tableColTab = screen.getByRole('tab', {
117
- name: 'Table columns'
118
- });
119
- userEvent.click(tableColTab);
120
- const activeTab = screen.getByRole('tab', {
121
- selected: true
122
- });
123
- expect(activeTab).toBe(tableColTab);
124
- const activeTabPanel = screen.getByRole('tabpanel');
125
- expect(activeTabPanel).toHaveTextContent('custom table column');
126
- });
127
- it('only renders common tabs that are specified', ()=>{
128
- render(/*#__PURE__*/ _jsx(OptionsEditorTabs, {
129
- tabs: {
130
- settings: {
131
- content: /*#__PURE__*/ _jsx("div", {
132
- children: "settings are alone"
133
- })
134
- },
135
- json: {
136
- content: /*#__PURE__*/ _jsx("div", {
137
- children: "JSON is at the end"
138
- })
139
- },
140
- other: [
141
- {
142
- id: 'custom',
143
- label: 'Another tab',
144
- content: /*#__PURE__*/ _jsx("div", {
145
- children: "another tab content"
146
- })
147
- }
148
- ]
149
- }
150
- }));
151
- const tabList = screen.getByRole('tablist');
152
- const tabs = getAllByRole(tabList, 'tab');
153
- expect(tabs).toHaveLength(3);
154
- expect(tabs[0]).toHaveTextContent('Settings');
155
- expect(tabs[1]).toHaveTextContent('Another tab');
156
96
  expect(tabs[2]).toHaveTextContent('JSON');
157
97
  });
158
98
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.test.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 { screen, render, getAllByRole } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\n\nimport { OptionsEditorTabs, OptionsEditorTabsProps } from './OptionsEditorTabs';\n\ndescribe('OptionsEditorTabs', () => {\n const renderTabs = (otherTabs?: OptionsEditorTabsProps['tabs']['other']) => {\n render(\n <OptionsEditorTabs\n tabs={{\n query: {\n content: <div>Edit query configuration</div>,\n },\n settings: {\n content: <div>Edit settings configuration</div>,\n },\n json: {\n content: <div>JSON editor</div>,\n },\n other: otherTabs,\n }}\n />\n );\n };\n\n const renderCustomTabs = () => {\n renderTabs([\n {\n id: 'tableCols',\n label: 'Table columns',\n content: <div>custom table column</div>,\n },\n {\n id: 'tableOpts',\n label: 'Table options',\n content: <div>custom table options</div>,\n },\n ]);\n };\n\n it('renders all specified tabs in a tab list', () => {\n renderTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n\n it('defaults to selecting the first tab', () => {\n renderTabs();\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toHaveTextContent('Query');\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('query configuration');\n });\n\n it('switches selected tab on click', () => {\n renderTabs();\n const jsonTab = screen.getByRole('tab', { name: 'JSON' });\n userEvent.click(jsonTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(jsonTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('JSON editor');\n });\n\n it('switches selected tab on keyboard interactions', () => {\n renderTabs();\n const vizTab = screen.getByRole('tab', { name: 'Settings' });\n userEvent.tab();\n userEvent.keyboard('{arrowright}{space}');\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(vizTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('settings configuration');\n });\n\n it('renders custom tabs between visual tabs and json editor', () => {\n renderCustomTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(5);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('Table column');\n expect(tabs[3]).toHaveTextContent('Table options');\n expect(tabs[4]).toHaveTextContent('JSON');\n });\n\n it('shows the correct content when selecting a custom tab', () => {\n renderCustomTabs();\n\n const tableColTab = screen.getByRole('tab', { name: 'Table columns' });\n userEvent.click(tableColTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(tableColTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('custom table column');\n });\n\n it('only renders common tabs that are specified', () => {\n render(\n <OptionsEditorTabs\n tabs={{\n settings: {\n content: <div>settings are alone</div>,\n },\n json: {\n content: <div>JSON is at the end</div>,\n },\n other: [\n {\n id: 'custom',\n label: 'Another tab',\n content: <div>another tab content</div>,\n },\n ],\n }}\n />\n );\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Settings');\n expect(tabs[1]).toHaveTextContent('Another tab');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n});\n"],"names":["screen","render","getAllByRole","userEvent","OptionsEditorTabs","describe","renderTabs","otherTabs","tabs","query","content","div","settings","json","other","renderCustomTabs","id","label","it","tabList","getByRole","expect","toHaveLength","toHaveTextContent","activeTab","selected","activeTabPanel","jsonTab","name","click","toBe","vizTab","tab","keyboard","tableColTab"],"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,EAAEC,MAAM,EAAEC,YAAY,QAAQ,wBAAwB,CAAC;AACtE,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,iBAAiB,QAAgC,qBAAqB,CAAC;AAEhFC,QAAQ,CAAC,mBAAmB,EAAE,IAAM;IAClC,MAAMC,UAAU,GAAG,CAACC,SAAmD,GAAK;QAC1EN,MAAM,eACJ,KAACG,iBAAiB;YAChBI,IAAI,EAAE;gBACJC,KAAK,EAAE;oBACLC,OAAO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DF,MAAM,CAACb,IAAI,CAAC,CAAC,CAAC,CAAC,CAACe,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.test.tsx"],"sourcesContent":["// Copyright 2023 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 { screen, render, getAllByRole } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\n\nimport { OptionsEditorTabs, OptionsEditorTabsProps } from './OptionsEditorTabs';\n\ndescribe('OptionsEditorTabs', () => {\n const mockTabs: OptionsEditorTabsProps['tabs'] = [\n {\n label: 'Query',\n content: <div>Edit query configuration</div>,\n },\n {\n label: 'Settings',\n content: <div>Edit settings configuration</div>,\n },\n {\n label: 'JSON',\n content: <div>JSON editor</div>,\n },\n ];\n const renderTabs = (otherTabs?: OptionsEditorTabsProps['tabs']) => {\n const tabs = otherTabs ?? mockTabs;\n render(<OptionsEditorTabs tabs={tabs} />);\n };\n\n it('renders all specified tabs in a tab list', () => {\n renderTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n\n it('defaults to selecting the first tab', () => {\n renderTabs();\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toHaveTextContent('Query');\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('query configuration');\n });\n\n it('switches selected tab on click', () => {\n renderTabs();\n const jsonTab = screen.getByRole('tab', { name: 'JSON' });\n userEvent.click(jsonTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(jsonTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('JSON editor');\n });\n\n it('switches selected tab on keyboard interactions', () => {\n renderTabs();\n const vizTab = screen.getByRole('tab', { name: 'Settings' });\n userEvent.tab();\n userEvent.keyboard('{arrowright}{space}');\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(vizTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('settings configuration');\n });\n\n it('renders tabs in correct order', () => {\n renderTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n});\n"],"names":["screen","render","getAllByRole","userEvent","OptionsEditorTabs","describe","mockTabs","label","content","div","renderTabs","otherTabs","tabs","it","tabList","getByRole","expect","toHaveLength","toHaveTextContent","activeTab","selected","activeTabPanel","jsonTab","name","click","toBe","vizTab","tab","keyboard"],"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,EAAEC,MAAM,EAAEC,YAAY,QAAQ,wBAAwB,CAAC;AACtE,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,iBAAiB,QAAgC,qBAAqB,CAAC;AAEhFC,QAAQ,CAAC,mBAAmB,EAAE,IAAM;I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SAAS,CAAC,CAACM,IAAI,CAACC,MAAM,CAAC,CAAC;QAE/B,MAAML,cAAc,GAAGrB,MAAM,CAACe,SAAS,CAAC,UAAU,CAAC,AAAC;QACpDC,MAAM,CAACK,cAAc,CAAC,CAACH,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEHL,EAAE,CAAC,+BAA+B,EAAE,IAAM;QACxCH,UAAU,EAAE,CAAC;QAEb,MAAMI,OAAO,GAAGd,MAAM,CAACe,SAAS,CAAC,SAAS,CAAC,AAAC;QAC5C,MAAMH,IAAI,GAAGV,YAAY,CAACY,OAAO,EAAE,KAAK,CAAC,AAAC;QAC1CE,MAAM,CAACJ,IAAI,CAAC,CAACK,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7BD,MAAM,CAACJ,IAAI,CAAC,CAAC,CAAC,CAAC,CAACM,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC3CF,MAAM,CAACJ,IAAI,CAAC,CAAC,CAAC,CAAC,CAACM,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC9CF,MAAM,CAACJ,IAAI,CAAC,CAAC,CAAC,CAAC,CAACM,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/OptionsEditorTabs/TabPanel.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 { Box } from '@mui/material';\n\ninterface TabPanelProps {\n children: React.ReactNode;\n index: number;\n value: number;\n}\n\nexport function TabPanel(props: TabPanelProps) {\n const { children, value, index, ...other } = props;\n\n const isActive = value === index;\n\n return (\n <div\n role=\"tabpanel\"\n hidden={!isActive}\n id={`options-editor-tabpanel-${index}`}\n aria-labelledby={`options-editor-tab-${index}`}\n {...other}\n >\n {isActive && <Box mt={2}>{children}</Box>}\n </div>\n );\n}\n"],"names":["Box","TabPanel","props","children","value","index","other","isActive","div","role","hidden","id","aria-labelledby","mt"],"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,GAAG,QAAQ,eAAe,CAAC;AAQpC,OAAO,SAASC,QAAQ,CAACC,KAAoB,EAAE;IAC7C,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGC,KAAK,EAAE,GAAGJ,KAAK,AAAC;IAEnD,MAAMK,QAAQ,GAAGH,KAAK,KAAKC,KAAK,AAAC;IAEjC,qBACE,KAACG,KAAG;QACFC,IAAI,EAAC,UAAU;QACfC,MAAM,EAAE,CAACH,QAAQ;QACjBI,EAAE,EAAE,CAAC,wBAAwB,EAAEN,KAAK,CAAC,CAAC;QACtCO,iBAAe,EAAE,CAAC,mBAAmB,EAAEP,KAAK,CAAC,CAAC;QAC7C,GAAGC,KAAK;kBAERC,QAAQ,kBAAI,KAACP,GAAG;YAACa,EAAE,EAAE,CAAC;sBAAGV,QAAQ;UAAO;MACrC,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/TabPanel.tsx"],"sourcesContent":["// Copyright 2023 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 { Box } from '@mui/material';\n\ninterface TabPanelProps {\n children: React.ReactNode;\n index: number;\n value: number;\n}\n\nexport function TabPanel(props: TabPanelProps) {\n const { children, value, index, ...other } = props;\n\n const isActive = value === index;\n\n return (\n <div\n role=\"tabpanel\"\n hidden={!isActive}\n id={`options-editor-tabpanel-${index}`}\n aria-labelledby={`options-editor-tab-${index}`}\n {...other}\n >\n {isActive && <Box mt={2}>{children}</Box>}\n </div>\n );\n}\n"],"names":["Box","TabPanel","props","children","value","index","other","isActive","div","role","hidden","id","aria-labelledby","mt"],"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,GAAG,QAAQ,eAAe,CAAC;AAQpC,OAAO,SAASC,QAAQ,CAACC,KAAoB,EAAE;IAC7C,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGC,KAAK,EAAE,GAAGJ,KAAK,AAAC;IAEnD,MAAMK,QAAQ,GAAGH,KAAK,KAAKC,KAAK,AAAC;IAEjC,qBACE,KAACG,KAAG;QACFC,IAAI,EAAC,UAAU;QACfC,MAAM,EAAE,CAACH,QAAQ;QACjBI,EAAE,EAAE,CAAC,wBAAwB,EAAEN,KAAK,CAAC,CAAC;QACtCO,iBAAe,EAAE,CAAC,mBAAmB,EAAEP,KAAK,CAAC,CAAC;QAC7C,GAAGC,KAAK;kBAERC,QAAQ,kBAAI,KAACP,GAAG;YAACa,EAAE,EAAE,CAAC;sBAAGV,QAAQ;UAAO;MACrC,CACN;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/OptionsEditorTabs/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 './OptionsEditorTabs';\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,qBAAqB,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/index.ts"],"sourcesContent":["// Copyright 2023 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 './OptionsEditorTabs';\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,qBAAqB,CAAC"}