react-timezone-select 1.5.6 → 2.0.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/dist/index.cjs CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var src_exports = {};
31
31
  __export(src_exports, {
32
32
  allTimezones: () => timezone_list_default,
33
- default: () => src_default
33
+ default: () => TimezoneSelect
34
34
  });
35
35
  module.exports = __toCommonJS(src_exports);
36
36
  var React = __toESM(require("react"), 1);
@@ -128,14 +128,12 @@ var TimezoneSelect = ({
128
128
  onBlur,
129
129
  onChange,
130
130
  labelStyle = "original",
131
- timezones,
131
+ timezones = timezone_list_default,
132
132
  maxAbbrLength = 4,
133
133
  ...props
134
134
  }) => {
135
- if (!timezones)
136
- timezones = timezone_list_default;
137
- const getOptions = React.useMemo(() => {
138
- return Object.entries(timezones).reduce((selectOptions, zone) => {
135
+ const getOptions = React.useMemo(
136
+ () => Object.entries(timezones).reduce((selectOptions, zone) => {
139
137
  try {
140
138
  const now = import_spacetime.default.now(zone[0]);
141
139
  const tz = now.timezone();
@@ -170,8 +168,9 @@ var TimezoneSelect = ({
170
168
  } catch {
171
169
  return selectOptions;
172
170
  }
173
- }, []).sort((a, b) => a.offset - b.offset);
174
- }, [labelStyle, timezones]);
171
+ }, []).sort((a, b) => a.offset - b.offset),
172
+ [labelStyle, timezones]
173
+ );
175
174
  const handleChange = (tz) => {
176
175
  onChange && onChange(tz);
177
176
  };
@@ -227,7 +226,6 @@ var TimezoneSelect = ({
227
226
  }
228
227
  );
229
228
  };
230
- var src_default = TimezoneSelect;
231
229
  // Annotate the CommonJS export names for ESM import in node:
232
230
  0 && (module.exports = {
233
231
  allTimezones
package/dist/index.d.ts CHANGED
@@ -1,36 +1,27 @@
1
1
  import { Props as Props$1 } from 'react-select';
2
2
 
3
3
  declare type ICustomTimezone = {
4
- [key: string]: string
5
- }
6
- declare type ILabelStyle = 'original' | 'altName' | 'abbrev'
4
+ [key: string]: string;
5
+ };
6
+ declare type ILabelStyle = 'original' | 'altName' | 'abbrev';
7
7
  interface ITimezoneOption {
8
- value: string
9
- label: string
10
- offset: number
11
- abbrev?: string
12
- altName?: string
8
+ value: string;
9
+ label: string;
10
+ abbrev?: string;
11
+ altName?: string;
12
+ offset?: number;
13
13
  }
14
- declare type ITimezone = ITimezoneOption | string
15
- interface Props
16
- extends Omit<Props$1<ITimezone, false>, 'onChange'> {
17
- value: ITimezone
18
- labelStyle?: ILabelStyle
19
- onChange?: (timezone: ITimezoneOption) => void
20
- timezones?: ICustomTimezone
21
- maxAbbrLength?: number
14
+ declare type ITimezone = ITimezoneOption | string;
15
+ interface Props extends Omit<Props$1<ITimezone, false>, 'onChange'> {
16
+ value: ITimezone;
17
+ labelStyle?: ILabelStyle;
18
+ onChange?: (timezone: ITimezoneOption) => void;
19
+ timezones?: ICustomTimezone;
20
+ maxAbbrLength?: number;
22
21
  }
23
22
 
24
23
  declare const allTimezones: ICustomTimezone;
25
24
 
26
- declare const TimezoneSelect: ({
27
- value,
28
- onBlur,
29
- onChange,
30
- labelStyle,
31
- timezones,
32
- maxAbbrLength,
33
- ...props
34
- }: Props) => JSX.Element
25
+ declare const TimezoneSelect: ({ value, onBlur, onChange, labelStyle, timezones, maxAbbrLength, ...props }: Props) => JSX.Element;
35
26
 
36
27
  export { ILabelStyle, ITimezone, ITimezoneOption, Props, allTimezones, TimezoneSelect as default };
package/dist/index.js CHANGED
@@ -94,14 +94,12 @@ var TimezoneSelect = ({
94
94
  onBlur,
95
95
  onChange,
96
96
  labelStyle = "original",
97
- timezones,
97
+ timezones = timezone_list_default,
98
98
  maxAbbrLength = 4,
99
99
  ...props
100
100
  }) => {
101
- if (!timezones)
102
- timezones = timezone_list_default;
103
- const getOptions = React.useMemo(() => {
104
- return Object.entries(timezones).reduce((selectOptions, zone) => {
101
+ const getOptions = React.useMemo(
102
+ () => Object.entries(timezones).reduce((selectOptions, zone) => {
105
103
  try {
106
104
  const now = spacetime.now(zone[0]);
107
105
  const tz = now.timezone();
@@ -136,8 +134,9 @@ var TimezoneSelect = ({
136
134
  } catch {
137
135
  return selectOptions;
138
136
  }
139
- }, []).sort((a, b) => a.offset - b.offset);
140
- }, [labelStyle, timezones]);
137
+ }, []).sort((a, b) => a.offset - b.offset),
138
+ [labelStyle, timezones]
139
+ );
141
140
  const handleChange = (tz) => {
142
141
  onChange && onChange(tz);
143
142
  };
@@ -193,8 +192,7 @@ var TimezoneSelect = ({
193
192
  }
194
193
  );
195
194
  };
196
- var src_default = TimezoneSelect;
197
195
  export {
198
196
  timezone_list_default as allTimezones,
199
- src_default as default
197
+ TimezoneSelect as default
200
198
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-timezone-select",
3
- "version": "1.5.6",
3
+ "version": "2.0.0",
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\"",
@@ -48,10 +48,10 @@
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": "^18 || ^17.0.1 || ^16",
51
- "react-dom": "^18 || ^17.0.1 || ^16"
51
+ "react-dom": "^18 || ^17.0.1 || ^16",
52
+ "react-select": "^5.7.0"
52
53
  },
53
54
  "dependencies": {
54
- "react-select": "^5.7.0",
55
55
  "spacetime": "^7.4.1",
56
56
  "timezone-soft": "^1.4.1"
57
57
  },