@perses-dev/components 0.40.1 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshIntervalPicker.d.ts","sourceRoot":"","sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,UAAU,0BAA0B;IAClC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,eA6BtE"}
1
+ {"version":3,"file":"RefreshIntervalPicker.d.ts","sourceRoot":"","sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,UAAU,0BAA0B;IAClC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,eAsCtE"}
@@ -10,14 +10,27 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box, FormControl, MenuItem, Select } from '@mui/material';
15
+ import { useMemo } from 'react';
15
16
  export function RefreshIntervalPicker(props) {
16
17
  const { value , onChange , timeOptions , height } = props;
17
18
  const formattedValue = value;
19
+ // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select
20
+ const customInterval = useMemo(()=>{
21
+ if (value && !timeOptions.some((option)=>option.value.pastDuration === value)) {
22
+ return /*#__PURE__*/ _jsx(MenuItem, {
23
+ value: value,
24
+ children: value
25
+ });
26
+ }
27
+ }, [
28
+ timeOptions,
29
+ value
30
+ ]);
18
31
  return /*#__PURE__*/ _jsx(FormControl, {
19
32
  children: /*#__PURE__*/ _jsx(Box, {
20
- children: /*#__PURE__*/ _jsx(Select, {
33
+ children: /*#__PURE__*/ _jsxs(Select, {
21
34
  id: "refreshInterval",
22
35
  value: formattedValue,
23
36
  onChange: (event)=>{
@@ -33,10 +46,13 @@ export function RefreshIntervalPicker(props) {
33
46
  paddingY: 0
34
47
  } : {}
35
48
  },
36
- children: timeOptions.map((item, idx)=>/*#__PURE__*/ _jsx(MenuItem, {
37
- value: item.value.pastDuration,
38
- children: item.display
39
- }, idx))
49
+ children: [
50
+ timeOptions.map((item, idx)=>/*#__PURE__*/ _jsx(MenuItem, {
51
+ value: item.value.pastDuration,
52
+ children: item.display
53
+ }, idx)),
54
+ customInterval
55
+ ]
40
56
  })
41
57
  })
42
58
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.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, FormControl, MenuItem, Select } from '@mui/material';\nimport { DurationString } from '@perses-dev/core';\nimport { TimeOption } from '../model';\n\ninterface RefreshIntervalPickerProps {\n timeOptions: TimeOption[];\n value?: DurationString;\n onChange: (value: DurationString) => void;\n height?: string;\n}\n\nexport function RefreshIntervalPicker(props: RefreshIntervalPickerProps) {\n const { value, onChange, timeOptions, height } = props;\n const formattedValue = value;\n return (\n <FormControl>\n <Box>\n <Select\n id=\"refreshInterval\"\n value={formattedValue}\n onChange={(event) => {\n const duration = event.target.value as DurationString;\n onChange(duration);\n }}\n inputProps={{\n 'aria-label': `Select refresh interval. Currently set to ${formattedValue}`,\n }}\n sx={{\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n </Select>\n </Box>\n </FormControl>\n );\n}\n"],"names":["Box","FormControl","MenuItem","Select","RefreshIntervalPicker","props","value","onChange","timeOptions","height","formattedValue","id","event","duration","target","inputProps","sx","lineHeight","paddingY","map","item","idx","pastDuration","display"],"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,GAAG,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AAWnE,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,MAAK,EAAEC,SAAQ,EAAEC,YAAW,EAAEC,OAAM,EAAE,GAAGJ;IACjD,MAAMK,iBAAiBJ;IACvB,qBACE,KAACL;kBACC,cAAA,KAACD;sBACC,cAAA,KAACG;gBACCQ,IAAG;gBACHL,OAAOI;gBACPH,UAAU,CAACK;oBACT,MAAMC,WAAWD,MAAME,OAAOR;oBAC9BC,SAASM;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAEL,eAAe,CAAC;gBAC7E;gBACAM,IAAI;oBACF,qBAAqBP,SAAS;wBAAEQ,YAAYR;wBAAQS,UAAU;oBAAE,IAAI,CAAC;gBACvE;0BAECV,YAAYW,IAAI,CAACC,MAAMC,oBACtB,KAACnB;wBAAmBI,OAAOc,KAAKd,MAAMgB;kCACnCF,KAAKG;uBADOF;;;;AAQ3B"}
1
+ {"version":3,"sources":["../../src/RefreshIntervalPicker/RefreshIntervalPicker.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, FormControl, MenuItem, Select } from '@mui/material';\nimport { DurationString } from '@perses-dev/core';\nimport { useMemo } from 'react';\nimport { TimeOption } from '../model';\n\ninterface RefreshIntervalPickerProps {\n timeOptions: TimeOption[];\n value?: DurationString;\n onChange: (value: DurationString) => void;\n height?: string;\n}\n\nexport function RefreshIntervalPicker(props: RefreshIntervalPickerProps) {\n const { value, onChange, timeOptions, height } = props;\n const formattedValue = value;\n\n // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select\n const customInterval = useMemo(() => {\n if (value && !timeOptions.some((option) => option.value.pastDuration === value)) {\n return <MenuItem value={value}>{value}</MenuItem>;\n }\n }, [timeOptions, value]);\n\n return (\n <FormControl>\n <Box>\n <Select\n id=\"refreshInterval\"\n value={formattedValue}\n onChange={(event) => {\n const duration = event.target.value as DurationString;\n onChange(duration);\n }}\n inputProps={{\n 'aria-label': `Select refresh interval. Currently set to ${formattedValue}`,\n }}\n sx={{\n '.MuiSelect-select': height ? { lineHeight: height, paddingY: 0 } : {},\n }}\n >\n {timeOptions.map((item, idx) => (\n <MenuItem key={idx} value={item.value.pastDuration}>\n {item.display}\n </MenuItem>\n ))}\n {customInterval}\n </Select>\n </Box>\n </FormControl>\n );\n}\n"],"names":["Box","FormControl","MenuItem","Select","useMemo","RefreshIntervalPicker","props","value","onChange","timeOptions","height","formattedValue","customInterval","some","option","pastDuration","id","event","duration","target","inputProps","sx","lineHeight","paddingY","map","item","idx","display"],"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,GAAG,EAAEC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,gBAAgB;AAEnE,SAASC,OAAO,QAAQ,QAAQ;AAUhC,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,MAAK,EAAEC,SAAQ,EAAEC,YAAW,EAAEC,OAAM,EAAE,GAAGJ;IACjD,MAAMK,iBAAiBJ;IAEvB,oHAAoH;IACpH,MAAMK,iBAAiBR,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYI,KAAK,CAACC,SAAWA,OAAOP,MAAMQ,iBAAiBR,QAAQ;YAC/E,qBAAO,KAACL;gBAASK,OAAOA;0BAAQA;;QAClC;IACF,GAAG;QAACE;QAAaF;KAAM;IAEvB,qBACE,KAACN;kBACC,cAAA,KAACD;sBACC,cAAA,MAACG;gBACCa,IAAG;gBACHT,OAAOI;gBACPH,UAAU,CAACS;oBACT,MAAMC,WAAWD,MAAME,OAAOZ;oBAC9BC,SAASU;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAET,eAAe,CAAC;gBAC7E;gBACAU,IAAI;oBACF,qBAAqBX,SAAS;wBAAEY,YAAYZ;wBAAQa,UAAU;oBAAE,IAAI,CAAC;gBACvE;;oBAECd,YAAYe,IAAI,CAACC,MAAMC,oBACtB,KAACxB;4BAAmBK,OAAOkB,KAAKlB,MAAMQ;sCACnCU,KAAKE;2BADOD;oBAIhBd;;;;;AAKX"}
@@ -22,12 +22,25 @@ Object.defineProperty(exports, "RefreshIntervalPicker", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
+ const _react = require("react");
25
26
  function RefreshIntervalPicker(props) {
26
27
  const { value , onChange , timeOptions , height } = props;
27
28
  const formattedValue = value;
29
+ // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select
30
+ const customInterval = (0, _react.useMemo)(()=>{
31
+ if (value && !timeOptions.some((option)=>option.value.pastDuration === value)) {
32
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
33
+ value: value,
34
+ children: value
35
+ });
36
+ }
37
+ }, [
38
+ timeOptions,
39
+ value
40
+ ]);
28
41
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
29
42
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
30
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Select, {
43
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Select, {
31
44
  id: "refreshInterval",
32
45
  value: formattedValue,
33
46
  onChange: (event)=>{
@@ -43,10 +56,13 @@ function RefreshIntervalPicker(props) {
43
56
  paddingY: 0
44
57
  } : {}
45
58
  },
46
- children: timeOptions.map((item, idx)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
47
- value: item.value.pastDuration,
48
- children: item.display
49
- }, idx))
59
+ children: [
60
+ timeOptions.map((item, idx)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
61
+ value: item.value.pastDuration,
62
+ children: item.display
63
+ }, idx)),
64
+ customInterval
65
+ ]
50
66
  })
51
67
  })
52
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.40.1",
3
+ "version": "0.41.1",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -36,7 +36,7 @@
36
36
  "@codemirror/lang-json": "^6.0.1",
37
37
  "@fontsource/lato": "^4.5.10",
38
38
  "@mui/x-date-pickers": "^6.12.1",
39
- "@perses-dev/core": "0.40.1",
39
+ "@perses-dev/core": "0.41.1",
40
40
  "@tanstack/react-table": "^8.9.1",
41
41
  "@uiw/react-codemirror": "^4.19.1",
42
42
  "date-fns": "^2.28.0",
@@ -51,7 +51,7 @@
51
51
  "react-virtuoso": "^4.3.6"
52
52
  },
53
53
  "devDependencies": {
54
- "@perses-dev/storybook": "0.40.1"
54
+ "@perses-dev/storybook": "0.41.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@mui/material": "^5.10.0",