From 4b2df98098c22dbdf183e880f10c1bdd59283d9c Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 10 Nov 2021 11:53:00 +0100 Subject: [PATCH] use react-tabs production build --- apps/remix-ide/src/app/panels/tab-proxy.js | 7 ++++++- apps/remix-ide/src/assets/js/react-tabs.production.min.js | 2 ++ libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 apps/remix-ide/src/assets/js/react-tabs.production.min.js diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index 139213a764..4f5a030e04 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -306,8 +306,13 @@ export class TabProxy extends Plugin { } renderTabsbar () { + window.React = React + const script = document.createElement('script') + script.type = 'text/javascript' + script.src = 'assets/js/react-tabs.production.min.js' + document.head.appendChild(script) + script.addEventListener('load', () => this.renderComponent()) this.el = document.createElement('div') - this.renderComponent() return this.el } } diff --git a/apps/remix-ide/src/assets/js/react-tabs.production.min.js b/apps/remix-ide/src/assets/js/react-tabs.production.min.js new file mode 100644 index 0000000000..59f4d0590c --- /dev/null +++ b/apps/remix-ide/src/assets/js/react-tabs.production.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactTabs={},e.React)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function a(){return(a=Object.assign||function(e){for(var t=1;t=0||(a[n]=e[n]);return a}function i(e){return function(t){return!!t.type&&t.type.tabsRole===e}}var d=i("Tab"),c=i("TabList"),u=i("TabPanel");function f(e,n){return t.Children.map(e,(function(e){return null===e?null:function(e){return d(e)||c(e)||u(e)}(e)?n(e):e.props&&e.props.children&&"object"==typeof e.props.children?t.cloneElement(e,a({},e.props,{children:f(e.props.children,n)})):e}))}function p(e,n){return t.Children.forEach(e,(function(e){null!==e&&(d(e)||u(e)?n(e):e.props&&e.props.children&&"object"==typeof e.props.children&&(c(e)&&n(e),p(e.props.children,n)))}))}function b(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t=this.getTabsCount())){var n=this.props;(0,n.onSelect)(e,n.selectedIndex,t)}},o.getNextTab=function(e){for(var t=this.getTabsCount(),n=e+1;ne;)if(!N(this.getTab(t)))return t;return e},o.getFirstTab=function(){for(var e=this.getTabsCount(),t=0;t string } +declare var ReactTabs: any + export const TabsUI = (props: TabsUIProps) => { + const { Tab, Tabs, TabList, TabPanel } = ReactTabs const [selectedIndex, setSelectedIndex] = useState(-1) const currentIndexRef = useRef(-1) const tabsRef = useRef({})