├── .husky ├── .gitignore └── pre-commit ├── index.d.ts ├── index.js ├── .prettierrc ├── assets └── demo.gif ├── .prettierignore ├── plop-templates ├── component.styles.ts.hbs ├── component.definition.ts.hbs ├── component.docs.hbs ├── component.test.ts.hbs ├── component.ts.hbs └── component.stories.ts.hbs ├── src ├── components │ ├── css-parts │ │ ├── css-parts.styles.ts │ │ ├── css-parts.test.ts │ │ ├── css-parts.mdx │ │ ├── css-parts.stories.ts │ │ └── css-parts.ts │ ├── props │ │ ├── props.styles.ts │ │ ├── props.test.ts │ │ ├── props.mdx │ │ ├── props.stories.ts │ │ └── props.ts │ ├── slots │ │ ├── slots.styles.ts │ │ ├── slots.test.ts │ │ ├── slots.mdx │ │ ├── slots.stories.ts │ │ └── slots.ts │ ├── events │ │ ├── events.styles.ts │ │ ├── events.test.ts │ │ ├── events.mdx │ │ ├── events.stories.ts │ │ └── events.ts │ ├── methods │ │ ├── methods.styles.ts │ │ ├── methods.test.ts │ │ ├── methods.mdx │ │ ├── methods.stories.ts │ │ └── methods.ts │ ├── css-props │ │ ├── css-props.styles.ts │ │ ├── css-props.test.ts │ │ ├── css-props.mdx │ │ ├── css-props.stories.ts │ │ └── css-props.ts │ ├── css-states │ │ ├── css-states.styles.ts │ │ ├── css-states.test.ts │ │ ├── css-states.mdx │ │ ├── css-states.stories.ts │ │ └── css-states.ts │ ├── dox │ │ ├── dox.styles.ts │ │ ├── dox.test.ts │ │ ├── dox.mdx │ │ ├── dox.stories.ts │ │ └── dox.ts │ ├── imports │ │ ├── imports.test.ts │ │ ├── imports.mdx │ │ ├── imports.stories.ts │ │ ├── imports.styles.ts │ │ └── imports.ts │ └── base │ │ └── dox-base.ts ├── utils │ ├── markdown.ts │ ├── define.ts │ ├── deep-merge.ts │ └── cem-tools.ts ├── configs │ ├── index.ts │ ├── types.ts │ └── default-values.ts └── index.ts ├── .vscode └── extensions.json ├── .storybook ├── styles.css ├── main.ts ├── preview.ts ├── code-bubble-setup.js └── custom-elements.json ├── LICENSE ├── web-test-runner.config.js ├── CHANGELOG.md ├── eslint.config.js ├── plopfile.js ├── .gitignore ├── custom-elements-manifest.config.js ├── package.json ├── rollup.config.js ├── tsconfig.json ├── README.md └── custom-elements.json /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './dist/index.js'; 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | export * from './dist/index.js'; 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "arrowParens": "avoid" 4 | } 5 | -------------------------------------------------------------------------------- /assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/break-stuff/wc-dox/HEAD/assets/demo.gif -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | cdn 3 | dist 4 | eslint 5 | plop-templates 6 | public 7 | react 8 | types -------------------------------------------------------------------------------- /plop-templates/component.styles.ts.hbs: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | :host { 5 | } 6 | `; 7 | -------------------------------------------------------------------------------- /src/components/css-parts/css-parts.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-css-parts { 5 | 6 | } 7 | `; 8 | -------------------------------------------------------------------------------- /src/components/props/props.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-props { 5 | 6 | 7 | 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/components/slots/slots.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-slots { 5 | 6 | 7 | 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/components/events/events.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-events { 5 | 6 | 7 | 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/components/methods/methods.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-methods { 5 | 6 | 7 | 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/components/css-props/css-props.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-css-props { 5 | 6 | 7 | 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/components/css-states/css-states.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-css-states { 5 | 6 | 7 | 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /src/utils/markdown.ts: -------------------------------------------------------------------------------- 1 | import { marked } from 'marked'; 2 | 3 | export function markdownToHtml(markdown: string): string { 4 | return marked.parse(markdown) as string; 5 | } -------------------------------------------------------------------------------- /src/utils/define.ts: -------------------------------------------------------------------------------- 1 | export function define( 2 | tag: string, 3 | constructor: new () => T, 4 | ) { 5 | if (!customElements.get(tag)) { 6 | customElements.define(tag, constructor); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /plop-templates/component.definition.ts.hbs: -------------------------------------------------------------------------------- 1 | import { {{pascalCase tagName}} } from './{{kebabCase name}}.js'; 2 | 3 | export type * from './{{kebabCase name}}.js'; 4 | 5 | customElements.define('{{kebabCase tagName}}', {{pascalCase tagName}}); -------------------------------------------------------------------------------- /src/components/dox/dox.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | wc-dox { 5 | --wc-dox-content-gap: 2rem; 6 | 7 | display: flex; 8 | flex-direction: column; 9 | gap: var(--wc-dox-content-gap); 10 | 11 | 12 | } 13 | `; 14 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "bierner.lit-html", 4 | "dbaeumer.vscode-eslint", 5 | "esbenp.prettier-vscode", 6 | "streetsidesoftware.code-spell-checker", 7 | "unifiedjs.vscode-mdx", 8 | "yzhang.markdown-all-in-one" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.storybook/styles.css: -------------------------------------------------------------------------------- 1 | :not(:defined) { 2 | opacity: 0; 3 | } 4 | 5 | code-bubble { 6 | margin-bottom: 2rem; 7 | } 8 | 9 | code-bubble[code-bubble] pre[slot] { 10 | margin: 0; 11 | } 12 | 13 | code-bubble[code-bubble] pre button { 14 | display: none; 15 | } 16 | 17 | .docblock-source.sb-unstyled { 18 | margin: 0; 19 | border: 0; 20 | box-shadow: none; 21 | } 22 | -------------------------------------------------------------------------------- /src/components/dox/dox.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcDox } from './dox.js'; 4 | 5 | describe('MyWcDox', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/props/props.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcProps } from './props.js'; 4 | 5 | describe('WcProps', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/slots/slots.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcSlots } from './slots.js'; 4 | 5 | describe('WcSlots', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/events/events.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcEvents } from './events.js'; 4 | 5 | describe('WcEvents', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/imports/imports.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcImports } from './imports.js'; 4 | 5 | describe('WcImports', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/methods/methods.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcMethods } from './methods.js'; 4 | 5 | describe('WcMethods', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/css-parts/css-parts.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcCssParts } from './css-parts.js'; 4 | 5 | describe('WcCssParts', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/css-props/css-props.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcCssProps } from './css-props.js'; 4 | 5 | describe('WcCssProps', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/css-states/css-states.test.ts: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { WcCssStates } from './css-states.js'; 4 | 5 | describe('WcCssStates', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture(html``); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/dox/dox.mdx: -------------------------------------------------------------------------------- 1 | # Dox 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcDox } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /plop-templates/component.docs.hbs: -------------------------------------------------------------------------------- 1 | # {{dashToTitle name}} 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | <{{kebabCase tagName}}> 9 | ``` 10 | 11 | ```tsx 12 | import { {{pascalCase tagName}} } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | <{{pascalCase tagName}}> 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /src/components/props/props.mdx: -------------------------------------------------------------------------------- 1 | # Props 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcProps } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/components/slots/slots.mdx: -------------------------------------------------------------------------------- 1 | # Slots 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcSlots } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/components/events/events.mdx: -------------------------------------------------------------------------------- 1 | # Events 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcEvents } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /.storybook/main.ts: -------------------------------------------------------------------------------- 1 | import type { StorybookConfig } from '@storybook/web-components-vite'; 2 | 3 | const config: StorybookConfig = { 4 | stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], 5 | addons: [ 6 | '@storybook/addon-links', 7 | '@storybook/addon-essentials', 8 | '@storybook/addon-a11y', 9 | ], 10 | framework: { 11 | name: '@storybook/web-components-vite', 12 | options: {}, 13 | }, 14 | staticDirs: ['../public'], 15 | }; 16 | export default config; 17 | -------------------------------------------------------------------------------- /src/components/methods/methods.mdx: -------------------------------------------------------------------------------- 1 | # Methods 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcMethods } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/components/css-states/css-states.mdx: -------------------------------------------------------------------------------- 1 | # States 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcCssStates } from 'lit-starter-kit/react'; 13 | export default () => { 14 | return ( 15 | <> 16 | 17 | 18 | ); 19 | }; 20 | ``` 21 | 22 | 23 | -------------------------------------------------------------------------------- /plop-templates/component.test.ts.hbs: -------------------------------------------------------------------------------- 1 | import './index.js'; 2 | import { expect, fixture, html } from '@open-wc/testing'; 3 | import type { {{pascalCase tagName}} } from './{{kebabCase name}}.js'; 4 | 5 | describe('{{pascalCase tagName}}', () => { 6 | describe('accessibility', () => { 7 | it('default is accessible', async () => { 8 | const el = await fixture<{{pascalCase tagName}}>(html`<{{kebabCase tagName}}>`); 9 | await expect(el).to.be.accessible(); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/components/css-parts/css-parts.mdx: -------------------------------------------------------------------------------- 1 | # Css Parts 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcCssParts } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/components/css-props/css-props.mdx: -------------------------------------------------------------------------------- 1 | # CSS Custom Properties 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcCssProps } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /plop-templates/component.ts.hbs: -------------------------------------------------------------------------------- 1 | import { html, LitElement } from 'lit'; 2 | import { property } from 'lit/decorators.js'; 3 | import styles from './{{kebabCase name}}.styles.js'; 4 | 5 | /** 6 | * Add a description here 7 | * 8 | * @tag {{kebabCase tagName}} 9 | * @since 0.0.0 10 | * @status experimental 11 | * 12 | **/ 13 | export class {{pascalCase tagName}} extends LitElement { 14 | static override styles = styles; 15 | 16 | @property() 17 | heading = 'Hello, word!'; 18 | 19 | override render() { 20 | return html` 21 |

${this.heading}

22 | `; 23 | } 24 | } 25 | 26 | export default {{pascalCase tagName}}; 27 | -------------------------------------------------------------------------------- /src/components/imports/imports.mdx: -------------------------------------------------------------------------------- 1 | # Imports 2 | 3 | Add examples and descriptions of the component features here. 4 | 5 | 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | ```tsx 12 | import { WcImports } from 'lit-starter-kit/react'; 13 | 14 | export default () => { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | }; 21 | ``` 22 | 23 | 24 | 25 | 26 | ```js 27 | const test - 'test'; 28 | ``` 29 | 30 | ```html 31 |
test
32 | ``` 33 | 34 | ```tsx 35 | const test = 'test'; 36 | ``` -------------------------------------------------------------------------------- /src/components/dox/dox.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcDox } from './dox.js'; 4 | 5 | const { args, argTypes, events, template } = getWcStorybookHelpers('wc-dox'); 6 | 7 | export default { 8 | title: 'Components/Dox', 9 | component: 'wc-dox', 10 | args, 11 | argTypes, 12 | parameters: { 13 | actions: { 14 | handles: events, 15 | }, 16 | }, 17 | }; 18 | 19 | type Story = StoryObj; 20 | 21 | export const Default: Story = { 22 | render: args => template(args), 23 | args: { 24 | tag: 'my-element', 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /src/components/props/props.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcProps } from './props.js'; 4 | 5 | const { args, argTypes, events, template } = getWcStorybookHelpers('wc-props'); 6 | 7 | export default { 8 | title: 'Components/Props', 9 | component: 'wc-props', 10 | args, 11 | argTypes, 12 | parameters: { 13 | actions: { 14 | handles: events, 15 | }, 16 | }, 17 | }; 18 | 19 | type Story = StoryObj; 20 | 21 | export const Default: Story = { 22 | render: args => template(args), 23 | args: { 24 | tag: 'my-element', 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /src/components/slots/slots.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcSlots } from './slots.js'; 4 | 5 | const { args, argTypes, events, template } = getWcStorybookHelpers('wc-slots'); 6 | 7 | export default { 8 | title: 'Components/Slots', 9 | component: 'wc-slots', 10 | args, 11 | argTypes, 12 | parameters: { 13 | actions: { 14 | handles: events, 15 | }, 16 | }, 17 | }; 18 | 19 | type Story = StoryObj; 20 | 21 | export const Default: Story = { 22 | render: args => template(args), 23 | args: { 24 | tag: 'my-element', 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /src/components/methods/methods.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcMethods } from './methods.js'; 4 | 5 | const { args, argTypes, events, template } = 6 | getWcStorybookHelpers('wc-methods'); 7 | 8 | export default { 9 | title: 'Components/Methods', 10 | component: 'wc-methods', 11 | args, 12 | argTypes, 13 | parameters: { 14 | actions: { 15 | handles: events, 16 | }, 17 | }, 18 | }; 19 | 20 | type Story = StoryObj; 21 | 22 | export const Default: Story = { 23 | render: args => template(args), 24 | args: { 25 | tag: 'my-element', 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /src/components/css-states/css-states.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcCssStates } from './css-states.js'; 4 | 5 | const { args, argTypes, events, template } = getWcStorybookHelpers('wc-css-states'); 6 | 7 | export default { 8 | title: 'Components/CSS States', 9 | component: 'wc-css-states', 10 | args, 11 | argTypes, 12 | parameters: { 13 | actions: { 14 | handles: events, 15 | }, 16 | }, 17 | }; 18 | 19 | type Story = StoryObj; 20 | 21 | export const Default: Story = { 22 | render: args => template(args), 23 | args: { 24 | tag: 'my-element', 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /plop-templates/component.stories.ts.hbs: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import type { {{pascalCase tagName}} } from './index.js'; 4 | 5 | const { args, argTypes, events, template } = getWcStorybookHelpers('{{kebabCase tagName}}'); 6 | 7 | export default { 8 | title: 'Components/{{pascalCase name}}', 9 | component: '{{kebabCase tagName}}', 10 | args, 11 | argTypes, 12 | parameters: { 13 | actions: { 14 | handles: events, 15 | }, 16 | }, 17 | }; 18 | 19 | 20 | type Story = StoryObj<{{pascalCase tagName}} & typeof args>; 21 | 22 | export const Default: Story = { 23 | render: args => template(args), 24 | args: {} 25 | }; 26 | -------------------------------------------------------------------------------- /src/components/events/events.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcEvents } from './events.js'; 4 | 5 | const { args, argTypes, events, template } = getWcStorybookHelpers('wc-events'); 6 | 7 | export default { 8 | title: 'Components/Events', 9 | component: 'wc-events', 10 | args, 11 | argTypes, 12 | parameters: { 13 | actions: { 14 | handles: events, 15 | }, 16 | }, 17 | }; 18 | 19 | type Story = StoryObj; 20 | 21 | export const Default: Story = { 22 | render: args => template(args), 23 | args: { 24 | tag: 'my-element', 25 | 'component-name': 'MyElement', 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /src/components/imports/imports.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcImports } from './imports.js'; 4 | 5 | const { args, argTypes, events, template } = 6 | getWcStorybookHelpers('wc-imports'); 7 | 8 | export default { 9 | title: 'Components/Imports', 10 | component: 'wc-imports', 11 | args, 12 | argTypes, 13 | parameters: { 14 | actions: { 15 | handles: events, 16 | }, 17 | }, 18 | }; 19 | 20 | type Story = StoryObj; 21 | 22 | export const Default: Story = { 23 | render: args => template(args), 24 | args: { 25 | tag: 'my-element', 26 | 'component-name': 'MyElement', 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /src/components/css-parts/css-parts.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcCssParts } from './css-parts.js'; 4 | 5 | const { args, argTypes, events, template } = 6 | getWcStorybookHelpers('wc-css-parts'); 7 | 8 | export default { 9 | title: 'Components/CSS Parts', 10 | component: 'wc-css-parts', 11 | args, 12 | argTypes, 13 | parameters: { 14 | actions: { 15 | handles: events, 16 | }, 17 | }, 18 | }; 19 | 20 | type Story = StoryObj; 21 | 22 | export const Default: Story = { 23 | render: args => template(args), 24 | args: { 25 | tag: 'my-element', 26 | 'component-name': 'MyElement', 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /src/components/css-props/css-props.stories.ts: -------------------------------------------------------------------------------- 1 | import { StoryObj } from '@storybook/web-components'; 2 | import { getWcStorybookHelpers } from 'wc-storybook-helpers'; 3 | import { WcCssProps } from './css-props.js'; 4 | 5 | const { args, argTypes, events, template } = 6 | getWcStorybookHelpers('wc-css-props'); 7 | 8 | export default { 9 | title: 'Components/CSS Props', 10 | component: 'wc-css-props', 11 | args, 12 | argTypes, 13 | parameters: { 14 | actions: { 15 | handles: events, 16 | }, 17 | }, 18 | }; 19 | 20 | type Story = StoryObj; 21 | 22 | export const Default: Story = { 23 | render: args => template(args), 24 | args: { 25 | tag: 'my-element', 26 | 'component-name': 'MyElement', 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /src/components/slots/slots.ts: -------------------------------------------------------------------------------- 1 | import styles from './slots.styles.js'; 2 | import { config, CssPropsElementConfig } from '../../configs/index.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import WcDoxBase from '../base/dox-base.js'; 5 | 6 | 7 | /** 8 | * A component to document the slots of a custom element 9 | * 10 | * @tag wc-slots 11 | * @since 1.0.0 12 | * @status experimental 13 | * 14 | **/ 15 | export class WcSlots extends WcDoxBase< 16 | CssPropsElementConfig, 17 | cem.CssCustomProperty 18 | > { 19 | public constructor() { 20 | super(); 21 | this.feature = 'slots'; 22 | this.config = config.slots; 23 | } 24 | 25 | override render() { 26 | return this.getRenderTemplate(styles, 'slots'); 27 | } 28 | } 29 | 30 | export default WcSlots; 31 | -------------------------------------------------------------------------------- /src/components/methods/methods.ts: -------------------------------------------------------------------------------- 1 | import styles from './methods.styles.js'; 2 | import { config, MethodsElementConfig } from '../../configs/index.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import WcDoxBase from '../base/dox-base.js'; 5 | 6 | /** 7 | * A component to document the methods of a custom element 8 | * 9 | * @tag wc-methods 10 | * @since 1.0.0 11 | * @status experimental 12 | * 13 | **/ 14 | export class WcMethods extends WcDoxBase< 15 | MethodsElementConfig, 16 | cem.ClassMethod 17 | > { 18 | public constructor() { 19 | super(); 20 | this.feature = 'methods'; 21 | this.config = config.methods; 22 | } 23 | 24 | override render() { 25 | return this.getRenderTemplate(styles, 'methods'); 26 | } 27 | } 28 | 29 | export default WcMethods; 30 | -------------------------------------------------------------------------------- /src/configs/index.ts: -------------------------------------------------------------------------------- 1 | import { mergeDeep } from '../utils/deep-merge.js'; 2 | import { defaultDoxConfig } from './default-values.js'; 3 | import { DoxConfig } from './types.js'; 4 | import * as cem from 'custom-elements-manifest/schema'; 5 | 6 | export * from './types.js'; 7 | 8 | export let config: DoxConfig = { ...defaultDoxConfig }; 9 | export let manifest = {} as cem.Package; 10 | 11 | export function setWcDoxConfig( 12 | customElementsManifest: unknown, 13 | userConfig: DoxConfig = {}, 14 | ) { 15 | if(!customElementsManifest || typeof customElementsManifest !== 'object') { 16 | console.warn('[wc-dox] Invalid custom elements manifest provided.'); 17 | return; 18 | } 19 | config = mergeDeep(config as never, userConfig as never); 20 | manifest = customElementsManifest as never; 21 | } 22 | -------------------------------------------------------------------------------- /src/components/props/props.ts: -------------------------------------------------------------------------------- 1 | import styles from './props.styles.js'; 2 | import { config, PropsElementConfig } from '../../configs/index.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import WcDoxBase from '../base/dox-base.js'; 5 | 6 | /** 7 | * A component to document the attributes and properties of a custom element 8 | * 9 | * @tag wc-props 10 | * @since 1.0.0 11 | * @status experimental 12 | * 13 | **/ 14 | export class WcProps extends WcDoxBase< 15 | PropsElementConfig, 16 | cem.CustomElementField 17 | > { 18 | public constructor() { 19 | super(); 20 | this.feature = 'properties'; 21 | this.config = config.props; 22 | } 23 | 24 | override render() { 25 | return this.getRenderTemplate(styles, 'props'); 26 | } 27 | } 28 | 29 | export default WcProps; 30 | -------------------------------------------------------------------------------- /src/components/events/events.ts: -------------------------------------------------------------------------------- 1 | import styles from './events.styles.js'; 2 | import { EventsElementConfig } from '../../configs/types.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import WcDoxBase from '../base/dox-base.js'; 5 | import { config } from '../../configs/index.js'; 6 | 7 | /** 8 | * A component to document the events of a custom element 9 | * 10 | * @tag wc-events 11 | * @since 1.0.0 12 | * @status experimental 13 | * 14 | **/ 15 | export class WcEvents extends WcDoxBase< 16 | EventsElementConfig, 17 | cem.Event 18 | > { 19 | public constructor() { 20 | super(); 21 | this.feature = 'events'; 22 | this.config = config.events; 23 | } 24 | 25 | override render() { 26 | return this.getRenderTemplate(styles, 'events'); 27 | } 28 | } 29 | 30 | export default WcEvents; 31 | -------------------------------------------------------------------------------- /src/components/css-states/css-states.ts: -------------------------------------------------------------------------------- 1 | import styles from './css-states.styles.js'; 2 | import { config, CssStatesElementConfig } from '../../configs/index.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import WcDoxBase from '../base/dox-base.js'; 5 | 6 | /** 7 | * A component to document the CSS custom states of a custom element 8 | * 9 | * @tag wc-css-states 10 | * @since 1.0.0 11 | * @status experimental 12 | * 13 | **/ 14 | export class WcCssStates extends WcDoxBase< 15 | CssStatesElementConfig, 16 | cem.CssCustomState 17 | > { 18 | public constructor() { 19 | super(); 20 | this.feature = 'cssStates'; 21 | this.config = config.cssStates; 22 | } 23 | 24 | override render() { 25 | return this.getRenderTemplate(styles, 'states'); 26 | } 27 | } 28 | 29 | export default WcCssStates; 30 | -------------------------------------------------------------------------------- /src/components/css-parts/css-parts.ts: -------------------------------------------------------------------------------- 1 | import { CssPartsElementConfig } from '../../configs/types.js'; 2 | import { config } from '../../configs/index.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import { WcDoxBase } from '../base/dox-base.js'; 5 | import styles from './css-parts.styles.js'; 6 | 7 | /** 8 | * A component to document the CSS Parts of a custom element 9 | * 10 | * @tag wc-css-parts 11 | * @since 1.0.0 12 | * @status experimental 13 | * 14 | **/ 15 | export class WcCssParts extends WcDoxBase { 16 | public constructor() { 17 | super(); 18 | this.feature = 'cssParts'; 19 | this.config = config.cssParts; 20 | } 21 | 22 | override render() { 23 | return this.getRenderTemplate(styles, 'css-parts'); 24 | } 25 | } 26 | 27 | export default WcCssParts; 28 | -------------------------------------------------------------------------------- /src/utils/deep-merge.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple object check. 3 | * @param item 4 | * @returns {boolean} 5 | */ 6 | export function isObject(item: never) { 7 | return item && typeof item === 'object' && !Array.isArray(item); 8 | } 9 | 10 | /** 11 | * Merges the content of two objects 12 | * @param target object being merged into 13 | * @param sources data to merge into the target 14 | * @returns object 15 | */ 16 | export function mergeDeep(target: never, source: never) { 17 | if (!isObject(target) || !isObject(source)) { 18 | return target; 19 | } 20 | 21 | for (const key in source as object) { 22 | if (isObject(source[key])) { 23 | Object.assign(target, { 24 | [key]: mergeDeep(target[key] || { [key]: {} }, source[key]), 25 | }); 26 | } else { 27 | Object.assign(target, { [key]: source[key] }); 28 | } 29 | } 30 | 31 | return target; 32 | } 33 | -------------------------------------------------------------------------------- /src/components/css-props/css-props.ts: -------------------------------------------------------------------------------- 1 | import styles from './css-props.styles.js'; 2 | import { config, CssPropsElementConfig } from '../../configs/index.js'; 3 | import * as cem from 'custom-elements-manifest/schema'; 4 | import WcDoxBase from '../base/dox-base.js'; 5 | 6 | /** 7 | * A component to document the CSS custom properties of a custom element 8 | * 9 | * @tag wc-css-props 10 | * @since 1.0.0 11 | * @status experimental 12 | * 13 | **/ 14 | export class WcCssProps extends WcDoxBase< 15 | CssPropsElementConfig, 16 | cem.CssCustomProperty 17 | > { 18 | public constructor() { 19 | super(); 20 | this.feature = 'cssProperties'; 21 | this.config = config.cssProps; 22 | } 23 | 24 | override connectedCallback(): void { 25 | super.connectedCallback(); 26 | this.updateMetaData('cssProperties'); 27 | } 28 | 29 | override render() { 30 | return this.getRenderTemplate(styles, 'css-props'); 31 | } 32 | } 33 | 34 | export default WcCssProps; 35 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './configs/index.js'; 2 | export { markdownToHtml } from './utils/markdown.js'; 3 | import WcDox from './components/dox/dox.js'; 4 | import WcImports from './components/imports/imports.js'; 5 | import WcCssParts from './components/css-parts/css-parts.js'; 6 | import WcCssProps from './components/css-props/css-props.js'; 7 | import WcEvents from './components/events/events.js'; 8 | import WcProps from './components/props/props.js'; 9 | import WcMethods from './components/methods/methods.js'; 10 | import WcSlots from './components/slots/slots.js'; 11 | import WcCssStates from './components/css-states/css-states.js'; 12 | import { define } from './utils/define.js'; 13 | 14 | try { 15 | define('wc-dox', WcDox); 16 | define('wc-imports', WcImports); 17 | define('wc-css-parts', WcCssParts); 18 | define('wc-css-props', WcCssProps); 19 | define('wc-events', WcEvents); 20 | define('wc-props', WcProps); 21 | define('wc-methods', WcMethods); 22 | define('wc-slots', WcSlots); 23 | define('wc-css-states', WcCssStates); 24 | } catch (e) { 25 | console.error(e); 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Burton Smith 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /web-test-runner.config.js: -------------------------------------------------------------------------------- 1 | import { esbuildPlugin } from '@web/dev-server-esbuild'; 2 | import { playwrightLauncher } from '@web/test-runner-playwright'; 3 | import { fileURLToPath } from 'url'; 4 | 5 | export default { 6 | rootDir: '.', 7 | files: 'src/**/*.test.ts', // "default" group 8 | concurrentBrowsers: 3, 9 | nodeResolve: { 10 | exportConditions: ['production', 'default'], 11 | }, 12 | testFramework: { 13 | config: { 14 | timeout: 3000, 15 | retries: 1, 16 | }, 17 | }, 18 | plugins: [ 19 | esbuildPlugin({ 20 | ts: true, 21 | tsconfig: fileURLToPath(new URL('./tsconfig.json', import.meta.url)), 22 | }), 23 | ], 24 | browsers: [ 25 | playwrightLauncher({ product: 'chromium' }), 26 | playwrightLauncher({ product: 'firefox' }), 27 | playwrightLauncher({ product: 'webkit' }), 28 | ], 29 | testRunnerHtml: testFramework => ` 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | `, 40 | }; 41 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.3.5 4 | 5 | - Simplified component lookup to improve performance and reduce errors 6 | 7 | ## 1.3.4 8 | 9 | - Upgraded `@wc-toolkit/cem-utilities` to resolve error when updating import descriptions. 10 | 11 | ## 1.3.3 12 | 13 | - Make `@wc-toolkit/cem-utilities` a `dependency` rather than a `devDependency` to resolve the module correctly. 14 | 15 | ## 1.3.2 16 | 17 | - Upgraded `@wc-toolkit/cem-utilities` to resolve error when updating import paths. 18 | 19 | ## 1.3.1 20 | 21 | - Fixed type-os in README when documenting CEM imports. 22 | 23 | ## 1.3.0 24 | 25 | - Upgrade dependencies to use the latest form WC Toolkit 26 | - Simplified component setup 27 | - Added logging for failures 28 | - Added configuration to add custom heading and table classes 29 | 30 | ## 1.2.0 31 | 32 | - Added templating for optional parameters and default values for methods 33 | 34 | ## 1.1.1 35 | 36 | - Fixed type-o in README.md 37 | - Fixed type-o in default values 38 | 39 | ## 1.1.0 40 | 41 | - Added `langOnPreTag` setting to `imports` to set the language class on the `pre` element instead of the `code` element 42 | - Fixed parameters for `importTemplate` to use content from the CEM rather than the component properties 43 | 44 | ## 1.0.4 45 | 46 | - Fixed logic for hiding components when there is no content 47 | - Fixed logic that cause exceptions when components and APIs are undefined 48 | 49 | ## 1.0.3 50 | 51 | - Fixed type-o in README 52 | 53 | ## 1.0.2 54 | 55 | - Removed default imports 56 | 57 | ## 1.0.1 58 | 59 | - Updated documentation 60 | 61 | ## 1.0.0 62 | 63 | - Initial release -------------------------------------------------------------------------------- /src/components/imports/imports.styles.ts: -------------------------------------------------------------------------------- 1 | import { css } from 'lit'; 2 | 3 | export default css` 4 | :root { 5 | --wc-imports-border-color: var(--wc-dox-border-color, #e0e0e0); 6 | --wc-imports-active-border-color: var( 7 | --wc-dox-active-border-color, 8 | #0078d4 9 | ); 10 | --wc-imports-border-size: var(--wc-dox-border-size, 2px); 11 | } 12 | 13 | wc-imports { 14 | &[hidden] { 15 | display: none !important; 16 | } 17 | 18 | .tabpanel { 19 | position: relative; 20 | 21 | code { 22 | display: block; 23 | } 24 | 25 | pre { 26 | overflow-x: auto; 27 | overflow-y: hidden; 28 | display: block; 29 | } 30 | 31 | .copy-button { 32 | padding: 0.25rem; 33 | line-height: 1; 34 | display: inline-flex; 35 | position: absolute; 36 | right: 0.25rem; 37 | top: 0.25rem; 38 | 39 | svg { 40 | fill: currentColor; 41 | width: 1em; 42 | height: 1em; 43 | } 44 | } 45 | } 46 | 47 | .tablist { 48 | display: flex; 49 | border-bottom: var(--wc-imports-border-size) solid 50 | var(--wc-imports-border-color); 51 | } 52 | 53 | .tab { 54 | padding: 8px 16px; 55 | cursor: pointer; 56 | border: transparent; 57 | border-bottom: 1px solid transparent; 58 | background-color: transparent; 59 | margin-bottom: calc(-1 * var(--wc-imports-border-size)); 60 | 61 | &[aria-selected='true'] { 62 | border-bottom: var(--wc-imports-border-size) solid 63 | var(--wc-imports-active-border-color); 64 | } 65 | } 66 | } 67 | `; 68 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import globals from 'globals'; 2 | import js from '@eslint/js'; 3 | import tseslint from 'typescript-eslint'; 4 | import { configs as lit } from 'eslint-plugin-lit'; 5 | import eslintConfigPrettier from 'eslint-config-prettier'; 6 | import json from '@eslint/json'; 7 | import markdown from '@eslint/markdown'; 8 | import storybook from 'eslint-plugin-storybook'; 9 | import litA11y from 'eslint-plugin-lit-a11y'; 10 | 11 | /** @type {import('eslint').Linter.Config[]} */ 12 | export default [ 13 | { languageOptions: { globals: globals.browser } }, 14 | eslintConfigPrettier, 15 | ...storybook.configs['flat/recommended'], 16 | 17 | // lint JSON files 18 | { 19 | files: ['**/*.json'], 20 | language: 'json/json', 21 | ...json.configs.recommended, 22 | rules: { 23 | 'json/no-duplicate-keys': 'error', 24 | 'no-irregular-whitespace': 'off', 25 | }, 26 | }, 27 | 28 | // lint MD files 29 | ...markdown.configs.recommended, 30 | { 31 | files: ['**/*.md'], 32 | rules: { 33 | 'no-irregular-whitespace': 'off', 34 | }, 35 | }, 36 | 37 | // lint JS/TS files 38 | ...tseslint.configs.recommended, 39 | { 40 | files: ['**/*.{js,mjs,cjs,ts}'], 41 | ...lit['flat/recommended'], 42 | ...js.configs.recommended, 43 | rules: {}, 44 | }, 45 | 46 | { 47 | plugins: { 48 | 'lit-a11y': litA11y, 49 | }, 50 | }, 51 | 52 | { 53 | ignores: [ 54 | '.vscode/*', 55 | 'cdn/*', 56 | 'dist/*', 57 | 'eslint/*', 58 | 'plop-templates/*', 59 | 'public/*', 60 | 'react/*', 61 | 'types/*', 62 | 'custom-elements.json', 63 | 'vscode.css-custom-data.json', 64 | 'vscode.html-custom-data.json', 65 | 'web-types.json', 66 | 'tsconfig.json', 67 | ], 68 | }, 69 | ]; 70 | -------------------------------------------------------------------------------- /src/components/dox/dox.ts: -------------------------------------------------------------------------------- 1 | import { html, LitElement } from 'lit'; 2 | import { property } from 'lit/decorators.js'; 3 | import styles from './dox.styles.js'; 4 | import { config, manifest } from '../../configs/index.js'; 5 | import WcDoxBase from '../base/dox-base.js'; 6 | import { 7 | Component, 8 | getComponentByClassName, 9 | getComponentByTagName, 10 | } from '@wc-toolkit/cem-utilities'; 11 | 12 | /** 13 | * A component to document the APIs of a custom element 14 | * 15 | * @tag wc-dox 16 | * @since 1.0.0 17 | * @status experimental 18 | * 19 | **/ 20 | export class WcDox extends LitElement { 21 | override createRenderRoot() { 22 | return this; 23 | } 24 | 25 | protected component?: Component; 26 | 27 | @property() 28 | tag?: string; 29 | 30 | @property({ attribute: 'component-name' }) 31 | componentName?: string; 32 | 33 | override connectedCallback(): void { 34 | super.connectedCallback(); 35 | this.component = this.tag 36 | ? getComponentByTagName(manifest, this.tag) 37 | : getComponentByClassName(manifest, this.componentName); 38 | if (this.component) { 39 | config.dox?.apiOrder?.forEach(importName => { 40 | const component = document.createElement( 41 | `wc-${importName}`, 42 | ) as WcDoxBase; 43 | component.component = this.component; 44 | this.appendChild(component); 45 | }); 46 | } else { 47 | console.warn( 48 | `[wc-dox] No component defined to extract metadata from for tag "${this.tag}" or class "${this.componentName}" in "${this.tagName.toLowerCase()}".`, 49 | ); 50 | } 51 | } 52 | 53 | override render() { 54 | return html` 55 | 58 | `; 59 | } 60 | } 61 | 62 | export default WcDox; 63 | -------------------------------------------------------------------------------- /.storybook/preview.ts: -------------------------------------------------------------------------------- 1 | import { setCustomElementsManifest } from '@storybook/web-components'; 2 | import customElements from '../custom-elements.json'; 3 | import { setWcStorybookHelpersConfig } from 'wc-storybook-helpers'; 4 | import { withActions } from '@storybook/addon-actions/decorator'; 5 | import './code-bubble-setup.js'; 6 | import './styles.css'; 7 | import { setWcDoxConfig } from '../public/html/index.js'; 8 | import manifest from './custom-elements.json'; 9 | 10 | import type { Preview } from '@storybook/web-components'; 11 | 12 | setWcStorybookHelpersConfig({ typeRef: 'expandedType' }); 13 | setCustomElementsManifest(customElements); 14 | setWcDoxConfig(manifest, { 15 | headingClass: 'api-heading', 16 | tableClass: 'api-table', 17 | imports: { 18 | langOnPreTag: true, 19 | imports: [ 20 | { 21 | label: 'HTML', 22 | lang: 'html', 23 | importTemplate: (tagName: string, className: string) => 24 | ``, 25 | }, 26 | { 27 | label: 'NPM', 28 | lang: 'js', 29 | importTemplate: (tagName: string, className: string) => 30 | `import 'my-library/dist/${tagName}/${className}.js';`, 31 | }, 32 | { 33 | label: 'React', 34 | lang: 'js', 35 | importTemplate: (tagName: string) => 36 | `import 'my-library/react/${tagName}/index.js';`, 37 | }, 38 | ], 39 | }, 40 | }); 41 | 42 | const preview: Preview = { 43 | parameters: { 44 | controls: { 45 | expanded: true, // provides descriptions and additional info for controls 46 | sort: 'alpha', // sorts controls in alphabetical order 47 | }, 48 | }, 49 | decorators: [withActions], 50 | }; 51 | 52 | export default preview; 53 | -------------------------------------------------------------------------------- /src/utils/cem-tools.ts: -------------------------------------------------------------------------------- 1 | import type * as cem from 'custom-elements-manifest'; 2 | 3 | /** 4 | * Gets a list of components from a CEM object 5 | * @param customElementsManifest CEM object 6 | * @param exclude and array of component names to exclude 7 | * @returns Component[] 8 | */ 9 | export function getComponent( 10 | customElementsManifest: cem.Package, 11 | className?: string, 12 | tagName?: string, 13 | ) { 14 | return (customElementsManifest.modules?.map(mod => 15 | mod?.declarations?.find( 16 | dec => 17 | (dec as cem.CustomElement).name === className || 18 | (dec as cem.CustomElement).tagName === tagName, 19 | ), 20 | ))?.find(e => e !== undefined) as cem.CustomElement; 21 | } 22 | 23 | /** 24 | * Gets a list of public properties from a CEM component 25 | * @param component CEM component/declaration object 26 | * @returns an array of public properties for a given component 27 | */ 28 | export function getComponentProperties(component: cem.CustomElement) { 29 | return (component?.members?.filter( 30 | member => 31 | member.kind === 'field' && 32 | member.privacy !== 'private' && 33 | member.privacy !== 'protected' && 34 | !member.static && 35 | !member.name.startsWith('#'), 36 | ) || []) as cem.ClassMember[]; 37 | } 38 | 39 | /** 40 | * Get all public methods for a component 41 | * @param component CEM component/declaration object 42 | * @returns ClassMethod[] 43 | */ 44 | export function getComponentMethods( 45 | component: cem.CustomElement, 46 | ): cem.ClassMethod[] { 47 | return (component?.members?.filter( 48 | member => 49 | member.kind === 'method' && 50 | member.privacy !== 'private' && 51 | member.privacy !== 'protected' && 52 | !member.name.startsWith('#'), 53 | ) || []) as cem.ClassMethod[]; 54 | } 55 | 56 | /** 57 | * Gets a list of event names for a given component 58 | * @param component The component you want to get the event types for 59 | * @param excludedTypes Any types you want to exclude from the list 60 | * @returns A string array of event types for a given component 61 | */ 62 | export function getCustomEventTypes(component: cem.CustomElement) { 63 | const types = 64 | component?.events 65 | ?.map(e => { 66 | const eventType = e.type?.text 67 | .replace('[]', '') 68 | .replace(' | undefined', ''); 69 | return eventType && 70 | !eventType.includes('<') && 71 | !eventType.includes(`{`) && 72 | !eventType.includes("'") && 73 | !eventType.includes(`"`) 74 | ? eventType 75 | : undefined; 76 | }) 77 | ?.filter(e => e !== undefined && !e?.startsWith('HTML')) || []; 78 | 79 | return types?.length ? [...new Set(types)].join(', ') : undefined; 80 | } 81 | -------------------------------------------------------------------------------- /plopfile.js: -------------------------------------------------------------------------------- 1 | /** @arg {import('plop').NodePlopAPI} plop */ 2 | 3 | export default function (plop) { 4 | plop.setHelper('dashToTitle', text => { 5 | const titleCase = plop.getHelper('titleCase'); 6 | return titleCase(text.replace(/-/g, ' ')); 7 | }); 8 | 9 | plop.setGenerator('component', { 10 | description: 'generate a new component', 11 | prompts: [ 12 | { 13 | type: 'input', 14 | name: 'name', 15 | message: 16 | 'Please enter your component name in kebab-case (e.g. button-group)', 17 | default: 'component', 18 | }, 19 | { 20 | type: 'input', 21 | name: 'prefix', 22 | message: 'What is the prefix for your component? (e.g. my)', 23 | default: '', 24 | }, 25 | ], 26 | actions: function (data) { 27 | const basename = data?.name; 28 | if ( 29 | // Must only contain alphanumeric characters and dashes 30 | !/[a-z0-9-]+/.test(basename) || 31 | // Must start with a letter 32 | !/^[a-z]/.test(basename) || 33 | // Must not end in a dash 34 | basename.endsWith('-') 35 | ) { 36 | console.log( 37 | 'The name must only contain alphanumeric characters and dashes, start with a letter, and not end in a dash. Please try again.', 38 | ); 39 | return []; 40 | } 41 | 42 | const BASE_PATH = `src/components/{{kebabCase name}}`; 43 | 44 | data.tagName = data?.prefix ? `${data.prefix}-${data.name}` : data.name; 45 | 46 | return [ 47 | { 48 | type: 'add', 49 | skipIfExists: true, 50 | path: `${BASE_PATH}/{{kebabCase name}}.ts`, 51 | templateFile: 'plop-templates/component.ts.hbs', 52 | }, 53 | { 54 | type: 'add', 55 | skipIfExists: true, 56 | path: `${BASE_PATH}/{{kebabCase name}}.styles.ts`, 57 | templateFile: 'plop-templates/component.styles.ts.hbs', 58 | }, 59 | { 60 | type: 'add', 61 | skipIfExists: true, 62 | path: `${BASE_PATH}/{{kebabCase name}}.test.ts`, 63 | templateFile: 'plop-templates/component.test.ts.hbs', 64 | }, 65 | { 66 | type: 'add', 67 | skipIfExists: true, 68 | path: `${BASE_PATH}/{{kebabCase name}}.mdx`, 69 | templateFile: 'plop-templates/component.docs.hbs', 70 | }, 71 | { 72 | type: 'add', 73 | skipIfExists: true, 74 | path: `${BASE_PATH}/{{kebabCase name}}.stories.ts`, 75 | templateFile: 'plop-templates/component.stories.ts.hbs', 76 | }, 77 | { 78 | type: 'add', 79 | skipIfExists: true, 80 | path: `${BASE_PATH}/index.ts`, 81 | templateFile: 'plop-templates/component.definition.ts.hbs', 82 | }, 83 | ]; 84 | }, 85 | }); 86 | } 87 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | # Custom 133 | /cdn 134 | /eslint 135 | /public 136 | /react 137 | /types 138 | ./custom-elements.json 139 | vscode.css-custom-data.json 140 | vscode.html-custom-data.json 141 | web-types.json -------------------------------------------------------------------------------- /custom-elements-manifest.config.js: -------------------------------------------------------------------------------- 1 | import { customElementReactWrapperPlugin } from 'custom-element-react-wrappers'; 2 | import { customElementVsCodePlugin } from 'custom-element-vs-code-integration'; 3 | import { customElementJetBrainsPlugin } from 'custom-element-jet-brains-integration'; 4 | import { customElementSolidJsPlugin } from 'custom-element-solidjs-integration'; 5 | import { customElementVuejsPlugin } from 'custom-element-vuejs-integration'; 6 | import { customElementSveltePlugin } from 'custom-element-svelte-integration'; 7 | import { cemDeprecatorPlugin } from 'custom-elements-manifest-deprecator'; 8 | import { cemSorterPlugin } from "@wc-toolkit/cem-sorter"; 9 | import { cemInheritancePlugin } from "@wc-toolkit/cem-inheritance"; 10 | import { jsDocTagsPlugin } from "@wc-toolkit/jsdoc-tags"; 11 | import { getTsProgram, typeParserPlugin } from "@wc-toolkit/type-parser"; 12 | import { jsxTypesPlugin } from "@wc-toolkit/jsx-types"; 13 | import { lazyLoaderPlugin } from "@wc-toolkit/lazy-loader"; 14 | 15 | 16 | const getTagBase = tagName => tagName.split('-').slice(1).join('-'); 17 | 18 | export default { 19 | /** Globs to analyze */ 20 | globs: ['src/components/**/*.ts'], 21 | /** Globs to exclude */ 22 | exclude: [ 23 | 'src/**/*.test.ts', 24 | 'src/**/*.stories.ts', 25 | 'src/**/*.styles.ts', 26 | ], 27 | /** Enable special handling for litelement */ 28 | litelement: true, 29 | /** Provide custom plugins */ 30 | plugins: [ 31 | cemSorterPlugin(), 32 | typeParserPlugin(), 33 | cemInheritancePlugin(), 34 | cemDeprecatorPlugin({ 35 | hideLogs: true, 36 | }), 37 | 38 | customElementVsCodePlugin({ 39 | hideLogs: true, 40 | }), 41 | customElementJetBrainsPlugin({ 42 | hideLogs: true, 43 | }), 44 | customElementReactWrapperPlugin({ 45 | hideLogs: true, 46 | outdir: 'react', 47 | exclude: ['WcDoxBase'], 48 | modulePath: (_, tagName) => 49 | `../dist/components/${getTagBase(tagName)}/${getTagBase(tagName)}.js`, 50 | }), 51 | customElementSolidJsPlugin({ 52 | hideLogs: true, 53 | outdir: 'types', 54 | fileName: 'custom-element-solidjs.d.ts', 55 | modulePath: (_, tagName) => 56 | `../dist/components/${getTagBase(tagName)}/${getTagBase(tagName)}.js`, 57 | }), 58 | jsxTypesPlugin({ 59 | outdir: 'types', 60 | modulePath: (_, tagName) => 61 | `../dist/components/${getTagBase(tagName)}/${getTagBase(tagName)}.js`, 62 | }), 63 | customElementVuejsPlugin({ 64 | hideLogs: true, 65 | outdir: 'types', 66 | fileName: 'custom-element-vuejs.d.ts', 67 | modulePath: (_, tagName) => 68 | `../dist/components/${getTagBase(tagName)}/${getTagBase(tagName)}.js`, 69 | }), 70 | customElementSveltePlugin({ 71 | hideLogs: true, 72 | outdir: 'types', 73 | fileName: 'custom-element-svelte.d.ts', 74 | modulePath: (_, tagName) => 75 | `../dist/components/${getTagBase(tagName)}/${getTagBase(tagName)}.js`, 76 | }), 77 | lazyLoaderPlugin({ 78 | outdir: 'cdn', 79 | importPathTemplate: (_, tagName) => 80 | `../dist/components/${getTagBase(tagName)}/${getTagBase(tagName)}.js`, 81 | }), 82 | 83 | jsDocTagsPlugin({ 84 | tags: { 85 | status: {}, 86 | since: {}, 87 | dependency: { 88 | mappedName: 'dependencies', 89 | isArray: true, 90 | }, 91 | }, 92 | }), 93 | ], 94 | 95 | overrideModuleCreation: ({ ts, globs }) => { 96 | const program = getTsProgram(ts, globs, 'tsconfig.json'); 97 | return program 98 | .getSourceFiles() 99 | .filter(sf => globs.find(glob => sf.fileName.includes(glob))); 100 | }, 101 | }; 102 | -------------------------------------------------------------------------------- /src/configs/types.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-explicit-any */ 2 | import * as cem from 'custom-elements-manifest/schema'; 3 | 4 | export type DoxConfig = { 5 | /** Hides a section of the documentation if it has no content */ 6 | hideOnEmpty?: boolean; 7 | /** Configures the heading level for the API sections - default is 3 */ 8 | headingLevel?: 1 | 2 | 3 | 4 | 5 | 6; 9 | /** Configures the CSS class for the API section headings */ 10 | headingClass?: string; 11 | /** Configures the CSS class for the API section tables */ 12 | tableClass?: string; 13 | /** Configures the `wc-dox` component contents */ 14 | dox?: DoxElementConfig; 15 | /** Configures the `wc-imports` component contents */ 16 | imports?: ImportsElementConfig; 17 | /** Configures the `wc-css-parts` component contents */ 18 | cssParts?: CssPartsElementConfig; 19 | /** Configures the `wc-css-props` component contents */ 20 | cssProps?: CssPropsElementConfig; 21 | /** Configures the `wc-events` component contents */ 22 | events?: EventsElementConfig; 23 | /** Configures the `wc-methods` component contents */ 24 | methods?: MethodsElementConfig; 25 | /** Configures the `wc-props` component contents */ 26 | props?: PropsElementConfig; 27 | /** Configures the `wc-slots` component contents */ 28 | slots?: SlotsElementConfig; 29 | /** Configures the `wc-css-states` component contents */ 30 | cssStates?: CssStatesElementConfig; 31 | }; 32 | 33 | export type DoxElementConfig = { 34 | /** Controls the order in which the API documentation sections are displayed */ 35 | apiOrder?: Array< 36 | | 'imports' 37 | | 'props' 38 | | 'slots' 39 | | 'methods' 40 | | 'events' 41 | | 'css-props' 42 | | 'css-parts' 43 | | 'css-states' 44 | >; 45 | }; 46 | 47 | export type ImportsElementConfig = { 48 | /** The heading for the imports section */ 49 | heading?: string; 50 | /** The ID used for the skip-link */ 51 | headingId?: string; 52 | /** The description for the imports section */ 53 | description?: string; 54 | /** The copy button icon */ 55 | copyIcon?: string; 56 | /** The copy button label */ 57 | copyLabel?: string; 58 | /** The icon displayed when the content is copied */ 59 | copiedIcon?: string; 60 | /** The label used when the content is copied */ 61 | copiedLabel?: string; 62 | /** Sets the language class on `pre` tag instead of `code` tag */ 63 | langOnPreTag?: boolean; 64 | /** The list of import options */ 65 | imports?: ImportConfig[]; 66 | }; 67 | 68 | export type ImportConfig = { 69 | /** The text displayed in the tab option */ 70 | label?: string; 71 | /** The language the code - `html`, `js`, `ts`, etc. */ 72 | lang?: string; 73 | /** An additional description that is specific to this import */ 74 | description?: string; 75 | /** 76 | * Use this function to specify import information for a given language. The tag and class names can be used to create dynamic component-specific import paths. 77 | * @param tagName The tag name specified using the @tag or @tagName in the component's jsDoc 78 | * @param className The JS class name for the component 79 | * @returns string 80 | */ 81 | importTemplate?: (tagName: string, className: string) => string; 82 | }; 83 | 84 | export type BaseElementConfig = { 85 | /** The heading for the section */ 86 | heading?: string; 87 | /** The ID used for the skip-link */ 88 | headingId?: string; 89 | /** The label used for the skip-link */ 90 | skipLinkLabel?: string; 91 | /** The description for the section */ 92 | headings?: string[]; 93 | /** The description for the section */ 94 | description?: string; 95 | /** The table row template for the section */ 96 | rowTemplate?: (x: T) => string; 97 | }; 98 | 99 | 100 | export type CssPart = cem.CssPart & Record; 101 | export type CssProp = cem.CssCustomProperty & Record; 102 | export type Event = cem.Event & Record; 103 | export type Method = cem.ClassMethod & Record; 104 | export type Property = cem.CustomElementField & Record; 105 | export type Slot = cem.Slot & Record; 106 | export type CssState = cem.CssCustomState & Record; 107 | 108 | export type CssPartsElementConfig = BaseElementConfig; 109 | export type CssPropsElementConfig = 110 | BaseElementConfig; 111 | export type EventsElementConfig = BaseElementConfig; 112 | export type MethodsElementConfig = BaseElementConfig; 113 | export type PropsElementConfig = 114 | BaseElementConfig; 115 | export type SlotsElementConfig = BaseElementConfig; 116 | export type CssStatesElementConfig = BaseElementConfig; 117 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wc-dox", 3 | "version": "1.3.5", 4 | "description": "A web component API documentation generator", 5 | "main": "index.js", 6 | "types": "index.d.ts", 7 | "type": "module", 8 | "scripts": { 9 | "analyze": "cem analyze", 10 | "analyze:dev": "cem analyze --watch", 11 | "dev": "concurrently -k -r \"npm run analyze:dev\" \"npm run build:watch\" \"npm run storybook\"", 12 | "test": "web-test-runner --group default", 13 | "build": "npm run analyze && npm run build:cdn", 14 | "build:cdn": "tsc && rollup -c rollup.config.js", 15 | "build:watch": "concurrently -k -r \"tsc --watch\" \"rollup -c rollup.config.js --watch\"", 16 | "new": "plop", 17 | "deploy": "npm run build && npm publish", 18 | "format": "npm run format:eslint && npm run format:prettier", 19 | "format:eslint": "npx eslint --fix", 20 | "format:prettier": "npx prettier . --write", 21 | "lint": "npm run lint:eslint && npm run lint:prettier", 22 | "lint:eslint": "npx eslint", 23 | "lint:prettier": "npx prettier . --check", 24 | "prepare": "husky && npx playwright install-deps", 25 | "storybook": "storybook dev -p 6006", 26 | "build-storybook": "storybook build" 27 | }, 28 | "author": "", 29 | "license": "MIT", 30 | "dependencies": { 31 | "@wc-toolkit/cem-utilities": "^1.5.3", 32 | "lit": "^3.2.1", 33 | "marked": "^15.0.3" 34 | }, 35 | "bugs": { 36 | "url": "https://github.com/break-stuff/wc-dox/issues" 37 | }, 38 | "homepage": "https://github.com/break-stuff/wc-dox/blob/main/README.md", 39 | "devDependencies": { 40 | "@custom-elements-manifest/analyzer": "^0.10.3", 41 | "@eslint/js": "^9.16.0", 42 | "@eslint/json": "^0.8.0", 43 | "@eslint/markdown": "^6.2.1", 44 | "@open-wc/testing": "^4.0.0", 45 | "@playwright/test": "^1.46.1", 46 | "@rollup/plugin-multi-entry": "^6.0.1", 47 | "@rollup/plugin-node-resolve": "^15.3.0", 48 | "@rollup/plugin-terser": "^0.4.4", 49 | "@rollup/plugin-typescript": "^12.1.1", 50 | "@storybook/addon-a11y": "^8.4.6", 51 | "@storybook/addon-actions": "^8.1.11", 52 | "@storybook/addon-essentials": "^8.1.11", 53 | "@storybook/addon-links": "^8.1.11", 54 | "@storybook/blocks": "^8.1.11", 55 | "@storybook/test": "^8.1.11", 56 | "@storybook/web-components": "^8.1.11", 57 | "@storybook/web-components-vite": "^8.1.11", 58 | "@types/mocha": "^10.0.2", 59 | "@wc-toolkit/cem-sorter": "^1.0.1", 60 | "@wc-toolkit/cem-validator": "^1.0.3", 61 | "@wc-toolkit/cem-inheritance": "^1.2.2", 62 | "@wc-toolkit/jsdoc-tags": "^1.1.0", 63 | "@wc-toolkit/jsx-types": "^1.4.3", 64 | "@wc-toolkit/lazy-loader": "^1.0.1", 65 | "@wc-toolkit/type-parser": "^1.2.0", 66 | "@web/dev-server-esbuild": "^1.0.2", 67 | "@web/test-runner": "^0.19.0", 68 | "@web/test-runner-commands": "^0.9.0", 69 | "@web/test-runner-playwright": "^0.11.0", 70 | "code-bubble": "^1.3.3", 71 | "concurrently": "^9.1.0", 72 | "custom-element-jet-brains-integration": "^1.6.2", 73 | "custom-element-react-wrappers": "^1.6.8", 74 | "custom-element-solidjs-integration": "^1.8.2", 75 | "custom-element-svelte-integration": "^1.1.2", 76 | "custom-element-vs-code-integration": "^1.4.1", 77 | "custom-element-vuejs-integration": "^1.3.3", 78 | "custom-elements-manifest": "^2.1.0", 79 | "custom-elements-manifest-deprecator": "^1.1.1", 80 | "eslint": "^9.16.0", 81 | "eslint-config-prettier": "^9.1.0", 82 | "eslint-plugin-lit": "^1.15.0", 83 | "eslint-plugin-lit-a11y": "^1.1.0-next.1", 84 | "eslint-plugin-require-extensions": "^0.1.3", 85 | "eslint-plugin-storybook": "^0.11.1", 86 | "glob": "^11.0.0", 87 | "globals": "^15.13.0", 88 | "husky": "^9.0.11", 89 | "lint-staged": "^15.2.7", 90 | "plop": "^4.0.1", 91 | "prettier": "^3.3.2", 92 | "rollup": "^4.28.0", 93 | "rollup-plugin-dts": "^6.1.1", 94 | "rollup-plugin-summary": "^3.0.0", 95 | "storybook": "^8.1.11", 96 | "tslib": "^2.8.1", 97 | "tsup": "^8.1.0", 98 | "typescript": "^5.5.3", 99 | "typescript-eslint": "^8.17.0", 100 | "wc-storybook-helpers": "^2.0.4" 101 | }, 102 | "lint-staged": { 103 | "*.js": "eslint --cache --fix", 104 | "*.format:prettier": "prettier --write" 105 | }, 106 | "files": [ 107 | "cdn", 108 | "eslint", 109 | "dist", 110 | "react", 111 | "types", 112 | "index.d.ts", 113 | "index.js", 114 | "package.json", 115 | "custom-elements.json", 116 | "vscode.css-custom-data.json", 117 | "vscode.html-custom-data.json", 118 | "web-types.json" 119 | ], 120 | "keywords": [ 121 | "web-components", 122 | "custom-elements", 123 | "lit-element", 124 | "typescript", 125 | "lit", 126 | "documentation" 127 | ], 128 | "customElements": "custom-elements.json" 129 | } 130 | -------------------------------------------------------------------------------- /src/components/base/dox-base.ts: -------------------------------------------------------------------------------- 1 | import { CSSResult, LitElement } from 'lit'; 2 | import { html, unsafeStatic } from 'lit/static-html.js'; 3 | import { property, state } from 'lit/decorators.js'; 4 | import { BaseElementConfig, manifest } from '../../configs/index.js'; 5 | import * as cem from 'custom-elements-manifest/schema'; 6 | import { unsafeHTML } from 'lit/directives/unsafe-html.js'; 7 | import { ifDefined } from 'lit/directives/if-defined.js'; 8 | import { markdownToHtml } from '../../utils/markdown.js'; 9 | import { config } from '../../configs/index.js'; 10 | import { 11 | getComponentByClassName, 12 | getComponentPublicProperties, 13 | getComponentByTagName, 14 | Component, 15 | getComponentPublicMethods, 16 | } from '@wc-toolkit/cem-utilities'; 17 | 18 | export type ComponentAPI = keyof cem.CustomElement | 'properties' | 'methods'; 19 | 20 | /** 21 | * This base class is to isolate reusable code for the dox components. 22 | **/ 23 | export class WcDoxBase< 24 | Config extends BaseElementConfig, 25 | MetaData, 26 | > extends LitElement { 27 | override createRenderRoot() { 28 | return this; 29 | } 30 | 31 | protected config?: Config; 32 | protected feature?: ComponentAPI; 33 | 34 | /** The component data */ 35 | public component?: Component; 36 | 37 | /** The tag name of the custom element */ 38 | @property() 39 | public tag?: string; 40 | 41 | /** The name of the component class */ 42 | @property({ attribute: 'component-name' }) 43 | public componentName?: string; 44 | 45 | @state() 46 | protected metaData?: MetaData[]; 47 | 48 | override connectedCallback(): void { 49 | super.connectedCallback(); 50 | if (!this.component) { 51 | this.component = this.tag 52 | ? getComponentByTagName(manifest, this.tag) 53 | : getComponentByClassName(manifest, this.componentName); 54 | } 55 | this.updateMetaData(this.feature); // default to empty string if feature is undefined 56 | } 57 | 58 | protected updateMetaData(feature?: ComponentAPI): void { 59 | if (!this.component) { 60 | console.warn( 61 | `[wc-dox] No component defined to extract metadata from for tag "${this.tag}" or class "${this.componentName}" in "${this.tagName.toLowerCase()}".`, 62 | ); 63 | this.metaData = []; 64 | this.updateVisibility(); 65 | return; 66 | } 67 | 68 | if (!feature) { 69 | console.warn( 70 | `[wc-dox] No feature defined to extract metadata from in "${this.tagName.toLowerCase()}".`, 71 | ); 72 | this.metaData = []; 73 | this.updateVisibility(); 74 | return; 75 | } 76 | 77 | if (feature === 'properties') { 78 | this.metaData = getComponentPublicProperties( 79 | this.component, 80 | ) as MetaData[]; 81 | this.updateVisibility(); 82 | return; 83 | } 84 | 85 | if (feature === 'methods') { 86 | this.metaData = getComponentPublicMethods(this.component) as MetaData[]; 87 | this.updateVisibility(); 88 | return; 89 | } 90 | 91 | this.metaData = this.component?.[feature] as MetaData[]; 92 | 93 | this.updateVisibility(); 94 | } 95 | 96 | protected updateVisibility(): void { 97 | if (config.hideOnEmpty && !this.metaData?.length) { 98 | this.hidden = true; 99 | } 100 | } 101 | 102 | protected getRenderTemplate(styles: CSSResult, className: string) { 103 | const heading = `h${config.headingLevel || 3}`; 104 | return html` 105 | 123 |
124 | <${unsafeStatic(heading)} class="heading ${config?.headingClass || ''}"> 125 | ${this.config?.heading} 126 | 127 | 128 | ${ 129 | this.config?.description 130 | ? unsafeHTML(markdownToHtml(this.config.description)) 131 | : '' 132 | } 133 |
134 | 135 | 136 | 137 | ${this.config?.headings?.map(x => html``)} 138 | 139 | 140 | 141 | ${unsafeHTML( 142 | this.metaData 143 | ?.map(x => this.config?.rowTemplate?.(x as never)) 144 | .join('\n') || '', 145 | )} 146 | 147 |
${x}
148 |
149 |
150 | `; 151 | } 152 | } 153 | 154 | export default WcDoxBase; 155 | -------------------------------------------------------------------------------- /.storybook/code-bubble-setup.js: -------------------------------------------------------------------------------- 1 | import { CodeBubble } from 'code-bubble'; 2 | import packageJson from '../package.json'; 3 | 4 | (async () => { 5 | async function fetchLibData(url) { 6 | const baseUrl = window.location.href.includes('localhost') 7 | ? '' 8 | : window.location.href.split('/iframe')[0]; 9 | 10 | try { 11 | const response = await fetch(baseUrl + url); // Make the request 12 | return await response.text(); // Extract JSON data 13 | } catch (error) { 14 | console.error('Error fetching data:', url, error); 15 | return null; // Handle the error gracefully 16 | } 17 | } 18 | 19 | /** @type { import('code-bubble').CodeBubbleConfig } */ 20 | new CodeBubble({ 21 | sandbox: 'stackblitz', 22 | component: { 23 | frameworkButtons: { 24 | label: framework => 25 | ({ 26 | html: 'HTML', 27 | tsx: 'React', 28 | })[framework], 29 | }, 30 | }, 31 | sandboxConfig: { 32 | /** StackBlitz sandbox configuration */ 33 | stackBlitz: { 34 | html: { 35 | project: { 36 | title: packageJson.name + ' Demo', 37 | description: 'A live web component demo', 38 | files: { 39 | [`libs/${packageJson.name}/index.js`]: 40 | await fetchLibData('/html/index.js'), 41 | }, 42 | }, 43 | exampleTemplate: { 44 | fileName: 'index.html', 45 | template: ` 46 | 47 | 48 | 49 | ${packageJson.name} Demo 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | %example% 58 | 59 | `, 60 | }, 61 | }, 62 | tsx: { 63 | project: { 64 | title: packageJson.name + ' React Demo', 65 | description: 'A live react/web component demo', 66 | files: { 67 | [`libs/${packageJson.name}/react/index.js`]: 68 | await fetchLibData('/react/index.js'), 69 | [`libs/${packageJson.name}/react/index.d.ts`]: 70 | await fetchLibData('/react/index.d.ts'), 71 | 'src/index.tsx': `import { createRoot } from "react-dom/client"; 72 | import App from "./App"; 73 | 74 | const rootElement = createRoot(document.getElementById("root")); 75 | rootElement.render();`, 76 | [`libs/${packageJson.name}/package.json`]: `{ 77 | "name": "${packageJson.name}", 78 | "version": "${packageJson.version}", 79 | "description": "A live react/web component demo", 80 | "main": "index.js" 81 | }`, 82 | 'package.json': `{ 83 | "name": "react-sandbox", 84 | "version": "1.0.0", 85 | "main": "src/index.tsx", 86 | "dependencies": { 87 | "react": "^18.2.0", 88 | "react-dom": "^18.2.0", 89 | "${packageJson.name}": "file:./libs/${packageJson.name}" 90 | }, 91 | "scripts": { 92 | "dev": "vite", 93 | "build": "vite build", 94 | "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", 95 | "preview": "vite preview" 96 | }, 97 | "devDependencies": { 98 | "@types/react": "^18.3.3", 99 | "@types/react-dom": "^18.3.0", 100 | "@typescript-eslint/eslint-plugin": "^7.15.0", 101 | "@typescript-eslint/parser": "^7.15.0", 102 | "@vitejs/plugin-react": "^4.3.1", 103 | "eslint": "^8.57.0", 104 | "eslint-plugin-react-hooks": "^4.6.2", 105 | "eslint-plugin-react-refresh": "^0.4.7", 106 | "typescript": "^5.2.2", 107 | "vite": "^5.3.2" 108 | } 109 | }`, 110 | 'tsconfig.json': `{ 111 | "include": ["./src/**/*"], 112 | "compilerOptions": { 113 | "strict": false, 114 | "esModuleInterop": true, 115 | "lib": ["ESNext", "DOM", "DOM.Iterable"], 116 | "jsx": "react-jsx", 117 | "baseUrl": "." 118 | } 119 | }`, 120 | 'vite.config.ts': `import { defineConfig } from 'vite'; 121 | import react from '@vitejs/plugin-react'; 122 | 123 | // https://vitejs.dev/config/ 124 | export default defineConfig({ 125 | plugins: [react()], 126 | });`, 127 | 'index.html': ` 128 | 129 | 130 | 131 | 132 | 133 | React code example 134 | 135 | 136 |
137 | 138 | 139 | `, 140 | }, 141 | }, 142 | exampleTemplate: { 143 | fileName: 'src/App.tsx', 144 | template: `%example%`, 145 | }, 146 | }, 147 | }, 148 | }, 149 | }); 150 | })(); 151 | -------------------------------------------------------------------------------- /src/components/imports/imports.ts: -------------------------------------------------------------------------------- 1 | import { LitElement } from 'lit'; 2 | import { property, state } from 'lit/decorators.js'; 3 | import styles from './imports.styles.js'; 4 | import { ImportsElementConfig } from '../../configs/types.js'; 5 | import { config, manifest } from '../../configs/index.js'; 6 | import { unsafeHTML } from 'lit/directives/unsafe-html.js'; 7 | import { unsafeSVG } from 'lit/directives/unsafe-svg.js'; 8 | import { markdownToHtml } from '../../utils/markdown.js'; 9 | import { html, unsafeStatic } from 'lit/static-html.js'; 10 | import * as cem from 'custom-elements-manifest/schema'; 11 | import { 12 | getComponentByClassName, 13 | getComponentByTagName, 14 | } from '@wc-toolkit/cem-utilities'; 15 | 16 | let importId = 0; 17 | 18 | /** 19 | * A component to document the ways to import a custom element 20 | * 21 | * @tag wc-imports 22 | * @since 1.0.0 23 | * @status experimental 24 | * 25 | * @cssprop [--wc-imports-border-color=#e0e0e0] - Controls the color of the divider between the tabs and tab content 26 | * @cssprop [--wc-imports-active-border-color=#0078d4] - The bottom border color of the selected tab 27 | * @cssprop [--wc-imports-border-size=2px] - the size of the border divider between the tabs and the tab content 28 | **/ 29 | export class WcImports extends LitElement { 30 | override createRenderRoot() { 31 | return this; 32 | } 33 | 34 | @property() 35 | tag?: string; 36 | 37 | @property({ attribute: 'component-name' }) 38 | componentName?: string; 39 | 40 | @state() 41 | private config?: ImportsElementConfig; 42 | 43 | @state() 44 | private selectedImport = 0; 45 | 46 | @state() 47 | copied = false; 48 | 49 | @state() 50 | component?: cem.CustomElement; 51 | 52 | public constructor() { 53 | super(); 54 | this.config = config.imports; 55 | } 56 | 57 | override connectedCallback() { 58 | super.connectedCallback(); 59 | if (!this.component) { 60 | this.component = this.tag 61 | ? getComponentByTagName(manifest, this.tag) 62 | : getComponentByClassName(manifest, this.componentName); 63 | } 64 | importId++; 65 | 66 | if (config.hideOnEmpty && !this.config?.imports?.length) { 67 | this.hidden = true; 68 | } 69 | } 70 | 71 | private handleTabClick(i: number) { 72 | this.selectedImport = i; 73 | } 74 | 75 | private handleCopyClick(content: string) { 76 | this.copied = true; 77 | navigator.clipboard.writeText(content); 78 | 79 | setTimeout(() => { 80 | this.copied = false; 81 | }, 2000); 82 | } 83 | 84 | override render() { 85 | const heading = `h${config.headingLevel || 3}`; 86 | 87 | return html` 88 | 91 |
92 | <${unsafeStatic(heading)} class="heading"> 93 | ${this.config?.heading} 94 | 95 | 96 | ${ 97 | this.config?.description 98 | ? unsafeHTML(markdownToHtml(this.config.description)) 99 | : '' 100 | } 101 |
106 | ${this.config?.imports?.map( 107 | (x, i) => 108 | html``, 119 | )} 120 |
121 | 122 | ${this.config?.imports?.map((x, i) => { 123 | const content = 124 | x.importTemplate?.( 125 | this.component?.tagName ?? '', 126 | this.component?.name ?? '', 127 | ) || ''; 128 | const lang = `language-${x.lang}`; 129 | return html`
136 |
137 |               ${content}
140 |             
141 | 154 |
`; 155 | })} 156 |
157 | `; 158 | } 159 | } 160 | 161 | export default WcImports; 162 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import { globSync } from 'glob'; 2 | import path from 'node:path'; 3 | import { fileURLToPath } from 'node:url'; 4 | import typescript from '@rollup/plugin-typescript'; 5 | import dts from 'rollup-plugin-dts'; 6 | import resolve from '@rollup/plugin-node-resolve'; 7 | import multi from '@rollup/plugin-multi-entry'; 8 | import terser from '@rollup/plugin-terser'; 9 | import summary from 'rollup-plugin-summary'; 10 | 11 | export default [ 12 | /** bundle components for the CDN */ 13 | { 14 | watch: false, 15 | input: Object.fromEntries( 16 | globSync('src/**/*.ts', { 17 | ignore: [ 18 | 'src/**/*.test.ts', 19 | 'src/**/*.stories.ts', 20 | 'src/**/*.styles.ts', 21 | ], 22 | }).map(file => [ 23 | // This remove `src/` as well as the file extension from each 24 | // file, so e.g. src/nested/foo.js becomes nested/foo 25 | path.relative( 26 | 'src', 27 | file.slice(0, file.length - path.extname(file).length), 28 | ), 29 | // This expands the relative paths to absolute paths, so e.g. 30 | // src/nested/foo becomes /project/src/nested/foo.js 31 | fileURLToPath(new URL(file, import.meta.url)), 32 | ]), 33 | ), 34 | output: { 35 | dir: 'cdn', 36 | format: 'esm', 37 | }, 38 | plugins: [ 39 | typescript({ 40 | tsconfig: 'tsconfig.json', 41 | outDir: 'cdn', 42 | sourceMap: false, 43 | declaration: false, 44 | declarationMap: false, 45 | }), 46 | resolve(), 47 | terser({ 48 | ecma: 2021, 49 | module: true, 50 | warnings: true, 51 | }), 52 | summary(), 53 | ], 54 | }, 55 | { 56 | watch: { 57 | buildDelay: 150, 58 | }, 59 | input: Object.fromEntries( 60 | globSync('src/**/*.ts', { 61 | ignore: ['src/**/*.test.ts', 'src/**/*.stories.ts'], 62 | }).map(file => [ 63 | // This remove `src/` as well as the file extension from each 64 | // file, so e.g. src/nested/foo.js becomes nested/foo 65 | path.relative( 66 | 'src', 67 | file.slice(0, file.length - path.extname(file).length), 68 | ), 69 | // This expands the relative paths to absolute paths, so e.g. 70 | // src/nested/foo becomes /project/src/nested/foo.js 71 | fileURLToPath(new URL(file, import.meta.url)), 72 | ]), 73 | ), 74 | output: { 75 | dir: 'cdn', 76 | format: 'esm', 77 | }, 78 | plugins: [ 79 | typescript({ 80 | tsconfig: 'tsconfig.json', 81 | outDir: 'cdn', 82 | sourceMap: false, 83 | declaration: false, 84 | declarationMap: false, 85 | }), 86 | resolve(), 87 | ], 88 | }, 89 | 90 | /** bundle components for sandboxes */ 91 | { 92 | watch: false, 93 | input: globSync('src/**/index.ts'), 94 | output: { 95 | format: 'esm', 96 | dir: 'public/html', 97 | }, 98 | plugins: [ 99 | typescript({ 100 | tsconfig: 'tsconfig.json', 101 | outDir: 'public/html', 102 | sourceMap: false, 103 | declaration: false, 104 | declarationMap: false, 105 | }), 106 | resolve(), 107 | multi({ 108 | entryFileName: 'index.js', 109 | }), 110 | terser({ 111 | ecma: 2021, 112 | module: true, 113 | warnings: true, 114 | }), 115 | summary(), 116 | ], 117 | }, 118 | { 119 | watch: { 120 | buildDelay: 150, 121 | }, 122 | input: globSync('src/**/index.ts'), 123 | output: { 124 | format: 'esm', 125 | dir: 'public/html', 126 | }, 127 | plugins: [ 128 | typescript({ 129 | tsconfig: 'tsconfig.json', 130 | outDir: 'public/html', 131 | sourceMap: false, 132 | declaration: false, 133 | declarationMap: false, 134 | }), 135 | resolve(), 136 | multi({ 137 | entryFileName: 'index.js', 138 | }), 139 | ], 140 | }, 141 | 142 | /** bundle react components for sandboxes */ 143 | { 144 | watch: false, 145 | input: 'react/index.js', 146 | output: { 147 | format: 'esm', 148 | file: 'public/react/index.js', 149 | sourcemap: false, 150 | }, 151 | external: ['react'], 152 | plugins: [ 153 | resolve(), 154 | terser({ 155 | ecma: 2021, 156 | module: true, 157 | warnings: true, 158 | }), 159 | summary(), 160 | ], 161 | onwarn(warning) { 162 | if ( 163 | /Could not resolve import/.test(warning.message) || 164 | /'this' keyword is equivalent to 'undefined'/.test(warning.message) 165 | ) { 166 | return; 167 | } 168 | 169 | console.error(warning.message); 170 | }, 171 | }, 172 | { 173 | watch: { 174 | buildDelay: 150, 175 | }, 176 | input: 'react/index.js', 177 | output: { 178 | format: 'esm', 179 | file: 'public/react/index.js', 180 | sourcemap: false, 181 | }, 182 | external: ['react'], 183 | plugins: [resolve()], 184 | onwarn(warning) { 185 | if ( 186 | /Could not resolve import/.test(warning.message) || 187 | /'this' keyword is equivalent to 'undefined'/.test(warning.message) 188 | ) { 189 | return; 190 | } 191 | 192 | console.error(warning.message); 193 | }, 194 | }, 195 | // bundle react component types for sandboxes 196 | { 197 | watch: false, 198 | input: './react/index.d.ts', 199 | output: [{ file: 'public/react/index.d.ts', format: 'es' }], 200 | external: ['react'], 201 | plugins: [dts(), resolve(), summary()], 202 | }, 203 | { 204 | watch: { 205 | buildDelay: 150, 206 | }, 207 | input: './react/index.d.ts', 208 | output: [{ file: 'public/react/index.d.ts', format: 'es' }], 209 | external: ['react'], 210 | plugins: [dts(), resolve()], 211 | }, 212 | ]; 213 | -------------------------------------------------------------------------------- /.storybook/custom-elements.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "readme": "", 4 | "modules": [ 5 | { 6 | "kind": "javascript-module", 7 | "path": "src/my-element.ts", 8 | "declarations": [ 9 | { 10 | "kind": "class", 11 | "description": "An sample element.", 12 | "name": "MyElement", 13 | "cssProperties": [ 14 | { 15 | "description": "The card border color", 16 | "name": "--card-border-color", 17 | "default": "#ccc" 18 | }, 19 | { 20 | "description": "The card border color", 21 | "name": "--card-border-size", 22 | "default": "1px" 23 | }, 24 | { 25 | "description": "The card border color", 26 | "name": "--card-border-style", 27 | "default": "solid" 28 | }, 29 | { 30 | "description": "The card border radius", 31 | "name": "--card-border-radius", 32 | "default": "8px" 33 | } 34 | ], 35 | "cssParts": [ 36 | { 37 | "description": "The button", 38 | "name": "button" 39 | }, 40 | { 41 | "description": "Adds custom styles to the docs hint", 42 | "name": "docs-hint" 43 | } 44 | ], 45 | "slots": [ 46 | { 47 | "description": "This adds content between the logo and the counter button", 48 | "name": "" 49 | }, 50 | { 51 | "description": "This adds extra content into the counter button", 52 | "name": "button-content" 53 | } 54 | ], 55 | "members": [ 56 | { 57 | "kind": "field", 58 | "name": "docsHint", 59 | "type": { 60 | "text": "string" 61 | }, 62 | "default": "\"Click on the Storybook logo to learn more\"", 63 | "description": "Copy for the read the docs hint.", 64 | "attribute": "docs-hint", 65 | "reflects": true 66 | }, 67 | { 68 | "kind": "field", 69 | "name": "count", 70 | "type": { 71 | "text": "number" 72 | }, 73 | "default": "0", 74 | "description": "The number of times the button has been clicked.", 75 | "attribute": "count", 76 | "reflects": true 77 | }, 78 | { 79 | "kind": "field", 80 | "name": "label", 81 | "type": { 82 | "text": "string | undefined" 83 | }, 84 | "description": "Adds a label to the component", 85 | "attribute": "label" 86 | }, 87 | { 88 | "kind": "method", 89 | "name": "increaseCount", 90 | "privacy": "public" 91 | }, 92 | { 93 | "kind": "method", 94 | "name": "decreaseCount", 95 | "privacy": "public" 96 | }, 97 | { 98 | "kind": "method", 99 | "name": "setCount", 100 | "privacy": "public", 101 | "parameters": [ 102 | { 103 | "name": "value", 104 | "type": { 105 | "text": "number" 106 | } 107 | } 108 | ] 109 | }, 110 | { 111 | "kind": "method", 112 | "name": "getCount", 113 | "privacy": "public", 114 | "return": { 115 | "type": { 116 | "text": "number" 117 | } 118 | } 119 | }, 120 | { 121 | "kind": "method", 122 | "name": "_onClick", 123 | "privacy": "private" 124 | } 125 | ], 126 | "events": [ 127 | { 128 | "name": "count", 129 | "type": { 130 | "text": "number" 131 | }, 132 | "description": "This is emitted every time the count button is clicked" 133 | } 134 | ], 135 | "attributes": [ 136 | { 137 | "name": "docs-hint", 138 | "type": { 139 | "text": "string" 140 | }, 141 | "default": "\"Click on the Storybook logo to learn more\"", 142 | "description": "Copy for the read the docs hint.", 143 | "fieldName": "docsHint" 144 | }, 145 | { 146 | "name": "count", 147 | "type": { 148 | "text": "number" 149 | }, 150 | "default": "0", 151 | "description": "The number of times the button has been clicked.", 152 | "fieldName": "count" 153 | }, 154 | { 155 | "name": "label", 156 | "type": { 157 | "text": "string | undefined" 158 | }, 159 | "description": "Adds a label to the component", 160 | "fieldName": "label" 161 | } 162 | ], 163 | "cssStates": [ 164 | { 165 | "description": "used when the component is in a valid state", 166 | "name": "success" 167 | }, 168 | { 169 | "description": "used when the component is in a invalid state", 170 | "name": "invalid" 171 | }, 172 | { 173 | "description": "used when something has gone wrong in the component", 174 | "name": "error" 175 | } 176 | ], 177 | "superclass": { 178 | "name": "LitElement", 179 | "package": "lit" 180 | }, 181 | "tagName": "my-element", 182 | "customElement": true 183 | } 184 | ], 185 | "exports": [ 186 | { 187 | "kind": "js", 188 | "name": "MyElement", 189 | "declaration": { 190 | "name": "MyElement", 191 | "module": "src/my-element.ts" 192 | } 193 | }, 194 | { 195 | "kind": "custom-element-definition", 196 | "name": "my-element", 197 | "declaration": { 198 | "name": "MyElement", 199 | "module": "src/my-element.ts" 200 | } 201 | } 202 | ] 203 | } 204 | ] 205 | } 206 | -------------------------------------------------------------------------------- /src/configs/default-values.ts: -------------------------------------------------------------------------------- 1 | import { DoxConfig } from './types'; 2 | import { markdownToHtml } from '../utils/markdown.js'; 3 | import { Parameter } from 'custom-elements-manifest'; 4 | 5 | export const defaultDoxConfig: DoxConfig = { 6 | hideOnEmpty: true, 7 | headingLevel: 3, 8 | headingClass: '', 9 | tableClass: '', 10 | dox: { 11 | apiOrder: [ 12 | 'imports', 13 | 'props', 14 | 'slots', 15 | 'methods', 16 | 'events', 17 | 'css-props', 18 | 'css-parts', 19 | 'css-states', 20 | ], 21 | }, 22 | imports: { 23 | heading: 'Imports', 24 | headingId: 'imports', 25 | description: 'You can import the component in the following ways:', 26 | copyIcon: 27 | '', 28 | copyLabel: 'Copy import', 29 | copiedIcon: 30 | '', 31 | copiedLabel: 'Import copied', 32 | imports: [], 33 | }, 34 | cssParts: { 35 | heading: 'CSS Parts', 36 | headingId: 'css-parts', 37 | skipLinkLabel: 'Skip to CSS parts', 38 | description: 39 | 'The following [CSS shadow parts](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_shadow_parts) are available to customize the component:', 40 | headings: ['Name', 'Description', 'Deprecated'], 41 | rowTemplate: cssPart => 42 | ` 43 |

${cssPart.name}

44 | ${markdownToHtml(cssPart.description || '')} 45 | ${cssPart.deprecated ? '✔️' : ''} 46 | `, 47 | }, 48 | cssProps: { 49 | heading: 'CSS Custom Properties', 50 | headingId: 'css-props', 51 | skipLinkLabel: 'Skip to CSS custom properties', 52 | description: 53 | 'You can use [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) to customize the look and feel of the component using the following properties:', 54 | headings: ['Name', 'Default', 'Description', 'Deprecated'], 55 | rowTemplate: cssVar => 56 | ` 57 |

${cssVar.name}

58 |

${cssVar.default}

59 | ${markdownToHtml(cssVar.description || '')} 60 | ${cssVar.deprecated ? '✔️' : ''} 61 | `, 62 | }, 63 | events: { 64 | heading: 'Events', 65 | headingId: 'events', 66 | skipLinkLabel: 'Skip to events', 67 | description: 68 | 'The following [events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events) are emitted by the component:', 69 | headings: ['Name', 'Type', 'Description', 'Deprecated'], 70 | rowTemplate: event => 71 | ` 72 |

${event.name}

73 |

${event.type.text === 'CustomEvent' ? 'CustomEvent' : `CustomEvent<${event.type.text}>`}

74 | ${markdownToHtml(event.description || '')} 75 | ${event.deprecated ? '✔️' : ''} 76 | `, 77 | }, 78 | methods: { 79 | heading: 'Methods', 80 | headingId: 'methods', 81 | skipLinkLabel: 'Skip to methods', 82 | description: 'The following Methods are available:', 83 | headings: ['Name', 'Description', 'Deprecated'], 84 | rowTemplate: method => { 85 | const getParameter = (p: Parameter) => p.name + getParamType(p) + getParamDefaultValue(p); 86 | const getParamType = (p: Parameter) => p.type?.text ? `${p.optional ? '?' : ''}: ${p.type?.text}` : ''; 87 | const getParamDefaultValue = (p: Parameter) => p.default ? ` = ${p.default}` : ''; 88 | return ` 89 |

${method.name}(${method.parameters?.map(p => getParameter(p)).join(', ') || ''}) => ${method.return?.type?.text || 'void'}

90 | ${markdownToHtml(method.description || '')} 91 | ${method.deprecated ? '✔️' : ''} 92 | `; 93 | } 94 | }, 95 | props: { 96 | heading: 'Attributes and Properties', 97 | headingId: 'props', 98 | skipLinkLabel: 'Skip to attributes and properties', 99 | description: 'The following Properties and Attributes are available:', 100 | headings: [ 101 | 'Name', 102 | 'Attribute', 103 | 'Description', 104 | 'Type', 105 | 'Default', 106 | 'Read-only', 107 | 'Deprecated', 108 | ], 109 | rowTemplate: prop => 110 | ` 111 |

${prop.name}

112 |

${prop.attribute || ''}

113 | ${markdownToHtml(prop.description || '')} 114 |

${prop.type?.text || ''}

115 |

${prop.default}

116 | ${prop.readonly ? '✔️' : ''} 117 | ${prop.deprecated ? '✔️' : ''} 118 | `, 119 | }, 120 | slots: { 121 | heading: 'Slots', 122 | headingId: 'slots', 123 | skipLinkLabel: 'Skip to slots', 124 | description: 'The following slots are available:', 125 | headings: ['Name', 'Description', 'Deprecated'], 126 | rowTemplate: slot => 127 | ` 128 |

${slot.name || '(default)'}

129 | ${markdownToHtml(slot.description || '')} 130 | ${slot.deprecated ? '✔️' : ''} 131 | `, 132 | }, 133 | cssStates: { 134 | heading: 'CSS States', 135 | headingId: 'css-states', 136 | skipLinkLabel: 'Skip to CSS states', 137 | description: 138 | 'The following [CSS states](https://developer.mozilla.org/en-US/docs/Web/CSS/:state) can be used to customize component styles:', 139 | headings: ['Name', 'Description', 'Deprecated'], 140 | rowTemplate: state => 141 | ` 142 |

${state.name}

143 | ${markdownToHtml(state.description || '')} 144 | ${state.deprecated ? '✔️' : ''} 145 | `, 146 | }, 147 | }; 148 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ES2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 15 | "lib": [ 16 | "ES2020", 17 | "DOM", 18 | "DOM.Iterable" 19 | ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, 20 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 21 | "experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */, 22 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 23 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 24 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 25 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 26 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 27 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 28 | "useDefineForClassFields": false /* Emit ECMAScript-standard-compliant class fields. */, 29 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 30 | 31 | /* Modules */ 32 | "module": "ESNext" /* Specify what module code is generated. */, 33 | "rootDir": "./src" /* Specify the root folder within your source files. */, 34 | "moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */, 35 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 36 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 37 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 38 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 39 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 40 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 41 | "moduleSuffixes": [] /* List of file name suffixes to search when resolving a module. */, 42 | "resolveJsonModule": true /* Enable importing .json files. */, 43 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 44 | 45 | /* JavaScript Support */ 46 | "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */, 47 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 48 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 49 | 50 | /* Emit */ 51 | "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, 52 | "declarationMap": true /* Create sourcemaps for d.ts files. */, 53 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 54 | "sourceMap": true /* Create source map files for emitted JavaScript files. */, 55 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 56 | "outDir": "./dist" /* Specify an output folder for all emitted files. */, 57 | // "removeComments": true, /* Disable emitting comments. */ 58 | // "noEmit": true, /* Disable emitting files from a compilation. */ 59 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 60 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 61 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 62 | // "sourceRoot": "/src", /* Specify the root path for debuggers to find the reference source code. */ 63 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 64 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 65 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 66 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 67 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 68 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 69 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 70 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 71 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 72 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 73 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 74 | 75 | /* Interop Constraints */ 76 | "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, 77 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 78 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 79 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 80 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 81 | 82 | /* Type Checking */ 83 | "strict": true /* Enable all strict type-checking options. */, 84 | "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */, 85 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 86 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 87 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 88 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 89 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 90 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 91 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 92 | "noUnusedLocals": true /* Enable error reporting when local variables aren't read. */, 93 | "noUnusedParameters": true /* Raise an error when a function parameter isn't read. */, 94 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 95 | "noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */, 96 | "noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */, 97 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 98 | "noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */, 99 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 100 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 101 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 102 | 103 | /* Completeness */ 104 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 105 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 106 | }, 107 | "include": ["src"], 108 | "exclude": ["**/*.stories.ts", "**/*.test.ts"] 109 | } 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Web Component Documentation (`wc-dox`) 2 | 3 | The `wc-dox` package and it's components are designed to be a way to quickly and consistently document your custom element APIs using the [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest). 4 | 5 | > If you're not already generating a Custom Elements Manifest, [here is a list of options](https://dev.to/stuffbreaker/you-should-be-shipping-a-manifest-with-your-web-components-2da0) you can use to generate one. 6 | 7 | ![demo of documentation output](https://github.com/break-stuff/wc-dox/blob/main/assets/demo.gif?raw=true) 8 | 9 |
10 | 11 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/github-tdtmrsak-3eijkyac?file=src%2Fmy-element.mdx) 12 | 13 |
14 | 15 | ## Installation 16 | 17 | ```bash 18 | npm i wc-dox 19 | ``` 20 | 21 | You can also use the package directly from a CDN: 22 | 23 | ```html 24 | 25 | ``` 26 | 27 | ## Prerequisites 28 | 29 | This package requires a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to function. If you don't have one yet, you'll need to generate it using one of these tools: 30 | 31 | - [@custom-elements-manifest/analyzer](https://custom-elements-manifest.open-wc.org/analyzer/getting-started/) - The official analyzer 32 | - [CEM Analyzer Plugins](https://custom-elements-manifest.open-wc.org/analyzer/plugins/intro/) - Extend the analyzer with additional functionality 33 | 34 | ## Usage 35 | 36 | After installing, you can load the documentation at the root of your project. 37 | 38 | ```ts 39 | import { setWcDoxConfig } from 'wc-dox/index.js'; 40 | import manifest from './custom-elements.json' with { type: 'json' }; 41 | 42 | setWcDoxConfig(manifest); 43 | ``` 44 | 45 | Now that it's loaded, you can load the appropriate documentation by passing the component's tag name or class name to the component. 46 | 47 | ```html 48 | 49 | 50 | 51 | 52 | 53 | ``` 54 | 55 | > **Note:** You must specify either the `tag` attribute or the `component-name` attribute for the component to work properly. 56 | 57 | ### Framework Integration 58 | 59 | #### React 60 | 61 | If you're using React, you can import the React wrapper components: 62 | 63 | ```jsx 64 | import { WcDox } from 'wc-dox/react'; 65 | import manifest from './custom-elements.json' with { type: 'json' }; 66 | import { setWcDoxConfig } from 'wc-dox'; 67 | 68 | setWcDoxConfig(manifest); 69 | 70 | function App() { 71 | return ; 72 | } 73 | ``` 74 | 75 | The package includes React wrappers for all components: `WcDox`, `WcCssParts`, `WcCssProps`, `WcCssStates`, `WcEvents`, `WcImports`, `WcMethods`, `WcProps`, and `WcSlots`. 76 | 77 | ## Component Attributes 78 | 79 | All documentation components accept the following attributes: 80 | 81 | ### `tag` (optional) 82 | The tag name of the component to document. This should match the tag name defined in your custom elements manifest (typically from the `@tag` or `@tagname` JSDoc comment). 83 | 84 | ```html 85 | 86 | ``` 87 | 88 | ### `component-name` (optional) 89 | The JavaScript class name of the component to document. Use this when you don't have a tag name or prefer to reference by class name. 90 | 91 | ```html 92 | 93 | ``` 94 | 95 | > **Important:** You must provide either `tag` or `component-name` for the component to display documentation. 96 | 97 | ### Content is in the Light DOM 98 | 99 | The content generated by these components is all render in the light DOM so that styles can be easily inherited from the rest of your application or so that customizations can easily be applied. 100 | 101 | ### Flexible Implementation 102 | 103 | The `` element should be all that you need, but if you eed more flexibility, each of the sections can also be used independently as individual components. 104 | 105 | ```html 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | ``` 130 | 131 | ## Quick Reference 132 | 133 | - [Installation](#installation) - How to install the package 134 | - [Prerequisites](#prerequisites) - Required dependencies 135 | - [Usage](#usage) - Basic usage examples 136 | - [Framework Integration](#framework-integration) - Using with React and other frameworks 137 | - [Component Attributes](#component-attributes) - Available attributes 138 | - [Configuration](#configuration) - Customizing the output 139 | - [Styling](#styling) - Applying custom styles 140 | - [Examples](#examples) - Real-world usage examples 141 | - [Troubleshooting](#troubleshooting) - Common issues and solutions 142 | - [TypeScript Support](#typescript-support) - Using with TypeScript 143 | - [API Reference](#configuration) - Complete configuration options 144 | 145 | ## Configuration 146 | 147 | The `setWcDoxConfig` function can take a second parameter to configure the documentation. 148 | 149 | The `` and `` components have unique configurations, but the others follow a consistent API. 150 | 151 | ```ts 152 | import { setWcDoxConfig, DoxConfig } from 'wc-dox/index.js'; 153 | import manifest from './custom-elements.json' with { type: 'json' }; 154 | 155 | const options: DoxConfig = {}; 156 | 157 | setWcDoxConfig(manifest, options); 158 | ``` 159 | 160 | ```ts 161 | type DoxConfig = { 162 | /** Hides a section of the documentation if it has no content */ 163 | hideOnEmpty?: boolean; 164 | /** Configures the heading level for the API sections - default is 3 */ 165 | headingLevel?: 1 | 2 | 3 | 4 | 5 | 6; 166 | /** Configures the CSS class for the API section headings */ 167 | headingClass?: string; 168 | /** Configures the CSS class for the API section tables */ 169 | tableClass?: string; 170 | /** Configures the `wc-dox` component contents */ 171 | dox?: DoxElementConfig; 172 | /** Configures the `wc-imports` component contents */ 173 | imports?: ImportsElementConfig; 174 | /** Configures the `wc-css-parts` component contents */ 175 | cssParts?: CssPartsElementConfig; 176 | /** Configures the `wc-css-props` component contents */ 177 | cssProps?: CssPropsElementConfig; 178 | /** Configures the `wc-css-states` component contents */ 179 | cssStates?: StatesElementConfig; 180 | /** Configures the `wc-events` component contents */ 181 | events?: EventsElementConfig; 182 | /** Configures the `wc-methods` component contents */ 183 | methods?: MethodsElementConfig; 184 | /** Configures the `wc-props` component contents */ 185 | props?: PropsElementConfig; 186 | /** Configures the `wc-slots` component contents */ 187 | slots?: SlotsElementConfig; 188 | }; 189 | ``` 190 | 191 | ### Hide Empty Sections 192 | 193 | By default, sections with no content are hidden. You can control this behavior with the `hideOnEmpty` option: 194 | 195 | ```ts 196 | setWcDoxConfig(manifest, { 197 | hideOnEmpty: false, // Show all sections even if empty 198 | }); 199 | ``` 200 | 201 | ### Custom CSS Classes 202 | 203 | You can apply custom CSS classes to the generated headings and tables: 204 | 205 | ```ts 206 | setWcDoxConfig(manifest, { 207 | headingClass: 'my-custom-heading', 208 | tableClass: 'my-custom-table', 209 | }); 210 | ``` 211 | 212 | ### Heading Level 213 | 214 | The `headingLevel` setting controls the heading level for each of the sections of the API sections. 215 | 216 | ### Dox Element Config 217 | 218 | The `` element works as a wrapper for the API components. The `apiOrder` setting controls the order in which the API sections are rendered. If you do not want a section to render at all, you can exclude it from the array. 219 | 220 | ```ts 221 | type DoxElementConfig = { 222 | /** 223 | * Controls the order in which the API documentation sections are displayed 224 | * 225 | * Default value is ['imports', 'props', 'slots', 'methods', 'events', 'css-props', 'css-parts', 'css-states'] 226 | */ 227 | apiOrder?: Array< 228 | | 'imports' 229 | | 'props' 230 | | 'slots' 231 | | 'methods' 232 | | 'events' 233 | | 'css-props' 234 | | 'css-parts' 235 | | 'css-states' 236 | >; 237 | }; 238 | ``` 239 | 240 | ### Imports Element Config 241 | 242 | The imports element is a way for you to document the various ways to import your components. Each of the imports will be displayed in it's own tab. 243 | 244 | ```ts 245 | type ImportsElementConfig = { 246 | /** The heading for the imports section */ 247 | heading?: string; 248 | /** The ID used for the skip-link */ 249 | headingId?: string; 250 | /** The description for the imports section */ 251 | description?: string; 252 | /** The copy button icon */ 253 | copyIcon?: string; 254 | /** The copy button label */ 255 | copyLabel?: string; 256 | /** The icon displayed when the content is copied */ 257 | copiedIcon?: string; 258 | /** The label used when the content is copied */ 259 | copiedLabel?: string; 260 | /** Sets the language class on `pre` tag instead of `code` tag */ 261 | langOnPreTag?: boolean; 262 | /** The list of import options */ 263 | imports?: ImportConfig[]; 264 | }; 265 | 266 | type ImportConfig = { 267 | /** The text displayed in the tab option */ 268 | label?: string; 269 | /** The language the code - `html`, `js`, `ts`, etc. */ 270 | lang?: string; 271 | /** An additional description that is specific to this import */ 272 | description?: string; 273 | /** 274 | * Use this function to specify import information for a given language. The tag and class names can be used to create dynamic component-specific import paths. 275 | * @param tagName The tag name specified using the @tag or @tagName in the component's jsDoc 276 | * @param className The JS class name for the component 277 | * @returns string 278 | */ 279 | importTemplate?: (tagName: string, className: string) => string; 280 | }; 281 | ``` 282 | 283 | Here's a sample configuration: 284 | 285 | ```ts 286 | imports: { 287 | heading: 'Imports', 288 | headingId: 'imports', 289 | description: 'You can import the component in the following ways:', 290 | copyIcon: 291 | '', 292 | copyLabel: 'Copy import', 293 | copiedIcon: 294 | '', 295 | copiedLabel: 'Import copied', 296 | imports: [ 297 | { 298 | label: 'HTML', 299 | lang: 'html', 300 | importTemplate: (tagName, className) => 301 | ` 652 | 653 | 654 |

My Button Component

655 | 656 | 657 |

My Input Component

658 | 659 | 660 | 661 | ``` 662 | 663 | ### Customized Configuration 664 | 665 | ```ts 666 | import { setWcDoxConfig, markdownToHtml } from 'wc-dox/index.js'; 667 | import manifest from './custom-elements.json' with { type: 'json' }; 668 | 669 | setWcDoxConfig(manifest, { 670 | headingLevel: 2, 671 | headingClass: 'api-heading', 672 | tableClass: 'api-table', 673 | hideOnEmpty: true, 674 | dox: { 675 | apiOrder: ['props', 'events', 'methods', 'slots', 'css-props', 'css-parts'], 676 | }, 677 | props: { 678 | heading: 'Properties & Attributes', 679 | description: 'Configure the component using these properties:', 680 | }, 681 | events: { 682 | heading: 'Custom Events', 683 | description: 'Listen for these events:', 684 | }, 685 | }); 686 | ``` 687 | 688 | ### Individual Component Usage 689 | 690 | ```html 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | ``` 700 | 701 | ## Contributing 702 | 703 | Contributions are welcome! Please feel free to submit a Pull Request. 704 | 705 | ## License 706 | 707 | MIT License - see the [LICENSE](LICENSE) file for details. 708 | 709 | ## Related Projects 710 | 711 | - [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) - The schema and spec 712 | - [@custom-elements-manifest/analyzer](https://custom-elements-manifest.open-wc.org/) - Generate custom elements manifests 713 | - [Lit](https://lit.dev/) - The library used to build these components 714 | 715 | ## Changelog 716 | 717 | See [CHANGELOG.md](CHANGELOG.md) for version history and updates. 718 | -------------------------------------------------------------------------------- /custom-elements.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "readme": "", 4 | "modules": [ 5 | { 6 | "kind": "javascript-module", 7 | "path": "src/components/base/dox-base.ts", 8 | "declarations": [ 9 | { 10 | "kind": "class", 11 | "description": "This base class is to isolate reusable code for the dox components.", 12 | "name": "WcDoxBase", 13 | "members": [ 14 | { 15 | "kind": "field", 16 | "name": "component", 17 | "type": { 18 | "text": "Component | undefined" 19 | }, 20 | "privacy": "public", 21 | "description": "The component data" 22 | }, 23 | { 24 | "kind": "field", 25 | "name": "componentName", 26 | "type": { 27 | "text": "string | undefined" 28 | }, 29 | "privacy": "public", 30 | "description": "The name of the component class", 31 | "attribute": "component-name" 32 | }, 33 | { 34 | "kind": "field", 35 | "name": "config", 36 | "type": { 37 | "text": "Config | undefined" 38 | }, 39 | "privacy": "protected" 40 | }, 41 | { 42 | "kind": "field", 43 | "name": "feature", 44 | "type": { 45 | "text": "ComponentAPI | undefined" 46 | }, 47 | "privacy": "protected", 48 | "parsedType": { 49 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 50 | } 51 | }, 52 | { 53 | "kind": "method", 54 | "name": "getRenderTemplate", 55 | "privacy": "protected", 56 | "parameters": [ 57 | { 58 | "name": "styles", 59 | "type": { 60 | "text": "CSSResult" 61 | } 62 | }, 63 | { 64 | "name": "className", 65 | "type": { 66 | "text": "string" 67 | } 68 | } 69 | ] 70 | }, 71 | { 72 | "kind": "field", 73 | "name": "metaData", 74 | "type": { 75 | "text": "MetaData[] | undefined" 76 | }, 77 | "privacy": "protected" 78 | }, 79 | { 80 | "kind": "field", 81 | "name": "tag", 82 | "type": { 83 | "text": "string | undefined" 84 | }, 85 | "privacy": "public", 86 | "description": "The tag name of the custom element", 87 | "attribute": "tag" 88 | }, 89 | { 90 | "kind": "method", 91 | "name": "updateMetaData", 92 | "privacy": "protected", 93 | "return": { 94 | "type": { 95 | "text": "void" 96 | } 97 | }, 98 | "parameters": [ 99 | { 100 | "name": "feature", 101 | "optional": true, 102 | "type": { 103 | "text": "ComponentAPI" 104 | } 105 | } 106 | ] 107 | }, 108 | { 109 | "kind": "method", 110 | "name": "updateVisibility", 111 | "privacy": "protected", 112 | "return": { 113 | "type": { 114 | "text": "void" 115 | } 116 | } 117 | } 118 | ], 119 | "attributes": [ 120 | { 121 | "name": "component-name", 122 | "type": { 123 | "text": "string | undefined" 124 | }, 125 | "description": "The name of the component class", 126 | "fieldName": "componentName" 127 | }, 128 | { 129 | "name": "tag", 130 | "type": { 131 | "text": "string | undefined" 132 | }, 133 | "description": "The tag name of the custom element", 134 | "fieldName": "tag" 135 | } 136 | ], 137 | "superclass": { 138 | "name": "LitElement", 139 | "package": "lit" 140 | }, 141 | "customElement": true, 142 | "modulePath": "src/components/base/dox-base.ts" 143 | } 144 | ], 145 | "exports": [ 146 | { 147 | "kind": "js", 148 | "name": "default", 149 | "declaration": { 150 | "name": "WcDoxBase", 151 | "module": "src/components/base/dox-base.ts" 152 | } 153 | }, 154 | { 155 | "kind": "js", 156 | "name": "WcDoxBase", 157 | "declaration": { 158 | "name": "WcDoxBase", 159 | "module": "src/components/base/dox-base.ts" 160 | } 161 | } 162 | ] 163 | }, 164 | { 165 | "kind": "javascript-module", 166 | "path": "src/components/css-parts/css-parts.ts", 167 | "declarations": [ 168 | { 169 | "kind": "class", 170 | "description": "A component to document the CSS Parts of a custom element", 171 | "name": "WcCssParts", 172 | "members": [ 173 | { 174 | "kind": "field", 175 | "name": "component", 176 | "type": { 177 | "text": "Component | undefined" 178 | }, 179 | "privacy": "public", 180 | "description": "The component data", 181 | "inheritedFrom": { 182 | "name": "WcDoxBase", 183 | "module": "src/components/base/dox-base.ts" 184 | } 185 | }, 186 | { 187 | "kind": "field", 188 | "name": "componentName", 189 | "type": { 190 | "text": "string | undefined" 191 | }, 192 | "privacy": "public", 193 | "description": "The name of the component class", 194 | "attribute": "component-name", 195 | "inheritedFrom": { 196 | "name": "WcDoxBase", 197 | "module": "src/components/base/dox-base.ts" 198 | } 199 | }, 200 | { 201 | "kind": "field", 202 | "name": "config", 203 | "type": { 204 | "text": "Config | undefined" 205 | }, 206 | "privacy": "protected", 207 | "inheritedFrom": { 208 | "name": "WcDoxBase", 209 | "module": "src/components/base/dox-base.ts" 210 | } 211 | }, 212 | { 213 | "kind": "field", 214 | "name": "feature", 215 | "type": { 216 | "text": "ComponentAPI | undefined" 217 | }, 218 | "privacy": "protected", 219 | "parsedType": { 220 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 221 | }, 222 | "default": "'cssParts'", 223 | "inheritedFrom": { 224 | "name": "WcDoxBase", 225 | "module": "src/components/base/dox-base.ts" 226 | } 227 | }, 228 | { 229 | "kind": "method", 230 | "name": "getRenderTemplate", 231 | "privacy": "protected", 232 | "parameters": [ 233 | { 234 | "name": "styles", 235 | "type": { 236 | "text": "CSSResult" 237 | } 238 | }, 239 | { 240 | "name": "className", 241 | "type": { 242 | "text": "string" 243 | } 244 | } 245 | ], 246 | "inheritedFrom": { 247 | "name": "WcDoxBase", 248 | "module": "src/components/base/dox-base.ts" 249 | } 250 | }, 251 | { 252 | "kind": "field", 253 | "name": "metaData", 254 | "type": { 255 | "text": "MetaData[] | undefined" 256 | }, 257 | "privacy": "protected", 258 | "inheritedFrom": { 259 | "name": "WcDoxBase", 260 | "module": "src/components/base/dox-base.ts" 261 | } 262 | }, 263 | { 264 | "kind": "field", 265 | "name": "tag", 266 | "type": { 267 | "text": "string | undefined" 268 | }, 269 | "privacy": "public", 270 | "description": "The tag name of the custom element", 271 | "attribute": "tag", 272 | "inheritedFrom": { 273 | "name": "WcDoxBase", 274 | "module": "src/components/base/dox-base.ts" 275 | } 276 | }, 277 | { 278 | "kind": "method", 279 | "name": "updateMetaData", 280 | "privacy": "protected", 281 | "return": { 282 | "type": { 283 | "text": "void" 284 | } 285 | }, 286 | "parameters": [ 287 | { 288 | "name": "feature", 289 | "optional": true, 290 | "type": { 291 | "text": "ComponentAPI" 292 | } 293 | } 294 | ], 295 | "inheritedFrom": { 296 | "name": "WcDoxBase", 297 | "module": "src/components/base/dox-base.ts" 298 | } 299 | }, 300 | { 301 | "kind": "method", 302 | "name": "updateVisibility", 303 | "privacy": "protected", 304 | "return": { 305 | "type": { 306 | "text": "void" 307 | } 308 | }, 309 | "inheritedFrom": { 310 | "name": "WcDoxBase", 311 | "module": "src/components/base/dox-base.ts" 312 | } 313 | } 314 | ], 315 | "superclass": { 316 | "name": "WcDoxBase", 317 | "module": "/src/components/base/dox-base.js" 318 | }, 319 | "tagName": "wc-css-parts", 320 | "customElement": true, 321 | "since": { 322 | "name": "1.0.0", 323 | "description": "" 324 | }, 325 | "status": { 326 | "name": "experimental", 327 | "description": "" 328 | }, 329 | "attributes": [ 330 | { 331 | "name": "component-name", 332 | "type": { 333 | "text": "string | undefined" 334 | }, 335 | "description": "The name of the component class", 336 | "fieldName": "componentName", 337 | "inheritedFrom": { 338 | "name": "WcDoxBase", 339 | "module": "src/components/base/dox-base.ts" 340 | }, 341 | "propName": "componentName" 342 | }, 343 | { 344 | "name": "tag", 345 | "type": { 346 | "text": "string | undefined" 347 | }, 348 | "description": "The tag name of the custom element", 349 | "fieldName": "tag", 350 | "inheritedFrom": { 351 | "name": "WcDoxBase", 352 | "module": "src/components/base/dox-base.ts" 353 | }, 354 | "propName": "tag" 355 | } 356 | ], 357 | "modulePath": "src/components/css-parts/css-parts.ts" 358 | } 359 | ], 360 | "exports": [ 361 | { 362 | "kind": "js", 363 | "name": "default", 364 | "declaration": { 365 | "name": "WcCssParts", 366 | "module": "src/components/css-parts/css-parts.ts" 367 | } 368 | }, 369 | { 370 | "kind": "js", 371 | "name": "WcCssParts", 372 | "declaration": { 373 | "name": "WcCssParts", 374 | "module": "src/components/css-parts/css-parts.ts" 375 | } 376 | } 377 | ] 378 | }, 379 | { 380 | "kind": "javascript-module", 381 | "path": "src/components/css-props/css-props.ts", 382 | "declarations": [ 383 | { 384 | "kind": "class", 385 | "description": "A component to document the CSS custom properties of a custom element", 386 | "name": "WcCssProps", 387 | "members": [ 388 | { 389 | "kind": "field", 390 | "name": "component", 391 | "type": { 392 | "text": "Component | undefined" 393 | }, 394 | "privacy": "public", 395 | "description": "The component data", 396 | "inheritedFrom": { 397 | "name": "WcDoxBase", 398 | "module": "src/components/base/dox-base.ts" 399 | } 400 | }, 401 | { 402 | "kind": "field", 403 | "name": "componentName", 404 | "type": { 405 | "text": "string | undefined" 406 | }, 407 | "privacy": "public", 408 | "description": "The name of the component class", 409 | "attribute": "component-name", 410 | "inheritedFrom": { 411 | "name": "WcDoxBase", 412 | "module": "src/components/base/dox-base.ts" 413 | } 414 | }, 415 | { 416 | "kind": "field", 417 | "name": "config", 418 | "type": { 419 | "text": "Config | undefined" 420 | }, 421 | "privacy": "protected", 422 | "inheritedFrom": { 423 | "name": "WcDoxBase", 424 | "module": "src/components/base/dox-base.ts" 425 | } 426 | }, 427 | { 428 | "kind": "field", 429 | "name": "feature", 430 | "type": { 431 | "text": "ComponentAPI | undefined" 432 | }, 433 | "privacy": "protected", 434 | "parsedType": { 435 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 436 | }, 437 | "default": "'cssProperties'", 438 | "inheritedFrom": { 439 | "name": "WcDoxBase", 440 | "module": "src/components/base/dox-base.ts" 441 | } 442 | }, 443 | { 444 | "kind": "method", 445 | "name": "getRenderTemplate", 446 | "privacy": "protected", 447 | "parameters": [ 448 | { 449 | "name": "styles", 450 | "type": { 451 | "text": "CSSResult" 452 | } 453 | }, 454 | { 455 | "name": "className", 456 | "type": { 457 | "text": "string" 458 | } 459 | } 460 | ], 461 | "inheritedFrom": { 462 | "name": "WcDoxBase", 463 | "module": "src/components/base/dox-base.ts" 464 | } 465 | }, 466 | { 467 | "kind": "field", 468 | "name": "metaData", 469 | "type": { 470 | "text": "MetaData[] | undefined" 471 | }, 472 | "privacy": "protected", 473 | "inheritedFrom": { 474 | "name": "WcDoxBase", 475 | "module": "src/components/base/dox-base.ts" 476 | } 477 | }, 478 | { 479 | "kind": "field", 480 | "name": "tag", 481 | "type": { 482 | "text": "string | undefined" 483 | }, 484 | "privacy": "public", 485 | "description": "The tag name of the custom element", 486 | "attribute": "tag", 487 | "inheritedFrom": { 488 | "name": "WcDoxBase", 489 | "module": "src/components/base/dox-base.ts" 490 | } 491 | }, 492 | { 493 | "kind": "method", 494 | "name": "updateMetaData", 495 | "privacy": "protected", 496 | "return": { 497 | "type": { 498 | "text": "void" 499 | } 500 | }, 501 | "parameters": [ 502 | { 503 | "name": "feature", 504 | "optional": true, 505 | "type": { 506 | "text": "ComponentAPI" 507 | } 508 | } 509 | ], 510 | "inheritedFrom": { 511 | "name": "WcDoxBase", 512 | "module": "src/components/base/dox-base.ts" 513 | } 514 | }, 515 | { 516 | "kind": "method", 517 | "name": "updateVisibility", 518 | "privacy": "protected", 519 | "return": { 520 | "type": { 521 | "text": "void" 522 | } 523 | }, 524 | "inheritedFrom": { 525 | "name": "WcDoxBase", 526 | "module": "src/components/base/dox-base.ts" 527 | } 528 | } 529 | ], 530 | "superclass": { 531 | "name": "WcDoxBase", 532 | "module": "/src/components/base/dox-base.js" 533 | }, 534 | "tagName": "wc-css-props", 535 | "customElement": true, 536 | "since": { 537 | "name": "1.0.0", 538 | "description": "" 539 | }, 540 | "status": { 541 | "name": "experimental", 542 | "description": "" 543 | }, 544 | "attributes": [ 545 | { 546 | "name": "component-name", 547 | "type": { 548 | "text": "string | undefined" 549 | }, 550 | "description": "The name of the component class", 551 | "fieldName": "componentName", 552 | "inheritedFrom": { 553 | "name": "WcDoxBase", 554 | "module": "src/components/base/dox-base.ts" 555 | }, 556 | "propName": "componentName" 557 | }, 558 | { 559 | "name": "tag", 560 | "type": { 561 | "text": "string | undefined" 562 | }, 563 | "description": "The tag name of the custom element", 564 | "fieldName": "tag", 565 | "inheritedFrom": { 566 | "name": "WcDoxBase", 567 | "module": "src/components/base/dox-base.ts" 568 | }, 569 | "propName": "tag" 570 | } 571 | ], 572 | "modulePath": "src/components/css-props/css-props.ts" 573 | } 574 | ], 575 | "exports": [ 576 | { 577 | "kind": "js", 578 | "name": "default", 579 | "declaration": { 580 | "name": "WcCssProps", 581 | "module": "src/components/css-props/css-props.ts" 582 | } 583 | }, 584 | { 585 | "kind": "js", 586 | "name": "WcCssProps", 587 | "declaration": { 588 | "name": "WcCssProps", 589 | "module": "src/components/css-props/css-props.ts" 590 | } 591 | } 592 | ] 593 | }, 594 | { 595 | "kind": "javascript-module", 596 | "path": "src/components/css-states/css-states.ts", 597 | "declarations": [ 598 | { 599 | "kind": "class", 600 | "description": "A component to document the CSS custom states of a custom element", 601 | "name": "WcCssStates", 602 | "members": [ 603 | { 604 | "kind": "field", 605 | "name": "component", 606 | "type": { 607 | "text": "Component | undefined" 608 | }, 609 | "privacy": "public", 610 | "description": "The component data", 611 | "inheritedFrom": { 612 | "name": "WcDoxBase", 613 | "module": "src/components/base/dox-base.ts" 614 | } 615 | }, 616 | { 617 | "kind": "field", 618 | "name": "componentName", 619 | "type": { 620 | "text": "string | undefined" 621 | }, 622 | "privacy": "public", 623 | "description": "The name of the component class", 624 | "attribute": "component-name", 625 | "inheritedFrom": { 626 | "name": "WcDoxBase", 627 | "module": "src/components/base/dox-base.ts" 628 | } 629 | }, 630 | { 631 | "kind": "field", 632 | "name": "config", 633 | "type": { 634 | "text": "Config | undefined" 635 | }, 636 | "privacy": "protected", 637 | "inheritedFrom": { 638 | "name": "WcDoxBase", 639 | "module": "src/components/base/dox-base.ts" 640 | } 641 | }, 642 | { 643 | "kind": "field", 644 | "name": "feature", 645 | "type": { 646 | "text": "ComponentAPI | undefined" 647 | }, 648 | "privacy": "protected", 649 | "parsedType": { 650 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 651 | }, 652 | "default": "'cssStates'", 653 | "inheritedFrom": { 654 | "name": "WcDoxBase", 655 | "module": "src/components/base/dox-base.ts" 656 | } 657 | }, 658 | { 659 | "kind": "method", 660 | "name": "getRenderTemplate", 661 | "privacy": "protected", 662 | "parameters": [ 663 | { 664 | "name": "styles", 665 | "type": { 666 | "text": "CSSResult" 667 | } 668 | }, 669 | { 670 | "name": "className", 671 | "type": { 672 | "text": "string" 673 | } 674 | } 675 | ], 676 | "inheritedFrom": { 677 | "name": "WcDoxBase", 678 | "module": "src/components/base/dox-base.ts" 679 | } 680 | }, 681 | { 682 | "kind": "field", 683 | "name": "metaData", 684 | "type": { 685 | "text": "MetaData[] | undefined" 686 | }, 687 | "privacy": "protected", 688 | "inheritedFrom": { 689 | "name": "WcDoxBase", 690 | "module": "src/components/base/dox-base.ts" 691 | } 692 | }, 693 | { 694 | "kind": "field", 695 | "name": "tag", 696 | "type": { 697 | "text": "string | undefined" 698 | }, 699 | "privacy": "public", 700 | "description": "The tag name of the custom element", 701 | "attribute": "tag", 702 | "inheritedFrom": { 703 | "name": "WcDoxBase", 704 | "module": "src/components/base/dox-base.ts" 705 | } 706 | }, 707 | { 708 | "kind": "method", 709 | "name": "updateMetaData", 710 | "privacy": "protected", 711 | "return": { 712 | "type": { 713 | "text": "void" 714 | } 715 | }, 716 | "parameters": [ 717 | { 718 | "name": "feature", 719 | "optional": true, 720 | "type": { 721 | "text": "ComponentAPI" 722 | } 723 | } 724 | ], 725 | "inheritedFrom": { 726 | "name": "WcDoxBase", 727 | "module": "src/components/base/dox-base.ts" 728 | } 729 | }, 730 | { 731 | "kind": "method", 732 | "name": "updateVisibility", 733 | "privacy": "protected", 734 | "return": { 735 | "type": { 736 | "text": "void" 737 | } 738 | }, 739 | "inheritedFrom": { 740 | "name": "WcDoxBase", 741 | "module": "src/components/base/dox-base.ts" 742 | } 743 | } 744 | ], 745 | "superclass": { 746 | "name": "WcDoxBase", 747 | "module": "/src/components/base/dox-base.js" 748 | }, 749 | "tagName": "wc-css-states", 750 | "customElement": true, 751 | "since": { 752 | "name": "1.0.0", 753 | "description": "" 754 | }, 755 | "status": { 756 | "name": "experimental", 757 | "description": "" 758 | }, 759 | "attributes": [ 760 | { 761 | "name": "component-name", 762 | "type": { 763 | "text": "string | undefined" 764 | }, 765 | "description": "The name of the component class", 766 | "fieldName": "componentName", 767 | "inheritedFrom": { 768 | "name": "WcDoxBase", 769 | "module": "src/components/base/dox-base.ts" 770 | }, 771 | "propName": "componentName" 772 | }, 773 | { 774 | "name": "tag", 775 | "type": { 776 | "text": "string | undefined" 777 | }, 778 | "description": "The tag name of the custom element", 779 | "fieldName": "tag", 780 | "inheritedFrom": { 781 | "name": "WcDoxBase", 782 | "module": "src/components/base/dox-base.ts" 783 | }, 784 | "propName": "tag" 785 | } 786 | ], 787 | "modulePath": "src/components/css-states/css-states.ts" 788 | } 789 | ], 790 | "exports": [ 791 | { 792 | "kind": "js", 793 | "name": "default", 794 | "declaration": { 795 | "name": "WcCssStates", 796 | "module": "src/components/css-states/css-states.ts" 797 | } 798 | }, 799 | { 800 | "kind": "js", 801 | "name": "WcCssStates", 802 | "declaration": { 803 | "name": "WcCssStates", 804 | "module": "src/components/css-states/css-states.ts" 805 | } 806 | } 807 | ] 808 | }, 809 | { 810 | "kind": "javascript-module", 811 | "path": "src/components/dox/dox.ts", 812 | "declarations": [ 813 | { 814 | "kind": "class", 815 | "description": "A component to document the APIs of a custom element", 816 | "name": "WcDox", 817 | "members": [ 818 | { 819 | "kind": "field", 820 | "name": "component", 821 | "type": { 822 | "text": "Component | undefined" 823 | }, 824 | "privacy": "protected" 825 | }, 826 | { 827 | "kind": "field", 828 | "name": "componentName", 829 | "type": { 830 | "text": "string | undefined" 831 | }, 832 | "attribute": "component-name" 833 | }, 834 | { 835 | "kind": "field", 836 | "name": "tag", 837 | "type": { 838 | "text": "string | undefined" 839 | }, 840 | "attribute": "tag" 841 | } 842 | ], 843 | "attributes": [ 844 | { 845 | "name": "component-name", 846 | "type": { 847 | "text": "string | undefined" 848 | }, 849 | "fieldName": "componentName", 850 | "propName": "componentName" 851 | }, 852 | { 853 | "name": "tag", 854 | "type": { 855 | "text": "string | undefined" 856 | }, 857 | "fieldName": "tag", 858 | "propName": "tag" 859 | } 860 | ], 861 | "superclass": { 862 | "name": "LitElement", 863 | "package": "lit" 864 | }, 865 | "tagName": "wc-dox", 866 | "customElement": true, 867 | "since": { 868 | "name": "1.0.0", 869 | "description": "" 870 | }, 871 | "status": { 872 | "name": "experimental", 873 | "description": "" 874 | }, 875 | "modulePath": "src/components/dox/dox.ts" 876 | } 877 | ], 878 | "exports": [ 879 | { 880 | "kind": "js", 881 | "name": "default", 882 | "declaration": { 883 | "name": "WcDox", 884 | "module": "src/components/dox/dox.ts" 885 | } 886 | }, 887 | { 888 | "kind": "js", 889 | "name": "WcDox", 890 | "declaration": { 891 | "name": "WcDox", 892 | "module": "src/components/dox/dox.ts" 893 | } 894 | } 895 | ] 896 | }, 897 | { 898 | "kind": "javascript-module", 899 | "path": "src/components/events/events.ts", 900 | "declarations": [ 901 | { 902 | "kind": "class", 903 | "description": "A component to document the events of a custom element", 904 | "name": "WcEvents", 905 | "members": [ 906 | { 907 | "kind": "field", 908 | "name": "component", 909 | "type": { 910 | "text": "Component | undefined" 911 | }, 912 | "privacy": "public", 913 | "description": "The component data", 914 | "inheritedFrom": { 915 | "name": "WcDoxBase", 916 | "module": "src/components/base/dox-base.ts" 917 | } 918 | }, 919 | { 920 | "kind": "field", 921 | "name": "componentName", 922 | "type": { 923 | "text": "string | undefined" 924 | }, 925 | "privacy": "public", 926 | "description": "The name of the component class", 927 | "attribute": "component-name", 928 | "inheritedFrom": { 929 | "name": "WcDoxBase", 930 | "module": "src/components/base/dox-base.ts" 931 | } 932 | }, 933 | { 934 | "kind": "field", 935 | "name": "config", 936 | "type": { 937 | "text": "Config | undefined" 938 | }, 939 | "privacy": "protected", 940 | "inheritedFrom": { 941 | "name": "WcDoxBase", 942 | "module": "src/components/base/dox-base.ts" 943 | } 944 | }, 945 | { 946 | "kind": "field", 947 | "name": "feature", 948 | "type": { 949 | "text": "ComponentAPI | undefined" 950 | }, 951 | "privacy": "protected", 952 | "parsedType": { 953 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 954 | }, 955 | "default": "'events'", 956 | "inheritedFrom": { 957 | "name": "WcDoxBase", 958 | "module": "src/components/base/dox-base.ts" 959 | } 960 | }, 961 | { 962 | "kind": "method", 963 | "name": "getRenderTemplate", 964 | "privacy": "protected", 965 | "parameters": [ 966 | { 967 | "name": "styles", 968 | "type": { 969 | "text": "CSSResult" 970 | } 971 | }, 972 | { 973 | "name": "className", 974 | "type": { 975 | "text": "string" 976 | } 977 | } 978 | ], 979 | "inheritedFrom": { 980 | "name": "WcDoxBase", 981 | "module": "src/components/base/dox-base.ts" 982 | } 983 | }, 984 | { 985 | "kind": "field", 986 | "name": "metaData", 987 | "type": { 988 | "text": "MetaData[] | undefined" 989 | }, 990 | "privacy": "protected", 991 | "inheritedFrom": { 992 | "name": "WcDoxBase", 993 | "module": "src/components/base/dox-base.ts" 994 | } 995 | }, 996 | { 997 | "kind": "field", 998 | "name": "tag", 999 | "type": { 1000 | "text": "string | undefined" 1001 | }, 1002 | "privacy": "public", 1003 | "description": "The tag name of the custom element", 1004 | "attribute": "tag", 1005 | "inheritedFrom": { 1006 | "name": "WcDoxBase", 1007 | "module": "src/components/base/dox-base.ts" 1008 | } 1009 | }, 1010 | { 1011 | "kind": "method", 1012 | "name": "updateMetaData", 1013 | "privacy": "protected", 1014 | "return": { 1015 | "type": { 1016 | "text": "void" 1017 | } 1018 | }, 1019 | "parameters": [ 1020 | { 1021 | "name": "feature", 1022 | "optional": true, 1023 | "type": { 1024 | "text": "ComponentAPI" 1025 | } 1026 | } 1027 | ], 1028 | "inheritedFrom": { 1029 | "name": "WcDoxBase", 1030 | "module": "src/components/base/dox-base.ts" 1031 | } 1032 | }, 1033 | { 1034 | "kind": "method", 1035 | "name": "updateVisibility", 1036 | "privacy": "protected", 1037 | "return": { 1038 | "type": { 1039 | "text": "void" 1040 | } 1041 | }, 1042 | "inheritedFrom": { 1043 | "name": "WcDoxBase", 1044 | "module": "src/components/base/dox-base.ts" 1045 | } 1046 | } 1047 | ], 1048 | "superclass": { 1049 | "name": "WcDoxBase", 1050 | "module": "/src/components/base/dox-base.js" 1051 | }, 1052 | "tagName": "wc-events", 1053 | "customElement": true, 1054 | "since": { 1055 | "name": "1.0.0", 1056 | "description": "" 1057 | }, 1058 | "status": { 1059 | "name": "experimental", 1060 | "description": "" 1061 | }, 1062 | "attributes": [ 1063 | { 1064 | "name": "component-name", 1065 | "type": { 1066 | "text": "string | undefined" 1067 | }, 1068 | "description": "The name of the component class", 1069 | "fieldName": "componentName", 1070 | "inheritedFrom": { 1071 | "name": "WcDoxBase", 1072 | "module": "src/components/base/dox-base.ts" 1073 | }, 1074 | "propName": "componentName" 1075 | }, 1076 | { 1077 | "name": "tag", 1078 | "type": { 1079 | "text": "string | undefined" 1080 | }, 1081 | "description": "The tag name of the custom element", 1082 | "fieldName": "tag", 1083 | "inheritedFrom": { 1084 | "name": "WcDoxBase", 1085 | "module": "src/components/base/dox-base.ts" 1086 | }, 1087 | "propName": "tag" 1088 | } 1089 | ], 1090 | "modulePath": "src/components/events/events.ts" 1091 | } 1092 | ], 1093 | "exports": [ 1094 | { 1095 | "kind": "js", 1096 | "name": "default", 1097 | "declaration": { 1098 | "name": "WcEvents", 1099 | "module": "src/components/events/events.ts" 1100 | } 1101 | }, 1102 | { 1103 | "kind": "js", 1104 | "name": "WcEvents", 1105 | "declaration": { 1106 | "name": "WcEvents", 1107 | "module": "src/components/events/events.ts" 1108 | } 1109 | } 1110 | ] 1111 | }, 1112 | { 1113 | "kind": "javascript-module", 1114 | "path": "src/components/imports/imports.ts", 1115 | "declarations": [ 1116 | { 1117 | "kind": "class", 1118 | "description": "A component to document the ways to import a custom element", 1119 | "name": "WcImports", 1120 | "cssProperties": [ 1121 | { 1122 | "description": "Controls the color of the divider between the tabs and tab content", 1123 | "name": "--wc-imports-border-color", 1124 | "default": "#e0e0e0" 1125 | }, 1126 | { 1127 | "description": "The bottom border color of the selected tab", 1128 | "name": "--wc-imports-active-border-color", 1129 | "default": "#0078d4" 1130 | }, 1131 | { 1132 | "description": "the size of the border divider between the tabs and the tab content", 1133 | "name": "--wc-imports-border-size", 1134 | "default": "2px" 1135 | } 1136 | ], 1137 | "members": [ 1138 | { 1139 | "kind": "field", 1140 | "name": "component", 1141 | "type": { 1142 | "text": "cem.CustomElement | undefined" 1143 | } 1144 | }, 1145 | { 1146 | "kind": "field", 1147 | "name": "componentName", 1148 | "type": { 1149 | "text": "string | undefined" 1150 | }, 1151 | "attribute": "component-name" 1152 | }, 1153 | { 1154 | "kind": "field", 1155 | "name": "config", 1156 | "type": { 1157 | "text": "ImportsElementConfig | undefined" 1158 | }, 1159 | "privacy": "private", 1160 | "parsedType": { 1161 | "text": "{ heading?: string, headingId?: string, description?: string, copyIcon?: string, copyLabel?: string, copiedIcon?: string, copiedLabel?: string, langOnPreTag?: false | true, imports?: ImportConfig[] } | undefined" 1162 | } 1163 | }, 1164 | { 1165 | "kind": "field", 1166 | "name": "copied", 1167 | "type": { 1168 | "text": "boolean" 1169 | }, 1170 | "default": "false" 1171 | }, 1172 | { 1173 | "kind": "method", 1174 | "name": "handleCopyClick", 1175 | "privacy": "private", 1176 | "parameters": [ 1177 | { 1178 | "name": "content", 1179 | "type": { 1180 | "text": "string" 1181 | } 1182 | } 1183 | ] 1184 | }, 1185 | { 1186 | "kind": "method", 1187 | "name": "handleTabClick", 1188 | "privacy": "private", 1189 | "parameters": [ 1190 | { 1191 | "name": "i", 1192 | "type": { 1193 | "text": "number" 1194 | } 1195 | } 1196 | ] 1197 | }, 1198 | { 1199 | "kind": "field", 1200 | "name": "selectedImport", 1201 | "type": { 1202 | "text": "number" 1203 | }, 1204 | "privacy": "private", 1205 | "default": "0" 1206 | }, 1207 | { 1208 | "kind": "field", 1209 | "name": "tag", 1210 | "type": { 1211 | "text": "string | undefined" 1212 | }, 1213 | "attribute": "tag" 1214 | } 1215 | ], 1216 | "attributes": [ 1217 | { 1218 | "name": "component-name", 1219 | "type": { 1220 | "text": "string | undefined" 1221 | }, 1222 | "fieldName": "componentName", 1223 | "propName": "componentName" 1224 | }, 1225 | { 1226 | "name": "tag", 1227 | "type": { 1228 | "text": "string | undefined" 1229 | }, 1230 | "fieldName": "tag", 1231 | "propName": "tag" 1232 | } 1233 | ], 1234 | "superclass": { 1235 | "name": "LitElement", 1236 | "package": "lit" 1237 | }, 1238 | "tagName": "wc-imports", 1239 | "customElement": true, 1240 | "since": { 1241 | "name": "1.0.0", 1242 | "description": "" 1243 | }, 1244 | "status": { 1245 | "name": "experimental", 1246 | "description": "" 1247 | }, 1248 | "modulePath": "src/components/imports/imports.ts" 1249 | } 1250 | ], 1251 | "exports": [ 1252 | { 1253 | "kind": "js", 1254 | "name": "default", 1255 | "declaration": { 1256 | "name": "WcImports", 1257 | "module": "src/components/imports/imports.ts" 1258 | } 1259 | }, 1260 | { 1261 | "kind": "js", 1262 | "name": "WcImports", 1263 | "declaration": { 1264 | "name": "WcImports", 1265 | "module": "src/components/imports/imports.ts" 1266 | } 1267 | } 1268 | ] 1269 | }, 1270 | { 1271 | "kind": "javascript-module", 1272 | "path": "src/components/methods/methods.ts", 1273 | "declarations": [ 1274 | { 1275 | "kind": "class", 1276 | "description": "A component to document the methods of a custom element", 1277 | "name": "WcMethods", 1278 | "members": [ 1279 | { 1280 | "kind": "field", 1281 | "name": "component", 1282 | "type": { 1283 | "text": "Component | undefined" 1284 | }, 1285 | "privacy": "public", 1286 | "description": "The component data", 1287 | "inheritedFrom": { 1288 | "name": "WcDoxBase", 1289 | "module": "src/components/base/dox-base.ts" 1290 | } 1291 | }, 1292 | { 1293 | "kind": "field", 1294 | "name": "componentName", 1295 | "type": { 1296 | "text": "string | undefined" 1297 | }, 1298 | "privacy": "public", 1299 | "description": "The name of the component class", 1300 | "attribute": "component-name", 1301 | "inheritedFrom": { 1302 | "name": "WcDoxBase", 1303 | "module": "src/components/base/dox-base.ts" 1304 | } 1305 | }, 1306 | { 1307 | "kind": "field", 1308 | "name": "config", 1309 | "type": { 1310 | "text": "Config | undefined" 1311 | }, 1312 | "privacy": "protected", 1313 | "inheritedFrom": { 1314 | "name": "WcDoxBase", 1315 | "module": "src/components/base/dox-base.ts" 1316 | } 1317 | }, 1318 | { 1319 | "kind": "field", 1320 | "name": "feature", 1321 | "type": { 1322 | "text": "ComponentAPI | undefined" 1323 | }, 1324 | "privacy": "protected", 1325 | "parsedType": { 1326 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 1327 | }, 1328 | "default": "'methods'", 1329 | "inheritedFrom": { 1330 | "name": "WcDoxBase", 1331 | "module": "src/components/base/dox-base.ts" 1332 | } 1333 | }, 1334 | { 1335 | "kind": "method", 1336 | "name": "getRenderTemplate", 1337 | "privacy": "protected", 1338 | "parameters": [ 1339 | { 1340 | "name": "styles", 1341 | "type": { 1342 | "text": "CSSResult" 1343 | } 1344 | }, 1345 | { 1346 | "name": "className", 1347 | "type": { 1348 | "text": "string" 1349 | } 1350 | } 1351 | ], 1352 | "inheritedFrom": { 1353 | "name": "WcDoxBase", 1354 | "module": "src/components/base/dox-base.ts" 1355 | } 1356 | }, 1357 | { 1358 | "kind": "field", 1359 | "name": "metaData", 1360 | "type": { 1361 | "text": "MetaData[] | undefined" 1362 | }, 1363 | "privacy": "protected", 1364 | "inheritedFrom": { 1365 | "name": "WcDoxBase", 1366 | "module": "src/components/base/dox-base.ts" 1367 | } 1368 | }, 1369 | { 1370 | "kind": "field", 1371 | "name": "tag", 1372 | "type": { 1373 | "text": "string | undefined" 1374 | }, 1375 | "privacy": "public", 1376 | "description": "The tag name of the custom element", 1377 | "attribute": "tag", 1378 | "inheritedFrom": { 1379 | "name": "WcDoxBase", 1380 | "module": "src/components/base/dox-base.ts" 1381 | } 1382 | }, 1383 | { 1384 | "kind": "method", 1385 | "name": "updateMetaData", 1386 | "privacy": "protected", 1387 | "return": { 1388 | "type": { 1389 | "text": "void" 1390 | } 1391 | }, 1392 | "parameters": [ 1393 | { 1394 | "name": "feature", 1395 | "optional": true, 1396 | "type": { 1397 | "text": "ComponentAPI" 1398 | } 1399 | } 1400 | ], 1401 | "inheritedFrom": { 1402 | "name": "WcDoxBase", 1403 | "module": "src/components/base/dox-base.ts" 1404 | } 1405 | }, 1406 | { 1407 | "kind": "method", 1408 | "name": "updateVisibility", 1409 | "privacy": "protected", 1410 | "return": { 1411 | "type": { 1412 | "text": "void" 1413 | } 1414 | }, 1415 | "inheritedFrom": { 1416 | "name": "WcDoxBase", 1417 | "module": "src/components/base/dox-base.ts" 1418 | } 1419 | } 1420 | ], 1421 | "superclass": { 1422 | "name": "WcDoxBase", 1423 | "module": "/src/components/base/dox-base.js" 1424 | }, 1425 | "tagName": "wc-methods", 1426 | "customElement": true, 1427 | "since": { 1428 | "name": "1.0.0", 1429 | "description": "" 1430 | }, 1431 | "status": { 1432 | "name": "experimental", 1433 | "description": "" 1434 | }, 1435 | "attributes": [ 1436 | { 1437 | "name": "component-name", 1438 | "type": { 1439 | "text": "string | undefined" 1440 | }, 1441 | "description": "The name of the component class", 1442 | "fieldName": "componentName", 1443 | "inheritedFrom": { 1444 | "name": "WcDoxBase", 1445 | "module": "src/components/base/dox-base.ts" 1446 | }, 1447 | "propName": "componentName" 1448 | }, 1449 | { 1450 | "name": "tag", 1451 | "type": { 1452 | "text": "string | undefined" 1453 | }, 1454 | "description": "The tag name of the custom element", 1455 | "fieldName": "tag", 1456 | "inheritedFrom": { 1457 | "name": "WcDoxBase", 1458 | "module": "src/components/base/dox-base.ts" 1459 | }, 1460 | "propName": "tag" 1461 | } 1462 | ], 1463 | "modulePath": "src/components/methods/methods.ts" 1464 | } 1465 | ], 1466 | "exports": [ 1467 | { 1468 | "kind": "js", 1469 | "name": "default", 1470 | "declaration": { 1471 | "name": "WcMethods", 1472 | "module": "src/components/methods/methods.ts" 1473 | } 1474 | }, 1475 | { 1476 | "kind": "js", 1477 | "name": "WcMethods", 1478 | "declaration": { 1479 | "name": "WcMethods", 1480 | "module": "src/components/methods/methods.ts" 1481 | } 1482 | } 1483 | ] 1484 | }, 1485 | { 1486 | "kind": "javascript-module", 1487 | "path": "src/components/props/props.ts", 1488 | "declarations": [ 1489 | { 1490 | "kind": "class", 1491 | "description": "A component to document the attributes and properties of a custom element", 1492 | "name": "WcProps", 1493 | "members": [ 1494 | { 1495 | "kind": "field", 1496 | "name": "component", 1497 | "type": { 1498 | "text": "Component | undefined" 1499 | }, 1500 | "privacy": "public", 1501 | "description": "The component data", 1502 | "inheritedFrom": { 1503 | "name": "WcDoxBase", 1504 | "module": "src/components/base/dox-base.ts" 1505 | } 1506 | }, 1507 | { 1508 | "kind": "field", 1509 | "name": "componentName", 1510 | "type": { 1511 | "text": "string | undefined" 1512 | }, 1513 | "privacy": "public", 1514 | "description": "The name of the component class", 1515 | "attribute": "component-name", 1516 | "inheritedFrom": { 1517 | "name": "WcDoxBase", 1518 | "module": "src/components/base/dox-base.ts" 1519 | } 1520 | }, 1521 | { 1522 | "kind": "field", 1523 | "name": "config", 1524 | "type": { 1525 | "text": "Config | undefined" 1526 | }, 1527 | "privacy": "protected", 1528 | "inheritedFrom": { 1529 | "name": "WcDoxBase", 1530 | "module": "src/components/base/dox-base.ts" 1531 | } 1532 | }, 1533 | { 1534 | "kind": "field", 1535 | "name": "feature", 1536 | "type": { 1537 | "text": "ComponentAPI | undefined" 1538 | }, 1539 | "privacy": "protected", 1540 | "parsedType": { 1541 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 1542 | }, 1543 | "default": "'properties'", 1544 | "inheritedFrom": { 1545 | "name": "WcDoxBase", 1546 | "module": "src/components/base/dox-base.ts" 1547 | } 1548 | }, 1549 | { 1550 | "kind": "method", 1551 | "name": "getRenderTemplate", 1552 | "privacy": "protected", 1553 | "parameters": [ 1554 | { 1555 | "name": "styles", 1556 | "type": { 1557 | "text": "CSSResult" 1558 | } 1559 | }, 1560 | { 1561 | "name": "className", 1562 | "type": { 1563 | "text": "string" 1564 | } 1565 | } 1566 | ], 1567 | "inheritedFrom": { 1568 | "name": "WcDoxBase", 1569 | "module": "src/components/base/dox-base.ts" 1570 | } 1571 | }, 1572 | { 1573 | "kind": "field", 1574 | "name": "metaData", 1575 | "type": { 1576 | "text": "MetaData[] | undefined" 1577 | }, 1578 | "privacy": "protected", 1579 | "inheritedFrom": { 1580 | "name": "WcDoxBase", 1581 | "module": "src/components/base/dox-base.ts" 1582 | } 1583 | }, 1584 | { 1585 | "kind": "field", 1586 | "name": "tag", 1587 | "type": { 1588 | "text": "string | undefined" 1589 | }, 1590 | "privacy": "public", 1591 | "description": "The tag name of the custom element", 1592 | "attribute": "tag", 1593 | "inheritedFrom": { 1594 | "name": "WcDoxBase", 1595 | "module": "src/components/base/dox-base.ts" 1596 | } 1597 | }, 1598 | { 1599 | "kind": "method", 1600 | "name": "updateMetaData", 1601 | "privacy": "protected", 1602 | "return": { 1603 | "type": { 1604 | "text": "void" 1605 | } 1606 | }, 1607 | "parameters": [ 1608 | { 1609 | "name": "feature", 1610 | "optional": true, 1611 | "type": { 1612 | "text": "ComponentAPI" 1613 | } 1614 | } 1615 | ], 1616 | "inheritedFrom": { 1617 | "name": "WcDoxBase", 1618 | "module": "src/components/base/dox-base.ts" 1619 | } 1620 | }, 1621 | { 1622 | "kind": "method", 1623 | "name": "updateVisibility", 1624 | "privacy": "protected", 1625 | "return": { 1626 | "type": { 1627 | "text": "void" 1628 | } 1629 | }, 1630 | "inheritedFrom": { 1631 | "name": "WcDoxBase", 1632 | "module": "src/components/base/dox-base.ts" 1633 | } 1634 | } 1635 | ], 1636 | "superclass": { 1637 | "name": "WcDoxBase", 1638 | "module": "/src/components/base/dox-base.js" 1639 | }, 1640 | "tagName": "wc-props", 1641 | "customElement": true, 1642 | "since": { 1643 | "name": "1.0.0", 1644 | "description": "" 1645 | }, 1646 | "status": { 1647 | "name": "experimental", 1648 | "description": "" 1649 | }, 1650 | "attributes": [ 1651 | { 1652 | "name": "component-name", 1653 | "type": { 1654 | "text": "string | undefined" 1655 | }, 1656 | "description": "The name of the component class", 1657 | "fieldName": "componentName", 1658 | "inheritedFrom": { 1659 | "name": "WcDoxBase", 1660 | "module": "src/components/base/dox-base.ts" 1661 | }, 1662 | "propName": "componentName" 1663 | }, 1664 | { 1665 | "name": "tag", 1666 | "type": { 1667 | "text": "string | undefined" 1668 | }, 1669 | "description": "The tag name of the custom element", 1670 | "fieldName": "tag", 1671 | "inheritedFrom": { 1672 | "name": "WcDoxBase", 1673 | "module": "src/components/base/dox-base.ts" 1674 | }, 1675 | "propName": "tag" 1676 | } 1677 | ], 1678 | "modulePath": "src/components/props/props.ts" 1679 | } 1680 | ], 1681 | "exports": [ 1682 | { 1683 | "kind": "js", 1684 | "name": "default", 1685 | "declaration": { 1686 | "name": "WcProps", 1687 | "module": "src/components/props/props.ts" 1688 | } 1689 | }, 1690 | { 1691 | "kind": "js", 1692 | "name": "WcProps", 1693 | "declaration": { 1694 | "name": "WcProps", 1695 | "module": "src/components/props/props.ts" 1696 | } 1697 | } 1698 | ] 1699 | }, 1700 | { 1701 | "kind": "javascript-module", 1702 | "path": "src/components/slots/slots.ts", 1703 | "declarations": [ 1704 | { 1705 | "kind": "class", 1706 | "description": "A component to document the slots of a custom element", 1707 | "name": "WcSlots", 1708 | "members": [ 1709 | { 1710 | "kind": "field", 1711 | "name": "component", 1712 | "type": { 1713 | "text": "Component | undefined" 1714 | }, 1715 | "privacy": "public", 1716 | "description": "The component data", 1717 | "inheritedFrom": { 1718 | "name": "WcDoxBase", 1719 | "module": "src/components/base/dox-base.ts" 1720 | } 1721 | }, 1722 | { 1723 | "kind": "field", 1724 | "name": "componentName", 1725 | "type": { 1726 | "text": "string | undefined" 1727 | }, 1728 | "privacy": "public", 1729 | "description": "The name of the component class", 1730 | "attribute": "component-name", 1731 | "inheritedFrom": { 1732 | "name": "WcDoxBase", 1733 | "module": "src/components/base/dox-base.ts" 1734 | } 1735 | }, 1736 | { 1737 | "kind": "field", 1738 | "name": "config", 1739 | "type": { 1740 | "text": "Config | undefined" 1741 | }, 1742 | "privacy": "protected", 1743 | "inheritedFrom": { 1744 | "name": "WcDoxBase", 1745 | "module": "src/components/base/dox-base.ts" 1746 | } 1747 | }, 1748 | { 1749 | "kind": "field", 1750 | "name": "feature", 1751 | "type": { 1752 | "text": "ComponentAPI | undefined" 1753 | }, 1754 | "privacy": "protected", 1755 | "parsedType": { 1756 | "text": "'slots' | 'methods' | 'events' | 'tagName' | 'attributes' | 'cssParts' | 'cssProperties' | 'cssStates' | 'demos' | 'customElement' | 'name' | 'summary' | 'description' | 'superclass' | 'mixins' | 'members' | 'source' | 'deprecated' | 'properties' | undefined" 1757 | }, 1758 | "default": "'slots'", 1759 | "inheritedFrom": { 1760 | "name": "WcDoxBase", 1761 | "module": "src/components/base/dox-base.ts" 1762 | } 1763 | }, 1764 | { 1765 | "kind": "method", 1766 | "name": "getRenderTemplate", 1767 | "privacy": "protected", 1768 | "parameters": [ 1769 | { 1770 | "name": "styles", 1771 | "type": { 1772 | "text": "CSSResult" 1773 | } 1774 | }, 1775 | { 1776 | "name": "className", 1777 | "type": { 1778 | "text": "string" 1779 | } 1780 | } 1781 | ], 1782 | "inheritedFrom": { 1783 | "name": "WcDoxBase", 1784 | "module": "src/components/base/dox-base.ts" 1785 | } 1786 | }, 1787 | { 1788 | "kind": "field", 1789 | "name": "metaData", 1790 | "type": { 1791 | "text": "MetaData[] | undefined" 1792 | }, 1793 | "privacy": "protected", 1794 | "inheritedFrom": { 1795 | "name": "WcDoxBase", 1796 | "module": "src/components/base/dox-base.ts" 1797 | } 1798 | }, 1799 | { 1800 | "kind": "field", 1801 | "name": "tag", 1802 | "type": { 1803 | "text": "string | undefined" 1804 | }, 1805 | "privacy": "public", 1806 | "description": "The tag name of the custom element", 1807 | "attribute": "tag", 1808 | "inheritedFrom": { 1809 | "name": "WcDoxBase", 1810 | "module": "src/components/base/dox-base.ts" 1811 | } 1812 | }, 1813 | { 1814 | "kind": "method", 1815 | "name": "updateMetaData", 1816 | "privacy": "protected", 1817 | "return": { 1818 | "type": { 1819 | "text": "void" 1820 | } 1821 | }, 1822 | "parameters": [ 1823 | { 1824 | "name": "feature", 1825 | "optional": true, 1826 | "type": { 1827 | "text": "ComponentAPI" 1828 | } 1829 | } 1830 | ], 1831 | "inheritedFrom": { 1832 | "name": "WcDoxBase", 1833 | "module": "src/components/base/dox-base.ts" 1834 | } 1835 | }, 1836 | { 1837 | "kind": "method", 1838 | "name": "updateVisibility", 1839 | "privacy": "protected", 1840 | "return": { 1841 | "type": { 1842 | "text": "void" 1843 | } 1844 | }, 1845 | "inheritedFrom": { 1846 | "name": "WcDoxBase", 1847 | "module": "src/components/base/dox-base.ts" 1848 | } 1849 | } 1850 | ], 1851 | "superclass": { 1852 | "name": "WcDoxBase", 1853 | "module": "/src/components/base/dox-base.js" 1854 | }, 1855 | "tagName": "wc-slots", 1856 | "customElement": true, 1857 | "since": { 1858 | "name": "1.0.0", 1859 | "description": "" 1860 | }, 1861 | "status": { 1862 | "name": "experimental", 1863 | "description": "" 1864 | }, 1865 | "attributes": [ 1866 | { 1867 | "name": "component-name", 1868 | "type": { 1869 | "text": "string | undefined" 1870 | }, 1871 | "description": "The name of the component class", 1872 | "fieldName": "componentName", 1873 | "inheritedFrom": { 1874 | "name": "WcDoxBase", 1875 | "module": "src/components/base/dox-base.ts" 1876 | }, 1877 | "propName": "componentName" 1878 | }, 1879 | { 1880 | "name": "tag", 1881 | "type": { 1882 | "text": "string | undefined" 1883 | }, 1884 | "description": "The tag name of the custom element", 1885 | "fieldName": "tag", 1886 | "inheritedFrom": { 1887 | "name": "WcDoxBase", 1888 | "module": "src/components/base/dox-base.ts" 1889 | }, 1890 | "propName": "tag" 1891 | } 1892 | ], 1893 | "modulePath": "src/components/slots/slots.ts" 1894 | } 1895 | ], 1896 | "exports": [ 1897 | { 1898 | "kind": "js", 1899 | "name": "default", 1900 | "declaration": { 1901 | "name": "WcSlots", 1902 | "module": "src/components/slots/slots.ts" 1903 | } 1904 | }, 1905 | { 1906 | "kind": "js", 1907 | "name": "WcSlots", 1908 | "declaration": { 1909 | "name": "WcSlots", 1910 | "module": "src/components/slots/slots.ts" 1911 | } 1912 | } 1913 | ] 1914 | } 1915 | ] 1916 | } 1917 | --------------------------------------------------------------------------------