{"id":13708006,"url":"https://github.com/julienetie/create-interface","last_synced_at":"2025-08-15T10:30:44.243Z","repository":{"id":89939147,"uuid":"182969514","full_name":"julienetie/create-interface","owner":"julienetie","description":"Create Custom Elements for Declarative and Functional Programming","archived":false,"fork":false,"pushed_at":"2024-04-29T08:52:50.000Z","size":33,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T03:54:46.106Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/julienetie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-23T08:27:24.000Z","updated_at":"2025-02-01T06:03:24.000Z","dependencies_parsed_at":"2024-10-04T01:04:51.321Z","dependency_job_id":"7d93fd75-fb7f-4759-a107-9afc77013da2","html_url":"https://github.com/julienetie/create-interface","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":"0.30000000000000004","last_synced_commit":"b011f4f45db6557e68846f77971e227f9569f0a4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/julienetie/create-interface","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienetie%2Fcreate-interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienetie%2Fcreate-interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienetie%2Fcreate-interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienetie%2Fcreate-interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/julienetie","download_url":"https://codeload.github.com/julienetie/create-interface/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julienetie%2Fcreate-interface/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270558032,"owners_count":24606598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T22:01:52.781Z","updated_at":"2025-08-15T10:30:43.988Z","avatar_url":"https://github.com/julienetie.png","language":"JavaScript","readme":"# Create Interface\n\n## Create custom elements without classes\n\nCreate Interface is not a wrapper around class, it's uses `Reflect.construct` internally for new instances and inheritance.\n\n\u003e #### _createInterface_ is a [declarative](https://en.wikipedia.org/wiki/Declarative_programming) method that creates a [custom-element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) without using the [_class_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) syntax.\n\n_createInterface_ is preferred for declarative and [functional programming](https://wiki.haskell.org/Functional_programming#Features_of_functional_languages) paradigm styles. _createInterface_ mimics the mannerism of \n`Object.assign`. It will create a new custom element from a base element whilst inheriting the base element's callback functions. \nThere are two way to use _createInterface_.\n\n### Install \n`npm install create-interface` or `yarn add create-interface`\n\n## Create an Autonomous/ Built-in Custom Element from an HTML Interface\n```javascript \nimport createInterface from 'create-interface';\n\nconst newCustomElement = createInterface(\n  'new-cusomt-element', \n  HTMLElement, \n  {...callbacks}\n);\n\ncustomElements.define('new-cusomt-element', newCustomElement); \n\n```\n## Extend a Custom Element from a Custom Element \n```javascript \n...\n\nconst anotherCustomElement = createInterface(\n  'new-cusomt-element',\n  newCustomElement,\n  {...newCallbacks}\n);\n\ncustomElements.define('another-cusomt-element', anotherCustomElement); \n```\n\n## Lifecycle Callbacks\n\n\u003e The lifecycle callbacks are smilar to native _customElement_ callbacks but with some slight differences:\n\n ### _adopted(element)_\n\u003e **_adopted_**  is the equivalence of [**_adoptedCallback_**](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#Using_the_lifecycle_callbacks) but without context. Instead it provides the active _element_ as an argument.\n\n ### _attributeChanged(element, name, oldValue, newValue)_\n\u003e **_attributeChanged_** is the equivalence of [**_attributeChangedCallback_**](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#Using_the_lifecycle_callbacks) but without context. It provides the following argumetnts respectively: \n\u003e - _element_\n\u003e - _name_ \n\u003e - _oldValue_\n\u003e - _newValue_\n\n\n ### _disconnected(element)_\n\u003e **_disconnected_**  is the equivalence of [**_disconnectedCallback_**](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#Using_the_lifecycle_callbacks) but without context. Instead it provides the active _element_ as an argument.\n\n ### _connected(element)_\n\u003e **_connected_**  is the equivalence of [**_connectedCallback_**](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#Using_the_lifecycle_callbacks) but without context. Instead it provides the active _element_ as an argument.\n\n ### _observedAttributes(element)_\n\u003e **_observedAttributes_**  is the equivalence of [**_static get observedAttributes()_**](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#Using_the_lifecycle_callbacks) but without context. It expects an array of attribute names as a return value.\n\n ## Browser Support\n\u003e This method does not provide polyfills. It is intended to support enviroments that support Custom Elements (V1).\nCheck for native support [here](https://caniuse.com/#feat=custom-elementsv1):\n\nMIT 2024 Julien Etienne\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulienetie%2Fcreate-interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulienetie%2Fcreate-interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulienetie%2Fcreate-interface/lists"}