{"id":35438519,"url":"https://github.com/aarongustafson/table-modifiable","last_synced_at":"2026-01-20T17:01:14.291Z","repository":{"id":328753125,"uuid":"1113395376","full_name":"aarongustafson/table-modifiable","owner":"aarongustafson","description":"A web component that enables users to hide \u0026 show columns on an HTML table.","archived":false,"fork":false,"pushed_at":"2025-12-15T04:43:33.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-17T23:59:58.092Z","etag":null,"topics":["light-dom","table","web-components"],"latest_commit_sha":null,"homepage":"https://aarongustafson.github.io/table-modifiable/","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/aarongustafson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-09T23:21:10.000Z","updated_at":"2025-12-15T04:43:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aarongustafson/table-modifiable","commit_stats":null,"previous_names":["aarongustafson/table-modifiable"],"tags_count":2,"template":false,"template_full_name":"aarongustafson/web-component-starter","purl":"pkg:github/aarongustafson/table-modifiable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarongustafson%2Ftable-modifiable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarongustafson%2Ftable-modifiable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarongustafson%2Ftable-modifiable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarongustafson%2Ftable-modifiable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aarongustafson","download_url":"https://codeload.github.com/aarongustafson/table-modifiable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarongustafson%2Ftable-modifiable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["light-dom","table","web-components"],"created_at":"2026-01-02T23:04:11.770Z","updated_at":"2026-01-20T17:01:14.285Z","avatar_url":"https://github.com/aarongustafson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# table-modifiable Web Component\n\n[![npm version](https://img.shields.io/npm/v/@aarongustafson/table-modifiable.svg)](https://www.npmjs.com/package/@aarongustafson/table-modifiable) [![Build Status](https://img.shields.io/github/actions/workflow/status/aarongustafson/table-modifiable/ci.yml?branch=main)](https://github.com/aarongustafson/table-modifiable/actions)\n\nA web component that enables users to hide \u0026 show columns on an HTML table.\n\n## Demo\n\n[Live Demo](https://aarongustafson.github.io/table-modifiable/demo/) ([Source](./demo/index.html))\n\nAdditional demos:\n\n- [ESM CDN Demo](https://aarongustafson.github.io/table-modifiable/demo/esm.html) ([Source](./demo/esm.html))\n- [Unpkg CDN Demo](https://aarongustafson.github.io/table-modifiable/demo/unpkg.html) ([Source](./demo/unpkg.html))\n\n## Installation\n\n```bash\nnpm install @aarongustafson/table-modifiable\n```\n\n## Usage\n\n### Option 1: Auto-define the custom element (easiest)\n\nImport the package to automatically define the `\u003ctable-modifiable\u003e` custom element:\n\n```javascript\nimport '@aarongustafson/table-modifiable';\n```\n\nOr use the define-only script in HTML:\n\n```html\n\u003cscript src=\"./node_modules/@aarongustafson/table-modifiable/define.js\" type=\"module\"\u003e\u003c/script\u003e\n```\n\n### Option 2: Import the class and define manually\n\nImport the class and define the custom element with your preferred tag name:\n\n```javascript\nimport { TableModifiableElement } from '@aarongustafson/table-modifiable/table-modifiable.js';\n\ncustomElements.define('my-custom-name', TableModifiableElement);\n```\n\nYou can also call the provided helper to register the element without importing the class:\n\n```javascript\nimport { defineTableModifiable } from '@aarongustafson/table-modifiable/define.js';\n\ndefineTableModifiable('my-custom-name');\n```\n\n### Basic Example\n\n```html\n\u003ctable-modifiable removable=\"Name,Email,Phone\" start-with=\"Name,Email\"\u003e\n  \u003ctable\u003e\n    \u003cthead\u003e\n      \u003ctr\u003e\n        \u003cth\u003eName\u003c/th\u003e\n        \u003cth\u003eEmail\u003c/th\u003e\n        \u003cth\u003ePhone\u003c/th\u003e\n      \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n      \u003ctr\u003e\n        \u003ctd\u003eJohn Doe\u003c/td\u003e\n        \u003ctd\u003ejohn@example.com\u003c/td\u003e\n        \u003ctd\u003e555-1234\u003c/td\u003e\n      \u003c/tr\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/table-modifiable\u003e\n```\n\n## Attributes\n\n| Attribute | Type | Default | Description |\n|-----------|------|---------|-------------|\n| `removable` | `string` | `\"\"` | Comma-separated list of all column names that can be shown/hidden |\n| `start-with` | `string` | (all removable) | Comma-separated list of which columns should be visible by default. If not specified, all removable columns will be shown initially |\n| `button-label` | `string` | `\"Modify Table\"` | Text label for the toggle button |\n| `button-aria-label` | `string` | (same as button-label) | Accessible label for the toggle button. Use this to provide a more descriptive label for screen readers if needed |\n| `tools-label` | `string` | `\"Show/Hide Columns\"` | Heading text for the popover panel |\n\n## Properties\n\nAll of the attributes above have matching camelCase properties (`removable`, `startWith`, `buttonLabel`, `buttonAriaLabel`, `toolsLabel`). Setting a property updates the corresponding attribute and schedules the component to re-render.\n\n```javascript\nconst modifiable = document.querySelector('table-modifiable');\nmodifiable.removable = 'Name,Email';\nmodifiable.startWith = 'Name';\n```\n\n## Events\n\nThe component fires custom events that you can listen to:\n\n| Event | Description | Detail |\n|-------|-------------|--------|\n| `table-modifiable:change` | Fired when a column's visibility is toggled | `{ column: string, visible: boolean }` |\n\n### Example Event Handling\n\n```javascript\nconst element = document.querySelector('table-modifiable');\n\nelement.addEventListener('table-modifiable:change', (event) =\u003e {\n  console.log(`Column \"${event.detail.column}\" is now ${event.detail.visible ? 'visible' : 'hidden'}`);\n});\n```\n\n## CSS Custom Properties\n\n| Property | Default | Description |\n|----------|---------|-------------|\n| `--table-modifiable-tool-bg` | (none) | Background color for the modification tools popover |\n| `--table-modifiable-tool-color` | (none) | Text color for the modification tools popover |\n\n### Example Styling\n\nYou can style the generated elements directly to customize the appearance:\n\n```css\n/* Style the toggle button */\n.modification-tools-toggle {\n  background: #0969da;\n  color: white;\n  border: none;\n  padding: 0.5rem 1rem;\n  border-radius: 4px;\n  font-size: 1rem;\n  cursor: pointer;\n}\n\n.modification-tools-toggle:hover {\n  background: #0860ca;\n}\n\n/* Style the popover */\n.modification-tools {\n  background: var(--table-modifiable-tool-bg, white);\n  color: var(--table-modifiable-tool-color, #333);\n  padding: 1rem;\n  border-radius: 6px;\n  border: 1px solid #d0d7de;\n  box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);\n  min-width: 250px;\n}\n\n.modification-tools-heading {\n  font-weight: bold;\n  display: block;\n  margin-bottom: 0.75rem;\n  font-size: 1.1rem;\n}\n\n.modification-tools ul {\n  list-style: none;\n  padding: 0;\n  margin: 0;\n  display: flex;\n  flex-direction: column;\n  gap: 0.5rem;\n}\n\n.modification-tools li {\n  margin: 0;\n}\n\n.modification-tools label {\n  cursor: pointer;\n  user-select: none;\n}\n```\n\n## How It Works\n\nThis component wraps an HTML table and adds interactive controls to show/hide columns:\n\n1. **Place your table inside the component**: The component uses Light DOM, so your table remains in the regular DOM and is fully accessible.\n\n2. **Specify removable columns**: Use the `removable` attribute to list which columns can be toggled. The column names must match the text content of the `\u003cth\u003e` elements in the first header row exactly.\n\n3. **Set initial visibility**: Optionally use `start-with` to specify which columns should be visible when the page loads. Any columns in `removable` but not in `start-with` will be hidden initially.\n\n4. **Toggle via popover**: The component creates a button that opens a popover with checkboxes. Users can check/uncheck these to show/hide the corresponding columns. The popover uses the native [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API).\n\n5. **Customize labels**: Use the `button-label`, `button-aria-label`, and `tools-label` attributes to customize the text shown to users.\n\n**Note**: This component works with simple tables (one header row, matching body cells). It does not support `colspan` or `rowspan` attributes.\n\n## Advanced Examples\n\n### Table with Multiple Columns\n\n```html\n\u003ctable-modifiable removable=\"Product,Price,Stock,Category\" start-with=\"Product,Price\"\u003e\n  \u003ctable\u003e\n    \u003cthead\u003e\n      \u003ctr\u003e\n        \u003cth\u003eProduct\u003c/th\u003e\n        \u003cth\u003ePrice\u003c/th\u003e\n        \u003cth\u003eStock\u003c/th\u003e\n        \u003cth\u003eCategory\u003c/th\u003e\n      \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n      \u003ctr\u003e\n        \u003ctd\u003eWidget\u003c/td\u003e\n        \u003ctd\u003e$9.99\u003c/td\u003e\n        \u003ctd\u003e42\u003c/td\u003e\n        \u003ctd\u003eTools\u003c/td\u003e\n      \u003c/tr\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/table-modifiable\u003e\n```\n\n### Customizing Labels\n\n```html\n\u003ctable-modifiable\n  removable=\"Name,Email,Phone,Address\"\n  start-with=\"Name,Email\"\n  button-label=\"Customize Columns\"\n  button-aria-label=\"Customize which columns are visible in the table\"\n  tools-label=\"Select Visible Columns\"\u003e\n  \u003ctable\u003e\n    \u003cthead\u003e\n      \u003ctr\u003e\n        \u003cth\u003eName\u003c/th\u003e\n        \u003cth\u003eEmail\u003c/th\u003e\n        \u003cth\u003ePhone\u003c/th\u003e\n        \u003cth\u003eAddress\u003c/th\u003e\n      \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n      \u003ctr\u003e\n        \u003ctd\u003eJane Doe\u003c/td\u003e\n        \u003ctd\u003ejane@example.com\u003c/td\u003e\n        \u003ctd\u003e555-5678\u003c/td\u003e\n        \u003ctd\u003e123 Main St\u003c/td\u003e\n      \u003c/tr\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/table-modifiable\u003e\n```\n\n## TypeScript\n\nThis package ships bundled type definitions (`table-modifiable.d.ts`). You can import the element type, the change event payload, and the registration helper:\n\n```ts\nimport type {\n  TableModifiableElement,\n  TableModifiableChangeEvent,\n} from '@aarongustafson/table-modifiable/table-modifiable.js';\nimport { defineTableModifiable } from '@aarongustafson/table-modifiable/define.js';\n\ndefineTableModifiable();\n\nconst element = document.querySelector('table-modifiable') as TableModifiableElement;\n\nelement.addEventListener(\n  'table-modifiable:change',\n  (event: TableModifiableChangeEvent) =\u003e {\n    console.log(event.detail.column, event.detail.visible);\n  },\n);\n```\n\n## Browser Support\n\nThis component uses modern web standards:\n- Custom Elements v1\n- ES Modules\n- Popover API\n\nFor older browsers, you may need polyfills.\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Run tests\nnpm test\n\n# Run tests with coverage\nnpm run test:coverage\n\n# Lint code\nnpm run lint\n\n# Format code\nnpm run format\n\n# View demo\nopen demo/index.html\n```\n\n## License\n\nMIT © [Aaron Gustafson](https://www.aaron-gustafson.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarongustafson%2Ftable-modifiable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faarongustafson%2Ftable-modifiable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarongustafson%2Ftable-modifiable/lists"}