react-timezone-select 3.0.0 → 3.0.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 +8 -6
- package/dist/index.cjs +3 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -2
- package/package.json +2 -2
- package/dist/index.html +0 -43
- package/dist/styles.css +0 -26
package/README.md
CHANGED
|
@@ -18,12 +18,11 @@ While looking around for a good option, I had trouble finding a timezone select
|
|
|
18
18
|
|
|
19
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
|
-
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
|
-
|
|
23
21
|
## 🏗️ Installing
|
|
24
22
|
|
|
25
23
|
```bash
|
|
26
|
-
|
|
24
|
+
// react-select is an optional peer dependency, unnecessary if using the hook
|
|
25
|
+
npm install react-timezone-select react-select
|
|
27
26
|
```
|
|
28
27
|
|
|
29
28
|
## 🔭 Usage
|
|
@@ -31,10 +30,10 @@ npm install react-select react-timezone-select
|
|
|
31
30
|
```jsx
|
|
32
31
|
import React, { useState } from 'react'
|
|
33
32
|
import ReactDOM from 'react-dom'
|
|
34
|
-
import TimezoneSelect from 'react-timezone-select'
|
|
33
|
+
import TimezoneSelect, { type ITimezone } from 'react-timezone-select'
|
|
35
34
|
|
|
36
35
|
const App = () => {
|
|
37
|
-
const [selectedTimezone, setSelectedTimezone] =useState(
|
|
36
|
+
const [selectedTimezone, setSelectedTimezone] = useState<ITimezone>(
|
|
38
37
|
Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
39
38
|
)
|
|
40
39
|
|
|
@@ -97,7 +96,10 @@ You can append custom choices of your own, or fully replace the listed timezone
|
|
|
97
96
|
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.
|
|
98
97
|
|
|
99
98
|
```jsx
|
|
100
|
-
import TimezoneSelect, { allTimezones } from 'react-timezone-select'
|
|
99
|
+
import TimezoneSelect, { type ITimezone, allTimezones } from 'react-timezone-select'
|
|
100
|
+
|
|
101
|
+
const [selectedTimezone, setSelectedTimezone] = useState<ITimezone>('Europe/Berlin')
|
|
102
|
+
|
|
101
103
|
<TimezoneSelect
|
|
102
104
|
value={selectedTimezone}
|
|
103
105
|
onChange={setSelectedTimezone}
|
package/dist/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ __export(src_exports, {
|
|
|
60
60
|
useTimezoneSelect: () => useTimezoneSelect
|
|
61
61
|
});
|
|
62
62
|
module.exports = __toCommonJS(src_exports);
|
|
63
|
-
var import_react =
|
|
63
|
+
var import_react = require("react");
|
|
64
64
|
var import_react_select = __toESM(require("react-select"), 1);
|
|
65
65
|
var import_spacetime = __toESM(require("spacetime"), 1);
|
|
66
66
|
var import_timezone_soft = __toESM(require("timezone-soft"), 1);
|
|
@@ -150,6 +150,7 @@ var allTimezones = {
|
|
|
150
150
|
var timezone_list_default = allTimezones;
|
|
151
151
|
|
|
152
152
|
// src/index.tsx
|
|
153
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
153
154
|
function useTimezoneSelect({
|
|
154
155
|
timezones = timezone_list_default,
|
|
155
156
|
labelStyle = "original",
|
|
@@ -264,7 +265,7 @@ var TimezoneSelect = (_a) => {
|
|
|
264
265
|
const handleChange = (tz) => {
|
|
265
266
|
onChange && onChange(tz);
|
|
266
267
|
};
|
|
267
|
-
return /* @__PURE__ */
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
268
269
|
import_react_select.default,
|
|
269
270
|
__spreadValues({
|
|
270
271
|
value: parseTimezone(value),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
|
|
2
2
|
import { Props as Props$1 } from 'react-select';
|
|
3
3
|
|
|
4
4
|
type ICustomTimezone = {
|
|
@@ -18,7 +18,6 @@ type TimezoneSelectOptions = {
|
|
|
18
18
|
labelStyle?: ILabelStyle;
|
|
19
19
|
displayValue?: IDisplayValue;
|
|
20
20
|
timezones?: ICustomTimezone;
|
|
21
|
-
maxAbbrLength?: number;
|
|
22
21
|
};
|
|
23
22
|
type Props = Omit<Props$1<ITimezone, false>, 'onChange'> & TimezoneSelectOptions & {
|
|
24
23
|
value: ITimezone;
|
|
@@ -31,6 +30,6 @@ declare function useTimezoneSelect({ timezones, labelStyle, displayValue, }: Tim
|
|
|
31
30
|
parseTimezone: (zone: ITimezone) => ITimezoneOption;
|
|
32
31
|
options: ITimezoneOption[];
|
|
33
32
|
};
|
|
34
|
-
declare const TimezoneSelect: ({ value, onBlur, onChange, labelStyle, displayValue, timezones, ...props }: Props) =>
|
|
33
|
+
declare const TimezoneSelect: ({ value, onBlur, onChange, labelStyle, displayValue, timezones, ...props }: Props) => react_jsx_runtime_js.JSX.Element;
|
|
35
34
|
|
|
36
35
|
export { ILabelStyle, ITimezone, ITimezoneOption, Props, TimezoneSelectOptions, allTimezones, TimezoneSelect as default, useTimezoneSelect };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __objRest = (source, exclude) => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// src/index.tsx
|
|
31
|
-
import
|
|
31
|
+
import { useMemo } from "react";
|
|
32
32
|
import Select from "react-select";
|
|
33
33
|
import spacetime from "spacetime";
|
|
34
34
|
import soft from "timezone-soft";
|
|
@@ -118,6 +118,7 @@ var allTimezones = {
|
|
|
118
118
|
var timezone_list_default = allTimezones;
|
|
119
119
|
|
|
120
120
|
// src/index.tsx
|
|
121
|
+
import { jsx } from "react/jsx-runtime";
|
|
121
122
|
function useTimezoneSelect({
|
|
122
123
|
timezones = timezone_list_default,
|
|
123
124
|
labelStyle = "original",
|
|
@@ -232,7 +233,7 @@ var TimezoneSelect = (_a) => {
|
|
|
232
233
|
const handleChange = (tz) => {
|
|
233
234
|
onChange && onChange(tz);
|
|
234
235
|
};
|
|
235
|
-
return /* @__PURE__ */
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
236
237
|
Select,
|
|
237
238
|
__spreadValues({
|
|
238
239
|
value: parseTimezone(value),
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-timezone-select",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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\"",
|
|
7
7
|
"prepublishOnly": "pnpm run build",
|
|
8
8
|
"postpublish": "pnpm run build:example && npm run deploy",
|
|
9
|
-
"build": "tsup src/index.tsx --format cjs,esm --dts",
|
|
9
|
+
"build": "tsup src/index.tsx --format cjs,esm --clean --dts",
|
|
10
10
|
"build:example": "cd example && pnpm run build",
|
|
11
11
|
"deploy": "gh-pages -d example/dist",
|
|
12
12
|
"pretest": "pnpm run build",
|
package/dist/index.html
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
7
|
-
<meta name="theme-color" content="#000000">
|
|
8
|
-
<!--
|
|
9
|
-
manifest.json provides metadata used when your web app is added to the
|
|
10
|
-
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
|
11
|
-
-->
|
|
12
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
|
13
|
-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
|
14
|
-
<!--
|
|
15
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
16
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
17
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
18
|
-
|
|
19
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
20
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
21
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
22
|
-
-->
|
|
23
|
-
<title>React App</title>
|
|
24
|
-
</head>
|
|
25
|
-
|
|
26
|
-
<body>
|
|
27
|
-
<noscript>
|
|
28
|
-
You need to enable JavaScript to run this app.
|
|
29
|
-
</noscript>
|
|
30
|
-
<div id="root"></div>
|
|
31
|
-
<!--
|
|
32
|
-
This HTML file is a template.
|
|
33
|
-
If you open it directly in the browser, you will see an empty page.
|
|
34
|
-
|
|
35
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
36
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
37
|
-
|
|
38
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
39
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
40
|
-
-->
|
|
41
|
-
</body>
|
|
42
|
-
|
|
43
|
-
</html>
|
package/dist/styles.css
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
* {
|
|
2
|
-
font-family: Helvetica;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.App {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.select-wrapper {
|
|
12
|
-
margin-top: 50px;
|
|
13
|
-
width: 500px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.code,
|
|
17
|
-
.code span {
|
|
18
|
-
background-color: #efefef;
|
|
19
|
-
font-family: monospace;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.code {
|
|
23
|
-
padding: 10px;
|
|
24
|
-
line-height: 2;
|
|
25
|
-
font-size: 1.4rem;
|
|
26
|
-
}
|