react-timezone-select 2.0.0 → 2.0.1

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/README.md CHANGED
@@ -23,7 +23,7 @@ We also have some **more examples** available on Codesandbox using this componen
23
23
  ## 🏗️ Installing
24
24
 
25
25
  ```bash
26
- npm install react-timezone-select
26
+ npm install react-select react-timezone-select
27
27
  ```
28
28
 
29
29
  ## 🔭 Usage
package/dist/index.cjs CHANGED
@@ -139,8 +139,12 @@ var TimezoneSelect = ({
139
139
  const tz = now.timezone();
140
140
  const tzStrings = (0, import_timezone_soft.default)(zone[0]);
141
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;
142
+ const standardAbbr = tzStrings?.[0]?.standard?.abbr ?? "";
143
+ const dstAbbr = tzStrings?.[0]?.daylight?.abbr ?? standardAbbr;
144
+ let abbr = now.isDST() ? dstAbbr : standardAbbr;
145
+ const standardAltName = tzStrings?.[0]?.standard?.name ?? "";
146
+ const dstAltName = tzStrings?.[0]?.daylight?.name ?? standardAltName;
147
+ let altName = now.isDST() ? dstAltName : standardAltName;
144
148
  const min = tz.current.offset * 60;
145
149
  const hr = `${min / 60 ^ 0}:` + (min % 60 === 0 ? "00" : Math.abs(min % 60));
146
150
  const prefix = `(GMT${hr.includes("-") ? hr : `+${hr}`}) ${zone[1]}`;
@@ -149,7 +153,7 @@ var TimezoneSelect = ({
149
153
  label = prefix;
150
154
  break;
151
155
  case "altName":
152
- label = `${prefix} ${altName?.length ? `(${altName})` : ""}`;
156
+ label = `${prefix} ${altName ? `(${altName})` : ""}`;
153
157
  break;
154
158
  case "abbrev":
155
159
  label = `${prefix} (${abbr.substring(0, maxAbbrLength)})`;
package/dist/index.js CHANGED
@@ -105,8 +105,12 @@ var TimezoneSelect = ({
105
105
  const tz = now.timezone();
106
106
  const tzStrings = soft(zone[0]);
107
107
  let label = "";
108
- let abbr = now.isDST() ? tzStrings[0].daylight.abbr : tzStrings[0].standard.abbr;
109
- let altName = now.isDST() ? tzStrings[0].daylight.name : tzStrings[0].standard.name;
108
+ const standardAbbr = tzStrings?.[0]?.standard?.abbr ?? "";
109
+ const dstAbbr = tzStrings?.[0]?.daylight?.abbr ?? standardAbbr;
110
+ let abbr = now.isDST() ? dstAbbr : standardAbbr;
111
+ const standardAltName = tzStrings?.[0]?.standard?.name ?? "";
112
+ const dstAltName = tzStrings?.[0]?.daylight?.name ?? standardAltName;
113
+ let altName = now.isDST() ? dstAltName : standardAltName;
110
114
  const min = tz.current.offset * 60;
111
115
  const hr = `${min / 60 ^ 0}:` + (min % 60 === 0 ? "00" : Math.abs(min % 60));
112
116
  const prefix = `(GMT${hr.includes("-") ? hr : `+${hr}`}) ${zone[1]}`;
@@ -115,7 +119,7 @@ var TimezoneSelect = ({
115
119
  label = prefix;
116
120
  break;
117
121
  case "altName":
118
- label = `${prefix} ${altName?.length ? `(${altName})` : ""}`;
122
+ label = `${prefix} ${altName ? `(${altName})` : ""}`;
119
123
  break;
120
124
  case "abbrev":
121
125
  label = `${prefix} (${abbr.substring(0, maxAbbrLength)})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-timezone-select",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Usable, dynamic React Timezone Select",
5
5
  "scripts": {
6
6
  "dev": "concurrently \"tsup src/index.tsx --format esm --watch\" \"cd example && pnpm dev\"",