@iobroker/adapter-react-v5 3.1.18 → 3.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/ObjectBrowser.js +1 -1
- package/Components/ObjectBrowser.js.map +1 -1
- package/Components/Utils.js +3 -3
- package/Components/Utils.js.map +1 -1
- package/Dialogs/SelectID.js +3 -0
- package/Dialogs/SelectID.js.map +1 -1
- package/README.md +9 -0
- package/i18n.js +76 -18
- package/i18n.js.map +1 -1
- package/package.json +12 -12
package/Dialogs/SelectID.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectID.js","names":["styles","theme","headerID","fontWeight","fontStyle","dialog","height","dialogMobile","padding","width","maxWidth","maxHeight","content","overflow","contentMobile","titleRoot","whiteSpace","display","textOverflow","DialogSelectID","props","dialogName","filters","window","_localStorage","localStorage","getItem","JSON","parse","e","selected","filter","id","state","name","isMobile","innerWidth","onClose","onOk","multiSelect","title","length","I18n","t","classes","paper","Utils","clsx","root","foldersFirst","imagePrefix","prefix","showExpertButton","undefined","columns","types","lang","getLanguage","socket","notEditable","themeName","themeType","customFilter","filterConfig","setItem","stringify","isDouble","setState","handleOk","filterFunc","ok","handleCancel","cancel","React","Component","propTypes","PropTypes","string","object","bool","func","isRequired","isFloatComma","dateFormat","oneOfType","array","statesOnly","_export","withStyles"],"sources":["SelectID.js"],"sourcesContent":["/**\n * Copyright 2018-2022 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n **/\n// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport withStyles from '@mui/styles/withStyles';\n\nimport Button from '@mui/material/Button';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogActions from '@mui/material/DialogActions';\nimport Dialog from '@mui/material/Dialog';\n\nimport IconCancel from '@mui/icons-material/Cancel';\nimport IconOk from '@mui/icons-material/Check';\n\nimport Utils from '../Components/Utils';\nimport I18n from '../i18n';\nimport ObjectBrowser from '../Components/ObjectBrowser';\n\nconst styles = theme => ({\n headerID: {\n fontWeight: 'bold',\n fontStyle: 'italic'\n },\n dialog: {\n height: '95%'\n },\n dialogMobile: {\n padding: 4,\n width: '100%',\n maxWidth: '100%',\n maxHeight: 'calc(100% - 16px)',\n height: '100%'\n },\n content: {\n height: '100%',\n overflow: 'hidden'\n },\n contentMobile: {\n padding: '8px 4px'\n },\n titleRoot: {\n whiteSpace: 'nowrap',\n width: 'calc(100% - 72px)',\n overflow: 'hidden',\n display: 'inline-block',\n textOverflow: 'ellipsis',\n }\n});\n\n/**\n * @typedef {object} DialogSelectIDProps\n * @property {string} [dialogName] The internal name of the dialog; default: \"default\"\n * @property {string} [title] The dialog title; default: Please select object ID... (translated)\n * @property {boolean} [multiSelect] Set to true to allow the selection of multiple IDs.\n * @property {boolean} [foldersFirst] Show folders before any leaves.\n * @property {string} [imagePrefix] Prefix (default: '.')\n * @property {boolean} [showExpertButton] Show the expert button?\n * @property {import('../Components/types').ObjectBrowserColumn[]} [columns] Columns to display; default: 'name', 'type', 'role', 'room', 'func', 'val'\n * @property {import('../Components/types').ObjectBrowserType[]} [types] Object types to show; default: 'state' only\n * @property {ioBroker.Languages} [lang] The language.\n * @property {import('../Connection').default} socket The socket connection.\n * @property {boolean} [notEditable] Can't objects be edited? (default: true)\n * @property {string} [themeName] Theme name.\n * @property {string} [themeType] Theme type.\n * @property {import('../Components/types').ObjectBrowserCustomFilter} [customFilter] Custom filter.\n * @property {string | string[]} [selected] The selected IDs.\n * @property {string} [ok] The ok button text; default: OK (translated)\n * @property {string} [cancel] The cancel button text; default: Cancel (translated)\n * @property {() => void} onClose Close handler that is always called when the dialog is closed.\n * @property {(selected: string | string[] | undefined, name: string) => void} onOk Handler that is called when the user presses OK.\n * @property {{headerID: string; dialog: string; content: string}} [classes] The styling class names.\n *\n * @extends {React.Component<DialogSelectIDProps>}\n */\nclass DialogSelectID extends React.Component {\n /**\n * @param {DialogSelectIDProps} props\n */\n constructor(props) {\n super(props);\n this.dialogName = this.props.dialogName || 'default';\n this.dialogName = 'SelectID.' + this.dialogName;\n\n this.filters = (window._localStorage || window.localStorage).getItem(this.dialogName) || '{}';\n\n try {\n this.filters = JSON.parse(this.filters);\n } catch (e) {\n this.filters = {};\n }\n\n let selected = this.props.selected || [];\n if (typeof selected !== 'object') {\n selected = [selected];\n }\n selected = selected.filter(id => id);\n\n this.state = {\n selected,\n name: '',\n isMobile: window.innerWidth < 800\n };\n }\n\n handleCancel() {\n this.props.onClose();\n };\n\n handleOk() {\n this.props.onOk(this.props.multiSelect ? this.state.selected : this.state.selected[0] || '', this.state.name);\n this.props.onClose();\n };\n\n render() {\n let title;\n if (this.state.name || this.state.selected.length) {\n if (this.state.selected.length === 1) {\n title = [\n <span key=\"selected\">{ I18n.t('ra_Selected') } </span>,\n <span key=\"id\" className={ this.props.classes.headerID }>{\n (this.state.name || this.state.selected) + (this.state.name ? ' [' + this.state.selected + ']' : '')\n }</span>\n ];\n } else {\n title = [\n <span key=\"selected\">{ I18n.t('ra_Selected') } </span>,\n <span key=\"id\" className={ this.props.classes.headerID }>{\n I18n.t('%s items', this.state.selected.length)\n }</span>\n ];\n }\n } else {\n title = this.props.title || I18n.t('ra_Please select object ID...');\n }\n\n return <Dialog\n onClose={() => {}}\n maxWidth={false}\n classes={{paper: Utils.clsx(this.props.classes.dialog, this.props.classes.dialogMobile)}}\n fullWidth={true}\n open={true}\n aria-labelledby=\"selectid-dialog-title\"\n >\n <DialogTitle id=\"selectid-dialog-title\" classes={{root: this.props.classes.titleRoot}}>{ title }</DialogTitle>\n <DialogContent className={Utils.clsx(this.props.classes.content, this.props.classes.contentMobile)}>\n <ObjectBrowser\n foldersFirst={ this.props.foldersFirst }\n imagePrefix={ this.props.imagePrefix || this.props.prefix } // prefix is for back compatibility\n defaultFilters={ this.filters }\n dialogName={this.dialogName}\n showExpertButton={ this.props.showExpertButton !== undefined ? this.props.showExpertButton : true }\n style={ {width: '100%', height: '100%'} }\n columns={ this.props.columns || ['name', 'type', 'role', 'room', 'func', 'val'] }\n types={ this.props.types || ['state'] }\n t={ I18n.t }\n lang={ this.props.lang || I18n.getLanguage() }\n socket={ this.props.socket }\n selected={ this.state.selected }\n multiSelect={ this.props.multiSelect }\n notEditable={ this.props.notEditable === undefined ? true : this.props.notEditable }\n name={ this.state.name }\n themeName={ this.props.themeName }\n themeType={ this.props.themeType }\n customFilter={ this.props.customFilter }\n onFilterChanged={ filterConfig => {\n this.filters = filterConfig;\n (window._localStorage || window.localStorage).setItem(this.dialogName, JSON.stringify(filterConfig));\n } }\n onSelect={ (selected, name, isDouble) => {\n if (JSON.stringify(selected) !== JSON.stringify(this.state.selected)) {\n this.setState({selected, name}, () =>\n isDouble && this.handleOk());\n } else if (isDouble) {\n this.handleOk();\n }\n } }\n filterFunc={this.props.filterFunc}\n />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={ () => this.handleOk() } startIcon={<IconOk />} disabled={ !this.state.selected.length } color=\"primary\">{ this.props.ok || I18n.t('ra_Ok') }</Button>\n <Button color=\"grey\" variant=\"contained\" onClick={ () => this.handleCancel() } startIcon={<IconCancel />}>{ this.props.cancel || I18n.t('ra_Cancel') }</Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nDialogSelectID.propTypes = {\n dialogName: PropTypes.string, // where to store settings in localStorage\n classes: PropTypes.object,\n notEditable: PropTypes.bool,\n onClose: PropTypes.func.isRequired,\n onOk: PropTypes.func.isRequired,\n title: PropTypes.string,\n lang: PropTypes.string,\n foldersFirst: PropTypes.bool,\n isFloatComma: PropTypes.bool,\n dateFormat: PropTypes.string,\n selected: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.array\n ]),\n customFilter: PropTypes.object, // optional {common: {custom: true}} or {common: {custom: 'sql.0'}}\n statesOnly: PropTypes.bool,\n socket: PropTypes.object.isRequired,\n cancel: PropTypes.string,\n imagePrefix: PropTypes.string,\n ok: PropTypes.string,\n themeName: PropTypes.string,\n themeType: PropTypes.string,\n showExpertButton: PropTypes.bool,\n multiSelect: PropTypes.bool,\n types: PropTypes.array, // optional ['state', 'instance', 'channel']\n columns: PropTypes.array, // optional ['name', 'type', 'role', 'room', 'func', 'val', 'buttons']\n\n filterFunc: PropTypes.func, // function to filter out all unnecessary objects. It cannot be used together with \"types\"\n // Example for function: `obj => obj.common && obj.common.type === 'boolean'` to show only boolean states\n};\n\n/** @type {typeof DialogSelectID} */\nconst _export = withStyles(styles)(DialogSelectID);\nexport default _export;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,QAAQ,EAAE;MACNC,UAAU,EAAE,MADN;MAENC,SAAS,EAAE;IAFL,CADW;IAKrBC,MAAM,EAAE;MACJC,MAAM,EAAE;IADJ,CALa;IAQrBC,YAAY,EAAE;MACVC,OAAO,EAAE,CADC;MAEVC,KAAK,EAAE,MAFG;MAGVC,QAAQ,EAAE,MAHA;MAIVC,SAAS,EAAE,mBAJD;MAKVL,MAAM,EAAE;IALE,CARO;IAerBM,OAAO,EAAE;MACLN,MAAM,EAAE,MADH;MAELO,QAAQ,EAAE;IAFL,CAfY;IAmBrBC,aAAa,EAAE;MACXN,OAAO,EAAE;IADE,CAnBM;IAsBrBO,SAAS,EAAE;MACPC,UAAU,EAAE,QADL;MAEPP,KAAK,EAAE,mBAFA;MAGPI,QAAQ,EAAE,QAHH;MAIPI,OAAO,EAAE,cAJF;MAKPC,YAAY,EAAE;IALP;EAtBU,CAAL;AAAA,CAApB;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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gB,EAE1BD,qBAAA,CAAUS,KAFgB,CAApB,CAXa;EAevBvB,YAAY,EAAEc,qBAAA,CAAUE,MAfD;EAeS;EAChCQ,UAAU,EAAEV,qBAAA,CAAUG,IAhBC;EAiBvBrB,MAAM,EAAEkB,qBAAA,CAAUE,MAAV,CAAiBG,UAjBF;EAkBvBT,MAAM,EAAEI,qBAAA,CAAUC,MAlBK;EAmBvB3B,WAAW,EAAE0B,qBAAA,CAAUC,MAnBA;EAoBvBP,EAAE,EAAEM,qBAAA,CAAUC,MApBS;EAqBvBjB,SAAS,EAAEgB,qBAAA,CAAUC,MArBE;EAsBvBhB,SAAS,EAAEe,qBAAA,CAAUC,MAtBE;EAuBvBzB,gBAAgB,EAAEwB,qBAAA,CAAUG,IAvBL;EAwBvBxC,WAAW,EAAEqC,qBAAA,CAAUG,IAxBA;EAyBvBxB,KAAK,EAAEqB,qBAAA,CAAUS,KAzBM;EAyBG;EAC1B/B,OAAO,EAAEsB,qBAAA,CAAUS,KA1BI;EA0BG;EAE1BhB,UAAU,EAAEO,qBAAA,CAAUI,IA5BC,CA4Ba;EACA;;AA7Bb,CAA3B;AAgCA;;AACA,IAAMO,OAAO,GAAG,IAAAC,sBAAA,EAAWxF,MAAX,EAAmBmB,cAAnB,CAAhB;;eACeoE,O"}
|
|
1
|
+
{"version":3,"file":"SelectID.js","names":["styles","theme","headerID","fontWeight","fontStyle","dialog","height","dialogMobile","padding","width","maxWidth","maxHeight","content","overflow","contentMobile","titleRoot","whiteSpace","display","textOverflow","DialogSelectID","props","dialogName","filters","window","_localStorage","localStorage","getItem","JSON","parse","e","selected","filter","id","state","name","isMobile","innerWidth","onClose","onOk","multiSelect","title","length","I18n","t","classes","paper","Utils","clsx","root","foldersFirst","imagePrefix","prefix","showExpertButton","undefined","expertMode","columns","types","lang","getLanguage","socket","notEditable","themeName","themeType","customFilter","filterConfig","setItem","stringify","isDouble","setState","handleOk","filterFunc","ok","handleCancel","cancel","React","Component","propTypes","PropTypes","string","object","bool","func","isRequired","isFloatComma","dateFormat","oneOfType","array","statesOnly","_export","withStyles"],"sources":["SelectID.js"],"sourcesContent":["/**\n * Copyright 2018-2022 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n **/\n// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport withStyles from '@mui/styles/withStyles';\n\nimport Button from '@mui/material/Button';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogActions from '@mui/material/DialogActions';\nimport Dialog from '@mui/material/Dialog';\n\nimport IconCancel from '@mui/icons-material/Cancel';\nimport IconOk from '@mui/icons-material/Check';\n\nimport Utils from '../Components/Utils';\nimport I18n from '../i18n';\nimport ObjectBrowser from '../Components/ObjectBrowser';\n\nconst styles = theme => ({\n headerID: {\n fontWeight: 'bold',\n fontStyle: 'italic'\n },\n dialog: {\n height: '95%'\n },\n dialogMobile: {\n padding: 4,\n width: '100%',\n maxWidth: '100%',\n maxHeight: 'calc(100% - 16px)',\n height: '100%'\n },\n content: {\n height: '100%',\n overflow: 'hidden'\n },\n contentMobile: {\n padding: '8px 4px'\n },\n titleRoot: {\n whiteSpace: 'nowrap',\n width: 'calc(100% - 72px)',\n overflow: 'hidden',\n display: 'inline-block',\n textOverflow: 'ellipsis',\n }\n});\n\n/**\n * @typedef {object} DialogSelectIDProps\n * @property {string} [dialogName] The internal name of the dialog; default: \"default\"\n * @property {string} [title] The dialog title; default: Please select object ID... (translated)\n * @property {boolean} [multiSelect] Set to true to allow the selection of multiple IDs.\n * @property {boolean} [foldersFirst] Show folders before any leaves.\n * @property {string} [imagePrefix] Prefix (default: '.')\n * @property {boolean} [showExpertButton] Show the expert button?\n * @property {import('../Components/types').ObjectBrowserColumn[]} [columns] Columns to display; default: 'name', 'type', 'role', 'room', 'func', 'val'\n * @property {import('../Components/types').ObjectBrowserType[]} [types] Object types to show; default: 'state' only\n * @property {ioBroker.Languages} [lang] The language.\n * @property {import('../Connection').default} socket The socket connection.\n * @property {boolean} [notEditable] Can't objects be edited? (default: true)\n * @property {string} [themeName] Theme name.\n * @property {string} [themeType] Theme type.\n * @property {import('../Components/types').ObjectBrowserCustomFilter} [customFilter] Custom filter.\n * @property {string | string[]} [selected] The selected IDs.\n * @property {string} [ok] The ok button text; default: OK (translated)\n * @property {string} [cancel] The cancel button text; default: Cancel (translated)\n * @property {() => void} onClose Close handler that is always called when the dialog is closed.\n * @property {(selected: string | string[] | undefined, name: string) => void} onOk Handler that is called when the user presses OK.\n * @property {{headerID: string; dialog: string; content: string}} [classes] The styling class names.\n *\n * @extends {React.Component<DialogSelectIDProps>}\n */\nclass DialogSelectID extends React.Component {\n /**\n * @param {DialogSelectIDProps} props\n */\n constructor(props) {\n super(props);\n this.dialogName = this.props.dialogName || 'default';\n this.dialogName = 'SelectID.' + this.dialogName;\n\n this.filters = (window._localStorage || window.localStorage).getItem(this.dialogName) || '{}';\n\n try {\n this.filters = JSON.parse(this.filters);\n } catch (e) {\n this.filters = {};\n }\n\n let selected = this.props.selected || [];\n if (typeof selected !== 'object') {\n selected = [selected];\n }\n selected = selected.filter(id => id);\n\n this.state = {\n selected,\n name: '',\n isMobile: window.innerWidth < 800\n };\n }\n\n handleCancel() {\n this.props.onClose();\n };\n\n handleOk() {\n this.props.onOk(this.props.multiSelect ? this.state.selected : this.state.selected[0] || '', this.state.name);\n this.props.onClose();\n };\n\n render() {\n let title;\n if (this.state.name || this.state.selected.length) {\n if (this.state.selected.length === 1) {\n title = [\n <span key=\"selected\">{ I18n.t('ra_Selected') } </span>,\n <span key=\"id\" className={ this.props.classes.headerID }>{\n (this.state.name || this.state.selected) + (this.state.name ? ' [' + this.state.selected + ']' : '')\n }</span>\n ];\n } else {\n title = [\n <span key=\"selected\">{ I18n.t('ra_Selected') } </span>,\n <span key=\"id\" className={ this.props.classes.headerID }>{\n I18n.t('%s items', this.state.selected.length)\n }</span>\n ];\n }\n } else {\n title = this.props.title || I18n.t('ra_Please select object ID...');\n }\n\n return <Dialog\n onClose={() => {}}\n maxWidth={false}\n classes={{paper: Utils.clsx(this.props.classes.dialog, this.props.classes.dialogMobile)}}\n fullWidth={true}\n open={true}\n aria-labelledby=\"selectid-dialog-title\"\n >\n <DialogTitle id=\"selectid-dialog-title\" classes={{root: this.props.classes.titleRoot}}>{ title }</DialogTitle>\n <DialogContent className={Utils.clsx(this.props.classes.content, this.props.classes.contentMobile)}>\n <ObjectBrowser\n foldersFirst={ this.props.foldersFirst }\n imagePrefix={ this.props.imagePrefix || this.props.prefix } // prefix is for back compatibility\n defaultFilters={ this.filters }\n dialogName={this.dialogName}\n showExpertButton={ this.props.showExpertButton !== undefined ? this.props.showExpertButton : true }\n expertMode={ this.props.expertMode }\n style={ {width: '100%', height: '100%'} }\n columns={ this.props.columns || ['name', 'type', 'role', 'room', 'func', 'val'] }\n types={ this.props.types || ['state'] }\n t={ I18n.t }\n lang={ this.props.lang || I18n.getLanguage() }\n socket={ this.props.socket }\n selected={ this.state.selected }\n multiSelect={ this.props.multiSelect }\n notEditable={ this.props.notEditable === undefined ? true : this.props.notEditable }\n name={ this.state.name }\n themeName={ this.props.themeName }\n themeType={ this.props.themeType }\n customFilter={ this.props.customFilter }\n onFilterChanged={ filterConfig => {\n this.filters = filterConfig;\n (window._localStorage || window.localStorage).setItem(this.dialogName, JSON.stringify(filterConfig));\n } }\n onSelect={(selected, name, isDouble) => {\n if (JSON.stringify(selected) !== JSON.stringify(this.state.selected)) {\n this.setState({selected, name}, () =>\n isDouble && this.handleOk());\n } else if (isDouble) {\n this.handleOk();\n }\n }}\n filterFunc={this.props.filterFunc}\n />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={ () => this.handleOk() } startIcon={<IconOk />} disabled={ !this.state.selected.length } color=\"primary\">{ this.props.ok || I18n.t('ra_Ok') }</Button>\n <Button color=\"grey\" variant=\"contained\" onClick={ () => this.handleCancel() } startIcon={<IconCancel />}>{ this.props.cancel || I18n.t('ra_Cancel') }</Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nDialogSelectID.propTypes = {\n dialogName: PropTypes.string, // where to store settings in localStorage\n classes: PropTypes.object,\n notEditable: PropTypes.bool,\n onClose: PropTypes.func.isRequired,\n onOk: PropTypes.func.isRequired,\n title: PropTypes.string,\n lang: PropTypes.string,\n foldersFirst: PropTypes.bool,\n isFloatComma: PropTypes.bool,\n dateFormat: PropTypes.string,\n selected: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.array\n ]),\n customFilter: PropTypes.object, // optional {common: {custom: true}} or {common: {custom: 'sql.0'}}\n statesOnly: PropTypes.bool,\n socket: PropTypes.object.isRequired,\n cancel: PropTypes.string,\n imagePrefix: PropTypes.string,\n ok: PropTypes.string,\n themeName: PropTypes.string,\n themeType: PropTypes.string,\n showExpertButton: PropTypes.bool,\n expertMode: PropTypes.bool, // force expert mode\n multiSelect: PropTypes.bool,\n types: PropTypes.array, // optional ['state', 'instance', 'channel']\n columns: PropTypes.array, // optional ['name', 'type', 'role', 'room', 'func', 'val', 'buttons']\n\n filterFunc: PropTypes.func, // function to filter out all unnecessary objects. It cannot be used together with \"types\"\n // Example for function: `obj => obj.common && obj.common.type === 'boolean'` to show only boolean states\n};\n\n/** @type {typeof DialogSelectID} */\nconst _export = withStyles(styles)(DialogSelectID);\nexport default _export;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,QAAQ,EAAE;MACNC,UAAU,EAAE,MADN;MAENC,SAAS,EAAE;IAFL,CADW;IAKrBC,MAAM,EAAE;MACJC,MAAM,EAAE;IADJ,CALa;IAQrBC,YAAY,EAAE;MACVC,OAAO,EAAE,CADC;MAEVC,KAAK,EAAE,MAFG;MAGVC,QAAQ,EAAE,MAH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AAA,CAAUI,IA7BC,CA6Ba;EACA;;AA9Bb,CAA3B;AAiCA;;AACA,IAAMO,OAAO,GAAG,IAAAC,sBAAA,EAAWzF,MAAX,EAAmBmB,cAAnB,CAAhB;;eACeqE,O"}
|
package/README.md
CHANGED
|
@@ -642,6 +642,15 @@ If you still have questions, try to find an answer [here](https://mui.com/guides
|
|
|
642
642
|
-->
|
|
643
643
|
|
|
644
644
|
## Changelog
|
|
645
|
+
### 3.1.21 (2022-07-22)
|
|
646
|
+
* (bluefox) Added i18n tools for development
|
|
647
|
+
|
|
648
|
+
### 3.1.20 (2022-07-14)
|
|
649
|
+
* (bluefox) Allowed to show select dialog with the expert mode enabled
|
|
650
|
+
|
|
651
|
+
### 3.1.19 (2022-07-08)
|
|
652
|
+
* (bluefox) Allowed to extend translations for all languages together
|
|
653
|
+
|
|
645
654
|
### 3.1.18 (2022-07-06)
|
|
646
655
|
* (bluefox) Added translation
|
|
647
656
|
|
package/i18n.js
CHANGED
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
|
|
12
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -36,6 +38,11 @@ var I18n = /*#__PURE__*/function () {
|
|
|
36
38
|
* @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}
|
|
37
39
|
*/
|
|
38
40
|
|
|
41
|
+
/**
|
|
42
|
+
* List of unknown translations during development.
|
|
43
|
+
* @type {string[]}
|
|
44
|
+
*/
|
|
45
|
+
|
|
39
46
|
/**
|
|
40
47
|
* The currently displayed language.
|
|
41
48
|
* @type {ioBroker.Languages}
|
|
@@ -64,19 +71,26 @@ var I18n = /*#__PURE__*/function () {
|
|
|
64
71
|
value: function extendTranslations(words, lang) {
|
|
65
72
|
try {
|
|
66
73
|
if (!lang) {
|
|
67
|
-
|
|
68
|
-
Object.keys(words
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!I18n.translations[lang][word]) {
|
|
74
|
-
I18n.translations[lang][word] = words[word][lang];
|
|
75
|
-
} else if (I18n.translations[lang][word] !== words[word][lang]) {
|
|
76
|
-
console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word][lang]));
|
|
77
|
-
}
|
|
74
|
+
if (words.en && words.de && words.ru) {
|
|
75
|
+
Object.keys(words).forEach(function (lang) {
|
|
76
|
+
I18n.translations[lang] = I18n.translations[lang] || {};
|
|
77
|
+
Object.assign(I18n.translations[lang], words[lang]);
|
|
78
78
|
});
|
|
79
|
-
}
|
|
79
|
+
} else {
|
|
80
|
+
Object.keys(words).forEach(function (word) {
|
|
81
|
+
Object.keys(words[word]).forEach(function (lang) {
|
|
82
|
+
if (!I18n.translations[lang]) {
|
|
83
|
+
console.warn("Used unknown language: ".concat(lang));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!I18n.translations[lang][word]) {
|
|
87
|
+
I18n.translations[lang][word] = words[word][lang];
|
|
88
|
+
} else if (I18n.translations[lang][word] !== words[word][lang]) {
|
|
89
|
+
console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word][lang]));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
80
94
|
} else {
|
|
81
95
|
if (!I18n.translations[lang]) {
|
|
82
96
|
console.warn("Used unknown language: ".concat(lang));
|
|
@@ -134,7 +148,11 @@ var I18n = /*#__PURE__*/function () {
|
|
|
134
148
|
if (w) {
|
|
135
149
|
word = w;
|
|
136
150
|
} else {
|
|
137
|
-
I18n.
|
|
151
|
+
if (!I18n.unknownTranslations.includes(word)) {
|
|
152
|
+
I18n.unknownTranslations.push(word);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
!I18n._disableWarning && console.log("Translate: ".concat(word));
|
|
138
156
|
}
|
|
139
157
|
}
|
|
140
158
|
|
|
@@ -149,6 +167,42 @@ var I18n = /*#__PURE__*/function () {
|
|
|
149
167
|
|
|
150
168
|
return word;
|
|
151
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Show non-translated words
|
|
172
|
+
* Required during development
|
|
173
|
+
* @param {string | RegExp} filter filter words
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
}, {
|
|
177
|
+
key: "i18nShow",
|
|
178
|
+
value: function i18nShow(filter) {
|
|
179
|
+
/**
|
|
180
|
+
* List words with their translations.
|
|
181
|
+
* @type {Record<string, string>}
|
|
182
|
+
*/
|
|
183
|
+
var result = {};
|
|
184
|
+
|
|
185
|
+
if (!filter) {
|
|
186
|
+
I18n.unknownTranslations.forEach(function (word) {
|
|
187
|
+
result[word] = word;
|
|
188
|
+
});
|
|
189
|
+
console.log(JSON.stringify(result, null, 2));
|
|
190
|
+
} else if (typeof filter === 'string') {
|
|
191
|
+
I18n.unknownTranslations.forEach(function (word) {
|
|
192
|
+
if (word.startsWith(filter)) {
|
|
193
|
+
result[word] = word.replace(filter, '');
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
console.log(JSON.stringify(result, null, 2));
|
|
197
|
+
} else if ((0, _typeof2["default"])(filter) === 'object') {
|
|
198
|
+
I18n.unknownTranslations.forEach(function (word) {
|
|
199
|
+
if (filter.test(word)) {
|
|
200
|
+
result[word] = word;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
console.log(JSON.stringify(result, null, 2));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
152
206
|
/**
|
|
153
207
|
* Disable warning about non-translated words
|
|
154
208
|
* Required during development
|
|
@@ -162,7 +216,15 @@ var I18n = /*#__PURE__*/function () {
|
|
|
162
216
|
}
|
|
163
217
|
}]);
|
|
164
218
|
return I18n;
|
|
165
|
-
}();
|
|
219
|
+
}(); // install global handlers
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
(0, _defineProperty2["default"])(I18n, "translations", {});
|
|
223
|
+
(0, _defineProperty2["default"])(I18n, "unknownTranslations", []);
|
|
224
|
+
(0, _defineProperty2["default"])(I18n, "lang", window.sysLang || 'en');
|
|
225
|
+
(0, _defineProperty2["default"])(I18n, "_disableWarning", false);
|
|
226
|
+
window.i18nShow = I18n.i18nShow;
|
|
227
|
+
window.i18nDisableWarning = I18n.disableWarning;
|
|
166
228
|
/*I18n.translations = {
|
|
167
229
|
'en': require('./i18n/en'),
|
|
168
230
|
'ru': require('./i18n/ru'),
|
|
@@ -171,10 +233,6 @@ var I18n = /*#__PURE__*/function () {
|
|
|
171
233
|
I18n.fallbacks = true;
|
|
172
234
|
I18n.t = function () {};*/
|
|
173
235
|
|
|
174
|
-
|
|
175
|
-
(0, _defineProperty2["default"])(I18n, "translations", {});
|
|
176
|
-
(0, _defineProperty2["default"])(I18n, "lang", window.sysLang || 'en');
|
|
177
|
-
(0, _defineProperty2["default"])(I18n, "_disableWarning", false);
|
|
178
236
|
var _default = I18n;
|
|
179
237
|
exports["default"] = _default;
|
|
180
238
|
//# sourceMappingURL=i18n.js.map
|
package/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":["I18n","lang","words","Object","keys","forEach","word","translations","console","warn","e","error","translation","w","_disableWarning","log","args","arg","replace","disable","window","sysLang"],"sources":["i18n.js"],"sourcesContent":["/***\n * Copyright 2018-2022 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n ***/\n\n /**\n * Translation string management.\n */\nclass I18n {\n /**\n * List of all languages with their translations.\n * @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}\n */\n static translations = {};\n\n /**\n * The currently displayed language.\n * @type {ioBroker.Languages}\n */\n static lang = window.sysLang || 'en';\n\n static _disableWarning = false;\n\n /**\n * Set the language to display.\n * @param {ioBroker.Languages} lang\n */\n static setLanguage(lang) {\n if (lang) {\n I18n.lang = lang;\n }\n }\n\n /**\n * Add translations\n * User can provide two types of structures:\n * - {\"word1\": \"translated word1\", \"word2\": \"translated word2\"}, but in this case the lang must be provided\n * - {\"word1\": {\"en\": \"translated en word1\", \"de\": \"translated de word1\"}, \"word2\": {\"en\": \"translated en word2\", \"de\": \"translated de word2\"}}, but no lang must be provided\n * @param {object} words additional words for specific language\n * @param {ioBroker.Languages} lang\n */\n static extendTranslations(words, lang) {\n try {\n if (!lang) {\n Object.keys(words).forEach(word => {\n Object.keys(words[word]).forEach(lang => {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word][lang];\n } else if (I18n.translations[lang][word] !== words[word][lang]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word][lang]}`);\n }\n });\n });\n } else {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n I18n.translations[lang] = I18n.translations[lang] || {};\n Object.keys(words)\n .forEach(word => {\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word];\n } else if (I18n.translations[lang][word] !== words[word]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word]}`);\n }\n });\n }\n } catch (e) {\n console.error(`Cannot apply translations: ${e}`);\n }\n }\n\n /**\n * Sets all translations (in all languages).\n * @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations\n */\n static setTranslations(translations) {\n if (translations) {\n I18n.translations = translations;\n }\n }\n\n /**\n * Get the currently chosen language.\n * @returns {ioBroker.Languages} The current language.\n */\n static getLanguage() {\n return I18n.lang;\n }\n\n /**\n * Translate the given string to the selected language.\n * @param {string} word The (key) word to look up the string.\n * @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurrences of %s\n */\n static t(word, ...args) {\n const translation = I18n.translations[I18n.lang];\n if (translation) {\n const w = translation[word];\n if (w) {\n word = w;\n } else {\n I18n._disableWarning && console.log(`Translate: ${word}`);\n }\n }\n for (const arg of args) {\n word = word.replace('%s', arg);\n }\n return word;\n }\n\n /**\n * Disable warning about non-translated words\n * Required during development\n * @param {boolean} disable Do the warning should be disabled\n */\n static disableWarning(disable) {\n I18n._disableWarning = !!disable;\n }\n}\n\n/*I18n.translations = {\n 'en': require('./i18n/en'),\n 'ru': require('./i18n/ru'),\n 'de': require('./i18n/de'),\n};\nI18n.fallbacks = true;\nI18n.t = function () {};*/\n\nexport default I18n;"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;IACMA,I;;;;;;;;IACF;AACJ;AACA;AACA;;IAGI;AACJ;AACA;AACA;;IAKI;AACJ;AACA;AACA;IACI,qBAAmBC,IAAnB,EAAyB;MACrB,IAAIA,IAAJ,EAAU;QACND,IAAI,CAACC,IAAL,GAAYA,IAAZ;MACH;IACJ;IAEA;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;;WACK,4BAA0BC,KAA1B,EAAiCD,IAAjC,EAAuC;MACnC,IAAI;QACA,IAAI,CAACA,IAAL,EAAW;UACPE,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,OAAnB,CAA2B,UAAAC,IAAI,EAAI;YAC/BH,MAAM,CAACC,IAAP,CAAYF,KAAK,CAACI,IAAD,CAAjB,EAAyBD,OAAzB,CAAiC,UAAAJ,IAAI,EAAI;cACrC,IAAI,CAACD,IAAI,CAACO,YAAL,CAAkBN,IAAlB,CAAL,EAA8B;gBAC1BO,OAAO,CAACC,IAAR,kCAAuCR,IAAvC;cACH;;cACD,IAAI,CAACD,IAAI,CAACO,YAAL,CAAkBN,IAAlB,EAAw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UACJ,CAPL;QAQH;MACJ,CA5BD,CA4BE,OAAOI,CAAP,EAAU;QACRF,OAAO,CAACG,KAAR,sCAA4CD,CAA5C;MACH;IACL;IAED;AACJ;AACA;AACA;;;;WACI,yBAAuBH,YAAvB,EAAqC;MACjC,IAAIA,YAAJ,EAAkB;QACdP,IAAI,CAACO,YAAL,GAAoBA,YAApB;MACH;IACJ;IAED;AACJ;AACA;AACA;;;;WACI,uBAAqB;MACjB,OAAOP,IAAI,CAACC,IAAZ;IACH;IAED;AACJ;AACA;AACA;AACA;;;;WACI,WAASK,IAAT,EAAwB;MACpB,IAAMM,WAAW,GAAGZ,IAAI,CAACO,YAAL,CAAkBP,IAAI,CAACC,IAAvB,CAApB;;MACA,IAAIW,WAAJ,EAAiB;QACb,IAAMC,CAAC,GAAGD,WAAW,CAACN,IAAD,CAArB;;QACA,IAAIO,CAAJ,EAAO;UACHP,IAAI,GAAGO,CAAP;QACH,CAFD,MAEO;UACHb,IAAI,CAACc,eAAL,IAAwBN,OAAO,CAACO,GAAR,sBAA0BT,IAA1B,EAAxB;QACH;MACJ;;MATmB,kCAANU,IAAM;QAANA,IAAM;MAAA;;MAUpB,yBAAkBA,IAAlB,2BAAwB;QAAnB,IAAMC,GAAG,YAAT;QACDX,IAAI,GAAGA,IAAI,CAACY,OAAL,CAAa,IAAb,EAAmBD,GAAnB,CAAP;MACH;;MACD,OAAOX,IAAP;IACH;IAEA;AACL;AACA;AACA;AACA;;;;WACI,wBAAsBa,OAAtB,EAA+B;MAC3BnB,IAAI,CAACc,eAAL,GAAuB,CAAC,CAACK,OAAzB;IACH;;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;;;iCA1HMnB,I,kBAKoB,E;iCALpBA,I,UAWYoB,MAAM,CAACC,OAAP,IAAkB,I;iCAX9BrB,I,qBAauB,K;eA+GdA,I"}
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["I18n","lang","words","en","de","ru","Object","keys","forEach","translations","assign","word","console","warn","e","error","translation","w","unknownTranslations","includes","push","_disableWarning","log","args","arg","replace","filter","result","JSON","stringify","startsWith","test","disable","window","sysLang","i18nShow","i18nDisableWarning","disableWarning"],"sources":["i18n.js"],"sourcesContent":["/***\n * Copyright 2018-2022 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n ***/\n\n /**\n * Translation string management.\n */\nclass I18n {\n /**\n * List of all languages with their translations.\n * @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}\n */\n static translations = {};\n\n /**\n * List of unknown translations during development.\n * @type {string[]}\n */\n static unknownTranslations = [];\n\n /**\n * The currently displayed language.\n * @type {ioBroker.Languages}\n */\n static lang = window.sysLang || 'en';\n\n static _disableWarning = false;\n\n /**\n * Set the language to display.\n * @param {ioBroker.Languages} lang\n */\n static setLanguage(lang) {\n if (lang) {\n I18n.lang = lang;\n }\n }\n\n /**\n * Add translations\n * User can provide two types of structures:\n * - {\"word1\": \"translated word1\", \"word2\": \"translated word2\"}, but in this case the lang must be provided\n * - {\"word1\": {\"en\": \"translated en word1\", \"de\": \"translated de word1\"}, \"word2\": {\"en\": \"translated en word2\", \"de\": \"translated de word2\"}}, but no lang must be provided\n * @param {object} words additional words for specific language\n * @param {ioBroker.Languages} lang\n */\n static extendTranslations(words, lang) {\n try {\n if (!lang) {\n if (words.en && words.de && words.ru) {\n Object.keys(words).forEach(lang => {\n I18n.translations[lang] = I18n.translations[lang] || {};\n Object.assign(I18n.translations[lang], words[lang]);\n });\n } else {\n Object.keys(words).forEach(word => {\n Object.keys(words[word]).forEach(lang => {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word][lang];\n } else if (I18n.translations[lang][word] !== words[word][lang]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word][lang]}`);\n }\n });\n });\n }\n } else {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n I18n.translations[lang] = I18n.translations[lang] || {};\n Object.keys(words)\n .forEach(word => {\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word];\n } else if (I18n.translations[lang][word] !== words[word]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word]}`);\n }\n });\n }\n } catch (e) {\n console.error(`Cannot apply translations: ${e}`);\n }\n }\n\n /**\n * Sets all translations (in all languages).\n * @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations\n */\n static setTranslations(translations) {\n if (translations) {\n I18n.translations = translations;\n }\n }\n\n /**\n * Get the currently chosen language.\n * @returns {ioBroker.Languages} The current language.\n */\n static getLanguage() {\n return I18n.lang;\n }\n\n /**\n * Translate the given string to the selected language.\n * @param {string} word The (key) word to look up the string.\n * @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurrences of %s\n */\n static t(word, ...args) {\n const translation = I18n.translations[I18n.lang];\n if (translation) {\n const w = translation[word];\n if (w) {\n word = w;\n } else {\n if (!I18n.unknownTranslations.includes(word)) {\n I18n.unknownTranslations.push(word);\n }\n\n !I18n._disableWarning && console.log(`Translate: ${word}`);\n }\n }\n for (const arg of args) {\n word = word.replace('%s', arg);\n }\n return word;\n }\n\n /**\n * Show non-translated words\n * Required during development\n * @param {string | RegExp} filter filter words\n */\n static i18nShow(filter) {\n /**\n * List words with their translations.\n * @type {Record<string, string>}\n */\n const result = {};\n if (!filter) {\n I18n.unknownTranslations.forEach(word => {\n result[word] = word;\n });\n console.log(JSON.stringify(result, null, 2));\n } else if (typeof filter === 'string') {\n I18n.unknownTranslations.forEach(word => {\n if (word.startsWith(filter)) {\n result[word] = word.replace(filter, '');\n }\n });\n console.log(JSON.stringify(result, null, 2));\n } else if (typeof filter === 'object') {\n I18n.unknownTranslations.forEach(word => {\n if (filter.test(word)) {\n result[word] = word;\n }\n });\n console.log(JSON.stringify(result, null, 2));\n }\n }\n\n /**\n * Disable warning about non-translated words\n * Required during development\n * @param {boolean} disable Do the warning should be disabled\n */\n static disableWarning(disable) {\n I18n._disableWarning = !!disable;\n }\n}\n\n// install global handlers\nwindow.i18nShow = I18n.i18nShow;\nwindow.i18nDisableWarning = I18n.disableWarning;\n\n\n/*I18n.translations = {\n 'en': require('./i18n/en'),\n 'ru': require('./i18n/ru'),\n 'de': require('./i18n/de'),\n};\nI18n.fallbacks = true;\nI18n.t = function () {};*/\n\nexport default I18n;"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEC;AACD;AACA;IACMA,I;;;;;;;;IACF;AACJ;AACA;AACA;;IAGK;AACL;AACA;AACA;;IAGI;AACJ;AACA;AACA;;IAKI;AACJ;AACA;AACA;IACI,qBAAmBC,IAAnB,EAAyB;MACrB,IAAIA,IAAJ,EAAU;QACND,IAAI,CAACC,IAAL,GAAYA,IAAZ;MACH;IACJ;IAEA;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;;;WACK,4BAA0BC,KAA1B,EAAiCD,IAAjC,EAAuC;MACnC,IAAI;QACA,IAAI,CAACA,IAAL,EAAW;UACP,IAAIC,KAAK,CAACC,EAAN,IAAYD,KAAK,CAACE,EAAlB,IAAwBF,KAAK,CAACG,EAAlC,EAAsC;YAClCC,MAAM,CAACC,IAAP,CAAYL,KAAZ,EAAmBM,OAAnB,CAA2B,UAAAP,IAAI,EAAI;cAC/BD,IAAI,CAACS,YAAL,CAAkBR,IAAlB,IAA0BD,IAAI,CAACS,YAAL,CAAkBR,IAAlB,KAA2B,EAArD;cACAK,MAAM,CAACI,MAAP,CAAcV,IAAI,CAACS,YAAL,CAAkBR,IAAlB,CAAd,EAAuCC,KAAK,CAACD,IAAD,CAA5C;YACH,CAHD;UAIH,CALD,MAKO;YACHK,MAAM,CAACC,IAAP,CAAYL,KAAZ,EAAmBM,OAAnB,CAA2B,UAAAG,IAAI,EAAI;cAC/BL,MAAM,CAACC,IAAP,CAAYL,KAAK,CAACS,IAA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,CAACqB,eAAL,GAAuB,CAAC,CAACW,OAAzB;IACH;;;KAGL;;;iCAtKMhC,I,kBAKoB,E;iCALpBA,I,yBAW4B,E;iCAX5BA,I,UAiBYiC,MAAM,CAACC,OAAP,IAAkB,I;iCAjB9BlC,I,qBAmBuB,K;AAoJ7BiC,MAAM,CAACE,QAAP,GAAkBnC,IAAI,CAACmC,QAAvB;AACAF,MAAM,CAACG,kBAAP,GAA4BpC,IAAI,CAACqC,cAAjC;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;eAEerC,I"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/adapter-react-v5",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.21",
|
|
4
4
|
"description": "React classes to develop admin interfaces for ioBroker with react.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"homepage": "https://github.com/ioBroker/adapter-react-v5#readme",
|
|
28
28
|
"devDependencies": {},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@emotion/react": "^11.9.
|
|
31
|
-
"@emotion/styled": "^11.
|
|
32
|
-
"@mui/icons-material": "^5.8.
|
|
33
|
-
"@mui/material": "^5.
|
|
34
|
-
"@mui/styles": "^5.
|
|
35
|
-
"@mui/x-date-pickers": "^5.0.0-
|
|
30
|
+
"@emotion/react": "^11.9.3",
|
|
31
|
+
"@emotion/styled": "^11.9.3",
|
|
32
|
+
"@mui/icons-material": "^5.8.4",
|
|
33
|
+
"@mui/material": "^5.9.0",
|
|
34
|
+
"@mui/styles": "^5.9.0",
|
|
35
|
+
"@mui/x-date-pickers": "^5.0.0-beta.0",
|
|
36
36
|
"react-cropper": "^2.1.8",
|
|
37
|
-
"@sentry/browser": "^6.
|
|
38
|
-
"@sentry/integrations": "^6.
|
|
39
|
-
"@types/iobroker": "^4.0.
|
|
37
|
+
"@sentry/browser": "^7.6.0",
|
|
38
|
+
"@sentry/integrations": "^7.6.0",
|
|
39
|
+
"@types/iobroker": "^4.0.4",
|
|
40
40
|
"react-color": "^2.19.3",
|
|
41
41
|
"react-colorful": "^5.5.1",
|
|
42
|
-
"react-dropzone": "^14.2.
|
|
43
|
-
"react-icons": "^4.
|
|
42
|
+
"react-dropzone": "^14.2.2",
|
|
43
|
+
"react-icons": "^4.4.0",
|
|
44
44
|
"react-inlinesvg": "^3.0.0",
|
|
45
45
|
"react-text-mask": "^5.4.3"
|
|
46
46
|
}
|