@sb1/ffe-tables-react 8.0.31 → 8.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/Table.js CHANGED
@@ -1,89 +1,107 @@
1
- var _excluded = ["sortable"];
2
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
3
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
4
23
  import React from 'react';
5
- import { node, bool, func, number, oneOf, oneOfType, arrayOf, shape, string } from 'prop-types';
24
+ import { node, bool, func, number, oneOf, oneOfType, arrayOf, shape, string, } from 'prop-types';
6
25
  import DefaultTable from './DefaultTable/DefaultTable';
7
26
  import SortableTable from './SortableTable/SortableTable';
8
- var Table = function Table(props) {
9
- var sortable = props.sortable,
10
- rest = _objectWithoutProperties(props, _excluded);
11
- if (sortable) {
12
- return /*#__PURE__*/React.createElement(SortableTable, rest);
13
- }
14
- return /*#__PURE__*/React.createElement(DefaultTable, rest);
27
+ var Table = function (props) {
28
+ var sortable = props.sortable, rest = __rest(props, ["sortable"]);
29
+ if (sortable) {
30
+ return React.createElement(SortableTable, __assign({}, rest));
31
+ }
32
+ return React.createElement(DefaultTable, __assign({}, rest));
15
33
  };
16
34
  Table.propTypes = {
17
- caption: node,
18
- /** Make the caption only visible for screen readers */
19
- srOnlyCaption: bool,
20
- /** A mapping function that returns a renderable node that will be rendered for each expandable row */
21
- expandedContentMapper: func,
22
- sortable: bool,
23
- /** A string reference to a column key to set an initial sort of the table */
24
- sortBy: string,
25
- /** Used in conjunction with sortBy */
26
- descending: bool,
27
- /** When paginated, lets you set the number of rows to offset from the beginning */
28
- offset: number,
29
- /** Limits the number of rows to show on one page. Decides whether or not to paginate your table */
30
- limit: number,
31
- /** Makes your table condensed - for pages that show a lot of data */
32
- condensed: bool,
33
- /** Set to true if you want the row headings to be narrower on smalls screens */
34
- smallHeader: bool,
35
- /** Removes left cell padding from the first column */
36
- alignLeft: bool,
37
- /** Show your table as a regular column based table on small devices */
38
- columnLayoutMobile: bool,
39
- /** Decide if your table rows should break into a vertical view on small or no devices */
40
- breakpoint: oneOf(['sm', 'none']),
41
- /**
42
- * Override rendering of rows with a prop
43
- * rowRender={(props, rowcontent, trprops, index)=>{return <tr {...trprops}>{rowcontent}</tr>}}
44
- */
45
- rowRender: func,
46
- /**
47
- * Override rendering of headers with a prop
48
- * headerRender={(props, rowcontent, trprops) => {return <tr {...trprops}>{rowcontent}</tr>}}
49
- */
50
- headerRender: func,
51
- /**
52
- * Override rendering of footer with a prop
53
- * footerRender={(props, rowcontent, trprops) => {return <tr {...trprops}>{rowcontent}</tr>}}
54
- */
55
- footerRender: func,
56
- /**
57
- * An array of objects with keys equal to the columns array's key value, and value equal to whatever you
58
- * want in your cell. These are basically an array of rows
59
- **/
60
- data: arrayOf(shape({
61
- /** A unique ID for each row of data. Required for sorting */
62
- id: oneOfType([string, number])
63
- })),
64
- /** An array of objects with a key describing your column, and a header describing that column */
65
- columns: arrayOf(shape({
66
- /** The column header. Required, but may be an empty string. */
67
- header: node.isRequired,
68
- /** The column key used in the `data` array's objects */
69
- key: string.isRequired,
70
- /** Content shown in the table footer */
71
- footer: node,
72
- alignRight: bool,
73
- alignTop: bool,
74
- hideOnDesktop: bool,
75
- hideOnTablet: bool,
76
- hideOnSmallTablet: bool,
77
- hideOnMobile: bool,
78
- /** Custom comparator function for sorting this column */
79
- compare: func,
80
- /** Disable column from sorting. Not needed if heading is an empty string */
81
- notSortable: bool,
82
- cellRender: func,
83
- columnHeaderRender: func,
84
- columnFooterRender: func
85
- }).isRequired),
86
- /** Class names set in addition to the ffe tables classes. */
87
- className: string
35
+ caption: node,
36
+ /** Make the caption only visible for screen readers */
37
+ srOnlyCaption: bool,
38
+ /** A mapping function that returns a renderable node that will be rendered for each expandable row */
39
+ expandedContentMapper: func,
40
+ sortable: bool,
41
+ /** A string reference to a column key to set an initial sort of the table */
42
+ sortBy: string,
43
+ /** Used in conjunction with sortBy */
44
+ descending: bool,
45
+ /** When paginated, lets you set the number of rows to offset from the beginning */
46
+ offset: number,
47
+ /** Limits the number of rows to show on one page. Decides whether or not to paginate your table */
48
+ limit: number,
49
+ /** Makes your table condensed - for pages that show a lot of data */
50
+ condensed: bool,
51
+ /** Set to true if you want the row headings to be narrower on smalls screens */
52
+ smallHeader: bool,
53
+ /** Removes left cell padding from the first column */
54
+ alignLeft: bool,
55
+ /** Show your table as a regular column based table on small devices */
56
+ columnLayoutMobile: bool,
57
+ /** Decide if your table rows should break into a vertical view on small or no devices */
58
+ breakpoint: oneOf(['sm', 'none']),
59
+ /**
60
+ * Override rendering of rows with a prop
61
+ * rowRender={(props, rowcontent, trprops, index)=>{return <tr {...trprops}>{rowcontent}</tr>}}
62
+ */
63
+ rowRender: func,
64
+ /**
65
+ * Override rendering of headers with a prop
66
+ * headerRender={(props, rowcontent, trprops) => {return <tr {...trprops}>{rowcontent}</tr>}}
67
+ */
68
+ headerRender: func,
69
+ /**
70
+ * Override rendering of footer with a prop
71
+ * footerRender={(props, rowcontent, trprops) => {return <tr {...trprops}>{rowcontent}</tr>}}
72
+ */
73
+ footerRender: func,
74
+ /**
75
+ * An array of objects with keys equal to the columns array's key value, and value equal to whatever you
76
+ * want in your cell. These are basically an array of rows
77
+ **/
78
+ data: arrayOf(shape({
79
+ /** A unique ID for each row of data. Required for sorting */
80
+ id: oneOfType([string, number]),
81
+ })),
82
+ /** An array of objects with a key describing your column, and a header describing that column */
83
+ columns: arrayOf(shape({
84
+ /** The column header. Required, but may be an empty string. */
85
+ header: node.isRequired,
86
+ /** The column key used in the `data` array's objects */
87
+ key: string.isRequired,
88
+ /** Content shown in the table footer */
89
+ footer: node,
90
+ alignRight: bool,
91
+ alignTop: bool,
92
+ hideOnDesktop: bool,
93
+ hideOnTablet: bool,
94
+ hideOnSmallTablet: bool,
95
+ hideOnMobile: bool,
96
+ /** Custom comparator function for sorting this column */
97
+ compare: func,
98
+ /** Disable column from sorting. Not needed if heading is an empty string */
99
+ notSortable: bool,
100
+ cellRender: func,
101
+ columnHeaderRender: func,
102
+ columnFooterRender: func,
103
+ }).isRequired),
104
+ /** Class names set in addition to the ffe tables classes. */
105
+ className: string,
88
106
  };
89
- export default Table;
107
+ export default Table;
@@ -1,38 +1,26 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- var TableCell = function TableCell(props) {
5
- var alignRight = props.alignRight,
6
- alignTop = props.alignTop,
7
- children = props.children,
8
- columnHeader = props.columnHeader,
9
- contentClasses = props.contentClasses,
10
- tdClasses = props.tdClasses;
11
- var dataTh = '';
12
- if (columnHeader) {
13
- if (typeof columnHeader === 'string') {
14
- dataTh = columnHeader;
15
- } else if (columnHeader.props && columnHeader.props.children) {
16
- dataTh = React.Children.toArray(columnHeader.props.children)[0];
4
+ var TableCell = function (props) {
5
+ var alignRight = props.alignRight, alignTop = props.alignTop, children = props.children, columnHeader = props.columnHeader, contentClasses = props.contentClasses, tdClasses = props.tdClasses;
6
+ var dataTh = '';
7
+ if (columnHeader) {
8
+ if (typeof columnHeader === 'string') {
9
+ dataTh = columnHeader;
10
+ }
11
+ else if (columnHeader.props && columnHeader.props.children) {
12
+ dataTh = React.Children.toArray(columnHeader.props.children)[0];
13
+ }
17
14
  }
18
- }
19
- return /*#__PURE__*/React.createElement("td", {
20
- className: classNames('ffe-table__cell', {
21
- 'ffe-table__cell--top': alignTop
22
- }, tdClasses),
23
- "data-th": dataTh
24
- }, /*#__PURE__*/React.createElement("span", {
25
- className: classNames('ffe-table__content', {
26
- 'ffe-table__content--text-right': alignRight
27
- }, contentClasses)
28
- }, children));
15
+ return (React.createElement("td", { className: classNames('ffe-table__cell', { 'ffe-table__cell--top': alignTop }, tdClasses), "data-th": dataTh },
16
+ React.createElement("span", { className: classNames('ffe-table__content', { 'ffe-table__content--text-right': alignRight }, contentClasses) }, children)));
29
17
  };
30
18
  TableCell.propTypes = {
31
- alignRight: PropTypes.bool,
32
- alignTop: PropTypes.bool,
33
- children: PropTypes.any,
34
- columnHeader: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
35
- contentClasses: PropTypes.string,
36
- tdClasses: PropTypes.string
19
+ alignRight: PropTypes.bool,
20
+ alignTop: PropTypes.bool,
21
+ children: PropTypes.any,
22
+ columnHeader: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
23
+ contentClasses: PropTypes.string,
24
+ tdClasses: PropTypes.string,
37
25
  };
38
- export default TableCell;
26
+ export default TableCell;
@@ -1,80 +1,69 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import React from 'react';
2
13
  import PropTypes from 'prop-types';
3
14
  import TableCell from './TableCell';
4
15
  import classNames from 'classnames';
5
- var TableFooter = function TableFooter(_ref) {
6
- var columns = _ref.columns,
7
- footerRender = _ref.footerRender,
8
- dataWindow = _ref.dataWindow;
9
- var footerContent = columns.map(function (column, index) {
10
- if (column === null) {
11
- return /*#__PURE__*/React.createElement("td", {
12
- key: index
13
- });
14
- }
15
- var className = classNames({
16
- 'ffe-table--hide-sm': column.hideOnMobile
17
- }, {
18
- 'ffe-table--hide-md': column.hideOnSmallTablet
19
- }, {
20
- 'ffe-table--hide-lg': column.hideOnTablet
21
- }, {
22
- 'ffe-table--hide-xlg': column.hideOnDesktop
16
+ var TableFooter = function (_a) {
17
+ var columns = _a.columns, footerRender = _a.footerRender, dataWindow = _a.dataWindow;
18
+ var footerContent = columns.map(function (column, index) {
19
+ if (column === null) {
20
+ return React.createElement("td", { key: index });
21
+ }
22
+ var className = classNames({ 'ffe-table--hide-sm': column.hideOnMobile }, { 'ffe-table--hide-md': column.hideOnSmallTablet }, { 'ffe-table--hide-lg': column.hideOnTablet }, { 'ffe-table--hide-xlg': column.hideOnDesktop });
23
+ var dataTh = '';
24
+ var columnHeader = column.header;
25
+ if (columnHeader) {
26
+ if (typeof columnHeader === 'string') {
27
+ dataTh = columnHeader;
28
+ }
29
+ else if (columnHeader.props && columnHeader.props.children) {
30
+ dataTh = React.Children.toArray(columnHeader.props.children)[0];
31
+ }
32
+ }
33
+ var tdProps = {
34
+ className: classNames('ffe-table__cell', { 'ffe-table__cell--top': column.alignTop }, className),
35
+ 'data-th': dataTh,
36
+ key: index,
37
+ };
38
+ var spanProps = {
39
+ className: classNames('ffe-table__content', {
40
+ 'ffe-table__content--text-right': column.alignRight,
41
+ }),
42
+ };
43
+ if (typeof column.columnFooterRender === 'function') {
44
+ return column.columnFooterRender(column.footer, dataWindow, tdProps, spanProps, columns, index);
45
+ }
46
+ return (React.createElement(TableCell, { key: index, columnHeader: column.header, alignRight: column.alignRight, alignTop: column.alignTop, tdClasses: className }, column.footer));
23
47
  });
24
- var dataTh = '';
25
- var columnHeader = column.header;
26
- if (columnHeader) {
27
- if (typeof columnHeader === 'string') {
28
- dataTh = columnHeader;
29
- } else if (columnHeader.props && columnHeader.props.children) {
30
- dataTh = React.Children.toArray(columnHeader.props.children)[0];
31
- }
32
- }
33
- var tdProps = {
34
- className: classNames('ffe-table__cell', {
35
- 'ffe-table__cell--top': column.alignTop
36
- }, className),
37
- 'data-th': dataTh,
38
- key: index
39
- };
40
- var spanProps = {
41
- className: classNames('ffe-table__content', {
42
- 'ffe-table__content--text-right': column.alignRight
43
- })
44
- };
45
- if (typeof column.columnFooterRender === 'function') {
46
- return column.columnFooterRender(column.footer, dataWindow, tdProps, spanProps, columns, index);
47
- }
48
- return /*#__PURE__*/React.createElement(TableCell, {
49
- key: index,
50
- columnHeader: column.header,
51
- alignRight: column.alignRight,
52
- alignTop: column.alignTop,
53
- tdClasses: className
54
- }, column.footer);
55
- });
56
- var trProps = {
57
- className: 'ffe-table__row',
58
- children: footerContent
59
- };
60
- var trDefault = /*#__PURE__*/React.createElement("tr", trProps);
61
- var footerRendered = typeof footerRender === 'function' ? footerRender(trProps, columns) : trDefault;
62
- return /*#__PURE__*/React.createElement("tfoot", {
63
- className: "ffe-table__footer"
64
- }, footerRendered);
48
+ var trProps = { className: 'ffe-table__row', children: footerContent };
49
+ var trDefault = React.createElement("tr", __assign({}, trProps));
50
+ var footerRendered = typeof footerRender === 'function'
51
+ ? footerRender(trProps, columns)
52
+ : trDefault;
53
+ return React.createElement("tfoot", { className: "ffe-table__footer" }, footerRendered);
65
54
  };
66
55
  TableFooter.propTypes = {
67
- columns: PropTypes.arrayOf(PropTypes.shape({
68
- alignRight: PropTypes.bool,
69
- alignTop: PropTypes.bool,
70
- footer: PropTypes.any,
71
- header: PropTypes.node.isRequired,
72
- hideOnDesktop: PropTypes.bool,
73
- hideOnMobile: PropTypes.bool,
74
- hideOnSmallTablet: PropTypes.bool,
75
- hideOnTablet: PropTypes.bool
76
- })),
77
- footerRender: PropTypes.func,
78
- dataWindow: PropTypes.array
56
+ columns: PropTypes.arrayOf(PropTypes.shape({
57
+ alignRight: PropTypes.bool,
58
+ alignTop: PropTypes.bool,
59
+ footer: PropTypes.any,
60
+ header: PropTypes.node.isRequired,
61
+ hideOnDesktop: PropTypes.bool,
62
+ hideOnMobile: PropTypes.bool,
63
+ hideOnSmallTablet: PropTypes.bool,
64
+ hideOnTablet: PropTypes.bool,
65
+ })),
66
+ footerRender: PropTypes.func,
67
+ dataWindow: PropTypes.array,
79
68
  };
80
- export default TableFooter;
69
+ export default TableFooter;
@@ -1,65 +1,58 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
2
12
  import React from 'react';
3
13
  import PropTypes from 'prop-types';
4
14
  import classNames from 'classnames';
5
- var TableHeaders = function TableHeaders(_ref) {
6
- var columns = _ref.columns,
7
- headerRender = _ref.headerRender,
8
- dataWindow = _ref.dataWindow;
9
- var headerContent = columns.map(function (column, index) {
10
- if (column === null) {
11
- return /*#__PURE__*/React.createElement("th", {
12
- key: index
13
- });
14
- }
15
- var thProps = {
16
- key: index,
17
- className: classNames('ffe-table__heading', {
18
- 'ffe-table--hide-sm': column.hideOnMobile
19
- }, {
20
- 'ffe-table--hide-md': column.hideOnSmallTablet
21
- }, {
22
- 'ffe-table--hide-lg': column.hideOnTablet
23
- }, {
24
- 'ffe-table--hide-xlg': column.hideOnDesktop
25
- }),
26
- 'aria-sort': column.ariaSort,
27
- scope: 'col'
28
- };
29
- var spanProps = {
30
- className: classNames('ffe-table__content', {
31
- 'ffe-table__content--text-right': column.alignRight
32
- })
33
- };
34
- var thContentDefault = /*#__PURE__*/React.createElement("span", spanProps, column.header);
35
- if (typeof column.columnHeaderRender === 'function') {
36
- return column.columnHeaderRender(column.header, dataWindow, spanProps, thProps, columns, index);
37
- }
38
- return /*#__PURE__*/React.createElement("th", _extends({
39
- key: thProps.key
40
- }, thProps), thContentDefault);
41
- });
42
- var trProps = {
43
- className: 'ffe-table__row',
44
- children: headerContent
45
- };
46
- var trDefault = /*#__PURE__*/React.createElement("tr", trProps);
47
- var headerRendered = typeof headerRender === 'function' ? headerRender(trProps, columns) : trDefault;
48
- return /*#__PURE__*/React.createElement("thead", {
49
- className: "ffe-table__head"
50
- }, headerRendered);
15
+ var TableHeaders = function (_a) {
16
+ var columns = _a.columns, headerRender = _a.headerRender, dataWindow = _a.dataWindow;
17
+ var headerContent = columns.map(function (column, index) {
18
+ if (column === null) {
19
+ return React.createElement("th", { key: index });
20
+ }
21
+ var thProps = {
22
+ key: index,
23
+ className: classNames('ffe-table__heading', { 'ffe-table--hide-sm': column.hideOnMobile }, { 'ffe-table--hide-md': column.hideOnSmallTablet }, { 'ffe-table--hide-lg': column.hideOnTablet }, { 'ffe-table--hide-xlg': column.hideOnDesktop }),
24
+ 'aria-sort': column.ariaSort,
25
+ scope: 'col',
26
+ };
27
+ var spanProps = {
28
+ className: classNames('ffe-table__content', {
29
+ 'ffe-table__content--text-right': column.alignRight,
30
+ }),
31
+ };
32
+ var thContentDefault = React.createElement("span", __assign({}, spanProps), column.header);
33
+ if (typeof column.columnHeaderRender === 'function') {
34
+ return column.columnHeaderRender(column.header, dataWindow, spanProps, thProps, columns, index);
35
+ }
36
+ return (React.createElement("th", __assign({ key: thProps.key }, thProps), thContentDefault));
37
+ });
38
+ var trProps = { className: 'ffe-table__row', children: headerContent };
39
+ var trDefault = React.createElement("tr", __assign({}, trProps));
40
+ var headerRendered = typeof headerRender === 'function'
41
+ ? headerRender(trProps, columns)
42
+ : trDefault;
43
+ return React.createElement("thead", { className: "ffe-table__head" }, headerRendered);
51
44
  };
52
45
  TableHeaders.propTypes = {
53
- columns: PropTypes.arrayOf(PropTypes.shape({
54
- alignRight: PropTypes.bool,
55
- header: PropTypes.node.isRequired,
56
- hideOnDesktop: PropTypes.bool,
57
- hideOnMobile: PropTypes.bool,
58
- hideOnSmallTablet: PropTypes.bool,
59
- hideOnTablet: PropTypes.bool,
60
- key: PropTypes.string.isRequired
61
- })),
62
- headerRender: PropTypes.func,
63
- dataWindow: PropTypes.array
46
+ columns: PropTypes.arrayOf(PropTypes.shape({
47
+ alignRight: PropTypes.bool,
48
+ header: PropTypes.node.isRequired,
49
+ hideOnDesktop: PropTypes.bool,
50
+ hideOnMobile: PropTypes.bool,
51
+ hideOnSmallTablet: PropTypes.bool,
52
+ hideOnTablet: PropTypes.bool,
53
+ key: PropTypes.string.isRequired,
54
+ })),
55
+ headerRender: PropTypes.func,
56
+ dataWindow: PropTypes.array,
64
57
  };
65
- export default TableHeaders;
58
+ export default TableHeaders;