npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pxlwidgets/table-selection

v1.0.0

Published

Adds vertical and rectangular selection to HTML tables to allow copy of specific columns and rows without copying contents of other cells in range.

Downloads

58

Readme

TableSelection

Adds rectangular selection to HTML tables to allow copy of specific columns and rows without copying contents of other cells in range.

  • Supports horizontal, vertical and rectangular selections.
  • Includes clipboard support with table formatting for Excel or other spreadsheet software!
  • It even works on mobile!
  • Tested and working in Chrome, Firefox, Edge, Mobile Chrome and Samsung Browser
  • Lightweight (5,4 kB)

Table of contents

Installation

  • Run npm i @pxlwidgets/table-selection or download the sources.

Using the precompiled js and css files
  • Include dist/js/table-selection.js or dist/js/table-selection.min.js in your project or import using a module loader (more info below).
  • Include dist/css/table-selection.css or dist/css/table-selection.min.css in your project (or use the provided LESS or SCSS file).

Using a module loader

The package includes files for integration in Typescript and ES6 projects:

import { TableSelection } from '@pxlwidgets/table-selection';

Upgrading from v0.9.x

v1.x no longer uses a stylesheet file, so you should remove any of these CSS/SCSS/LESS imports:

  • CSS: dist/css/table-selection.css
  • SCSS: @import '~/@pxlwidgets/table-selection'
  • LESS: @include 'node_modules/@pxlwidgets/table-selection/dist/less/table-selection.less'

Usage

  • Add .table-selection class to the table(s) you want to apply the selection functionality on.
  • Initialize the script using new TableSelection().

Note You can use a different DOM selector by setting the selector configuration option when creating the Javascript instance.

Javascript API

The constructor takes one, optional argument.

constructor(config: TableSelectionConfig = {})

The config parameter (interface TableSelectionConfig) has the following properties:

| Property | Type | Required | Default | Description | |---------------------|----------|----------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | selector | string | No | '.table-selection' | Sets the DOM selector to apply the functionality to. This should point to one or more table elements on your page. E.g. table or .table. | | selectionCssMode | string | No | '.style' | One of 'style' or 'cssClass'. Sets which method to use to highlight selected cells. 'style' uses style attributes with CSS variables. 'cssClass' adds the CSS class specified in the selectionCssClass config property. | | selectionCssClass | string | No | 'selected' | Sets the CSS class to apply to 'selected' table cells. E.g. active, selected or highlighted. This only applies if the selectionCssMode is set to 'cssClass' and requires you to add styles for the selector yourself. |

Example usage :

new TableSelection({
  selector: '#my-table',
  selectionCssMode: 'cssClass',
  selectionCssClass: 'my-highlighted-cell-class',
});

For example:

new TableSelection();
new TableSelection({ selector: 'table' });

Demo

View live example on Codepen

License

MIT License

Copyright (c) 2019 Wouter Smit Copyright (c) 2019 PXL.Widgets B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.