@perses-dev/components 0.50.0-rc.1 → 0.50.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.
@@ -57,7 +57,14 @@ type ZREventProperties = {
57
57
  zrEventControl?: 'no_globalout' | 'only_globalout';
58
58
  zrByTouch?: boolean;
59
59
  };
60
- export type ZRRawMouseEvent = MouseEvent & ZREventProperties;
60
+ export type ZRRawMouseEvent = (MouseEvent | PointerEvent) & ZREventProperties;
61
+ type ZRBrowser = {
62
+ ie: RegExpMatchArray | null;
63
+ edge: RegExpMatchArray | null;
64
+ };
65
+ export declare const browser: ZRBrowser;
66
+ export declare const pointerEventsSupported: boolean | "" | RegExpMatchArray | null | undefined;
67
+ export declare const trackingEventName: string;
61
68
  export declare const useMousePosition: () => CursorData['coords'];
62
69
  export type TooltipConfig = {
63
70
  wrapLabels: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-model.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/tooltip-model.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,wBAAwB,QAA0B,CAAC;AAChE,eAAO,MAAM,+BAA+B,OAAO,CAAC;AACpD,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAC5E,eAAO,MAAM,6BAA6B,iDAAiD,CAAC;AAE5F,eAAO,MAAM,yBAAyB,YAAY,CAAC;AAEnD,eAAO,MAAM,mBAAmB,qBAQ9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAa7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAA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M,EAAE,UAAU,CAAC;CACpB;AAED,KAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,UAAU,GAAG,YAAY,CAAC,GAAG,iBAAiB,CAAC;AAE9E,KAAK,SAAS,GAAG;IACf,EAAE,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,SAKrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,oDACmE,CAAC;AAEvG,eAAO,MAAM,iBAAiB,QAAuD,CAAC;AAEtF,eAAO,MAAM,gBAAgB,QAAO,UAAU,CAAC,QAAQ,CAqCtD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,aAGpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D,eAAO,MAAM,uBAAuB,yBAAyB,CAAC"}
@@ -45,6 +45,14 @@ export const defaultCursorData = {
45
45
  chartWidth: 0
46
46
  };
47
47
  export const EMPTY_TOOLTIP_DATA = [];
48
+ export const browser = {
49
+ // IE 11 Trident/7.0; rv:11.0
50
+ ie: navigator.userAgent.match(/MSIE\s([\d.]+)/) || navigator.userAgent.match(/Trident\/.+?rv:(([\d.]+))/),
51
+ // IE 12 and 12+
52
+ edge: navigator.userAgent.match(/Edge?\/([\d.]+)/)
53
+ };
54
+ export const pointerEventsSupported = 'onpointerdown' in window && (browser.edge || browser.ie && browser.ie[1] && +browser.ie[1] >= 11);
55
+ export const trackingEventName = pointerEventsSupported ? 'pointermove' : 'mousemove';
48
56
  export const useMousePosition = ()=>{
49
57
  const [coords, setCoords] = useState(null);
50
58
  useEffect(()=>{
@@ -69,9 +77,12 @@ export const useMousePosition = ()=>{
69
77
  target: e.target
70
78
  });
71
79
  };
72
- window.addEventListener('mousemove', setFromEvent);
80
+ // Devices that both enabled touch and mouse don't trigger touch events correctly
81
+ // which leads to missing zrender mousemove coordinates
82
+ // {@link https://github.com/ecomfe/zrender/blob/ae8cfaae186e6c1bf66b5dc431b2cdda5e67dacf/src/dom/HandlerProxy.ts#L423-L428 }
83
+ window.addEventListener(trackingEventName, setFromEvent);
73
84
  return ()=>{
74
- window.removeEventListener('mousemove', setFromEvent);
85
+ window.removeEventListener(trackingEventName, setFromEvent);
75
86
  };
76
87
  }, []);
77
88
  return coords;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-model.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 { useEffect, useState } from 'react';\nimport { NearbySeriesArray } from './nearby-series';\n\nexport const TOOLTIP_MIN_WIDTH = 375;\nexport const TOOLTIP_MAX_WIDTH = 650;\nexport const TOOLTIP_MAX_HEIGHT = 650;\nexport const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;\nexport const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;\nexport const TOOLTIP_PADDING = 8;\n\nexport const FALLBACK_CHART_WIDTH = 750;\n\nexport const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';\nexport const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';\n\nexport const TOOLTIP_BG_COLOR_FALLBACK = '#2E313E';\n\nexport const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n hour12: true,\n});\n\nexport const defaultCursorData = {\n coords: {\n plotCanvas: {\n x: 0,\n y: 0,\n },\n zrender: {\n x: 0,\n y: 0,\n },\n target: null,\n },\n chartWidth: 0,\n};\n\nexport const EMPTY_TOOLTIP_DATA: NearbySeriesArray = [];\n\n/**\n * ECharts is built with zrender, zrX and zrY are undefined when not hovering over a chart canvas\n */\nexport interface ZRCoordinate {\n x?: number;\n y?: number;\n}\n\nexport interface Coordinate {\n x: number;\n y: number;\n}\n\nexport interface CursorCoordinates {\n page: Coordinate;\n client: Coordinate;\n plotCanvas: ZRCoordinate;\n target: EventTarget | null;\n}\n\nexport interface CursorData {\n coords: CursorCoordinates | null;\n chartWidth?: number;\n}\n\nexport interface TooltipData {\n focusedSeries: NearbySeriesArray | null;\n cursor: CursorData;\n}\n\ntype ZREventProperties = {\n zrX?: number;\n zrY?: number;\n zrDelta?: number;\n zrEventControl?: 'no_globalout' | 'only_globalout';\n zrByTouch?: boolean;\n};\n\nexport type ZRRawMouseEvent = MouseEvent & ZREventProperties;\n\nexport const useMousePosition = (): CursorData['coords'] => {\n const [coords, setCoords] = useState<CursorData['coords']>(null);\n\n useEffect(() => {\n const setFromEvent = (e: ZRRawMouseEvent): void => {\n return setCoords({\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n // Always use zrender mousemove coords since they handle browser inconsistencies for us\n // ex: Firefox and Chrome have slightly different implementations of offsetX and offsetY\n // more info: https://github.com/ecomfe/zrender/blob/5.5.0/src/core/event.ts#L46-L120\n x: e.zrX,\n y: e.zrY,\n },\n // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)\n target: e.target,\n });\n };\n window.addEventListener('mousemove', setFromEvent);\n\n return (): void => {\n window.removeEventListener('mousemove', setFromEvent);\n };\n }, []);\n\n return coords;\n};\n\nexport type TooltipConfig = {\n wrapLabels: boolean;\n hidden?: boolean;\n enablePinning?: boolean;\n};\n\nexport const DEFAULT_TOOLTIP_CONFIG: TooltipConfig = {\n wrapLabels: true,\n enablePinning: true,\n};\n\nexport const PIN_TOOLTIP_HELP_TEXT = 'Click chart to pin';\n\nexport const UNPIN_TOOLTIP_HELP_TEXT = 'Click chart to unpin';\n"],"names":["useEffect","useState","TOOLTIP_MIN_WIDTH","TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_LABELS_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_PADDING","FALLBACK_CHART_WIDTH","NEARBY_SERIES_DESCRIPTION","EMPHASIZED_SERIES_DESCRIPTION","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_DATE_FORMAT","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","defaultCursorData","coords","plotCanvas","x","y","zrender","target","chartWidth","EMPTY_TOOLTIP_DATA","useMousePosition","setCoords","setFromEvent","e","page","pageX","pageY","client","clientX","clientY","zrX","zrY","window","addEventListener","removeEventListener","DEFAULT_TOOLTIP_CONFIG","wrapLabels","enablePinning","PIN_TOOLTIP_HELP_TEXT","UNPIN_TOOLTIP_HELP_TEXT"],"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,SAAS,EAAEC,QAAQ,QAAQ,QAAQ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QAErC,OAAO;YACLU,OAAOE,mBAAmB,CAAC,aAAaZ;QAC1C;IACF,GAAG,EAAE;IAEL,OAAOV;AACT,EAAE;AAQF,OAAO,MAAMuB,yBAAwC;IACnDC,YAAY;IACZC,eAAe;AACjB,EAAE;AAEF,OAAO,MAAMC,wBAAwB,qBAAqB;AAE1D,OAAO,MAAMC,0BAA0B,uBAAuB"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-model.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 { useEffect, useState } from 'react';\nimport { NearbySeriesArray } from './nearby-series';\n\nexport const TOOLTIP_MIN_WIDTH = 375;\nexport const TOOLTIP_MAX_WIDTH = 650;\nexport const TOOLTIP_MAX_HEIGHT = 650;\nexport const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;\nexport const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;\nexport const TOOLTIP_PADDING = 8;\n\nexport const FALLBACK_CHART_WIDTH = 750;\n\nexport const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';\nexport const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';\n\nexport const TOOLTIP_BG_COLOR_FALLBACK = '#2E313E';\n\nexport const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n hour12: true,\n});\n\nexport const defaultCursorData = {\n coords: {\n plotCanvas: {\n x: 0,\n y: 0,\n },\n zrender: {\n x: 0,\n y: 0,\n },\n target: null,\n },\n chartWidth: 0,\n};\n\nexport const EMPTY_TOOLTIP_DATA: NearbySeriesArray = [];\n\n/**\n * ECharts is built with zrender, zrX and zrY are undefined when not hovering over a chart canvas\n */\nexport interface ZRCoordinate {\n x?: number;\n y?: number;\n}\n\nexport interface Coordinate {\n x: number;\n y: number;\n}\n\nexport interface CursorCoordinates {\n page: Coordinate;\n client: Coordinate;\n plotCanvas: ZRCoordinate;\n target: EventTarget | null;\n}\n\nexport interface CursorData {\n coords: CursorCoordinates | null;\n chartWidth?: number;\n}\n\nexport interface TooltipData {\n focusedSeries: NearbySeriesArray | null;\n cursor: CursorData;\n}\n\ntype ZREventProperties = {\n zrX?: number;\n zrY?: number;\n zrDelta?: number;\n zrEventControl?: 'no_globalout' | 'only_globalout';\n zrByTouch?: boolean;\n};\n\nexport type ZRRawMouseEvent = (MouseEvent | PointerEvent) & ZREventProperties;\n\ntype ZRBrowser = {\n ie: RegExpMatchArray | null;\n edge: RegExpMatchArray | null;\n};\n\nexport const browser: ZRBrowser = {\n // IE 11 Trident/7.0; rv:11.0\n ie: navigator.userAgent.match(/MSIE\\s([\\d.]+)/) || navigator.userAgent.match(/Trident\\/.+?rv:(([\\d.]+))/),\n // IE 12 and 12+\n edge: navigator.userAgent.match(/Edge?\\/([\\d.]+)/),\n};\n\nexport const pointerEventsSupported =\n 'onpointerdown' in window && (browser.edge || (browser.ie && browser.ie[1] && +browser.ie[1] >= 11));\n\nexport const trackingEventName = pointerEventsSupported ? 'pointermove' : 'mousemove';\n\nexport const useMousePosition = (): CursorData['coords'] => {\n const [coords, setCoords] = useState<CursorData['coords']>(null);\n\n useEffect(() => {\n const setFromEvent = (e: ZRRawMouseEvent): void => {\n return setCoords({\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n // Always use zrender mousemove coords since they handle browser inconsistencies for us\n // ex: Firefox and Chrome have slightly different implementations of offsetX and offsetY\n // more info: https://github.com/ecomfe/zrender/blob/5.5.0/src/core/event.ts#L46-L120\n x: e.zrX,\n y: e.zrY,\n },\n // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)\n target: e.target,\n });\n };\n\n // Devices that both enabled touch and mouse don't trigger touch events correctly\n // which leads to missing zrender mousemove coordinates\n // {@link https://github.com/ecomfe/zrender/blob/ae8cfaae186e6c1bf66b5dc431b2cdda5e67dacf/src/dom/HandlerProxy.ts#L423-L428 }\n window.addEventListener(trackingEventName, setFromEvent);\n\n return (): void => {\n window.removeEventListener(trackingEventName, setFromEvent);\n };\n }, []);\n\n return coords;\n};\n\nexport type TooltipConfig = {\n wrapLabels: boolean;\n hidden?: boolean;\n enablePinning?: boolean;\n};\n\nexport const DEFAULT_TOOLTIP_CONFIG: TooltipConfig = {\n wrapLabels: true,\n enablePinning: true,\n};\n\nexport const PIN_TOOLTIP_HELP_TEXT = 'Click chart to pin';\n\nexport const UNPIN_TOOLTIP_HELP_TEXT = 'Click chart to unpin';\n"],"names":["useEffect","useState","TOOLTIP_MIN_WIDTH","TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_LABELS_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_PADDING","FALLBACK_CHART_WIDTH","NEARBY_SERIES_DESCRIPTION","EMPHASIZED_SERIES_DESCRIPTION","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_DATE_FORMAT","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","defaultCursorData","coords","plotCanvas","x","y","zrender","target","chartWidth","EMPTY_TOOLTIP_DATA","browser","ie","navigator","userAgent","match","edge","pointerEventsSupported","window","trackingEventName","useMousePosition","setCoords","setFromEvent","e","page","pageX","pageY","client","clientX","clientY","zrX","zrY","addEventListener","removeEventListener","DEFAULT_TOOLTIP_CONFIG","wrapLabels","enablePinning","PIN_TOOLTIP_HELP_TEXT","UNPIN_TOOL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AAKL,QAAQC,EAAE,IAAID,QAAQC,EAAE,CAAC,EAAE,IAAI,CAACD,QAAQC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAG;AAEvG,OAAO,MAAMO,oBAAoBF,yBAAyB,gBAAgB,YAAY;AAEtF,OAAO,MAAMG,mBAAmB;IAC9B,MAAM,CAACjB,QAAQkB,UAAU,GAAGzC,SAA+B;IAE3DD,UAAU;QACR,MAAM2C,eAAe,CAACC;YACpB,OAAOF,UAAU;gBACfG,MAAM;oBACJnB,GAAGkB,EAAEE,KAAK;oBACVnB,GAAGiB,EAAEG,KAAK;gBACZ;gBACAC,QAAQ;oBACNtB,GAAGkB,EAAEK,OAAO;oBACZtB,GAAGiB,EAAEM,OAAO;gBACd;gBACAzB,YAAY;oBACV,uFAAuF;oBACvF,wFAAwF;oBACxF,qFAAqF;oBACrFC,GAAGkB,EAAEO,GAAG;oBACRxB,GAAGiB,EAAEQ,GAAG;gBACV;gBACA,0HAA0H;gBAC1HvB,QAAQe,EAAEf,MAAM;YAClB;QACF;QAEA,iFAAiF;QACjF,uDAAuD;QACvD,6HAA6H;QAC7HU,OAAOc,gBAAgB,CAACb,mBAAmBG;QAE3C,OAAO;YACLJ,OAAOe,mBAAmB,CAACd,mBAAmBG;QAChD;IACF,GAAG,EAAE;IAEL,OAAOnB;AACT,EAAE;AAQF,OAAO,MAAM+B,yBAAwC;IACnDC,YAAY;IACZC,eAAe;AACjB,EAAE;AAEF,OAAO,MAAMC,wBAAwB,qBAAqB;AAE1D,OAAO,MAAMC,0BAA0B,uBAAuB"}
@@ -66,9 +66,18 @@ _export(exports, {
66
66
  UNPIN_TOOLTIP_HELP_TEXT: function() {
67
67
  return UNPIN_TOOLTIP_HELP_TEXT;
68
68
  },
69
+ browser: function() {
70
+ return browser;
71
+ },
69
72
  defaultCursorData: function() {
70
73
  return defaultCursorData;
71
74
  },
75
+ pointerEventsSupported: function() {
76
+ return pointerEventsSupported;
77
+ },
78
+ trackingEventName: function() {
79
+ return trackingEventName;
80
+ },
72
81
  useMousePosition: function() {
73
82
  return useMousePosition;
74
83
  }
@@ -108,6 +117,14 @@ const defaultCursorData = {
108
117
  chartWidth: 0
109
118
  };
110
119
  const EMPTY_TOOLTIP_DATA = [];
120
+ const browser = {
121
+ // IE 11 Trident/7.0; rv:11.0
122
+ ie: navigator.userAgent.match(/MSIE\s([\d.]+)/) || navigator.userAgent.match(/Trident\/.+?rv:(([\d.]+))/),
123
+ // IE 12 and 12+
124
+ edge: navigator.userAgent.match(/Edge?\/([\d.]+)/)
125
+ };
126
+ const pointerEventsSupported = 'onpointerdown' in window && (browser.edge || browser.ie && browser.ie[1] && +browser.ie[1] >= 11);
127
+ const trackingEventName = pointerEventsSupported ? 'pointermove' : 'mousemove';
111
128
  const useMousePosition = ()=>{
112
129
  const [coords, setCoords] = (0, _react.useState)(null);
113
130
  (0, _react.useEffect)(()=>{
@@ -132,9 +149,12 @@ const useMousePosition = ()=>{
132
149
  target: e.target
133
150
  });
134
151
  };
135
- window.addEventListener('mousemove', setFromEvent);
152
+ // Devices that both enabled touch and mouse don't trigger touch events correctly
153
+ // which leads to missing zrender mousemove coordinates
154
+ // {@link https://github.com/ecomfe/zrender/blob/ae8cfaae186e6c1bf66b5dc431b2cdda5e67dacf/src/dom/HandlerProxy.ts#L423-L428 }
155
+ window.addEventListener(trackingEventName, setFromEvent);
136
156
  return ()=>{
137
- window.removeEventListener('mousemove', setFromEvent);
157
+ window.removeEventListener(trackingEventName, setFromEvent);
138
158
  };
139
159
  }, []);
140
160
  return coords;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.50.0-rc.1",
3
+ "version": "0.50.0",
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",
@@ -38,7 +38,7 @@
38
38
  "@codemirror/lang-json": "^6.0.1",
39
39
  "@fontsource/lato": "^4.5.10",
40
40
  "@mui/x-date-pickers": "^7.23.1",
41
- "@perses-dev/core": "0.50.0-rc.1",
41
+ "@perses-dev/core": "0.50.0",
42
42
  "@tanstack/react-table": "^8.20.5",
43
43
  "@uiw/react-codemirror": "^4.19.1",
44
44
  "date-fns": "^2.28.0",
@@ -55,7 +55,7 @@
55
55
  "zod": "^3.21.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@perses-dev/storybook": "0.50.0-rc.1"
58
+ "@perses-dev/storybook": "0.50.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@mui/material": "^6.1.10",