@perses-dev/components 0.0.0-snapshot-profile-89b306f → 0.0.0-snapshot-time-zone-selector-946f408
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.
- package/README.md +1 -5
- package/dist/EChart/EChart.d.ts.map +1 -1
- package/dist/EChart/EChart.js +9 -4
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +2 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +5 -6
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +5 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +14 -10
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +0 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +0 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeZoneSelector/TimeZoneSelector.d.ts +10 -0
- package/dist/TimeZoneSelector/TimeZoneSelector.d.ts.map +1 -0
- package/dist/TimeZoneSelector/TimeZoneSelector.js +143 -0
- package/dist/TimeZoneSelector/TimeZoneSelector.js.map +1 -0
- package/dist/TimeZoneSelector/index.d.ts +2 -0
- package/dist/TimeZoneSelector/index.d.ts.map +1 -0
- package/dist/{LineChart → TimeZoneSelector}/index.js +2 -2
- package/dist/TimeZoneSelector/index.js.map +1 -0
- package/dist/cjs/EChart/EChart.js +7 -2
- package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +5 -6
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +12 -8
- package/dist/cjs/TimeSeriesTooltip/index.js +0 -1
- package/dist/cjs/TimeZoneSelector/TimeZoneSelector.js +156 -0
- package/dist/cjs/{LineChart → TimeZoneSelector}/index.js +2 -2
- package/dist/cjs/context/index.js +0 -1
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/timeZoneOption.js +100 -0
- package/dist/cjs/utils/axis.js +3 -18
- package/dist/cjs/utils/format.js +0 -21
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +0 -1
- package/dist/context/index.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +0 -1
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/timeZoneOption.d.ts +10 -0
- package/dist/model/timeZoneOption.d.ts.map +1 -0
- package/dist/model/timeZoneOption.js +79 -0
- package/dist/model/timeZoneOption.js.map +1 -0
- package/dist/utils/axis.d.ts +0 -4
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +0 -9
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/chart-actions.d.ts +0 -2
- package/dist/utils/chart-actions.d.ts.map +1 -1
- package/dist/utils/chart-actions.js.map +1 -1
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +0 -20
- package/dist/utils/format.js.map +1 -1
- package/package.json +4 -7
- package/dist/LineChart/LineChart.d.ts +0 -22
- package/dist/LineChart/LineChart.d.ts.map +0 -1
- package/dist/LineChart/LineChart.js +0 -266
- package/dist/LineChart/LineChart.js.map +0 -1
- package/dist/LineChart/index.d.ts +0 -2
- package/dist/LineChart/index.d.ts.map +0 -1
- package/dist/LineChart/index.js.map +0 -1
- package/dist/TimeChart/TimeChart.d.ts +0 -24
- package/dist/TimeChart/TimeChart.d.ts.map +0 -1
- package/dist/TimeChart/TimeChart.js +0 -394
- package/dist/TimeChart/TimeChart.js.map +0 -1
- package/dist/TimeChart/index.d.ts +0 -2
- package/dist/TimeChart/index.d.ts.map +0 -1
- package/dist/TimeChart/index.js +0 -15
- package/dist/TimeChart/index.js.map +0 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +0 -21
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.js +0 -101
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +0 -1
- package/dist/cjs/LineChart/LineChart.js +0 -274
- package/dist/cjs/TimeChart/TimeChart.js +0 -407
- package/dist/cjs/TimeChart/index.js +0 -30
- package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +0 -114
- package/dist/cjs/context/TimeZoneProvider.js +0 -98
- package/dist/context/TimeZoneProvider.d.ts +0 -13
- package/dist/context/TimeZoneProvider.d.ts.map +0 -1
- package/dist/context/TimeZoneProvider.js +0 -38
- package/dist/context/TimeZoneProvider.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/TimeZoneSelector/TimeZoneSelector.tsx"],"sourcesContent":["// Copyright 2025 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 {\n MenuItem,\n Box,\n Paper,\n ListItemText,\n Typography,\n MenuList,\n Input,\n InputAdornment,\n Divider,\n useTheme,\n useMediaQuery,\n} from '@mui/material';\nimport ClickAwayListener from '@mui/material/ClickAwayListener';\nimport EarthIcon from 'mdi-material-ui/Earth';\nimport MagnifyIcon from 'mdi-material-ui/Magnify';\nimport { ChangeEvent, ReactElement, useState } from 'react';\nimport { DEFAULT_DASHBOARD_TIMEZONE } from '@perses-dev/core';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { getTimeZoneOffset, TimeZoneOption } from '../model/timeZoneOption';\n\nexport interface TimeZoneSelectorProps {\n heightPx?: string;\n timeZoneOptions: TimeZoneOption[];\n value: string;\n onChange?: (timeZone: TimeZoneOption) => void;\n}\n\nexport function TimeZoneSelector({\n heightPx = '34px',\n timeZoneOptions: defaultTimeZoneOptions,\n onChange,\n value = DEFAULT_DASHBOARD_TIMEZONE,\n}: TimeZoneSelectorProps): ReactElement {\n const isMobile = useMediaQuery(useTheme().breakpoints.down('md'));\n const [open, setOpen] = useState(false);\n const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n const [searchValue, setSearchValue] = useState('');\n\n const [timeZoneOptions, setTimeZoneOptions] = useState(defaultTimeZoneOptions);\n\n function handleSearchChange(event: ChangeEvent<HTMLInputElement>): void {\n setSearchValue(event.target.value);\n if (event.target.value === '') {\n setTimeZoneOptions(defaultTimeZoneOptions);\n } else {\n setTimeZoneOptions(\n defaultTimeZoneOptions.filter((option) => option.label.toLowerCase().includes(event.target.value.toLowerCase()))\n );\n }\n }\n\n function handleTimeZoneSelection(timeZone: TimeZoneOption): void {\n setOpen(false);\n setTimeZoneOptions(defaultTimeZoneOptions);\n setSearchValue('');\n onChange?.(timeZone);\n }\n\n function handleOnClickAway(): void {\n setOpen(false);\n setSearchValue('');\n setTimeZoneOptions(defaultTimeZoneOptions);\n }\n\n return (\n <ClickAwayListener onClickAway={handleOnClickAway}>\n <Box>\n <Box sx={{ position: 'relative' }}>\n <InfoTooltip description={value === DEFAULT_DASHBOARD_TIMEZONE ? localTimeZone : value}>\n <ToolbarIconButton\n data-testid=\"current-timezone\"\n aria-label=\"Timezone\"\n onClick={() => setOpen(!open)}\n sx={(theme) => ({\n height: heightPx,\n paddingLeft: isMobile ? 0 : theme.spacing(1),\n // Hide the timezone text on mobile\n '& .timezone-text': {\n display: isMobile ? 'none' : 'inline',\n },\n })}\n >\n <span className=\"timezone-text\">\n {value === DEFAULT_DASHBOARD_TIMEZONE\n ? getTimeZoneOffset(localTimeZone)?.value\n : getTimeZoneOffset(value)?.value}\n </span>\n <EarthIcon sx={(theme) => ({ marginLeft: theme.spacing(0.5) })} />\n </ToolbarIconButton>\n </InfoTooltip>\n </Box>\n <Paper\n sx={(theme) => ({\n width: 350,\n height: 355,\n position: 'absolute',\n top: isMobile ? 160 : 110,\n right: 10,\n zIndex: 1,\n boxShadow: 3,\n backgroundColor: theme.palette.background.paper,\n display: open ? 'block' : 'none',\n })}\n >\n <Input\n data-testid=\"search-timezone\"\n sx={(theme) => ({\n height: 45,\n padding: theme.spacing(1),\n })}\n value={searchValue}\n fullWidth\n placeholder=\"Search timezone\"\n startAdornment={\n <InputAdornment position=\"start\">\n <MagnifyIcon />\n </InputAdornment>\n }\n onChange={handleSearchChange}\n />\n <MenuList sx={{ height: 305, overflowX: 'auto' }}>\n {timeZoneOptions.map((timeZoneOption) => (\n <Box key={timeZoneOption.value}>\n <MenuItem\n key={timeZoneOption.value}\n onClick={() => handleTimeZoneSelection(timeZoneOption)}\n selected={timeZoneOption.value === value}\n >\n <ListItemText>{timeZoneOption.label}</ListItemText>\n <Typography variant=\"body2\">{timeZoneOption.longOffset}</Typography>\n </MenuItem>\n {timeZoneOption.value === DEFAULT_DASHBOARD_TIMEZONE && <Divider />}\n </Box>\n ))}\n </MenuList>\n </Paper>\n </Box>\n </ClickAwayListener>\n );\n}\n"],"names":["MenuItem","Box","Paper","ListItemText","Typography","MenuList","Input","InputAdornment","Divider","useTheme","useMediaQuery","ClickAwayListener","EarthIcon","MagnifyIcon","useState","DEFAULT_DASHBOARD_TIMEZONE","ToolbarIconButton","InfoTooltip","getTimeZoneOffset","TimeZoneSelector","heightPx","timeZoneOptions","defaultTimeZoneOptions","onChange","value","isMobile","breakpoints","down","open","setOpen","localTimeZone","Intl","DateTimeFormat","resolvedOptions","timeZone","searchValue","setSearchValue","setTimeZoneOptions","handleSearchChange","event","target","filter","option","label","toLowerCase","includes","handleTimeZoneSelection","handleOnClickAway","onClickAway","sx","position","description","data-testid","aria-label","onClick","theme","height","paddingLeft","spacing","display","span","className","marginLeft","width","top","right","zIndex","boxShadow","backgroundColor","palette","background","paper","padding","fullWidth","placeholder","startAdornment","overflowX","map","timeZoneOption","selected","variant","longOffset"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimeZoneSelector/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 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
|
|
@@ -10,6 +10,6 @@
|
|
|
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
|
-
export * from './
|
|
13
|
+
export * from './TimeZoneSelector';
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/TimeZoneSelector/index.ts"],"sourcesContent":["// Copyright 2025 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 './TimeZoneSelector';\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"}
|
|
@@ -34,12 +34,13 @@ function _interop_require_default(obj) {
|
|
|
34
34
|
default: obj
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
// Loading the ECharts extensions should happen in the respective
|
|
37
|
+
// Loading the ECharts extensions should happen in the respective plugins.
|
|
38
38
|
// This is a workaround for https://github.com/perses/plugins/issues/83.
|
|
39
39
|
(0, _core.use)([
|
|
40
40
|
_components.DatasetComponent,
|
|
41
41
|
_components.DataZoomComponent,
|
|
42
42
|
_components.LegendComponent,
|
|
43
|
+
_charts.LineChart,
|
|
43
44
|
_charts.GaugeChart,
|
|
44
45
|
_charts.PieChart,
|
|
45
46
|
_charts.ScatterChart,
|
|
@@ -47,9 +48,13 @@ function _interop_require_default(obj) {
|
|
|
47
48
|
_charts.HeatmapChart,
|
|
48
49
|
_components.GridComponent,
|
|
49
50
|
_components.TitleComponent,
|
|
51
|
+
_components.ToolboxComponent,
|
|
50
52
|
_components.TooltipComponent,
|
|
51
53
|
_renderers.CanvasRenderer,
|
|
52
|
-
_components.VisualMapComponent
|
|
54
|
+
_components.VisualMapComponent,
|
|
55
|
+
_components.MarkAreaComponent,
|
|
56
|
+
_components.MarkLineComponent,
|
|
57
|
+
_components.MarkPointComponent
|
|
53
58
|
]);
|
|
54
59
|
const mouseEvents = [
|
|
55
60
|
'click',
|
|
@@ -25,24 +25,23 @@ const _react = require("react");
|
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
26
|
const _xdatepickers = require("@mui/x-date-pickers");
|
|
27
27
|
const _AdapterDateFnsV3 = require("@mui/x-date-pickers/AdapterDateFnsV3");
|
|
28
|
-
const _context = require("../context");
|
|
29
28
|
const _ErrorBoundary = require("../ErrorBoundary");
|
|
30
29
|
const _ErrorAlert = require("../ErrorAlert");
|
|
30
|
+
const _format = require("../utils/format");
|
|
31
31
|
const _utils = require("./utils");
|
|
32
|
-
const DateTimeRangePicker = ({ initialTimeRange, onChange, onCancel })=>{
|
|
33
|
-
const { formatWithUserTimeZone } = (0, _context.useTimeZone)();
|
|
32
|
+
const DateTimeRangePicker = ({ initialTimeRange, onChange, onCancel, timeZone })=>{
|
|
34
33
|
// Time range values as dates that can be used as a time range.
|
|
35
34
|
const [timeRange, setTimeRange] = (0, _react.useState)(initialTimeRange);
|
|
36
35
|
// Time range values as strings used to populate the text inputs. May not
|
|
37
36
|
// be valid as dates when the user is typing.
|
|
38
37
|
const [timeRangeInputs, setTimeRangeInputs] = (0, _react.useState)({
|
|
39
|
-
start:
|
|
40
|
-
end:
|
|
38
|
+
start: (0, _format.formatWithTimeZone)(initialTimeRange.start, _utils.DATE_TIME_FORMAT, timeZone),
|
|
39
|
+
end: (0, _format.formatWithTimeZone)(initialTimeRange.end, _utils.DATE_TIME_FORMAT, timeZone)
|
|
41
40
|
});
|
|
42
41
|
const [showStartCalendar, setShowStartCalendar] = (0, _react.useState)(true);
|
|
43
42
|
const changeTimeRange = (newTime, segment)=>{
|
|
44
43
|
const isInputChange = typeof newTime === 'string';
|
|
45
|
-
const newInputTime = isInputChange ? newTime :
|
|
44
|
+
const newInputTime = isInputChange ? newTime : (0, _format.formatWithTimeZone)(newTime, _utils.DATE_TIME_FORMAT, timeZone);
|
|
46
45
|
setTimeRangeInputs((prevTimeRangeInputs)=>{
|
|
47
46
|
return {
|
|
48
47
|
...prevTimeRangeInputs,
|
|
@@ -22,10 +22,9 @@ Object.defineProperty(exports, "TimeRangeSelector", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
|
-
const
|
|
25
|
+
const _ClockTimeFiveOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ClockTimeFiveOutline"));
|
|
26
26
|
const _core = require("@perses-dev/core");
|
|
27
27
|
const _react = require("react");
|
|
28
|
-
const _context = require("../context");
|
|
29
28
|
const _DateTimeRangePicker = require("./DateTimeRangePicker");
|
|
30
29
|
const _utils = require("./utils");
|
|
31
30
|
function _interop_require_default(obj) {
|
|
@@ -33,8 +32,8 @@ function _interop_require_default(obj) {
|
|
|
33
32
|
default: obj
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
|
-
function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTimeRange = true }) {
|
|
37
|
-
const
|
|
35
|
+
function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTimeRange = true, timeZone = _core.DEFAULT_DASHBOARD_TIMEZONE }) {
|
|
36
|
+
const isMobile = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.down('md'));
|
|
38
37
|
const anchorEl = (0, _react.useRef)(); // Used to position the absolute time range picker
|
|
39
38
|
// Control the open state of the absolute time range picker
|
|
40
39
|
const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
|
|
@@ -78,7 +77,8 @@ function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTim
|
|
|
78
77
|
setShowCustomDateSelector(false);
|
|
79
78
|
setOpen(false);
|
|
80
79
|
},
|
|
81
|
-
onCancel: ()=>setShowCustomDateSelector(false)
|
|
80
|
+
onCancel: ()=>setShowCustomDateSelector(false),
|
|
81
|
+
timeZone: timeZone
|
|
82
82
|
})
|
|
83
83
|
}),
|
|
84
84
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
@@ -87,18 +87,22 @@ function TimeRangeSelector({ value, timeOptions, onChange, height, showCustomTim
|
|
|
87
87
|
open: open,
|
|
88
88
|
value: (0, _utils.formatTimeRange)(value, timeZone),
|
|
89
89
|
onClick: ()=>setOpen(!open),
|
|
90
|
-
IconComponent:
|
|
90
|
+
IconComponent: _ClockTimeFiveOutline.default,
|
|
91
91
|
inputProps: {
|
|
92
92
|
'aria-label': `Select time range. Currently set to ${value}`
|
|
93
93
|
},
|
|
94
94
|
sx: {
|
|
95
95
|
// `transform: none` prevents calendar icon from flipping over when menu is open
|
|
96
96
|
'.MuiSelect-icon': {
|
|
97
|
-
marginTop: '1px',
|
|
98
97
|
transform: 'none'
|
|
99
98
|
},
|
|
100
99
|
// paddingRight creates more space for the calendar icon (it's a bigger icon)
|
|
101
|
-
'.MuiSelect-select.MuiSelect-outlined.MuiInputBase-input': {
|
|
100
|
+
'.MuiSelect-select.MuiSelect-outlined.MuiInputBase-input': isMobile ? {
|
|
101
|
+
paddingRight: '25px',
|
|
102
|
+
textIndent: '-9999px',
|
|
103
|
+
whiteSpace: 'nowrap',
|
|
104
|
+
overflow: 'hidden'
|
|
105
|
+
} : {
|
|
102
106
|
paddingRight: '36px'
|
|
103
107
|
},
|
|
104
108
|
'.MuiSelect-select': height ? {
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
_export_star(require("./LineChartTooltip"), exports);
|
|
18
17
|
_export_star(require("./SeriesInfo"), exports);
|
|
19
18
|
_export_star(require("./SeriesLabelsStack"), exports);
|
|
20
19
|
_export_star(require("./SeriesMarker"), exports);
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Copyright 2025 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
|
+
Object.defineProperty(exports, "TimeZoneSelector", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return TimeZoneSelector;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _ClickAwayListener = /*#__PURE__*/ _interop_require_default(require("@mui/material/ClickAwayListener"));
|
|
26
|
+
const _Earth = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Earth"));
|
|
27
|
+
const _Magnify = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Magnify"));
|
|
28
|
+
const _react = require("react");
|
|
29
|
+
const _core = require("@perses-dev/core");
|
|
30
|
+
const _ToolbarIconButton = require("../ToolbarIconButton");
|
|
31
|
+
const _InfoTooltip = require("../InfoTooltip");
|
|
32
|
+
const _timeZoneOption = require("../model/timeZoneOption");
|
|
33
|
+
function _interop_require_default(obj) {
|
|
34
|
+
return obj && obj.__esModule ? obj : {
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function TimeZoneSelector({ heightPx = '34px', timeZoneOptions: defaultTimeZoneOptions, onChange, value = _core.DEFAULT_DASHBOARD_TIMEZONE }) {
|
|
39
|
+
const isMobile = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.down('md'));
|
|
40
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
41
|
+
const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
42
|
+
const [searchValue, setSearchValue] = (0, _react.useState)('');
|
|
43
|
+
const [timeZoneOptions, setTimeZoneOptions] = (0, _react.useState)(defaultTimeZoneOptions);
|
|
44
|
+
function handleSearchChange(event) {
|
|
45
|
+
setSearchValue(event.target.value);
|
|
46
|
+
if (event.target.value === '') {
|
|
47
|
+
setTimeZoneOptions(defaultTimeZoneOptions);
|
|
48
|
+
} else {
|
|
49
|
+
setTimeZoneOptions(defaultTimeZoneOptions.filter((option)=>option.label.toLowerCase().includes(event.target.value.toLowerCase())));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function handleTimeZoneSelection(timeZone) {
|
|
53
|
+
setOpen(false);
|
|
54
|
+
setTimeZoneOptions(defaultTimeZoneOptions);
|
|
55
|
+
setSearchValue('');
|
|
56
|
+
onChange?.(timeZone);
|
|
57
|
+
}
|
|
58
|
+
function handleOnClickAway() {
|
|
59
|
+
setOpen(false);
|
|
60
|
+
setSearchValue('');
|
|
61
|
+
setTimeZoneOptions(defaultTimeZoneOptions);
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ClickAwayListener.default, {
|
|
64
|
+
onClickAway: handleOnClickAway,
|
|
65
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
66
|
+
children: [
|
|
67
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
68
|
+
sx: {
|
|
69
|
+
position: 'relative'
|
|
70
|
+
},
|
|
71
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_InfoTooltip.InfoTooltip, {
|
|
72
|
+
description: value === _core.DEFAULT_DASHBOARD_TIMEZONE ? localTimeZone : value,
|
|
73
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ToolbarIconButton.ToolbarIconButton, {
|
|
74
|
+
"data-testid": "current-timezone",
|
|
75
|
+
"aria-label": "Timezone",
|
|
76
|
+
onClick: ()=>setOpen(!open),
|
|
77
|
+
sx: (theme)=>({
|
|
78
|
+
height: heightPx,
|
|
79
|
+
paddingLeft: isMobile ? 0 : theme.spacing(1),
|
|
80
|
+
// Hide the timezone text on mobile
|
|
81
|
+
'& .timezone-text': {
|
|
82
|
+
display: isMobile ? 'none' : 'inline'
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
87
|
+
className: "timezone-text",
|
|
88
|
+
children: value === _core.DEFAULT_DASHBOARD_TIMEZONE ? (0, _timeZoneOption.getTimeZoneOffset)(localTimeZone)?.value : (0, _timeZoneOption.getTimeZoneOffset)(value)?.value
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Earth.default, {
|
|
91
|
+
sx: (theme)=>({
|
|
92
|
+
marginLeft: theme.spacing(0.5)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Paper, {
|
|
100
|
+
sx: (theme)=>({
|
|
101
|
+
width: 350,
|
|
102
|
+
height: 355,
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
top: isMobile ? 160 : 110,
|
|
105
|
+
right: 10,
|
|
106
|
+
zIndex: 1,
|
|
107
|
+
boxShadow: 3,
|
|
108
|
+
backgroundColor: theme.palette.background.paper,
|
|
109
|
+
display: open ? 'block' : 'none'
|
|
110
|
+
}),
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Input, {
|
|
113
|
+
"data-testid": "search-timezone",
|
|
114
|
+
sx: (theme)=>({
|
|
115
|
+
height: 45,
|
|
116
|
+
padding: theme.spacing(1)
|
|
117
|
+
}),
|
|
118
|
+
value: searchValue,
|
|
119
|
+
fullWidth: true,
|
|
120
|
+
placeholder: "Search timezone",
|
|
121
|
+
startAdornment: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputAdornment, {
|
|
122
|
+
position: "start",
|
|
123
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Magnify.default, {})
|
|
124
|
+
}),
|
|
125
|
+
onChange: handleSearchChange
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuList, {
|
|
128
|
+
sx: {
|
|
129
|
+
height: 305,
|
|
130
|
+
overflowX: 'auto'
|
|
131
|
+
},
|
|
132
|
+
children: timeZoneOptions.map((timeZoneOption)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
133
|
+
children: [
|
|
134
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
|
|
135
|
+
onClick: ()=>handleTimeZoneSelection(timeZoneOption),
|
|
136
|
+
selected: timeZoneOption.value === value,
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ListItemText, {
|
|
139
|
+
children: timeZoneOption.label
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
142
|
+
variant: "body2",
|
|
143
|
+
children: timeZoneOption.longOffset
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}, timeZoneOption.value),
|
|
147
|
+
timeZoneOption.value === _core.DEFAULT_DASHBOARD_TIMEZONE && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {})
|
|
148
|
+
]
|
|
149
|
+
}, timeZoneOption.value))
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
]
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 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,7 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
_export_star(require("./
|
|
17
|
+
_export_star(require("./TimeZoneSelector"), exports);
|
|
18
18
|
function _export_star(from, to) {
|
|
19
19
|
Object.keys(from).forEach(function(k) {
|
|
20
20
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -16,7 +16,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
_export_star(require("./ChartsProvider"), exports);
|
|
18
18
|
_export_star(require("./SnackbarProvider"), exports);
|
|
19
|
-
_export_star(require("./TimeZoneProvider"), exports);
|
|
20
19
|
function _export_star(from, to) {
|
|
21
20
|
Object.keys(from).forEach(function(k) {
|
|
22
21
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -30,7 +30,6 @@ _export_star(require("./FormEditor"), exports);
|
|
|
30
30
|
_export_star(require("./InfoTooltip"), exports);
|
|
31
31
|
_export_star(require("./JSONEditor"), exports);
|
|
32
32
|
_export_star(require("./Legend"), exports);
|
|
33
|
-
_export_star(require("./LineChart"), exports);
|
|
34
33
|
_export_star(require("./LinksEditor"), exports);
|
|
35
34
|
_export_star(require("./ModeSelector"), exports);
|
|
36
35
|
_export_star(require("./OptionsEditorLayout"), exports);
|
|
@@ -39,8 +38,8 @@ _export_star(require("./SettingsAutocomplete"), exports);
|
|
|
39
38
|
_export_star(require("./SortSelector"), exports);
|
|
40
39
|
_export_star(require("./Table"), exports);
|
|
41
40
|
_export_star(require("./ThresholdsEditor"), exports);
|
|
42
|
-
_export_star(require("./TimeChart"), exports);
|
|
43
41
|
_export_star(require("./TimeRangeSelector"), exports);
|
|
42
|
+
_export_star(require("./TimeZoneSelector"), exports);
|
|
44
43
|
_export_star(require("./TimeSeriesTooltip"), exports);
|
|
45
44
|
_export_star(require("./ToolbarIconButton"), exports);
|
|
46
45
|
_export_star(require("./FormatControls"), exports);
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
_export_star(require("./graph"), exports);
|
|
18
18
|
_export_star(require("./theme"), exports);
|
|
19
19
|
_export_star(require("./timeOption"), exports);
|
|
20
|
+
_export_star(require("./timeZoneOption"), exports);
|
|
20
21
|
function _export_star(from, to) {
|
|
21
22
|
Object.keys(from).forEach(function(k) {
|
|
22
23
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright 2025 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
|
+
DEFAULT_TIMEZONE_OPTIONS: function() {
|
|
25
|
+
return DEFAULT_TIMEZONE_OPTIONS;
|
|
26
|
+
},
|
|
27
|
+
getTimeZoneOffset: function() {
|
|
28
|
+
return getTimeZoneOffset;
|
|
29
|
+
},
|
|
30
|
+
getTimeZoneOptions: function() {
|
|
31
|
+
return getTimeZoneOptions;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _core = require("@perses-dev/core");
|
|
35
|
+
const _memoize = /*#__PURE__*/ _interop_require_default(require("lodash/memoize"));
|
|
36
|
+
function _interop_require_default(obj) {
|
|
37
|
+
return obj && obj.__esModule ? obj : {
|
|
38
|
+
default: obj
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const DEFAULT_TIMEZONE_OPTIONS = (0, _memoize.default)(()=>Intl.supportedValuesOf('timeZone'));
|
|
42
|
+
const getTimeZoneOffset = (timeZone)=>{
|
|
43
|
+
const defaultLocale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
44
|
+
// longOffset is returned as either GMT+-<offset>, UTC+-<offset> or just GMT/UTC
|
|
45
|
+
const longOffset = Intl.DateTimeFormat(defaultLocale, {
|
|
46
|
+
timeZone,
|
|
47
|
+
timeZoneName: 'longOffset'
|
|
48
|
+
}).formatToParts(new Date()).find((part)=>part.type === 'timeZoneName');
|
|
49
|
+
return longOffset ? {
|
|
50
|
+
...longOffset,
|
|
51
|
+
// we want some consistency in the format of the offset, so if it's just GMT/UTC, we add +00:00
|
|
52
|
+
value: !(longOffset.value.includes('+') || longOffset.value.includes('-')) ? `${longOffset.value}+00:00` : longOffset.value
|
|
53
|
+
} : undefined;
|
|
54
|
+
};
|
|
55
|
+
const getTimeZoneOptions = (0, _memoize.default)(()=>{
|
|
56
|
+
const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
57
|
+
// define a browser time zone option
|
|
58
|
+
const BROWSER_TIME_ZONE = {
|
|
59
|
+
value: _core.DEFAULT_DASHBOARD_TIMEZONE,
|
|
60
|
+
label: `${localTimeZone} (default)`,
|
|
61
|
+
longOffset: getTimeZoneOffset(localTimeZone)?.value || ''
|
|
62
|
+
};
|
|
63
|
+
// define a UTC time zone option
|
|
64
|
+
const UTC = {
|
|
65
|
+
value: 'UTC',
|
|
66
|
+
label: 'UTC, GMT',
|
|
67
|
+
longOffset: 'UTC+00:00'
|
|
68
|
+
};
|
|
69
|
+
return(// putting UTC and local time zone options first for better user experience
|
|
70
|
+
[
|
|
71
|
+
'UTC',
|
|
72
|
+
_core.DEFAULT_DASHBOARD_TIMEZONE,
|
|
73
|
+
...DEFAULT_TIMEZONE_OPTIONS()
|
|
74
|
+
].map((timeZone)=>{
|
|
75
|
+
// return defined BROWSER_TIME_ZONE if timeZone is DEFAULT_DASHBOARD_TIMEZONE
|
|
76
|
+
if (timeZone === _core.DEFAULT_DASHBOARD_TIMEZONE) {
|
|
77
|
+
return BROWSER_TIME_ZONE;
|
|
78
|
+
}
|
|
79
|
+
// return defined UTC if timeZone is 'UTC'
|
|
80
|
+
if (timeZone === 'UTC') {
|
|
81
|
+
return UTC;
|
|
82
|
+
}
|
|
83
|
+
// return empty object if timeZone matches localTimeZone because we already returned it as BROWSER_TIME_ZONE
|
|
84
|
+
// avoid returning duplicate options
|
|
85
|
+
if (timeZone === localTimeZone) {
|
|
86
|
+
return {
|
|
87
|
+
value: '',
|
|
88
|
+
label: '',
|
|
89
|
+
longOffset: ''
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const longOffset = getTimeZoneOffset(timeZone);
|
|
93
|
+
return {
|
|
94
|
+
value: timeZone,
|
|
95
|
+
label: timeZone.replaceAll('_', ' '),
|
|
96
|
+
longOffset: longOffset ? longOffset.value : ''
|
|
97
|
+
};
|
|
98
|
+
})// filter out objects with empty value
|
|
99
|
+
.filter((option)=>option.value !== ''));
|
|
100
|
+
});
|
package/dist/cjs/utils/axis.js
CHANGED
|
@@ -14,17 +14,9 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
getDateRange: function() {
|
|
25
|
-
return getDateRange;
|
|
26
|
-
},
|
|
27
|
-
getFormattedAxis: function() {
|
|
17
|
+
Object.defineProperty(exports, "getFormattedAxis", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
28
20
|
return getFormattedAxis;
|
|
29
21
|
}
|
|
30
22
|
});
|
|
@@ -53,10 +45,3 @@ function getFormattedAxis(axis, unit) {
|
|
|
53
45
|
(0, _merge.default)(AXIS_DEFAULT, axis)
|
|
54
46
|
];
|
|
55
47
|
}
|
|
56
|
-
function getDateRange(data) {
|
|
57
|
-
const defaultRange = 3600000; // hour in ms
|
|
58
|
-
if (data.length === 0) return defaultRange;
|
|
59
|
-
const lastDatum = data[data.length - 1];
|
|
60
|
-
if (data[0] === undefined || lastDatum === undefined) return defaultRange;
|
|
61
|
-
return lastDatum - data[0];
|
|
62
|
-
}
|
package/dist/cjs/utils/format.js
CHANGED
|
@@ -32,9 +32,6 @@ _export(exports, {
|
|
|
32
32
|
},
|
|
33
33
|
getFormattedAxisLabel: function() {
|
|
34
34
|
return getFormattedAxisLabel;
|
|
35
|
-
},
|
|
36
|
-
getFormattedDate: function() {
|
|
37
|
-
return getFormattedDate;
|
|
38
35
|
}
|
|
39
36
|
});
|
|
40
37
|
const _datefnstz = require("date-fns-tz");
|
|
@@ -67,24 +64,6 @@ function formatWithTimeZone(date, formatString, timeZone) {
|
|
|
67
64
|
return (0, _datefnstz.formatInTimeZone)(date, lowerTimeZone === 'utc' ? 'UTC' : timeZone, formatString);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
function getFormattedDate(value, rangeMs, timeZone) {
|
|
71
|
-
const dateFormatOptions = dateFormatOptionsWithTimeZone({
|
|
72
|
-
hour: 'numeric',
|
|
73
|
-
minute: 'numeric',
|
|
74
|
-
hourCycle: 'h23'
|
|
75
|
-
}, timeZone);
|
|
76
|
-
const thirtyMinMs = 1800000;
|
|
77
|
-
const dayMs = 86400000;
|
|
78
|
-
if (rangeMs <= thirtyMinMs) {
|
|
79
|
-
dateFormatOptions.second = 'numeric';
|
|
80
|
-
} else if (rangeMs >= dayMs) {
|
|
81
|
-
dateFormatOptions.month = 'numeric';
|
|
82
|
-
dateFormatOptions.day = 'numeric';
|
|
83
|
-
}
|
|
84
|
-
const DATE_FORMAT = new Intl.DateTimeFormat(undefined, dateFormatOptions);
|
|
85
|
-
// remove comma when month / day present
|
|
86
|
-
return DATE_FORMAT.format(value).replace(/, /g, ' ');
|
|
87
|
-
}
|
|
88
67
|
function getFormattedAxisLabel(rangeMs) {
|
|
89
68
|
const dayMs = 86400000;
|
|
90
69
|
const monthMs = 2629440000;
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
package/dist/context/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/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 './ChartsProvider';\nexport * from './SnackbarProvider';\
|
|
1
|
+
{"version":3,"sources":["../../src/context/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 './ChartsProvider';\nexport * from './SnackbarProvider';\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,mBAAmB;AACjC,cAAc,qBAAqB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export * from './FormEditor';
|
|
|
14
14
|
export * from './InfoTooltip';
|
|
15
15
|
export * from './JSONEditor';
|
|
16
16
|
export * from './Legend';
|
|
17
|
-
export * from './LineChart';
|
|
18
17
|
export * from './LinksEditor';
|
|
19
18
|
export * from './ModeSelector';
|
|
20
19
|
export * from './OptionsEditorLayout';
|
|
@@ -23,8 +22,8 @@ export * from './SettingsAutocomplete';
|
|
|
23
22
|
export * from './SortSelector';
|
|
24
23
|
export * from './Table';
|
|
25
24
|
export * from './ThresholdsEditor';
|
|
26
|
-
export * from './TimeChart';
|
|
27
25
|
export * from './TimeRangeSelector';
|
|
26
|
+
export * from './TimeZoneSelector';
|
|
28
27
|
export * from './TimeSeriesTooltip';
|
|
29
28
|
export * from './ToolbarIconButton';
|
|
30
29
|
export * from './FormatControls';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,6 @@ export * from './FormEditor';
|
|
|
26
26
|
export * from './InfoTooltip';
|
|
27
27
|
export * from './JSONEditor';
|
|
28
28
|
export * from './Legend';
|
|
29
|
-
export * from './LineChart';
|
|
30
29
|
export * from './LinksEditor';
|
|
31
30
|
export * from './ModeSelector';
|
|
32
31
|
export * from './OptionsEditorLayout';
|
|
@@ -35,8 +34,8 @@ export * from './SettingsAutocomplete';
|
|
|
35
34
|
export * from './SortSelector';
|
|
36
35
|
export * from './Table';
|
|
37
36
|
export * from './ThresholdsEditor';
|
|
38
|
-
export * from './TimeChart';
|
|
39
37
|
export * from './TimeRangeSelector';
|
|
38
|
+
export * from './TimeZoneSelector';
|
|
40
39
|
export * from './TimeSeriesTooltip';
|
|
41
40
|
export * from './ToolbarIconButton';
|
|
42
41
|
export * from './FormatControls';
|