Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-inclusive-sortable-table

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-inclusive-sortable-table - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

186

dist/index.es.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
var Arrow = function Arrow(_ref) {
var sortDir = _ref.sortDir,
isCurrent = _ref.isCurrent;
var ascending = sortDir === 'ascending';
return React.createElement(
'svg',
{ viewBox: '0 0 100 200', width: '100', height: '200' },
!(!ascending && isCurrent) && React.createElement('polyline', { points: '20 50, 50 20, 80 50' }),
React.createElement('line', { x1: '50', y1: '20', x2: '50', y2: '180' }),
!(ascending && isCurrent) && React.createElement('polyline', { points: '20 150, 50 180, 80 150' })
);
};
function styleInject(css, ref) {

@@ -31,6 +45,58 @@ if ( ref === void 0 ) ref = {};

var css = ":root {\n font-size: calc(1rem + 0.5vw);\n font-family: sans-serif;\n margin: 1rem;\n}\n\n:focus {\n -webkit-box-shadow: 0 0 0 4px DodgerBlue;\n box-shadow: 0 0 0 4px DodgerBlue;\n outline: none;\n}\n\ndiv:not([tabindex]):focus {\n -webkit-box-shadow: none;\n box-shadow: none;\n}\n\n* {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\nbody {\n overflow-x: hidden;\n}\n\n.styles_tableContainer__fjLYp {\n overflow-x: auto;\n}\n\n@media (max-width: 400px) {\n .styles_tableContainer__fjLYp {\n display: none;\n }\n}\n\ntable {\n border-collapse: collapse;\n}\n\nth,\ntd {\n border: 2px solid #000;\n padding: 0.75rem;\n text-align: left;\n}\n\nth {\n font-weight: bold;\n white-space: nowrap;\n}\n\nth {\n background: #000;\n color: #fff;\n}\n\ntr:first-of-type th:not(:last-child) {\n border-right-color: #fff;\n}\n\ntr:first-child th:first-child,\ntr:not(:first-child):not(:last-child) th {\n border-bottom-color: #fff !important;\n}\n\ncaption {\n margin-bottom: 0.5rem;\n font-style: italic;\n text-align: left;\n}\n\n.styles_listsContainer__3xrp- {\n display: block;\n}\n\n@media (min-width: 400px) {\n .styles_listsContainer__3xrp- {\n display: none;\n }\n}\n\ndl {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n\ndl > * {\n -ms-flex: 0 0 50%;\n flex: 0 0 50%;\n margin: 0;\n}\n\ndt {\n padding-right: 0.5rem;\n}\n\ndt {\n font-weight: bold;\n}\n\nth button {\n background: #fff;\n color: #000;\n border: 0;\n padding: 0.125rem 0.5rem;\n border-radius: 0.25rem;\n font-weight: bold;\n vertical-align: middle;\n margin-left: 0.333rem;\n}\n\nh3 {\n background: #000;\n color: #fff;\n padding: 0.5rem;\n}\n\nth svg {\n stroke: currentColor;\n stroke-width: 20;\n stroke-linecap: round;\n stroke-linejoin: round;\n fill: none;\n width: 0.5rem;\n height: 1.5em;\n}\n\n.styles_visually-hidden__xyp28 {\n position: absolute !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n padding: 0 !important;\n border: 0 !important;\n height: 1px !important;\n width: 1px !important;\n overflow: hidden !important;\n}\n";
var styles = { "tableContainer": "styles_tableContainer__fjLYp", "listsContainer": "styles_listsContainer__3xrp-", "visually-hidden": "styles_visually-hidden__xyp28" };
var css = "div:not([tabindex]):focus {\n -webkit-box-shadow: none;\n box-shadow: none;\n}\n\n* {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\nbody {\n overflow-x: hidden;\n}\n\n.styles_tableContainer__fjLYp {\n overflow-x: auto;\n}\n\n@media (max-width: 400px) {\n .styles_tableContainer__fjLYp {\n display: none;\n }\n}\n\ntable {\n border-collapse: collapse;\n}\n\nth,\ntd {\n text-align: left;\n padding: 0.75rem;\n}\n\nth {\n white-space: nowrap;\n}\n\ncaption {\n margin-bottom: 0.5rem;\n text-align: left;\n}\n\n.styles_listsContainer__3xrp- {\n display: block;\n}\n\n@media (min-width: 400px) {\n .styles_listsContainer__3xrp- {\n display: none;\n }\n}\n\ndl {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n\ndl > * {\n -ms-flex: 0 0 50%;\n flex: 0 0 50%;\n margin: 0;\n margin-bottom: 0.5rem;\n}\n\ndt {\n padding-right: 0.5rem;\n}\n\ndt {\n font-weight: bold;\n}\n\nth button {\n background: #fff;\n color: #000;\n border: 0;\n padding: 0.125rem 0.5rem;\n border-radius: 0.25rem;\n font-weight: bold;\n vertical-align: middle;\n margin-left: 0.333rem;\n}\n\n\nth svg {\n stroke: currentColor;\n stroke-width: 20;\n stroke-linecap: round;\n stroke-linejoin: round;\n fill: none;\n width: 0.5rem;\n height: 1.5em;\n}\n\n.styles_visuallyHidden__12unE {\n position: absolute !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n padding: 0 !important;\n border: 0 !important;\n height: 1px !important;\n width: 1px !important;\n overflow: hidden !important;\n}\n";
var styles = { "tableContainer": "styles_tableContainer__fjLYp", "listsContainer": "styles_listsContainer__3xrp-", "visuallyHidden": "styles_visuallyHidden__12unE" };
styleInject(css);
var DefinitionList = function DefinitionList(_ref) {
var caption = _ref.caption,
rows = _ref.rows,
headers = _ref.headers;
return React.createElement(
'div',
{ className: styles.listsContainer },
React.createElement(
'h2',
null,
caption
),
rows.map(function (row, i) {
return React.createElement(
'div',
{ key: i },
React.createElement(
'h3',
null,
row[0]
),
React.createElement(
'dl',
null,
headers.map(function (header, i) {
return i > 0 && React.createElement(
React.Fragment,
{ key: i },
React.createElement(
'dt',
null,
header
),
React.createElement(
'dd',
null,
row[i]
)
);
})
)
);
})
);
};
DefinitionList.propTypes = {
caption: PropTypes.string.isRequired,
rows: PropTypes.array.isRequired,
headers: PropTypes.array.isRequired
};
var classCallCheck = function (instance, Constructor) {

@@ -84,16 +150,5 @@ if (!(instance instanceof Constructor)) {

var Arrow = function Arrow(props) {
var ascending = props.sortDir === 'ascending';
return React.createElement(
'svg',
{ viewBox: '0 0 100 200', width: '100', height: '200' },
!(!ascending && props.isCurrent) && React.createElement('polyline', { points: '20 50, 50 20, 80 50' }),
React.createElement('line', { x1: '50', y1: '20', x2: '50', y2: '180' }),
!(ascending && props.isCurrent) && React.createElement('polyline', { points: '20 150, 50 180, 80 150' })
);
};
var Table = function (_Component) {
inherits(Table, _Component);
var Table = function (_React$Component) {
inherits(Table, _React$Component);
function Table(props) {

@@ -143,5 +198,5 @@ classCallCheck(this, Table);

value: function componentDidMount() {
var _container = this.container,
scrollWidth = _container.scrollWidth,
clientWidth = _container.clientWidth;
var _ref = this.container && this.container.current,
scrollWidth = _ref.scrollWidth,
clientWidth = _ref.clientWidth;

@@ -158,2 +213,10 @@ var scrollable = scrollWidth > clientWidth;

var _props = this.props,
rows = _props.rows,
caption = _props.caption,
headers = _props.headers,
sortable = _props.sortable,
rowHeaders = _props.rowHeaders;
return React.createElement(

@@ -177,3 +240,3 @@ 'div',

{ id: this.captionID },
this.props.caption,
caption,
this.state.tabindex === '0' && React.createElement(

@@ -195,3 +258,3 @@ 'div',

null,
this.props.headers.map(function (header, i) {
headers.map(function (header, i) {
return React.createElement(

@@ -206,3 +269,3 @@ 'th',

header,
_this2.props.sortable && React.createElement(
sortable && React.createElement(
'button',

@@ -218,3 +281,3 @@ { onClick: function onClick() {

'span',
{ className: 'visually-hidden' },
{ className: styles.visuallyHidden },
'sort by ',

@@ -235,3 +298,3 @@ header,

row.map(function (cell, i) {
return _this2.props.rowHeaders && i < 1 ? React.createElement(
return rowHeaders && i < 1 ? React.createElement(
'th',

@@ -251,42 +314,3 @@ { scope: 'row', key: i },

),
React.createElement(
'div',
{ className: styles.listsContainer },
React.createElement(
'h2',
null,
this.props.caption
),
this.props.rows.map(function (row, i) {
return React.createElement(
'div',
{ key: i },
React.createElement(
'h3',
null,
row[0]
),
React.createElement(
'dl',
null,
_this2.props.headers.map(function (header, i) {
return i > 0 && React.createElement(
React.Fragment,
{ key: i },
React.createElement(
'dt',
null,
header
),
React.createElement(
'dd',
null,
row[i]
)
);
})
)
);
})
)
React.createElement(DefinitionList, { caption: caption, rows: rows, headers: headers })
);

@@ -296,35 +320,13 @@ }

return Table;
}(React.Component);
// import './styles.css'
var ExampleComponent = function (_Component) {
inherits(ExampleComponent, _Component);
function ExampleComponent() {
classCallCheck(this, ExampleComponent);
return possibleConstructorReturn(this, (ExampleComponent.__proto__ || Object.getPrototypeOf(ExampleComponent)).apply(this, arguments));
}
createClass(ExampleComponent, [{
key: 'render',
value: function render() {
var headers = ['Band', 'Singer', 'Inception', 'Label'];
var rows = [['Napalm Death', 'Barney Greenway', '1981', 'Century Media'], ['Carcass', 'Jeff Walker', '1985', 'Earache'], ['Extreme Noise Terror', 'Dean Jones', '1985', 'Candlelight'], ['Discordance Axis', 'Jon Chang', '1992', 'Hydrahead']];
return React.createElement(
'div',
{ className: 'App' },
React.createElement(Table, { rows: rows, headers: headers, rowHeaders: true, caption: 'Grindcore bands', sortable: true })
);
}
}]);
return ExampleComponent;
}(Component);
ExampleComponent.propTypes = {
text: PropTypes.string
Table.propTypes = {
caption: PropTypes.string,
headers: PropTypes.array.isRequired,
rowHeaders: PropTypes.bool,
rows: PropTypes.array.isRequired,
sortable: PropTypes.bool
};
export default ExampleComponent;
export default Table;
//# sourceMappingURL=index.es.js.map

@@ -9,2 +9,16 @@ 'use strict';

var Arrow = function Arrow(_ref) {
var sortDir = _ref.sortDir,
isCurrent = _ref.isCurrent;
var ascending = sortDir === 'ascending';
return React__default.createElement(
'svg',
{ viewBox: '0 0 100 200', width: '100', height: '200' },
!(!ascending && isCurrent) && React__default.createElement('polyline', { points: '20 50, 50 20, 80 50' }),
React__default.createElement('line', { x1: '50', y1: '20', x2: '50', y2: '180' }),
!(ascending && isCurrent) && React__default.createElement('polyline', { points: '20 150, 50 180, 80 150' })
);
};
function styleInject(css, ref) {

@@ -37,6 +51,58 @@ if ( ref === void 0 ) ref = {};

var css = ":root {\n font-size: calc(1rem + 0.5vw);\n font-family: sans-serif;\n margin: 1rem;\n}\n\n:focus {\n -webkit-box-shadow: 0 0 0 4px DodgerBlue;\n box-shadow: 0 0 0 4px DodgerBlue;\n outline: none;\n}\n\ndiv:not([tabindex]):focus {\n -webkit-box-shadow: none;\n box-shadow: none;\n}\n\n* {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\nbody {\n overflow-x: hidden;\n}\n\n.styles_tableContainer__fjLYp {\n overflow-x: auto;\n}\n\n@media (max-width: 400px) {\n .styles_tableContainer__fjLYp {\n display: none;\n }\n}\n\ntable {\n border-collapse: collapse;\n}\n\nth,\ntd {\n border: 2px solid #000;\n padding: 0.75rem;\n text-align: left;\n}\n\nth {\n font-weight: bold;\n white-space: nowrap;\n}\n\nth {\n background: #000;\n color: #fff;\n}\n\ntr:first-of-type th:not(:last-child) {\n border-right-color: #fff;\n}\n\ntr:first-child th:first-child,\ntr:not(:first-child):not(:last-child) th {\n border-bottom-color: #fff !important;\n}\n\ncaption {\n margin-bottom: 0.5rem;\n font-style: italic;\n text-align: left;\n}\n\n.styles_listsContainer__3xrp- {\n display: block;\n}\n\n@media (min-width: 400px) {\n .styles_listsContainer__3xrp- {\n display: none;\n }\n}\n\ndl {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n\ndl > * {\n -ms-flex: 0 0 50%;\n flex: 0 0 50%;\n margin: 0;\n}\n\ndt {\n padding-right: 0.5rem;\n}\n\ndt {\n font-weight: bold;\n}\n\nth button {\n background: #fff;\n color: #000;\n border: 0;\n padding: 0.125rem 0.5rem;\n border-radius: 0.25rem;\n font-weight: bold;\n vertical-align: middle;\n margin-left: 0.333rem;\n}\n\nh3 {\n background: #000;\n color: #fff;\n padding: 0.5rem;\n}\n\nth svg {\n stroke: currentColor;\n stroke-width: 20;\n stroke-linecap: round;\n stroke-linejoin: round;\n fill: none;\n width: 0.5rem;\n height: 1.5em;\n}\n\n.styles_visually-hidden__xyp28 {\n position: absolute !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n padding: 0 !important;\n border: 0 !important;\n height: 1px !important;\n width: 1px !important;\n overflow: hidden !important;\n}\n";
var styles = { "tableContainer": "styles_tableContainer__fjLYp", "listsContainer": "styles_listsContainer__3xrp-", "visually-hidden": "styles_visually-hidden__xyp28" };
var css = "div:not([tabindex]):focus {\n -webkit-box-shadow: none;\n box-shadow: none;\n}\n\n* {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\nbody {\n overflow-x: hidden;\n}\n\n.styles_tableContainer__fjLYp {\n overflow-x: auto;\n}\n\n@media (max-width: 400px) {\n .styles_tableContainer__fjLYp {\n display: none;\n }\n}\n\ntable {\n border-collapse: collapse;\n}\n\nth,\ntd {\n text-align: left;\n padding: 0.75rem;\n}\n\nth {\n white-space: nowrap;\n}\n\ncaption {\n margin-bottom: 0.5rem;\n text-align: left;\n}\n\n.styles_listsContainer__3xrp- {\n display: block;\n}\n\n@media (min-width: 400px) {\n .styles_listsContainer__3xrp- {\n display: none;\n }\n}\n\ndl {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n\ndl > * {\n -ms-flex: 0 0 50%;\n flex: 0 0 50%;\n margin: 0;\n margin-bottom: 0.5rem;\n}\n\ndt {\n padding-right: 0.5rem;\n}\n\ndt {\n font-weight: bold;\n}\n\nth button {\n background: #fff;\n color: #000;\n border: 0;\n padding: 0.125rem 0.5rem;\n border-radius: 0.25rem;\n font-weight: bold;\n vertical-align: middle;\n margin-left: 0.333rem;\n}\n\n\nth svg {\n stroke: currentColor;\n stroke-width: 20;\n stroke-linecap: round;\n stroke-linejoin: round;\n fill: none;\n width: 0.5rem;\n height: 1.5em;\n}\n\n.styles_visuallyHidden__12unE {\n position: absolute !important;\n clip: rect(1px, 1px, 1px, 1px) !important;\n padding: 0 !important;\n border: 0 !important;\n height: 1px !important;\n width: 1px !important;\n overflow: hidden !important;\n}\n";
var styles = { "tableContainer": "styles_tableContainer__fjLYp", "listsContainer": "styles_listsContainer__3xrp-", "visuallyHidden": "styles_visuallyHidden__12unE" };
styleInject(css);
var DefinitionList = function DefinitionList(_ref) {
var caption = _ref.caption,
rows = _ref.rows,
headers = _ref.headers;
return React__default.createElement(
'div',
{ className: styles.listsContainer },
React__default.createElement(
'h2',
null,
caption
),
rows.map(function (row, i) {
return React__default.createElement(
'div',
{ key: i },
React__default.createElement(
'h3',
null,
row[0]
),
React__default.createElement(
'dl',
null,
headers.map(function (header, i) {
return i > 0 && React__default.createElement(
React__default.Fragment,
{ key: i },
React__default.createElement(
'dt',
null,
header
),
React__default.createElement(
'dd',
null,
row[i]
)
);
})
)
);
})
);
};
DefinitionList.propTypes = {
caption: PropTypes.string.isRequired,
rows: PropTypes.array.isRequired,
headers: PropTypes.array.isRequired
};
var classCallCheck = function (instance, Constructor) {

@@ -90,16 +156,5 @@ if (!(instance instanceof Constructor)) {

var Arrow = function Arrow(props) {
var ascending = props.sortDir === 'ascending';
return React__default.createElement(
'svg',
{ viewBox: '0 0 100 200', width: '100', height: '200' },
!(!ascending && props.isCurrent) && React__default.createElement('polyline', { points: '20 50, 50 20, 80 50' }),
React__default.createElement('line', { x1: '50', y1: '20', x2: '50', y2: '180' }),
!(ascending && props.isCurrent) && React__default.createElement('polyline', { points: '20 150, 50 180, 80 150' })
);
};
var Table = function (_Component) {
inherits(Table, _Component);
var Table = function (_React$Component) {
inherits(Table, _React$Component);
function Table(props) {

@@ -149,5 +204,5 @@ classCallCheck(this, Table);

value: function componentDidMount() {
var _container = this.container,
scrollWidth = _container.scrollWidth,
clientWidth = _container.clientWidth;
var _ref = this.container && this.container.current,
scrollWidth = _ref.scrollWidth,
clientWidth = _ref.clientWidth;

@@ -164,2 +219,10 @@ var scrollable = scrollWidth > clientWidth;

var _props = this.props,
rows = _props.rows,
caption = _props.caption,
headers = _props.headers,
sortable = _props.sortable,
rowHeaders = _props.rowHeaders;
return React__default.createElement(

@@ -183,3 +246,3 @@ 'div',

{ id: this.captionID },
this.props.caption,
caption,
this.state.tabindex === '0' && React__default.createElement(

@@ -201,3 +264,3 @@ 'div',

null,
this.props.headers.map(function (header, i) {
headers.map(function (header, i) {
return React__default.createElement(

@@ -212,3 +275,3 @@ 'th',

header,
_this2.props.sortable && React__default.createElement(
sortable && React__default.createElement(
'button',

@@ -224,3 +287,3 @@ { onClick: function onClick() {

'span',
{ className: 'visually-hidden' },
{ className: styles.visuallyHidden },
'sort by ',

@@ -241,3 +304,3 @@ header,

row.map(function (cell, i) {
return _this2.props.rowHeaders && i < 1 ? React__default.createElement(
return rowHeaders && i < 1 ? React__default.createElement(
'th',

@@ -257,42 +320,3 @@ { scope: 'row', key: i },

),
React__default.createElement(
'div',
{ className: styles.listsContainer },
React__default.createElement(
'h2',
null,
this.props.caption
),
this.props.rows.map(function (row, i) {
return React__default.createElement(
'div',
{ key: i },
React__default.createElement(
'h3',
null,
row[0]
),
React__default.createElement(
'dl',
null,
_this2.props.headers.map(function (header, i) {
return i > 0 && React__default.createElement(
React__default.Fragment,
{ key: i },
React__default.createElement(
'dt',
null,
header
),
React__default.createElement(
'dd',
null,
row[i]
)
);
})
)
);
})
)
React__default.createElement(DefinitionList, { caption: caption, rows: rows, headers: headers })
);

@@ -302,35 +326,13 @@ }

return Table;
}(React__default.Component);
// import './styles.css'
var ExampleComponent = function (_Component) {
inherits(ExampleComponent, _Component);
function ExampleComponent() {
classCallCheck(this, ExampleComponent);
return possibleConstructorReturn(this, (ExampleComponent.__proto__ || Object.getPrototypeOf(ExampleComponent)).apply(this, arguments));
}
createClass(ExampleComponent, [{
key: 'render',
value: function render() {
var headers = ['Band', 'Singer', 'Inception', 'Label'];
var rows = [['Napalm Death', 'Barney Greenway', '1981', 'Century Media'], ['Carcass', 'Jeff Walker', '1985', 'Earache'], ['Extreme Noise Terror', 'Dean Jones', '1985', 'Candlelight'], ['Discordance Axis', 'Jon Chang', '1992', 'Hydrahead']];
return React__default.createElement(
'div',
{ className: 'App' },
React__default.createElement(Table, { rows: rows, headers: headers, rowHeaders: true, caption: 'Grindcore bands', sortable: true })
);
}
}]);
return ExampleComponent;
}(React.Component);
ExampleComponent.propTypes = {
text: PropTypes.string
Table.propTypes = {
caption: PropTypes.string,
headers: PropTypes.array.isRequired,
rowHeaders: PropTypes.bool,
rows: PropTypes.array.isRequired,
sortable: PropTypes.bool
};
module.exports = ExampleComponent;
module.exports = Table;
//# sourceMappingURL=index.js.map
{
"name": "react-inclusive-sortable-table",
"version": "0.1.0",
"version": "0.1.1",
"description": "An accessible, sortable table based off of Heydon Pickering&#x27;s Sortable Table from Inclusive Components.",

@@ -5,0 +5,0 @@ "author": "benjamingrobertson",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc