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

@statua/dialog

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@statua/dialog

Dialog component.

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@statua/dialog

Build Status BrowserStack Status

Dialog component.

Features:

  • Best accessibility practices baked in
  • Tab and focus lock on tabbable elements inside dialog
  • Handles usual UX considerations such as closing on Escape key and clicking on dialog backdrop
  • Flexible styling
  • Sets aria-hidden on all sibling and ancestor elements except for the currently active dialog which traps the virtual cursor inside the dialog

Try it now!

Install

npm install @statua/dialog --save

Usage

import dialog from '@statua/dialog';

const instance = dialog({
	content: `<p>Becky</p>`
});

instance.show();

API

dialog(options)

Returns: Object

Creates dialog instance. Dialog element will be appended to body element.

options

Type: Object

content

Type: string|Node
Required

Dialog content which can be:

  • HTML string
  • Instance of Node (DOM node, HTML comment, document fragment, …)
onCreate

Type: Function
Default: () => {}

Callback to run when dialog instance is created.

onDestroy

Type: Function
Default: () => {}

Callback to run when dialog instance is destroyed.

Useful when you want to perform operations such as moving dialog content to original location if dialog content was already existing DOM node.

onShow

Type: Function
Default: () => {}

Callback to run when dialog instance is shown.

onClose

Type: Function
Default: () => {}

Callback to run when dialog instance is closed.

htmlClassNamespace

Type: string
Default: ``

HTML class namespace in addition to default one (statua-Dialog).

Useful if you want to create additional styling/functionality selector hook.

explicitClose

Type: boolean
Default: false

Disable modal close on Escape key press or when modal backdrop is clicked.

instance.show()

Show dialog.

instance.close()

Close dialog.

instance.destroy()

Destroy dialog instance.

DOM API

Dialog instance can be controlled with certain DOM attributes.

[data-statua-dialog-action="close"]

Closes closest dialog instance when clicking on element.

Browser support

Tested in IE11+ and all modern browsers.

Test

For automated tests, run npm run test:automated (append :watch for watcher support).

License

MIT © Ivan Nikolić

Keywords

FAQs

Package last updated on 16 Mar 2020

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