baseui 0.0.0-next-d7a218e → 0.0.0-next-77075cd

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.
@@ -32,12 +32,16 @@ class ProgressBar extends React.Component {
32
32
  size,
33
33
  steps,
34
34
  successValue,
35
+ minValue,
36
+ maxValue,
35
37
  showLabel,
36
38
  infinite,
37
39
  errorMessage,
38
40
  forwardedRef,
39
41
  ...restProps
40
- } = this.props;
42
+ } = this.props; // fallback on successValue (and it's default) if maxValue is not set by user
43
+
44
+ const maximumValue = maxValue !== 100 ? maxValue : successValue;
41
45
  const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
42
46
  const [BarContainer, barContainerProps] = getOverrides(overrides.BarContainer, StyledBarContainer);
43
47
  const [Bar, barProps] = getOverrides(overrides.Bar, StyledBar);
@@ -48,7 +52,9 @@ class ProgressBar extends React.Component {
48
52
  $infinite: infinite,
49
53
  $size: size,
50
54
  $steps: steps,
51
- $successValue: successValue,
55
+ $successValue: maximumValue,
56
+ $minValue: minValue,
57
+ $maxValue: maximumValue,
52
58
  $value: value
53
59
  };
54
60
 
@@ -73,10 +79,10 @@ class ProgressBar extends React.Component {
73
79
  ref: forwardedRef,
74
80
  "data-baseweb": "progress-bar",
75
81
  role: "progressbar",
76
- "aria-label": ariaLabel || getProgressLabel(value, successValue),
82
+ "aria-label": ariaLabel || getProgressLabel(value, maximumValue, minValue),
77
83
  "aria-valuenow": infinite ? null : value,
78
- "aria-valuemin": infinite ? null : 0,
79
- "aria-valuemax": infinite ? null : successValue,
84
+ "aria-valuemin": infinite ? null : minValue,
85
+ "aria-valuemax": infinite ? null : maximumValue,
80
86
  "aria-invalid": errorMessage ? true : null,
81
87
  "aria-errormessage": errorMessage
82
88
  }, restProps, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
@@ -84,20 +90,22 @@ class ProgressBar extends React.Component {
84
90
  $size: sharedProps.$size
85
91
  }, infiniteBarProps)), /*#__PURE__*/React.createElement(InfiniteBar, _extends({
86
92
  $size: sharedProps.$size
87
- }, infiniteBarProps))) : renderProgressBar()), showLabel && /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), getProgressLabel(value, successValue)))
93
+ }, infiniteBarProps))) : renderProgressBar()), showLabel && /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), getProgressLabel(value, maximumValue, minValue)))
88
94
  );
89
95
  }
90
96
 
91
97
  }
92
98
 
93
99
  _defineProperty(ProgressBar, "defaultProps", {
94
- getProgressLabel: (value, successValue) => `${Math.round(value / successValue * 100)}% Loaded`,
100
+ getProgressLabel: (value, maxValue, minValue) => `${Math.round((value - minValue) / (maxValue - minValue) * 100)}% Loaded`,
95
101
  infinite: false,
96
102
  overrides: {},
97
103
  showLabel: false,
98
104
  size: SIZE.medium,
99
105
  steps: 1,
100
106
  successValue: 100,
107
+ minValue: 0,
108
+ maxValue: 100,
101
109
  value: 0
102
110
  });
103
111
 
@@ -76,14 +76,18 @@ export const StyledBarProgress = styled('div', props => {
76
76
  $value,
77
77
  $successValue,
78
78
  $steps,
79
- $index
80
- } = props;
79
+ $index,
80
+ $maxValue,
81
+ $minValue = 0
82
+ } = props; // making sure this doesn't break existing use that use StyledBarProgress directly
83
+
84
+ const maxValue = $maxValue ? $maxValue : $successValue;
81
85
  const {
82
86
  colors,
83
87
  sizing,
84
88
  borders
85
89
  } = $theme;
