How to develop a vis widget based on React?
See here: https://github.com/ioBroker/ioBroker.vis-2-widgets-react-template
- Add to import
import { getProps } from '@iobroker/vis-2-widgets-react-dev/visDevUtils';
- Add in constructor
constructor(props) {
super(props);
this.refParent = React.createRef();
this.widgetProps = getProps(
{
socket: this.socket,
theme: this.state.theme,
refParent: this.refParent,
},
{
// Your test settings for widget
type: 'all',
},
{
// Your test styles for widget
width: 600,
height: 200,
},
);
}
- Modify renderer
renderWidget() {
return <div
ref={this.refParent}
style={{
width: 600,
height: 200,
}}
>
<DemoWidget
{...this.widgetProps}
/>
</div>;
}
Here is an example of the widget:
import React from 'react';
import WidgetDemoApp from '@iobroker/vis-2-widgets-react-dev/widgetDemoApp';
import { I18n } from '@iobroker/adapter-react-v5';
import { getProps } from '@iobroker/vis-2-widgets-react-dev/visDevUtils';
import DemoWidget from './DemoWidget';
import translations from './translations';
class App extends WidgetDemoApp {
constructor(props) {
super(props);
// init translations
I18n.extendTranslations(translations);
this.refParent = React.createRef();
this.widgetProps = getProps(
{
socket: this.socket,
theme: this.state.theme,
refParent: this.refParent,
},
{
type: 'all',
},
{
width: 600,
height: 200,
},
);
}
renderWidget() {
return <div
ref={this.refParent}
style={{
width: 600,
height: 200,
}}
>
<DemoWidget
{...this.widgetProps}
/>
</div>;
}
}
export default App;
- (bluefox) Updated adapter-react-v5
- (bluefox) Improvement for vis-2 widgets
- (bluefox) Removed gulp from a build process
- (bluefox) Optimization of packages
- (bluefox) Corrected
deleteFoldersRecursive
function
- (bluefox) Rewritten with typescript
- (bluefox) Updated packages
- (Steiger04) Removed version warning
- (bluefox) Removed dependency to
@mui/styles
- (bluefox) updated packages
- (bluefox) added getWidgetView to visRxWidget
- (bluefox) updated packages
- (foxriver76) port to
@iobroker/types
- (bluefox) Corrected error in deleteFoldersRecursive
- (bluefox) Updated packages
- (bluefox) Corrected simulation of widgets
- (bluefox) Packages updated
- (bluefox) Corrected simulation of widgets
- (bluefox) Packages updated
- (bluefox) Packages updated
- (bluefox) Disable
craco-esbuild
plugin
- (bluefox) Added gulp helper
- (bluefox) Added developer settings: proxy
- (bluefox) Try to fix error in webpack
- (dilesoft) Try to fix error in webpack
- (bluefox) added some common methods like
formatValue
orwrapContent
- (bluefox) GUI packages updated
- Better i18n support
- (bluefox) Better i18n support
- (bluefox) Better i18n support
- (bluefox) Added method onStateUpdated
- (bluefox) Added search for i18n keys in the tooltips
- (bluefox) Renamed to
vis-2-widgets-react-dev
- (bluefox) Corrected simulation of
data
andstyle
- (bluefox) Added search for i18n keys in the code
- (bluefox) Added
modulefederation
andcraco
config files
- (bluefox) visRxWidget was optimized
- (bluefox) initial commit
The MIT License (MIT)
Copyright (c) 2022-2024 bluefox dogafox@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.