@perses-dev/components 0.0.0-snapshot-time-zone-selector-946f408 → 0.0.0-snapshot-panel-actions-520389b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +1 -2
  2. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
  3. package/dist/TimeRangeSelector/DateTimeRangePicker.js +6 -5
  4. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  5. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -5
  6. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
  7. package/dist/TimeRangeSelector/TimeRangeSelector.js +10 -14
  8. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  9. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +6 -5
  10. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +8 -12
  11. package/dist/cjs/context/TimeZoneProvider.js +98 -0
  12. package/dist/cjs/context/index.js +1 -0
  13. package/dist/cjs/index.js +0 -1
  14. package/dist/cjs/model/index.js +0 -1
  15. package/dist/context/TimeZoneProvider.d.ts +13 -0
  16. package/dist/context/TimeZoneProvider.d.ts.map +1 -0
  17. package/dist/context/TimeZoneProvider.js +38 -0
  18. package/dist/context/TimeZoneProvider.js.map +1 -0
  19. package/dist/context/index.d.ts +1 -0
  20. package/dist/context/index.d.ts.map +1 -1
  21. package/dist/context/index.js +1 -0
  22. package/dist/context/index.js.map +1 -1
  23. package/dist/index.d.ts +0 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +0 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/model/index.d.ts +0 -1
  28. package/dist/model/index.d.ts.map +1 -1
  29. package/dist/model/index.js +0 -1
  30. package/dist/model/index.js.map +1 -1
  31. package/package.json +2 -2
  32. package/dist/TimeZoneSelector/TimeZoneSelector.d.ts +0 -10
  33. package/dist/TimeZoneSelector/TimeZoneSelector.d.ts.map +0 -1
  34. package/dist/TimeZoneSelector/TimeZoneSelector.js +0 -143
  35. package/dist/TimeZoneSelector/TimeZoneSelector.js.map +0 -1
  36. package/dist/TimeZoneSelector/index.d.ts +0 -2
  37. package/dist/TimeZoneSelector/index.d.ts.map +0 -1
  38. package/dist/TimeZoneSelector/index.js +0 -15
  39. package/dist/TimeZoneSelector/index.js.map +0 -1
  40. package/dist/cjs/TimeZoneSelector/TimeZoneSelector.js +0 -156
  41. package/dist/cjs/TimeZoneSelector/index.js +0 -30
  42. package/dist/cjs/model/timeZoneOption.js +0 -100
  43. package/dist/model/timeZoneOption.d.ts +0 -10
  44. package/dist/model/timeZoneOption.d.ts.map +0 -1
  45. package/dist/model/timeZoneOption.js +0 -79
  46. package/dist/model/timeZoneOption.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/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 './AlignSelector';\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './controls';\nexport * from './Dialog';\nexport * from './DensitySelector';\nexport * from './DragAndDrop';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './FormEditor';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LinksEditor';\nexport * from './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './Overlay';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeRangeSelector';\nexport * from './TimeZoneSelector';\nexport * from './TimeSeriesTooltip';\nexport * from './ToolbarIconButton';\nexport * from './FormatControls';\nexport * from './YAxisLabel';\nexport * from './context';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './TransformsEditor';\nexport * from './RefreshIntervalPicker';\nexport * from './ValueMappingEditor';\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,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,qBAAqB;AACnC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,YAAY;AAC1B,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,qBAAqB;AACnC,cAAc,0BAA0B;AACxC,cAAc,uBAAuB"}
1
+ {"version":3,"sources":["../src/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 './AlignSelector';\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './controls';\nexport * from './Dialog';\nexport * from './DensitySelector';\nexport * from './DragAndDrop';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './FormEditor';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LinksEditor';\nexport * from './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './Overlay';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeRangeSelector';\nexport * from './TimeSeriesTooltip';\nexport * from './ToolbarIconButton';\nexport * from './FormatControls';\nexport * from './YAxisLabel';\nexport * from './context';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './TransformsEditor';\nexport * from './RefreshIntervalPicker';\nexport * from './ValueMappingEditor';\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,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,qBAAqB;AACnC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,YAAY;AAC1B,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,qBAAqB;AACnC,cAAc,0BAA0B;AACxC,cAAc,uBAAuB"}
@@ -1,5 +1,4 @@
1
1
  export * from './graph';
2
2
  export * from './theme';
3
3
  export * from './timeOption';
4
- export * from './timeZoneOption';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -13,6 +13,5 @@
13
13
  export * from './graph';
14
14
  export * from './theme';
15
15
  export * from './timeOption';
16
- export * from './timeZoneOption';
17
16
 
18
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/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 './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\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,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,mBAAmB"}
1
+ {"version":3,"sources":["../../src/model/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 './graph';\nexport * from './theme';\nexport * from './timeOption';\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,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.0.0-snapshot-time-zone-selector-946f408",
3
+ "version": "0.0.0-snapshot-panel-actions-520389b",
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.0.0-snapshot-time-zone-selector-946f408",
36
+ "@perses-dev/core": "0.0.0-snapshot-panel-actions-520389b",
37
37
  "@tanstack/react-table": "^8.20.5",
38
38
  "@uiw/react-codemirror": "^4.19.1",
39
39
  "date-fns": "^4.1.0",
@@ -1,10 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { TimeZoneOption } from '../model/timeZoneOption';
3
- export interface TimeZoneSelectorProps {
4
- heightPx?: string;
5
- timeZoneOptions: TimeZoneOption[];
6
- value: string;
7
- onChange?: (timeZone: TimeZoneOption) => void;
8
- }
9
- export declare function TimeZoneSelector({ heightPx, timeZoneOptions: defaultTimeZoneOptions, onChange, value, }: TimeZoneSelectorProps): ReactElement;
10
- //# sourceMappingURL=TimeZoneSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeZoneSelector.d.ts","sourceRoot":"","sources":["../../src/TimeZoneSelector/TimeZoneSelector.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAe,YAAY,EAAY,MAAM,OAAO,CAAC;AAI5D,OAAO,EAAqB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE5E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAiB,EACjB,eAAe,EAAE,sBAAsB,EACvC,QAAQ,EACR,KAAkC,GACnC,EAAE,qBAAqB,GAAG,YAAY,CA2GtC"}
@@ -1,143 +0,0 @@
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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { MenuItem, Box, Paper, ListItemText, Typography, MenuList, Input, InputAdornment, Divider, useTheme, useMediaQuery } from '@mui/material';
15
- import ClickAwayListener from '@mui/material/ClickAwayListener';
16
- import EarthIcon from 'mdi-material-ui/Earth';
17
- import MagnifyIcon from 'mdi-material-ui/Magnify';
18
- import { useState } from 'react';
19
- import { DEFAULT_DASHBOARD_TIMEZONE } from '@perses-dev/core';
20
- import { ToolbarIconButton } from '../ToolbarIconButton';
21
- import { InfoTooltip } from '../InfoTooltip';
22
- import { getTimeZoneOffset } from '../model/timeZoneOption';
23
- export function TimeZoneSelector({ heightPx = '34px', timeZoneOptions: defaultTimeZoneOptions, onChange, value = DEFAULT_DASHBOARD_TIMEZONE }) {
24
- const isMobile = useMediaQuery(useTheme().breakpoints.down('md'));
25
- const [open, setOpen] = useState(false);
26
- const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
27
- const [searchValue, setSearchValue] = useState('');
28
- const [timeZoneOptions, setTimeZoneOptions] = useState(defaultTimeZoneOptions);
29
- function handleSearchChange(event) {
30
- setSearchValue(event.target.value);
31
- if (event.target.value === '') {
32
- setTimeZoneOptions(defaultTimeZoneOptions);
33
- } else {
34
- setTimeZoneOptions(defaultTimeZoneOptions.filter((option)=>option.label.toLowerCase().includes(event.target.value.toLowerCase())));
35
- }
36
- }
37
- function handleTimeZoneSelection(timeZone) {
38
- setOpen(false);
39
- setTimeZoneOptions(defaultTimeZoneOptions);
40
- setSearchValue('');
41
- onChange?.(timeZone);
42
- }
43
- function handleOnClickAway() {
44
- setOpen(false);
45
- setSearchValue('');
46
- setTimeZoneOptions(defaultTimeZoneOptions);
47
- }
48
- return /*#__PURE__*/ _jsx(ClickAwayListener, {
49
- onClickAway: handleOnClickAway,
50
- children: /*#__PURE__*/ _jsxs(Box, {
51
- children: [
52
- /*#__PURE__*/ _jsx(Box, {
53
- sx: {
54
- position: 'relative'
55
- },
56
- children: /*#__PURE__*/ _jsx(InfoTooltip, {
57
- description: value === DEFAULT_DASHBOARD_TIMEZONE ? localTimeZone : value,
58
- children: /*#__PURE__*/ _jsxs(ToolbarIconButton, {
59
- "data-testid": "current-timezone",
60
- "aria-label": "Timezone",
61
- onClick: ()=>setOpen(!open),
62
- sx: (theme)=>({
63
- height: heightPx,
64
- paddingLeft: isMobile ? 0 : theme.spacing(1),
65
- // Hide the timezone text on mobile
66
- '& .timezone-text': {
67
- display: isMobile ? 'none' : 'inline'
68
- }
69
- }),
70
- children: [
71
- /*#__PURE__*/ _jsx("span", {
72
- className: "timezone-text",
73
- children: value === DEFAULT_DASHBOARD_TIMEZONE ? getTimeZoneOffset(localTimeZone)?.value : getTimeZoneOffset(value)?.value
74
- }),
75
- /*#__PURE__*/ _jsx(EarthIcon, {
76
- sx: (theme)=>({
77
- marginLeft: theme.spacing(0.5)
78
- })
79
- })
80
- ]
81
- })
82
- })
83
- }),
84
- /*#__PURE__*/ _jsxs(Paper, {
85
- sx: (theme)=>({
86
- width: 350,
87
- height: 355,
88
- position: 'absolute',
89
- top: isMobile ? 160 : 110,
90
- right: 10,
91
- zIndex: 1,
92
- boxShadow: 3,
93
- backgroundColor: theme.palette.background.paper,
94
- display: open ? 'block' : 'none'
95
- }),
96
- children: [
97
- /*#__PURE__*/ _jsx(Input, {
98
- "data-testid": "search-timezone",
99
- sx: (theme)=>({
100
- height: 45,
101
- padding: theme.spacing(1)
102
- }),
103
- value: searchValue,
104
- fullWidth: true,
105
- placeholder: "Search timezone",
106
- startAdornment: /*#__PURE__*/ _jsx(InputAdornment, {
107
- position: "start",
108
- children: /*#__PURE__*/ _jsx(MagnifyIcon, {})
109
- }),
110
- onChange: handleSearchChange
111
- }),
112
- /*#__PURE__*/ _jsx(MenuList, {
113
- sx: {
114
- height: 305,
115
- overflowX: 'auto'
116
- },
117
- children: timeZoneOptions.map((timeZoneOption)=>/*#__PURE__*/ _jsxs(Box, {
118
- children: [
119
- /*#__PURE__*/ _jsxs(MenuItem, {
120
- onClick: ()=>handleTimeZoneSelection(timeZoneOption),
121
- selected: timeZoneOption.value === value,
122
- children: [
123
- /*#__PURE__*/ _jsx(ListItemText, {
124
- children: timeZoneOption.label
125
- }),
126
- /*#__PURE__*/ _jsx(Typography, {
127
- variant: "body2",
128
- children: timeZoneOption.longOffset
129
- })
130
- ]
131
- }, timeZoneOption.value),
132
- timeZoneOption.value === DEFAULT_DASHBOARD_TIMEZONE && /*#__PURE__*/ _jsx(Divider, {})
133
- ]
134
- }, timeZoneOption.value))
135
- })
136
- ]
137
- })
138
- ]
139
- })
140
- });
141
- }
142
-
143
- //# sourceMappingURL=TimeZoneSelector.js.map
@@ -1 +0,0 @@
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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"}
@@ -1,2 +0,0 @@
1
- export * from './TimeZoneSelector';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TimeZoneSelector/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
@@ -1,15 +0,0 @@
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
- export * from './TimeZoneSelector';
14
-
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,156 +0,0 @@
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,30 +0,0 @@
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
- _export_star(require("./TimeZoneSelector"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }
@@ -1,100 +0,0 @@
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
- });
@@ -1,10 +0,0 @@
1
- /// <reference types="lodash" />
2
- export interface TimeZoneOption {
3
- value: string;
4
- label: string;
5
- longOffset: string;
6
- }
7
- export declare const DEFAULT_TIMEZONE_OPTIONS: (() => string[]) & import("lodash").MemoizedFunction;
8
- export declare const getTimeZoneOffset: (timeZone: string) => Intl.DateTimeFormatPart | undefined;
9
- export declare const getTimeZoneOptions: (() => TimeZoneOption[]) & import("lodash").MemoizedFunction;
10
- //# sourceMappingURL=timeZoneOption.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeZoneOption.d.ts","sourceRoot":"","sources":["../../src/model/timeZoneOption.ts"],"names":[],"mappings":";AAgBA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,eAAO,MAAM,wBAAwB,sDAAoD,CAAC;AAG1F,eAAO,MAAM,iBAAiB,aAAc,MAAM,KAAG,KAAK,kBAAkB,GAAG,SAe9E,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAe,cAAc,EAAE,qCAsC5D,CAAC"}