From dcb19b2953069bfbf979d4ba5d1e00e092137eca Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 13:47:59 +0300 Subject: [PATCH] revert defaultProps change --- es/components/static-pages/StaticPageBase.js | 61 +++++++++++-------- src/components/static-pages/StaticPageBase.js | 57 +++++++++-------- 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/es/components/static-pages/StaticPageBase.js b/es/components/static-pages/StaticPageBase.js index 8b238cdd..8fa6d285 100644 --- a/es/components/static-pages/StaticPageBase.js +++ b/es/components/static-pages/StaticPageBase.js @@ -224,32 +224,8 @@ export var StaticPageBase = /*#__PURE__*/function (_React$PureComponent2) { key: "render", value: function render() { var _this$props2 = this.props, - _this$props2$context = _this$props2.context, - context = _this$props2$context === void 0 ? { - title: "Page Title", - content: { - sectionNameID1: { - order: 0, - title: "Section Title 1", - content: "

Hello

", - filetype: "html" - }, - sectionNameID2: { - order: 1, - title: "Section Title 2", - content: "

World

", - filetype: "html" - } - } - } : _this$props2$context, - _this$props2$entryRen = _this$props2.entryRenderFxn, - entryRenderFxn = _this$props2$entryRen === void 0 ? memoize(function (sectionName, section, props) { - return /*#__PURE__*/React.createElement(StaticEntry, _extends({}, props, { - key: sectionName, - sectionName: sectionName, - section: section - })); - }) : _this$props2$entryRen, + context = _this$props2.context, + entryRenderFxn = _this$props2.entryRenderFxn, contentParseFxn = _this$props2.contentParseFxn, CustomWrapper = _this$props2.CustomWrapper; var parsedContent = null; @@ -298,6 +274,39 @@ export var StaticPageBase = /*#__PURE__*/function (_React$PureComponent2) { }]); }(React.PureComponent); _defineProperty(StaticPageBase, "Wrapper", Wrapper); +_defineProperty(StaticPageBase, "defaultProps", { + "context": { + "title": "Page Title", + "content": { + "sectionNameID1": { + "order": 0, + "title": "Section Title 1", + "content": "

Hello

", + "filetype": "html" + }, + "sectionNameID2": { + "order": 1, + "title": "Section Title 2", + "content": "

World

", + "filetype": "html" + } + } + }, + /** + * Default function for rendering out parsed section(s) content. + * + * @param {string} sectionName - Unique identifier of the section. Use to navigate to via '#' in URL. + * @param {{ content : string|JSX.Element }} section - Object with parsed content, title, etc. + * @param {Object} props - Collection of props passed down from BodyElement. + */ + 'entryRenderFxn': memoize(function (sectionName, section, props) { + return /*#__PURE__*/React.createElement(StaticEntry, _extends({}, props, { + key: sectionName, + sectionName: sectionName, + section: section + })); + }) +}); _defineProperty(StaticPageBase, "propTypes", { 'context': PropTypes.shape({ "title": PropTypes.string, diff --git a/src/components/static-pages/StaticPageBase.js b/src/components/static-pages/StaticPageBase.js index b24d4f84..41041817 100644 --- a/src/components/static-pages/StaticPageBase.js +++ b/src/components/static-pages/StaticPageBase.js @@ -203,6 +203,38 @@ export class StaticPageBase extends React.PureComponent { ); } + static defaultProps = { + "context" : { + "title" : "Page Title", + "content" : { + "sectionNameID1" : { + "order" : 0, + "title" : "Section Title 1", + "content" : "

Hello

", + "filetype" : "html" + }, + "sectionNameID2" : { + "order" : 1, + "title" : "Section Title 2", + "content" : "

World

", + "filetype" : "html" + } + } + }, + + /** + * Default function for rendering out parsed section(s) content. + * + * @param {string} sectionName - Unique identifier of the section. Use to navigate to via '#' in URL. + * @param {{ content : string|JSX.Element }} section - Object with parsed content, title, etc. + * @param {Object} props - Collection of props passed down from BodyElement. + */ + 'entryRenderFxn' : memoize(function(sectionName, section, props){ + return ( + + ); + }) + }; static propTypes = { 'context' : PropTypes.shape({ @@ -217,30 +249,7 @@ export class StaticPageBase extends React.PureComponent { }; render() { - const { - context = { - title: "Page Title", - content: { - sectionNameID1: { - order: 0, - title: "Section Title 1", - content: "

Hello

", - filetype: "html" - }, - sectionNameID2: { - order: 1, - title: "Section Title 2", - content: "

World

", - filetype: "html" - } - } - }, - entryRenderFxn = memoize((sectionName, section, props) => ( - - )), - contentParseFxn, - CustomWrapper - } = this.props; + const { context, entryRenderFxn, contentParseFxn, CustomWrapper } = this.props; let parsedContent = null; try {