react-timezone-select 1.2.3-experimental.9 → 1.3.2
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 +18 -18
- package/dist/{index.d.ts → cjs/dist/index.d.ts} +0 -0
- 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 +7 -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 +33 -14
- package/dist/index.js +0 -10075
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 `npm
|
|
19
|
+
> This demo is also available in the `./examples` directory. Simply run `npm run dev` in the root of the repository after installing everything in the examples subdirectory and snowpack dev will begin, where you can find the demo at [`localhost:8080`](http://localhost:8080).
|
|
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
|
|
|
@@ -29,9 +29,9 @@ npm install react-timezone-select
|
|
|
29
29
|
## 🔭 Usage
|
|
30
30
|
|
|
31
31
|
```jsx
|
|
32
|
-
import React, { useState } from
|
|
33
|
-
import ReactDOM from
|
|
34
|
-
import TimezoneSelect from
|
|
32
|
+
import React, { useState } from 'react'
|
|
33
|
+
import ReactDOM from 'react-dom'
|
|
34
|
+
import TimezoneSelect from 'react-timezone-select'
|
|
35
35
|
|
|
36
36
|
const App = () => {
|
|
37
37
|
const [selectedTimezone, setSelectedTimezone] = useState({})
|
|
@@ -49,18 +49,18 @@ const App = () => {
|
|
|
49
49
|
<h3>Output:</h3>
|
|
50
50
|
<div
|
|
51
51
|
style={{
|
|
52
|
-
backgroundColor:
|
|
53
|
-
padding:
|
|
54
|
-
margin:
|
|
55
|
-
borderRadius:
|
|
56
|
-
maxWidth:
|
|
52
|
+
backgroundColor: '#ccc',
|
|
53
|
+
padding: '20px',
|
|
54
|
+
margin: '20px auto',
|
|
55
|
+
borderRadius: '5px',
|
|
56
|
+
maxWidth: '600px',
|
|
57
57
|
}}
|
|
58
58
|
>
|
|
59
59
|
<pre
|
|
60
60
|
style={{
|
|
61
|
-
margin:
|
|
61
|
+
margin: '0 20px',
|
|
62
62
|
fontWeight: 500,
|
|
63
|
-
fontFamily:
|
|
63
|
+
fontFamily: 'monospace',
|
|
64
64
|
}}
|
|
65
65
|
>
|
|
66
66
|
{JSON.stringify(selectedTimezone, null, 2)}
|
|
@@ -70,7 +70,7 @@ const App = () => {
|
|
|
70
70
|
)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const rootElement = document.getElementById(
|
|
73
|
+
const rootElement = document.getElementById('root')
|
|
74
74
|
ReactDOM.render(<App />, rootElement)
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -90,19 +90,19 @@ Thanks [@ndrwksr](https://github.com/ndom91/react-timezone-select/issues/25)!
|
|
|
90
90
|
|
|
91
91
|
### ⚠ Next.js Users
|
|
92
92
|
|
|
93
|
+
**Update**: Starting with `v1.3.0` you DO NOT need `next-transpile-modules` to use this library with Next.js anymore!
|
|
94
|
+
|
|
93
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).
|
|
94
96
|
|
|
95
97
|
```js
|
|
96
98
|
// next.config.js
|
|
97
|
-
const withTM = require(
|
|
99
|
+
const withTM = require('next-transpile-modules')(['react-timezone-select'])
|
|
98
100
|
|
|
99
101
|
module.exports = withTM({
|
|
100
102
|
// ...further Next.js config
|
|
101
103
|
})
|
|
102
104
|
```
|
|
103
105
|
|
|
104
|
-
**Update**: Next.js 12 now supports ESM packages by default. If you have any problems with this package in a Next.js 12 project, please let me know!
|
|
105
|
-
|
|
106
106
|
### 🕒 Custom Timezones
|
|
107
107
|
|
|
108
108
|
You can append custom choices of your own, or fully replace the listed timezone options.
|
|
@@ -110,14 +110,14 @@ You can append custom choices of your own, or fully replace the listed timezone
|
|
|
110
110
|
The `timezones` prop takes a dictionary of timezones. Don't worry, we'll prepend the `(GMT...)` part, you just have to pass the city(s) or region(s) you want in your label.
|
|
111
111
|
|
|
112
112
|
```jsx
|
|
113
|
-
import TimezoneSelect, { allTimezones } from
|
|
113
|
+
import TimezoneSelect, { allTimezones } from 'react-timezone-select'
|
|
114
114
|
;<TimezoneSelect
|
|
115
115
|
value={selectedTimezone}
|
|
116
116
|
onChange={setSelectedTimezone}
|
|
117
117
|
timezones={{
|
|
118
118
|
...allTimezones,
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
'America/Lima': 'Pittsburgh',
|
|
120
|
+
'Europe/Berlin': 'Frankfurt',
|
|
121
121
|
}}
|
|
122
122
|
/>
|
|
123
123
|
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|