{"_id":"@avery42/preact-custom-element","name":"@avery42/preact-custom-element","dist-tags":{"latest":"4.2.1"},"versions":{"4.2.1":{"name":"@avery42/preact-custom-element","version":"4.2.1","description":"Wrap your component up as a custom element","main":"dist/preact-custom-element.js","module":"dist/preact-custom-element.esm.js","unpkg":"dist/preact-custom-element.umd.js","source":"src/index.js","types":"src/index.d.ts","scripts":{"prepare":"microbundle","lint":"eslint src/*.{js,jsx}","test":"wtr src/*.test.{js,jsx}","test:browsers":"wtr src/*.test.{js,jsx} --playwright --browsers chromium firefox webkit","prettier":"prettier **/*.{js,jsx} --write","prepublishOnly":"npm run lint && npm run test"},"eslintConfig":{"extends":"developit","settings":{"react":{"version":"latest"}},"rules":{"brace-style":"off","jest/expect-expect":"off","lines-around-comment":"off","comma-dangle":"off","no-unused-vars":[2,{"args":"none","varsIgnorePattern":"^h$"}]}},"repository":{"type":"git","url":"https://github.com/preactjs/preact-custom-element.git"},"keywords":["preact","web","components","custom","element"],"authors":["Bradley J. Spaulding","The Preact Authors (https://preactjs.com)"],"license":"MIT","homepage":"https://github.com/coolavery/preact-custom-element/blob/master/package.json","peerDependencies":{"preact":"10.x"},"devDependencies":{"@open-wc/testing":"^2.5.25","@web/dev-server-core":"^0.2.4","@web/dev-server-esbuild":"^0.2.2","@web/test-runner":"^0.7.12","@web/test-runner-playwright":"^0.5.4","eslint":"^7.7.0","eslint-config-developit":"^1.2.0","get-stream":"^6.0.0","husky":"^4.2.5","lint-staged":"^10.2.13","microbundle":"^0.12.3","preact":"^10.4.8","prettier":"^2.1.1"},"lint-staged":{"**/*.{js,jsx,ts,tsx,yml}":["prettier --write"]},"husky":{"hooks":{"pre-commit":"lint-staged"}},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2016 Bradley Spaulding\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@avery42/preact-custom-element@4.2.1","dist":{"shasum":"dc6493004e7ebed30ef7be4adedcd4a4adc99752","integrity":"sha512-7dlldhWh6QHaiw+Y90G+IK59iING7/r3wpd5eHfxqNZDnGw2a6UE+QTFwyuHc4U+fWirTubMq1bTC4bda2yvJA==","tarball":"https://registry.npmjs.org/@avery42/preact-custom-element/-/preact-custom-element-4.2.1.tgz","fileCount":16,"unpackedSize":437022,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfMAbjGk9uO0OrHT41NJ1geXDRXdJnDpFB808740EG1QIgFVHjO6xkkHRz+6THut2GNmpmsumHxzrW6SFE9lUnOOQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaHY5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoQDQ/+NP8nbvveY9jyznwaHPc8stT9WRJmO/wF+WLMx3SPAK/9Q29/\r\nkc696b3f3ACFsEMAO1QY4Ugj2+3ZwHlJrbdSmwfPMzzZJTTYcn6/aub0lybx\r\nQppp8mSw/ldxf3yqLE/8e72Hf6oXT6UTzdDp+addGDdxFpE8BvOg67mzZnID\r\nSVVpadBvzptK/MdHEcYHgZtHI6PF49XZ8HqO7t258ViHZsTRQIW9d6TOje9I\r\nuUf6w9HRYyVEE+OL2Jo47cZiouILDuwOAl4OxvUGik8BQul9OHZGr1g5PE9C\r\nL5v/IMFJVEMC41P2dnzoBsfh5cVpRiBEYWKXnMtfXxzXVYhA7g4CnAQf6rMA\r\nrW+sU4InSFH0YZz+HcNRldD6ynLVfmfzNFEeUQNfjWd4wzMRU+ESGuJUEMca\r\ng3wvDF3wS4aJtKzW9gE1xp+TfzDn4VUaqgBaTadxKfpNUi76fy3VnXls/96z\r\nTdzX5KQQBZLytB0C5O2YXEoR9JfkPI/8pCrtFl7ucZwAhTt4Q4tzrgbZb+QO\r\n0FZAySThWGj1TD6GWnoW+lAvehTyDUG9XWo0UETHpLtpSeG2Xw3jM8+Zi2NB\r\n0bhaWlGUROBIM2wolE7kOmF3nYXquH4ZY3AayBFwIqR1PrkUfqrF1TE02jhT\r\namjwZlx8KG25YD7wbJOFnZfLFMgk1OFgyEo=\r\n=7EMk\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"avery42","email":"npm@avery.cafe"},"directories":{},"maintainers":[{"name":"avery42","email":"npm@avery.cafe"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/preact-custom-element_4.2.1_1651013177035_0.36005341617413267"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-26T22:46:16.989Z","4.2.1":"2022-04-26T22:46:17.187Z","modified":"2022-04-26T22:46:17.311Z"},"maintainers":[{"name":"avery42","email":"npm@avery.cafe"}],"description":"Wrap your component up as a custom element","homepage":"https://github.com/coolavery/preact-custom-element/blob/master/package.json","keywords":["preact","web","components","custom","element"],"repository":{"type":"git","url":"https://github.com/preactjs/preact-custom-element.git"},"license":"MIT","readme":"# preact-custom-element\n\nGenerate/register a custom element from a preact component. As of 3.0.0, this library implements the Custom Elements v1 spec.\nPrevious versions (< 3.0.0) implemented the v0 proposal, which was only implemented in Chrome and is abandoned.\n\n## Usage\n\nImport `CustomElement` and call with your component a tag name __\\*__, and a list of attribute names you want to observe:\n\n```javascript\nimport register from 'preact-custom-element';\n\nconst Greeting = ({ name = 'World' }) => (\n  <p>Hello, {name}!</p>\n);\n\nregister(Greeting, 'x-greeting', ['name']);\n```\n\n> _**\\* Note:** as per the [Custom Elements specification](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name), the tag name must contain a hyphen._\n\nUse the new tag name in HTML, attribute keys and values will be passed in as props:\n\n```html\n<x-greeting name=\"Billy Jo\"></x-greeting>\n```\n\nOutput:\n\n```html\n<p>Hello, Billy Jo!</p>\n```\n\n### Prop Names and Automatic Prop Names\n\nThe Custom Elements V1 specification requires explictly stating the names of any attributes you want to observe. From your Preact component perspective, `props` could be an object with any keys at runtime, so it's not always clear which props should be accepted as attributes.\n\nIf you omit the third parameter to `register()`, the list of attributes to observe can be specified using a static `observedAttributes` property on your Component. This also works for the Custom Element's name, which can be specified using a `tagName` static property:\n\n```js\nimport register from 'preact-custom-element';\n\n// <x-greeting name=\"Bo\"></x-greeting>\nclass Greeting extends Component {\n  // Register as <x-greeting>:\n  static tagName = 'x-greeting';\n\n  // Track these attributes:\n  static observedAttributes = ['name'];\n\n  render({ name }) {\n    return <p>Hello, {name}!</p>;\n  }\n}\nregister(Greeting);\n```\n\nIf no `observedAttributes` are specified, they will be inferred from the keys of `propTypes` if present on the Component:\n\n```js\n// Other option: use PropTypes:\nfunction FullName(props) {\n  return <span>{props.first} {props.last}</span>\n}\nFullName.propTypes = {\n  first: Object,   // you can use PropTypes, or this\n  last: Object     // trick to define untyped props.\n};\nregister(FullName, 'full-name');\n```\n\n\n## Related\n\n[preact-shadow-dom](https://github.com/bspaulding/preact-shadow-dom)\n","readmeFilename":"README.md"}