react-timezone-select 1.5.5 â 1.5.6
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 +27 -32
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ While looking around for a good option, I had trouble finding a timezone select
|
|
|
16
16
|
|
|
17
17
|
#### Demo: [ndom91.github.io/react-timezone-select](https://ndom91.github.io/react-timezone-select/)
|
|
18
18
|
|
|
19
|
-
> This demo is also available in the `./examples` directory. Simply run `
|
|
19
|
+
> This demo is also available in the `./examples` directory. Simply run `pnpm dev` in the root of the repository and the vite dev server will start, where you can then find the example app at [`localhost:3001`](http://localhost:3001).
|
|
20
20
|
|
|
21
21
|
We also have some **more examples** available on Codesandbox using this component with the datetime library `spacetime` ([example](https://codesandbox.io/s/react-timezone-select-usage-z37hf)) as well as with `moment` ([example](https://codesandbox.io/s/react-timezone-select-usage-moment-5n6vn)), as well as in Typescript using the new `Intl` browser API ([example](https://codesandbox.io/s/react-timezone-select-typescript-8lsv3?file=/src/App.tsx)) showing how one might use this component in a real application.
|
|
22
22
|
|
|
@@ -34,7 +34,9 @@ import ReactDOM from 'react-dom'
|
|
|
34
34
|
import TimezoneSelect from 'react-timezone-select'
|
|
35
35
|
|
|
36
36
|
const App = () => {
|
|
37
|
-
const [selectedTimezone, setSelectedTimezone] =
|
|
37
|
+
const [selectedTimezone, setSelectedTimezone] =useState(
|
|
38
|
+
Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
39
|
+
)
|
|
38
40
|
|
|
39
41
|
return (
|
|
40
42
|
<div className="App">
|
|
@@ -86,22 +88,7 @@ const [timezone, setTimezone] = useState(
|
|
|
86
88
|
)
|
|
87
89
|
```
|
|
88
90
|
|
|
89
|
-
Thanks [@ndrwksr](https://github.com/ndom91/react-timezone-select/issues/25)
|
|
90
|
-
|
|
91
|
-
### â Next.js Users
|
|
92
|
-
|
|
93
|
-
**Update**: Starting with `v1.3.0` you DO NOT need `next-transpile-modules` to use this library with Next.js anymore!
|
|
94
|
-
|
|
95
|
-
For now, Next.js isn't great about handling ESM packages. Until this gets fixed, there is a workaround for using this and other ESM packages via [`next-transpile-modules`](https://www.npmjs.com/package/next-transpile-modules).
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
// next.config.js
|
|
99
|
-
const withTM = require('next-transpile-modules')(['react-timezone-select'])
|
|
100
|
-
|
|
101
|
-
module.exports = withTM({
|
|
102
|
-
// ...further Next.js config
|
|
103
|
-
})
|
|
104
|
-
```
|
|
91
|
+
Thanks [@ndrwksr](https://github.com/ndom91/react-timezone-select/issues/25)
|
|
105
92
|
|
|
106
93
|
### đ Custom Timezones
|
|
107
94
|
|
|
@@ -111,7 +98,7 @@ The `timezones` prop takes a dictionary of timezones. Don't worry, we'll prepend
|
|
|
111
98
|
|
|
112
99
|
```jsx
|
|
113
100
|
import TimezoneSelect, { allTimezones } from 'react-timezone-select'
|
|
114
|
-
|
|
101
|
+
<TimezoneSelect
|
|
115
102
|
value={selectedTimezone}
|
|
116
103
|
onChange={setSelectedTimezone}
|
|
117
104
|
timezones={{
|
|
@@ -126,26 +113,34 @@ The above example will generate two additional choices in the select options, on
|
|
|
126
113
|
|
|
127
114
|
## đšī¸ Props
|
|
128
115
|
|
|
129
|
-
- `value` -
|
|
116
|
+
- `value` - `string | Object` - Initial/current Timezone.
|
|
117
|
+
```
|
|
118
|
+
'America/Juneau' | {
|
|
119
|
+
value: 'America/Juneau'
|
|
120
|
+
label: '(GMT-8:00) Alaska,
|
|
121
|
+
abbrev: 'AHST',
|
|
122
|
+
offset: -8,
|
|
123
|
+
altName: 'Alaskan Standard Time'
|
|
124
|
+
}
|
|
125
|
+
```
|
|
130
126
|
- `onBlur` - `() => void`
|
|
131
127
|
- `onChange` - `(timezone) => void`
|
|
132
|
-
- Example `timezone` parameter:
|
|
133
|
-
```
|
|
134
|
-
{
|
|
135
|
-
value: 'America/Juneau'
|
|
136
|
-
label: '(GMT-8:00) Alaska,
|
|
137
|
-
abbrev: 'AHST',
|
|
138
|
-
offset: -8,
|
|
139
|
-
altName: 'Alaskan Standard Time'
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
128
|
- `labelStyle` - `'original' | 'altName' | 'abbrev'`
|
|
143
|
-
- `timezones` -
|
|
129
|
+
- `timezones` - `Record<string,string>`
|
|
130
|
+
```
|
|
131
|
+
timezones={{
|
|
132
|
+
...allTimezones,
|
|
133
|
+
'America/Lima': 'Pittsburgh',
|
|
134
|
+
'Europe/Berlin': 'Frankfurt',
|
|
135
|
+
}}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- `maxAbbrLength` - `number` - Truncate `abbrev` labelStyles string to length
|
|
144
139
|
- Any other [`react-select`](https://github.com/jedwatson/react-select#props) props
|
|
145
140
|
|
|
146
141
|
## đ§ Contributing
|
|
147
142
|
|
|
148
|
-
Pull requests are always welcome! Please stick to
|
|
143
|
+
Pull requests are always welcome! Please stick to repo settings (prettier, eslint, etc.), and if adding new features, please consider adding test(s) and documentation where appropriate!
|
|
149
144
|
|
|
150
145
|
## đ Thanks
|
|
151
146
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-timezone-select",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "Usable, dynamic React Timezone Select",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"dev": "concurrently \"tsup src/index.tsx --format esm --watch\" \"cd example &&
|
|
6
|
+
"dev": "concurrently \"tsup src/index.tsx --format esm --watch\" \"cd example && pnpm dev\"",
|
|
7
7
|
"prepublishOnly": "pnpm run build",
|
|
8
8
|
"postpublish": "pnpm run build:example && npm run deploy",
|
|
9
9
|
"build": "tsup src/index.tsx --format cjs,esm --dts",
|