86
- const width = `${100 - $value / $successValue * 100}%`;
90
+ const width = `${100 - ($value - $minValue) * 100 / (maxValue - $minValue)}%`;
87
91
  const stepStates = {
88
92
  default: 'default',
89
93
  awaits: 'awaits',
@@ -93,8 +97,8 @@ export const StyledBarProgress = styled('div', props => {
93
97
  let stepState = stepStates.default;
94
98
 
95
99
  if ($steps > 1) {
96
- const stepValue = $successValue / $steps;
97
- const currentValue = $value / $successValue * 100;
100
+ const stepValue = (maxValue - $minValue) / $steps;
101
+ const currentValue = ($value - $minValue) / (maxValue - $minValue) * 100;
98
102
  const completedSteps = Math.floor(currentValue / stepValue);
99
103
 
100
104
  if ($index < completedSteps) {
@@ -10,11 +10,11 @@ LICENSE file in the root directory of this source tree.
10
10
  */
11
11
  // global Intl
12
12
  import * as React from 'react';
13
- import { findTimeZone, getZonedTime, listTimeZones } from 'timezone-support/dist/index-1900-2050.js';
14
- import { formatZonedTime } from 'timezone-support/dist/parse-format.js';
13
+ import { format, getTimezoneOffset } from 'date-fns-tz';
15
14
  import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
16
15
  import { LocaleContext } from '../locale/index.js';
17
16
  import { Select } from '../select/index.js';
17
+ import { zones } from './tzdata.js';
18
18
 
19
19
  class TimezonePicker extends React.Component {
20
20
  constructor(...args) {
@@ -25,42 +25,49 @@ class TimezonePicker extends React.Component {
25
25
  value: null
26
26
  });
27
27
 
28
- _defineProperty(this, "buildTimezones", compareDate => listTimeZones().map(zone => {
29
- const timezone = findTimeZone(zone);
30
- const zonedTime = getZonedTime(compareDate, timezone);
31
- const offsetTime = (zonedTime.zone.offset < 0 ? '+' : '-') + Math.abs(zonedTime.zone.offset / 60);
32
- const abbreviation = formatZonedTime(zonedTime, 'z');
33
- const formatted = `(GMT ${offsetTime}) ${zone}${this.props.includeAbbreviations ? ` - ${abbreviation}` : ''}`.replace('_', ' ');
34
- const option = {
35
- id: zone,
36
- label: formatted,
37
- offset: zonedTime.zone.offset
38
- };
39
-
40
- if (this.props.mapLabels) {
41
- option.label = this.props.mapLabels(option);
42
- }
28
+ _defineProperty(this, "buildTimezones", compareDate => {
29
+ const timezones = [];
30
+
31
+ for (const zoneName of zones) {
32
+ try {
33
+ const offset = getTimezoneOffset(zoneName, compareDate) / 3_600_000;
34
+ const offsetFormatted = `${offset >= 0 ? '+' : '-'}${Math.abs(offset)}`;
35
+ let label = `(GMT${offsetFormatted}) ${zoneName.replace('_', ' ')}`;
36
+
37
+ if (this.props.includeAbbreviations) {
38
+ const abbreviation = format(compareDate, 'zzz', {
39
+ timeZone: zoneName
40
+ });
41
+
42
+ if (abbreviation) {
43
+ label += ` - ${abbreviation}`;
44
+ }
45
+ }
46
+
47
+ timezones.push({
48
+ id: zoneName,
49
+ label,
50
+ offset
51
+ });
52
+ } catch (error) {
53
+ // Ignores timezones that are not available within a user's browser/operating system
54
+ console.error(`failed to format zone name ${zoneName}`);
55
+ }
56
+ } // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
43
57
 
44
- return option;
45
- }) // Formats 'noisy' timezones without a letter acronym.
46
- .map(option => {
47
- const rgx = /(\s-\s(\+|-)\d\d\d?\d?)$/;
48
- const matches = option.label.match(rgx);
49
58
 
50
- if (matches) {
51
- const prefix = matches[0];
52
- option.label = option.label.split(prefix)[0];
53
- }
59
+ return timezones.sort((a, b) => {
60
+ const offsetDelta = b.offset - a.offset;
61
+ if (offsetDelta !== 0) return offsetDelta;
62
+
63
+ if (typeof a.label === 'string' && typeof b.label === 'string') {
64
+ if (a.label < b.label) return -1;
65
+ if (a.label > b.label) return 1;
66
+ }
54
67
 
55
- return option;
56
- }) // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
57
- .sort((a, b) => {
58
- const offsetDelta = b.offset - a.offset;
59
- if (offsetDelta !== 0) return offsetDelta;
60
- if (a.label < b.label) return -1;
61
- if (a.label > b.label) return 1;
62
- return 0;
63
- }));
68
+ return 0;
69
+ });
70
+ });
64
71
  }
65
72
 
66
73
  componentDidMount() {
@@ -116,9 +123,19 @@ class TimezonePicker extends React.Component {
116
123
  selectProps.overrides); // $FlowFixMe
117
124
 
118
125
  selectProps.overrides = selectOverrides;
126
+ let options = this.state.timezones;
127
+
128
+ if (this.props.mapLabels) {
129
+ options = options.map(option => {
130
+ // $FlowFixMe - TimezoneT.label is a string, but mapLabels can return a React.Node
131
+ option.label = this.props.mapLabels(option);
132
+ return option;
133
+ });
134
+ }
135
+
119
136
  return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => /*#__PURE__*/React.createElement(OverriddenSelect, _extends({
120
137
  "aria-label": locale.datepicker.timezonePickerAriaLabel,
121
- options: this.state.timezones,
138
+ options: options,
122
139
  clearable: false,
123
140
  disabled: this.props.disabled,
124
141
  error: this.props.error,
@@ -0,0 +1,2 @@
1
+ /* eslint-disable header/header */
2
+ export const zones = ['Europe/Andorra', 'Asia/Dubai', 'Asia/Kabul', 'Europe/Tirane', 'Asia/Yerevan', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/Mawson', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/Troll', 'Antarctica/Vostok', 'America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Salta', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/San_Luis', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuaia', 'Pacific/Pago_Pago', 'Europe/Vienna', 'Australia/Lord_Howe', 'Antarctica/Macquarie', 'Australia/Hobart', 'Australia/Melbourne', 'Australia/Sydney', 'Australia/Broken_Hill', 'Australia/Brisbane', 'Australia/Lindeman', 'Australia/Adelaide', 'Australia/Darwin', 'Australia/Perth', 'Australia/Eucla', 'Asia/Baku', 'America/Barbados', 'Asia/Dhaka', 'Europe/Brussels', 'Europe/Sofia', 'Atlantic/Bermuda', 'Asia/Brunei', 'America/La_Paz', 'America/Noronha', 'America/Belem', 'America/Fortaleza', 'America/Recife', 'America/Araguaina', 'America/Maceio', 'America/Bahia', 'America/Sao_Paulo', 'America/Campo_Grande', 'America/Cuiaba', 'America/Santarem', 'America/Porto_Velho', 'America/Boa_Vista', 'America/Manaus', 'America/Eirunepe', 'America/Rio_Branco', 'Asia/Thimphu', 'Europe/Minsk', 'America/Belize', 'America/St_Johns', 'America/Halifax', 'America/Glace_Bay', 'America/Moncton', 'America/Goose_Bay', 'America/Toronto', 'America/Nipigon', 'America/Thunder_Bay', 'America/Iqaluit', 'America/Pangnirtung', 'America/Winnipeg', 'America/Rainy_River', 'America/Resolute', 'America/Rankin_Inlet', 'America/Regina', 'America/Swift_Current', 'America/Edmonton', 'America/Cambridge_Bay', 'America/Yellowknife', 'America/Inuvik', 'America/Dawson_Creek', 'America/Fort_Nelson', 'America/Whitehorse', 'America/Dawson', 'America/Vancouver', 'Indian/Cocos', 'Europe/Zurich', 'Africa/Abidjan', 'Pacific/Rarotonga', 'America/Santiago', 'America/Punta_Arenas', 'Pacific/Easter', 'Asia/Shanghai', 'Asia/Urumqi', 'America/Bogota', 'America/Costa_Rica', 'America/Havana', 'Atlantic/Cape_Verde', 'Indian/Christmas', 'Asia/Nicosia', 'Asia/Famagusta', 'Europe/Prague', 'Europe/Berlin', 'Europe/Copenhagen', 'America/Santo_Domingo', 'Africa/Algiers', 'America/Guayaquil', 'Pacific/Galapagos', 'Europe/Tallinn', 'Africa/Cairo', 'Africa/El_Aaiun', 'Europe/Madrid', 'Africa/Ceuta', 'Atlantic/Canary', 'Europe/Helsinki', 'Pacific/Fiji', 'Atlantic/Stanley', 'Pacific/Chuuk', 'Pacific/Pohnpei', 'Pacific/Kosrae', 'Atlantic/Faroe', 'Europe/Paris', 'Europe/London', 'Asia/Tbilisi', 'America/Cayenne', 'Europe/Gibraltar', 'America/Nuuk', 'America/Danmarkshavn', 'America/Scoresbysund', 'America/Thule', 'Europe/Athens', 'Atlantic/South_Georgia', 'America/Guatemala', 'Pacific/Guam', 'Africa/Bissau', 'America/Guyana', 'Asia/Hong_Kong', 'America/Tegucigalpa', 'America/Port-au-Prince', 'Europe/Budapest', 'Asia/Jakarta', 'Asia/Pontianak', 'Asia/Makassar', 'Asia/Jayapura', 'Europe/Dublin', 'Asia/Jerusalem', 'Asia/Kolkata', 'Indian/Chagos', 'Asia/Baghdad', 'Asia/Tehran', 'Atlantic/Reykjavik', 'Europe/Rome', 'America/Jamaica', 'Asia/Amman', 'Asia/Tokyo', 'Africa/Nairobi', 'Asia/Bishkek', 'Pacific/Tarawa', 'Pacific/Kanton', 'Pacific/Kiritimati', 'Asia/Pyongyang', 'Asia/Seoul', 'Asia/Almaty', 'Asia/Qyzylorda', 'Asia/Qostanay', 'Asia/Aqtobe', 'Asia/Aqtau', 'Asia/Atyrau', 'Asia/Oral', 'Asia/Beirut', 'Asia/Colombo', 'Africa/Monrovia', 'Europe/Vilnius', 'Europe/Luxembourg', 'Europe/Riga', 'Africa/Tripoli', 'Africa/Casablanca', 'Europe/Monaco', 'Europe/Chisinau', 'Pacific/Majuro', 'Pacific/Kwajalein', 'Asia/Yangon', 'Asia/Ulaanbaatar', 'Asia/Hovd', 'Asia/Choibalsan', 'Asia/Macau', 'America/Martinique', 'Europe/Malta', 'Indian/Mauritius', 'Indian/Maldives', 'America/Mexico_City', 'America/Cancun', 'America/Merida', 'America/Monterrey', 'America/Matamoros', 'America/Mazatlan', 'America/Chihuahua', 'America/Ojinaga', 'America/Hermosillo', 'America/Tijuana', 'America/Bahia_Banderas', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Africa/Maputo', 'Africa/Windhoek', 'Pacific/Noumea', 'Pacific/Norfolk', 'Africa/Lagos', 'America/Managua', 'Europe/Amsterdam', 'Europe/Oslo', 'Asia/Kathmandu', 'Pacific/Nauru', 'Pacific/Niue', 'Pacific/Auckland', 'Pacific/Chatham', 'America/Panama', 'America/Lima', 'Pacific/Tahiti', 'Pacific/Marquesas', 'Pacific/Gambier', 'Pacific/Port_Moresby', 'Pacific/Bougainville', 'Asia/Manila', 'Asia/Karachi', 'Europe/Warsaw', 'America/Miquelon', 'Pacific/Pitcairn', 'America/Puerto_Rico', 'Asia/Gaza', 'Asia/Hebron', 'Europe/Lisbon', 'Atlantic/Madeira', 'Atlantic/Azores', 'Pacific/Palau', 'America/Asuncion', 'Asia/Qatar', 'Indian/Reunion', 'Europe/Bucharest', 'Europe/Belgrade', 'Europe/Kaliningrad', 'Europe/Moscow', 'Europe/Simferopol', 'Europe/Kirov', 'Europe/Volgograd', 'Europe/Astrakhan', 'Europe/Saratov', 'Europe/Ulyanovsk', 'Europe/Samara', 'Asia/Yekaterinburg', 'Asia/Omsk', 'Asia/Novosibirsk', 'Asia/Barnaul', 'Asia/Tomsk', 'Asia/Novokuznetsk', 'Asia/Krasnoyarsk', 'Asia/Irkutsk', 'Asia/Chita', 'Asia/Yakutsk', 'Asia/Khandyga', 'Asia/Vladivostok', 'Asia/Ust-Nera', 'Asia/Magadan', 'Asia/Sakhalin', 'Asia/Srednekolymsk', 'Asia/Kamchatka', 'Asia/Anadyr', 'Asia/Riyadh', 'Pacific/Guadalcanal', 'Indian/Mahe', 'Africa/Khartoum', 'Europe/Stockholm', 'Asia/Singapore', 'America/Paramaribo', 'Africa/Juba', 'Africa/Sao_Tome', 'America/El_Salvador', 'Asia/Damascus', 'America/Grand_Turk', 'Africa/Ndjamena', 'Indian/Kerguelen', 'Asia/Bangkok', 'Asia/Dushanbe', 'Pacific/Fakaofo', 'Asia/Dili', 'Asia/Ashgabat', 'Africa/Tunis', 'Pacific/Tongatapu', 'Europe/Istanbul', 'Pacific/Funafuti', 'Asia/Taipei', 'Europe/Kiev', 'Europe/Uzhgorod', 'Europe/Zaporozhye', 'Pacific/Wake', 'America/New_York', 'America/Detroit', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Indiana/Indianapolis', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Vevay', 'America/Chicago', 'America/Indiana/Tell_City', 'America/Indiana/Knox', 'America/Menominee', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/North_Dakota/Beulah', 'America/Denver', 'America/Boise', 'America/Phoenix', 'America/Los_Angeles', 'America/Anchorage', 'America/Juneau', 'America/Sitka', 'America/Metlakatla', 'America/Yakutat', 'America/Nome', 'America/Adak', 'Pacific/Honolulu', 'America/Montevideo', 'Asia/Samarkand', 'Asia/Tashkent', 'America/Caracas', 'Asia/Ho_Chi_Minh', 'Pacific/Efate', 'Pacific/Wallis', 'Pacific/Apia', 'Africa/Johannesburg'];
@@ -0,0 +1,69 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /* eslint-env node */
9
+ const fs = require('fs');
10
+
11
+ const path = require('path');
12
+
13
+ const util = require('util');
14
+
15
+ const exec = util.promisify(require('child_process').exec); // Download tzdata and collect a list of timezones. Baseui previously used a library
16
+ // to do this, but it grew stale and unmaintained. This approach is straightforward
17
+ // enough to update whenever necessary, but future improvements could include building
18
+ // this data set before baseui is published so that the data is always fresh.
19
+
20
+ async function main() {
21
+ try {
22
+ const tmpDir = path.join(__dirname, 'tmp'); // $FlowFixMe - flow is not aware of recursive option
23
+
24
+ await fs.promises.rmdir(tmpDir, {
25
+ recursive: true
26
+ });
27
+ await fs.promises.mkdir(tmpDir);
28
+ const src = `https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz`;
29
+ await exec(`curl -L ${src} | gzip -dc | tar -xf - --directory ${tmpDir}`);
30
+ const zoneTabPath = path.join(tmpDir, 'zone1970.tab');
31
+ const content = await fs.promises.readFile(zoneTabPath, 'utf-8');
32
+ const lines = content.split('\n');
33
+ const zones = [];
34
+
35
+ for (const line of lines) {
36
+ if (line[0] === '#') {
37
+ continue;
38
+ }
39
+
40
+ const parts = line.split(/\s+/);
41
+
42
+ if (parts.length >= 3) {
43
+ zones.push(parts[2]);
44
+ }
45
+ }
46
+
47
+ const file = [];
48
+ file.push('/* eslint-disable header/header */');
49
+ file.push('// @flow');
50
+ file.push('');
51
+ file.push('export const zones = [');
52
+
53
+ for (const zone of zones) {
54
+ file.push(` '${zone}',`);
55
+ }
56
+
57
+ file.push('];');
58
+ const tzdataPath = path.join(__dirname, 'tzdata.js');
59
+ await fs.promises.writeFile(tzdataPath, file.join('\n')); // $FlowFixMe - flow is not aware of recursive option
60
+
61
+ await fs.promises.rmdir(tmpDir, {
62
+ recursive: true
63
+ });
64
+ } catch (error) {
65
+ console.error(error);
66
+ }
67
+ }
68
+
69
+ main();
@@ -84,11 +84,16 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
84
84
  size = _this$props.size,
85
85
  steps = _this$props.steps,
86
86
  successValue = _this$props.successValue,
87
+ minValue = _this$props.minValue,
88
+ maxValue = _this$props.maxValue,
87
89
  showLabel = _this$props.showLabel,
88
90
  infinite = _this$props.infinite,
89
91
  errorMessage = _this$props.errorMessage,
90
92
  forwardedRef = _this$props.forwardedRef,
91
- restProps = _objectWithoutProperties(_this$props, ["ariaLabel", "overrides", "getProgressLabel", "value", "size", "steps", "successValue", "showLabel", "infinite", "errorMessage", "forwardedRef"]);
93
+ restProps = _objectWithoutProperties(_this$props, ["ariaLabel", "overrides", "getProgressLabel", "value", "size", "steps", "successValue", "minValue", "maxValue", "showLabel", "infinite", "errorMessage", "forwardedRef"]); // fallback on successValue (and it's default) if maxValue is not set by user
94
+
95
+
96
+ var maximumValue = maxValue !== 100 ? maxValue : successValue;
92
97
 
93
98
  var _getOverrides = getOverrides(overrides.Root, StyledRoot),
94
99
  _getOverrides2 = _slicedToArray(_getOverrides, 2),
@@ -124,7 +129,9 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
124
129
  $infinite: infinite,
125
130
  $size: size,
126
131
  $steps: steps,
127
- $successValue: successValue,
132
+ $successValue: maximumValue,
133
+ $minValue: minValue,
134
+ $maxValue: maximumValue,
128
135
  $value: value
129
136
  };
130
137
 
@@ -149,10 +156,10 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
149
156
  ref: forwardedRef,
150
157
  "data-baseweb": "progress-bar",
151
158
  role: "progressbar",
152
- "aria-label": ariaLabel || getProgressLabel(value, successValue),
159
+ "aria-label": ariaLabel || getProgressLabel(value, maximumValue, minValue),
153
160
  "aria-valuenow": infinite ? null : value,
154
- "aria-valuemin": infinite ? null : 0,
155
- "aria-valuemax": infinite ? null : successValue,
161
+ "aria-valuemin": infinite ? null : minValue,
162
+ "aria-valuemax": infinite ? null : maximumValue,
156
163
  "aria-invalid": errorMessage ? true : null,
157
164
  "aria-errormessage": errorMessage
158
165
  }, restProps, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
@@ -160,7 +167,7 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
160
167
  $size: sharedProps.$size
161
168
  }, infiniteBarProps)), /*#__PURE__*/React.createElement(InfiniteBar, _extends({
162
169
  $size: sharedProps.$size
163
- }, infiniteBarProps))) : renderProgressBar()), showLabel && /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), getProgressLabel(value, successValue)))
170
+ }, infiniteBarProps))) : renderProgressBar()), showLabel && /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), getProgressLabel(value, maximumValue, minValue)))
164
171
  );
