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

custom-elements-manifest-inheritance

v1.1.1

Published

A tool for mapping inherited content (including class members, attributes, CSS parts, CSS variables, slots, and events) from parent classes in the Custom Elements Manifest

Downloads

201

Readme

Custom Elements Manifest Inheritance

This package is designed to update the Custom Elements Manifest data about your components with all of the information (attributes, properties, methods, CSS custom properties, CSS parts, and events) from the components or classes they are being inherited from.

Usage

This package includes two ways to generate an updated Custom Elements Manifest:

  1. calling a function in your build pipeline
  2. as a plugin for the Custom Element Manifest Analyzer.

Install

npm i -D custom-elements-manifest-inheritance

Build Pipeline

import { updateCemInheritance } from "custom-elements-manifest-inheritance";
import manifest from "./path/to/custom-elements.json";

const options = {...};

updateCemInheritance(manifest, options);

CEM Analyzer

Set-up

Ensure the following steps have been taken in your component library prior to using this plugin:

Import

// custom-elements-manifest.config.js

import { cemInheritancePlugin } from "custom-elements-manifest-inheritance";

const options = {...};

export default {
  plugins: [
    cemInheritancePlugin(options)
  ],
};

Configuration

There are a number of configurations you can apply to customize the output for your components.

interface Options {
  /** Name of the updated CEM file - default is "custom-elements.json" */
  fileName?: string;
  /** Path to output directory */
  outdir?: string;
  /** Class names of any components you would like to exclude from inheritance */
  exclude?: string[];
  /** Aspects of your class that you would like to exclude from it and its children */
  omit?: Omit;
  /** Skip inheritance for an aspect of your components */
  ignore?: string[];
  /** External CEMs that your components extend */
  externalManifests?: any[];
  /** Hides logs produced by the plugin */
  hideLogs?: boolean;
  /** Prevents plugin from executing */
  skip?: boolean;
}

fileName and outdir

If you would like to add your updated Custom Elements Manifest to a specific location in your project, you can use the fileName and outdir setting for that. Otherwise, the updated manifest will be default location - ./custom-elements.json.

NOTE: If you are using the CEM Analyzer, you do not need to set these options. It will allow the analyzer to handle it based on your configuration.

exclude

If there are any classes you would like to exclude from inheritance, you can specify the class names here in a string array.

omit

If there are any parts of your parent classes you do not want to have inherited, you can specify them in the omit setting.

interface Omit {
  [key: string]: {
    cssProperties?: string[];
    cssParts?: string[];
    members?: string[];
    attributes?: string[];
    events?: string[];
    slots?: string[];
  };
}

This setting is an object where the class name is the key and any aspect of the inherited members can include a string array of the name of the feature to be excluded.

const options = {
  omit: {
    MyElement: {
      cssProperties: ["--my-css-property"],
      events: ["my-event", "my-other-event"],
    },
  },
};

ignore

Some CEM generators will already handle some aspects of the inheritance for you or you may want to exclude an aspect of the inheritance and manage it yourself. If that's the case, you can use the ignore setting to skip an area of inheritance.

const options = {
  ignore: ["attributes", "members"],
};

externalManifests

If your components are being extended from an existing library, you can import that library's manifest and add it to the externalManifests array. You can add as many manifest to this as you need. The external manifest's components will not be added to your manifest, but only update the information for your components.

import externalCEM from "path/to/external/custom-elements.json" assert { type: "json" };

const options = {
  externalManifests: [externalCEM],
};