Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-timezone-map-select

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-timezone-map-select

react component which lets you select a timezone on world map

  • 1.2.25
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-63.83%
Maintainers
1
Weekly downloads
 
Created
Source

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 nameTypeDefault ValueDescription
openbooleanfalseIf true, the modal dialog is shown.
onClose(newTZ:string) => voidundefinedCallback fired when the modal dialog is to be closed.
timezoneNamestring"America/Los_Angeles"Initial timezone name.
titlestring"Time Zone"Title string.
descriptionstring"Select a time zone in the list or click an area on the map."Description string.
buttonLabelOkstring"OK"Label on "ok" button.
buttonLabelCancelstring"Cancel"Label on "cancel" button.
SubstituteButtonOk((props: ButtonProps) => ReactElement) | string;@mui/material/ButtonReact component to be used as "ok" button.
SubstituteButtonCancel((props: ButtonProps) => ReactElement) | string;@mui/material/ButtonReact component to be used as "cancel" button.
isOkFirstButtonbooleanfalseIf 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

ParameterTypeDescription
offsetInMinutesnumberoffset 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

ParameterTypeDescription
timeZoneNamestringTime 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.

Keywords

FAQs

Package last updated on 30 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc