react-timezone-select 1.2.1 → 1.2.3-experimental.11
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/dist/{index.d.ts → cjs/dist/index.d.ts} +0 -2
- package/dist/{timezone-list.d.ts → cjs/dist/timezone-list.d.ts} +0 -0
- package/dist/{types → cjs/dist/types}/globals.d.ts +0 -0
- package/dist/{types → cjs/dist/types}/timezone.d.ts +0 -0
- package/dist/cjs/index.js +10 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/dist/index.d.ts +5 -0
- package/dist/esm/dist/timezone-list.d.ts +3 -0
- package/dist/esm/dist/types/globals.d.ts +1 -0
- package/dist/esm/dist/types/timezone.d.ts +19 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +16 -20
- package/dist/index.cjs +0 -217
- package/dist/index.mjs +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-timezone-select",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3-experimental.11",
|
|
4
4
|
"description": "Usable, dynamic React Timezone Select",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "concurrently npm:start:example npm:build",
|
|
7
7
|
"start:example": "cd example && npm start",
|
|
8
8
|
"prepublish": "npm run build",
|
|
9
9
|
"postpublish": "npm run build:example && npm run deploy",
|
|
10
|
-
"
|
|
10
|
+
"build3": "tsc",
|
|
11
|
+
"build2": "node build.cjs",
|
|
12
|
+
"build": "rollup -c",
|
|
11
13
|
"build:example": "cd example && npm run build",
|
|
12
14
|
"deploy": "gh-pages -d example/build",
|
|
13
15
|
"test": "jest",
|
|
@@ -26,25 +28,12 @@
|
|
|
26
28
|
"url": "https://github.com/ndom91/react-timezone-select/issues"
|
|
27
29
|
},
|
|
28
30
|
"license": "MIT",
|
|
29
|
-
"keywords": [
|
|
30
|
-
|
|
31
|
-
"timezone",
|
|
32
|
-
"select",
|
|
33
|
-
"react-select"
|
|
34
|
-
],
|
|
35
|
-
"files": [
|
|
36
|
-
"dist/**/*"
|
|
37
|
-
],
|
|
31
|
+
"keywords": ["react", "timezone", "select", "react-select"],
|
|
32
|
+
"files": ["dist/**/*", "package.json"],
|
|
38
33
|
"type": "module",
|
|
39
|
-
"main": "./dist/index.
|
|
40
|
-
"module": "./dist/index.
|
|
41
|
-
"types": "./dist/index.d.
|
|
42
|
-
"exports": {
|
|
43
|
-
".": {
|
|
44
|
-
"import": "./dist/index.mjs",
|
|
45
|
-
"require": "./dist/index.cjs"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
34
|
+
"main": "./dist/cjs/index.js",
|
|
35
|
+
"module": "./dist/esm/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
48
37
|
"peerDependencies": {
|
|
49
38
|
"react": "^17.0.1 || ^16",
|
|
50
39
|
"react-dom": "^17.0.1 || ^16"
|
|
@@ -55,6 +44,9 @@
|
|
|
55
44
|
"timezone-soft": "^1.3.1"
|
|
56
45
|
},
|
|
57
46
|
"devDependencies": {
|
|
47
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
48
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
49
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
58
50
|
"@testing-library/jest-dom": "^5.16.1",
|
|
59
51
|
"@testing-library/react": "^12.1.2",
|
|
60
52
|
"@types/jest": "^27.4.0",
|
|
@@ -68,6 +60,10 @@
|
|
|
68
60
|
"pretty-quick": "^3.1.3",
|
|
69
61
|
"react": "^17",
|
|
70
62
|
"react-dom": "^17",
|
|
63
|
+
"rollup": "^2.67.0",
|
|
64
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
65
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
66
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
71
67
|
"simple-git-hooks": "^2.7.0",
|
|
72
68
|
"ts-jest": "^27.1.3",
|
|
73
69
|
"typescript": "^4.5.5"
|
package/dist/index.cjs
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
|
|
29
|
-
// src/index.tsx
|
|
30
|
-
var src_exports = {};
|
|
31
|
-
__export(src_exports, {
|
|
32
|
-
allTimezones: () => timezone_list_default,
|
|
33
|
-
default: () => src_default
|
|
34
|
-
});
|
|
35
|
-
var import_react = __toESM(require("react"), 1);
|
|
36
|
-
var import_react_select = __toESM(require("react-select"), 1);
|
|
37
|
-
var import_spacetime = __toESM(require("spacetime"), 1);
|
|
38
|
-
var import_timezone_soft = __toESM(require("timezone-soft"), 1);
|
|
39
|
-
|
|
40
|
-
// src/timezone-list.ts
|
|
41
|
-
var allTimezones = {
|
|
42
|
-
"Pacific/Midway": "Midway Island, Samoa",
|
|
43
|
-
"Pacific/Honolulu": "Hawaii",
|
|
44
|
-
"America/Juneau": "Alaska",
|
|
45
|
-
"America/Boise": "Mountain Time",
|
|
46
|
-
"America/Dawson": "Dawson, Yukon",
|
|
47
|
-
"America/Chihuahua": "Chihuahua, La Paz, Mazatlan",
|
|
48
|
-
"America/Phoenix": "Arizona",
|
|
49
|
-
"America/Chicago": "Central Time",
|
|
50
|
-
"America/Regina": "Saskatchewan",
|
|
51
|
-
"America/Mexico_City": "Guadalajara, Mexico City, Monterrey",
|
|
52
|
-
"America/Belize": "Central America",
|
|
53
|
-
"America/Detroit": "Eastern Time",
|
|
54
|
-
"America/Bogota": "Bogota, Lima, Quito",
|
|
55
|
-
"America/Caracas": "Caracas, La Paz",
|
|
56
|
-
"America/Santiago": "Santiago",
|
|
57
|
-
"America/St_Johns": "Newfoundland and Labrador",
|
|
58
|
-
"America/Sao_Paulo": "Brasilia",
|
|
59
|
-
"America/Tijuana": "Tijuana",
|
|
60
|
-
"America/Montevideo": "Montevideo",
|
|
61
|
-
"America/Argentina/Buenos_Aires": "Buenos Aires, Georgetown",
|
|
62
|
-
"America/Godthab": "Greenland",
|
|
63
|
-
"America/Los_Angeles": "Pacific Time",
|
|
64
|
-
"Atlantic/Azores": "Azores",
|
|
65
|
-
"Atlantic/Cape_Verde": "Cape Verde Islands",
|
|
66
|
-
GMT: "UTC",
|
|
67
|
-
"Europe/London": "Edinburgh, London",
|
|
68
|
-
"Europe/Dublin": "Dublin",
|
|
69
|
-
"Europe/Lisbon": "Lisbon",
|
|
70
|
-
"Africa/Casablanca": "Casablanca, Monrovia",
|
|
71
|
-
"Atlantic/Canary": "Canary Islands",
|
|
72
|
-
"Europe/Belgrade": "Belgrade, Bratislava, Budapest, Ljubljana, Prague",
|
|
73
|
-
"Europe/Sarajevo": "Sarajevo, Skopje, Warsaw, Zagreb",
|
|
74
|
-
"Europe/Brussels": "Brussels, Copenhagen, Madrid, Paris",
|
|
75
|
-
"Europe/Amsterdam": "Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
|
|
76
|
-
"Africa/Algiers": "West Central Africa",
|
|
77
|
-
"Europe/Bucharest": "Bucharest",
|
|
78
|
-
"Africa/Cairo": "Cairo",
|
|
79
|
-
"Europe/Helsinki": "Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius",
|
|
80
|
-
"Europe/Athens": "Athens, Minsk",
|
|
81
|
-
"Asia/Jerusalem": "Jerusalem",
|
|
82
|
-
"Africa/Harare": "Harare, Pretoria",
|
|
83
|
-
"Europe/Moscow": "Istanbul, Moscow, St. Petersburg, Volgograd",
|
|
84
|
-
"Asia/Kuwait": "Kuwait, Riyadh",
|
|
85
|
-
"Africa/Nairobi": "Nairobi",
|
|
86
|
-
"Asia/Baghdad": "Baghdad",
|
|
87
|
-
"Asia/Tehran": "Tehran",
|
|
88
|
-
"Asia/Dubai": "Abu Dhabi, Muscat",
|
|
89
|
-
"Asia/Baku": "Baku, Tbilisi, Yerevan",
|
|
90
|
-
"Asia/Kabul": "Kabul",
|
|
91
|
-
"Asia/Yekaterinburg": "Ekaterinburg",
|
|
92
|
-
"Asia/Karachi": "Islamabad, Karachi, Tashkent",
|
|
93
|
-
"Asia/Kolkata": "Chennai, Kolkata, Mumbai, New Delhi",
|
|
94
|
-
"Asia/Kathmandu": "Kathmandu",
|
|
95
|
-
"Asia/Dhaka": "Astana, Dhaka",
|
|
96
|
-
"Asia/Colombo": "Sri Jayawardenepura",
|
|
97
|
-
"Asia/Almaty": "Almaty, Novosibirsk",
|
|
98
|
-
"Asia/Rangoon": "Yangon Rangoon",
|
|
99
|
-
"Asia/Bangkok": "Bangkok, Hanoi, Jakarta",
|
|
100
|
-
"Asia/Krasnoyarsk": "Krasnoyarsk",
|
|
101
|
-
"Asia/Shanghai": "Beijing, Chongqing, Hong Kong SAR, Urumqi",
|
|
102
|
-
"Asia/Kuala_Lumpur": "Kuala Lumpur, Singapore",
|
|
103
|
-
"Asia/Taipei": "Taipei",
|
|
104
|
-
"Australia/Perth": "Perth",
|
|
105
|
-
"Asia/Irkutsk": "Irkutsk, Ulaanbaatar",
|
|
106
|
-
"Asia/Seoul": "Seoul",
|
|
107
|
-
"Asia/Tokyo": "Osaka, Sapporo, Tokyo",
|
|
108
|
-
"Asia/Yakutsk": "Yakutsk",
|
|
109
|
-
"Australia/Darwin": "Darwin",
|
|
110
|
-
"Australia/Adelaide": "Adelaide",
|
|
111
|
-
"Australia/Sydney": "Canberra, Melbourne, Sydney",
|
|
112
|
-
"Australia/Brisbane": "Brisbane",
|
|
113
|
-
"Australia/Hobart": "Hobart",
|
|
114
|
-
"Asia/Vladivostok": "Vladivostok",
|
|
115
|
-
"Pacific/Guam": "Guam, Port Moresby",
|
|
116
|
-
"Asia/Magadan": "Magadan, Solomon Islands, New Caledonia",
|
|
117
|
-
"Asia/Kamchatka": "Kamchatka, Marshall Islands",
|
|
118
|
-
"Pacific/Fiji": "Fiji Islands",
|
|
119
|
-
"Pacific/Auckland": "Auckland, Wellington",
|
|
120
|
-
"Pacific/Tongatapu": "Nuku'alofa"
|
|
121
|
-
};
|
|
122
|
-
var timezone_list_default = allTimezones;
|
|
123
|
-
|
|
124
|
-
// src/index.tsx
|
|
125
|
-
var TimezoneSelect = ({
|
|
126
|
-
value,
|
|
127
|
-
onBlur,
|
|
128
|
-
onChange,
|
|
129
|
-
labelStyle = "original",
|
|
130
|
-
timezones,
|
|
131
|
-
...props
|
|
132
|
-
}) => {
|
|
133
|
-
if (!timezones) {
|
|
134
|
-
timezones = timezone_list_default;
|
|
135
|
-
}
|
|
136
|
-
const getOptions = (0, import_react.useMemo)(() => {
|
|
137
|
-
return Object.entries(timezones).reduce((selectOptions, zone) => {
|
|
138
|
-
const now = import_spacetime.default.now(zone[0]);
|
|
139
|
-
const tz = now.timezone();
|
|
140
|
-
const tzStrings = (0, import_timezone_soft.default)(zone[0]);
|
|
141
|
-
let label = "";
|
|
142
|
-
let abbr = now.isDST() ? tzStrings[0].daylight?.abbr : tzStrings[0].standard?.abbr;
|
|
143
|
-
let altName = now.isDST() ? tzStrings[0].daylight?.name : tzStrings[0].standard?.name;
|
|
144
|
-
const min = tz.current.offset * 60;
|
|
145
|
-
const hr = `${min / 60 ^ 0}:` + (min % 60 === 0 ? "00" : Math.abs(min % 60));
|
|
146
|
-
const prefix = `(GMT${hr.includes("-") ? hr : `+${hr}`}) ${zone[1]}`;
|
|
147
|
-
switch (labelStyle) {
|
|
148
|
-
case "original":
|
|
149
|
-
label = prefix;
|
|
150
|
-
break;
|
|
151
|
-
case "altName":
|
|
152
|
-
label = `${prefix} ${altName?.length ? `(${altName})` : ""}`;
|
|
153
|
-
break;
|
|
154
|
-
case "abbrev":
|
|
155
|
-
label = `${prefix} ${abbr?.length < 5 ? `(${abbr})` : ""}`;
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
label = `${prefix}`;
|
|
159
|
-
}
|
|
160
|
-
selectOptions.push({
|
|
161
|
-
value: tz.name,
|
|
162
|
-
label,
|
|
163
|
-
offset: tz.current.offset,
|
|
164
|
-
abbrev: abbr,
|
|
165
|
-
altName
|
|
166
|
-
});
|
|
167
|
-
return selectOptions;
|
|
168
|
-
}, []).sort((a, b) => a.offset - b.offset);
|
|
169
|
-
}, [labelStyle, timezones]);
|
|
170
|
-
const handleChange = (tz) => {
|
|
171
|
-
onChange && onChange(tz);
|
|
172
|
-
};
|
|
173
|
-
const findFuzzyTz = (zone) => {
|
|
174
|
-
let currentTime = import_spacetime.default.now("GMT");
|
|
175
|
-
try {
|
|
176
|
-
currentTime = import_spacetime.default.now(zone);
|
|
177
|
-
} catch (err) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
return getOptions.filter((tz) => tz.offset === currentTime.timezone().current.offset).map((tz) => {
|
|
181
|
-
let score = 0;
|
|
182
|
-
if (currentTime.timezones[tz.value.toLowerCase()] && !!currentTime.timezones[tz.value.toLowerCase()].dst === currentTime.timezone().hasDst) {
|
|
183
|
-
if (tz.value.toLowerCase().indexOf(currentTime.tz.substring(currentTime.tz.indexOf("/") + 1)) !== -1) {
|
|
184
|
-
score += 8;
|
|
185
|
-
}
|
|
186
|
-
if (tz.label.toLowerCase().indexOf(currentTime.tz.substring(currentTime.tz.indexOf("/") + 1)) !== -1) {
|
|
187
|
-
score += 4;
|
|
188
|
-
}
|
|
189
|
-
if (tz.value.toLowerCase().indexOf(currentTime.tz.substring(0, currentTime.tz.indexOf("/")))) {
|
|
190
|
-
score += 2;
|
|
191
|
-
}
|
|
192
|
-
score += 1;
|
|
193
|
-
} else if (tz.value === "GMT") {
|
|
194
|
-
score += 1;
|
|
195
|
-
}
|
|
196
|
-
return { tz, score };
|
|
197
|
-
}).sort((a, b) => b.score - a.score).map(({ tz }) => tz)[0];
|
|
198
|
-
};
|
|
199
|
-
const parseTimezone = (zone) => {
|
|
200
|
-
if (typeof zone === "object" && zone.value && zone.label)
|
|
201
|
-
return zone;
|
|
202
|
-
if (typeof zone === "string") {
|
|
203
|
-
return getOptions.find((tz) => tz.value === zone) || zone.indexOf("/") !== -1 && findFuzzyTz(zone);
|
|
204
|
-
} else if (zone.value && !zone.label) {
|
|
205
|
-
return getOptions.find((tz) => tz.value === zone.value);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_select.default, {
|
|
209
|
-
value: parseTimezone(value),
|
|
210
|
-
onChange: handleChange,
|
|
211
|
-
options: getOptions,
|
|
212
|
-
onBlur,
|
|
213
|
-
...props
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
var src_default = TimezoneSelect;
|
|
217
|
-
module.exports = __toCommonJS(src_exports);
|
package/dist/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import w,{useMemo as S}from"react";import B from"react-select";import d from"spacetime";import M from"timezone-soft";var y={"Pacific/Midway":"Midway Island, Samoa","Pacific/Honolulu":"Hawaii","America/Juneau":"Alaska","America/Boise":"Mountain Time","America/Dawson":"Dawson, Yukon","America/Chihuahua":"Chihuahua, La Paz, Mazatlan","America/Phoenix":"Arizona","America/Chicago":"Central Time","America/Regina":"Saskatchewan","America/Mexico_City":"Guadalajara, Mexico City, Monterrey","America/Belize":"Central America","America/Detroit":"Eastern Time","America/Bogota":"Bogota, Lima, Quito","America/Caracas":"Caracas, La Paz","America/Santiago":"Santiago","America/St_Johns":"Newfoundland and Labrador","America/Sao_Paulo":"Brasilia","America/Tijuana":"Tijuana","America/Montevideo":"Montevideo","America/Argentina/Buenos_Aires":"Buenos Aires, Georgetown","America/Godthab":"Greenland","America/Los_Angeles":"Pacific Time","Atlantic/Azores":"Azores","Atlantic/Cape_Verde":"Cape Verde Islands",GMT:"UTC","Europe/London":"Edinburgh, London","Europe/Dublin":"Dublin","Europe/Lisbon":"Lisbon","Africa/Casablanca":"Casablanca, Monrovia","Atlantic/Canary":"Canary Islands","Europe/Belgrade":"Belgrade, Bratislava, Budapest, Ljubljana, Prague","Europe/Sarajevo":"Sarajevo, Skopje, Warsaw, Zagreb","Europe/Brussels":"Brussels, Copenhagen, Madrid, Paris","Europe/Amsterdam":"Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna","Africa/Algiers":"West Central Africa","Europe/Bucharest":"Bucharest","Africa/Cairo":"Cairo","Europe/Helsinki":"Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius","Europe/Athens":"Athens, Minsk","Asia/Jerusalem":"Jerusalem","Africa/Harare":"Harare, Pretoria","Europe/Moscow":"Istanbul, Moscow, St. Petersburg, Volgograd","Asia/Kuwait":"Kuwait, Riyadh","Africa/Nairobi":"Nairobi","Asia/Baghdad":"Baghdad","Asia/Tehran":"Tehran","Asia/Dubai":"Abu Dhabi, Muscat","Asia/Baku":"Baku, Tbilisi, Yerevan","Asia/Kabul":"Kabul","Asia/Yekaterinburg":"Ekaterinburg","Asia/Karachi":"Islamabad, Karachi, Tashkent","Asia/Kolkata":"Chennai, Kolkata, Mumbai, New Delhi","Asia/Kathmandu":"Kathmandu","Asia/Dhaka":"Astana, Dhaka","Asia/Colombo":"Sri Jayawardenepura","Asia/Almaty":"Almaty, Novosibirsk","Asia/Rangoon":"Yangon Rangoon","Asia/Bangkok":"Bangkok, Hanoi, Jakarta","Asia/Krasnoyarsk":"Krasnoyarsk","Asia/Shanghai":"Beijing, Chongqing, Hong Kong SAR, Urumqi","Asia/Kuala_Lumpur":"Kuala Lumpur, Singapore","Asia/Taipei":"Taipei","Australia/Perth":"Perth","Asia/Irkutsk":"Irkutsk, Ulaanbaatar","Asia/Seoul":"Seoul","Asia/Tokyo":"Osaka, Sapporo, Tokyo","Asia/Yakutsk":"Yakutsk","Australia/Darwin":"Darwin","Australia/Adelaide":"Adelaide","Australia/Sydney":"Canberra, Melbourne, Sydney","Australia/Brisbane":"Brisbane","Australia/Hobart":"Hobart","Asia/Vladivostok":"Vladivostok","Pacific/Guam":"Guam, Port Moresby","Asia/Magadan":"Magadan, Solomon Islands, New Caledonia","Asia/Kamchatka":"Kamchatka, Marshall Islands","Pacific/Fiji":"Fiji Islands","Pacific/Auckland":"Auckland, Wellington","Pacific/Tongatapu":"Nuku'alofa"},b=y;var I=({value:g,onBlur:h,onChange:f,labelStyle:p="original",timezones:n,...k})=>{n||(n=b);let t=S(()=>Object.entries(n).reduce((e,a)=>{let i=d.now(a[0]),r=i.timezone(),s=M(a[0]),o="",u=i.isDST()?s[0].daylight?.abbr:s[0].standard?.abbr,m=i.isDST()?s[0].daylight?.name:s[0].standard?.name,c=r.current.offset*60,A=`${c/60^0}:`+(c%60===0?"00":Math.abs(c%60)),l=`(GMT${A.includes("-")?A:`+${A}`}) ${a[1]}`;switch(p){case"original":o=l;break;case"altName":o=`${l} ${m?.length?`(${m})`:""}`;break;case"abbrev":o=`${l} ${u?.length<5?`(${u})`:""}`;break;default:o=`${l}`}return e.push({value:r.name,label:o,offset:r.current.offset,abbrev:u,altName:m}),e},[]).sort((e,a)=>e.offset-a.offset),[p,n]),T=e=>{f&&f(e)},C=e=>{let a=d.now("GMT");try{a=d.now(e)}catch{return}return t.filter(i=>i.offset===a.timezone().current.offset).map(i=>{let r=0;return a.timezones[i.value.toLowerCase()]&&!!a.timezones[i.value.toLowerCase()].dst===a.timezone().hasDst?(i.value.toLowerCase().indexOf(a.tz.substring(a.tz.indexOf("/")+1))!==-1&&(r+=8),i.label.toLowerCase().indexOf(a.tz.substring(a.tz.indexOf("/")+1))!==-1&&(r+=4),i.value.toLowerCase().indexOf(a.tz.substring(0,a.tz.indexOf("/")))&&(r+=2),r+=1):i.value==="GMT"&&(r+=1),{tz:i,score:r}}).sort((i,r)=>r.score-i.score).map(({tz:i})=>i)[0]};return w.createElement(B,{value:(e=>{if(typeof e=="object"&&e.value&&e.label)return e;if(typeof e=="string")return t.find(a=>a.value===e)||e.indexOf("/")!==-1&&C(e);if(e.value&&!e.label)return t.find(a=>a.value===e.value)})(g),onChange:T,options:t,onBlur:h,...k})},D=I;export{b as allTimezones,D as default};
|