@perses-dev/components 0.53.0-beta.0 → 0.53.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,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,GAAG,YAAY,CAsCrF"}
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,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,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,GAAG,YAAY,CAqCrF"}
@@ -15,7 +15,6 @@ import { Box, FormControl, MenuItem, Select } from '@mui/material';
15
15
  import { useMemo } from 'react';
16
16
  export function RefreshIntervalPicker(props) {
17
17
  const { value, onChange, timeOptions, height } = props;
18
- const formattedValue = value;
19
18
  // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select
20
19
  const customInterval = useMemo(()=>{
21
20
  if (value && !timeOptions.some((option)=>option.value.pastDuration === value)) {
@@ -32,13 +31,13 @@ export function RefreshIntervalPicker(props) {
32
31
  children: /*#__PURE__*/ _jsx(Box, {
33
32
  children: /*#__PURE__*/ _jsxs(Select, {
34
33
  id: "refreshInterval",
35
- value: formattedValue,
34
+ value: value,
36
35
  onChange: (event)=>{
37
36
  const duration = event.target.value;
38
37
  onChange(duration);
39
38
  },
40
39
  inputProps: {
41
- 'aria-label': `Select refresh interval. Currently set to ${formattedValue}`
40
+ 'aria-label': `Select refresh interval. Currently set to ${value}`
42
41
  },
43
42
  sx: {
44
43
  '.MuiSelect-select': height ? {
@@ -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 { ReactElement, 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): ReactElement {\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,SAAuBC,OAAO,QAAQ,QAAQ;AAU9C,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;IACjD,MAAMK,iBAAiBJ;IAEvB,oHAAoH;IACpH,MAAMK,iBAAiBR,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYI,IAAI,CAAC,CAACC,SAAWA,OAAOP,KAAK,CAACQ,YAAY,KAAKR,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,MAAM,CAACZ,KAAK;oBACnCC,SAASU;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAET,gBAAgB;gBAC7E;gBACAU,IAAI;oBACF,qBAAqBX,SAAS;wBAAEY,YAAYZ;wBAAQa,UAAU;oBAAE,IAAI,CAAC;gBACvE;;oBAECd,YAAYe,GAAG,CAAC,CAACC,MAAMC,oBACtB,KAACxB;4BAAmBK,OAAOkB,KAAKlB,KAAK,CAACQ,YAAY;sCAC/CU,KAAKE,OAAO;2BADAD;oBAIhBd;;;;;AAKX"}
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 { ReactElement, 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): ReactElement {\n const { value, onChange, timeOptions, height } = props;\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={value}\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 ${value}`,\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","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,SAAuBC,OAAO,QAAQ,QAAQ;AAU9C,OAAO,SAASC,sBAAsBC,KAAiC;IACrE,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;IAEjD,oHAAoH;IACpH,MAAMK,iBAAiBP,QAAQ;QAC7B,IAAIG,SAAS,CAACE,YAAYG,IAAI,CAAC,CAACC,SAAWA,OAAON,KAAK,CAACO,YAAY,KAAKP,QAAQ;YAC/E,qBAAO,KAACL;gBAASK,OAAOA;0BAAQA;;QAClC;IACF,GAAG;QAACE;QAAaF;KAAM;IAEvB,qBACE,KAACN;kBACC,cAAA,KAACD;sBACC,cAAA,MAACG;gBACCY,IAAG;gBACHR,OAAOA;gBACPC,UAAU,CAACQ;oBACT,MAAMC,WAAWD,MAAME,MAAM,CAACX,KAAK;oBACnCC,SAASS;gBACX;gBACAE,YAAY;oBACV,cAAc,CAAC,0CAA0C,EAAEZ,OAAO;gBACpE;gBACAa,IAAI;oBACF,qBAAqBV,SAAS;wBAAEW,YAAYX;wBAAQY,UAAU;oBAAE,IAAI,CAAC;gBACvE;;oBAECb,YAAYc,GAAG,CAAC,CAACC,MAAMC,oBACtB,KAACvB;4BAAmBK,OAAOiB,KAAKjB,KAAK,CAACO,YAAY;sCAC/CU,KAAKE,OAAO;2BADAD;oBAIhBd;;;;;AAKX"}
@@ -25,7 +25,6 @@ const _material = require("@mui/material");
25
25
  const _react = require("react");
26
26
  function RefreshIntervalPicker(props) {
27
27
  const { value, onChange, timeOptions, height } = props;
28
- const formattedValue = value;
29
28
  // If the dashboard refresh interval is not provided in timeOptions, it will create a specific option for the select
30
29
  const customInterval = (0, _react.useMemo)(()=>{
31
30
  if (value && !timeOptions.some((option)=>option.value.pastDuration === value)) {
@@ -42,13 +41,13 @@ function RefreshIntervalPicker(props) {
42
41
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
43
42
  children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Select, {
44
43
  id: "refreshInterval",
45
- value: formattedValue,
44
+ value: value,
46
45
  onChange: (event)=>{
47
46
  const duration = event.target.value;
48
47
  onChange(duration);
49
48
  },
50
49
  inputProps: {
51
- 'aria-label': `Select refresh interval. Currently set to ${formattedValue}`
50
+ 'aria-label': `Select refresh interval. Currently set to ${value}`
52
51
  },
53
52
  sx: {
54
53
  '.MuiSelect-select': height ? {
@@ -21,6 +21,7 @@ _export_star(require("./combine-sx"), exports);
21
21
  _export_star(require("./component-ids"), exports);
22
22
  _export_star(require("./format"), exports);
23
23
  _export_star(require("./theme-gen"), exports);
24
+ _export_star(require("./memo"), exports);
24
25
  function _export_star(from, to) {
25
26
  Object.keys(from).forEach(function(k) {
26
27
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,64 @@
1
+ // Copyright 2023 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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ useDeepMemo: function() {
25
+ return useDeepMemo;
26
+ },
27
+ useMemoized: function() {
28
+ return useMemoized;
29
+ }
30
+ });
31
+ const _react = require("react");
32
+ const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
33
+ function _interop_require_default(obj) {
34
+ return obj && obj.__esModule ? obj : {
35
+ default: obj
36
+ };
37
+ }
38
+ function useMemoized(factory, deps) {
39
+ const ref = (0, _react.useRef)();
40
+ let areEqual = true;
41
+ for(let i = 0; i < deps.length; i++){
42
+ if (ref.current?.deps[i] !== deps[i]) {
43
+ areEqual = false;
44
+ break;
45
+ }
46
+ }
47
+ if (ref.current === undefined || areEqual === false) {
48
+ ref.current = {
49
+ value: factory(),
50
+ deps: deps
51
+ };
52
+ }
53
+ return ref.current.value;
54
+ }
55
+ function useDeepMemo(factory, deps) {
56
+ const ref = (0, _react.useRef)();
57
+ if (ref.current === undefined || (0, _isEqual.default)(deps, ref.current.deps) === false) {
58
+ ref.current = {
59
+ value: factory(),
60
+ deps
61
+ };
62
+ }
63
+ return ref.current.value;
64
+ }
@@ -1,4 +1,4 @@
1
- import { PaletteMode, ThemeOptions, Theme } from '@mui/material';
1
+ import { createTheme, PaletteMode, Theme } from '@mui/material';
2
2
  /**
3
3
  * Gets theme used by all components for the provided mode. For more details, see:
4
4
  * - Base colors, typography, sizing - go/chrono-ui-theme
@@ -9,5 +9,5 @@ import { PaletteMode, ThemeOptions, Theme } from '@mui/material';
9
9
  * Need to reinstantiate the theme everytime to support switching between light and dark themes
10
10
  * https://github.com/mui-org/material-ui/issues/18831
11
11
  */
12
- export declare function getTheme(mode: PaletteMode, options?: ThemeOptions): Theme;
12
+ export declare function getTheme(mode: PaletteMode, options?: Parameters<typeof createTheme>[0]): Theme;
13
13
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAuB9E;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAQ7E"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AAuB9E;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAM,GAAG,KAAK,CAQlG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/theme.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\nimport { createTheme, PaletteMode, ThemeOptions, Theme } from '@mui/material';\nimport { MuiAlert } from './component-overrides/alert';\nimport { MuiPaper } from './component-overrides/paper';\nimport { getPaletteOptions } from './palette';\nimport { typography } from './typography';\n\nconst getModalBackgroundStyle = ({\n theme,\n}: {\n theme: Omit<Theme, 'components'>;\n}): { backgroundImage?: string; backgroundColor?: string } => {\n const backgroundStyle =\n theme.palette.mode === 'light'\n ? {}\n : {\n backgroundImage: 'unset',\n backgroundColor: theme.palette.designSystem.grey[800],\n };\n return {\n ...backgroundStyle,\n };\n};\n\n/**\n * Gets theme used by all components for the provided mode. For more details, see:\n * - Base colors, typography, sizing - go/chrono-ui-theme\n * - Material UI defaults: https://material-ui.com/customization/default-theme/\n * - Material UI variables: https://material-ui.com/customization/theming/#theme-configuration-variables\n * - Material UI global overrides and default props: https://material-ui.com/customization/globals/#css\n *\n * Need to reinstantiate the theme everytime to support switching between light and dark themes\n * https://github.com/mui-org/material-ui/issues/18831\n */\nexport function getTheme(mode: PaletteMode, options: ThemeOptions = {}): Theme {\n return createTheme({\n palette: getPaletteOptions(mode),\n typography,\n mixins: {},\n components,\n ...options,\n });\n}\n\n// Overrides for component default prop values and styles go here\nconst components: ThemeOptions['components'] = {\n MuiAlert,\n MuiFormControl: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiPaper,\n MuiTextField: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiDrawer: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiDialog: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiPopover: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n};\n"],"names":["createTheme","MuiAlert","MuiPaper","getPaletteOptions","typography","getModalBackgroundStyle","theme","backgroundStyle","palette","mode","backgroundImage","backgroundColor","designSystem","grey","getTheme","options","mixins","components","MuiFormControl","defaultProps","size","MuiTextField","MuiDrawer","styleOverrides","paper","MuiDialog","MuiPopover"],"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,QAA0C,gBAAgB;AAC9E,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,0BAA0B,CAAC,EAC/BC,KAAK,EAGN;IACC,MAAMC,kBACJD,MAAME,OAAO,CAACC,IAAI,KAAK,UACnB,CAAC,IACD;QACEC,iBAAiB;QACjBC,iBAAiBL,MAAME,OAAO,CAACI,YAAY,CAACC,IAAI,CAAC,IAAI;IACvD;IACN,OAAO;QACL,GAAGN,eAAe;IACpB;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASO,SAASL,IAAiB,EAAEM,UAAwB,CAAC,CAAC;IACpE,OAAOf,YAAY;QACjBQ,SAASL,kBAAkBM;QAC3BL;QACAY,QAAQ,CAAC;QACTC;QACA,GAAGF,OAAO;IACZ;AACF;AAEA,iEAAiE;AACjE,MAAME,aAAyC;IAC7ChB;IACAiB,gBAAgB;QACdC,cAAc;YACZC,MAAM;QACR;IACF;IACAlB;IACAmB,cAAc;QACZF,cAAc;YACZC,MAAM;QACR;IACF;IACAE,WAAW;QACTC,gBAAgB;YACdC,OAAOnB;QACT;IACF;IACAoB,WAAW;QACTF,gBAAgB;YACdC,OAAOnB;QACT;IACF;IACAqB,YAAY;QACVH,gBAAgB;YACdC,OAAOnB;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/theme/theme.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\nimport { createTheme, PaletteMode, ThemeOptions, Theme } from '@mui/material';\nimport { MuiAlert } from './component-overrides/alert';\nimport { MuiPaper } from './component-overrides/paper';\nimport { getPaletteOptions } from './palette';\nimport { typography } from './typography';\n\nconst getModalBackgroundStyle = ({\n theme,\n}: {\n theme: Omit<Theme, 'components'>;\n}): { backgroundImage?: string; backgroundColor?: string } => {\n const backgroundStyle =\n theme.palette.mode === 'light'\n ? {}\n : {\n backgroundImage: 'unset',\n backgroundColor: theme.palette.designSystem.grey[800],\n };\n return {\n ...backgroundStyle,\n };\n};\n\n/**\n * Gets theme used by all components for the provided mode. For more details, see:\n * - Base colors, typography, sizing - go/chrono-ui-theme\n * - Material UI defaults: https://material-ui.com/customization/default-theme/\n * - Material UI variables: https://material-ui.com/customization/theming/#theme-configuration-variables\n * - Material UI global overrides and default props: https://material-ui.com/customization/globals/#css\n *\n * Need to reinstantiate the theme everytime to support switching between light and dark themes\n * https://github.com/mui-org/material-ui/issues/18831\n */\nexport function getTheme(mode: PaletteMode, options: Parameters<typeof createTheme>[0] = {}): Theme {\n return createTheme({\n palette: getPaletteOptions(mode),\n typography,\n mixins: {},\n components,\n ...options,\n });\n}\n\n// Overrides for component default prop values and styles go here\nconst components: ThemeOptions['components'] = {\n MuiAlert,\n MuiFormControl: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiPaper,\n MuiTextField: {\n defaultProps: {\n size: 'small',\n },\n },\n MuiDrawer: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiDialog: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n MuiPopover: {\n styleOverrides: {\n paper: getModalBackgroundStyle,\n },\n },\n};\n"],"names":["createTheme","MuiAlert","MuiPaper","getPaletteOptions","typography","getModalBackgroundStyle","theme","backgroundStyle","palette","mode","backgroundImage","backgroundColor","designSystem","grey","getTheme","options","mixins","components","MuiFormControl","defaultProps","size","MuiTextField","MuiDrawer","styleOverrides","paper","MuiDialog","MuiPopover"],"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,QAA0C,gBAAgB;AAC9E,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,0BAA0B,CAAC,EAC/BC,KAAK,EAGN;IACC,MAAMC,kBACJD,MAAME,OAAO,CAACC,IAAI,KAAK,UACnB,CAAC,IACD;QACEC,iBAAiB;QACjBC,iBAAiBL,MAAME,OAAO,CAACI,YAAY,CAACC,IAAI,CAAC,IAAI;IACvD;IACN,OAAO;QACL,GAAGN,eAAe;IACpB;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASO,SAASL,IAAiB,EAAEM,UAA6C,CAAC,CAAC;IACzF,OAAOf,YAAY;QACjBQ,SAASL,kBAAkBM;QAC3BL;QACAY,QAAQ,CAAC;QACTC;QACA,GAAGF,OAAO;IACZ;AACF;AAEA,iEAAiE;AACjE,MAAME,aAAyC;IAC7ChB;IACAiB,gBAAgB;QACdC,cAAc;YACZC,MAAM;QACR;IACF;IACAlB;IACAmB,cAAc;QACZF,cAAc;YACZC,MAAM;QACR;IACF;IACAE,WAAW;QACTC,gBAAgB;YACdC,OAAOnB;QACT;IACF;IACAoB,WAAW;QACTF,gBAAgB;YACdC,OAAOnB;QACT;IACF;IACAqB,YAAY;QACVH,gBAAgB;YACdC,OAAOnB;QACT;IACF;AACF"}
@@ -5,4 +5,5 @@ export * from './combine-sx';
5
5
  export * from './component-ids';
6
6
  export * from './format';
7
7
  export * from './theme-gen';
8
+ export * from './memo';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
@@ -17,5 +17,6 @@ export * from './combine-sx';
17
17
  export * from './component-ids';
18
18
  export * from './format';
19
19
  export * from './theme-gen';
20
+ export * from './memo';
20
21
 
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/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 './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './format';\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,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,cAAc"}
1
+ {"version":3,"sources":["../../src/utils/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 './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './format';\nexport * from './theme-gen';\nexport * from './memo';\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,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,SAAS"}
@@ -0,0 +1,13 @@
1
+ import { DependencyList } from 'react';
2
+ /**
3
+ * Like React's useMemo, but guarantees the value will only be recalulated if
4
+ * a dependency changes. Uses strict equality (===) for comparison. (React's
5
+ * useMemo does not offer this guarantee, it's only a performance optimization).
6
+ */
7
+ export declare function useMemoized<T>(factory: () => T, deps: DependencyList): T;
8
+ /**
9
+ * Like React's useMemo, except it does a deep equality comparison with lodash's
10
+ * isEqual on the dependency list.
11
+ */
12
+ export declare function useDeepMemo<T>(factory: () => T, deps: DependencyList): T;
13
+ //# sourceMappingURL=memo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../src/utils/memo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAgBxE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAMxE"}
@@ -0,0 +1,50 @@
1
+ // Copyright 2023 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 { useRef } from 'react';
14
+ import isEqual from 'lodash/isEqual';
15
+ /**
16
+ * Like React's useMemo, but guarantees the value will only be recalulated if
17
+ * a dependency changes. Uses strict equality (===) for comparison. (React's
18
+ * useMemo does not offer this guarantee, it's only a performance optimization).
19
+ */ export function useMemoized(factory, deps) {
20
+ const ref = useRef();
21
+ let areEqual = true;
22
+ for(let i = 0; i < deps.length; i++){
23
+ if (ref.current?.deps[i] !== deps[i]) {
24
+ areEqual = false;
25
+ break;
26
+ }
27
+ }
28
+ if (ref.current === undefined || areEqual === false) {
29
+ ref.current = {
30
+ value: factory(),
31
+ deps: deps
32
+ };
33
+ }
34
+ return ref.current.value;
35
+ }
36
+ /**
37
+ * Like React's useMemo, except it does a deep equality comparison with lodash's
38
+ * isEqual on the dependency list.
39
+ */ export function useDeepMemo(factory, deps) {
40
+ const ref = useRef();
41
+ if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {
42
+ ref.current = {
43
+ value: factory(),
44
+ deps
45
+ };
46
+ }
47
+ return ref.current.value;
48
+ }
49
+
50
+ //# sourceMappingURL=memo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/memo.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\nimport { useRef, DependencyList } from 'react';\nimport isEqual from 'lodash/isEqual';\n\ntype MemoRef<T> = {\n value: T;\n deps: DependencyList;\n};\n\n/**\n * Like React's useMemo, but guarantees the value will only be recalulated if\n * a dependency changes. Uses strict equality (===) for comparison. (React's\n * useMemo does not offer this guarantee, it's only a performance optimization).\n */\nexport function useMemoized<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n\n let areEqual = true;\n for (let i = 0; i < deps.length; i++) {\n if (ref.current?.deps[i] !== deps[i]) {\n areEqual = false;\n break;\n }\n }\n\n if (ref.current === undefined || areEqual === false) {\n ref.current = { value: factory(), deps: deps };\n }\n\n return ref.current.value;\n}\n\n/**\n * Like React's useMemo, except it does a deep equality comparison with lodash's\n * isEqual on the dependency list.\n */\nexport function useDeepMemo<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {\n ref.current = { value: factory(), deps };\n }\n return ref.current.value;\n}\n"],"names":["useRef","isEqual","useMemoized","factory","deps","ref","areEqual","i","length","current","undefined","value","useDeepMemo"],"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,MAAM,QAAwB,QAAQ;AAC/C,OAAOC,aAAa,iBAAiB;AAOrC;;;;CAIC,GACD,OAAO,SAASC,YAAeC,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IAEZ,IAAIM,WAAW;IACf,IAAK,IAAIC,IAAI,GAAGA,IAAIH,KAAKI,MAAM,EAAED,IAAK;QACpC,IAAIF,IAAII,OAAO,EAAEL,IAAI,CAACG,EAAE,KAAKH,IAAI,CAACG,EAAE,EAAE;YACpCD,WAAW;YACX;QACF;IACF;IAEA,IAAID,IAAII,OAAO,KAAKC,aAAaJ,aAAa,OAAO;QACnDD,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC,MAAMA;QAAK;IAC/C;IAEA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B;AAEA;;;CAGC,GACD,OAAO,SAASC,YAAeT,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IACZ,IAAIK,IAAII,OAAO,KAAKC,aAAaT,QAAQG,MAAMC,IAAII,OAAO,CAACL,IAAI,MAAM,OAAO;QAC1EC,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC;QAAK;IACzC;IACA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.53.0-beta.0",
3
+ "version": "0.53.0-beta.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",
@@ -33,7 +33,7 @@
33
33
  "@codemirror/lang-json": "^6.0.1",
34
34
  "@fontsource/lato": "^4.5.10",
35
35
  "@mui/x-date-pickers": "^7.23.1",
36
- "@perses-dev/core": "0.53.0-beta.0",
36
+ "@perses-dev/core": "0.53.0-beta.1",
37
37
  "@tanstack/react-table": "^8.20.5",
38
38
  "@uiw/react-codemirror": "^4.19.1",
39
39
  "date-fns": "^4.1.0",