baseui 10.8.0 → 10.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/a11y.js +2 -2
- package/a11y/a11y.js.flow +3 -3
- package/button/styled-components.js +47 -18
- package/button/styled-components.js.flow +25 -5
- package/combobox/combobox.js +6 -3
- package/combobox/combobox.js.flow +4 -2
- package/combobox/types.js.flow +2 -0
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +2 -2
- package/data-table/column-numerical.js +307 -355
- package/data-table/column-numerical.js.flow +273 -287
- package/data-table/constants.js +17 -11
- package/data-table/constants.js.flow +11 -8
- package/data-table/data-table.js +53 -50
- package/data-table/data-table.js.flow +18 -13
- package/data-table/filter-shell.js +27 -4
- package/data-table/filter-shell.js.flow +33 -9
- package/data-table/locale.js +4 -2
- package/data-table/locale.js.flow +6 -2
- package/data-table/measure-column-widths.js +83 -121
- package/data-table/measure-column-widths.js.flow +87 -109
- package/datepicker/styled-components.js +1 -1
- package/datepicker/styled-components.js.flow +4 -1
- package/drawer/drawer.js +3 -1
- package/drawer/drawer.js.flow +7 -1
- package/es/a11y/a11y.js +2 -2
- package/es/button/styled-components.js +32 -2
- package/es/combobox/combobox.js +6 -3
- package/es/data-table/column-categorical.js +2 -2
- package/es/data-table/column-numerical.js +245 -317
- package/es/data-table/constants.js +12 -8
- package/es/data-table/data-table.js +18 -16
- package/es/data-table/filter-shell.js +26 -4
- package/es/data-table/locale.js +4 -2
- package/es/data-table/measure-column-widths.js +75 -86
- package/es/datepicker/styled-components.js +1 -1
- package/es/drawer/drawer.js +3 -1
- package/es/index.js +1 -1
- package/es/map-marker/badge-enhancer.js +61 -0
- package/es/map-marker/constants.js +146 -2
- package/es/map-marker/drag-shadow.js +32 -0
- package/es/map-marker/fixed-marker.js +54 -48
- package/es/map-marker/floating-marker.js +21 -12
- package/es/map-marker/index.js +1 -1
- package/es/map-marker/label-enhancer.js +39 -0
- package/es/map-marker/needle.js +26 -0
- package/es/map-marker/pin-head.js +42 -40
- package/es/map-marker/styled-components.js +177 -32
- package/es/map-marker/types.js +1 -1
- package/es/menu/maybe-child-menu.js +0 -2
- package/es/menu/nested-menus.js +49 -3
- package/es/menu/stateful-container.js +13 -12
- package/es/modal/modal.js +3 -1
- package/es/popover/popover.js +3 -1
- package/es/progress-bar/index.js +1 -1
- package/es/progress-bar/progressbar.js +25 -10
- package/es/progress-bar/styled-components.js +9 -5
- package/es/select/select-component.js +2 -10
- package/es/spinner/styled-components.js +34 -16
- package/es/table/filter.js +3 -1
- package/es/themes/dark-theme/color-component-tokens.js +4 -0
- package/es/themes/light-theme/color-component-tokens.js +4 -0
- package/es/timezonepicker/timezone-picker.js +53 -36
- package/es/timezonepicker/tzdata.js +2 -0
- package/es/timezonepicker/update-tzdata.js +69 -0
- package/esm/a11y/a11y.js +3 -3
- package/esm/button/styled-components.js +47 -18
- package/esm/combobox/combobox.js +6 -3
- package/esm/data-table/column-categorical.js +2 -2
- package/esm/data-table/column-numerical.js +304 -353
- package/esm/data-table/constants.js +12 -8
- package/esm/data-table/data-table.js +53 -50
- package/esm/data-table/filter-shell.js +26 -4
- package/esm/data-table/locale.js +4 -2
- package/esm/data-table/measure-column-widths.js +83 -121
- package/esm/datepicker/styled-components.js +1 -1
- package/esm/drawer/drawer.js +3 -1
- package/esm/index.js +1 -1
- package/esm/map-marker/badge-enhancer.js +79 -0
- package/esm/map-marker/constants.js +94 -4
- package/esm/map-marker/drag-shadow.js +53 -0
- package/esm/map-marker/fixed-marker.js +84 -80
- package/esm/map-marker/floating-marker.js +22 -13
- package/esm/map-marker/index.js +1 -1
- package/esm/map-marker/label-enhancer.js +60 -0
- package/esm/map-marker/needle.js +43 -0
- package/esm/map-marker/pin-head.js +77 -66
- package/esm/map-marker/styled-components.js +182 -51
- package/esm/map-marker/types.js +1 -1
- package/esm/menu/maybe-child-menu.js +0 -2
- package/esm/menu/nested-menus.js +66 -5
- package/esm/menu/stateful-container.js +15 -13
- package/esm/modal/modal.js +3 -1
- package/esm/popover/popover.js +3 -1
- package/esm/progress-bar/index.js +1 -1
- package/esm/progress-bar/progressbar.js +32 -10
- package/esm/progress-bar/styled-components.js +9 -4
- package/esm/select/select-component.js +2 -11
- package/esm/spinner/styled-components.js +35 -16
- package/esm/table/filter.js +3 -1
- package/esm/themes/dark-theme/color-component-tokens.js +4 -0
- package/esm/themes/light-theme/color-component-tokens.js +4 -0
- package/esm/timezonepicker/timezone-picker.js +64 -36
- package/esm/timezonepicker/tzdata.js +2 -0
- package/esm/timezonepicker/update-tzdata.js +160 -0
- package/index.js +6 -0
- package/index.js.flow +1 -1
- package/map-marker/badge-enhancer.js +90 -0
- package/map-marker/badge-enhancer.js.flow +86 -0
- package/map-marker/constants.js +103 -5
- package/map-marker/constants.js.flow +152 -0
- package/map-marker/drag-shadow.js +64 -0
- package/map-marker/drag-shadow.js.flow +52 -0
- package/map-marker/fixed-marker.js +84 -78
- package/map-marker/fixed-marker.js.flow +78 -66
- package/map-marker/floating-marker.js +22 -13
- package/map-marker/floating-marker.js.flow +30 -17
- package/map-marker/index.d.ts +125 -24
- package/map-marker/index.js +18 -0
- package/map-marker/index.js.flow +3 -0
- package/map-marker/label-enhancer.js +71 -0
- package/map-marker/label-enhancer.js.flow +63 -0
- package/map-marker/needle.js +54 -0
- package/map-marker/needle.js.flow +29 -0
- package/map-marker/pin-head.js +80 -69
- package/map-marker/pin-head.js.flow +122 -84
- package/map-marker/styled-components.js +200 -62
- package/map-marker/styled-components.js.flow +172 -22
- package/map-marker/types.js.flow +69 -20
- package/menu/index.d.ts +9 -4
- package/menu/maybe-child-menu.js +0 -2
- package/menu/maybe-child-menu.js.flow +0 -2
- package/menu/nested-menus.js +66 -5
- package/menu/nested-menus.js.flow +50 -5
- package/menu/stateful-container.js +15 -13
- package/menu/stateful-container.js.flow +19 -13
- package/menu/types.js.flow +7 -1
- package/modal/modal.js +3 -1
- package/modal/modal.js.flow +2 -0
- package/package.json +5 -4
- package/popover/popover.js +3 -1
- package/popover/popover.js.flow +2 -0
- package/progress-bar/index.d.ts +2 -0
- package/progress-bar/index.js +6 -0
- package/progress-bar/index.js.flow +1 -0
- package/progress-bar/progressbar.js +32 -10
- package/progress-bar/progressbar.js.flow +35 -9
- package/progress-bar/styled-components.js +9 -4
- package/progress-bar/styled-components.js.flow +15 -4
- package/progress-bar/types.js.flow +12 -2
- package/select/select-component.js +2 -11
- package/select/select-component.js.flow +5 -7
- package/spinner/styled-components.js +35 -16
- package/spinner/styled-components.js.flow +37 -19
- package/spinner/types.js.flow +10 -0
- package/styles/index.js.flow +1 -1
- package/table/filter.js +3 -1
- package/table/filter.js.flow +5 -1
- package/themes/dark-theme/color-component-tokens.js +4 -0
- package/themes/dark-theme/color-component-tokens.js.flow +4 -0
- package/themes/light-theme/color-component-tokens.js +4 -0
- package/themes/light-theme/color-component-tokens.js.flow +4 -0
- package/themes/types.js.flow +4 -0
- package/timezonepicker/timezone-picker.js +69 -41
- package/timezonepicker/timezone-picker.js.flow +52 -46
- package/timezonepicker/types.js.flow +1 -1
- package/timezonepicker/tzdata.js +10 -0
- package/timezonepicker/tzdata.js.flow +347 -0
- package/timezonepicker/update-tzdata.js +164 -0
- package/timezonepicker/update-tzdata.js.flow +70 -0
|
@@ -48,6 +48,8 @@ var _default = function _default() {
|
|
|
48
48
|
buttonTertiaryActive: themePrimitives.primary100,
|
|
49
49
|
buttonTertiarySelectedFill: themePrimitives.primary100,
|
|
50
50
|
buttonTertiarySelectedText: themePrimitives.primary,
|
|
51
|
+
buttonTertiaryDisabledActiveFill: themePrimitives.primary50,
|
|
52
|
+
buttonTertiaryDisabledActiveText: themePrimitives.mono600,
|
|
51
53
|
buttonTertiarySpinnerForeground: themePrimitives.accent,
|
|
52
54
|
buttonTertiarySpinnerBackground: themePrimitives.primary100,
|
|
53
55
|
buttonMinimalFill: 'transparent',
|
|
@@ -60,6 +62,8 @@ var _default = function _default() {
|
|
|
60
62
|
buttonMinimalSpinnerBackground: themePrimitives.primary100,
|
|
61
63
|
buttonDisabledFill: themePrimitives.mono200,
|
|
62
64
|
buttonDisabledText: themePrimitives.mono600,
|
|
65
|
+
buttonDisabledActiveFill: themePrimitives.mono700,
|
|
66
|
+
buttonDisabledActiveText: themePrimitives.mono100,
|
|
63
67
|
buttonDisabledSpinnerForeground: themePrimitives.mono600,
|
|
64
68
|
buttonDisabledSpinnerBackground: themePrimitives.mono400,
|
|
65
69
|
// Breadcrumbs
|
|
@@ -43,6 +43,8 @@ export default (
|
|
|
43
43
|
buttonTertiaryActive: themePrimitives.primary100,
|
|
44
44
|
buttonTertiarySelectedFill: themePrimitives.primary100,
|
|
45
45
|
buttonTertiarySelectedText: themePrimitives.primary,
|
|
46
|
+
buttonTertiaryDisabledActiveFill: themePrimitives.primary50,
|
|
47
|
+
buttonTertiaryDisabledActiveText: themePrimitives.mono600,
|
|
46
48
|
buttonTertiarySpinnerForeground: themePrimitives.accent,
|
|
47
49
|
buttonTertiarySpinnerBackground: themePrimitives.primary100,
|
|
48
50
|
|
|
@@ -57,6 +59,8 @@ export default (
|
|
|
57
59
|
|
|
58
60
|
buttonDisabledFill: themePrimitives.mono200,
|
|
59
61
|
buttonDisabledText: themePrimitives.mono600,
|
|
62
|
+
buttonDisabledActiveFill: themePrimitives.mono700,
|
|
63
|
+
buttonDisabledActiveText: themePrimitives.mono100,
|
|
60
64
|
buttonDisabledSpinnerForeground: themePrimitives.mono600,
|
|
61
65
|
buttonDisabledSpinnerBackground: themePrimitives.mono400,
|
|
62
66
|
|
package/themes/types.js.flow
CHANGED
|
@@ -198,6 +198,8 @@ export type ComponentColorTokensT = {|
|
|
|
198
198
|
buttonTertiaryActive: string,
|
|
199
199
|
buttonTertiarySelectedText: string,
|
|
200
200
|
buttonTertiarySelectedFill: string,
|
|
201
|
+
buttonTertiaryDisabledActiveFill: string,
|
|
202
|
+
buttonTertiaryDisabledActiveText: string,
|
|
201
203
|
buttonTertiarySpinnerForeground: string,
|
|
202
204
|
buttonTertiarySpinnerBackground: string,
|
|
203
205
|
buttonMinimalFill: string,
|
|
@@ -210,6 +212,8 @@ export type ComponentColorTokensT = {|
|
|
|
210
212
|
buttonMinimalSpinnerBackground: string,
|
|
211
213
|
buttonDisabledFill: string,
|
|
212
214
|
buttonDisabledText: string,
|
|
215
|
+
buttonDisabledActiveFill: string,
|
|
216
|
+
buttonDisabledActiveText: string,
|
|
213
217
|
buttonDisabledSpinnerForeground: string,
|
|
214
218
|
buttonDisabledSpinnerBackground: string,
|
|
215
219
|
|
|
@@ -9,15 +9,15 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _parseFormat = require("timezone-support/dist/parse-format.js");
|
|
12
|
+
var _dateFnsTz = require("date-fns-tz");
|
|
15
13
|
|
|
16
14
|
var _overrides = require("../helpers/overrides.js");
|
|
17
15
|
|
|
18
|
-
var
|
|
16
|
+
var _index = require("../locale/index.js");
|
|
17
|
+
|
|
18
|
+
var _index2 = require("../select/index.js");
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _tzdata = require("./tzdata.js");
|
|
21
21
|
|
|
22
22
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
23
23
|
|
|
@@ -29,14 +29,16 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
29
29
|
|
|
30
30
|
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."); }
|
|
31
31
|
|
|
32
|
-
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); }
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
36
32
|
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; }
|
|
37
33
|
|
|
38
34
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
35
|
|
|
36
|
+
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; } } }; }
|
|
37
|
+
|
|
38
|
+
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); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
40
42
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
43
|
|
|
42
44
|
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); } }
|
|
@@ -81,40 +83,56 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
_defineProperty(_assertThisInitialized(_this), "buildTimezones", function (compareDate) {
|
|
84
|
-
|
|
85
|
-
var timezone = (0, _index.findTimeZone)(zone);
|
|
86
|
-
var zonedTime = (0, _index.getZonedTime)(compareDate, timezone);
|
|
87
|
-
var offsetTime = (zonedTime.zone.offset < 0 ? '+' : '-') + Math.abs(zonedTime.zone.offset / 60);
|
|
88
|
-
var abbreviation = (0, _parseFormat.formatZonedTime)(zonedTime, 'z');
|
|
89
|
-
var formatted = "(GMT ".concat(offsetTime, ") ").concat(zone).concat(_this.props.includeAbbreviations ? " - ".concat(abbreviation) : '').replace('_', ' ');
|
|
90
|
-
var option = {
|
|
91
|
-
id: zone,
|
|
92
|
-
label: formatted,
|
|
93
|
-
offset: zonedTime.zone.offset
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
if (_this.props.mapLabels) {
|
|
97
|
-
option.label = _this.props.mapLabels(option);
|
|
98
|
-
}
|
|
86
|
+
var timezones = [];
|
|
99
87
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.map(function (option) {
|
|
103
|
-
var rgx = /(\s-\s(\+|-)\d\d\d?\d?)$/;
|
|
104
|
-
var matches = option.label.match(rgx);
|
|
88
|
+
var _iterator = _createForOfIteratorHelper(_tzdata.zones),
|
|
89
|
+
_step;
|
|
105
90
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var zoneName = _step.value;
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
var offset = (0, _dateFnsTz.getTimezoneOffset)(zoneName, compareDate) / 3600000;
|
|
97
|
+
var offsetFormatted = "".concat(offset >= 0 ? '+' : '-').concat(Math.abs(offset));
|
|
98
|
+
var label = "(GMT".concat(offsetFormatted, ") ").concat(zoneName.replace('_', ' '));
|
|
110
99
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
if (_this.props.includeAbbreviations) {
|
|
101
|
+
var abbreviation = (0, _dateFnsTz.format)(compareDate, 'zzz', {
|
|
102
|
+
timeZone: zoneName
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (abbreviation) {
|
|
106
|
+
label += " - ".concat(abbreviation);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
timezones.push({
|
|
111
|
+
id: zoneName,
|
|
112
|
+
label: label,
|
|
113
|
+
offset: offset
|
|
114
|
+
});
|
|
115
|
+
} catch (error) {
|
|
116
|
+
// Ignores timezones that are not available within a user's browser/operating system
|
|
117
|
+
console.error("failed to format zone name ".concat(zoneName));
|
|
118
|
+
}
|
|
119
|
+
} // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
|
|
120
|
+
|
|
121
|
+
} catch (err) {
|
|
122
|
+
_iterator.e(err);
|
|
123
|
+
} finally {
|
|
124
|
+
_iterator.f();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return timezones.sort(function (a, b) {
|
|
114
128
|
var offsetDelta = b.offset - a.offset;
|
|
115
129
|
if (offsetDelta !== 0) return offsetDelta;
|
|
116
|
-
|
|
117
|
-
if (a.label
|
|
130
|
+
|
|
131
|
+
if (typeof a.label === 'string' && typeof b.label === 'string') {
|
|
132
|
+
if (a.label < b.label) return -1;
|
|
133
|
+
if (a.label > b.label) return 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
118
136
|
return 0;
|
|
119
137
|
});
|
|
120
138
|
});
|
|
@@ -176,7 +194,7 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
176
194
|
var _this$props$overrides = this.props.overrides,
|
|
177
195
|
overrides = _this$props$overrides === void 0 ? {} : _this$props$overrides;
|
|
178
196
|
|
|
179
|
-
var _getOverrides = (0, _overrides.getOverrides)(overrides.Select,
|
|
197
|
+
var _getOverrides = (0, _overrides.getOverrides)(overrides.Select, _index2.Select),
|
|
180
198
|
_getOverrides2 = _slicedToArray(_getOverrides, 2),
|
|
181
199
|
OverriddenSelect = _getOverrides2[0],
|
|
182
200
|
selectProps = _getOverrides2[1];
|
|
@@ -191,10 +209,20 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
191
209
|
selectProps.overrides); // $FlowFixMe
|
|
192
210
|
|
|
193
211
|
selectProps.overrides = selectOverrides;
|
|
194
|
-
|
|
212
|
+
var options = this.state.timezones;
|
|
213
|
+
|
|
214
|
+
if (this.props.mapLabels) {
|
|
215
|
+
options = options.map(function (option) {
|
|
216
|
+
// $FlowFixMe - TimezoneT.label is a string, but mapLabels can return a React.Node
|
|
217
|
+
option.label = _this3.props.mapLabels(option);
|
|
218
|
+
return option;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return /*#__PURE__*/React.createElement(_index.LocaleContext.Consumer, null, function (locale) {
|
|
195
223
|
return /*#__PURE__*/React.createElement(OverriddenSelect, _extends({
|
|
196
224
|
"aria-label": locale.datepicker.timezonePickerAriaLabel,
|
|
197
|
-
options:
|
|
225
|
+
options: options,
|
|
198
226
|
clearable: false,
|
|
199
227
|
disabled: _this3.props.disabled,
|
|
200
228
|
error: _this3.props.error,
|
|
@@ -8,18 +8,18 @@ LICENSE file in the root directory of this source tree.
|
|
|
8
8
|
// @flow
|
|
9
9
|
|
|
10
10
|
import * as React from 'react';
|
|
11
|
-
import {
|
|
12
|
-
findTimeZone,
|
|
13
|
-
getZonedTime,
|
|
14
|
-
listTimeZones,
|
|
15
|
-
} from 'timezone-support/dist/index-1900-2050.js';
|
|
16
|
-
import {formatZonedTime} from 'timezone-support/dist/parse-format.js';
|
|
11
|
+
import {format, getTimezoneOffset} from 'date-fns-tz';
|
|
17
12
|
|
|
18
13
|
import {getOverrides, mergeOverrides} from '../helpers/overrides.js';
|
|
19
14
|
import {LocaleContext} from '../locale/index.js';
|
|
20
15
|
import {Select} from '../select/index.js';
|
|
21
16
|
|
|
22
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
TimezonePickerPropsT,
|
|
19
|
+
TimezonePickerStateT,
|
|
20
|
+
TimezoneT,
|
|
21
|
+
} from './types.js';
|
|
22
|
+
import {zones} from './tzdata.js';
|
|
23
23
|
|
|
24
24
|
class TimezonePicker extends React.Component<
|
|
25
25
|
TimezonePickerPropsT,
|
|
@@ -57,48 +57,45 @@ class TimezonePicker extends React.Component<
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
buildTimezones = (compareDate: Date) =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
id: zone,
|
|
75
|
-
label: formatted,
|
|
76
|
-
offset: zonedTime.zone.offset,
|
|
77
|
-
};
|
|
78
|
-
if (this.props.mapLabels) {
|
|
79
|
-
option.label = this.props.mapLabels(option);
|
|
80
|
-
}
|
|
81
|
-
return option;
|
|
82
|
-
})
|
|
83
|
-
// Formats 'noisy' timezones without a letter acronym.
|
|
84
|
-
.map(option => {
|
|
85
|
-
const rgx = /(\s-\s(\+|-)\d\d\d?\d?)$/;
|
|
86
|
-
const matches = option.label.match(rgx);
|
|
87
|
-
if (matches) {
|
|
88
|
-
const prefix = matches[0];
|
|
89
|
-
option.label = option.label.split(prefix)[0];
|
|
60
|
+
buildTimezones = (compareDate: Date): TimezoneT[] => {
|
|
61
|
+
const timezones: TimezoneT[] = [];
|
|
62
|
+
for (const zoneName of zones) {
|
|
63
|
+
try {
|
|
64
|
+
const offset = getTimezoneOffset(zoneName, compareDate) / 3_600_000;
|
|
65
|
+
|
|
66
|
+
const offsetFormatted = `${offset >= 0 ? '+' : '-'}${Math.abs(offset)}`;
|
|
67
|
+
let label = `(GMT${offsetFormatted}) ${zoneName.replace('_', ' ')}`;
|
|
68
|
+
|
|
69
|
+
if (this.props.includeAbbreviations) {
|
|
70
|
+
const abbreviation = format(compareDate, 'zzz', {timeZone: zoneName});
|
|
71
|
+
if (abbreviation) {
|
|
72
|
+
label += ` - ${abbreviation}`;
|
|
73
|
+
}
|
|
90
74
|
}
|
|
91
|
-
return option;
|
|
92
|
-
})
|
|
93
|
-
// Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
|
|
94
|
-
.sort((a, b) => {
|
|
95
|
-
const offsetDelta = b.offset - a.offset;
|
|
96
|
-
if (offsetDelta !== 0) return offsetDelta;
|
|
97
75
|
|
|
76
|
+
timezones.push({
|
|
77
|
+
id: zoneName,
|
|
78
|
+
label,
|
|
79
|
+
offset,
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
// Ignores timezones that are not available within a user's browser/operating system
|
|
83
|
+
console.error(`failed to format zone name ${zoneName}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
|
|
88
|
+
return timezones.sort((a, b) => {
|
|
89
|
+
const offsetDelta = b.offset - a.offset;
|
|
90
|
+
if (offsetDelta !== 0) return offsetDelta;
|
|
91
|
+
|
|
92
|
+
if (typeof a.label === 'string' && typeof b.label === 'string') {
|
|
98
93
|
if (a.label < b.label) return -1;
|
|
99
94
|
if (a.label > b.label) return 1;
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
}
|
|
96
|
+
return 0;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
102
99
|
|
|
103
100
|
render() {
|
|
104
101
|
const {overrides = {}} = this.props;
|
|
@@ -116,12 +113,21 @@ class TimezonePicker extends React.Component<
|
|
|
116
113
|
// $FlowFixMe
|
|
117
114
|
selectProps.overrides = selectOverrides;
|
|
118
115
|
|
|
116
|
+
let options = this.state.timezones;
|
|
117
|
+
if (this.props.mapLabels) {
|
|
118
|
+
options = options.map(option => {
|
|
119
|
+
// $FlowFixMe - TimezoneT.label is a string, but mapLabels can return a React.Node
|
|
120
|
+
option.label = this.props.mapLabels(option);
|
|
121
|
+
return option;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
return (
|
|
120
126
|
<LocaleContext.Consumer>
|
|
121
127
|
{locale => (
|
|
122
128
|
<OverriddenSelect
|
|
123
129
|
aria-label={locale.datepicker.timezonePickerAriaLabel}
|
|
124
|
-
options={
|
|
130
|
+
options={options}
|
|
125
131
|
clearable={false}
|
|
126
132
|
disabled={this.props.disabled}
|
|
127
133
|
error={this.props.error}
|
|
@@ -14,7 +14,7 @@ import type {SizeT} from '../input/types.js';
|
|
|
14
14
|
|
|
15
15
|
export type TimezonePickerStateT = {
|
|
16
16
|
/** List of timezones from the IANA database. */
|
|
17
|
-
timezones:
|
|
17
|
+
timezones: TimezoneT[],
|
|
18
18
|
/** Value provided to the select component. */
|
|
19
19
|
value: ?string,
|
|
20
20
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.zones = void 0;
|
|
7
|
+
|
|
8
|
+
/* eslint-disable header/header */
|
|
9
|
+
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'];
|
|
10
|
+
exports.zones = zones;
|