https://github.com/stagas/with-properties
custom elements base class factory with properties mapped to observed attributes
https://github.com/stagas/with-properties
custom-elements mixin observed-attributes properties web-components
Last synced: 9 days ago
JSON representation
custom elements base class factory with properties mapped to observed attributes
- Host: GitHub
- URL: https://github.com/stagas/with-properties
- Owner: stagas
- Created: 2021-12-03T07:20:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-16T17:54:39.000Z (over 4 years ago)
- Last Synced: 2025-09-02T04:39:48.913Z (10 months ago)
- Topics: custom-elements, mixin, observed-attributes, properties, web-components
- Language: TypeScript
- Homepage:
- Size: 227 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
with-properties
custom elements base class factory with properties mapped to observed attributes
🔧 Install
· 🧩 Example
· 📜 API docs
· 🔥 Releases
· 💪🏼 Contribute
· 🖐️ Help
***
## Install
```sh
$ npm i with-properties
```
## API
#### Table of Contents
* [withProperties](#withproperties)
* [Parameters](#parameters)
### withProperties
[src/index.ts:84-129](https://github.com/stagas/with-properties/blob/347859f1dd6689f28f04586900fbe4e8a754a482/src/index.ts#L84-L129 "Source code on GitHub")
```js
class Foo extends withProperties(
HTMLElement,
class {
string? = String
number? = Number
boolean = Boolean
implicitString = 'string'
implicitNumber = 123
implicitBoolean = true
somethingElse? = new Uint8Array(1)
}
) {}
```
#### Parameters
* `parent` **C** The parent constructor to extend (usually `HTMLElement`)
* `propsClass` **[Constructor](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)\
** A "props" class to create the properties from
Returns **any** A base constructor to be extended from
## Contribute
[Fork](https://github.com/stagas/with-properties/fork) or
[edit](https://github.dev/stagas/with-properties) and submit a PR.
All contributions are welcome!
## License
MIT © 2021
[stagas](https://github.com/stagas)