{"id":18751141,"url":"https://github.com/substrate-system/password-field","last_synced_at":"2025-06-12T23:37:17.368Z","repository":{"id":247543613,"uuid":"824802262","full_name":"substrate-system/password-field","owner":"substrate-system","description":"Web component input for passwords","archived":false,"fork":false,"pushed_at":"2025-04-07T00:55:48.000Z","size":87,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T00:09:30.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://substrate-system.github.io/password-field/","language":"TypeScript","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/substrate-system.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-07-06T01:54:42.000Z","updated_at":"2025-03-26T05:02:26.000Z","dependencies_parsed_at":"2024-11-18T05:19:11.027Z","dependency_job_id":"d3efd08e-3c0b-417e-80a0-f6070aa66d79","html_url":"https://github.com/substrate-system/password-field","commit_stats":null,"previous_names":["substrate-system/password-field"],"tags_count":6,"template":false,"template_full_name":"substrate-system/template-web-component","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fpassword-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fpassword-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fpassword-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fpassword-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/substrate-system","download_url":"https://codeload.github.com/substrate-system/password-field/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647299,"owners_count":21139086,"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","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-11-07T17:14:37.070Z","updated_at":"2025-04-13T00:10:18.626Z","avatar_url":"https://github.com/substrate-system.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# password field\n![tests](https://github.com/substrate-system/password-field/actions/workflows/nodejs.yml/badge.svg)\n[![types](https://img.shields.io/npm/types/@substrate-system/password-field?style=flat-square)](README.md)\n[![module](https://img.shields.io/badge/module-ESM%2FCJS-blue?style=flat-square)](README.md)\n[![install size](https://packagephobia.com/badge?p=@substrate-system/password-field)](https://packagephobia.com/result?p=@substrate-system/password-field)\n[![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver\u0026style=flat-square)](https://semver.org/)\n[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\nWeb component for password inputs\n\n[See a live demonstration](https://substrate-system.github.io/password-field/)\n\n__*Featuring*__\n\nAn eyeball button that will change the visiblity of the password.\n\nThis state is tracked by the webcomponent itself, but it can also be set by an attribute, `visible`. If `visible` is present on the tag, then you can see the password.\n\nSee [./example](./example/index.ts) for an example of using the attribute to control visiblity, and keeping two inputs in sync with each other.\n\n\u003c!-- toc --\u003e\n\n- [Install](#install)\n- [tl;dr](#tldr)\n- [API](#api)\n  * [Events](#events)\n  * [Attributes](#attributes)\n  * [ESM \u0026 CJS](#esm--cjs)\n  * [ESM](#esm)\n  * [Common JS](#common-js)\n- [CSS](#css)\n- [Example](#example)\n\n\u003c!-- tocstop --\u003e\n\n## Install\n\n```sh\nnpm i -S @substrate-system/password-field\n```\n\n## tl;dr\nImport the JS component and CSS.\n\n```js\nimport { PasswordField } from '@substrate-system/password-field'\nimport '@substrate-system/password-field/css'\n// or import minified css\nimport '@substrate-system/password-field/css/min'\n```\n\nUse the tag in HTML\n\n```html\n\u003cform\u003e\n    \u003cpassword-field\n        name=\"password\"\n        display-name=\"New Password\"\n    \u003e\u003c/password-field\u003e\n\u003c/form\u003e\n```\n\nListen for events in JS\n\n```js\nimport { PasswordField } from '@substrate-system/password-field'\nconst eventName = PasswordField.event('change-visibility')\n\nform?.addEventListener(eventName, ev =\u003e {\n    const { isVisible } = ev.detail\n    console.log('is visible', isVisible)\n})\n```\n\n## API\n\n### Events\n\n* `password-field:change-visiblity`\n\n    ```js\n    import { PasswordField } from '../src/index.js'\n    PasswordField.event('change-visiblity')\n    // =\u003e 'password-field:change-visiblity'\n    ```\n\n    Fired when someone clicks the eyeball button in the field. The event\n    `.detail` has a property `isVisible`\n\n    ```js\n    form?.addEventListener(PasswordField.event('change-visibility'), ev =\u003e {\n        const { isVisible } = ev.detail\n    })\n    ```\n\n### Attributes\n\n* `visible`\n* `display-name`\n* `required`\n* `autocomplete`\n* `name`\n\n\u003e [!NOTE]  \n\u003e The `name` attribute is used for an `id` on the element also, so it should\n\u003e be unique.\n\n### ESM \u0026 CJS\n\nThis exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).\n\n### ESM\n```js\nimport '@namespace/package/module'\n```\n\n### Common JS\n```js\nrequire('@namespace/package/module')\n```\n\n## CSS\n\n```js\nimport '@namespace/package-name/css'\n```\n\nOr minified:\n```js\nimport '@namespace/package-name/css/min'\n```\n\n## Example\nUse event bubbling to attach a single listener to the parent form. Use the imported component, `PasswordField`, to get the namespaced event name.\n\n```js\nimport { PasswordField } from '@substrate-system/password-field'\nimport '@substrate-field/password-field/css'\n\nconst form = document.querySelector('form')\n\nform?.addEventListener(PasswordField.event('change-visibility'), ev =\u003e {\n    // synchronize changes in visibility, so\n    // both inputs are either visible or not visible\n    const { isVisible } = ev.detail\n    document.querySelectorAll('password-field').forEach(el =\u003e {\n        if (isVisible) {\n            el.setAttribute('visible', '')\n        } else {\n            el.removeAttribute('visible')\n        }\n    })\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fpassword-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubstrate-system%2Fpassword-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fpassword-field/lists"}