@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
@@ -1,79 +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 { DEFAULT_DASHBOARD_TIMEZONE } from '@perses-dev/core';
14
- import memoize from 'lodash/memoize';
15
- // Instead of adding another dependency which returns an array of time zones, we can use the built-in Intl object
16
- // memoizing this because the list of time zones is relatively expensive to compute with 400+ entries
17
- export const DEFAULT_TIMEZONE_OPTIONS = memoize(()=>Intl.supportedValuesOf('timeZone'));
18
- // Get the time zone offset for a given time zone
19
- export const getTimeZoneOffset = (timeZone)=>{
20
- const defaultLocale = Intl.DateTimeFormat().resolvedOptions().locale;
21
- // longOffset is returned as either GMT+-<offset>, UTC+-<offset> or just GMT/UTC
22
- const longOffset = Intl.DateTimeFormat(defaultLocale, {
23
- timeZone,
24
- timeZoneName: 'longOffset'
25
- }).formatToParts(new Date()).find((part)=>part.type === 'timeZoneName');
26
- return longOffset ? {
27
- ...longOffset,
28
- // we want some consistency in the format of the offset, so if it's just GMT/UTC, we add +00:00
29
- value: !(longOffset.value.includes('+') || longOffset.value.includes('-')) ? `${longOffset.value}+00:00` : longOffset.value
30
- } : undefined;
31
- };
32
- export const getTimeZoneOptions = memoize(()=>{
33
- const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
34
- // define a browser time zone option
35
- const BROWSER_TIME_ZONE = {
36
- value: DEFAULT_DASHBOARD_TIMEZONE,
37
- label: `${localTimeZone} (default)`,
38
- longOffset: getTimeZoneOffset(localTimeZone)?.value || ''
39
- };
40
- // define a UTC time zone option
41
- const UTC = {
42
- value: 'UTC',
43
- label: 'UTC, GMT',
44
- longOffset: 'UTC+00:00'
45
- };
46
- return(// putting UTC and local time zone options first for better user experience
47
- [
48
- 'UTC',
49
- DEFAULT_DASHBOARD_TIMEZONE,
50
- ...DEFAULT_TIMEZONE_OPTIONS()
51
- ].map((timeZone)=>{
52
- // return defined BROWSER_TIME_ZONE if timeZone is DEFAULT_DASHBOARD_TIMEZONE
53
- if (timeZone === DEFAULT_DASHBOARD_TIMEZONE) {
54
- return BROWSER_TIME_ZONE;
55
- }
56
- // return defined UTC if timeZone is 'UTC'
57
- if (timeZone === 'UTC') {
58
- return UTC;
59
- }
60
- // return empty object if timeZone matches localTimeZone because we already returned it as BROWSER_TIME_ZONE
61
- // avoid returning duplicate options
62
- if (timeZone === localTimeZone) {
63
- return {
64
- value: '',
65
- label: '',
66
- longOffset: ''
67
- };
68
- }
69
- const longOffset = getTimeZoneOffset(timeZone);
70
- return {
71
- value: timeZone,
72
- label: timeZone.replaceAll('_', ' '),
73
- longOffset: longOffset ? longOffset.value : ''
74
- };
75
- })// filter out objects with empty value
76
- .filter((option)=>option.value !== ''));
77
- });
78
-
79
- //# sourceMappingURL=timeZoneOption.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/model/timeZoneOption.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\nimport { DEFAULT_DASHBOARD_TIMEZONE } from '@perses-dev/core';\nimport memoize from 'lodash/memoize';\n\nexport interface TimeZoneOption {\n value: string;\n label: string;\n longOffset: string;\n}\n\n// Instead of adding another dependency which returns an array of time zones, we can use the built-in Intl object\n// memoizing this because the list of time zones is relatively expensive to compute with 400+ entries\nexport const DEFAULT_TIMEZONE_OPTIONS = memoize(() => Intl.supportedValuesOf('timeZone'));\n\n// Get the time zone offset for a given time zone\nexport const getTimeZoneOffset = (timeZone: string): Intl.DateTimeFormatPart | undefined => {\n const defaultLocale = Intl.DateTimeFormat().resolvedOptions().locale;\n // longOffset is returned as either GMT+-<offset>, UTC+-<offset> or just GMT/UTC\n const longOffset = Intl.DateTimeFormat(defaultLocale, { timeZone, timeZoneName: 'longOffset' })\n .formatToParts(new Date())\n .find((part) => part.type === 'timeZoneName');\n return longOffset\n ? {\n ...longOffset,\n // we want some consistency in the format of the offset, so if it's just GMT/UTC, we add +00:00\n value: !(longOffset.value.includes('+') || longOffset.value.includes('-'))\n ? `${longOffset.value}+00:00`\n : longOffset.value,\n }\n : undefined;\n};\n\nexport const getTimeZoneOptions = memoize((): TimeZoneOption[] => {\n const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n // define a browser time zone option\n const BROWSER_TIME_ZONE: TimeZoneOption = {\n value: DEFAULT_DASHBOARD_TIMEZONE,\n label: `${localTimeZone} (default)`,\n longOffset: getTimeZoneOffset(localTimeZone)?.value || '',\n };\n // define a UTC time zone option\n const UTC: TimeZoneOption = { value: 'UTC', label: 'UTC, GMT', longOffset: 'UTC+00:00' };\n\n return (\n // putting UTC and local time zone options first for better user experience\n ['UTC', DEFAULT_DASHBOARD_TIMEZONE, ...DEFAULT_TIMEZONE_OPTIONS()]\n .map((timeZone) => {\n // return defined BROWSER_TIME_ZONE if timeZone is DEFAULT_DASHBOARD_TIMEZONE\n if (timeZone === DEFAULT_DASHBOARD_TIMEZONE) {\n return BROWSER_TIME_ZONE;\n }\n // return defined UTC if timeZone is 'UTC'\n if (timeZone === 'UTC') {\n return UTC;\n }\n // return empty object if timeZone matches localTimeZone because we already returned it as BROWSER_TIME_ZONE\n // avoid returning duplicate options\n if (timeZone === localTimeZone) {\n return { value: '', label: '', longOffset: '' };\n }\n const longOffset = getTimeZoneOffset(timeZone);\n return {\n value: timeZone,\n label: timeZone.replaceAll('_', ' '),\n longOffset: longOffset ? longOffset.value : '',\n };\n })\n // filter out objects with empty value\n .filter((option) => option.value !== '')\n );\n});\n"],"names":["DEFAULT_DASHBOARD_TIMEZONE","memoize","DEFAULT_TIMEZONE_OPTIONS","Intl","supportedValuesOf","getTimeZoneOffset","timeZone","defaultLocale","DateTimeFormat","resolvedOptions","locale","longOffset","timeZoneName","formatToParts","Date","find","part","type","value","includes","undefined","getTimeZoneOptions","localTimeZone","BROWSER_TIME_ZONE","label","UTC","map","replaceAll","filter","option"],"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,0BAA0B,QAAQ,mBAAmB;AAC9D,OAAOC,aAAa,iBAAiB;AAQrC,iHAAiH;AACjH,qGAAqG;AACrG,OAAO,MAAMC,2BAA2BD,QAAQ,IAAME,KAAK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