{"id":22279311,"url":"https://github.com/19h47/19h47-checkbox","last_synced_at":"2025-03-25T18:26:07.701Z","repository":{"id":34448875,"uuid":"178957101","full_name":"19h47/19h47-checkbox","owner":"19h47","description":"☑️","archived":false,"fork":false,"pushed_at":"2024-03-29T00:00:45.000Z","size":2121,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T06:07:25.540Z","etag":null,"topics":["checkbox","checkboxes","html","javascript"],"latest_commit_sha":null,"homepage":"https://19h47.github.io/19h47-checkbox/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/19h47.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01T22:32:39.000Z","updated_at":"2024-06-22T04:28:29.290Z","dependencies_parsed_at":"2024-06-22T04:28:20.578Z","dependency_job_id":"7049eecf-33e0-4d69-8558-592f723cf9db","html_url":"https://github.com/19h47/19h47-checkbox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/19h47%2F19h47-checkbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/19h47%2F19h47-checkbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/19h47%2F19h47-checkbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/19h47%2F19h47-checkbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/19h47","download_url":"https://codeload.github.com/19h47/19h47-checkbox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245518549,"owners_count":20628550,"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":["checkbox","checkboxes","html","javascript"],"created_at":"2024-12-03T15:18:59.575Z","updated_at":"2025-03-25T18:26:07.667Z","avatar_url":"https://github.com/19h47.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @19h47/checkbox\n\n## Install\n\n```\nyarn add @19h47/checkbox\n```\n\n## HTML\n\n```html\n\u003cdiv role=\"checkbox\" aria-checked=\"false\"\u003e\n\t\u003cbutton type=\"button\" tabindex=\"-1\"\u003eDo you want to click me?\u003c/button\u003e\n\t\u003cdiv style=\"display: none;\"\u003e\n\t\t\u003cinput id=\"option\" name=\"option\" value=\"false\" type=\"checkbox\" /\u003e\n\t\u003c/div\u003e\n\u003c/div\u003e\n```\n\n## JavaScript\n\n```javascript\nimport Checkbox from '@19h47/checkbox';\n\nconst $checkbox = document.querySelector('[role=\"checkbox\"]');\nconst checkbox = new Checkbox($checkbox);\n\ncheckbox.init();\n```\n\n## Keyboard Support\n\n| Key   | Function                                               |\n| ----- | ------------------------------------------------------ |\n| Tab   | Moves keyboard focus to the `checkbox`.                |\n| Space | Toggles checkbox between checked and unchecked states. |\n\n## Role, Property, State, and Tabindex Attributes\n\n| Role       | Attribute              | Element | Usage                                                                                                                                                    |\n| ---------- | ---------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |\n|            |                        | `h3`    | Provides a grouping label for the group of checkboxes.                                                                                                   |\n| `group`    |                        | `div`   | Identifies the div element as a group container for the checkboxes.                                                                                      |\n|            | `aria-labelledby`      | `div`   | The `aria-labelledby` attribute references the id attribute of the `h3` element to define the accessible name for the group of checkboxes.\u003c/li\u003e\u003c/ul\u003e     |\n| `checkbox` |                        | `div`   | \u003cul\u003e\u003cli\u003eIdentifies the `div` element as a `checkbox`.\u003c/li\u003e\u003cli\u003eThe child text content of this div provides the accessible name of the checkbox.\u003c/li\u003e\u003c/ul\u003e |\n|            | `tabindex=\"0\"`         | `div`   | Includes the checkbox in the page tab sequence.                                                                                                          |\n|            | `aria-checked=\"false\"` | `div`   | Indicates the `checkbox` is **not** checked.                                                                                                             |\n|            | `aria-checked=\"true\"`  | `div`   | Indicates the `checkbox` is checked.                                                                                                                     |\n\n## Methods\n\n| Method         | Description             | Arguments                                                                          |\n| -------------- | ----------------------- | ---------------------------------------------------------------------------------- |\n| `activate()`   | Activate the checkbox   | `trigger` (optional) Whether or not the event should be trigger. Default to `true` |\n| `deactivate()` | Deactivate the checkbox | `trigger` (optional) Whether or not the event should be trigger. Default to `true` |\n\n```javascript\nimport Checkbox from '@19h47/checkbox';\n\nconst $checkbox = document.querySelector('[role=\"checkbox\"]');\nconst checkbox = new Checkbox($checkbox);\n\ncheckbox.init();\n\ncheckbox.activate();\ncheckbox.deactivate();\n```\n\n## Event\n\n### Activate\n\n```javascript\nimport Checkbox from '@19h47/checkbox';\n\nconst $checkbox = document.querySelectorAll('[role=\"checkbox\"]');\nconst checkbox = new Checkbox($checkbox);\n\ncheckbox.init();\n\ncheckbox.$input.addEventListener('activate', event =\u003e {\n\tconst {\n\t\ttarget: { value },\n\t} = event;\n\n\tconsole.log(value); // Current activate value\n});\n```\n\n### Deactivate\n\n```javascript\nimport Checkbox from '@19h47/checkbox';\n\nconst $checkbox = document.querySelectorAll('[role=\"checkbox\"]');\nconst checkbox = new Checkbox($checkbox);\n\ncheckbox.init();\n\ncheckbox.$input.addEventListener('deactivate', event =\u003e {\n\tconst {\n\t\ttarget: { value },\n\t} = event;\n\n\tconsole.log(value); // Current deactivate value\n});\n```\n\n## CheckboxGroup\n\nThe `CheckboxGroup` is a wrapper class around `Checkbox`.\n\nWhen a user clicks a checkbox, holds Shift, and then clicks another checkbox a few rows down, all the checkboxes inbetween those two checkboxes should be checked.\n\n```html\n\u003cdiv role=\"group\"\u003e\n\t\u003cdiv tabindex=\"0\" role=\"checkbox\" aria-checked=\"false\"\u003e\n\t\t\u003cbutton type=\"button\" tabindex=\"-1\"\u003e\u003c/button\u003e\n\t\tCurst\n\t\t\u003cdiv style=\"display: none;\"\u003e\n\t\t\t\u003cinput id=\"curst\" name=\"curst\" value=\"Curst\" type=\"checkbox\" /\u003e\n\t\t\u003c/div\u003e\n\t\u003c/div\u003e\n\n\t\u003cdiv tabindex=\"0\" role=\"checkbox\" aria-checked=\"false\"\u003e\n\t\t\u003cbutton type=\"button\" tabindex=\"-1\"\u003e\u003c/button\u003e\n\t\tDoppelganger, Greater\n\t\t\u003cdiv style=\"display: none;\"\u003e\n\t\t\t\u003cinput\n\t\t\t\tid=\"doppelganger-greater\"\n\t\t\t\tname=\"city-of-splendors[]\"\n\t\t\t\tvalue=\"Doppelganger, greater\"\n\t\t\t\ttype=\"checkbox\"\n\t\t\t/\u003e\n\t\t\u003c/div\u003e\n\t\u003c/div\u003e\n\n\t\u003cdiv tabindex=\"0\" role=\"checkbox\" aria-checked=\"false\"\u003e\n\t\t\u003cbutton type=\"button\" tabindex=\"-1\"\u003e\u003c/button\u003e\n\t\tDuhlarkin\n\t\t\u003cdiv style=\"display: none;\"\u003e\n\t\t\t\u003cinput id=\"duhlarkin\" name=\"city-of-splendors[]\" value=\"Duhlarkin\" type=\"checkbox\" /\u003e\n\t\t\u003c/div\u003e\n\t\u003c/div\u003e\n\u003c/div\u003e\n```\n\n```javascript\nimport { CheckboxGroup } from '@19h47/checkbox';\n\nconst $element = document.querySelector('[role=\"group\"]');\nconst checkboxgroup = new CheckboxGroup($element);\n\ncheckbox.init();\n```\n\n## Example\n\nAn example is located right [here](https://19h47.github.io/19h47-checkbox/), see [sources](https://github.com/19h47/19h47-checkbox/blob/main/index.html).\n\n## References\n\n-   [Checkbox Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F19h47%2F19h47-checkbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F19h47%2F19h47-checkbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F19h47%2F19h47-checkbox/lists"}