New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ewc-lib/ewc-dialog

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ewc-lib/ewc-dialog

![Screenshot](./screenshot.png)

  • 2.0.7-alpha
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-91.67%
Maintainers
0
Weekly downloads
 
Created
Source

Screenshot

Screenshot

API

There are the following setters:

  • visible - true to show modally, false to hide
  • title - sets the header text
  • bodyHtml - sets the body html
  • width - width of the dialog, preferrably in %. Default = 50%

And one optional attribute:

  • width - is reflected to property w/ same name.

All attribs and props support modification at runtime.

Usage with WebPack

package.json

"dependencies": {
  "@ewc-lib/ewc-dialog": "latest"
},

webpack.config.js

...
module: {
  rules: [
    {
      test: /\.css$/i,
      use: [
        'style-loader',
        'css-loader'
      ]
    }
  ]
}
...

index.html

<body>

  <script src="bundle.js"></script>

  <ewc-dialog></ewc-dialog>

  <script>
    document.addEventListener("DOMContentLoaded", function(event) {
      const el = document.getElementsByTagName("ewc-dialog")[0]
      el.title = "Information"
      el.bodyHtml = "<ul> <li>This</li> <li>That</li> </ul> And some more."
      el.visible = true
    })
  </script>

</body>

main.js

import "@ewc-lib/ewc-css/ewc.css"
import "@ewc-lib/ewc-dialog"

Focus trap

If bodyHtml contains elements which should be included in the focus trap - for example links - there's the possibility to set the focus trap's last element (to the last focusable element from the body html) - after which the first element (the close button) is focussed again, completing a cycle.

Example:

document.getElementById("infoModal").bodyHtml = `<a id="dialog_last_element" href="https://ec.europa.eu/eurostat" title="Link to Estat">Some Link Text</a>`
document.getElementById("infoModal").visible = true
document.getElementById("infoModal").focusTrap.setLastElement(document.getElementById("dialog_last_element") )

This way, the focus is still trapped within the dialog but also includes tab-focusable elements within the bodyHtml.

Note that setLastElement() is called after the visible setter.

FAQs

Package last updated on 12 Feb 2025

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