165
172
  }
166
173
  }]);
@@ -169,8 +176,8 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
169
176
  }(React.Component);
170
177
 
171
178
  _defineProperty(ProgressBar, "defaultProps", {
172
- getProgressLabel: function getProgressLabel(value, successValue) {
173
- return "".concat(Math.round(value / successValue * 100), "% Loaded");
179
+ getProgressLabel: function getProgressLabel(value, maxValue, minValue) {
180
+ return "".concat(Math.round((value - minValue) / (maxValue - minValue) * 100), "% Loaded");
174
181
  },
175
182
  infinite: false,
176
183
  overrides: {},
@@ -178,6 +185,8 @@ _defineProperty(ProgressBar, "defaultProps", {
178
185
  size: SIZE.medium,
179
186
  steps: 1,
180
187
  successValue: 100,
188
+ minValue: 0,
189
+ maxValue: 100,
181
190
  value: 0
182
191
  });
183
192
 
@@ -72,11 +72,16 @@ export var StyledBarProgress = styled('div', function (props) {
72
72
  $value = props.$value,
73
73
  $successValue = props.$successValue,
74
74
  $steps = props.$steps,
75
- $index = props.$index;
75
+ $index = props.$index,
76
+ $maxValue = props.$maxValue,
77
+ _props$$minValue = props.$minValue,
78
+ $minValue = _props$$minValue === void 0 ? 0 : _props$$minValue; // making sure this doesn't break existing use that use StyledBarProgress directly
79
+
80
+ var maxValue = $maxValue ? $maxValue : $successValue;
76
81
  var colors = $theme.colors,
77
82
  sizing = $theme.sizing,
78
83
  borders = $theme.borders;
79
- var width = "".concat(100 - $value / $successValue * 100, "%");
84
+ var width = "".concat(100 - ($value - $minValue) * 100 / (maxValue - $minValue), "%");
80
85
  var stepStates = {
81
86
  default: 'default',
82
87
  awaits: 'awaits',
@@ -86,8 +91,8 @@ export var StyledBarProgress = styled('div', function (props) {
86
91
  var stepState = stepStates.default;
87
92
 
88
93
  if ($steps > 1) {
89
- var stepValue = $successValue / $steps;
90
- var currentValue = $value / $successValue * 100;
94
+ var stepValue = (maxValue - $minValue) / $steps;
95
+ var currentValue = ($value - $minValue) / (maxValue - $minValue) * 100;
91
96
  var completedSteps = Math.floor(currentValue / stepValue);
92
97
 
93
98
  if ($index < completedSteps) {
@@ -6,14 +6,16 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
6
6
 
7
7
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
8
 
9
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
-
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
9
  function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
10
 
15
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
12
 
13
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
+
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
+
17
19
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
20
 
19
21
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -44,11 +46,11 @@ LICENSE file in the root directory of this source tree.
44
46
  */
45
47
  // global Intl
46
48
  import * as React from 'react';
47
- import { findTimeZone, getZonedTime, listTimeZones } from 'timezone-support/dist/index-1900-2050.js';
48
- import { formatZonedTime } from 'timezone-support/dist/parse-format.js';
49
+ import { format, getTimezoneOffset } from 'date-fns-tz';
49
50
  import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
50
51
  import { LocaleContext } from '../locale/index.js';
51
52
  import { Select } from '../select/index.js';
53
+ import { zones } from './tzdata.js';
52
54
 
53
55
  var TimezonePicker = /*#__PURE__*/function (_React$Component) {
54
56
  _inherits(TimezonePicker, _React$Component);
@@ -72,40 +74,56 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
72
74
  });
73
75
 
74
76
  _defineProperty(_assertThisInitialized(_this), "buildTimezones", function (compareDate) {
75
- return listTimeZones().map(function (zone) {
76
- var timezone = findTimeZone(zone);
77
- var zonedTime = getZonedTime(compareDate, timezone);
78
- var offsetTime = (zonedTime.zone.offset < 0 ? '+' : '-') + Math.abs(zonedTime.zone.offset / 60);
79
- var abbreviation = formatZonedTime(zonedTime, 'z');
80
- var formatted = "(GMT ".concat(offsetTime, ") ").concat(zone).concat(_this.props.includeAbbreviations ? " - ".concat(abbreviation) : '').replace('_', ' ');
81
- var option = {
82
- id: zone,
83
- label: formatted,
84
- offset: zonedTime.zone.offset
85
- };
86
-
87
- if (_this.props.mapLabels) {
88
- option.label = _this.props.mapLabels(option);
89
- }
77
+ var timezones = [];
90
78
 
91
- return option;
92
- }) // Formats 'noisy' timezones without a letter acronym.
93
- .map(function (option) {
94
- var rgx = /(\s-\s(\+|-)\d\d\d?\d?)$/;
95
- var matches = option.label.match(rgx);
79
+ var _iterator = _createForOfIteratorHelper(zones),
80
+ _step;
96
81
 
97
- if (matches) {
98
- var prefix = matches[0];
99
- option.label = option.label.split(prefix)[0];
100
- }
82
+ try {
83
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
84
+ var zoneName = _step.value;
85
+
86
+ try {
87
+ var offset = getTimezoneOffset(zoneName, compareDate) / 3600000;
88
+ var offsetFormatted = "".concat(offset >= 0 ? '+' : '-').concat(Math.abs(offset));
89
+ var label = "(GMT".concat(offsetFormatted, ") ").concat(zoneName.replace('_', ' '));
90
+
91
+ if (_this.props.includeAbbreviations) {
92
+ var abbreviation = format(compareDate, 'zzz', {
93
+ timeZone: zoneName
94
+ });
101
95
 
102
- return option;
103
- }) // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
104
- .sort(function (a, b) {
96
+ if (abbreviation) {
97
+ label += " - ".concat(abbreviation);
98
+ }
99
+ }
100
+
101
+ timezones.push({
102
+ id: zoneName,
103
+ label: label,
104
+ offset: offset
105
+ });
106
+ } catch (error) {
107
+ // Ignores timezones that are not available within a user's browser/operating system
108
+ console.error("failed to format zone name ".concat(zoneName));
109
+ }
110
+ } // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
111
+
112
+ } catch (err) {
113
+ _iterator.e(err);
114
+ } finally {
115
+ _iterator.f();
116
+ }
117
+
118
+ return timezones.sort(function (a, b) {
105
119
  var offsetDelta = b.offset - a.offset;
106
120
  if (offsetDelta !== 0) return offsetDelta;
107
- if (a.label < b.label) return -1;
108
- if (a.label > b.label) return 1;
121
+
122
+ if (typeof a.label === 'string' && typeof b.label === 'string') {
123
+ if (a.label < b.label) return -1;
124
+ if (a.label > b.label) return 1;
125
+ }
126
+
109
127
  return 0;
110
128
  });
111
129
  });
@@ -182,10 +200,20 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
182
200
  selectProps.overrides); // $FlowFixMe
183
201
 
184
202
  selectProps.overrides = selectOverrides;
203
+ var options = this.state.timezones;
204
+
205
+ if (this.props.mapLabels) {
206
+ options = options.map(function (option) {
207
+ // $FlowFixMe - TimezoneT.label is a string, but mapLabels can return a React.Node
208
+ option.label = _this3.props.mapLabels(option);
209
+ return option;
210
+ });
211
+ }
212
+
185
213
  return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, function (locale) {
186
214
  return /*#__PURE__*/React.createElement(OverriddenSelect, _extends({
187
215
  "aria-label": locale.datepicker.timezonePickerAriaLabel,
188
- options: _this3.state.timezones,
216
+ options: options,
189
217
  clearable: false,
190
218
  disabled: _this3.props.disabled,
191
219
  error: _this3.props.error,
@@ -0,0 +1,2 @@
1
+ /* eslint-disable header/header */
2
+ export var zones = ['Europe/Andorra', 'Asia/Dubai', 'Asia/Kabul', 'Europe/Tirane', 'Asia/Yerevan', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/Mawson', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/Troll', 'Antarctica/Vostok', 'America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Salta', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/San_Luis', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuaia', 'Pacific/Pago_Pago', 'Europe/Vienna', 'Australia/Lord_Howe', 'Antarctica/Macquarie', 'Australia/Hobart', 'Australia/Melbourne', 'Australia/Sydney', 'Australia/Broken_Hill', 'Australia/Brisbane', 'Australia/Lindeman', 'Australia/Adelaide', 'Australia/Darwin', 'Australia/Perth', 'Australia/Eucla', 'Asia/Baku', 'America/Barbados', 'Asia/Dhaka', 'Europe/Brussels', 'Europe/Sofia', 'Atlantic/Bermuda', 'Asia/Brunei', 'America/La_Paz', 'America/Noronha', 'America/Belem', 'America/Fortaleza', 'America/Recife', 'America/Araguaina', 'America/Maceio', 'America/Bahia', 'America/Sao_Paulo', 'America/Campo_Grande', 'America/Cuiaba', 'America/Santarem', 'America/Porto_Velho', 'America/Boa_Vista', 'America/Manaus', 'America/Eirunepe', 'America/Rio_Branco', 'Asia/Thimphu', 'Europe/Minsk', 'America/Belize', 'America/St_Johns', 'America/Halifax', 'America/Glace_Bay', 'America/Moncton', 'America/Goose_Bay', 'America/Toronto', 'America/Nipigon', 'America/Thunder_Bay', 'America/Iqaluit', 'America/Pangnirtung', 'America/Winnipeg', 'America/Rainy_River', 'America/Resolute', 'America/Rankin_Inlet', 'America/Regina', 'America/Swift_Current', 'America/Edmonton', 'America/Cambridge_Bay', 'America/Yellowknife', 'America/Inuvik', 'America/Dawson_Creek', 'America/Fort_Nelson', 'America/Whitehorse', 'America/Dawson', 'America/Vancouver', 'Indian/Cocos', 'Europe/Zurich', 'Africa/Abidjan', 'Pacific/Rarotonga', 'America/Santiago', 'America/Punta_Arenas', 'Pacific/Easter', 'Asia/Shanghai', 'Asia/Urumqi', 'America/Bogota', 'America/Costa_Rica', 'America/Havana', 'Atlantic/Cape_Verde', 'Indian/Christmas', 'Asia/Nicosia', 'Asia/Famagusta', 'Europe/Prague', 'Europe/Berlin', 'Europe/Copenhagen', 'America/Santo_Domingo', 'Africa/Algiers', 'America/Guayaquil', 'Pacific/Galapagos', 'Europe/Tallinn', 'Africa/Cairo', 'Africa/El_Aaiun', 'Europe/Madrid', 'Africa/Ceuta', 'Atlantic/Canary', 'Europe/Helsinki', 'Pacific/Fiji', 'Atlantic/Stanley', 'Pacific/Chuuk', 'Pacific/Pohnpei', 'Pacific/Kosrae', 'Atlantic/Faroe', 'Europe/Paris', 'Europe/London', 'Asia/Tbilisi', 'America/Cayenne', 'Europe/Gibraltar', 'America/Nuuk', 'America/Danmarkshavn', 'America/Scoresbysund', 'America/Thule', 'Europe/Athens', 'Atlantic/South_Georgia', 'America/Guatemala', 'Pacific/Guam', 'Africa/Bissau', 'America/Guyana', 'Asia/Hong_Kong', 'America/Tegucigalpa', 'America/Port-au-Prince', 'Europe/Budapest', 'Asia/Jakarta', 'Asia/Pontianak', 'Asia/Makassar', 'Asia/Jayapura', 'Europe/Dublin', 'Asia/Jerusalem', 'Asia/Kolkata', 'Indian/Chagos', 'Asia/Baghdad', 'Asia/Tehran', 'Atlantic/Reykjavik', 'Europe/Rome', 'America/Jamaica', 'Asia/Amman', 'Asia/Tokyo', 'Africa/Nairobi', 'Asia/Bishkek', 'Pacific/Tarawa', 'Pacific/Kanton', 'Pacific/Kiritimati', 'Asia/Pyongyang', 'Asia/Seoul', 'Asia/Almaty', 'Asia/Qyzylorda', 'Asia/Qostanay', 'Asia/Aqtobe', 'Asia/Aqtau', 'Asia/Atyrau', 'Asia/Oral', 'Asia/Beirut', 'Asia/Colombo', 'Africa/Monrovia', 'Europe/Vilnius', 'Europe/Luxembourg', 'Europe/Riga', 'Africa/Tripoli', 'Africa/Casablanca', 'Europe/Monaco', 'Europe/Chisinau', 'Pacific/Majuro', 'Pacific/Kwajalein', 'Asia/Yangon', 'Asia/Ulaanbaatar', 'Asia/Hovd', 'Asia/Choibalsan', 'Asia/Macau', 'America/Martinique', 'Europe/Malta', 'Indian/Mauritius', 'Indian/Maldives', 'America/Mexico_City', 'America/Cancun', 'America/Merida', 'America/Monterrey', 'America/Matamoros', 'America/Mazatlan', 'America/Chihuahua', 'America/Ojinaga', 'America/Hermosillo', 'America/Tijuana', 'America/Bahia_Banderas', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Africa/Maputo', 'Africa/Windhoek', 'Pacific/Noumea', 'Pacific/Norfolk', 'Africa/Lagos', 'America/Managua', 'Europe/Amsterdam', 'Europe/Oslo', 'Asia/Kathmandu', 'Pacific/Nauru', 'Pacific/Niue', 'Pacific/Auckland', 'Pacific/Chatham', 'America/Panama', 'America/Lima', 'Pacific/Tahiti', 'Pacific/Marquesas', 'Pacific/Gambier', 'Pacific/Port_Moresby', 'Pacific/Bougainville', 'Asia/Manila', 'Asia/Karachi', 'Europe/Warsaw', 'America/Miquelon', 'Pacific/Pitcairn', 'America/Puerto_Rico', 'Asia/Gaza', 'Asia/Hebron', 'Europe/Lisbon', 'Atlantic/Madeira', 'Atlantic/Azores', 'Pacific/Palau', 'America/Asuncion', 'Asia/Qatar', 'Indian/Reunion', 'Europe/Bucharest', 'Europe/Belgrade', 'Europe/Kaliningrad', 'Europe/Moscow', 'Europe/Simferopol', 'Europe/Kirov', 'Europe/Volgograd', 'Europe/Astrakhan', 'Europe/Saratov', 'Europe/Ulyanovsk', 'Europe/Samara', 'Asia/Yekaterinburg', 'Asia/Omsk', 'Asia/Novosibirsk', 'Asia/Barnaul', 'Asia/Tomsk', 'Asia/Novokuznetsk', 'Asia/Krasnoyarsk', 'Asia/Irkutsk', 'Asia/Chita', 'Asia/Yakutsk', 'Asia/Khandyga', 'Asia/Vladivostok', 'Asia/Ust-Nera', 'Asia/Magadan', 'Asia/Sakhalin', 'Asia/Srednekolymsk', 'Asia/Kamchatka', 'Asia/Anadyr', 'Asia/Riyadh', 'Pacific/Guadalcanal', 'Indian/Mahe', 'Africa/Khartoum', 'Europe/Stockholm', 'Asia/Singapore', 'America/Paramaribo', 'Africa/Juba', 'Africa/Sao_Tome', 'America/El_Salvador', 'Asia/Damascus', 'America/Grand_Turk', 'Africa/Ndjamena', 'Indian/Kerguelen', 'Asia/Bangkok', 'Asia/Dushanbe', 'Pacific/Fakaofo', 'Asia/Dili', 'Asia/Ashgabat', 'Africa/Tunis', 'Pacific/Tongatapu', 'Europe/Istanbul', 'Pacific/Funafuti', 'Asia/Taipei', 'Europe/Kiev', 'Europe/Uzhgorod', 'Europe/Zaporozhye', 'Pacific/Wake', 'America/New_York', 'America/Detroit', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Indiana/Indianapolis', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Vevay', 'America/Chicago', 'America/Indiana/Tell_City', 'America/Indiana/Knox', 'America/Menominee', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/North_Dakota/Beulah', 'America/Denver', 'America/Boise', 'America/Phoenix', 'America/Los_Angeles', 'America/Anchorage', 'America/Juneau', 'America/Sitka', 'America/Metlakatla', 'America/Yakutat', 'America/Nome', 'America/Adak', 'Pacific/Honolulu', 'America/Montevideo', 'Asia/Samarkand', 'Asia/Tashkent', 'America/Caracas', 'Asia/Ho_Chi_Minh', 'Pacific/Efate', 'Pacific/Wallis', 'Pacific/Apia', 'Africa/Johannesburg'];