From ddcba281f2b12cc910eb9bb96f552362ef047de1 Mon Sep 17 00:00:00 2001 From: David Kucsai Date: Sat, 12 Feb 2022 23:08:51 +0800 Subject: [PATCH] Build all required files and push version 0.4.0 to npm --- docs/iframe.html | 2 +- docs/main.2dab1aa2.iframe.bundle.js | 1 - docs/main.dfdc807a.iframe.bundle.js | 1 + docs/typedoc/classes/DataTableCell.md | 8 +- docs/typedoc/classes/Table.md | 8 +- docs/typedoc/classes/TableBody.md | 12 +- docs/typedoc/classes/TableCell.md | 2 +- docs/typedoc/classes/TableHeader.md | 8 +- docs/typedoc/interfaces/DataTableCellProps.md | 207 ++++++++++++++++++ docs/typedoc/interfaces/TableBodyProps.md | 39 +++- docs/typedoc/interfaces/TableBorder.md | 8 +- docs/typedoc/interfaces/TableCellProps.md | 20 +- docs/typedoc/interfaces/TableHeaderProps.md | 201 +++++++++++++++++ docs/typedoc/interfaces/TableProps.md | 81 +++++++ docs/typedoc/interfaces/ZebraProps.md | 56 +++++ docs/typedoc/modules.md | 8 +- lib/DataTableCell.d.ts | 3 +- lib/DataTableCell.js.map | 2 +- lib/Table.d.ts | 7 +- lib/Table.js | 13 +- lib/Table.js.map | 2 +- lib/TableBody.d.ts | 9 +- lib/TableBody.js.map | 2 +- lib/TableHeader.d.ts | 3 +- lib/TableHeader.js.map | 2 +- lib/src/DataTableCell.d.ts | 3 +- lib/src/Table.d.ts | 7 +- lib/src/TableBody.d.ts | 4 +- lib/src/TableHeader.d.ts | 3 +- package.json | 2 +- src/DataTableCell.tsx | 2 +- src/Table.tsx | 24 +- src/TableBody.tsx | 4 +- src/TableHeader.tsx | 2 +- 34 files changed, 670 insertions(+), 86 deletions(-) delete mode 100644 docs/main.2dab1aa2.iframe.bundle.js create mode 100644 docs/main.dfdc807a.iframe.bundle.js create mode 100644 docs/typedoc/interfaces/DataTableCellProps.md create mode 100644 docs/typedoc/interfaces/TableHeaderProps.md create mode 100644 docs/typedoc/interfaces/TableProps.md create mode 100644 docs/typedoc/interfaces/ZebraProps.md diff --git a/docs/iframe.html b/docs/iframe.html index cfb92ce..37b379e 100644 --- a/docs/iframe.html +++ b/docs/iframe.html @@ -345,4 +345,4 @@ - window['STORIES'] = []; \ No newline at end of file + window['STORIES'] = []; \ No newline at end of file diff --git a/docs/main.2dab1aa2.iframe.bundle.js b/docs/main.2dab1aa2.iframe.bundle.js deleted file mode 100644 index 8c92758..0000000 --- a/docs/main.2dab1aa2.iframe.bundle.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[1],{"./.storybook/config.js":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),function(module){__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.to-string.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.iterator.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.iterator.js");var _storybook_react__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("./node_modules/@storybook/react/dist/esm/client/index.js");Object(_storybook_react__WEBPACK_IMPORTED_MODULE_5__.addParameters)({options:{name:"Storybook",url:"#",goFullScreen:!1,showStoriesPanel:!0,showAddonPanel:!0,showSearchBox:!1,addonPanelInRight:!0,hierarchySeparator:null,hierarchyRootSeparator:null,sidebarAnimations:!0}});var req=__webpack_require__("./stories sync recursive \\.stories\\.js$");Object(_storybook_react__WEBPACK_IMPORTED_MODULE_5__.configure)((function loadStories(){req.keys().forEach((function(filename){return req(filename)}))}),module)}.call(this,__webpack_require__("./node_modules/webpack/buildin/harmony-module.js")(module))},"./.storybook/config.js-generated-config-entry.js":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.keys.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.symbol.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.filter.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.get-own-property-descriptor.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.get-own-property-descriptors.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-properties.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-property.js");var _Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__("./node_modules/@storybook/client-api/dist/esm/ClientApi.js"),_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_logger__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__("./node_modules/@storybook/client-logger/dist/esm/index.js"),_Users_davidkucsai_development_react_pdf_table_storybook_config_js__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__("./.storybook/config.js");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.keys(_Users_davidkucsai_development_react_pdf_table_storybook_config_js__WEBPACK_IMPORTED_MODULE_11__).forEach((function(key){var value=_Users_davidkucsai_development_react_pdf_table_storybook_config_js__WEBPACK_IMPORTED_MODULE_11__[key];switch(key){case"args":case"argTypes":return _Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_logger__WEBPACK_IMPORTED_MODULE_10__.a.warn("Invalid args/argTypes in config, ignoring.",JSON.stringify(value));case"decorators":return value.forEach((function(decorator){return Object(_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__.d)(decorator,!1)}));case"loaders":return value.forEach((function(loader){return Object(_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__.e)(loader,!1)}));case"parameters":return Object(_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__.f)(function _objectSpread(target){for(var i=1;i ReactNode | Element"}},weighting:{defaultValue:null,description:"The weighting of a cell based on the flex layout style.\nThis value is between 0..1, if not specified 1 is assumed, this will take up the remaining available space.",name:"weighting",required:!1,type:{name:"number"}},style:{defaultValue:null,description:"Extra styling to apply. These will override existing style with the same key.",name:"style",required:!1,type:{name:"Style | Style[]"}},textAlign:{defaultValue:null,description:"How to align the text",name:"textAlign",required:!1,type:{name:"enum",value:[{value:'"left"'},{value:'"center"'},{value:'"right"'}]}},isHeader:{defaultValue:null,description:"Whether this is a header cell or not. If not defined it will be false.",name:"isHeader",required:!1,type:{name:"boolean"}},fontSize:{defaultValue:null,description:"The font-size to apply to the cell.",name:"fontSize",required:!1,type:{name:"string | number"}},includeTopBorder:{defaultValue:null,description:"Include the top border. Default true.",name:"includeTopBorder",required:!1,type:{name:"boolean"}},includeRightBorder:{defaultValue:null,description:"Include the right border. Default true.",name:"includeRightBorder",required:!1,type:{name:"boolean"}},includeBottomBorder:{defaultValue:null,description:"Include the bottom border. Default true.",name:"includeBottomBorder",required:!1,type:{name:"boolean"}},includeLeftBorder:{defaultValue:null,description:"Include the left border. Default true.",name:"includeLeftBorder",required:!1,type:{name:"boolean"}}}},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/DataTableCell.tsx#DataTableCell"]={docgenInfo:DataTableCell.__docgenInfo,name:"DataTableCell",path:"src/DataTableCell.tsx#DataTableCell"})}catch(__react_docgen_typescript_loader_error){}},"./src/Table.tsx":function(module,exports,__webpack_require__){"use strict";__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.set-prototype-of.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.create.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-property.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.for-each.js");var _extendStatics,__extends=this&&this.__extends||(_extendStatics=function extendStatics(d,b){return _extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},_extendStatics(d,b)},function(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}_extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)});Object.defineProperty(exports,"__esModule",{value:!0}),exports.Table=void 0;var React=__webpack_require__("./node_modules/react/index.js"),TableHeader_1=__webpack_require__("./src/TableHeader.tsx"),TableBody_1=__webpack_require__("./src/TableBody.tsx"),renderer_1=__webpack_require__("./node_modules/@react-pdf/renderer/dist/react-pdf.browser.es.js"),Table=function(_super){function Table(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(Table,_super),Table.prototype.render=function(){var _a,_b,_c,_d,_e,_f,_g,_h,tableHeader=null,tableBody=null;return React.Children.forEach(this.props.children,(function(c){(null==c?void 0:c.type)===TableHeader_1.TableHeader?tableHeader=c:(null==c?void 0:c.type)===TableBody_1.TableBody&&(tableBody=c)})),tableBody=React.cloneElement(tableBody,{data:null!==(_b=null!==(_a=tableBody.props.data)&&void 0!==_a?_a:this.props.data)&&void 0!==_b?_b:[],renderTopBorder:!tableHeader,zebra:null!==(_d=null!==(_c=tableBody.props.zebra)&&void 0!==_c?_c:this.props.zebra)&&void 0!==_d&&_d,evenRowColor:null!==(_f=null!==(_e=tableBody.props.evenRowColor)&&void 0!==_e?_e:this.props.evenRowColor)&&void 0!==_f?_f:"",oddRowColor:null!==(_h=null!==(_g=tableBody.props.oddRowColor)&&void 0!==_g?_g:this.props.oddRowColor)&&void 0!==_h?_h:""}),React.createElement(renderer_1.View,{style:{width:"100%"}},tableHeader,tableBody)},Table}(React.PureComponent);exports.Table=Table;try{Table.displayName="Table",Table.__docgenInfo={description:"",displayName:"Table",props:{data:{defaultValue:null,description:"",name:"data",required:!1,type:{name:"any[]"}},zebra:{defaultValue:null,description:"",name:"zebra",required:!1,type:{name:"boolean"}},evenRowColor:{defaultValue:null,description:"",name:"evenRowColor",required:!1,type:{name:"string"}},oddRowColor:{defaultValue:null,description:"",name:"oddRowColor",required:!1,type:{name:"string"}}}},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/Table.tsx#Table"]={docgenInfo:Table.__docgenInfo,name:"Table",path:"src/Table.tsx#Table"})}catch(__react_docgen_typescript_loader_error){}},"./src/TableBody.tsx":function(module,exports,__webpack_require__){"use strict";__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.set-prototype-of.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.create.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.assign.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-property.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.map.js");var _extendStatics,__extends=this&&this.__extends||(_extendStatics=function extendStatics(d,b){return _extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},_extendStatics(d,b)},function(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}_extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i );\n\nconst tableStories = storiesOf("Table", module);\ntableStories.addDecorator(withKnobs);\n\ntableStories.add("Simple Table", () => ());\ntableStories.add("Simple Table with Weighting", () => ());\ntableStories.add("Nested Tables", () => ());\ntableStories.add("Zebra Table", () => ());\n',__LOCATIONS_MAP__={"to-react-pdf-table":{startLoc:{col:33,line:13},endLoc:{col:76,line:13},startBody:{col:55,line:13},endBody:{col:76,line:13}},"simple-table":{startLoc:{col:17,line:18},endLoc:{col:55,line:18},startBody:{col:33,line:18},endBody:{col:55,line:18}},"simple-table-with-weighting":{startLoc:{col:17,line:19},endLoc:{col:83,line:19},startBody:{col:48,line:19},endBody:{col:83,line:19}},"nested-tables":{startLoc:{col:17,line:20},endLoc:{col:57,line:20},startBody:{col:34,line:20},endBody:{col:57,line:20}},"zebra-table":{startLoc:{col:17,line:21},endLoc:{col:53,line:21},startBody:{col:32,line:21},endBody:{col:53,line:21}}};Object(_storybook_react__WEBPACK_IMPORTED_MODULE_1__.storiesOf)("Welcome",module).addParameters({storySource:{source:__STORY__,locationsMap:__LOCATIONS_MAP__}}).add("to react-pdf-table",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Introduction__WEBPACK_IMPORTED_MODULE_4___default.a,null)}));var tableStories=Object(_storybook_react__WEBPACK_IMPORTED_MODULE_1__.storiesOf)("Table",module).addParameters({storySource:{source:__STORY__,locationsMap:__LOCATIONS_MAP__}});tableStories.addDecorator(_storybook_addon_knobs__WEBPACK_IMPORTED_MODULE_3__.withKnobs),tableStories.add("Simple Table",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_SimpleTable__WEBPACK_IMPORTED_MODULE_5__.SimpleTable,null)})),tableStories.add("Simple Table with Weighting",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_SimpleTableWithWeighting__WEBPACK_IMPORTED_MODULE_6__.SimpleTableWithWeighting,null)})),tableStories.add("Nested Tables",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_NestedTables__WEBPACK_IMPORTED_MODULE_7__.NestedTables,null)})),tableStories.add("Zebra Table",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_ZebraTable__WEBPACK_IMPORTED_MODULE_8__.ZebraTable,null)}))}.call(this,__webpack_require__("./node_modules/webpack/buildin/harmony-module.js")(module))},"./storybook-init-framework-entry.js":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);__webpack_require__("./node_modules/@storybook/react/dist/esm/client/index.js")},0:function(module,exports,__webpack_require__){__webpack_require__("./node_modules/@storybook/core-client/dist/esm/globals/polyfills.js"),__webpack_require__("./node_modules/@storybook/core-client/dist/esm/globals/globals.js"),__webpack_require__("./storybook-init-framework-entry.js"),__webpack_require__("./node_modules/@storybook/react/dist/esm/client/preview/config-generated-config-entry.js"),module.exports=__webpack_require__("./.storybook/config.js-generated-config-entry.js")},1:function(module,exports){},2:function(module,exports){},3:function(module,exports){},4:function(module,exports){},5:function(module,exports){},6:function(module,exports){},7:function(module,exports){},8:function(module,exports){}},[[0,2,3]]]); \ No newline at end of file diff --git a/docs/main.dfdc807a.iframe.bundle.js b/docs/main.dfdc807a.iframe.bundle.js new file mode 100644 index 0000000..ecc5785 --- /dev/null +++ b/docs/main.dfdc807a.iframe.bundle.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[1],{"./.storybook/config.js":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__),function(module){__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.to-string.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.iterator.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.iterator.js");var _storybook_react__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("./node_modules/@storybook/react/dist/esm/client/index.js");Object(_storybook_react__WEBPACK_IMPORTED_MODULE_5__.addParameters)({options:{name:"Storybook",url:"#",goFullScreen:!1,showStoriesPanel:!0,showAddonPanel:!0,showSearchBox:!1,addonPanelInRight:!0,hierarchySeparator:null,hierarchyRootSeparator:null,sidebarAnimations:!0}});var req=__webpack_require__("./stories sync recursive \\.stories\\.js$");Object(_storybook_react__WEBPACK_IMPORTED_MODULE_5__.configure)((function loadStories(){req.keys().forEach((function(filename){return req(filename)}))}),module)}.call(this,__webpack_require__("./node_modules/webpack/buildin/harmony-module.js")(module))},"./.storybook/config.js-generated-config-entry.js":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.keys.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.symbol.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.filter.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.get-own-property-descriptor.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.get-own-property-descriptors.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-properties.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-property.js");var _Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__("./node_modules/@storybook/client-api/dist/esm/ClientApi.js"),_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_logger__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__("./node_modules/@storybook/client-logger/dist/esm/index.js"),_Users_davidkucsai_development_react_pdf_table_storybook_config_js__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__("./.storybook/config.js");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.keys(_Users_davidkucsai_development_react_pdf_table_storybook_config_js__WEBPACK_IMPORTED_MODULE_11__).forEach((function(key){var value=_Users_davidkucsai_development_react_pdf_table_storybook_config_js__WEBPACK_IMPORTED_MODULE_11__[key];switch(key){case"args":case"argTypes":return _Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_logger__WEBPACK_IMPORTED_MODULE_10__.a.warn("Invalid args/argTypes in config, ignoring.",JSON.stringify(value));case"decorators":return value.forEach((function(decorator){return Object(_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__.d)(decorator,!1)}));case"loaders":return value.forEach((function(loader){return Object(_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__.e)(loader,!1)}));case"parameters":return Object(_Users_davidkucsai_development_react_pdf_table_node_modules_storybook_client_api__WEBPACK_IMPORTED_MODULE_9__.f)(function _objectSpread(target){for(var i=1;i ReactNode | Element"}},weighting:{defaultValue:null,description:"The weighting of a cell based on the flex layout style.\nThis value is between 0..1, if not specified 1 is assumed, this will take up the remaining available space.",name:"weighting",required:!1,type:{name:"number"}},style:{defaultValue:null,description:"Extra styling to apply. These will override existing style with the same key.",name:"style",required:!1,type:{name:"Style | Style[]"}},textAlign:{defaultValue:null,description:"How to align the text",name:"textAlign",required:!1,type:{name:"enum",value:[{value:'"left"'},{value:'"center"'},{value:'"right"'}]}},isHeader:{defaultValue:null,description:"Whether this is a header cell or not. If not defined it will be false.",name:"isHeader",required:!1,type:{name:"boolean"}},fontSize:{defaultValue:null,description:"The font-size to apply to the cell.",name:"fontSize",required:!1,type:{name:"string | number"}},includeTopBorder:{defaultValue:null,description:"Include the top border. Default true.",name:"includeTopBorder",required:!1,type:{name:"boolean"}},includeRightBorder:{defaultValue:null,description:"Include the right border. Default true.",name:"includeRightBorder",required:!1,type:{name:"boolean"}},includeBottomBorder:{defaultValue:null,description:"Include the bottom border. Default true.",name:"includeBottomBorder",required:!1,type:{name:"boolean"}},includeLeftBorder:{defaultValue:null,description:"Include the left border. Default true.",name:"includeLeftBorder",required:!1,type:{name:"boolean"}}}},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/DataTableCell.tsx#DataTableCell"]={docgenInfo:DataTableCell.__docgenInfo,name:"DataTableCell",path:"src/DataTableCell.tsx#DataTableCell"})}catch(__react_docgen_typescript_loader_error){}},"./src/Table.tsx":function(module,exports,__webpack_require__){"use strict";__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.set-prototype-of.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.create.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-property.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.for-each.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/web.dom-collections.for-each.js");var _extendStatics,__extends=this&&this.__extends||(_extendStatics=function extendStatics(d,b){return _extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},_extendStatics(d,b)},function(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}_extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)});Object.defineProperty(exports,"__esModule",{value:!0}),exports.Table=void 0;var React=__webpack_require__("./node_modules/react/index.js"),TableHeader_1=__webpack_require__("./src/TableHeader.tsx"),TableBody_1=__webpack_require__("./src/TableBody.tsx"),renderer_1=__webpack_require__("./node_modules/@react-pdf/renderer/dist/react-pdf.browser.es.js"),Table=function(_super){function Table(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(Table,_super),Table.prototype.render=function(){var _a,_b,_c,_d,_e,_f,_g,_h,_j,_k,_l,_m,tableHeader=null,tableBody=null;return React.Children.forEach(this.props.children,(function(c){(null==c?void 0:c.type)===TableHeader_1.TableHeader?tableHeader=c:(null==c?void 0:c.type)===TableBody_1.TableBody&&(tableBody=c)})),null===tableBody&&(tableBody=React.createElement(TableBody_1.TableBody)),tableBody=React.cloneElement(tableBody,{data:null!==(_c=null!==(_b=null===(_a=null==tableBody?void 0:tableBody.props)||void 0===_a?void 0:_a.data)&&void 0!==_b?_b:this.props.data)&&void 0!==_c?_c:[],renderTopBorder:!tableHeader,zebra:null!==(_f=null!==(_e=null===(_d=null==tableBody?void 0:tableBody.props)||void 0===_d?void 0:_d.zebra)&&void 0!==_e?_e:this.props.zebra)&&void 0!==_f&&_f,evenRowColor:null!==(_j=null!==(_h=null===(_g=null==tableBody?void 0:tableBody.props)||void 0===_g?void 0:_g.evenRowColor)&&void 0!==_h?_h:this.props.evenRowColor)&&void 0!==_j?_j:"",oddRowColor:null!==(_m=null!==(_l=null===(_k=null==tableBody?void 0:tableBody.props)||void 0===_k?void 0:_k.oddRowColor)&&void 0!==_l?_l:this.props.oddRowColor)&&void 0!==_m?_m:""}),React.createElement(renderer_1.View,{style:{width:"100%"}},tableHeader,tableBody)},Table}(React.PureComponent);exports.Table=Table;try{Table.displayName="Table",Table.__docgenInfo={description:"",displayName:"Table",props:{data:{defaultValue:null,description:"The table data to display.",name:"data",required:!1,type:{name:"any[]"}},zebra:{defaultValue:null,description:"Whether to display alternate row colours.\nDefaults to false.",name:"zebra",required:!1,type:{name:"boolean"}},evenRowColor:{defaultValue:null,description:"The even row colour when {@see zebra} is true.\nDefaults to lightgray if not defined.",name:"evenRowColor",required:!1,type:{name:"string"}},oddRowColor:{defaultValue:null,description:"The odd row colour when {@see zebra} is true.\nDefaults to transparent or '' if not defined.",name:"oddRowColor",required:!1,type:{name:"string"}}}},"undefined"!=typeof STORYBOOK_REACT_CLASSES&&(STORYBOOK_REACT_CLASSES["src/Table.tsx#Table"]={docgenInfo:Table.__docgenInfo,name:"Table",path:"src/Table.tsx#Table"})}catch(__react_docgen_typescript_loader_error){}},"./src/TableBody.tsx":function(module,exports,__webpack_require__){"use strict";__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.set-prototype-of.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.create.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.assign.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.object.define-property.js"),__webpack_require__("./node_modules/@storybook/core-common/node_modules/core-js/modules/es.array.map.js");var _extendStatics,__extends=this&&this.__extends||(_extendStatics=function extendStatics(d,b){return _extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},_extendStatics(d,b)},function(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}_extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}),__assign=this&&this.__assign||function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i );\n\nconst tableStories = storiesOf("Table", module);\ntableStories.addDecorator(withKnobs);\n\ntableStories.add("Simple Table", () => ());\ntableStories.add("Simple Table with Weighting", () => ());\ntableStories.add("Nested Tables", () => ());\ntableStories.add("Zebra Table", () => ());\n',__LOCATIONS_MAP__={"to-react-pdf-table":{startLoc:{col:33,line:13},endLoc:{col:76,line:13},startBody:{col:55,line:13},endBody:{col:76,line:13}},"simple-table":{startLoc:{col:17,line:18},endLoc:{col:55,line:18},startBody:{col:33,line:18},endBody:{col:55,line:18}},"simple-table-with-weighting":{startLoc:{col:17,line:19},endLoc:{col:83,line:19},startBody:{col:48,line:19},endBody:{col:83,line:19}},"nested-tables":{startLoc:{col:17,line:20},endLoc:{col:57,line:20},startBody:{col:34,line:20},endBody:{col:57,line:20}},"zebra-table":{startLoc:{col:17,line:21},endLoc:{col:53,line:21},startBody:{col:32,line:21},endBody:{col:53,line:21}}};Object(_storybook_react__WEBPACK_IMPORTED_MODULE_1__.storiesOf)("Welcome",module).addParameters({storySource:{source:__STORY__,locationsMap:__LOCATIONS_MAP__}}).add("to react-pdf-table",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Introduction__WEBPACK_IMPORTED_MODULE_4___default.a,null)}));var tableStories=Object(_storybook_react__WEBPACK_IMPORTED_MODULE_1__.storiesOf)("Table",module).addParameters({storySource:{source:__STORY__,locationsMap:__LOCATIONS_MAP__}});tableStories.addDecorator(_storybook_addon_knobs__WEBPACK_IMPORTED_MODULE_3__.withKnobs),tableStories.add("Simple Table",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_SimpleTable__WEBPACK_IMPORTED_MODULE_5__.SimpleTable,null)})),tableStories.add("Simple Table with Weighting",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_SimpleTableWithWeighting__WEBPACK_IMPORTED_MODULE_6__.SimpleTableWithWeighting,null)})),tableStories.add("Nested Tables",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_NestedTables__WEBPACK_IMPORTED_MODULE_7__.NestedTables,null)})),tableStories.add("Zebra Table",(function(){return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_story_ZebraTable__WEBPACK_IMPORTED_MODULE_8__.ZebraTable,null)}))}.call(this,__webpack_require__("./node_modules/webpack/buildin/harmony-module.js")(module))},"./storybook-init-framework-entry.js":function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__);__webpack_require__("./node_modules/@storybook/react/dist/esm/client/index.js")},0:function(module,exports,__webpack_require__){__webpack_require__("./node_modules/@storybook/core-client/dist/esm/globals/polyfills.js"),__webpack_require__("./node_modules/@storybook/core-client/dist/esm/globals/globals.js"),__webpack_require__("./storybook-init-framework-entry.js"),__webpack_require__("./node_modules/@storybook/react/dist/esm/client/preview/config-generated-config-entry.js"),module.exports=__webpack_require__("./.storybook/config.js-generated-config-entry.js")},1:function(module,exports){},2:function(module,exports){},3:function(module,exports){},4:function(module,exports){},5:function(module,exports){},6:function(module,exports){},7:function(module,exports){},8:function(module,exports){}},[[0,2,3]]]); \ No newline at end of file diff --git a/docs/typedoc/classes/DataTableCell.md b/docs/typedoc/classes/DataTableCell.md index a94d6ae..143554d 100644 --- a/docs/typedoc/classes/DataTableCell.md +++ b/docs/typedoc/classes/DataTableCell.md @@ -6,7 +6,7 @@ This component is used to display data in the the {@see TableRow} component. ## Hierarchy -- `PureComponent`<`DataTableCellProps`\> +- `PureComponent`<[`DataTableCellProps`](../interfaces/DataTableCellProps.md)\> ↳ **`DataTableCell`** @@ -30,7 +30,7 @@ This component is used to display data in the the {@see TableRow} component. | Name | Type | | :------ | :------ | -| `props` | `Readonly`<`DataTableCellProps`\> | +| `props` | `Readonly`<[`DataTableCellProps`](../interfaces/DataTableCellProps.md)\> | #### Inherited from @@ -50,7 +50,7 @@ node_modules/@types/react/index.d.ts:478 | Name | Type | | :------ | :------ | -| `props` | `DataTableCellProps` | +| `props` | [`DataTableCellProps`](../interfaces/DataTableCellProps.md) | | `context?` | `any` | #### Inherited from @@ -77,4 +77,4 @@ React.PureComponent.render #### Defined in -[src/DataTableCell.tsx:21](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/DataTableCell.tsx#L21) +[src/DataTableCell.tsx:21](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/DataTableCell.tsx#L21) diff --git a/docs/typedoc/classes/Table.md b/docs/typedoc/classes/Table.md index f723f9d..daf6689 100644 --- a/docs/typedoc/classes/Table.md +++ b/docs/typedoc/classes/Table.md @@ -4,7 +4,7 @@ ## Hierarchy -- `PureComponent`<`TableProps`\> +- `PureComponent`<[`TableProps`](../interfaces/TableProps.md)\> ↳ **`Table`** @@ -28,7 +28,7 @@ | Name | Type | | :------ | :------ | -| `props` | `Readonly`<`TableProps`\> | +| `props` | `Readonly`<[`TableProps`](../interfaces/TableProps.md)\> | #### Inherited from @@ -48,7 +48,7 @@ node_modules/@types/react/index.d.ts:478 | Name | Type | | :------ | :------ | -| `props` | `TableProps` | +| `props` | [`TableProps`](../interfaces/TableProps.md) | | `context?` | `any` | #### Inherited from @@ -75,4 +75,4 @@ React.PureComponent.render #### Defined in -[src/Table.tsx:14](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/Table.tsx#L14) +[src/Table.tsx:34](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L34) diff --git a/docs/typedoc/classes/TableBody.md b/docs/typedoc/classes/TableBody.md index b34247c..a41df22 100644 --- a/docs/typedoc/classes/TableBody.md +++ b/docs/typedoc/classes/TableBody.md @@ -6,7 +6,7 @@ This component displays the data as {@see TableRow}s. ## Hierarchy -- `PureComponent`<`InternalBodyProps`\> +- `PureComponent`<[`TableBodyProps`](../interfaces/TableBodyProps.md)\> ↳ **`TableBody`** @@ -30,11 +30,11 @@ This component displays the data as {@see TableRow}s. | Name | Type | | :------ | :------ | -| `props` | `Readonly`<`InternalBodyProps`\> | +| `props` | `Readonly`<[`TableBodyProps`](../interfaces/TableBodyProps.md)\> | #### Inherited from -React.PureComponent.constructor +React.PureComponent.constructor #### Defined in @@ -50,12 +50,12 @@ node_modules/@types/react/index.d.ts:478 | Name | Type | | :------ | :------ | -| `props` | `InternalBodyProps` | +| `props` | [`TableBodyProps`](../interfaces/TableBodyProps.md) | | `context?` | `any` | #### Inherited from -React.PureComponent.constructor +React.PureComponent.constructor #### Defined in @@ -77,4 +77,4 @@ React.PureComponent.render #### Defined in -[src/TableBody.tsx:24](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableBody.tsx#L24) +[src/TableBody.tsx:22](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableBody.tsx#L22) diff --git a/docs/typedoc/classes/TableCell.md b/docs/typedoc/classes/TableCell.md index 0d048a2..ee9c92a 100644 --- a/docs/typedoc/classes/TableCell.md +++ b/docs/typedoc/classes/TableCell.md @@ -77,4 +77,4 @@ React.PureComponent.render #### Defined in -[src/TableCell.tsx:63](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L63) +[src/TableCell.tsx:63](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L63) diff --git a/docs/typedoc/classes/TableHeader.md b/docs/typedoc/classes/TableHeader.md index 29c92d8..7a42953 100644 --- a/docs/typedoc/classes/TableHeader.md +++ b/docs/typedoc/classes/TableHeader.md @@ -6,7 +6,7 @@ This component displays the titles for the rows. ## Hierarchy -- `PureComponent`<`TableHeaderProps`\> +- `PureComponent`<[`TableHeaderProps`](../interfaces/TableHeaderProps.md)\> ↳ **`TableHeader`** @@ -30,7 +30,7 @@ This component displays the titles for the rows. | Name | Type | | :------ | :------ | -| `props` | `Readonly`<`TableHeaderProps`\> | +| `props` | `Readonly`<[`TableHeaderProps`](../interfaces/TableHeaderProps.md)\> | #### Inherited from @@ -50,7 +50,7 @@ node_modules/@types/react/index.d.ts:478 | Name | Type | | :------ | :------ | -| `props` | `TableHeaderProps` | +| `props` | [`TableHeaderProps`](../interfaces/TableHeaderProps.md) | | `context?` | `any` | #### Inherited from @@ -77,4 +77,4 @@ React.PureComponent.render #### Defined in -[src/TableHeader.tsx:12](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableHeader.tsx#L12) +[src/TableHeader.tsx:12](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableHeader.tsx#L12) diff --git a/docs/typedoc/interfaces/DataTableCellProps.md b/docs/typedoc/interfaces/DataTableCellProps.md new file mode 100644 index 0000000..16ef3d4 --- /dev/null +++ b/docs/typedoc/interfaces/DataTableCellProps.md @@ -0,0 +1,207 @@ +[@david.kucsai/react-pdf-table](../README.md) / [Exports](../modules.md) / DataTableCellProps + +# Interface: DataTableCellProps + +## Hierarchy + +- [`TableCellProps`](TableCellProps.md) + + ↳ **`DataTableCellProps`** + +## Table of contents + +### Properties + +- [data](DataTableCellProps.md#data) +- [fontSize](DataTableCellProps.md#fontsize) +- [includeBottomBorder](DataTableCellProps.md#includebottomborder) +- [includeLeftBorder](DataTableCellProps.md#includeleftborder) +- [includeRightBorder](DataTableCellProps.md#includerightborder) +- [includeTopBorder](DataTableCellProps.md#includetopborder) +- [isHeader](DataTableCellProps.md#isheader) +- [style](DataTableCellProps.md#style) +- [textAlign](DataTableCellProps.md#textalign) +- [weighting](DataTableCellProps.md#weighting) + +### Methods + +- [getContent](DataTableCellProps.md#getcontent) + +## Properties + +### data + +• `Optional` **data**: `any` + +The data associated with the cell. + +#### Defined in + +[src/DataTableCell.tsx:8](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/DataTableCell.tsx#L8) + +___ + +### fontSize + +• `Optional` **fontSize**: `string` \| `number` + +The font-size to apply to the cell. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[fontSize](TableCellProps.md#fontsize) + +#### Defined in + +[src/TableCell.tsx:56](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L56) + +___ + +### includeBottomBorder + +• `Optional` **includeBottomBorder**: `boolean` + +Include the bottom border. Default true. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[includeBottomBorder](TableCellProps.md#includebottomborder) + +#### Defined in + +[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L23) + +___ + +### includeLeftBorder + +• `Optional` **includeLeftBorder**: `boolean` + +Include the left border. Default true. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[includeLeftBorder](TableCellProps.md#includeleftborder) + +#### Defined in + +[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L28) + +___ + +### includeRightBorder + +• `Optional` **includeRightBorder**: `boolean` + +Include the right border. Default true. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[includeRightBorder](TableCellProps.md#includerightborder) + +#### Defined in + +[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L18) + +___ + +### includeTopBorder + +• `Optional` **includeTopBorder**: `boolean` + +Include the top border. Default true. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[includeTopBorder](TableCellProps.md#includetopborder) + +#### Defined in + +[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L13) + +___ + +### isHeader + +• `Optional` **isHeader**: `boolean` + +Whether this is a header cell or not. If not defined it will be false. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[isHeader](TableCellProps.md#isheader) + +#### Defined in + +[src/TableCell.tsx:51](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L51) + +___ + +### style + +• `Optional` **style**: `Style` \| `Style`[] + +Extra styling to apply. These will override existing style with the same key. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[style](TableCellProps.md#style) + +#### Defined in + +[src/TableCell.tsx:41](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L41) + +___ + +### textAlign + +• `Optional` **textAlign**: ``"left"`` \| ``"center"`` \| ``"right"`` + +How to align the text + +#### Inherited from + +[TableCellProps](TableCellProps.md).[textAlign](TableCellProps.md#textalign) + +#### Defined in + +[src/TableCell.tsx:46](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L46) + +___ + +### weighting + +• `Optional` **weighting**: `number` + +The weighting of a cell based on the flex layout style. +This value is between 0..1, if not specified 1 is assumed, this will take up the remaining available space. + +#### Inherited from + +[TableCellProps](TableCellProps.md).[weighting](TableCellProps.md#weighting) + +#### Defined in + +[src/TableCell.tsx:36](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L36) + +## Methods + +### getContent + +▸ **getContent**(`data`): `ReactNode` \| `Element` + +The content to display for this cell. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `data` | `any` | the data passed in. | + +#### Returns + +`ReactNode` \| `Element` + +#### Defined in + +[src/DataTableCell.tsx:14](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/DataTableCell.tsx#L14) diff --git a/docs/typedoc/interfaces/TableBodyProps.md b/docs/typedoc/interfaces/TableBodyProps.md index 4c4686a..3b967a0 100644 --- a/docs/typedoc/interfaces/TableBodyProps.md +++ b/docs/typedoc/interfaces/TableBodyProps.md @@ -6,6 +6,8 @@ - `TableRowProps` +- `Pick`<[`ZebraProps`](ZebraProps.md), ``"zebra"``\> + ↳ **`TableBodyProps`** ## Table of contents @@ -21,6 +23,7 @@ - [includeRightBorder](TableBodyProps.md#includerightborder) - [includeTopBorder](TableBodyProps.md#includetopborder) - [oddRowColor](TableBodyProps.md#oddrowcolor) +- [renderTopBorder](TableBodyProps.md#rendertopborder) - [textAlign](TableBodyProps.md#textalign) - [zebra](TableBodyProps.md#zebra) @@ -38,7 +41,7 @@ TableRowProps.data #### Defined in -[src/TableBody.tsx:9](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableBody.tsx#L9) +[src/TableBody.tsx:10](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableBody.tsx#L10) ___ @@ -54,7 +57,7 @@ TableRowProps.even #### Defined in -[src/TableRow.tsx:32](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableRow.tsx#L32) +[src/TableRow.tsx:32](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L32) ___ @@ -70,7 +73,7 @@ TableRowProps.evenRowColor #### Defined in -[src/TableRow.tsx:37](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableRow.tsx#L37) +[src/TableRow.tsx:37](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L37) ___ @@ -86,7 +89,7 @@ TableRowProps.fontSize #### Defined in -[src/TableRow.tsx:12](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableRow.tsx#L12) +[src/TableRow.tsx:12](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L12) ___ @@ -102,7 +105,7 @@ TableRowProps.includeBottomBorder #### Defined in -[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L23) +[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L23) ___ @@ -118,7 +121,7 @@ TableRowProps.includeLeftBorder #### Defined in -[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L28) +[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L28) ___ @@ -134,7 +137,7 @@ TableRowProps.includeRightBorder #### Defined in -[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L18) +[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L18) ___ @@ -150,7 +153,7 @@ TableRowProps.includeTopBorder #### Defined in -[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L13) +[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L13) ___ @@ -166,7 +169,17 @@ TableRowProps.oddRowColor #### Defined in -[src/TableRow.tsx:42](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableRow.tsx#L42) +[src/TableRow.tsx:42](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L42) + +___ + +### renderTopBorder + +• `Optional` **renderTopBorder**: `boolean` + +#### Defined in + +[src/TableBody.tsx:15](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableBody.tsx#L15) ___ @@ -182,7 +195,7 @@ TableRowProps.textAlign #### Defined in -[src/TableRow.tsx:17](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableRow.tsx#L17) +[src/TableRow.tsx:17](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L17) ___ @@ -190,10 +203,12 @@ ___ • `Optional` **zebra**: `boolean` -#### Overrides +Whether rows have alternating styles + +#### Inherited from TableRowProps.zebra #### Defined in -[src/TableBody.tsx:10](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableBody.tsx#L10) +[src/TableRow.tsx:27](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L27) diff --git a/docs/typedoc/interfaces/TableBorder.md b/docs/typedoc/interfaces/TableBorder.md index 431f696..f92f5ee 100644 --- a/docs/typedoc/interfaces/TableBorder.md +++ b/docs/typedoc/interfaces/TableBorder.md @@ -30,7 +30,7 @@ Include the bottom border. Default true. #### Defined in -[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L23) +[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L23) ___ @@ -42,7 +42,7 @@ Include the left border. Default true. #### Defined in -[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L28) +[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L28) ___ @@ -54,7 +54,7 @@ Include the right border. Default true. #### Defined in -[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L18) +[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L18) ___ @@ -66,4 +66,4 @@ Include the top border. Default true. #### Defined in -[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L13) +[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L13) diff --git a/docs/typedoc/interfaces/TableCellProps.md b/docs/typedoc/interfaces/TableCellProps.md index 2706244..eedff9a 100644 --- a/docs/typedoc/interfaces/TableCellProps.md +++ b/docs/typedoc/interfaces/TableCellProps.md @@ -8,6 +8,8 @@ ↳ **`TableCellProps`** + ↳↳ [`DataTableCellProps`](DataTableCellProps.md) + ## Table of contents ### Properties @@ -32,7 +34,7 @@ The font-size to apply to the cell. #### Defined in -[src/TableCell.tsx:56](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L56) +[src/TableCell.tsx:56](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L56) ___ @@ -48,7 +50,7 @@ Include the bottom border. Default true. #### Defined in -[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L23) +[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L23) ___ @@ -64,7 +66,7 @@ Include the left border. Default true. #### Defined in -[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L28) +[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L28) ___ @@ -80,7 +82,7 @@ Include the right border. Default true. #### Defined in -[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L18) +[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L18) ___ @@ -96,7 +98,7 @@ Include the top border. Default true. #### Defined in -[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L13) +[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L13) ___ @@ -108,7 +110,7 @@ Whether this is a header cell or not. If not defined it will be false. #### Defined in -[src/TableCell.tsx:51](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L51) +[src/TableCell.tsx:51](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L51) ___ @@ -120,7 +122,7 @@ Extra styling to apply. These will override existing style with the same key. #### Defined in -[src/TableCell.tsx:41](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L41) +[src/TableCell.tsx:41](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L41) ___ @@ -132,7 +134,7 @@ How to align the text #### Defined in -[src/TableCell.tsx:46](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L46) +[src/TableCell.tsx:46](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L46) ___ @@ -145,4 +147,4 @@ This value is between 0..1, if not specified 1 is assumed, this will take up the #### Defined in -[src/TableCell.tsx:36](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/TableCell.tsx#L36) +[src/TableCell.tsx:36](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L36) diff --git a/docs/typedoc/interfaces/TableHeaderProps.md b/docs/typedoc/interfaces/TableHeaderProps.md new file mode 100644 index 0000000..0108e03 --- /dev/null +++ b/docs/typedoc/interfaces/TableHeaderProps.md @@ -0,0 +1,201 @@ +[@david.kucsai/react-pdf-table](../README.md) / [Exports](../modules.md) / TableHeaderProps + +# Interface: TableHeaderProps + +## Hierarchy + +- `TableRowProps` + + ↳ **`TableHeaderProps`** + +## Table of contents + +### Properties + +- [data](TableHeaderProps.md#data) +- [even](TableHeaderProps.md#even) +- [evenRowColor](TableHeaderProps.md#evenrowcolor) +- [fontSize](TableHeaderProps.md#fontsize) +- [includeBottomBorder](TableHeaderProps.md#includebottomborder) +- [includeLeftBorder](TableHeaderProps.md#includeleftborder) +- [includeRightBorder](TableHeaderProps.md#includerightborder) +- [includeTopBorder](TableHeaderProps.md#includetopborder) +- [oddRowColor](TableHeaderProps.md#oddrowcolor) +- [textAlign](TableHeaderProps.md#textalign) +- [zebra](TableHeaderProps.md#zebra) + +## Properties + +### data + +• `Optional` **data**: `any` + +Any data associated, relevant if the parent is a {@see DataTableCell}. + +#### Inherited from + +TableRowProps.data + +#### Defined in + +[src/TableRow.tsx:22](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L22) + +___ + +### even + +• `Optional` **even**: `boolean` + +Whether this row is even (true) or odd (false) + +#### Inherited from + +TableRowProps.even + +#### Defined in + +[src/TableRow.tsx:32](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L32) + +___ + +### evenRowColor + +• `Optional` **evenRowColor**: `string` + +Specify the color of even rows + +#### Inherited from + +TableRowProps.evenRowColor + +#### Defined in + +[src/TableRow.tsx:37](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L37) + +___ + +### fontSize + +• `Optional` **fontSize**: `string` \| `number` + +The font size as a valid unit defined in react-pdf. + +#### Inherited from + +TableRowProps.fontSize + +#### Defined in + +[src/TableRow.tsx:12](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L12) + +___ + +### includeBottomBorder + +• `Optional` **includeBottomBorder**: `boolean` + +Include the bottom border. Default true. + +#### Inherited from + +TableRowProps.includeBottomBorder + +#### Defined in + +[src/TableCell.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L23) + +___ + +### includeLeftBorder + +• `Optional` **includeLeftBorder**: `boolean` + +Include the left border. Default true. + +#### Inherited from + +TableRowProps.includeLeftBorder + +#### Defined in + +[src/TableCell.tsx:28](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L28) + +___ + +### includeRightBorder + +• `Optional` **includeRightBorder**: `boolean` + +Include the right border. Default true. + +#### Inherited from + +TableRowProps.includeRightBorder + +#### Defined in + +[src/TableCell.tsx:18](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L18) + +___ + +### includeTopBorder + +• `Optional` **includeTopBorder**: `boolean` + +Include the top border. Default true. + +#### Inherited from + +TableRowProps.includeTopBorder + +#### Defined in + +[src/TableCell.tsx:13](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableCell.tsx#L13) + +___ + +### oddRowColor + +• `Optional` **oddRowColor**: `string` + +Specify the color of odd rows + +#### Inherited from + +TableRowProps.oddRowColor + +#### Defined in + +[src/TableRow.tsx:42](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L42) + +___ + +### textAlign + +• `Optional` **textAlign**: ``"left"`` \| ``"center"`` \| ``"right"`` + +Whether to align the text. Defaults to left. + +#### Inherited from + +TableRowProps.textAlign + +#### Defined in + +[src/TableRow.tsx:17](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L17) + +___ + +### zebra + +• `Optional` **zebra**: `boolean` + +Whether rows have alternating styles + +#### Inherited from + +TableRowProps.zebra + +#### Defined in + +[src/TableRow.tsx:27](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/TableRow.tsx#L27) diff --git a/docs/typedoc/interfaces/TableProps.md b/docs/typedoc/interfaces/TableProps.md new file mode 100644 index 0000000..bf6365d --- /dev/null +++ b/docs/typedoc/interfaces/TableProps.md @@ -0,0 +1,81 @@ +[@david.kucsai/react-pdf-table](../README.md) / [Exports](../modules.md) / TableProps + +# Interface: TableProps + +## Hierarchy + +- [`ZebraProps`](ZebraProps.md) + + ↳ **`TableProps`** + +## Table of contents + +### Properties + +- [data](TableProps.md#data) +- [evenRowColor](TableProps.md#evenrowcolor) +- [oddRowColor](TableProps.md#oddrowcolor) +- [zebra](TableProps.md#zebra) + +## Properties + +### data + +• `Optional` **data**: `any`[] + +The table data to display. + +#### Defined in + +[src/Table.tsx:30](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L30) + +___ + +### evenRowColor + +• `Optional` **evenRowColor**: `string` + +The even row colour when {@see zebra} is true. +Defaults to lightgray if not defined. + +#### Inherited from + +[ZebraProps](ZebraProps.md).[evenRowColor](ZebraProps.md#evenrowcolor) + +#### Defined in + +[src/Table.tsx:17](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L17) + +___ + +### oddRowColor + +• `Optional` **oddRowColor**: `string` + +The odd row colour when {@see zebra} is true. +Defaults to transparent or '' if not defined. + +#### Inherited from + +[ZebraProps](ZebraProps.md).[oddRowColor](ZebraProps.md#oddrowcolor) + +#### Defined in + +[src/Table.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L23) + +___ + +### zebra + +• `Optional` **zebra**: `boolean` + +Whether to display alternate row colours. +Defaults to false. + +#### Inherited from + +[ZebraProps](ZebraProps.md).[zebra](ZebraProps.md#zebra) + +#### Defined in + +[src/Table.tsx:11](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L11) diff --git a/docs/typedoc/interfaces/ZebraProps.md b/docs/typedoc/interfaces/ZebraProps.md new file mode 100644 index 0000000..f243a44 --- /dev/null +++ b/docs/typedoc/interfaces/ZebraProps.md @@ -0,0 +1,56 @@ +[@david.kucsai/react-pdf-table](../README.md) / [Exports](../modules.md) / ZebraProps + +# Interface: ZebraProps + +## Hierarchy + +- **`ZebraProps`** + + ↳ [`TableProps`](TableProps.md) + +## Table of contents + +### Properties + +- [evenRowColor](ZebraProps.md#evenrowcolor) +- [oddRowColor](ZebraProps.md#oddrowcolor) +- [zebra](ZebraProps.md#zebra) + +## Properties + +### evenRowColor + +• `Optional` **evenRowColor**: `string` + +The even row colour when {@see zebra} is true. +Defaults to lightgray if not defined. + +#### Defined in + +[src/Table.tsx:17](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L17) + +___ + +### oddRowColor + +• `Optional` **oddRowColor**: `string` + +The odd row colour when {@see zebra} is true. +Defaults to transparent or '' if not defined. + +#### Defined in + +[src/Table.tsx:23](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L23) + +___ + +### zebra + +• `Optional` **zebra**: `boolean` + +Whether to display alternate row colours. +Defaults to false. + +#### Defined in + +[src/Table.tsx:11](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Table.tsx#L11) diff --git a/docs/typedoc/modules.md b/docs/typedoc/modules.md index 45d0753..6263887 100644 --- a/docs/typedoc/modules.md +++ b/docs/typedoc/modules.md @@ -14,9 +14,13 @@ ### Interfaces +- [DataTableCellProps](interfaces/DataTableCellProps.md) - [TableBodyProps](interfaces/TableBodyProps.md) - [TableBorder](interfaces/TableBorder.md) - [TableCellProps](interfaces/TableCellProps.md) +- [TableHeaderProps](interfaces/TableHeaderProps.md) +- [TableProps](interfaces/TableProps.md) +- [ZebraProps](interfaces/ZebraProps.md) ### Functions @@ -44,7 +48,7 @@ If the value is undefined then return true for that border. #### Defined in -[src/Utils.ts:9](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/Utils.ts#L9) +[src/Utils.ts:9](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Utils.ts#L9) ___ @@ -75,4 +79,4 @@ an array of items or an empty array. #### Defined in -[src/Utils.ts:25](https://github.com/dmk99/react-pdf-table/blob/b9a51c5/src/Utils.ts#L25) +[src/Utils.ts:25](https://github.com/dmk99/react-pdf-table/blob/bebcafb/src/Utils.ts#L25) diff --git a/lib/DataTableCell.d.ts b/lib/DataTableCell.d.ts index 77d64f8..1526799 100644 --- a/lib/DataTableCell.d.ts +++ b/lib/DataTableCell.d.ts @@ -1,10 +1,9 @@ import * as React from "react"; import { TableCellProps } from "./TableCell"; -interface DataTableCellProps extends TableCellProps { +export interface DataTableCellProps extends TableCellProps { data?: any; getContent: (data: any) => React.ReactNode | JSX.Element | string | number; } export declare class DataTableCell extends React.PureComponent { render(): JSX.Element; } -export {}; diff --git a/lib/DataTableCell.js.map b/lib/DataTableCell.js.map index bb9249a..1333c4a 100644 --- a/lib/DataTableCell.js.map +++ b/lib/DataTableCell.js.map @@ -1 +1 @@ -{"version":3,"file":"DataTableCell.js","sourceRoot":"","sources":["../src/DataTableCell.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,yCAAsD;AAkBtD;IAAmC,iCAAuC;IAA1E;;IAUA,CAAC;IATG,8BAAM,GAAN;QACI,OAAO,CACH,oBAAC,qBAAS,eACF,IAAI,CAAC,KAAK,GAEb,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAC/B,CACf,CAAA;IACL,CAAC;IACL,oBAAC;AAAD,CAAC,AAVD,CAAmC,KAAK,CAAC,aAAa,GAUrD;AAVY,sCAAa","sourcesContent":["import * as React from \"react\";\nimport {TableCell, TableCellProps} from \"./TableCell\";\n\ninterface DataTableCellProps extends TableCellProps {\n /**\n * The data associated with the cell.\n */\n data?: any;\n\n /**\n * The content to display for this cell.\n * @param data the data passed in.\n */\n getContent: (data: any) => React.ReactNode | JSX.Element | string | number;\n}\n\n/**\n * This component is used to display data in the the {@see TableRow} component.\n */\nexport class DataTableCell extends React.PureComponent {\n render() {\n return (\n \n {this.props.getContent(this.props.data)}\n \n )\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"DataTableCell.js","sourceRoot":"","sources":["../src/DataTableCell.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,yCAAsD;AAkBtD;IAAmC,iCAAuC;IAA1E;;IAUA,CAAC;IATG,8BAAM,GAAN;QACI,OAAO,CACH,oBAAC,qBAAS,eACF,IAAI,CAAC,KAAK,GAEb,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAC/B,CACf,CAAA;IACL,CAAC;IACL,oBAAC;AAAD,CAAC,AAVD,CAAmC,KAAK,CAAC,aAAa,GAUrD;AAVY,sCAAa","sourcesContent":["import * as React from \"react\";\nimport {TableCell, TableCellProps} from \"./TableCell\";\n\nexport interface DataTableCellProps extends TableCellProps {\n /**\n * The data associated with the cell.\n */\n data?: any;\n\n /**\n * The content to display for this cell.\n * @param data the data passed in.\n */\n getContent: (data: any) => React.ReactNode | JSX.Element | string | number;\n}\n\n/**\n * This component is used to display data in the the {@see TableRow} component.\n */\nexport class DataTableCell extends React.PureComponent {\n render() {\n return (\n \n {this.props.getContent(this.props.data)}\n \n )\n }\n}\n"]} \ No newline at end of file diff --git a/lib/Table.d.ts b/lib/Table.d.ts index 7a88f91..18fa8a9 100644 --- a/lib/Table.d.ts +++ b/lib/Table.d.ts @@ -1,11 +1,12 @@ import * as React from "react"; -interface TableProps { - data?: any[]; +export interface ZebraProps { zebra?: boolean; evenRowColor?: string; oddRowColor?: string; } +export interface TableProps extends ZebraProps { + data?: any[]; +} export declare class Table extends React.PureComponent { render(): JSX.Element; } -export {}; diff --git a/lib/Table.js b/lib/Table.js index 0566068..b48d209 100644 --- a/lib/Table.js +++ b/lib/Table.js @@ -26,7 +26,7 @@ var Table = (function (_super) { return _super !== null && _super.apply(this, arguments) || this; } Table.prototype.render = function () { - var _a, _b, _c, _d, _e, _f, _g, _h; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; var tableHeader = null; var tableBody = null; React.Children.forEach(this.props.children, function (c) { @@ -37,12 +37,15 @@ var Table = (function (_super) { tableBody = c; } }); + if (tableBody === null) { + tableBody = React.createElement(TableBody_1.TableBody); + } tableBody = React.cloneElement(tableBody, { - data: (_b = (_a = tableBody.props.data) !== null && _a !== void 0 ? _a : this.props.data) !== null && _b !== void 0 ? _b : [], + data: (_c = (_b = (_a = tableBody === null || tableBody === void 0 ? void 0 : tableBody.props) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : this.props.data) !== null && _c !== void 0 ? _c : [], renderTopBorder: !tableHeader, - zebra: (_d = (_c = tableBody.props.zebra) !== null && _c !== void 0 ? _c : this.props.zebra) !== null && _d !== void 0 ? _d : false, - evenRowColor: (_f = (_e = tableBody.props.evenRowColor) !== null && _e !== void 0 ? _e : this.props.evenRowColor) !== null && _f !== void 0 ? _f : '', - oddRowColor: (_h = (_g = tableBody.props.oddRowColor) !== null && _g !== void 0 ? _g : this.props.oddRowColor) !== null && _h !== void 0 ? _h : '', + zebra: (_f = (_e = (_d = tableBody === null || tableBody === void 0 ? void 0 : tableBody.props) === null || _d === void 0 ? void 0 : _d.zebra) !== null && _e !== void 0 ? _e : this.props.zebra) !== null && _f !== void 0 ? _f : false, + evenRowColor: (_j = (_h = (_g = tableBody === null || tableBody === void 0 ? void 0 : tableBody.props) === null || _g === void 0 ? void 0 : _g.evenRowColor) !== null && _h !== void 0 ? _h : this.props.evenRowColor) !== null && _j !== void 0 ? _j : '', + oddRowColor: (_m = (_l = (_k = tableBody === null || tableBody === void 0 ? void 0 : tableBody.props) === null || _k === void 0 ? void 0 : _k.oddRowColor) !== null && _l !== void 0 ? _l : this.props.oddRowColor) !== null && _m !== void 0 ? _m : '', }); return (React.createElement(renderer_1.View, { style: { width: "100%", diff --git a/lib/Table.js.map b/lib/Table.js.map index 94f2191..783aeda 100644 --- a/lib/Table.js.map +++ b/lib/Table.js.map @@ -1 +1 @@ -{"version":3,"file":"Table.js","sourceRoot":"","sources":["../src/Table.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,6CAA0C;AAC1C,yCAAsC;AACtC,gDAAyC;AASzC;IAA2B,yBAA+B;IAA1D;;IAgCA,CAAC;IA/BG,sBAAM,GAAN;;QACI,IAAI,WAAW,GAAgB,IAAI,CAAC;QACpC,IAAI,SAAS,GAAgB,IAAI,CAAC;QAElC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAC,CAAM;YAC/C,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,yBAAW,EAAE;gBACzB,WAAW,GAAG,CAAC,CAAC;aACnB;iBAAM,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,qBAAS,EAAE;gBAC9B,SAAS,GAAG,CAAC,CAAC;aACjB;QACL,CAAC,CAAC,CAAC;QAEH,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE;YACtC,IAAI,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,CAAC,IAAI,mCAAI,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAI,EAAE;YACnD,eAAe,EAAE,CAAC,WAAW;YAC7B,KAAK,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,KAAK;YACzD,YAAY,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,CAAC,YAAY,mCAAI,IAAI,CAAC,KAAK,CAAC,YAAY,mCAAI,EAAE;YAC3E,WAAW,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,CAAC,WAAW,mCAAI,IAAI,CAAC,KAAK,CAAC,WAAW,mCAAI,EAAE;SAC3E,CAAC,CAAC;QAEH,OAAO,CACH,oBAAC,eAAI,IACD,KAAK,EAAE;gBACH,KAAK,EAAE,MAAM;aAChB;YAEA,WAAW;YACX,SAAS,CACP,CACV,CAAC;IACN,CAAC;IACL,YAAC;AAAD,CAAC,AAhCD,CAA2B,KAAK,CAAC,aAAa,GAgC7C;AAhCY,sBAAK","sourcesContent":["import * as React from \"react\";\nimport {TableHeader} from \"./TableHeader\";\nimport {TableBody} from \"./TableBody\";\nimport {View} from \"@react-pdf/renderer\";\n\ninterface TableProps {\n data?: any[];\n zebra?: boolean;\n evenRowColor?: string;\n oddRowColor?: string;\n}\n\nexport class Table extends React.PureComponent {\n render() {\n let tableHeader: JSX.Element = null;\n let tableBody: JSX.Element = null;\n\n React.Children.forEach(this.props.children, (c: any) => {\n if (c?.type === TableHeader) {\n tableHeader = c;\n } else if (c?.type === TableBody) {\n tableBody = c;\n }\n });\n\n tableBody = React.cloneElement(tableBody, {\n data: tableBody.props.data ?? this.props.data ?? [],\n renderTopBorder: !tableHeader,\n zebra: tableBody.props.zebra ?? this.props.zebra ?? false,\n evenRowColor: tableBody.props.evenRowColor ?? this.props.evenRowColor ?? '',\n oddRowColor: tableBody.props.oddRowColor ?? this.props.oddRowColor ?? '',\n });\n\n return (\n \n {tableHeader}\n {tableBody}\n \n );\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"Table.js","sourceRoot":"","sources":["../src/Table.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,6CAA0C;AAC1C,yCAAsC;AACtC,gDAAyC;AA6BzC;IAA2B,yBAA+B;IAA1D;;IAoCA,CAAC;IAnCG,sBAAM,GAAN;;QACI,IAAI,WAAW,GAAuB,IAAI,CAAC;QAC3C,IAAI,SAAS,GAAuB,IAAI,CAAC;QAEzC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAC,CAAqB;YAC9D,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,yBAAW,EAAE;gBACzB,WAAW,GAAG,CAAC,CAAC;aACnB;iBAAM,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,qBAAS,EAAE;gBAC9B,SAAS,GAAG,CAAC,CAAC;aACjB;QACL,CAAC,CAAC,CAAC;QAEH,IAAG,SAAS,KAAK,IAAI,EAAE;YACnB,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC,qBAAS,CAAC,CAAC;SAC9C;QAED,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE;YACtC,IAAI,EAAE,MAAA,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,0CAAE,IAAI,mCAAI,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAI,EAAE;YACrD,eAAe,EAAE,CAAC,WAAW;YAC7B,KAAK,EAAE,MAAA,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,0CAAE,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,KAAK;YAC3D,YAAY,EAAE,MAAA,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,0CAAE,YAAY,mCAAI,IAAI,CAAC,KAAK,CAAC,YAAY,mCAAI,EAAE;YAC7E,WAAW,EAAE,MAAA,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,0CAAE,WAAW,mCAAI,IAAI,CAAC,KAAK,CAAC,WAAW,mCAAI,EAAE;SAC7E,CAAC,CAAC;QAEH,OAAO,CACH,oBAAC,eAAI,IACD,KAAK,EAAE;gBACH,KAAK,EAAE,MAAM;aAChB;YAEA,WAAW;YACX,SAAS,CACP,CACV,CAAC;IACN,CAAC;IACL,YAAC;AAAD,CAAC,AApCD,CAA2B,KAAK,CAAC,aAAa,GAoC7C;AApCY,sBAAK","sourcesContent":["import * as React from \"react\";\nimport {TableHeader} from \"./TableHeader\";\nimport {TableBody} from \"./TableBody\";\nimport {View} from \"@react-pdf/renderer\";\n\nexport interface ZebraProps {\n /**\n * Whether to display alternate row colours.\n * Defaults to false.\n */\n zebra?: boolean;\n\n /**\n * The even row colour when {@see zebra} is true.\n * Defaults to lightgray if not defined.\n */\n evenRowColor?: string;\n\n /**\n * The odd row colour when {@see zebra} is true.\n * Defaults to transparent or '' if not defined.\n */\n oddRowColor?: string;\n}\n\nexport interface TableProps extends ZebraProps {\n /**\n * The table data to display.\n */\n data?: any[];\n}\n\nexport class Table extends React.PureComponent {\n render() {\n let tableHeader: React.ReactElement = null;\n let tableBody: React.ReactElement = null;\n\n React.Children.forEach(this.props.children, (c: React.ReactElement) => {\n if (c?.type === TableHeader) {\n tableHeader = c;\n } else if (c?.type === TableBody) {\n tableBody = c;\n }\n });\n\n if(tableBody === null) {\n tableBody = React.createElement(TableBody);\n }\n\n tableBody = React.cloneElement(tableBody, {\n data: tableBody?.props?.data ?? this.props.data ?? [],\n renderTopBorder: !tableHeader,\n zebra: tableBody?.props?.zebra ?? this.props.zebra ?? false,\n evenRowColor: tableBody?.props?.evenRowColor ?? this.props.evenRowColor ?? '',\n oddRowColor: tableBody?.props?.oddRowColor ?? this.props.oddRowColor ?? '',\n });\n\n return (\n \n {tableHeader}\n {tableBody}\n \n );\n }\n}\n"]} \ No newline at end of file diff --git a/lib/TableBody.d.ts b/lib/TableBody.d.ts index a363239..ec1ad14 100644 --- a/lib/TableBody.d.ts +++ b/lib/TableBody.d.ts @@ -1,13 +1,10 @@ import { TableRowProps } from "./TableRow"; import * as React from "react"; -export interface TableBodyProps extends TableRowProps { +import { ZebraProps } from "./Table"; +export interface TableBodyProps extends TableRowProps, Pick { data?: any[]; - zebra?: boolean; -} -interface InternalBodyProps extends TableBodyProps { renderTopBorder?: boolean; } -export declare class TableBody extends React.PureComponent { +export declare class TableBody extends React.PureComponent { render(): JSX.Element[]; } -export {}; diff --git a/lib/TableBody.js.map b/lib/TableBody.js.map index 99bae12..57ff23d 100644 --- a/lib/TableBody.js.map +++ b/lib/TableBody.js.map @@ -1 +1 @@ -{"version":3,"file":"TableBody.js","sourceRoot":"","sources":["../src/TableBody.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAmD;AACnD,6BAA+B;AAC/B,iCAAiD;AAoBjD;IAA+B,6BAAsC;IAArE;;IAuBA,CAAC;IAtBG,0BAAM,GAAN;QAAA,iBAqBC;;QApBG,IAAM,QAAQ,GAAU,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAA,KAA+D,IAAA,gCAAwB,EAAC,IAAI,CAAC,KAAK,CAAC,EAAlG,iBAAiB,uBAAA,EAAE,mBAAmB,yBAAA,EAAE,kBAAkB,wBAAwC,CAAC;QAC1G,IAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAI,EAAE,CAAC;QAEvC,OAAO,CACH,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,QAAQ;;YAAK,OAAA,CAC/B,oBAAC,mBAAQ,eACD,KAAI,CAAC,KAAK,IACd,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,QAAQ,GAAC,CAAC,KAAG,CAAC,EACpB,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,gBAAgB,EAAE,MAAA,KAAI,CAAC,KAAK,CAAC,eAAe,mCAAI,KAAK,KAEpD,QAAQ,CACF,CACd,CAAA;SAAA,CAAC,CACL,CAAC;IACN,CAAC;IACL,gBAAC;AAAD,CAAC,AAvBD,CAA+B,KAAK,CAAC,aAAa,GAuBjD;AAvBY,8BAAS","sourcesContent":["import {TableRow, TableRowProps} from \"./TableRow\";\nimport * as React from \"react\";\nimport {getDefaultBorderIncludes} from \"./Utils\";\n\nexport interface TableBodyProps extends TableRowProps {\n /**\n * The data associated with the table.\n */\n data?: any[];\n zebra?: boolean;\n}\n\n// This interface adds a flag to indicate if we should render the top border,\n// thus allowing us to render it in the event that no\n// header rows were present in the table.\ninterface InternalBodyProps extends TableBodyProps {\n renderTopBorder?: boolean\n}\n\n/**\n * This component displays the data as {@see TableRow}s.\n */\nexport class TableBody extends React.PureComponent {\n render() {\n const rowCells: any[] = React.Children.toArray(this.props.children);\n const {includeLeftBorder, includeBottomBorder, includeRightBorder} = getDefaultBorderIncludes(this.props);\n const dataRows = this.props.data ?? [];\n\n return (\n (dataRows).map((data, rowIndex) => (\n \n {rowCells}\n \n ))\n );\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"TableBody.js","sourceRoot":"","sources":["../src/TableBody.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAmD;AACnD,6BAA+B;AAC/B,iCAAiD;AAkBjD;IAA+B,6BAAmC;IAAlE;;IAuBA,CAAC;IAtBG,0BAAM,GAAN;QAAA,iBAqBC;;QApBG,IAAM,QAAQ,GAAsB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1E,IAAA,KAA+D,IAAA,gCAAwB,EAAC,IAAI,CAAC,KAAK,CAAC,EAAlG,iBAAiB,uBAAA,EAAE,mBAAmB,yBAAA,EAAE,kBAAkB,wBAAwC,CAAC;QAC1G,IAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,IAAI,mCAAI,EAAE,CAAC;QAEvC,OAAO,CACH,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,QAAQ;;YAAK,OAAA,CAC/B,oBAAC,mBAAQ,eACD,KAAI,CAAC,KAAK,IACd,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,QAAQ,GAAG,CAAC,KAAK,CAAC,EACxB,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,gBAAgB,EAAE,MAAA,KAAI,CAAC,KAAK,CAAC,eAAe,mCAAI,KAAK,KAEpD,QAAQ,CACF,CACd,CAAA;SAAA,CAAC,CACL,CAAC;IACN,CAAC;IACL,gBAAC;AAAD,CAAC,AAvBD,CAA+B,KAAK,CAAC,aAAa,GAuBjD;AAvBY,8BAAS","sourcesContent":["import {TableRow, TableRowProps} from \"./TableRow\";\nimport * as React from \"react\";\nimport {getDefaultBorderIncludes} from \"./Utils\";\nimport {ZebraProps} from \"./Table\";\n\nexport interface TableBodyProps extends TableRowProps, Pick {\n /**\n * The data associated with the table.\n */\n data?: any[];\n\n // This interface adds a flag to indicate if we should render the top border,\n // thus allowing us to render it in the event that no\n // header rows were present in the table.\n renderTopBorder?: boolean\n}\n\n/**\n * This component displays the data as {@see TableRow}s.\n */\nexport class TableBody extends React.PureComponent {\n render() {\n const rowCells: React.ReactNode[] = React.Children.toArray(this.props.children);\n const {includeLeftBorder, includeBottomBorder, includeRightBorder} = getDefaultBorderIncludes(this.props);\n const dataRows = this.props.data ?? [];\n\n return (\n (dataRows).map((data, rowIndex) => (\n \n {rowCells}\n \n ))\n );\n }\n}\n"]} \ No newline at end of file diff --git a/lib/TableHeader.d.ts b/lib/TableHeader.d.ts index 09bbeb0..25f75ef 100644 --- a/lib/TableHeader.d.ts +++ b/lib/TableHeader.d.ts @@ -1,8 +1,7 @@ import * as React from "react"; import { TableRowProps } from "./TableRow"; -interface TableHeaderProps extends TableRowProps { +export interface TableHeaderProps extends TableRowProps { } export declare class TableHeader extends React.PureComponent { render(): JSX.Element; } -export {}; diff --git a/lib/TableHeader.js.map b/lib/TableHeader.js.map index ed8a6fb..0219300 100644 --- a/lib/TableHeader.js.map +++ b/lib/TableHeader.js.map @@ -1 +1 @@ -{"version":3,"file":"TableHeader.js","sourceRoot":"","sources":["../src/TableHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,iCAAiD;AACjD,uCAAmD;AAQnD;IAAiC,+BAAqC;IAAtE;;IA4BA,CAAC;IA3BG,4BAAM,GAAN;QAAA,iBA0BC;QAzBO,IAAA,KAAiF,IAAA,gCAAwB,EAAC,IAAI,CAAC,KAAK,CAAC,EAApH,iBAAiB,uBAAA,EAAE,mBAAmB,yBAAA,EAAE,kBAAkB,wBAAA,EAAE,gBAAgB,sBAAwC,CAAC;QAE1H,IAAM,QAAQ,GAAU,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEpE,OAAO,CACH,oBAAC,mBAAQ,eACD,IAAI,CAAC,KAAK,IACd,GAAG,EAAE,QAAQ,EACb,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,gBAAgB,EAAE,gBAAgB,KAG9B,QAAQ,CAAC,GAAG,CAAC,UAAC,EAAE,EAAE,WAAW,IAAK,OAAA,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE;YACrD,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,KAAI,CAAC,KAAK,CAAC,QAAQ;YAC7B,SAAS,EAAE,KAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,iBAAiB,EAAE,WAAW,KAAK,CAAC;YACpC,kBAAkB,EAAE,WAAW,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;SAC5D,CAAC,EAPgC,CAOhC,CAAC,CAEA,CACd,CAAC;IACN,CAAC;IACL,kBAAC;AAAD,CAAC,AA5BD,CAAiC,KAAK,CAAC,aAAa,GA4BnD;AA5BY,kCAAW","sourcesContent":["import * as React from \"react\";\nimport {getDefaultBorderIncludes} from \"./Utils\";\nimport {TableRow, TableRowProps} from \"./TableRow\";\n\ninterface TableHeaderProps extends TableRowProps {\n}\n\n/**\n * This component displays the titles for the rows.\n */\nexport class TableHeader extends React.PureComponent {\n render() {\n let {includeLeftBorder, includeBottomBorder, includeRightBorder, includeTopBorder} = getDefaultBorderIncludes(this.props);\n\n const rowCells: any[] = React.Children.toArray(this.props.children);\n\n return (\n \n {\n rowCells.map((rc, columnIndex) => React.cloneElement(rc, {\n key: columnIndex,\n isHeader: true,\n fontSize: this.props.fontSize,\n textAlign: this.props.textAlign,\n includeLeftBorder: columnIndex === 0,\n includeRightBorder: columnIndex !== (rowCells.length - 1)\n }))\n }\n \n );\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"TableHeader.js","sourceRoot":"","sources":["../src/TableHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,iCAAiD;AACjD,uCAAmD;AAQnD;IAAiC,+BAAqC;IAAtE;;IA4BA,CAAC;IA3BG,4BAAM,GAAN;QAAA,iBA0BC;QAzBO,IAAA,KAAiF,IAAA,gCAAwB,EAAC,IAAI,CAAC,KAAK,CAAC,EAApH,iBAAiB,uBAAA,EAAE,mBAAmB,yBAAA,EAAE,kBAAkB,wBAAA,EAAE,gBAAgB,sBAAwC,CAAC;QAE1H,IAAM,QAAQ,GAAU,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEpE,OAAO,CACH,oBAAC,mBAAQ,eACD,IAAI,CAAC,KAAK,IACd,GAAG,EAAE,QAAQ,EACb,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,kBAAkB,EACtC,gBAAgB,EAAE,gBAAgB,KAG9B,QAAQ,CAAC,GAAG,CAAC,UAAC,EAAE,EAAE,WAAW,IAAK,OAAA,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE;YACrD,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,KAAI,CAAC,KAAK,CAAC,QAAQ;YAC7B,SAAS,EAAE,KAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,iBAAiB,EAAE,WAAW,KAAK,CAAC;YACpC,kBAAkB,EAAE,WAAW,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;SAC5D,CAAC,EAPgC,CAOhC,CAAC,CAEA,CACd,CAAC;IACN,CAAC;IACL,kBAAC;AAAD,CAAC,AA5BD,CAAiC,KAAK,CAAC,aAAa,GA4BnD;AA5BY,kCAAW","sourcesContent":["import * as React from \"react\";\nimport {getDefaultBorderIncludes} from \"./Utils\";\nimport {TableRow, TableRowProps} from \"./TableRow\";\n\nexport interface TableHeaderProps extends TableRowProps {\n}\n\n/**\n * This component displays the titles for the rows.\n */\nexport class TableHeader extends React.PureComponent {\n render() {\n let {includeLeftBorder, includeBottomBorder, includeRightBorder, includeTopBorder} = getDefaultBorderIncludes(this.props);\n\n const rowCells: any[] = React.Children.toArray(this.props.children);\n\n return (\n \n {\n rowCells.map((rc, columnIndex) => React.cloneElement(rc, {\n key: columnIndex,\n isHeader: true,\n fontSize: this.props.fontSize,\n textAlign: this.props.textAlign,\n includeLeftBorder: columnIndex === 0,\n includeRightBorder: columnIndex !== (rowCells.length - 1)\n }))\n }\n \n );\n }\n}\n"]} \ No newline at end of file diff --git a/lib/src/DataTableCell.d.ts b/lib/src/DataTableCell.d.ts index 77d64f8..1526799 100644 --- a/lib/src/DataTableCell.d.ts +++ b/lib/src/DataTableCell.d.ts @@ -1,10 +1,9 @@ import * as React from "react"; import { TableCellProps } from "./TableCell"; -interface DataTableCellProps extends TableCellProps { +export interface DataTableCellProps extends TableCellProps { data?: any; getContent: (data: any) => React.ReactNode | JSX.Element | string | number; } export declare class DataTableCell extends React.PureComponent { render(): JSX.Element; } -export {}; diff --git a/lib/src/Table.d.ts b/lib/src/Table.d.ts index 7a88f91..18fa8a9 100644 --- a/lib/src/Table.d.ts +++ b/lib/src/Table.d.ts @@ -1,11 +1,12 @@ import * as React from "react"; -interface TableProps { - data?: any[]; +export interface ZebraProps { zebra?: boolean; evenRowColor?: string; oddRowColor?: string; } +export interface TableProps extends ZebraProps { + data?: any[]; +} export declare class Table extends React.PureComponent { render(): JSX.Element; } -export {}; diff --git a/lib/src/TableBody.d.ts b/lib/src/TableBody.d.ts index 8d5c301..ec1ad14 100644 --- a/lib/src/TableBody.d.ts +++ b/lib/src/TableBody.d.ts @@ -1,8 +1,8 @@ import { TableRowProps } from "./TableRow"; import * as React from "react"; -export interface TableBodyProps extends TableRowProps { +import { ZebraProps } from "./Table"; +export interface TableBodyProps extends TableRowProps, Pick { data?: any[]; - zebra?: boolean; renderTopBorder?: boolean; } export declare class TableBody extends React.PureComponent { diff --git a/lib/src/TableHeader.d.ts b/lib/src/TableHeader.d.ts index 09bbeb0..25f75ef 100644 --- a/lib/src/TableHeader.d.ts +++ b/lib/src/TableHeader.d.ts @@ -1,8 +1,7 @@ import * as React from "react"; import { TableRowProps } from "./TableRow"; -interface TableHeaderProps extends TableRowProps { +export interface TableHeaderProps extends TableRowProps { } export declare class TableHeader extends React.PureComponent { render(): JSX.Element; } -export {}; diff --git a/package.json b/package.json index 7b3e9ca..763e9ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@david.kucsai/react-pdf-table", - "version": "0.3.0", + "version": "0.4.0", "description": "Provides tables for the @react-pdf/renderer.", "main": "./lib/index.js", "scripts": { diff --git a/src/DataTableCell.tsx b/src/DataTableCell.tsx index 03c2107..1d28efa 100644 --- a/src/DataTableCell.tsx +++ b/src/DataTableCell.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import {TableCell, TableCellProps} from "./TableCell"; -interface DataTableCellProps extends TableCellProps { +export interface DataTableCellProps extends TableCellProps { /** * The data associated with the cell. */ diff --git a/src/Table.tsx b/src/Table.tsx index 0507d5d..65f6d56 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -3,13 +3,33 @@ import {TableHeader} from "./TableHeader"; import {TableBody} from "./TableBody"; import {View} from "@react-pdf/renderer"; -interface TableProps { - data?: any[]; +export interface ZebraProps { + /** + * Whether to display alternate row colours. + * Defaults to false. + */ zebra?: boolean; + + /** + * The even row colour when {@see zebra} is true. + * Defaults to lightgray if not defined. + */ evenRowColor?: string; + + /** + * The odd row colour when {@see zebra} is true. + * Defaults to transparent or '' if not defined. + */ oddRowColor?: string; } +export interface TableProps extends ZebraProps { + /** + * The table data to display. + */ + data?: any[]; +} + export class Table extends React.PureComponent { render() { let tableHeader: React.ReactElement = null; diff --git a/src/TableBody.tsx b/src/TableBody.tsx index 56102ef..6870040 100644 --- a/src/TableBody.tsx +++ b/src/TableBody.tsx @@ -1,13 +1,13 @@ import {TableRow, TableRowProps} from "./TableRow"; import * as React from "react"; import {getDefaultBorderIncludes} from "./Utils"; +import {ZebraProps} from "./Table"; -export interface TableBodyProps extends TableRowProps { +export interface TableBodyProps extends TableRowProps, Pick { /** * The data associated with the table. */ data?: any[]; - zebra?: boolean; // This interface adds a flag to indicate if we should render the top border, // thus allowing us to render it in the event that no diff --git a/src/TableHeader.tsx b/src/TableHeader.tsx index 7fa48ab..7062448 100644 --- a/src/TableHeader.tsx +++ b/src/TableHeader.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import {getDefaultBorderIncludes} from "./Utils"; import {TableRow, TableRowProps} from "./TableRow"; -interface TableHeaderProps extends TableRowProps { +export interface TableHeaderProps extends TableRowProps { } /**