npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-timezone-map-select

v1.2.25

Published

react component which lets you select a timezone on world map

Downloads

336

Readme

react-timezone-map-select

pipeline status coverage report semantic-release

Features

This is a react component which lets you select a timezone on world map in a modal dialog.

  • Modal dialog is implemented using MUI (a.k.a. material UI) ver 5.x.
  • You can select a timezone from the list of country / city.
  • You can also select a country / city on the world map.
  • It is fully customizable to make it fit to your application's look and feel.
    • All text labels
    • Button design (you can specify your own react component)
    • Order of buttons. (Mac style: OK comes last. Windows style: OK comes first.)

modal dialog screenshot

Installation

react-timezone-map-select is available as an npm package.

To install and save in your package.json dependencies, run:

// with npm
npm install react-timezone-map-select

// with yarn
yarn add react-timezone-map-select

Usage

You can use TimeZoneSelectDialog in the same manner as modal dialog in MUI.

import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Container from '@mui/material/Container';
import React, { ReactElement } from 'react';
import { TimeZoneSelectDialog } from 'react-timezone-map-select';


function App(): ReactElement {
  /** Timezone name */
  const [timezoneName, setTimezoneName] = React.useState('America/Los_Angeles');

  /** Set true when you open TimeZoneSelectDialog. */
  const [open, setOpen] = React.useState(false);

  /** Called when you press "Open Dialog" button. */
  const handleOpen = React.useCallback(() => {
    setOpen(true);
  }, []);

  /** Called when TimeZoneSelectDialog is closed. */
  const handleClose = React.useCallback((newTimeZoneName: string) => {
    setTimezoneName(newTimeZoneName);
    setOpen(false);
  }, []);

  return (
    <Container>
      <Box>
        <p>Timezone = {timezoneName}</p>
      </Box>
      <Box>
        <Button onClick={handleOpen} variant="contained" >
          Open Dialog
        </Button>
      </Box>
      <TimeZoneSelectDialog
        open={open}
        timeZoneName={timezoneName}
        onClose={handleClose}
      />
    </Container>
  );
}

Examples

Simple demo

Customize demo

Properties and Functions

TimeZoneSelectDialog

| Property name | Type | Default Value | Description | |------------------------|--------------------------------------------------|---------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| | open | boolean | false | If true, the modal dialog is shown. | | onClose | (newTZ:string) => void | undefined | Callback fired when the modal dialog is to be closed. | | timezoneName | string | "America/Los_Angeles" | Initial timezone name. | | title | string | "Time Zone" | Title string. | | description | string | "Select a time zone in the list or click an area on the map." | Description string. | | buttonLabelOk | string | "OK" | Label on "ok" button. | | buttonLabelCancel | string | "Cancel" | Label on "cancel" button. | | SubstituteButtonOk | ((props: ButtonProps) => ReactElement) | string; | @mui/material/Button | React component to be used as "ok" button. | | SubstituteButtonCancel | ((props: ButtonProps) => ReactElement) | string; | @mui/material/Button | React component to be used as "cancel" button. | | isOkFirstButton | boolean | false | If true, "ok" button comes first (Windows style). Otherwise, "cancel" button comes first (Mac style). |

convertOffsetInMinutesToString

function convertOffsetInMinutesToString(offsetInMinutes: number): string

Convert time offset to user friendly string. e.g. -60 ==> "-01:00"

Parameters | Parameter | Type | Description | |------------|--------|----------------| | offsetInMinutes | number | offset from UTC in minutes. |

Return value

User friendly string e.g. "-01:00"

findTimeZone

function findTimeZone(timeZoneName: string): RawTimeZone | undefined

Find a time zone data in @vvo/tzdb.

Parameters

| Parameter | Type | Description | |------------|--------|----------------| | timeZoneName | string | Time zone name. Note it could be grouped in "group". |

Return value

Time zone data in @vvo/tzdb if found. undefined if not found.

License

react-timezone-map-select is available under the MIT License.