From 80c37945d0f8699be3c1c022af632e69169ab39d Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 29 Jul 2024 00:23:16 +0300 Subject: [PATCH 01/35] support legacy and new redux stores --- es/components/ui/Alerts.js | 129 +++++++++++++++++++++--------------- src/components/ui/Alerts.js | 31 ++++++--- 2 files changed, 97 insertions(+), 63 deletions(-) diff --git a/es/components/ui/Alerts.js b/es/components/ui/Alerts.js index 8963810f..d8f56aa1 100644 --- a/es/components/ui/Alerts.js +++ b/es/components/ui/Alerts.js @@ -1,20 +1,24 @@ +import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; +import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; +import _createClass from "@babel/runtime/helpers/createClass"; +import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; +import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; +import _inherits from "@babel/runtime/helpers/inherits"; +import _defineProperty from "@babel/runtime/helpers/defineProperty"; var _excluded = ["alerts", "children"]; -function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } -function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } -function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _callSuper(_this, derived, args) { + derived = _getPrototypeOf(derived); + return _possibleConstructorReturn(_this, function () { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + try { + return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); + } catch (e) { + return false; + } + }() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); +} import React from 'react'; import PropTypes from 'prop-types'; import _ from 'underscore'; @@ -23,6 +27,7 @@ import { AlertObj } from './../util/typedefs'; var defaultNavigateDisappearThreshold = 1; var alertNavigatationCountMap = {}; var store = null; +var reduxIsLegacy = true; /** * A Component and utility (via Component's 'statics' property & functions) to @@ -31,14 +36,12 @@ var store = null; * title for alert that was queued. */ export var Alerts = /*#__PURE__*/function (_React$Component) { - _inherits(Alerts, _React$Component); - var _super = _createSuper(Alerts); /** @ignore */ function Alerts(props) { - var _this; + var _this2; _classCallCheck(this, Alerts); - _this = _super.call(this, props); - _this.setDismissing = _this.setDismissing.bind(_assertThisInitialized(_this)); + _this2 = _callSuper(this, Alerts, [props]); + _this2.setDismissing = _this2.setDismissing.bind(_this2); /** * State object for component. @@ -47,17 +50,18 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { * @private * @property {AlertObj[]} state.dismissing - List of alerts currently being faded out. */ - _this.state = { + _this2.state = { 'dismissing': [] }; - return _this; + return _this2; } /** * Called when 'fade out' of an alert is initialized. * @private */ - _createClass(Alerts, [{ + _inherits(Alerts, _React$Component); + return _createClass(Alerts, [{ key: "setDismissing", value: function setDismissing(dismissing) { this.setState({ @@ -74,7 +78,7 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { }, { key: "render", value: function render() { - var _this2 = this; + var _this3 = this; var _this$props = this.props, alerts = _this$props.alerts, children = _this$props.children, @@ -86,7 +90,7 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { alert: alert, index: index, alerts: alerts, - setDismissing: _this2.setDismissing, + setDismissing: _this3.setDismissing, dismissing: dismissing, key: index }); @@ -95,8 +99,11 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { }], [{ key: "setStore", value: /** This must be called with the current Redux store for the app before Alerts can be used. */ - function setStore(useStore) { + function setStore(useStore, isLegacy) { store = useStore; + if (typeof isLegacy === 'boolean') { + reduxIsLegacy = isLegacy; + } } /** @@ -130,11 +137,18 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { } else { newAlerts.push(alert); } - store.dispatch({ - type: { - 'alerts': newAlerts - } - }); + if (reduxIsLegacy) { + store.dispatch({ + type: { + 'alerts': newAlerts + } + }); + } else { + store.dispatch({ + type: 'SET_ALERTS', + payload: newAlerts + }); + } } /** @@ -167,11 +181,18 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { } }); if (nextAlerts.length < currentAlerts.length) { - store.dispatch({ - type: { - 'alerts': nextAlerts - } - }); + if (reduxIsLegacy) { + store.dispatch({ + type: { + 'alerts': nextAlerts + } + }); + } else { + store.dispatch({ + type: 'SET_ALERTS', + payload: nextAlerts + }); + } } } @@ -206,7 +227,6 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { }); } }]); - return Alerts; }(React.Component); _defineProperty(Alerts, "defaultProps", { "className": "alerts mt-2" @@ -262,17 +282,16 @@ export var LoginFailed = Alerts.LoginFailed = { * @private */ var AlertItem = /*#__PURE__*/function (_React$PureComponent) { - _inherits(AlertItem, _React$PureComponent); - var _super2 = _createSuper(AlertItem); function AlertItem(props) { - var _this3; + var _this4; _classCallCheck(this, AlertItem); - _this3 = _super2.call(this, props); - _this3.dismiss = _this3.dismiss.bind(_assertThisInitialized(_this3)); - _this3.finishDismiss = _this3.finishDismiss.bind(_assertThisInitialized(_this3)); - return _this3; + _this4 = _callSuper(this, AlertItem, [props]); + _this4.dismiss = _this4.dismiss.bind(_this4); + _this4.finishDismiss = _this4.finishDismiss.bind(_this4); + return _this4; } - _createClass(AlertItem, [{ + _inherits(AlertItem, _React$PureComponent); + return _createClass(AlertItem, [{ key: "dismiss", value: function dismiss(e) { e.stopPropagation(); @@ -296,11 +315,18 @@ var AlertItem = /*#__PURE__*/function (_React$PureComponent) { setDismissing = _this$props3.setDismissing, alerts = _this$props3.alerts; setDismissing(_.without(dismissing, alert)); - store.dispatch({ - type: { - 'alerts': _.without(alerts, alert) - } - }); + if (reduxIsLegacy) { + store.dispatch({ + type: { + 'alerts': _.without(alerts, alert) + } + }); + } else { + store.dispatch({ + type: 'SET_ALERTS', + payload: _.without(alerts, alert) + }); + } } }, { key: "render", @@ -335,5 +361,4 @@ var AlertItem = /*#__PURE__*/function (_React$PureComponent) { }, message) : null)); } }]); - return AlertItem; }(React.PureComponent); \ No newline at end of file diff --git a/src/components/ui/Alerts.js b/src/components/ui/Alerts.js index 48d43b9f..b63f9ca4 100644 --- a/src/components/ui/Alerts.js +++ b/src/components/ui/Alerts.js @@ -11,6 +11,7 @@ const alertNavigatationCountMap = {}; let store = null; +let reduxIsLegacy = true; /** * A Component and utility (via Component's 'statics' property & functions) to @@ -21,8 +22,11 @@ let store = null; export class Alerts extends React.Component { /** This must be called with the current Redux store for the app before Alerts can be used. */ - static setStore(useStore){ + static setStore(useStore, isLegacy){ store = useStore; + if (typeof isLegacy === 'boolean') { + reduxIsLegacy = isLegacy; + } } /** @@ -52,9 +56,11 @@ export class Alerts extends React.Component { } else { newAlerts.push(alert); } - store.dispatch({ - type: { 'alerts' : newAlerts } - }); + if (reduxIsLegacy) { + store.dispatch({ type: { 'alerts': newAlerts } }); + } else { + store.dispatch({ type: 'SET_ALERTS', payload: newAlerts }); + } } /** @@ -88,11 +94,12 @@ export class Alerts extends React.Component { }); if (nextAlerts.length < currentAlerts.length) { - store.dispatch({ - type: { 'alerts' : nextAlerts } - }); + if (reduxIsLegacy) { + store.dispatch({ type: { 'alerts': nextAlerts } }); + } else { + store.dispatch({ type: 'SET_ALERTS', payload: nextAlerts }); + } } - } /** @@ -248,9 +255,11 @@ class AlertItem extends React.PureComponent { finishDismiss(){ const { alert, dismissing, setDismissing, alerts } = this.props; setDismissing(_.without(dismissing, alert)); - store.dispatch({ - type: { 'alerts' : _.without(alerts, alert) } - }); + if (reduxIsLegacy) { + store.dispatch({ type: { 'alerts': _.without(alerts, alert) } }); + } else { + store.dispatch({ type: 'SET_ALERTS', payload: _.without(alerts, alert) }); + } } render(){ From cd35f9d0ef5e8f317bd21f1a604f81d8d687bb24 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 29 Jul 2024 00:34:55 +0300 Subject: [PATCH 02/35] add comment --- es/components/ui/Alerts.js | 7 ++++++- src/components/ui/Alerts.js | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/es/components/ui/Alerts.js b/es/components/ui/Alerts.js index d8f56aa1..66e2ecd2 100644 --- a/es/components/ui/Alerts.js +++ b/es/components/ui/Alerts.js @@ -98,7 +98,12 @@ export var Alerts = /*#__PURE__*/function (_React$Component) { } }], [{ key: "setStore", - value: /** This must be called with the current Redux store for the app before Alerts can be used. */ + value: + /** + * This must be called with the current Redux store for the app before Alerts can be used. + * @param {*} useStore + * @param {*} isLegacy pass false to use new redux v5 dispatcher call ({ type: 'STRING', payload: ... }) + */ function setStore(useStore, isLegacy) { store = useStore; if (typeof isLegacy === 'boolean') { diff --git a/src/components/ui/Alerts.js b/src/components/ui/Alerts.js index b63f9ca4..8657a76a 100644 --- a/src/components/ui/Alerts.js +++ b/src/components/ui/Alerts.js @@ -21,7 +21,11 @@ let reduxIsLegacy = true; */ export class Alerts extends React.Component { - /** This must be called with the current Redux store for the app before Alerts can be used. */ + /** + * This must be called with the current Redux store for the app before Alerts can be used. + * @param {*} useStore + * @param {*} isLegacy pass false to use new redux v5 dispatcher call ({ type: 'STRING', payload: ... }) + */ static setStore(useStore, isLegacy){ store = useStore; if (typeof isLegacy === 'boolean') { From 9f0577cd1d488e55300366f2f948335354919736 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 29 Jul 2024 00:35:15 +0300 Subject: [PATCH 03/35] bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 283cbc41..6ab46882 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hms-dbmi-bgm/shared-portal-components", - "version": "0.1.87", + "version": "0.1.88", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hms-dbmi-bgm/shared-portal-components", - "version": "0.1.87", + "version": "0.1.88", "license": "MIT", "dependencies": { "@4dn-dcic/react-infinite": "github:4dn-dcic/react-infinite#1.1.9", diff --git a/package.json b/package.json index adf1d58e..091b65ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hms-dbmi-bgm/shared-portal-components", - "version": "0.1.87", + "version": "0.1.88", "description": "Shared components used for DBMI/BGM portal(s).", "repository": { "type": "git", From 3f6941d0f2fddb739c252a5eacd7e3a128007b17 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Tue, 6 Aug 2024 23:14:20 +0300 Subject: [PATCH 04/35] bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ab46882..615a49f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hms-dbmi-bgm/shared-portal-components", - "version": "0.1.88", + "version": "0.1.89", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hms-dbmi-bgm/shared-portal-components", - "version": "0.1.88", + "version": "0.1.89", "license": "MIT", "dependencies": { "@4dn-dcic/react-infinite": "github:4dn-dcic/react-infinite#1.1.9", diff --git a/package.json b/package.json index 091b65ca..ad6bf4f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hms-dbmi-bgm/shared-portal-components", - "version": "0.1.88", + "version": "0.1.89", "description": "Shared components used for DBMI/BGM portal(s).", "repository": { "type": "git", From ab6a3c404008579b462397ecdd92e4d8c9b667f7 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Tue, 6 Aug 2024 23:15:10 +0300 Subject: [PATCH 05/35] rebuild unaligned /es file --- es/components/ui/ItemDetailList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/es/components/ui/ItemDetailList.js b/es/components/ui/ItemDetailList.js index 3d6de9f8..bf8346cf 100644 --- a/es/components/ui/ItemDetailList.js +++ b/es/components/ui/ItemDetailList.js @@ -475,7 +475,7 @@ var SubItemTable = /*#__PURE__*/function (_React$Component) { var valKey = valKeys[_i]; if (Array.isArray(v2[valKey])) { // Concatenate value in [v2] into value in [m] - if (typeof m[valKey] === "number") { + if (!Array.isArray(m[valKey])) { m[valKey] = [m[valKey]].concat(v2[valKey]); } else { // m[valKey] is already an array From 653579c380a65d5ff1bd702fe0300c6c586a6af3 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Tue, 6 Aug 2024 23:16:48 +0300 Subject: [PATCH 06/35] fix prop type mismatch ("boolean" expected, "string" found) warning --- es/components/browse/components/FacetList/FacetTermsList.js | 2 +- src/components/browse/components/FacetList/FacetTermsList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/browse/components/FacetList/FacetTermsList.js b/es/components/browse/components/FacetList/FacetTermsList.js index a5af35c3..a8031503 100644 --- a/es/components/browse/components/FacetList/FacetTermsList.js +++ b/es/components/browse/components/FacetList/FacetTermsList.js @@ -565,7 +565,7 @@ var ListOfTerms = /*#__PURE__*/React.memo(function (props) { /** Create term components and sort by status (selected->omitted->unselected) */ var _useMemo = useMemo(function () { var field = facet.field; - var facetSearchActive = searchType === 'basic' && searchText && typeof searchText === 'string' && searchText.length > 0; + var facetSearchActive = searchType === 'basic' && typeof searchText === 'string' && searchText.length > 0; var _ref7 = facetSearchActive ? getFilteredTerms(terms, searchText, facetHasGroupBy) : {}, _ref7$filteredTerms = _ref7.filteredTerms, textFilteredTerms = _ref7$filteredTerms === void 0 ? {} : _ref7$filteredTerms, diff --git a/src/components/browse/components/FacetList/FacetTermsList.js b/src/components/browse/components/FacetList/FacetTermsList.js index 479ef298..fb0df443 100644 --- a/src/components/browse/components/FacetList/FacetTermsList.js +++ b/src/components/browse/components/FacetList/FacetTermsList.js @@ -417,7 +417,7 @@ const ListOfTerms = React.memo(function ListOfTerms(props){ } = useMemo(function(){ const { field } = facet; - const facetSearchActive = searchType === 'basic' && searchText && typeof searchText === 'string' && searchText.length > 0; + const facetSearchActive = searchType === 'basic' && typeof searchText === 'string' && searchText.length > 0; const { filteredTerms: textFilteredTerms = {}, filteredSubTerms : textFilteredSubTerms = null From f13f6d3574eb5101e5d2a4ffbb1f8c1a63c81f4d Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Tue, 6 Aug 2024 23:17:07 +0300 Subject: [PATCH 07/35] remove unnecessary lines --- .../browse/components/FacetList/index.js | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/components/browse/components/FacetList/index.js b/src/components/browse/components/FacetList/index.js index 0bda6083..502cc3e6 100644 --- a/src/components/browse/components/FacetList/index.js +++ b/src/components/browse/components/FacetList/index.js @@ -822,35 +822,20 @@ export const FacetListHeader = React.memo(function FacetListHeader(props){ } - { !hideToggle && -
-
-
- - {/* { showClearFiltersButton ? */} - - {/* : null } */} + {!hideToggle && +
+
+
+ + +
-
} - {/* - - - */} + }
); }); From 872dfd1dffee90e77f5bb0c81183491e81571a09 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Wed, 7 Aug 2024 15:26:14 +0300 Subject: [PATCH 08/35] fix button hydration warning --- es/components/browse/components/FacetList/index.js | 6 ++++-- src/components/browse/components/FacetList/index.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/es/components/browse/components/FacetList/index.js b/es/components/browse/components/FacetList/index.js index 247ecde9..bf9f3cd0 100644 --- a/es/components/browse/components/FacetList/index.js +++ b/es/components/browse/components/FacetList/index.js @@ -977,7 +977,8 @@ export var FacetListHeader = /*#__PURE__*/React.memo(function (props) { }, className: "btn btn-xs btn-outline-secondary", onClick: onCollapseFacets, - "data-tip": "Collapse all facets below" + "data-tip": "Collapse all facets below", + autoComplete: "off" }, /*#__PURE__*/React.createElement("i", { className: "icon icon-fw icon-minus fas" }), " Collapse All"), /*#__PURE__*/React.createElement("button", { @@ -988,7 +989,8 @@ export var FacetListHeader = /*#__PURE__*/React.memo(function (props) { }, className: "btn btn-xs btn-outline-secondary", onClick: onClearFilters, - "data-tip": "Clear all filters" + "data-tip": "Clear all filters", + autoComplete: "off" }, /*#__PURE__*/React.createElement("i", { className: "icon icon-fw icon-times fas" }), " Clear All"))))); diff --git a/src/components/browse/components/FacetList/index.js b/src/components/browse/components/FacetList/index.js index 502cc3e6..5e75827d 100644 --- a/src/components/browse/components/FacetList/index.js +++ b/src/components/browse/components/FacetList/index.js @@ -826,10 +826,11 @@ export const FacetListHeader = React.memo(function FacetListHeader(props){
- -
From 193b383814c75959b14540b7f6e9e7559151a0bb Mon Sep 17 00:00:00 2001 From: Onurcankaratay Date: Wed, 7 Aug 2024 17:15:47 +0300 Subject: [PATCH 09/35] typo fix --- es/components/forms/SubmissionView.js | 3 +-- src/components/forms/SubmissionView.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/es/components/forms/SubmissionView.js b/es/components/forms/SubmissionView.js index c9874479..08b06983 100644 --- a/es/components/forms/SubmissionView.js +++ b/es/components/forms/SubmissionView.js @@ -189,9 +189,8 @@ var SubmissionView = /*#__PURE__*/function (_React$PureComponent) { } } if (currentAction !== pastProps.currentAction) { - var edit = ncurrentAction === 'edit'; this.setState({ - edit: edit, + edit: currentAction === 'edit', create: currentAction === 'create' || currentAction === 'add' }); } diff --git a/src/components/forms/SubmissionView.js b/src/components/forms/SubmissionView.js index b8f3a52c..781b7702 100644 --- a/src/components/forms/SubmissionView.js +++ b/src/components/forms/SubmissionView.js @@ -193,7 +193,7 @@ export default class SubmissionView extends React.PureComponent{ } } if (currentAction !== pastProps.currentAction){ - var edit = ncurrentAction === 'edit'; + var edit = currentAction === 'edit'; var create = (currentAction === 'create' || currentAction === 'add'); this.setState({ edit, create }); } From 37136e04c6487556a6e16f6d875a8ab7d1fb214c Mon Sep 17 00:00:00 2001 From: Onurcankaratay Date: Wed, 7 Aug 2024 17:41:15 +0300 Subject: [PATCH 10/35] add missing prop type value --- es/components/browse/components/FacetList/FacetTermsList.js | 2 +- src/components/browse/components/FacetList/FacetTermsList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/browse/components/FacetList/FacetTermsList.js b/es/components/browse/components/FacetList/FacetTermsList.js index a8031503..059bbc4d 100644 --- a/es/components/browse/components/FacetList/FacetTermsList.js +++ b/es/components/browse/components/FacetList/FacetTermsList.js @@ -299,7 +299,7 @@ _defineProperty(Term, "propTypes", { term: PropTypes.string }), 'onClick': PropTypes.func.isRequired, - 'status': PropTypes.oneOf(["none", "selected", "omitted"]), + 'status': PropTypes.oneOf(["none", "selected", "omitted", "partial"]), 'getTermStatus': PropTypes.func.isRequired, 'termTransformFxn': PropTypes.func, 'useRadioIcon': PropTypes.bool.isRequired, diff --git a/src/components/browse/components/FacetList/FacetTermsList.js b/src/components/browse/components/FacetList/FacetTermsList.js index fb0df443..1957126d 100644 --- a/src/components/browse/components/FacetList/FacetTermsList.js +++ b/src/components/browse/components/FacetList/FacetTermsList.js @@ -121,7 +121,7 @@ export class Term extends React.PureComponent { 'isFiltering' : PropTypes.bool, 'filteringFieldTerm': PropTypes.shape({ field: PropTypes.string, term: PropTypes.string }), 'onClick' : PropTypes.func.isRequired, - 'status' : PropTypes.oneOf(["none", "selected", "omitted"]), + 'status' : PropTypes.oneOf(["none", "selected", "omitted", "partial"]), 'getTermStatus' : PropTypes.func.isRequired, 'termTransformFxn' : PropTypes.func, 'useRadioIcon' : PropTypes.bool.isRequired, From b24c2f160227d0225cc5c269d8d5c17c4d54741c Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 8 Aug 2024 10:59:49 +0300 Subject: [PATCH 11/35] remove passProps injected to non-jsx content --- es/components/static-pages/BasicStaticSectionBody.js | 5 +++-- src/components/static-pages/BasicStaticSectionBody.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/es/components/static-pages/BasicStaticSectionBody.js b/es/components/static-pages/BasicStaticSectionBody.js index 4b9f8ea8..01b0e6c0 100644 --- a/es/components/static-pages/BasicStaticSectionBody.js +++ b/es/components/static-pages/BasicStaticSectionBody.js @@ -4,6 +4,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import _ from 'underscore'; import { htmlToJSX } from './../util/object'; +import { patchedConsoleInstance as console } from './../util/patched-console'; import { compiler } from 'markdown-to-jsx'; export var BasicStaticSectionBody = /*#__PURE__*/React.memo(function (props) { var content = props.content, @@ -16,9 +17,9 @@ export var BasicStaticSectionBody = /*#__PURE__*/React.memo(function (props) { passProps = _objectWithoutProperties(props, _excluded); //In some cases, markdown to html conversion is handled by backend by assigning the content_as_html. For the rest, use markdown-to-jsx compiler. if (filetype === 'md' && typeof content === 'string' && !content_as_html) { - return /*#__PURE__*/React.createElement(element, passProps, compiler(content, markdownCompilerOptions || undefined)); + return /*#__PURE__*/React.createElement(element, null, compiler(content, markdownCompilerOptions || undefined)); } else if ((filetype === 'html' || filetype === 'rst' || filetype === 'md') && (typeof content_as_html === 'string' || typeof content === 'string')) { - return /*#__PURE__*/React.createElement(element, passProps, htmlToJSX(content_as_html || content)); + return /*#__PURE__*/React.createElement(element, null, htmlToJSX(content_as_html || content)); } else if (filetype === 'jsx' && typeof content === 'string') { return placeholderReplacementFxn(content.trim(), passProps); } else if (filetype === 'txt' && typeof content === 'string' && content.slice(0, 12) === 'placeholder:') { diff --git a/src/components/static-pages/BasicStaticSectionBody.js b/src/components/static-pages/BasicStaticSectionBody.js index 77643c54..fa7e3290 100644 --- a/src/components/static-pages/BasicStaticSectionBody.js +++ b/src/components/static-pages/BasicStaticSectionBody.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import _ from 'underscore'; import { htmlToJSX } from './../util/object'; +import { patchedConsoleInstance as console } from './../util/patched-console'; import { compiler } from 'markdown-to-jsx'; @@ -9,9 +10,9 @@ export const BasicStaticSectionBody = React.memo(function BasicStaticSectionBody const { content, content_as_html, children, filetype, element, markdownCompilerOptions, placeholderReplacementFxn, ...passProps } = props; //In some cases, markdown to html conversion is handled by backend by assigning the content_as_html. For the rest, use markdown-to-jsx compiler. if (filetype === 'md' && typeof content === 'string' && !content_as_html){ - return React.createElement(element, passProps, compiler(content, markdownCompilerOptions || undefined) ); + return React.createElement(element, null, compiler(content, markdownCompilerOptions || undefined) ); } else if ((filetype === 'html' || filetype === 'rst' || filetype === 'md') && (typeof content_as_html === 'string' || typeof content === 'string')){ - return React.createElement(element, passProps, htmlToJSX(content_as_html || content)); + return React.createElement(element, null, htmlToJSX(content_as_html || content)); } else if (filetype === 'jsx' && typeof content === 'string'){ return placeholderReplacementFxn(content.trim(), passProps); } else if (filetype === 'txt' && typeof content === 'string' && content.slice(0,12) === 'placeholder:'){ From 8e5f4fdc17028c580ae4e5b766716fcc9503d81b Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 8 Aug 2024 12:31:06 +0300 Subject: [PATCH 12/35] suppress hydration warnings for localized time --- es/components/ui/LocalizedTime.js | 6 ++++-- src/components/ui/LocalizedTime.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/es/components/ui/LocalizedTime.js b/es/components/ui/LocalizedTime.js index 7d7f5a76..e26565a9 100644 --- a/es/components/ui/LocalizedTime.js +++ b/es/components/ui/LocalizedTime.js @@ -65,11 +65,13 @@ export var LocalizedTime = /*#__PURE__*/function (_React$Component) { var selfDateFns = this.memoized.getDateFns(dateFnsDate, timestamp); if (!mounted || isServerSide()) { return /*#__PURE__*/React.createElement("span", { - className: className + ' utc' + className: className + ' utc', + suppressHydrationWarning: true }, display(selfDateFns, formatType, dateTimeSeparator, false, customOutputFormat)); } else { return /*#__PURE__*/React.createElement("span", { - className: className + (localize ? ' local' : ' utc') + className: className + (localize ? ' local' : ' utc'), + suppressHydrationWarning: true }, display(selfDateFns, formatType, dateTimeSeparator, localize, customOutputFormat)); } } diff --git a/src/components/ui/LocalizedTime.js b/src/components/ui/LocalizedTime.js index 653203ce..ce974f5b 100644 --- a/src/components/ui/LocalizedTime.js +++ b/src/components/ui/LocalizedTime.js @@ -40,13 +40,13 @@ export class LocalizedTime extends React.Component { const selfDateFns = this.memoized.getDateFns(dateFnsDate, timestamp); if (!mounted || isServerSide()) { return ( - + { display(selfDateFns, formatType, dateTimeSeparator, false, customOutputFormat) } ); } else { return ( - + { display(selfDateFns, formatType, dateTimeSeparator, localize, customOutputFormat) } ); From 559c16d15a63c94e449e93d078873ba55bc59fae Mon Sep 17 00:00:00 2001 From: Onurcankaratay Date: Mon, 12 Aug 2024 09:23:53 +0300 Subject: [PATCH 13/35] Fix a state mutation. "A state mutation was detected between dispatches in the path." --- es/components/static-pages/TableOfContents.js | 4 +++- src/components/static-pages/TableOfContents.js | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/es/components/static-pages/TableOfContents.js b/es/components/static-pages/TableOfContents.js index c36d9eb2..518d3882 100644 --- a/es/components/static-pages/TableOfContents.js +++ b/es/components/static-pages/TableOfContents.js @@ -577,7 +577,9 @@ export var TableOfContents = /*#__PURE__*/function (_React$Component3) { identifier = section.identifier; var link = TableOfContents.elementIDFromSectionName(name || identifier); if (previousEncounteredSection) { - previousEncounteredSection.nextHeader = link; + previousEncounteredSection = _objectSpread(_objectSpread({}, previousEncounteredSection), {}, { + nextHeader: link + }); } previousEncounteredSection = section; var sectionCopy = _objectSpread(_objectSpread({}, section), {}, { diff --git a/src/components/static-pages/TableOfContents.js b/src/components/static-pages/TableOfContents.js index 7273343d..ae9f72bc 100644 --- a/src/components/static-pages/TableOfContents.js +++ b/src/components/static-pages/TableOfContents.js @@ -585,8 +585,11 @@ export class TableOfContents extends React.Component { .map(function(section, i, all){ const { name, identifier } = section; const link = TableOfContents.elementIDFromSectionName(name || identifier); - if (previousEncounteredSection){ - previousEncounteredSection.nextHeader = link; + if (previousEncounteredSection) { + previousEncounteredSection = { + ...previousEncounteredSection, + nextHeader: link + }; } previousEncounteredSection = section; const sectionCopy = { ...section, link }; From c27a22693e44f4b0db22f285085d3889d609ba78 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 12 Aug 2024 21:46:14 +0300 Subject: [PATCH 14/35] fix Infinite's prop type warning --- es/components/browse/components/SearchResultTable.js | 2 +- src/components/browse/components/SearchResultTable.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/browse/components/SearchResultTable.js b/es/components/browse/components/SearchResultTable.js index e7fea322..bf7de5cb 100644 --- a/es/components/browse/components/SearchResultTable.js +++ b/es/components/browse/components/SearchResultTable.js @@ -601,7 +601,7 @@ var LoadMoreAsYouScroll = /*#__PURE__*/function (_React$Component) { infiniteLoadBeginEdgeOffset: canLoadMore ? 200 : undefined, preloadAdditionalHeight: Infinite.containerHeightScaleFactor(1.5), preloadBatchSize: Infinite.containerHeightScaleFactor(1.5), - styles: isOwnPage ? null : this.memoized.getStyles(maxResultsBodyHeight) + styles: isOwnPage ? {} : this.memoized.getStyles(maxResultsBodyHeight) }, children); } }], [{ diff --git a/src/components/browse/components/SearchResultTable.js b/src/components/browse/components/SearchResultTable.js index ed06e4f5..760d851b 100644 --- a/src/components/browse/components/SearchResultTable.js +++ b/src/components/browse/components/SearchResultTable.js @@ -565,7 +565,7 @@ class LoadMoreAsYouScroll extends React.Component { infiniteLoadBeginEdgeOffset={canLoadMore ? 200 : undefined} preloadAdditionalHeight={Infinite.containerHeightScaleFactor(1.5)} preloadBatchSize={Infinite.containerHeightScaleFactor(1.5)} - styles={isOwnPage ? null : this.memoized.getStyles(maxResultsBodyHeight)}> + styles={isOwnPage ? {} : this.memoized.getStyles(maxResultsBodyHeight)}> { children } ); From f2be16d6b1ae12a3e158d78c56d8030bb9eea04f Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 12 Aug 2024 21:46:56 +0300 Subject: [PATCH 15/35] remove non existing prop's prop type --- es/components/browse/components/AboveSearchTablePanel.js | 1 - src/components/browse/components/AboveSearchTablePanel.js | 1 - 2 files changed, 2 deletions(-) diff --git a/es/components/browse/components/AboveSearchTablePanel.js b/es/components/browse/components/AboveSearchTablePanel.js index 006aad9a..eb606305 100644 --- a/es/components/browse/components/AboveSearchTablePanel.js +++ b/es/components/browse/components/AboveSearchTablePanel.js @@ -21,7 +21,6 @@ export var AboveSearchTablePanel = /*#__PURE__*/React.memo(function (_ref) { }))); }); AboveSearchTablePanel.propTypes = { - 'href': PropTypes.string.isRequired, 'context': PropTypes.object.isRequired, 'placeholderReplacementFxn': PropTypes.func }; diff --git a/src/components/browse/components/AboveSearchTablePanel.js b/src/components/browse/components/AboveSearchTablePanel.js index a52dc6c3..7fbf50b9 100644 --- a/src/components/browse/components/AboveSearchTablePanel.js +++ b/src/components/browse/components/AboveSearchTablePanel.js @@ -21,7 +21,6 @@ export const AboveSearchTablePanel = React.memo(function AboveSearchTablePanel({ ); }); AboveSearchTablePanel.propTypes = { - 'href' : PropTypes.string.isRequired, 'context' : PropTypes.object.isRequired, 'placeholderReplacementFxn' : PropTypes.func }; From c4b9181227959ca359878c77c9681c15e83e3799 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 12 Aug 2024 23:17:28 +0300 Subject: [PATCH 16/35] remove isRequired --- es/components/ui/FlexibleDescriptionBox.js | 2 +- src/components/ui/FlexibleDescriptionBox.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/ui/FlexibleDescriptionBox.js b/es/components/ui/FlexibleDescriptionBox.js index a5b86b6f..e14e0a2a 100644 --- a/es/components/ui/FlexibleDescriptionBox.js +++ b/es/components/ui/FlexibleDescriptionBox.js @@ -402,7 +402,7 @@ _defineProperty(FlexibleDescriptionBox, "propTypes", { 'textElement': PropTypes.oneOf(['p', 'span', 'div', 'label', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']), 'textStyle': PropTypes.object, 'expanded': PropTypes.bool, - 'windowWidth': PropTypes.number.isRequired, + 'windowWidth': PropTypes.number, 'context': PropTypes.object }); _defineProperty(FlexibleDescriptionBox, "defaultProps", { diff --git a/src/components/ui/FlexibleDescriptionBox.js b/src/components/ui/FlexibleDescriptionBox.js index d82e6a42..bed588b1 100644 --- a/src/components/ui/FlexibleDescriptionBox.js +++ b/src/components/ui/FlexibleDescriptionBox.js @@ -125,7 +125,7 @@ export class FlexibleDescriptionBox extends React.Component { 'textElement' : PropTypes.oneOf(['p', 'span', 'div', 'label', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']), 'textStyle' : PropTypes.object, 'expanded' : PropTypes.bool, - 'windowWidth' : PropTypes.number.isRequired, + 'windowWidth' : PropTypes.number, 'context' : PropTypes.object } From 795e45f7c33f35089e5ca92a1ad64adf7966184b Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 12 Aug 2024 23:19:57 +0300 Subject: [PATCH 17/35] replace defaultProps w/ js object initialization as R18 requirement for memoized components --- .../above-table-controls/RightButtonsSection.js | 12 ++++-------- .../above-table-controls/RightButtonsSection.js | 10 ++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/es/components/browse/components/above-table-controls/RightButtonsSection.js b/es/components/browse/components/above-table-controls/RightButtonsSection.js index aef62c7a..d0fe71cd 100644 --- a/es/components/browse/components/above-table-controls/RightButtonsSection.js +++ b/es/components/browse/components/above-table-controls/RightButtonsSection.js @@ -46,7 +46,8 @@ export var RightButtonsSection = /*#__PURE__*/React.memo(function (props) { export var ConfigureVisibleColumnsButton = /*#__PURE__*/React.memo(function (_ref) { var open = _ref.open, onClick = _ref.onClick, - className = _ref.className; + _ref$className = _ref.className, + className = _ref$className === void 0 ? "btn btn-outline-primary" : _ref$className; return /*#__PURE__*/React.createElement("button", { type: "button", key: "toggle-visible-columns", @@ -61,13 +62,11 @@ export var ConfigureVisibleColumnsButton = /*#__PURE__*/React.memo(function (_re className: "icon icon-fw icon-angle-down ml-03 fas" })); }); -ConfigureVisibleColumnsButton.defaultProps = { - "className": "btn btn-outline-primary" -}; export var MultiColumnSortButton = /*#__PURE__*/React.memo(function (_ref2) { var open = _ref2.open, onClick = _ref2.onClick, - className = _ref2.className; + _ref2$className = _ref2.className, + className = _ref2$className === void 0 ? "btn btn-outline-primary" : _ref2$className; return /*#__PURE__*/React.createElement("button", { type: "button", key: "toggle-visible-columns", @@ -82,9 +81,6 @@ export var MultiColumnSortButton = /*#__PURE__*/React.memo(function (_ref2) { className: "icon icon-fw icon-angle-down ml-03 fas" })); }); -MultiColumnSortButton.defaultProps = { - "className": "btn btn-outline-primary" -}; /** Toggles between regular & full screen views */ export var ToggleLayoutButton = /*#__PURE__*/function (_React$PureComponent) { diff --git a/src/components/browse/components/above-table-controls/RightButtonsSection.js b/src/components/browse/components/above-table-controls/RightButtonsSection.js index 82f6d6fe..884df77f 100644 --- a/src/components/browse/components/above-table-controls/RightButtonsSection.js +++ b/src/components/browse/components/above-table-controls/RightButtonsSection.js @@ -19,7 +19,7 @@ export const RightButtonsSection = React.memo(function RightButtonsSection(props -export const ConfigureVisibleColumnsButton = React.memo(function ConfigureVisibleColumnsButton({ open, onClick, className }){ +export const ConfigureVisibleColumnsButton = React.memo(function ConfigureVisibleColumnsButton({ open, onClick, className = "btn btn-outline-primary" }){ return ( ); }); -ConfigureVisibleColumnsButton.defaultProps = { - "className" : "btn btn-outline-primary" -}; -export const MultiColumnSortButton = React.memo(function MultiColumnSortButton({ open, onClick, className }){ +export const MultiColumnSortButton = React.memo(function MultiColumnSortButton({ open, onClick, className = "btn btn-outline-primary" }){ return ( ); }); -MultiColumnSortButton.defaultProps = { - "className" : "btn btn-outline-primary" -}; /** Toggles between regular & full screen views */ export class ToggleLayoutButton extends React.PureComponent { From e2ae81daccbdbb83e27f6c437dfbbab7b2d2a379 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 12 Aug 2024 23:47:50 +0300 Subject: [PATCH 18/35] fix detailOpen prop type --- es/components/browse/components/SearchResultTable.js | 2 +- src/components/browse/components/SearchResultTable.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/browse/components/SearchResultTable.js b/es/components/browse/components/SearchResultTable.js index bf7de5cb..e5dae139 100644 --- a/es/components/browse/components/SearchResultTable.js +++ b/es/components/browse/components/SearchResultTable.js @@ -430,7 +430,7 @@ _defineProperty(ResultRow, "propTypes", { 'columnWidths': PropTypes.objectOf(PropTypes.number), 'renderDetailPane': PropTypes.func.isRequired, 'detailPane': PropTypes.element, - 'detailOpen': PropTypes.bool.isRequired, + 'detailOpen': PropTypes.oneOfType([PropTypes.number, PropTypes.bool]).isRequired, 'defaultColAlignment': PropTypes.string, 'setDetailHeight': PropTypes.func.isRequired, 'id': PropTypes.string.isRequired, diff --git a/src/components/browse/components/SearchResultTable.js b/src/components/browse/components/SearchResultTable.js index 760d851b..992346a6 100644 --- a/src/components/browse/components/SearchResultTable.js +++ b/src/components/browse/components/SearchResultTable.js @@ -212,7 +212,7 @@ class ResultRow extends React.PureComponent { 'columnWidths' : PropTypes.objectOf(PropTypes.number), 'renderDetailPane' : PropTypes.func.isRequired, 'detailPane' : PropTypes.element, - 'detailOpen' : PropTypes.bool.isRequired, + 'detailOpen': PropTypes.oneOfType([PropTypes.number, PropTypes.bool]).isRequired, 'defaultColAlignment': PropTypes.string, 'setDetailHeight' : PropTypes.func.isRequired, 'id' : PropTypes.string.isRequired, From d9eef4874e9e7afc250dd46b9eb6b72cda19fd45 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Tue, 13 Aug 2024 00:59:18 +0300 Subject: [PATCH 19/35] replace defaultProps /w js object defaults --- es/components/static-pages/StaticPageBase.js | 75 ++++++++----------- es/components/static-pages/TableOfContents.js | 10 +-- src/components/static-pages/StaticPageBase.js | 69 +++++++---------- .../static-pages/TableOfContents.js | 6 +- 4 files changed, 65 insertions(+), 95 deletions(-) diff --git a/es/components/static-pages/StaticPageBase.js b/es/components/static-pages/StaticPageBase.js index 6f0c09df..8b238cdd 100644 --- a/es/components/static-pages/StaticPageBase.js +++ b/es/components/static-pages/StaticPageBase.js @@ -77,10 +77,13 @@ export function correctRelativeLinks(elem, context) { } var Wrapper = /*#__PURE__*/React.memo(function (props) { var children = props.children, - tableOfContents = props.tableOfContents, + _props$tableOfContent = props.tableOfContents, + tableOfContents = _props$tableOfContent === void 0 ? false : _props$tableOfContent, title = props.title, context = props.context, - windowWidth = props.windowWidth; + windowWidth = props.windowWidth, + _props$tocListStyles = props.tocListStyles, + tocListStyles = _props$tocListStyles === void 0 ? ['decimal', 'lower-alpha', 'lower-roman'] : _props$tocListStyles; var toc = context && context['table-of-contents'] || (tableOfContents && _typeof(tableOfContents) === 'object' ? tableOfContents : null); var pageTitle = title || context && context.title || null; var tocExists = toc && toc.enabled !== false; @@ -110,11 +113,6 @@ var Wrapper = /*#__PURE__*/React.memo(function (props) { windowInnerWidth: windowWidth })) : null)); }); -Wrapper.defaultProps = { - //'contentColSize' : 12, - 'tableOfContents': false, - 'tocListStyles': ['decimal', 'lower-alpha', 'lower-roman'] -}; export var StaticEntry = /*#__PURE__*/function (_React$PureComponent) { function StaticEntry(props) { var _this2; @@ -226,8 +224,32 @@ export var StaticPageBase = /*#__PURE__*/function (_React$PureComponent2) { key: "render", value: function render() { var _this$props2 = this.props, - context = _this$props2.context, - entryRenderFxn = _this$props2.entryRenderFxn, + _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, contentParseFxn = _this$props2.contentParseFxn, CustomWrapper = _this$props2.CustomWrapper; var parsedContent = null; @@ -276,46 +298,13 @@ 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, "content": PropTypes.any.isRequired, "table-of-contents": PropTypes.object }).isRequired, - 'entryRenderFxn': PropTypes.func.isRequired, + 'entryRenderFxn': PropTypes.func, 'contentParseFxn': PropTypes.func.isRequired, 'href': PropTypes.string, 'CustomWrapper': PropTypes.element diff --git a/es/components/static-pages/TableOfContents.js b/es/components/static-pages/TableOfContents.js index 518d3882..a72f7579 100644 --- a/es/components/static-pages/TableOfContents.js +++ b/es/components/static-pages/TableOfContents.js @@ -823,8 +823,10 @@ _defineProperty(TableOfContents, "defaultProps", { export var NextPreviousPageSection = /*#__PURE__*/React.memo(function (props) { var context = props.context, className = props.className, - previousTitle = props.previousTitle, - nextTitle = props.nextTitle; + _props$previousTitle = props.previousTitle, + previousTitle = _props$previousTitle === void 0 ? 'Previous' : _props$previousTitle, + _props$nextTitle = props.nextTitle, + nextTitle = _props$nextTitle === void 0 ? 'Next' : _props$nextTitle; var next = context.next, previous = context.previous; if (!next && !previous) return null; @@ -855,10 +857,6 @@ export var NextPreviousPageSection = /*#__PURE__*/React.memo(function (props) { href: next['@id'] || '/' + (next.name || previous.identifier) }, next.display_title))) : null)); }); -NextPreviousPageSection.defaultProps = { - 'previousTitle': 'Previous', - 'nextTitle': 'Next' -}; /** * @todo need to rename it as StaticContentHeading (here and in 4DN-CGAP-SMaHT) since we started to use it for not only MD but all types of content diff --git a/src/components/static-pages/StaticPageBase.js b/src/components/static-pages/StaticPageBase.js index c6a535ef..b24d4f84 100644 --- a/src/components/static-pages/StaticPageBase.js +++ b/src/components/static-pages/StaticPageBase.js @@ -69,7 +69,7 @@ export function correctRelativeLinks(elem, context, depth=0){ const Wrapper = React.memo(function Wrapper(props){ - const { children, tableOfContents, title, context, windowWidth } = props; + const { children, tableOfContents = false, title, context, windowWidth, tocListStyles = ['decimal', 'lower-alpha', 'lower-roman'] } = props; const toc = (context && context['table-of-contents']) || (tableOfContents && typeof tableOfContents === 'object' ? tableOfContents : null); const pageTitle = title || (context && context.title) || null; const tocExists = toc && toc.enabled !== false; @@ -96,11 +96,6 @@ const Wrapper = React.memo(function Wrapper(props){
); }); -Wrapper.defaultProps = { - //'contentColSize' : 12, - 'tableOfContents' : false, - 'tocListStyles' : ['decimal', 'lower-alpha', 'lower-roman'] -}; export class StaticEntry extends React.PureComponent { @@ -208,38 +203,6 @@ 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({ @@ -247,14 +210,38 @@ export class StaticPageBase extends React.PureComponent { "content" : PropTypes.any.isRequired, "table-of-contents" : PropTypes.object }).isRequired, - 'entryRenderFxn' : PropTypes.func.isRequired, + 'entryRenderFxn' : PropTypes.func, 'contentParseFxn' : PropTypes.func.isRequired, 'href' : PropTypes.string, 'CustomWrapper': PropTypes.element }; - render(){ - const { context, entryRenderFxn, contentParseFxn, CustomWrapper } = this.props; + 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; + let parsedContent = null; try { parsedContent = contentParseFxn(context); diff --git a/src/components/static-pages/TableOfContents.js b/src/components/static-pages/TableOfContents.js index ae9f72bc..114b3b87 100644 --- a/src/components/static-pages/TableOfContents.js +++ b/src/components/static-pages/TableOfContents.js @@ -681,7 +681,7 @@ export class TableOfContents extends React.Component { export const NextPreviousPageSection = React.memo(function NextPreviousPageSection(props){ - const { context, className, previousTitle, nextTitle } = props; + const { context, className, previousTitle = 'Previous', nextTitle = 'Next' } = props; const { next, previous } = context; if (!next && !previous) return null; const colSize = previous && next ? 6 : 12; @@ -704,10 +704,6 @@ export const NextPreviousPageSection = React.memo(function NextPreviousPageSecti
); }); -NextPreviousPageSection.defaultProps = { - 'previousTitle' : 'Previous', - 'nextTitle' : 'Next' -}; /** From 46be2be6866f1eb2806f02c77609b164e05d1931 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 09:50:26 +0300 Subject: [PATCH 20/35] remove isRequired --- es/components/browse/components/FacetList/index.js | 2 +- src/components/browse/components/FacetList/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/browse/components/FacetList/index.js b/es/components/browse/components/FacetList/index.js index bf9f3cd0..5687648f 100644 --- a/es/components/browse/components/FacetList/index.js +++ b/es/components/browse/components/FacetList/index.js @@ -839,7 +839,7 @@ _defineProperty(FacetList, "propTypes", { 'context': PropTypes.shape({ 'filters': PropTypes.arrayOf(PropTypes.object).isRequired // context.filters }).isRequired, - 'itemTypeForSchemas': PropTypes.string.isRequired, + 'itemTypeForSchemas': PropTypes.string, // For tooltips 'showClearFiltersButton': PropTypes.bool.isRequired, 'onClearFilters': PropTypes.func.isRequired, diff --git a/src/components/browse/components/FacetList/index.js b/src/components/browse/components/FacetList/index.js index 5e75827d..8f4e9ff6 100644 --- a/src/components/browse/components/FacetList/index.js +++ b/src/components/browse/components/FacetList/index.js @@ -124,7 +124,7 @@ export class FacetList extends React.PureComponent { 'context' : PropTypes.shape({ 'filters' : PropTypes.arrayOf(PropTypes.object).isRequired, // context.filters }).isRequired, - 'itemTypeForSchemas' : PropTypes.string.isRequired, // For tooltips + 'itemTypeForSchemas' : PropTypes.string, // For tooltips 'showClearFiltersButton' : PropTypes.bool.isRequired, 'onClearFilters' : PropTypes.func.isRequired, /** From b0f9362c27cd9da1fc164fc83e27cc72f2af1263 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 09:51:13 +0300 Subject: [PATCH 21/35] replace defaultProps /w js default parameters (React 18 requirement) --- es/components/ui/FileDownloadButton.js | 8 +++----- src/components/ui/FileDownloadButton.js | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/es/components/ui/FileDownloadButton.js b/es/components/ui/FileDownloadButton.js index 2e81420e..c374bf3b 100644 --- a/es/components/ui/FileDownloadButton.js +++ b/es/components/ui/FileDownloadButton.js @@ -63,11 +63,12 @@ var canDownloadFile = memoize(function (file, validStatuses) { }); export var FileDownloadButtonAuto = /*#__PURE__*/React.memo(function (props) { var file = props.result, - canDownloadStatuses = props.canDownloadStatuses, _props$onClick = props.onClick, onClick = _props$onClick === void 0 ? null : _props$onClick, _props$disabled = props.disabled, - propDisabled = _props$disabled === void 0 ? false : _props$disabled; + propDisabled = _props$disabled === void 0 ? false : _props$disabled, + _props$canDownloadSta = props.canDownloadStatuses, + canDownloadStatuses = _props$canDownloadSta === void 0 ? ['uploaded', 'released', 'replaced', 'submission in progress', 'released to project', 'archived'] : _props$canDownloadSta; var href = file.href, filename = file.filename; var isDownloadable = canDownloadFile(file, canDownloadStatuses); @@ -90,9 +91,6 @@ FileDownloadButtonAuto.propTypes = { 'disabled': PropTypes.bool, 'tooltip': PropTypes.string }; -FileDownloadButtonAuto.defaultProps = { - 'canDownloadStatuses': ['uploaded', 'released', 'replaced', 'submission in progress', 'released to project', 'archived'] -}; export var ViewFileButton = /*#__PURE__*/React.memo(function (props) { var filename = props.filename, href = props.href, diff --git a/src/components/ui/FileDownloadButton.js b/src/components/ui/FileDownloadButton.js index 02b6a31c..6c8b1f31 100644 --- a/src/components/ui/FileDownloadButton.js +++ b/src/components/ui/FileDownloadButton.js @@ -50,7 +50,17 @@ const canDownloadFile = memoize(function(file, validStatuses){ }); export const FileDownloadButtonAuto = React.memo(function FileDownloadButtonAuto(props){ - const { result: file, canDownloadStatuses, onClick = null, disabled: propDisabled = false } = props; + const { + result: file, onClick = null, disabled: propDisabled = false, + canDownloadStatuses = [ + 'uploaded', + 'released', + 'replaced', + 'submission in progress', + 'released to project', + 'archived' + ] + } = props; const { href, filename } = file; const isDownloadable = canDownloadFile(file, canDownloadStatuses); const passProps = { @@ -70,16 +80,6 @@ FileDownloadButtonAuto.propTypes = { 'disabled': PropTypes.bool, 'tooltip': PropTypes.string, }; -FileDownloadButtonAuto.defaultProps = { - 'canDownloadStatuses' : [ - 'uploaded', - 'released', - 'replaced', - 'submission in progress', - 'released to project', - 'archived' - ] -}; export const ViewFileButton = React.memo(function ViewFileButton(props){ From a3d1a64b16b3cd06f3b0f3a38e5c1d22648d4ca1 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 11:21:15 +0300 Subject: [PATCH 22/35] omit invalid `ref` from pass props into CheckBox --- es/components/forms/components/submission-fields.js | 2 +- src/components/forms/components/submission-fields.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/forms/components/submission-fields.js b/es/components/forms/components/submission-fields.js index a991c2c0..f68b038b 100644 --- a/es/components/forms/components/submission-fields.js +++ b/es/components/forms/components/submission-fields.js @@ -168,7 +168,7 @@ export var BuildField = /*#__PURE__*/function (_React$PureComponent) { type: "number" }, inputProps)); case 'boolean': - return /*#__PURE__*/React.createElement(Checkbox, _extends({}, _.omit(inputProps, 'value', 'placeholder'), { + return /*#__PURE__*/React.createElement(Checkbox, _extends({}, _.omit(inputProps, 'value', 'placeholder', 'ref'), { checked: !!value }), /*#__PURE__*/React.createElement("span", { style: { diff --git a/src/components/forms/components/submission-fields.js b/src/components/forms/components/submission-fields.js index 470faa28..7491bb19 100644 --- a/src/components/forms/components/submission-fields.js +++ b/src/components/forms/components/submission-fields.js @@ -137,7 +137,7 @@ export class BuildField extends React.PureComponent { case 'integer' : return ; case 'number' : return ; case 'boolean' : return ( - + { typeof value === 'boolean' ? value + '' : null } From 9a108584d1f8ab21c6cd4870e845dcf0b800bdb1 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 11:21:35 +0300 Subject: [PATCH 23/35] fix prop type --- es/components/forms/components/SearchAsYouTypeLocal.js | 2 +- src/components/forms/components/SearchAsYouTypeLocal.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/es/components/forms/components/SearchAsYouTypeLocal.js b/es/components/forms/components/SearchAsYouTypeLocal.js index e94b3d33..3f0b2ec2 100644 --- a/es/components/forms/components/SearchAsYouTypeLocal.js +++ b/es/components/forms/components/SearchAsYouTypeLocal.js @@ -131,7 +131,7 @@ export var SearchAsYouTypeLocal = /*#__PURE__*/function (_React$PureComponent) { }]); }(React.PureComponent); SearchAsYouTypeLocal.propTypes = { - searchList: PropTypes.arrayOf(PropTypes.string).isRequired, + searchList: PropTypes.arrayOf(PropTypes.oneOf(PropTypes.string, PropTypes.number)).isRequired, value: PropTypes.string, onChange: PropTypes.func.isRequired, filterMethod: PropTypes.string, diff --git a/src/components/forms/components/SearchAsYouTypeLocal.js b/src/components/forms/components/SearchAsYouTypeLocal.js index 5ede40a6..41409223 100644 --- a/src/components/forms/components/SearchAsYouTypeLocal.js +++ b/src/components/forms/components/SearchAsYouTypeLocal.js @@ -78,11 +78,11 @@ export class SearchAsYouTypeLocal extends React.PureComponent { ); } else { if (customFilterFunction) { - filteredOptions = customFilterFunction(currentTextValue, searchList, filterMethod) + filteredOptions = customFilterFunction(currentTextValue, searchList, filterMethod); } else { filteredOptions = this.memoized.filterOptions(currentTextValue, searchList, filterMethod); } - + if (filteredOptions.length === 0) { optionsHeader = ( @@ -104,7 +104,7 @@ export class SearchAsYouTypeLocal extends React.PureComponent { } } SearchAsYouTypeLocal.propTypes = { - searchList : PropTypes.arrayOf(PropTypes.string).isRequired, + searchList : PropTypes.arrayOf(PropTypes.oneOf(PropTypes.string, PropTypes.number)).isRequired, value : PropTypes.string, onChange : PropTypes.func.isRequired, filterMethod : PropTypes.string, // "startsWith", "includes" (can add more in future if necessary) -- defaults to startsWith From 9b5e311310a11c157c96fb91d314e8172553508f Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 11:26:16 +0300 Subject: [PATCH 24/35] replace defaultProps with js default parameters (React v18 requirement) --- es/components/ui/FileDownloadButton.js | 57 +++++++++++-------------- src/components/ui/FileDownloadButton.js | 43 ++++++++++--------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/es/components/ui/FileDownloadButton.js b/es/components/ui/FileDownloadButton.js index c374bf3b..e4d35c89 100644 --- a/es/components/ui/FileDownloadButton.js +++ b/es/components/ui/FileDownloadButton.js @@ -19,11 +19,15 @@ import { event as trackEvent } from './../util/analytics'; /** @todo (?) Move to ui folder */ export function FileDownloadButton(props) { var href = props.href, - className = props.className, - disabled = props.disabled, - title = props.title, + _props$className = props.className, + className = _props$className === void 0 ? "btn-block btn-primary" : _props$className, + _props$disabled = props.disabled, + disabled = _props$disabled === void 0 ? false : _props$disabled, + _props$title = props.title, + title = _props$title === void 0 ? "Download" : _props$title, filename = props.filename, - size = props.size, + _props$size = props.size, + size = _props$size === void 0 ? null : _props$size, tooltip = props.tooltip, onClick = props.onClick; var cls = "btn download-button" + (disabled ? ' disabled' : '') + (size ? ' btn-' + size : '') + (className ? " " + className : ''); @@ -41,12 +45,6 @@ export function FileDownloadButton(props) { className: "w-100" }, button) : button; } -FileDownloadButton.defaultProps = { - 'className': "btn-block btn-primary", - 'title': 'Download', - 'disabled': false, - 'size': null -}; var canDownloadFile = memoize(function (file, validStatuses) { if (!file || _typeof(file) !== 'object') { console.error("Incorrect data type"); @@ -65,8 +63,8 @@ export var FileDownloadButtonAuto = /*#__PURE__*/React.memo(function (props) { var file = props.result, _props$onClick = props.onClick, onClick = _props$onClick === void 0 ? null : _props$onClick, - _props$disabled = props.disabled, - propDisabled = _props$disabled === void 0 ? false : _props$disabled, + _props$disabled2 = props.disabled, + propDisabled = _props$disabled2 === void 0 ? false : _props$disabled2, _props$canDownloadSta = props.canDownloadStatuses, canDownloadStatuses = _props$canDownloadSta === void 0 ? ['uploaded', 'released', 'replaced', 'submission in progress', 'released to project', 'archived'] : _props$canDownloadSta; var href = file.href, @@ -77,7 +75,7 @@ export var FileDownloadButtonAuto = /*#__PURE__*/React.memo(function (props) { href: href, filename: filename, 'disabled': !!propDisabled || !isDownloadable, - 'title': !isDownloadable ? 'Not ready to download' : FileDownloadButton.defaultProps.title + 'title': !isDownloadable ? 'Not ready to download' : "Download" }; return /*#__PURE__*/React.createElement(FileDownloadButton, _extends({}, _.omit(props, 'disabled'), passProps)); }); @@ -93,14 +91,21 @@ FileDownloadButtonAuto.propTypes = { }; export var ViewFileButton = /*#__PURE__*/React.memo(function (props) { var filename = props.filename, - href = props.href, - target = props.target, - title = props.title, - mimeType = props.mimeType, - size = props.size, - className = props.className, + _props$href = props.href, + href = _props$href === void 0 ? null : _props$href, + _props$target = props.target, + target = _props$target === void 0 ? "_blank" : _props$target, + _props$title2 = props.title, + title = _props$title2 === void 0 ? null : _props$title2, + _props$mimeType = props.mimeType, + mimeType = _props$mimeType === void 0 ? null : _props$mimeType, + _props$size2 = props.size, + size = _props$size2 === void 0 ? null : _props$size2, + _props$className2 = props.className, + className = _props$className2 === void 0 ? "text-truncate mb-1" : _props$className2, bsStyle = props.bsStyle, - variant = props.variant, + _props$variant = props.variant, + variant = _props$variant === void 0 ? "primary" : _props$variant, propClick = props.onClick, passProps = _objectWithoutProperties(props, _excluded); var action = 'View'; @@ -157,14 +162,4 @@ export var ViewFileButton = /*#__PURE__*/React.memo(function (props) { }), preLink, " ", action, " ", title || filename && /*#__PURE__*/React.createElement("span", { className: "text-600" }, filename) || 'File', " ", extLink); -}); -ViewFileButton.defaultProps = { - 'className': "text-truncate mb-1", - 'target': "_blank", - 'href': null, - 'disabled': false, - 'title': null, - 'mimeType': null, - 'size': null, - 'variant': 'primary' -}; \ No newline at end of file +}); \ No newline at end of file diff --git a/src/components/ui/FileDownloadButton.js b/src/components/ui/FileDownloadButton.js index 6c8b1f31..236ea897 100644 --- a/src/components/ui/FileDownloadButton.js +++ b/src/components/ui/FileDownloadButton.js @@ -11,7 +11,16 @@ import { event as trackEvent } from './../util/analytics'; /** @todo (?) Move to ui folder */ export function FileDownloadButton(props){ - const { href, className, disabled, title, filename, size, tooltip, onClick } = props; + const { + href, + className = "btn-block btn-primary", + disabled = false, + title = "Download", + filename, + size = null, + tooltip, + onClick + } = props; const cls = "btn download-button" + (disabled ? ' disabled' : '') + (size ? ' btn-' + size : '') + (className ? " " + className : ''); const button = ( @@ -26,12 +35,6 @@ export function FileDownloadButton(props){ ) : button; } -FileDownloadButton.defaultProps = { - 'className' : "btn-block btn-primary", - 'title' : 'Download', - 'disabled' : false, - 'size' : null -}; const canDownloadFile = memoize(function(file, validStatuses){ @@ -66,7 +69,7 @@ export const FileDownloadButtonAuto = React.memo(function FileDownloadButtonAuto const passProps = { onClick, href, filename, 'disabled': !!propDisabled || !isDownloadable, - 'title': !isDownloadable ? 'Not ready to download' : FileDownloadButton.defaultProps.title + 'title': !isDownloadable ? 'Not ready to download' : "Download" }; return ; }); @@ -83,7 +86,19 @@ FileDownloadButtonAuto.propTypes = { export const ViewFileButton = React.memo(function ViewFileButton(props){ - const { filename, href, target, title, mimeType, size, className, bsStyle, variant, onClick: propClick, ...passProps } = props; + const { + filename, + href = null, + target = "_blank", + title = null, + mimeType = null, + size = null, + className = "text-truncate mb-1", + bsStyle, + variant = "primary", + onClick: propClick, + ...passProps + } = props; let action = 'View'; let extLink = null; // Unsure if really used. Maybe should test href for presence of http[s]:// instd of target="_blank"? let preLink = null; @@ -128,14 +143,4 @@ export const ViewFileButton = React.memo(function ViewFileButton(props){ ); }); -ViewFileButton.defaultProps = { - 'className' : "text-truncate mb-1", - 'target' : "_blank", - 'href' : null, - 'disabled' : false, - 'title' : null, - 'mimeType' : null, - 'size' : null, - 'variant' : 'primary' -}; From 8fac0b9f0617afed83d223197167486359c7b851 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 11:34:11 +0300 Subject: [PATCH 25/35] add missing brackets --- es/components/forms/components/SearchAsYouTypeLocal.js | 2 +- src/components/forms/components/SearchAsYouTypeLocal.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/forms/components/SearchAsYouTypeLocal.js b/es/components/forms/components/SearchAsYouTypeLocal.js index 3f0b2ec2..00a5be5c 100644 --- a/es/components/forms/components/SearchAsYouTypeLocal.js +++ b/es/components/forms/components/SearchAsYouTypeLocal.js @@ -131,7 +131,7 @@ export var SearchAsYouTypeLocal = /*#__PURE__*/function (_React$PureComponent) { }]); }(React.PureComponent); SearchAsYouTypeLocal.propTypes = { - searchList: PropTypes.arrayOf(PropTypes.oneOf(PropTypes.string, PropTypes.number)).isRequired, + searchList: PropTypes.arrayOf(PropTypes.oneOf([PropTypes.string, PropTypes.number])).isRequired, value: PropTypes.string, onChange: PropTypes.func.isRequired, filterMethod: PropTypes.string, diff --git a/src/components/forms/components/SearchAsYouTypeLocal.js b/src/components/forms/components/SearchAsYouTypeLocal.js index 41409223..20cbf2d8 100644 --- a/src/components/forms/components/SearchAsYouTypeLocal.js +++ b/src/components/forms/components/SearchAsYouTypeLocal.js @@ -104,7 +104,7 @@ export class SearchAsYouTypeLocal extends React.PureComponent { } } SearchAsYouTypeLocal.propTypes = { - searchList : PropTypes.arrayOf(PropTypes.oneOf(PropTypes.string, PropTypes.number)).isRequired, + searchList : PropTypes.arrayOf(PropTypes.oneOf([PropTypes.string, PropTypes.number])).isRequired, value : PropTypes.string, onChange : PropTypes.func.isRequired, filterMethod : PropTypes.string, // "startsWith", "includes" (can add more in future if necessary) -- defaults to startsWith From 74dc1db589a64bdb1e30ad93016d1b24fddfa125 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 11:56:13 +0300 Subject: [PATCH 26/35] replace defaultProps with js default parameters (React v18 requirement) --- es/components/forms/components/Toggle.js | 36 +++++++++++++---------- src/components/forms/components/Toggle.js | 25 +++++++++------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/es/components/forms/components/Toggle.js b/es/components/forms/components/Toggle.js index 633a10a8..ecf1b1c5 100644 --- a/es/components/forms/components/Toggle.js +++ b/es/components/forms/components/Toggle.js @@ -1,6 +1,6 @@ import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; -var _excluded = ["className", "id", "disabled"]; +var _excluded = ["className", "id", "disabled", "name", "onChange", "checked"]; import React from 'react'; import _ from 'underscore'; import { randomId } from './../../util/object'; @@ -15,20 +15,33 @@ import { patchedConsoleInstance as console } from './../../util/patched-console' * @prop {boolean} checked - Whether is checked or not. */ export var Toggle = /*#__PURE__*/React.memo(function (_ref) { - var className = _ref.className, - id = _ref.id, - disabled = _ref.disabled, + var _ref$className = _ref.className, + className = _ref$className === void 0 ? "" : _ref$className, + _ref$id = _ref.id, + id = _ref$id === void 0 ? null : _ref$id, + _ref$disabled = _ref.disabled, + disabled = _ref$disabled === void 0 ? false : _ref$disabled, + _ref$name = _ref.name, + name = _ref$name === void 0 ? "onoffswitch" : _ref$name, + _ref$onChange = _ref.onChange, + onChange = _ref$onChange === void 0 ? function (e) { + console.log("Toggled ", e.target); + } : _ref$onChange, + _ref$checked = _ref.checked, + checked = _ref$checked === void 0 ? false : _ref$checked, remainingProps = _objectWithoutProperties(_ref, _excluded); var useID = id || randomId(); return /*#__PURE__*/React.createElement("div", { className: "onoffswitch " + className + (disabled ? ' disabled' : '') }, /*#__PURE__*/React.createElement("input", _extends({ type: "checkbox", - id: useID - }, remainingProps, { + id: useID, + name: name, + onChange: onChange, + checked: checked, className: "onoffswitch-checkbox", disabled: disabled - })), /*#__PURE__*/React.createElement("label", { + }, remainingProps)), /*#__PURE__*/React.createElement("label", { className: "onoffswitch-label", htmlFor: id }, /*#__PURE__*/React.createElement("span", { @@ -37,15 +50,6 @@ export var Toggle = /*#__PURE__*/React.memo(function (_ref) { className: "onoffswitch-switch" }))); }); -Toggle.defaultProps = { - 'name': 'onoffswitch', - 'onChange': function onChange() { - console.log("Toggled ", this); - }, - 'id': null, - 'checked': false, - 'className': '' -}; /** Pulled out into own component so can style/adjust-if-needed together w. Case Review Tab */ export var IconToggle = function (props) { diff --git a/src/components/forms/components/Toggle.js b/src/components/forms/components/Toggle.js index 09b3ee6b..f1669b1d 100644 --- a/src/components/forms/components/Toggle.js +++ b/src/components/forms/components/Toggle.js @@ -11,11 +11,23 @@ import { patchedConsoleInstance as console } from './../../util/patched-console' * @prop {function} onChange - Change event handler. * @prop {boolean} checked - Whether is checked or not. */ -export const Toggle = React.memo(function Toggle({ className, id, disabled, ...remainingProps }){ +export const Toggle = React.memo(function Toggle({ + className = "", + id = null, + disabled = false, + name = "onoffswitch", + onChange = (e) => { console.log("Toggled ", e.target); }, + checked = false, + ...remainingProps +}) { const useID = id || randomId(); return (
- +
); }); -Toggle.defaultProps = { - 'name' : 'onoffswitch', - 'onChange' : function(e){ - console.log("Toggled ", this); - }, - 'id' : null, - 'checked' : false, - 'className' : '' -}; /** Pulled out into own component so can style/adjust-if-needed together w. Case Review Tab */ From 68b33d64d230a301d7994164157236cbf14fc36d Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 13:37:10 +0300 Subject: [PATCH 27/35] bug fix --- es/components/forms/components/SearchAsYouTypeLocal.js | 2 +- es/components/ui/FileDownloadButton.js | 2 +- src/components/forms/components/SearchAsYouTypeLocal.js | 2 +- src/components/ui/FileDownloadButton.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/es/components/forms/components/SearchAsYouTypeLocal.js b/es/components/forms/components/SearchAsYouTypeLocal.js index 00a5be5c..afd133b3 100644 --- a/es/components/forms/components/SearchAsYouTypeLocal.js +++ b/es/components/forms/components/SearchAsYouTypeLocal.js @@ -131,7 +131,7 @@ export var SearchAsYouTypeLocal = /*#__PURE__*/function (_React$PureComponent) { }]); }(React.PureComponent); SearchAsYouTypeLocal.propTypes = { - searchList: PropTypes.arrayOf(PropTypes.oneOf([PropTypes.string, PropTypes.number])).isRequired, + searchList: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).isRequired, value: PropTypes.string, onChange: PropTypes.func.isRequired, filterMethod: PropTypes.string, diff --git a/es/components/ui/FileDownloadButton.js b/es/components/ui/FileDownloadButton.js index e4d35c89..9ab24b83 100644 --- a/es/components/ui/FileDownloadButton.js +++ b/es/components/ui/FileDownloadButton.js @@ -82,7 +82,7 @@ export var FileDownloadButtonAuto = /*#__PURE__*/React.memo(function (props) { FileDownloadButtonAuto.propTypes = { 'result': PropTypes.shape({ 'href': PropTypes.string.isRequired, - 'filename': PropTypes.string.isRequired + 'filename': PropTypes.string }).isRequired, 'canDownloadStatuses': PropTypes.arrayOf(PropTypes.string), 'onClick': PropTypes.func, diff --git a/src/components/forms/components/SearchAsYouTypeLocal.js b/src/components/forms/components/SearchAsYouTypeLocal.js index 20cbf2d8..478ee6e2 100644 --- a/src/components/forms/components/SearchAsYouTypeLocal.js +++ b/src/components/forms/components/SearchAsYouTypeLocal.js @@ -104,7 +104,7 @@ export class SearchAsYouTypeLocal extends React.PureComponent { } } SearchAsYouTypeLocal.propTypes = { - searchList : PropTypes.arrayOf(PropTypes.oneOf([PropTypes.string, PropTypes.number])).isRequired, + searchList : PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).isRequired, value : PropTypes.string, onChange : PropTypes.func.isRequired, filterMethod : PropTypes.string, // "startsWith", "includes" (can add more in future if necessary) -- defaults to startsWith diff --git a/src/components/ui/FileDownloadButton.js b/src/components/ui/FileDownloadButton.js index 236ea897..4f944bf5 100644 --- a/src/components/ui/FileDownloadButton.js +++ b/src/components/ui/FileDownloadButton.js @@ -76,7 +76,7 @@ export const FileDownloadButtonAuto = React.memo(function FileDownloadButtonAuto FileDownloadButtonAuto.propTypes = { 'result' : PropTypes.shape({ 'href' : PropTypes.string.isRequired, - 'filename' : PropTypes.string.isRequired, + 'filename' : PropTypes.string, }).isRequired, 'canDownloadStatuses' : PropTypes.arrayOf(PropTypes.string), 'onClick' : PropTypes.func, From dcb19b2953069bfbf979d4ba5d1e00e092137eca Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 15 Aug 2024 13:47:59 +0300 Subject: [PATCH 28/35] 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 { From faa64b9464818c7e91f7402de85d25669419d487 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Mon, 19 Aug 2024 15:52:51 +0300 Subject: [PATCH 29/35] replace defaultProps with default js parameters (React 18 requirement) --- .../static-pages/BasicStaticSectionBody.js | 19 ++++++++---------- es/components/ui/PartialList.js | 18 ++++++++--------- .../static-pages/BasicStaticSectionBody.js | 20 ++++++++++--------- src/components/ui/PartialList.js | 8 +------- 4 files changed, 28 insertions(+), 37 deletions(-) diff --git a/es/components/static-pages/BasicStaticSectionBody.js b/es/components/static-pages/BasicStaticSectionBody.js index 01b0e6c0..66e7b4be 100644 --- a/es/components/static-pages/BasicStaticSectionBody.js +++ b/es/components/static-pages/BasicStaticSectionBody.js @@ -10,10 +10,15 @@ export var BasicStaticSectionBody = /*#__PURE__*/React.memo(function (props) { var content = props.content, content_as_html = props.content_as_html, children = props.children, - filetype = props.filetype, - element = props.element, + _props$filetype = props.filetype, + filetype = _props$filetype === void 0 ? "md" : _props$filetype, + _props$element = props.element, + element = _props$element === void 0 ? "div" : _props$element, markdownCompilerOptions = props.markdownCompilerOptions, - placeholderReplacementFxn = props.placeholderReplacementFxn, + _props$placeholderRep = props.placeholderReplacementFxn, + placeholderReplacementFxn = _props$placeholderRep === void 0 ? function (placeholderString) { + return placeholderString; + } : _props$placeholderRep, passProps = _objectWithoutProperties(props, _excluded); //In some cases, markdown to html conversion is handled by backend by assigning the content_as_html. For the rest, use markdown-to-jsx compiler. if (filetype === 'md' && typeof content === 'string' && !content_as_html) { @@ -36,12 +41,4 @@ BasicStaticSectionBody.propTypes = { "element": PropTypes.string.isRequired, "markdownCompilerOptions": PropTypes.any, "placeholderReplacementFxn": PropTypes.func.isRequired -}; -BasicStaticSectionBody.defaultProps = { - "filetype": "md", - "element": "div", - "placeholderReplacementFxn": function placeholderReplacementFxn(placeholderString) { - // To be implemented by parent app. - return placeholderString; - } }; \ No newline at end of file diff --git a/es/components/ui/PartialList.js b/es/components/ui/PartialList.js index d6290c0c..1cb7081d 100644 --- a/es/components/ui/PartialList.js +++ b/es/components/ui/PartialList.js @@ -34,11 +34,15 @@ import { console } from './../util'; * @prop {Component|Element|string} children - Alias for props.value. */ var Row = /*#__PURE__*/React.memo(function (props) { - var colSm = props.colSm, - colMd = props.colMd, - colLg = props.colLg, + var _props$colSm = props.colSm, + colSm = _props$colSm === void 0 ? 12 : _props$colSm, + _props$colMd = props.colMd, + colMd = _props$colMd === void 0 ? 4 : _props$colMd, + _props$colLg = props.colLg, + colLg = _props$colLg === void 0 ? 4 : _props$colLg, field = props.field, - className = props.className, + _props$className = props.className, + className = _props$className === void 0 ? '' : _props$className, label = props.label, title = props.title, value = props.value, @@ -63,12 +67,6 @@ var Row = /*#__PURE__*/React.memo(function (props) { className: "inner" }, value || val || children || "Value"))); }); -Row.defaultProps = { - 'colSm': 12, - 'colMd': 4, - 'colLg': 4, - 'className': '' -}; /** * Renders a list using elements along the Bootstrap grid. diff --git a/src/components/static-pages/BasicStaticSectionBody.js b/src/components/static-pages/BasicStaticSectionBody.js index fa7e3290..37c18597 100644 --- a/src/components/static-pages/BasicStaticSectionBody.js +++ b/src/components/static-pages/BasicStaticSectionBody.js @@ -7,7 +7,17 @@ import { compiler } from 'markdown-to-jsx'; export const BasicStaticSectionBody = React.memo(function BasicStaticSectionBody(props){ - const { content, content_as_html, children, filetype, element, markdownCompilerOptions, placeholderReplacementFxn, ...passProps } = props; + const { + content, + content_as_html, + children, + filetype = "md", + element = "div", + markdownCompilerOptions, + // To be implemented by parent app. + placeholderReplacementFxn = function (placeholderString, props) { return placeholderString; }, + ...passProps + } = props; //In some cases, markdown to html conversion is handled by backend by assigning the content_as_html. For the rest, use markdown-to-jsx compiler. if (filetype === 'md' && typeof content === 'string' && !content_as_html){ return React.createElement(element, null, compiler(content, markdownCompilerOptions || undefined) ); @@ -30,11 +40,3 @@ BasicStaticSectionBody.propTypes = { "markdownCompilerOptions" : PropTypes.any, "placeholderReplacementFxn" : PropTypes.func.isRequired }; -BasicStaticSectionBody.defaultProps = { - "filetype" : "md", - "element" : "div", - "placeholderReplacementFxn" : function(placeholderString, props){ - // To be implemented by parent app. - return placeholderString; - } -}; diff --git a/src/components/ui/PartialList.js b/src/components/ui/PartialList.js index bdcedbbf..60c8cd7e 100644 --- a/src/components/ui/PartialList.js +++ b/src/components/ui/PartialList.js @@ -17,7 +17,7 @@ import { console } from './../util'; * @prop {Component|Element|string} children - Alias for props.value. */ const Row = React.memo(function Row(props){ - const { colSm, colMd, colLg, field, className, label, title, value, val, children } = props; + const { colSm = 12, colMd = 4, colLg = 4, field, className = '', label, title, value, val, children } = props; let valSm = 12 - colSm; let valMd = 12 - colMd; let valLg = 12 - colLg; @@ -40,12 +40,6 @@ const Row = React.memo(function Row(props){
); }); -Row.defaultProps = { - 'colSm' : 12, - 'colMd' : 4, - 'colLg' : 4, - 'className' : '' -}; /** From 0f2c13660b83553a39789894a73a2b1c2927ccc3 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Wed, 21 Aug 2024 09:14:54 +0300 Subject: [PATCH 30/35] add missing key that prevents editing is strict mode --- es/components/forms/components/submission-fields.js | 4 +++- src/components/forms/components/submission-fields.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/es/components/forms/components/submission-fields.js b/es/components/forms/components/submission-fields.js index f68b038b..22b3983c 100644 --- a/es/components/forms/components/submission-fields.js +++ b/es/components/forms/components/submission-fields.js @@ -514,7 +514,9 @@ export var BuildField = /*#__PURE__*/function (_React$PureComponent) { if (fieldType === 'linked object' && LinkedObj.isInSelectionField(fieldBeingSelected, nestedField, arrayIdx, fieldBeingSelectedArrayIdx)) { extClass += ' in-selection-field'; } - return wrapFunc( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { + return wrapFunc( /*#__PURE__*/React.createElement(React.Fragment, { + key: field + '.' + (arrayIdx || '') + }, /*#__PURE__*/React.createElement("div", { className: 'field-column col' + extClass }, fieldToDisplay), fieldType === 'array' || fieldType === 'file upload' ? null : /*#__PURE__*/React.createElement(SquareButton, { show: showDelete, diff --git a/src/components/forms/components/submission-fields.js b/src/components/forms/components/submission-fields.js index 7491bb19..c0a08d37 100644 --- a/src/components/forms/components/submission-fields.js +++ b/src/components/forms/components/submission-fields.js @@ -398,7 +398,7 @@ export class BuildField extends React.PureComponent { } return wrapFunc( - +
{ fieldToDisplay }
{ excludeRemoveButton ? null : }
From 78cb864eb0dee2e3a357e2083537e069494bca23 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Wed, 21 Aug 2024 09:16:28 +0300 Subject: [PATCH 31/35] remove unnecessary `isRequired` --- es/components/static-pages/BasicStaticSectionBody.js | 4 ++-- src/components/static-pages/BasicStaticSectionBody.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/es/components/static-pages/BasicStaticSectionBody.js b/es/components/static-pages/BasicStaticSectionBody.js index 66e7b4be..f1f01d17 100644 --- a/es/components/static-pages/BasicStaticSectionBody.js +++ b/es/components/static-pages/BasicStaticSectionBody.js @@ -38,7 +38,7 @@ BasicStaticSectionBody.propTypes = { "content": PropTypes.string.isRequired, "content_as_html": PropTypes.string, "filetype": PropTypes.string, - "element": PropTypes.string.isRequired, + "element": PropTypes.string, "markdownCompilerOptions": PropTypes.any, - "placeholderReplacementFxn": PropTypes.func.isRequired + "placeholderReplacementFxn": PropTypes.func }; \ No newline at end of file diff --git a/src/components/static-pages/BasicStaticSectionBody.js b/src/components/static-pages/BasicStaticSectionBody.js index 37c18597..035b3b96 100644 --- a/src/components/static-pages/BasicStaticSectionBody.js +++ b/src/components/static-pages/BasicStaticSectionBody.js @@ -36,7 +36,7 @@ BasicStaticSectionBody.propTypes = { "content" : PropTypes.string.isRequired, "content_as_html" : PropTypes.string, "filetype" : PropTypes.string, - "element" : PropTypes.string.isRequired, + "element" : PropTypes.string, "markdownCompilerOptions" : PropTypes.any, - "placeholderReplacementFxn" : PropTypes.func.isRequired + "placeholderReplacementFxn" : PropTypes.func }; From 5c7a7f434c03314c254dcfe295dde10bbac3f801 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Wed, 21 Aug 2024 09:17:42 +0300 Subject: [PATCH 32/35] replace defaultProps with js default parameters (React 18 requirement) --- .../browse/components/SelectedItemsController.js | 14 ++++++-------- es/components/forms/SubmissionView.js | 7 ++----- .../forms/components/SearchAsYouTypeAjax.js | 16 +++++++--------- .../browse/components/SelectedItemsController.js | 8 +------- src/components/forms/SubmissionView.js | 6 +----- .../forms/components/SearchAsYouTypeAjax.js | 9 ++------- 6 files changed, 19 insertions(+), 41 deletions(-) diff --git a/es/components/browse/components/SelectedItemsController.js b/es/components/browse/components/SelectedItemsController.js index d5b706ca..65457abb 100644 --- a/es/components/browse/components/SelectedItemsController.js +++ b/es/components/browse/components/SelectedItemsController.js @@ -329,9 +329,12 @@ export var SelectStickyFooter = /*#__PURE__*/React.memo(function (props) { }), "\xA0 Cancel")))); }); export var BackNavigationStickyFooter = /*#__PURE__*/React.memo(function (props) { - var text = props.text, - tooltip = props.tooltip, - navigateToInitialPage = props.navigateToInitialPage; + var _props$text = props.text, + text = _props$text === void 0 ? 'Return to Selection List' : _props$text, + _props$tooltip = props.tooltip, + tooltip = _props$tooltip === void 0 ? 'Go to selection page' : _props$tooltip, + _props$navigateToInit = props.navigateToInitialPage, + navigateToInitialPage = _props$navigateToInit === void 0 ? true : _props$navigateToInit; var onBackButtonClick = useCallback(function () { if (window.history.length === 0) { return; @@ -356,11 +359,6 @@ BackNavigationStickyFooter.propTypes = { 'tooltip': PropTypes.string, 'navigateToInitialPage': PropTypes.bool }; -BackNavigationStickyFooter.defaultProps = { - 'text': 'Return to Selection List', - 'tooltip': 'Go to selection page', - 'navigateToInitialPage': true -}; /** * General purpose sticky footer component diff --git a/es/components/forms/SubmissionView.js b/es/components/forms/SubmissionView.js index 08b06983..213cb136 100644 --- a/es/components/forms/SubmissionView.js +++ b/es/components/forms/SubmissionView.js @@ -2741,7 +2741,8 @@ var IndividualObjectView = /*#__PURE__*/function (_React$Component2) { }(React.Component); var FormFieldsContainer = /*#__PURE__*/React.memo(function (props) { var children = props.children, - title = props.title; + _props$title = props.title, + title = _props$title === void 0 ? 'Fields & Dependencies' : _props$title; if (React.Children.count(children) === 0) return null; return /*#__PURE__*/React.createElement("div", { className: "form-fields-container" @@ -2751,10 +2752,6 @@ var FormFieldsContainer = /*#__PURE__*/React.memo(function (props) { className: "form-section-body" }, children)); }); -FormFieldsContainer.defaultProps = { - 'title': 'Fields & Dependencies', - 'currKey': 0 -}; /** * Simple Component that opens/closes and renders a Detail panel using the context diff --git a/es/components/forms/components/SearchAsYouTypeAjax.js b/es/components/forms/components/SearchAsYouTypeAjax.js index a3464090..8fb206b3 100644 --- a/es/components/forms/components/SearchAsYouTypeAjax.js +++ b/es/components/forms/components/SearchAsYouTypeAjax.js @@ -785,11 +785,14 @@ export var SquareButton = /*#__PURE__*/React.memo(function (props) { disabled = props.disabled, onClick = props.onClick, tip = props.tip, - bsStyle = props.bsStyle, + _props$bsStyle = props.bsStyle, + bsStyle = _props$bsStyle === void 0 ? 'danger' : _props$bsStyle, className = props.className, buttonContainerClassName = props.buttonContainerClassName, - icon = props.icon, - style = props.style; + _props$icon = props.icon, + icon = _props$icon === void 0 ? 'times fas' : _props$icon, + _props$style = props.style, + style = _props$style === void 0 ? null : _props$style; var outerCls = "remove-button-container" + (buttonContainerClassName ? ' ' + buttonContainerClassName : ''); var btnCls = "btn" + (className ? " " + className : ""); if (bsStyle) { @@ -812,9 +815,4 @@ export var SquareButton = /*#__PURE__*/React.memo(function (props) { }, /*#__PURE__*/React.createElement("i", { className: "icon icon-fw icon-" + icon }))))); -}); -SquareButton.defaultProps = { - 'bsStyle': 'danger', - 'icon': 'times fas', - 'style': null -}; \ No newline at end of file +}); \ No newline at end of file diff --git a/src/components/browse/components/SelectedItemsController.js b/src/components/browse/components/SelectedItemsController.js index d6958625..bc7eb23b 100644 --- a/src/components/browse/components/SelectedItemsController.js +++ b/src/components/browse/components/SelectedItemsController.js @@ -256,7 +256,7 @@ export const SelectStickyFooter = React.memo(function SelectStickyFooter(props){ }); export const BackNavigationStickyFooter = React.memo(function BackNavigationStickyFooter(props) { - const { text, tooltip, navigateToInitialPage } = props; + const { text = 'Return to Selection List', tooltip = 'Go to selection page', navigateToInitialPage = true } = props; const onBackButtonClick = useCallback(function () { if (window.history.length === 0) { @@ -284,12 +284,6 @@ BackNavigationStickyFooter.propTypes = { 'navigateToInitialPage': PropTypes.bool }; -BackNavigationStickyFooter.defaultProps = { - 'text': 'Return to Selection List', - 'tooltip': 'Go to selection page', - 'navigateToInitialPage': true -}; - /** * General purpose sticky footer component * TODO: Component can be moved to a separate file. diff --git a/src/components/forms/SubmissionView.js b/src/components/forms/SubmissionView.js index 781b7702..a0b469b1 100644 --- a/src/components/forms/SubmissionView.js +++ b/src/components/forms/SubmissionView.js @@ -2317,7 +2317,7 @@ class IndividualObjectView extends React.Component { const FormFieldsContainer = React.memo(function FormFieldsContainer(props){ - const { children, title } = props; + const { children, title = 'Fields & Dependencies' } = props; if (React.Children.count(children) === 0) return null; return (
@@ -2326,10 +2326,6 @@ const FormFieldsContainer = React.memo(function FormFieldsContainer(props){
); }); -FormFieldsContainer.defaultProps = { - 'title' : 'Fields & Dependencies', - 'currKey' : 0 -}; /** * Simple Component that opens/closes and renders a Detail panel using the context diff --git a/src/components/forms/components/SearchAsYouTypeAjax.js b/src/components/forms/components/SearchAsYouTypeAjax.js index f92d714f..369ebbcf 100644 --- a/src/components/forms/components/SearchAsYouTypeAjax.js +++ b/src/components/forms/components/SearchAsYouTypeAjax.js @@ -627,7 +627,7 @@ export class LinkedObj extends React.PureComponent { } export const SquareButton = React.memo(function SquareButton(props){ - const { show, disabled, onClick, tip, bsStyle, className, buttonContainerClassName, icon, style } = props; + const { show, disabled, onClick, tip, bsStyle = 'danger', className, buttonContainerClassName, icon = 'times fas', style = null } = props; const outerCls = "remove-button-container" + (buttonContainerClassName ? ' ' + buttonContainerClassName : ''); let btnCls = ("btn" + (className ? " " + className : "")); if (bsStyle){ @@ -644,9 +644,4 @@ export const SquareButton = React.memo(function SquareButton(props){ ); -}); -SquareButton.defaultProps = { - 'bsStyle' : 'danger', - 'icon' : 'times fas', - 'style' : null -}; \ No newline at end of file +}); \ No newline at end of file From dcc19406005fa685dc74f2115079df83ab100c87 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Wed, 21 Aug 2024 11:05:40 +0300 Subject: [PATCH 33/35] merge UNSAFE_componentWillReceiveProps into componentDidUpdate --- .../forms/components/EditableField.js | 39 ++++++------ .../forms/components/EditableField.js | 59 ++++++++++--------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/es/components/forms/components/EditableField.js b/es/components/forms/components/EditableField.js index 82772462..d7478f7d 100644 --- a/es/components/forms/components/EditableField.js +++ b/es/components/forms/components/EditableField.js @@ -124,38 +124,37 @@ export var EditableField = /*#__PURE__*/function (_React$Component) { }; }); } - - /** @todo Refactor to use memoization, didUpdate, derivedStateFromProps, or remove component entirely */ }, { - key: "UNSAFE_componentWillReceiveProps", - value: function UNSAFE_componentWillReceiveProps(newProps) { - var newState = {}, - stateChangeCallback = null; + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps, prevState) { + var newState = {}; + var stateChangeCallback = null; - // Reset value/savedValue if props.context or props.labelID changes for some reason. - if (!this.state.dispatching && (this.props.context !== newProps.context || this.props.labelID !== newProps.labelID)) { - var newVal = object.getNestedProperty(newProps.context, this.props.labelID, true); + // Handle prop changes + if (!this.state.dispatching && (prevProps.context !== this.props.context || prevProps.labelID !== this.props.labelID)) { + var newVal = object.getNestedProperty(this.props.context, this.props.labelID, true); newState.savedValue = newState.value = newVal || null; newState.valueExistsOnObj = typeof newVal !== 'undefined'; } + // Update state.validationPattern && state.isRequired if this.props.schemas becomes available // (loaded via ajax by app.js) or from props if is provided. - if (newProps.schemas !== this.props.schemas || newProps.pattern !== this.props.pattern || newProps.required !== this.props.required) { - newState.validationPattern = newProps.pattern || this.validationPattern(newProps.schemas); - newState.required = newProps.required || this.isRequired(newProps.schemas); + if (this.props.schemas !== prevProps.schemas || this.props.pattern !== prevProps.pattern || this.props.required !== prevProps.required) { + newState.validationPattern = this.props.pattern || this.validationPattern(this.props.schemas); + newState.required = this.props.required || this.isRequired(this.props.schemas); // Also, update state.valid if in editing mode if (this.props.parent.state && this.props.parent.state.currentlyEditing && this.inputElementRef.current) { stateChangeCallback = this.handleChange; } } + // Apply state edits, if any - if (_.keys(newState).length > 0) this.setState(newState, stateChangeCallback); - } - }, { - key: "componentDidUpdate", - value: function componentDidUpdate(oldProps, oldState) { - // If state change but not onChange event -- e.g. change to/from editing state - if (oldState.value === this.state.value && oldState.loading === this.state.loading && oldState.dispatching === this.state.dispatching && oldState.savedValue === this.state.savedValue) { + if (_.keys(newState).length > 0) { + this.setState(newState, stateChangeCallback); + } + + // Handle state changes + if (prevState.value === this.state.value && prevState.loading === this.state.loading && prevState.dispatching === this.state.dispatching && prevState.savedValue === this.state.savedValue) { if (this.justUpdatedLayout) { this.justUpdatedLayout = false; return false; @@ -846,7 +845,7 @@ _defineProperty(EditableField, "propTypes", { // Optional pattern to use in lieu of one derived from schema or default field pattern. If set to false, will skip (default or schema-based) validation. required: PropTypes.bool, // Optionally set if field is required, overriding setting derived from schema (if any). Defaults to false. - schemas: PropTypes.object.isRequired, + schemas: PropTypes.object, debug: PropTypes.bool, // Verbose lifecycle log messages. handleCustomSave: PropTypes.func, diff --git a/src/components/forms/components/EditableField.js b/src/components/forms/components/EditableField.js index d09a3767..8a97ffb3 100644 --- a/src/components/forms/components/EditableField.js +++ b/src/components/forms/components/EditableField.js @@ -45,7 +45,7 @@ export class EditableField extends React.Component { objectType : PropTypes.string, // Class name of object being edited, e.g. User, Biosource, AccessKey, etc. for schema-based validation. pattern : PropTypes.any, // Optional pattern to use in lieu of one derived from schema or default field pattern. If set to false, will skip (default or schema-based) validation. required : PropTypes.bool, // Optionally set if field is required, overriding setting derived from schema (if any). Defaults to false. - schemas : PropTypes.object.isRequired, + schemas : PropTypes.object, debug : PropTypes.bool, // Verbose lifecycle log messages. handleCustomSave: PropTypes.func, // instead of built-in save function, pass custom save dataType : PropTypes.oneOf(['string', 'int']), //return value is converted one of these types @@ -141,60 +141,61 @@ export class EditableField extends React.Component { }); } - /** @todo Refactor to use memoization, didUpdate, derivedStateFromProps, or remove component entirely */ - UNSAFE_componentWillReceiveProps(newProps){ - var newState = {}, - stateChangeCallback = null; + componentDidUpdate(prevProps, prevState) { + const newState = {}; + let stateChangeCallback = null; - // Reset value/savedValue if props.context or props.labelID changes for some reason. + // Handle prop changes if ( !this.state.dispatching && ( - (this.props.context !== newProps.context) || - (this.props.labelID !== newProps.labelID) + (prevProps.context !== this.props.context) || + (prevProps.labelID !== this.props.labelID) ) ) { - var newVal = object.getNestedProperty(newProps.context, this.props.labelID, true); + var newVal = object.getNestedProperty(this.props.context, this.props.labelID, true); newState.savedValue = newState.value = newVal || null; newState.valueExistsOnObj = typeof newVal !== 'undefined'; } + // Update state.validationPattern && state.isRequired if this.props.schemas becomes available // (loaded via ajax by app.js) or from props if is provided. if ( - newProps.schemas !== this.props.schemas || - newProps.pattern !== this.props.pattern || - newProps.required !== this.props.required - ){ - newState.validationPattern = newProps.pattern || this.validationPattern(newProps.schemas); - newState.required = newProps.required || this.isRequired(newProps.schemas); + this.props.schemas !== prevProps.schemas || + this.props.pattern !== prevProps.pattern || + this.props.required !== prevProps.required + ) { + newState.validationPattern = this.props.pattern || this.validationPattern(this.props.schemas); + newState.required = this.props.required || this.isRequired(this.props.schemas); // Also, update state.valid if in editing mode - if (this.props.parent.state && this.props.parent.state.currentlyEditing && this.inputElementRef.current){ + if (this.props.parent.state && this.props.parent.state.currentlyEditing && this.inputElementRef.current) { stateChangeCallback = this.handleChange; } } + // Apply state edits, if any - if (_.keys(newState).length > 0) this.setState(newState, stateChangeCallback); - } + if (_.keys(newState).length > 0) { + this.setState(newState, stateChangeCallback); + } - componentDidUpdate(oldProps, oldState){ - // If state change but not onChange event -- e.g. change to/from editing state + // Handle state changes if ( - oldState.value === this.state.value && - oldState.loading === this.state.loading && - oldState.dispatching === this.state.dispatching && - oldState.savedValue === this.state.savedValue - ){ - if (this.justUpdatedLayout){ + prevState.value === this.state.value && + prevState.loading === this.state.loading && + prevState.dispatching === this.state.dispatching && + prevState.savedValue === this.state.savedValue + ) { + if (this.justUpdatedLayout) { this.justUpdatedLayout = false; return false; } - if (this.props.parent.state && this.props.parent.state.currentlyEditing === this.props.labelID){ + if (this.props.parent.state && this.props.parent.state.currentlyEditing === this.props.labelID) { this.onResizeStateChange(); if (!this.state.selectAllDone && this.inputElementRef && this.inputElementRef.current) { this.inputElementRef.current.select(); - this.setState({ 'selectAllDone' : true }); + this.setState({ 'selectAllDone': true }); } } else { - this.setState({ 'leanTo' : null }); + this.setState({ 'leanTo': null }); } this.justUpdatedLayout = true; } From 4f9ecb14bb75a42d1ad29ca9660d54912d4c344a Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Wed, 21 Aug 2024 11:06:05 +0300 Subject: [PATCH 34/35] bump react-json-tree v0.19.0 --- package-lock.json | 182 +++++++++++++++++++++++----------------------- package.json | 2 +- 2 files changed, 94 insertions(+), 90 deletions(-) diff --git a/package-lock.json b/package-lock.json index 615a49f3..4c3c4fda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "jsdom": "^19.0.0", "jsonwebtoken": ">=7.4.0", "react-draggable": ">=4.4.5", - "react-json-tree": "^0.17.0" + "react-json-tree": "^0.19.0" }, "devDependencies": { "@babel/cli": "^7.23.9", @@ -3957,11 +3957,6 @@ "@babel/types": "^7.3.0" } }, - "node_modules/@types/base16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/base16/-/base16-1.0.2.tgz", - "integrity": "sha512-oYO/U4VD1DavwrKuCSQWdLG+5K22SLPem2OQaHmFcQuwHoVeGC+JGVRji2MUqZUAIQZHEonOeVfAX09hYiLsdg==" - }, "node_modules/@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", @@ -4008,9 +4003,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.14.192", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.192.tgz", - "integrity": "sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==" + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==" }, "node_modules/@types/node": { "version": "18.15.11", @@ -5333,11 +5328,6 @@ "node": ">=0.10.0" } }, - "node_modules/base16": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/base16/-/base16-1.0.0.tgz", - "integrity": "sha512-pNdYkNPiJUnEhnfXV56+sQy8+AaPcG3POZAUnwr4EeqCUZFz4u2PePbo3e5Gj4ziYPCWGUZT9RHisvJKnwFuBQ==" - }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -6089,18 +6079,22 @@ } }, "node_modules/color": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", - "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", "dependencies": { - "color-convert": "^1.9.3", - "color-string": "^1.6.0" + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" } }, "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "dependencies": { "color-name": "1.1.3" } @@ -6128,6 +6122,22 @@ "color-support": "bin.js" } }, + "node_modules/color/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -6422,9 +6432,9 @@ "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" }, "node_modules/csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "node_modules/cyclist": { "version": "1.0.1", @@ -14720,10 +14730,10 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lodash.curry": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.curry/-/lodash.curry-4.1.1.tgz", - "integrity": "sha512-/u14pXGviLaweY5JI0IUzgzF2J6Ne8INyzAZjImcryjgkZ+ebruBxy2/JaOOkTqScddcYtakjhSaeemV8lR0tA==" + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" }, "node_modules/lodash.debounce": { "version": "4.0.8", @@ -16654,17 +16664,14 @@ } }, "node_modules/react-base16-styling": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/react-base16-styling/-/react-base16-styling-0.9.1.tgz", - "integrity": "sha512-1s0CY1zRBOQ5M3T61wetEpvQmsYSNtWEcdYzyZNxKa8t7oDvaOn9d21xrGezGAHFWLM7SHcktPuPTrvoqxSfKw==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/react-base16-styling/-/react-base16-styling-0.10.0.tgz", + "integrity": "sha512-H1k2eFB6M45OaiRru3PBXkuCcn2qNmx+gzLb4a9IPMR7tMH8oBRXU5jGbPDYG1Hz+82d88ED0vjR8BmqU3pQdg==", "dependencies": { - "@babel/runtime": "^7.16.7", - "@types/base16": "^1.0.2", - "@types/lodash": "^4.14.178", - "base16": "^1.0.0", - "color": "^3.2.1", - "csstype": "^3.0.10", - "lodash.curry": "^4.1.1" + "@types/lodash": "^4.17.0", + "color": "^4.2.3", + "csstype": "^3.1.3", + "lodash-es": "^4.17.21" } }, "node_modules/react-bootstrap": { @@ -16736,19 +16743,16 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/react-json-tree": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/react-json-tree/-/react-json-tree-0.17.0.tgz", - "integrity": "sha512-hcWjibI/fAvsKnfYk+lka5OrE1Lvb1jH5pSnFhIU5T8cCCxB85r6h/NOzDPggSSgErjmx4rl3+2EkeclIKBOhg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/react-json-tree/-/react-json-tree-0.19.0.tgz", + "integrity": "sha512-PqT1WRVcWP+RROsZPQfNEKIC1iM/ZMfY4g5jN6oDnXp5593PPRAYgoHcgYCDjflAHQMtxl8XGdlTwIBdEGUXvw==", "dependencies": { - "@babel/runtime": "^7.18.3", - "@types/lodash": "^4.14.182", - "@types/prop-types": "^15.7.5", - "prop-types": "^15.8.1", - "react-base16-styling": "^0.9.1" + "@types/lodash": "^4.17.0", + "react-base16-styling": "^0.10.0" }, "peerDependencies": { - "@types/react": "^16.3.0 || ^17.0.0 || ^18.0.0", - "react": "^16.3.0 || ^17.0.0 || ^18.0.0" + "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, "node_modules/react-lifecycles-compat": { @@ -23640,11 +23644,6 @@ "@babel/types": "^7.3.0" } }, - "@types/base16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/base16/-/base16-1.0.2.tgz", - "integrity": "sha512-oYO/U4VD1DavwrKuCSQWdLG+5K22SLPem2OQaHmFcQuwHoVeGC+JGVRji2MUqZUAIQZHEonOeVfAX09hYiLsdg==" - }, "@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", @@ -23691,9 +23690,9 @@ "dev": true }, "@types/lodash": { - "version": "4.14.192", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.192.tgz", - "integrity": "sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==" + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==" }, "@types/node": { "version": "18.15.11", @@ -24792,11 +24791,6 @@ } } }, - "base16": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/base16/-/base16-1.0.0.tgz", - "integrity": "sha512-pNdYkNPiJUnEhnfXV56+sQy8+AaPcG3POZAUnwr4EeqCUZFz4u2PePbo3e5Gj4ziYPCWGUZT9RHisvJKnwFuBQ==" - }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -25386,18 +25380,34 @@ } }, "color": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", - "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", "requires": { - "color-convert": "^1.9.3", - "color-string": "^1.6.0" + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "dependencies": { + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + } } }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "requires": { "color-name": "1.1.3" } @@ -25688,9 +25698,9 @@ } }, "csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "cyclist": { "version": "1.0.1", @@ -32127,10 +32137,10 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "lodash.curry": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.curry/-/lodash.curry-4.1.1.tgz", - "integrity": "sha512-/u14pXGviLaweY5JI0IUzgzF2J6Ne8INyzAZjImcryjgkZ+ebruBxy2/JaOOkTqScddcYtakjhSaeemV8lR0tA==" + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" }, "lodash.debounce": { "version": "4.0.8", @@ -33690,17 +33700,14 @@ } }, "react-base16-styling": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/react-base16-styling/-/react-base16-styling-0.9.1.tgz", - "integrity": "sha512-1s0CY1zRBOQ5M3T61wetEpvQmsYSNtWEcdYzyZNxKa8t7oDvaOn9d21xrGezGAHFWLM7SHcktPuPTrvoqxSfKw==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/react-base16-styling/-/react-base16-styling-0.10.0.tgz", + "integrity": "sha512-H1k2eFB6M45OaiRru3PBXkuCcn2qNmx+gzLb4a9IPMR7tMH8oBRXU5jGbPDYG1Hz+82d88ED0vjR8BmqU3pQdg==", "requires": { - "@babel/runtime": "^7.16.7", - "@types/base16": "^1.0.2", - "@types/lodash": "^4.14.178", - "base16": "^1.0.0", - "color": "^3.2.1", - "csstype": "^3.0.10", - "lodash.curry": "^4.1.1" + "@types/lodash": "^4.17.0", + "color": "^4.2.3", + "csstype": "^3.1.3", + "lodash-es": "^4.17.21" } }, "react-bootstrap": { @@ -33760,15 +33767,12 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "react-json-tree": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/react-json-tree/-/react-json-tree-0.17.0.tgz", - "integrity": "sha512-hcWjibI/fAvsKnfYk+lka5OrE1Lvb1jH5pSnFhIU5T8cCCxB85r6h/NOzDPggSSgErjmx4rl3+2EkeclIKBOhg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/react-json-tree/-/react-json-tree-0.19.0.tgz", + "integrity": "sha512-PqT1WRVcWP+RROsZPQfNEKIC1iM/ZMfY4g5jN6oDnXp5593PPRAYgoHcgYCDjflAHQMtxl8XGdlTwIBdEGUXvw==", "requires": { - "@babel/runtime": "^7.18.3", - "@types/lodash": "^4.14.182", - "@types/prop-types": "^15.7.5", - "prop-types": "^15.8.1", - "react-base16-styling": "^0.9.1" + "@types/lodash": "^4.17.0", + "react-base16-styling": "^0.10.0" } }, "react-lifecycles-compat": { diff --git a/package.json b/package.json index ad6bf4f6..bdd44968 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "jsonwebtoken": ">=7.4.0", "react-draggable": ">=4.4.5", "@4dn-dcic/react-infinite": "github:4dn-dcic/react-infinite#1.1.9", - "react-json-tree": "^0.17.0" + "react-json-tree": "^0.19.0" }, "peerDependencies": { "auth0-lock": ">=11.26.3", From fc6e50d01e3577b02a568557d4a747644a4f5d14 Mon Sep 17 00:00:00 2001 From: utku-ozturk Date: Thu, 22 Aug 2024 11:38:57 +0300 Subject: [PATCH 35/35] start using `content_as_html` for jsx and html content when available --- es/components/static-pages/BasicStaticSectionBody.js | 2 +- src/components/static-pages/BasicStaticSectionBody.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/es/components/static-pages/BasicStaticSectionBody.js b/es/components/static-pages/BasicStaticSectionBody.js index f1f01d17..ec03e5f0 100644 --- a/es/components/static-pages/BasicStaticSectionBody.js +++ b/es/components/static-pages/BasicStaticSectionBody.js @@ -26,7 +26,7 @@ export var BasicStaticSectionBody = /*#__PURE__*/React.memo(function (props) { } else if ((filetype === 'html' || filetype === 'rst' || filetype === 'md') && (typeof content_as_html === 'string' || typeof content === 'string')) { return /*#__PURE__*/React.createElement(element, null, htmlToJSX(content_as_html || content)); } else if (filetype === 'jsx' && typeof content === 'string') { - return placeholderReplacementFxn(content.trim(), passProps); + return placeholderReplacementFxn((content_as_html || content).trim(), passProps); } else if (filetype === 'txt' && typeof content === 'string' && content.slice(0, 12) === 'placeholder:') { // Deprecated older method - to be removed once data.4dn uses filetype=jsx everywhere w/ placeholder return placeholderReplacementFxn(content.slice(12).trim()); diff --git a/src/components/static-pages/BasicStaticSectionBody.js b/src/components/static-pages/BasicStaticSectionBody.js index 035b3b96..e76ed8a7 100644 --- a/src/components/static-pages/BasicStaticSectionBody.js +++ b/src/components/static-pages/BasicStaticSectionBody.js @@ -24,7 +24,7 @@ export const BasicStaticSectionBody = React.memo(function BasicStaticSectionBody } else if ((filetype === 'html' || filetype === 'rst' || filetype === 'md') && (typeof content_as_html === 'string' || typeof content === 'string')){ return React.createElement(element, null, htmlToJSX(content_as_html || content)); } else if (filetype === 'jsx' && typeof content === 'string'){ - return placeholderReplacementFxn(content.trim(), passProps); + return placeholderReplacementFxn((content_as_html || content).trim(), passProps); } else if (filetype === 'txt' && typeof content === 'string' && content.slice(0,12) === 'placeholder:'){ // Deprecated older method - to be removed once data.4dn uses filetype=jsx everywhere w/ placeholder return placeholderReplacementFxn(content.slice(12).trim());