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 🙏

© 2026 – Pkg Stats / Ryan Hefner

shadow-dom-survey

v1.0.1

Published

A complete survey system with builder and reader components, built with Shadow DOM

Readme

Shadow DOM Survey Components

A complete survey system with builder and reader components, built with Shadow DOM for encapsulation and isolation.

Features

  • 🔒 Fully Encapsulated: Uses Shadow DOM to prevent style leakage and conflicts
  • 🌐 Bilingual Support: Full RTL and Arabic/English language support
  • 🧩 Multiple Question Types: Support for single/multi-line text, single/multiple choice, dropdown, rating, and matrix questions
  • 📱 Responsive Design: Works on all screen sizes
  • 🔌 Easy Integration: Simple API for embedding in any website

Installation

Direct Include

<!-- Include Shadow DOM Survey Components -->
<script src="builder-embed/builder-embed.js"></script>
<script src="reader-embed/reader-embed.js"></script>

Usage

Survey Builder

// Initialize builder
const builderInstance = new SurveyBuilder("#surveyBuilder", {
  isEnglish: false, // Arabic by default
  onSave: async (data) => {
    // Handle the survey data
    console.log("Survey saved:", data);

    // Example: Store in localStorage
    localStorage.setItem("surveyData", JSON.stringify(data));

    return data;
  },
});

Survey Reader

// Initialize reader with saved survey data
const readerInstance = new SurveyReader("#surveyReader", {
  isEnglish: false, // Arabic by default
  loadSurvey: async () => {
    // Load survey data from a source
    const data = JSON.parse(localStorage.getItem("surveyData"));
    return data;
  },
  onSubmit: async (responses) => {
    // Handle the responses
    console.log("Survey submitted:", responses);

    // Example: Store in localStorage
    const savedResponses = JSON.parse(
      localStorage.getItem("surveyResponses") || "[]"
    );
    savedResponses.push(responses);
    localStorage.setItem("surveyResponses", JSON.stringify(savedResponses));

    return responses;
  },
});

API Reference

SurveyBuilder

Constructor Options

| Option | Type | Default | Description | | ---------------------- | -------- | ---------------------- | ----------------------------------------- | | isEnglish | Boolean | false | Set to true for English, false for Arabic | | onSave | Function | async (data) => data | Callback when survey is saved | | loadSurvey | Function | async () => null | Function to load existing survey data | | autosave | Boolean | false | Enable automatic saving of survey data | | notificationDuration | Number | 3000 | Duration of notifications in ms |

Methods

  • save(): Save the current survey data
  • reset(): Reset the builder to its initial state
  • destroy(): Clean up the component and remove event listeners

SurveyReader

Constructor Options

| Option | Type | Default | Description | | ---------------------- | -------- | ---------------------------------------- | ----------------------------------------- | | isEnglish | Boolean | true | Set to true for English, false for Arabic | | surveyData | Object | null | Survey data object | | loadSurvey | Function | async () => null | Function to load survey data | | onSubmit | Function | async (responses) => responses | Callback when survey is submitted | | completedTitle | String | "Thank you!" | Title shown after completion | | completedMessage | String | "Thank you for completing the survey!" | Message shown after completion | | submitButtonText | String | "Submit" | Text for the submit button | | requiredFieldMessage | String | "This question requires an answer" | Message for required fields | | animation | Boolean | true | Enable/disable animations |

Methods

  • destroy(): Clean up the component and remove event listeners

Question Types

The system supports the following question types:

  1. Single Line Text: For short text responses
  2. Multi-line Text: For longer text responses
  3. Single Choice (Radio): For selecting one option from multiple choices
  4. Multiple Choice (Checkbox): For selecting multiple options
  5. Dropdown: For selecting one option from a dropdown list
  6. Rating Scale: For numerical ratings
  7. Matrix Question: For grid-based questions with rows and columns

Browser Compatibility

The components are compatible with all modern browsers that support Shadow DOM:

  • Chrome 53+
  • Firefox 63+
  • Safari 10.1+
  • Edge 79+

Examples & Demos

Check out the docs/examples directory for working examples:

  1. basic-usage.html - A simple implementation with minimal configuration
  2. advanced-demo.html - A comprehensive demo with workflow steps, multilingual support, and response tracking

You can also visit our live demos to see the components in action.

License

MIT License - see the LICENSE file for details.

Author

MAJED AL-ANAZI
GitHub: https://github.com/SKoRSA