@iobroker/adapter-react-v5 8.0.9 → 8.0.11
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/README.md +3 -0
- package/build/Components/Icon.d.ts +1 -3
- package/build/Components/Icon.js +11 -11
- package/build/Components/Icon.js.map +1 -1
- package/build/Components/TabContent.d.ts +1 -1
- package/build/Components/TabContent.js +3 -3
- package/build/Components/TabContent.js.map +1 -1
- package/build/Components/objectBrowser.types.d.ts +472 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -691,6 +691,9 @@ You can find the migration instructions:
|
|
|
691
691
|
-->
|
|
692
692
|
|
|
693
693
|
## Changelog
|
|
694
|
+
### 8.0.11 (2025-11-09)
|
|
695
|
+
- (@GermanBluefox) Fixing ref for Icon and TabContent components
|
|
696
|
+
|
|
694
697
|
### 8.0.9 (2025-11-02)
|
|
695
698
|
- (@GermanBluefox) Added possibility to import objects from text
|
|
696
699
|
- (@GermanBluefox) Object browser was split into a few files
|
|
@@ -27,9 +27,7 @@ export interface IconProps {
|
|
|
27
27
|
styleUTF8?: React.CSSProperties;
|
|
28
28
|
/** On error handler */
|
|
29
29
|
onError?: ReactEventHandler<HTMLImageElement>;
|
|
30
|
-
/** Reference to image */
|
|
31
|
-
ref?: React.RefObject<HTMLImageElement>;
|
|
32
30
|
/** Alternative text for image */
|
|
33
31
|
alt?: string;
|
|
34
32
|
}
|
|
35
|
-
export declare
|
|
33
|
+
export declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<HTMLSpanElement | HTMLImageElement>>;
|
package/build/Components/Icon.js
CHANGED
|
@@ -3,7 +3,6 @@ import SVG from 'react-inlinesvg';
|
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { SettingsApplications as IconSystem, Photo as IconPhoto, SupervisedUserCircle as IconGroup, PersonOutlined as IconUser, Router as IconHost, Wifi as IconConnection, Info as IconInfo, Description as IconMeta, } from '@mui/icons-material';
|
|
5
5
|
import { IconAlias } from '../icons/IconAlias';
|
|
6
|
-
import { Utils } from './Utils';
|
|
7
6
|
/**
|
|
8
7
|
* Get icon by object type (state, channel, device, ...).
|
|
9
8
|
*
|
|
@@ -67,7 +66,7 @@ export function getSelectIdIcon(obj, imagePrefix) {
|
|
|
67
66
|
if (obj.type === 'instance' || obj.type === 'adapter') {
|
|
68
67
|
src = `${imagePrefix}/adapter/${common.name}/${cIcon}`;
|
|
69
68
|
}
|
|
70
|
-
else if (obj._id
|
|
69
|
+
else if (obj._id?.startsWith('system.adapter.')) {
|
|
71
70
|
instance = obj._id.split('.', 3);
|
|
72
71
|
if (cIcon[0] === '/') {
|
|
73
72
|
instance[2] += cIcon;
|
|
@@ -102,18 +101,18 @@ export function getSelectIdIcon(obj, imagePrefix) {
|
|
|
102
101
|
}
|
|
103
102
|
const REMOTE_SERVER = window.location.hostname.endsWith('iobroker.in');
|
|
104
103
|
const REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
|
|
105
|
-
export
|
|
104
|
+
export const Icon = React.forwardRef(function IconComponent(props, ref) {
|
|
106
105
|
if (props.src) {
|
|
107
106
|
if (typeof props.src === 'string') {
|
|
108
107
|
if (props.src.length < 3) {
|
|
109
108
|
// utf-8 char
|
|
110
109
|
if (props.sx) {
|
|
111
|
-
return (React.createElement(Box, { component: "span", sx: props.sx, title: props.title || undefined, style: { height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }, className:
|
|
110
|
+
return (React.createElement(Box, { component: "span", sx: props.sx, ref: ref, title: props.title || undefined, style: { height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }, className: props.className ? `iconOwn ${props.className}` : 'iconOwn' }, props.src));
|
|
112
111
|
}
|
|
113
|
-
return (React.createElement("span", { title: props.title || undefined, style: { height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }, className:
|
|
112
|
+
return (React.createElement("span", { ref: ref, title: props.title || undefined, style: { height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }, className: props.className ? `iconOwn ${props.className}` : 'iconOwn' }, props.src));
|
|
114
113
|
}
|
|
115
114
|
if (props.src.startsWith('data:image/svg')) {
|
|
116
|
-
return (React.createElement(SVG, { title: props.title || undefined, src: props.src, className:
|
|
115
|
+
return (React.createElement(SVG, { title: props.title || undefined, src: props.src, className: props.className ? `iconOwn ${props.className}` : 'iconOwn', width: props.style?.width || 28, height: props.style?.height || props.style?.width || 28, style: props.style || undefined }));
|
|
117
116
|
}
|
|
118
117
|
if (REMOTE_SERVER && !props.src.startsWith('http://') && !props.src.startsWith('https://')) {
|
|
119
118
|
let src = props.src;
|
|
@@ -124,17 +123,18 @@ export function Icon(props) {
|
|
|
124
123
|
src = REMOTE_PREFIX + src;
|
|
125
124
|
}
|
|
126
125
|
if (props.sx) {
|
|
127
|
-
return (React.createElement(Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || undefined, className:
|
|
126
|
+
return (React.createElement(Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || undefined, className: props.className ? `iconOwn ${props.className}` : 'iconOwn', src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: ref, onError: e => props.onError?.(e) }));
|
|
128
127
|
}
|
|
129
|
-
return (React.createElement("img", { title: props.title || undefined, style: props.style || undefined, className:
|
|
128
|
+
return (React.createElement("img", { title: props.title || undefined, style: props.style || undefined, className: props.className ? `iconOwn ${props.className}` : 'iconOwn', src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: ref, onError: e => props.onError?.(e) }));
|
|
130
129
|
}
|
|
131
130
|
if (props.sx) {
|
|
132
|
-
return (React.createElement(Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || undefined, className:
|
|
131
|
+
return (React.createElement(Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || undefined, className: props.className ? `iconOwn ${props.className}` : 'iconOwn', src: props.src, alt: props.alt || undefined, ref: ref, onError: props.onError }));
|
|
133
132
|
}
|
|
134
|
-
return (React.createElement("img", { title: props.title || undefined, style: props.style || undefined, className:
|
|
133
|
+
return (React.createElement("img", { title: props.title || undefined, style: props.style || undefined, className: props.className ? `iconOwn ${props.className}` : 'iconOwn', src: props.src, alt: props.alt || undefined, ref: ref, onError: props.onError }));
|
|
135
134
|
}
|
|
136
135
|
return props.src;
|
|
137
136
|
}
|
|
138
137
|
return null;
|
|
139
|
-
}
|
|
138
|
+
});
|
|
139
|
+
Icon.displayName = 'Icon';
|
|
140
140
|
//# sourceMappingURL=Icon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","sourceRoot":"./src/","sources":["Components/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACH,oBAAoB,IAAI,UAAU,EAClC,KAAK,IAAI,SAAS,EAClB,oBAAoB,IAAI,SAAS,EACjC,cAAc,IAAI,QAAQ,EAC1B,MAAM,IAAI,QAAQ,EAClB,IAAI,IAAI,cAAc,EACtB,IAAI,IAAI,QAAQ,EAChB,WAAW,IAAI,QAAQ,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAA2B;IACrD,IAAI,IAAI,CAAC;IACT,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC;IAEpB,IAAI,CAAC,EAAE,EAAE,CAAC;QACN,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,qCAAqC;IACrC,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC/C,IAAI,GAAG,oBAAC,UAAU,IAAC,SAAS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AC7C,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,SAAS,EAC3B,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GACjD,CACL,CAAC;YACN,CAAC;YACD,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;gBACX,OAAO,CACH,oBAAC,GAAG,IACA,SAAS,EAAC,KAAK,EACf,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAC/B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAC/B,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,EACjD,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,SAAS,EAC3B,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,OAAO,EAAE,KAAK,CAAC,OAAO,GACxB,CACL,CAAC;YACN,CAAC;YACD,OAAO,CACH,6BACI,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAC/B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAC/B,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,EACjD,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,SAAS,EAC3B,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,OAAO,EAAE,KAAK,CAAC,OAAO,GACxB,CACL,CAAC;QACN,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import React, { type ReactEventHandler } from 'react';\nimport SVG from 'react-inlinesvg';\n\nimport { Box } from '@mui/material';\n\nimport {\n SettingsApplications as IconSystem,\n Photo as IconPhoto,\n SupervisedUserCircle as IconGroup,\n PersonOutlined as IconUser,\n Router as IconHost,\n Wifi as IconConnection,\n Info as IconInfo,\n Description as IconMeta,\n} from '@mui/icons-material';\n\nimport { IconAlias } from '../icons/IconAlias';\nimport { Utils } from './Utils';\n\n/**\n * Get icon by object type (state, channel, device, ...).\n *\n * @param obj Object\n */\nexport function getSystemIcon(obj: ioBroker.Object | null): React.JSX.Element | null {\n let icon;\n const id = obj?._id;\n\n if (!id) {\n return null;\n }\n\n // system or design has special icons\n if (id.startsWith('_design/') || id === 'system') {\n icon = <IconSystem className=\"iconOwn\" />;\n } else if (id === '0_userdata' || id === '0_userdata.0') {\n icon = <IconPhoto className=\"iconOwn\" />;\n } else if (id === 'alias' || id === 'alias.0') {\n icon = <IconAlias className=\"iconOwn\" />;\n } else if (id === 'system.adapter') {\n icon = <IconSystem className=\"iconOwn\" />;\n } else if (id === 'system.group') {\n icon = <IconGroup className=\"iconOwn\" />;\n } else if (id === 'system.user') {\n icon = <IconUser className=\"iconOwn\" />;\n } else if (id === 'system.host') {\n icon = <IconHost className=\"iconOwn\" />;\n } else if (id.endsWith('.connection') || id.endsWith('.connected')) {\n icon = <IconConnection className=\"iconOwn\" />;\n } else if (id.endsWith('.info')) {\n icon = <IconInfo className=\"iconOwn\" />;\n } else if (obj?.type === 'meta') {\n icon = <IconMeta className=\"iconOwn\" />;\n }\n\n return icon || null;\n}\n\n/**\n * Get icon from the object.\n *\n * @param obj Object\n * @param imagePrefix Prefix for image\n */\nexport function getSelectIdIcon(obj: ioBroker.Object | null, imagePrefix?: string): string | null {\n imagePrefix = imagePrefix || '.'; // http://localhost:8081';\n let src = '';\n const common = obj?.common;\n\n if (common) {\n const cIcon = common.icon;\n if (cIcon) {\n if (!cIcon.startsWith('data:image/')) {\n if (cIcon.includes('.')) {\n let instance;\n if (obj.type === 'instance' || obj.type === 'adapter') {\n src = `${imagePrefix}/adapter/${common.name as string}/${cIcon}`;\n } else if (obj._id && obj._id.startsWith('system.adapter.')) {\n instance = obj._id.split('.', 3);\n if (cIcon[0] === '/') {\n instance[2] += cIcon;\n } else {\n instance[2] += `/${cIcon}`;\n }\n src = `${imagePrefix}/adapter/${instance[2]}`;\n } else {\n instance = obj._id.split('.', 2);\n if (cIcon[0] === '/') {\n instance[0] += cIcon;\n } else {\n instance[0] += `/${cIcon}`;\n }\n src = `${imagePrefix}/adapter/${instance[0]}`;\n }\n } else {\n return null;\n }\n } else {\n // base 64 image\n src = cIcon;\n }\n }\n }\n\n return src || null;\n}\n\nexport interface IconProps {\n /** URL, UTF-8 character, or svg code (data:image/svg...) */\n src: string | React.JSX.Element | null | undefined;\n /** Class name */\n className?: string;\n /** Style for image */\n style?: React.CSSProperties;\n /** Styles for mui */\n sx?: Record<string, any>;\n /** Tooltip */\n title?: string;\n /** Styles for utf-8 characters */\n styleUTF8?: React.CSSProperties;\n /** On error handler */\n onError?: ReactEventHandler<HTMLImageElement>;\n /** Reference to image */\n ref?: React.RefObject<HTMLImageElement>;\n /** Alternative text for image */\n alt?: string;\n}\n\nconst REMOTE_SERVER = window.location.hostname.endsWith('iobroker.in');\nconst REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);\n\nexport function Icon(props: IconProps): React.JSX.Element | null {\n if (props.src) {\n if (typeof props.src === 'string') {\n if (props.src.length < 3) {\n // utf-8 char\n if (props.sx) {\n return (\n <Box\n component=\"span\"\n sx={props.sx}\n title={props.title || undefined}\n style={{ height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }}\n className={Utils.clsx(props.className, 'iconOwn')}\n >\n {props.src}\n </Box>\n );\n }\n return (\n <span\n title={props.title || undefined}\n style={{ height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }}\n className={Utils.clsx(props.className, 'iconOwn')}\n >\n {props.src}\n </span>\n );\n }\n if (props.src.startsWith('data:image/svg')) {\n return (\n <SVG\n title={props.title || undefined}\n src={props.src}\n className={Utils.clsx(props.className, 'iconOwn')}\n width={props.style?.width || 28}\n height={props.style?.height || props.style?.width || 28}\n style={props.style || undefined}\n />\n );\n }\n if (REMOTE_SERVER && !props.src.startsWith('http://') && !props.src.startsWith('https://')) {\n let src = props.src;\n if (src.startsWith('./')) {\n src = REMOTE_PREFIX + src.substring(2);\n } else if (!src.startsWith('/')) {\n src = REMOTE_PREFIX + src;\n }\n\n if (props.sx) {\n return (\n <Box\n component=\"img\"\n sx={props.sx}\n title={props.title || undefined}\n style={props.style || undefined}\n className={Utils.clsx(props.className, 'iconOwn')}\n src={`https://remote-files.iobroker.in${src}`}\n alt={props.alt || undefined}\n ref={props.ref}\n onError={e => props.onError && props.onError(e)}\n />\n );\n }\n return (\n <img\n title={props.title || undefined}\n style={props.style || undefined}\n className={Utils.clsx(props.className, 'iconOwn')}\n src={`https://remote-files.iobroker.in${src}`}\n alt={props.alt || undefined}\n ref={props.ref}\n onError={e => props.onError && props.onError(e)}\n />\n );\n }\n if (props.sx) {\n return (\n <Box\n component=\"img\"\n sx={props.sx}\n title={props.title || undefined}\n style={props.style || undefined}\n className={Utils.clsx(props.className, 'iconOwn')}\n src={props.src}\n alt={props.alt || undefined}\n ref={props.ref}\n onError={props.onError}\n />\n );\n }\n return (\n <img\n title={props.title || undefined}\n style={props.style || undefined}\n className={Utils.clsx(props.className, 'iconOwn')}\n src={props.src}\n alt={props.alt || undefined}\n ref={props.ref}\n onError={props.onError}\n />\n );\n }\n\n return props.src;\n }\n return null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Icon.js","sourceRoot":"./src/","sources":["Components/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACH,oBAAoB,IAAI,UAAU,EAClC,KAAK,IAAI,SAAS,EAClB,oBAAoB,IAAI,SA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AK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,EACrE,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,SAAS,EAC3B,GAAG,EAAE,GAAkC,EACvC,OAAO,EAAE,KAAK,CAAC,OAAO,GACxB,CACL,CAAC;YACN,CAAC;YACD,OAAO,CACH,6BACI,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAC/B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS,EAC/B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,EACrE,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,SAAS,EAC3B,GAAG,EAAE,GAAkC,EACvC,OAAO,EAAE,KAAK,CAAC,OAAO,GACxB,CACL,CAAC;QACN,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CACJ,CAAC;AAEF,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC","sourcesContent":["import React, { type ReactEventHandler } from 'react';\nimport SVG from 'react-inlinesvg';\n\nimport { Box } from '@mui/material';\n\nimport {\n SettingsApplications as IconSystem,\n Photo as IconPhoto,\n SupervisedUserCircle as IconGroup,\n PersonOutlined as IconUser,\n Router as IconHost,\n Wifi as IconConnection,\n Info as IconInfo,\n Description as IconMeta,\n} from '@mui/icons-material';\n\nimport { IconAlias } from '../icons/IconAlias';\n\n/**\n * Get icon by object type (state, channel, device, ...).\n *\n * @param obj Object\n */\nexport function getSystemIcon(obj: ioBroker.Object | null): React.JSX.Element | null {\n let icon;\n const id = obj?._id;\n\n if (!id) {\n return null;\n }\n\n // system or design has special icons\n if (id.startsWith('_design/') || id === 'system') {\n icon = <IconSystem className=\"iconOwn\" />;\n } else if (id === '0_userdata' || id === '0_userdata.0') {\n icon = <IconPhoto className=\"iconOwn\" />;\n } else if (id === 'alias' || id === 'alias.0') {\n icon = <IconAlias className=\"iconOwn\" />;\n } else if (id === 'system.adapter') {\n icon = <IconSystem className=\"iconOwn\" />;\n } else if (id === 'system.group') {\n icon = <IconGroup className=\"iconOwn\" />;\n } else if (id === 'system.user') {\n icon = <IconUser className=\"iconOwn\" />;\n } else if (id === 'system.host') {\n icon = <IconHost className=\"iconOwn\" />;\n } else if (id.endsWith('.connection') || id.endsWith('.connected')) {\n icon = <IconConnection className=\"iconOwn\" />;\n } else if (id.endsWith('.info')) {\n icon = <IconInfo className=\"iconOwn\" />;\n } else if (obj?.type === 'meta') {\n icon = <IconMeta className=\"iconOwn\" />;\n }\n\n return icon || null;\n}\n\n/**\n * Get icon from the object.\n *\n * @param obj Object\n * @param imagePrefix Prefix for image\n */\nexport function getSelectIdIcon(obj: ioBroker.Object | null, imagePrefix?: string): string | null {\n imagePrefix = imagePrefix || '.'; // http://localhost:8081';\n let src = '';\n const common = obj?.common;\n\n if (common) {\n const cIcon = common.icon;\n if (cIcon) {\n if (!cIcon.startsWith('data:image/')) {\n if (cIcon.includes('.')) {\n let instance;\n if (obj.type === 'instance' || obj.type === 'adapter') {\n src = `${imagePrefix}/adapter/${common.name as string}/${cIcon}`;\n } else if (obj._id?.startsWith('system.adapter.')) {\n instance = obj._id.split('.', 3);\n if (cIcon[0] === '/') {\n instance[2] += cIcon;\n } else {\n instance[2] += `/${cIcon}`;\n }\n src = `${imagePrefix}/adapter/${instance[2]}`;\n } else {\n instance = obj._id.split('.', 2);\n if (cIcon[0] === '/') {\n instance[0] += cIcon;\n } else {\n instance[0] += `/${cIcon}`;\n }\n src = `${imagePrefix}/adapter/${instance[0]}`;\n }\n } else {\n return null;\n }\n } else {\n // base 64 image\n src = cIcon;\n }\n }\n }\n\n return src || null;\n}\n\nexport interface IconProps {\n /** URL, UTF-8 character, or svg code (data:image/svg...) */\n src: string | React.JSX.Element | null | undefined;\n /** Class name */\n className?: string;\n /** Style for image */\n style?: React.CSSProperties;\n /** Styles for mui */\n sx?: Record<string, any>;\n /** Tooltip */\n title?: string;\n /** Styles for utf-8 characters */\n styleUTF8?: React.CSSProperties;\n /** On error handler */\n onError?: ReactEventHandler<HTMLImageElement>;\n /** Alternative text for image */\n alt?: string;\n}\n\nconst REMOTE_SERVER = window.location.hostname.endsWith('iobroker.in');\nconst REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);\n\nexport const Icon = React.forwardRef<HTMLImageElement | HTMLSpanElement, IconProps>(\n function IconComponent(props, ref): React.JSX.Element | null {\n if (props.src) {\n if (typeof props.src === 'string') {\n if (props.src.length < 3) {\n // utf-8 char\n if (props.sx) {\n return (\n <Box\n component=\"span\"\n sx={props.sx}\n ref={ref as React.Ref<HTMLSpanElement>}\n title={props.title || undefined}\n style={{ height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n >\n {props.src}\n </Box>\n );\n }\n return (\n <span\n ref={ref as React.Ref<HTMLSpanElement>}\n title={props.title || undefined}\n style={{ height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n >\n {props.src}\n </span>\n );\n }\n if (props.src.startsWith('data:image/svg')) {\n return (\n <SVG\n title={props.title || undefined}\n src={props.src}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n width={props.style?.width || 28}\n height={props.style?.height || props.style?.width || 28}\n style={props.style || undefined}\n />\n );\n }\n if (REMOTE_SERVER && !props.src.startsWith('http://') && !props.src.startsWith('https://')) {\n let src = props.src;\n if (src.startsWith('./')) {\n src = REMOTE_PREFIX + src.substring(2);\n } else if (!src.startsWith('/')) {\n src = REMOTE_PREFIX + src;\n }\n\n if (props.sx) {\n return (\n <Box\n component=\"img\"\n sx={props.sx}\n title={props.title || undefined}\n style={props.style || undefined}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n src={`https://remote-files.iobroker.in${src}`}\n alt={props.alt || undefined}\n ref={ref as React.Ref<HTMLImageElement>}\n onError={e => props.onError?.(e)}\n />\n );\n }\n return (\n <img\n title={props.title || undefined}\n style={props.style || undefined}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n src={`https://remote-files.iobroker.in${src}`}\n alt={props.alt || undefined}\n ref={ref as React.Ref<HTMLImageElement>}\n onError={e => props.onError?.(e)}\n />\n );\n }\n if (props.sx) {\n return (\n <Box\n component=\"img\"\n sx={props.sx}\n title={props.title || undefined}\n style={props.style || undefined}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n src={props.src}\n alt={props.alt || undefined}\n ref={ref as React.Ref<HTMLImageElement>}\n onError={props.onError}\n />\n );\n }\n return (\n <img\n title={props.title || undefined}\n style={props.style || undefined}\n className={props.className ? `iconOwn ${props.className}` : 'iconOwn'}\n src={props.src}\n alt={props.alt || undefined}\n ref={ref as React.Ref<HTMLImageElement>}\n onError={props.onError}\n />\n );\n }\n\n return props.src;\n }\n return null;\n },\n);\n\nIcon.displayName = 'Icon';\n"]}
|
|
@@ -7,5 +7,5 @@ interface TabContentProps {
|
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
ref?: React.RefObject<HTMLDivElement>;
|
|
9
9
|
}
|
|
10
|
-
export declare
|
|
10
|
+
export declare const TabContent: React.ForwardRefExoticComponent<Omit<TabContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
11
11
|
export {};
|
|
@@ -10,11 +10,11 @@ const styles = {
|
|
|
10
10
|
overflow: 'auto',
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export const TabContent = React.forwardRef(function TabContentComponent(props, ref) {
|
|
14
14
|
return (React.createElement(Grid2, { sx: {
|
|
15
15
|
...styles.root,
|
|
16
16
|
...(props?.style || undefined),
|
|
17
17
|
...(props.overflow === 'auto' ? styles.overflowAuto : undefined),
|
|
18
|
-
}, ref:
|
|
19
|
-
}
|
|
18
|
+
}, ref: ref }, props.children));
|
|
19
|
+
});
|
|
20
20
|
//# sourceMappingURL=TabContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabContent.js","sourceRoot":"./src/","sources":["Components/TabContent.tsx"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"TabContent.js","sourceRoot":"./src/","sources":["Components/TabContent.tsx"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,QAAQ;KACrB;IACD,YAAY,EAAE;QACV,QAAQ,EAAE,MAAM;KACnB;CACJ,CAAC;AAUF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACtC,SAAS,mBAAmB,CAAC,KAAK,EAAE,GAAG;IACnC,OAAO,CACH,oBAAC,KAAK,IACF,EAAE,EAAE;YACA,GAAG,MAAM,CAAC,IAAI;YACd,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,SAAS,CAAC;YAC9B,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;SACnE,EACD,GAAG,EAAE,GAAG,IAEP,KAAK,CAAC,QAAQ,CACX,CACX,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\nimport React from 'react';\nimport { Grid2 } from '@mui/material';\nimport { IconProps } from './Icon';\n\nconst styles: Record<string, React.CSSProperties> = {\n root: {\n height: '100%',\n overflow: 'hidden',\n },\n overflowAuto: {\n overflow: 'auto',\n },\n};\n\ninterface TabContentProps {\n /** The content of the component. */\n children: React.JSX.Element | (React.JSX.Element | null | React.JSX.Element[])[];\n /** Overflow behavior */\n overflow?: 'auto';\n style?: React.CSSProperties;\n ref?: React.RefObject<HTMLDivElement>;\n}\nexport const TabContent = React.forwardRef<HTMLDivElement, TabContentProps>(\n function TabContentComponent(props, ref): React.JSX.Element | null {\n return (\n <Grid2\n sx={{\n ...styles.root,\n ...(props?.style || undefined),\n ...(props.overflow === 'auto' ? styles.overflowAuto : undefined),\n }}\n ref={ref}\n >\n {props.children}\n </Grid2>\n );\n },\n);\n"]}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { IobTheme, ThemeName, ThemeType, Translate } from '../types';
|
|
3
|
+
import type { Connection } from '../Connection';
|
|
4
|
+
import type { Router } from './Router';
|
|
5
|
+
import type { ObjectBrowserClass } from './ObjectBrowser';
|
|
6
|
+
import type { AdapterColumn, ObjectBrowserCustomFilter } from './objectBrowserUtils';
|
|
7
|
+
|
|
8
|
+
type ObjectEventType = 'new' | 'changed' | 'deleted';
|
|
9
|
+
|
|
10
|
+
interface ObjectEvent {
|
|
11
|
+
id: string;
|
|
12
|
+
obj?: ioBroker.Object;
|
|
13
|
+
type: ObjectEventType;
|
|
14
|
+
oldObj?: ioBroker.Object;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ObjectsWorker {
|
|
18
|
+
getObjects(update?: boolean): Promise<void | Record<string, ioBroker.Object>>;
|
|
19
|
+
registerHandler(cb: (events: ObjectEvent[]) => void): void;
|
|
20
|
+
unregisterHandler(cb: (events: ObjectEvent[]) => void, doNotUnsubscribe?: boolean): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface CustomAdminColumnStored {
|
|
24
|
+
path: string;
|
|
25
|
+
name: string;
|
|
26
|
+
objTypes?: ioBroker.ObjectType[];
|
|
27
|
+
width?: number;
|
|
28
|
+
edit?: boolean;
|
|
29
|
+
type?: ioBroker.CommonType;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ContextMenuItem {
|
|
33
|
+
/** hotkey */
|
|
34
|
+
key?: string;
|
|
35
|
+
visibility: boolean;
|
|
36
|
+
icon: React.JSX.Element | string;
|
|
37
|
+
label: string;
|
|
38
|
+
onClick?: () => void;
|
|
39
|
+
listItemIconStyle?: React.CSSProperties;
|
|
40
|
+
style?: React.CSSProperties;
|
|
41
|
+
subMenu?: {
|
|
42
|
+
label: string;
|
|
43
|
+
visibility: boolean;
|
|
44
|
+
icon: React.JSX.Element;
|
|
45
|
+
onClick: () => void;
|
|
46
|
+
iconStyle?: React.CSSProperties;
|
|
47
|
+
style?: React.CSSProperties;
|
|
48
|
+
listItemIconStyle?: React.CSSProperties;
|
|
49
|
+
}[];
|
|
50
|
+
iconStyle?: React.CSSProperties;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type ioBrokerObjectForExport = ioBroker.Object & Partial<ioBroker.State>;
|
|
54
|
+
|
|
55
|
+
export interface ObjectBrowserEditRoleProps {
|
|
56
|
+
roleArray: { role: string; type: ioBroker.CommonType }[];
|
|
57
|
+
id: string;
|
|
58
|
+
socket: Connection;
|
|
59
|
+
onClose: (obj?: ioBroker.Object | null) => void;
|
|
60
|
+
t: Translate;
|
|
61
|
+
commonType: ioBroker.CommonType;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ObjectViewFileDialogProps {
|
|
65
|
+
t: Translate;
|
|
66
|
+
socket: Connection;
|
|
67
|
+
obj: ioBroker.AnyObject;
|
|
68
|
+
onClose: () => void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface InsertJsonObjectsDialogProps {
|
|
72
|
+
t: Translate;
|
|
73
|
+
onClose: (json?: string) => void;
|
|
74
|
+
themeType: ThemeType;
|
|
75
|
+
themeName: ThemeName;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface TreeItemData {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
obj?: ioBroker.Object;
|
|
82
|
+
/** Object ID in lower case for filtering */
|
|
83
|
+
fID?: string;
|
|
84
|
+
/** translated common.name in lower case for filtering */
|
|
85
|
+
fName?: string;
|
|
86
|
+
/** Link to parent item */
|
|
87
|
+
parent?: TreeItem;
|
|
88
|
+
level?: number;
|
|
89
|
+
icon?: string | React.JSX.Element | null;
|
|
90
|
+
/** If the item existing object or generated folder */
|
|
91
|
+
generated?: boolean;
|
|
92
|
+
title?: string;
|
|
93
|
+
/** if the item has "write" button (value=true, ack=false) */
|
|
94
|
+
button?: boolean;
|
|
95
|
+
/** If the item has read and write and is boolean */
|
|
96
|
+
switch?: boolean;
|
|
97
|
+
/** If the item is url linke */
|
|
98
|
+
url?: boolean;
|
|
99
|
+
/** if the item has custom settings in `common.custom` */
|
|
100
|
+
hasCustoms?: boolean;
|
|
101
|
+
/** If this item is visible */
|
|
102
|
+
visible?: boolean;
|
|
103
|
+
/** Is any of the children visible (not only directly children) */
|
|
104
|
+
hasVisibleChildren?: boolean;
|
|
105
|
+
/** Is any of the parents visible (not only directly parent) */
|
|
106
|
+
hasVisibleParent?: boolean;
|
|
107
|
+
/** Combination of `visible || hasVisibleChildren` */
|
|
108
|
+
sumVisibility?: boolean;
|
|
109
|
+
/** translated names of enumerations (functions) where this object is the member (or the parent), divided by comma */
|
|
110
|
+
funcs?: string;
|
|
111
|
+
/** is if the enums are from parent */
|
|
112
|
+
pef?: boolean;
|
|
113
|
+
/** translated names of enumerations (rooms) where this object is the member (or the parent), divided by comma */
|
|
114
|
+
rooms?: string;
|
|
115
|
+
/** is if the enums are from parent */
|
|
116
|
+
per?: boolean;
|
|
117
|
+
// language in what the rooms and functions where translated
|
|
118
|
+
lang?: ioBroker.Languages;
|
|
119
|
+
state?: {
|
|
120
|
+
valTextRx?: React.JSX.Element[] | null;
|
|
121
|
+
style?: React.CSSProperties;
|
|
122
|
+
};
|
|
123
|
+
aclTooltip?: null | React.JSX.Element;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface TreeItem {
|
|
127
|
+
id?: string;
|
|
128
|
+
data: TreeItemData;
|
|
129
|
+
children?: TreeItem[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface DragWrapperProps {
|
|
133
|
+
item: TreeItem;
|
|
134
|
+
className?: string;
|
|
135
|
+
style?: React.CSSProperties;
|
|
136
|
+
children: React.JSX.Element | null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ObjectCustomDialogProps {
|
|
140
|
+
allVisibleObjects: boolean;
|
|
141
|
+
customsInstances: string[];
|
|
142
|
+
expertMode?: boolean;
|
|
143
|
+
isFloatComma: boolean;
|
|
144
|
+
lang: ioBroker.Languages;
|
|
145
|
+
objectIDs: string[];
|
|
146
|
+
objects: Record<string, ioBroker.Object>;
|
|
147
|
+
onClose: () => void;
|
|
148
|
+
reportChangedIds: (ids: string[]) => void;
|
|
149
|
+
socket: Connection;
|
|
150
|
+
systemConfig: ioBroker.SystemConfigObject;
|
|
151
|
+
t: Translate;
|
|
152
|
+
theme: IobTheme;
|
|
153
|
+
themeName: ThemeName;
|
|
154
|
+
themeType: ThemeType;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface ObjectMoveRenameDialogProps {
|
|
158
|
+
childrenIds: string[];
|
|
159
|
+
expertMode: boolean;
|
|
160
|
+
id: string;
|
|
161
|
+
objectType: ioBroker.ObjectType | undefined;
|
|
162
|
+
onClose: () => void;
|
|
163
|
+
socket: Connection;
|
|
164
|
+
t: Translate;
|
|
165
|
+
theme: IobTheme;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface ObjectBrowserValueProps {
|
|
169
|
+
/** State type */
|
|
170
|
+
type: 'states' | 'string' | 'number' | 'boolean' | 'json';
|
|
171
|
+
/** State role */
|
|
172
|
+
role: string;
|
|
173
|
+
/** common.states */
|
|
174
|
+
states: Record<string, string> | null;
|
|
175
|
+
/** The state value */
|
|
176
|
+
value: string | number | boolean | null;
|
|
177
|
+
/** If expert mode is enabled */
|
|
178
|
+
expertMode: boolean;
|
|
179
|
+
onClose: (newValue?: {
|
|
180
|
+
val: ioBroker.StateValue;
|
|
181
|
+
ack: boolean;
|
|
182
|
+
q: ioBroker.STATE_QUALITY[keyof ioBroker.STATE_QUALITY];
|
|
183
|
+
expire: number | undefined;
|
|
184
|
+
}) => void;
|
|
185
|
+
/** Configured theme */
|
|
186
|
+
themeType: ThemeType;
|
|
187
|
+
theme: IobTheme;
|
|
188
|
+
socket: Connection;
|
|
189
|
+
defaultHistory: string;
|
|
190
|
+
dateFormat: string;
|
|
191
|
+
object: ioBroker.StateObject;
|
|
192
|
+
isFloatComma: boolean;
|
|
193
|
+
t: Translate;
|
|
194
|
+
lang: ioBroker.Languages;
|
|
195
|
+
width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface ObjectBrowserEditObjectProps {
|
|
199
|
+
socket: Connection;
|
|
200
|
+
obj: ioBroker.AnyObject;
|
|
201
|
+
roleArray: { role: string; type: ioBroker.CommonType }[];
|
|
202
|
+
expertMode: boolean;
|
|
203
|
+
themeType: ThemeType;
|
|
204
|
+
theme: IobTheme;
|
|
205
|
+
aliasTab: boolean;
|
|
206
|
+
onClose: (obj?: ioBroker.AnyObject) => void;
|
|
207
|
+
dialogName?: string;
|
|
208
|
+
objects: Record<string, ioBroker.AnyObject>;
|
|
209
|
+
dateFormat: string;
|
|
210
|
+
isFloatComma: boolean;
|
|
211
|
+
onNewObject: (obj: ioBroker.AnyObject) => void;
|
|
212
|
+
t: Translate;
|
|
213
|
+
width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface ObjectAliasEditorProps {
|
|
217
|
+
t: Translate;
|
|
218
|
+
roleArray: { role: string; type: ioBroker.CommonType }[];
|
|
219
|
+
socket: Connection;
|
|
220
|
+
objects: Record<string, ioBroker.AnyObject>;
|
|
221
|
+
onRedirect: (id: string, delay?: number) => void;
|
|
222
|
+
obj: ioBroker.AnyObject;
|
|
223
|
+
onClose: () => void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type ObjectBrowserColumn = 'name' | 'type' | 'role' | 'room' | 'func' | 'val' | 'buttons';
|
|
227
|
+
|
|
228
|
+
export type ObjectBrowserPossibleColumns =
|
|
229
|
+
| 'name'
|
|
230
|
+
| 'type'
|
|
231
|
+
| 'role'
|
|
232
|
+
| 'room'
|
|
233
|
+
| 'func'
|
|
234
|
+
| 'val'
|
|
235
|
+
| 'buttons'
|
|
236
|
+
| 'changedFrom'
|
|
237
|
+
| 'qualityCode'
|
|
238
|
+
| 'timestamp'
|
|
239
|
+
| 'lastChange'
|
|
240
|
+
| 'id';
|
|
241
|
+
|
|
242
|
+
export interface FormatValueOptions {
|
|
243
|
+
state: ioBroker.State;
|
|
244
|
+
obj: ioBroker.StateObject;
|
|
245
|
+
texts: Record<string, string>;
|
|
246
|
+
dateFormat: string;
|
|
247
|
+
isFloatComma: boolean;
|
|
248
|
+
full?: boolean;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface TreeInfo {
|
|
252
|
+
funcEnums: string[];
|
|
253
|
+
roomEnums: string[];
|
|
254
|
+
roles: { role: string; type: ioBroker.CommonType }[];
|
|
255
|
+
ids: string[];
|
|
256
|
+
types: string[];
|
|
257
|
+
objects: Record<string, ioBroker.Object>;
|
|
258
|
+
customs: string[];
|
|
259
|
+
enums: string[];
|
|
260
|
+
hasSomeCustoms: boolean;
|
|
261
|
+
// List of all aliases that shows to this state
|
|
262
|
+
aliasesMap: { [stateId: string]: string[] };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface GetValueStyleOptions {
|
|
266
|
+
state: ioBroker.State;
|
|
267
|
+
isExpertMode?: boolean;
|
|
268
|
+
isButton?: boolean;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface ObjectBrowserCustomFilter {
|
|
272
|
+
type?: ioBroker.ObjectType | ioBroker.ObjectType[];
|
|
273
|
+
common?: {
|
|
274
|
+
type?: ioBroker.CommonType | ioBroker.CommonType[];
|
|
275
|
+
role?: string | string[];
|
|
276
|
+
// If "_" - no custom set
|
|
277
|
+
// If "_dataSources" - only data sources (history, sql, influxdb, ...)
|
|
278
|
+
// Else "telegram." or something like this
|
|
279
|
+
// `true` - If common.custom not empty
|
|
280
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
281
|
+
custom?: '_' | '_dataSources' | true | string | string[];
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface InputSelectItem {
|
|
286
|
+
value: string;
|
|
287
|
+
name: string;
|
|
288
|
+
icon?: null | React.JSX.Element;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface AdapterColumn {
|
|
292
|
+
adapter: string;
|
|
293
|
+
id: string;
|
|
294
|
+
name: string;
|
|
295
|
+
path: string[];
|
|
296
|
+
pathText: string;
|
|
297
|
+
edit?: boolean;
|
|
298
|
+
type?: 'boolean' | 'string' | 'number';
|
|
299
|
+
objTypes?: ioBroker.ObjectType[];
|
|
300
|
+
align?: 'center' | 'left' | 'right';
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface ObjectBrowserFilter {
|
|
304
|
+
id?: string;
|
|
305
|
+
name?: string;
|
|
306
|
+
room?: string[];
|
|
307
|
+
func?: string[];
|
|
308
|
+
role?: string[];
|
|
309
|
+
type?: string[];
|
|
310
|
+
custom?: string[];
|
|
311
|
+
expertMode?: boolean;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface ObjectBrowserProps {
|
|
315
|
+
/** where to store settings in localStorage */
|
|
316
|
+
dialogName?: string;
|
|
317
|
+
defaultFilters?: ObjectBrowserFilter;
|
|
318
|
+
selected?: string | string[];
|
|
319
|
+
onSelect?: (selected: string | string[], name: string | null, isDouble?: boolean) => void;
|
|
320
|
+
onFilterChanged?: (newFilter: ObjectBrowserFilter) => void;
|
|
321
|
+
socket: Connection;
|
|
322
|
+
showExpertButton?: boolean;
|
|
323
|
+
expertMode?: boolean;
|
|
324
|
+
imagePrefix?: string;
|
|
325
|
+
themeName: ThemeName;
|
|
326
|
+
themeType: ThemeType;
|
|
327
|
+
/** will be filled by withWidth */
|
|
328
|
+
width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
329
|
+
theme: IobTheme;
|
|
330
|
+
t: Translate;
|
|
331
|
+
lang: ioBroker.Languages;
|
|
332
|
+
multiSelect?: boolean;
|
|
333
|
+
notEditable?: boolean;
|
|
334
|
+
foldersFirst?: boolean;
|
|
335
|
+
disableColumnSelector?: boolean;
|
|
336
|
+
isFloatComma?: boolean;
|
|
337
|
+
dateFormat?: string;
|
|
338
|
+
levelPadding?: number;
|
|
339
|
+
/** Allow selection of non-objects (virtual branches) */
|
|
340
|
+
allowNonObjects?: boolean;
|
|
341
|
+
/** Called when all objects are loaded */
|
|
342
|
+
onAllLoaded?: () => void;
|
|
343
|
+
|
|
344
|
+
// components
|
|
345
|
+
objectCustomDialog?: React.FC<ObjectCustomDialogProps>;
|
|
346
|
+
objectMoveRenameDialog?: React.FC<ObjectMoveRenameDialogProps>;
|
|
347
|
+
objectAddBoolean?: boolean; // optional toolbar button
|
|
348
|
+
objectEditBoolean?: boolean; // optional toolbar button
|
|
349
|
+
objectStatesView?: boolean; // optional toolbar button
|
|
350
|
+
objectImportExport?: boolean; // optional toolbar button
|
|
351
|
+
objectEditOfAccessControl?: boolean; // Access Control
|
|
352
|
+
/** modal add object */
|
|
353
|
+
modalNewObject?: (oBrowser: ObjectBrowserClass) => React.JSX.Element;
|
|
354
|
+
/** modal Edit Of Access Control */
|
|
355
|
+
modalEditOfAccessControl: (oBrowser: ObjectBrowserClass, data: TreeItemData) => React.JSX.Element;
|
|
356
|
+
onObjectDelete?: (id: string, hasChildren: boolean, objectExists: boolean, childrenCount: number) => void;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Optional filter
|
|
360
|
+
* `{common: {custom: true}}` - show only objects with some custom settings
|
|
361
|
+
* `{common: {custom: 'sql.0'}}` - show only objects with `sql.0` custom settings (only of the specific instance)
|
|
362
|
+
* `{common: {custom: '_dataSources'}}` - show only objects of adapters `influxdb' or 'sql' or 'history'
|
|
363
|
+
* `{common: {custom: 'adapterName.'}}` - show only objects of custom settings of specific adapter (all instances)
|
|
364
|
+
* `{type: 'channel'}` - show only channels
|
|
365
|
+
* `{type: ['channel', 'device']}` - show only channels and devices
|
|
366
|
+
* `{common: {type: 'number'}` - show only states of type 'number
|
|
367
|
+
* `{common: {type: ['number', 'string']}` - show only states of type 'number and string
|
|
368
|
+
* `{common: {role: ['switch']}` - show only states with roles starting from switch
|
|
369
|
+
* `{common: {role: ['switch', 'button']}` - show only states with roles starting from `switch` and `button`
|
|
370
|
+
*/
|
|
371
|
+
customFilter: ObjectBrowserCustomFilter;
|
|
372
|
+
objectBrowserValue?: React.FC<ObjectBrowserValueProps>;
|
|
373
|
+
objectBrowserEditObject?: React.FC<ObjectBrowserEditObjectProps>;
|
|
374
|
+
/** on edit alias */
|
|
375
|
+
objectBrowserAliasEditor?: React.FC<ObjectAliasEditorProps>;
|
|
376
|
+
/** on Edit role */
|
|
377
|
+
objectBrowserEditRole?: React.FC<ObjectBrowserEditRoleProps>;
|
|
378
|
+
/** on view file state */
|
|
379
|
+
objectBrowserViewFile?: React.FC<ObjectViewFileDialogProps>;
|
|
380
|
+
objectBrowserInsertJsonObjects?: React.FC<InsertJsonObjectsDialogProps>;
|
|
381
|
+
router?: typeof Router;
|
|
382
|
+
types?: ioBroker.ObjectType[];
|
|
383
|
+
/** Possible columns: ['name', 'type', 'role', 'room', 'func', 'val', 'buttons'] */
|
|
384
|
+
columns?: ObjectBrowserColumn[];
|
|
385
|
+
/** Shows only elements of this root */
|
|
386
|
+
root?: string;
|
|
387
|
+
|
|
388
|
+
/** cache of objects */
|
|
389
|
+
objectsWorker?: ObjectsWorker;
|
|
390
|
+
/**
|
|
391
|
+
* function to filter out all unnecessary objects. It cannot be used together with "types"
|
|
392
|
+
* Example for function: `obj => obj.common?.type === 'boolean'` to show only boolean states
|
|
393
|
+
*/
|
|
394
|
+
filterFunc?: (obj: ioBroker.Object) => boolean;
|
|
395
|
+
/** Used for enums dragging */
|
|
396
|
+
DragWrapper?: React.FC<DragWrapperProps>;
|
|
397
|
+
/** let DragWrapper know about objects to get the icons */
|
|
398
|
+
setObjectsReference?: (objects: Record<string, ioBroker.Object>) => void;
|
|
399
|
+
dragEnabled?: boolean;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export interface ObjectBrowserState {
|
|
403
|
+
loaded: boolean;
|
|
404
|
+
foldersFirst: boolean;
|
|
405
|
+
selected: string[];
|
|
406
|
+
focused: string;
|
|
407
|
+
selectedNonObject: string;
|
|
408
|
+
filter: ObjectBrowserFilter;
|
|
409
|
+
filterKey: number;
|
|
410
|
+
depth: number;
|
|
411
|
+
expandAllVisible: boolean;
|
|
412
|
+
expanded: string[];
|
|
413
|
+
toast: string;
|
|
414
|
+
scrollBarWidth: number;
|
|
415
|
+
customDialog: null | string[];
|
|
416
|
+
customDialogAll?: boolean;
|
|
417
|
+
editObjectDialog: string;
|
|
418
|
+
editObjectAlias: boolean; // open the edit object dialog on alias tab
|
|
419
|
+
viewFileDialog: string;
|
|
420
|
+
showAliasEditor: string;
|
|
421
|
+
enumDialog: null | {
|
|
422
|
+
item: TreeItem;
|
|
423
|
+
type: 'room' | 'func';
|
|
424
|
+
enumsOriginal: string;
|
|
425
|
+
};
|
|
426
|
+
enumDialogEnums?: null | string[];
|
|
427
|
+
roleDialog: null | string;
|
|
428
|
+
statesView: boolean;
|
|
429
|
+
/** ['name', 'type', 'role', 'room', 'func', 'val', 'buttons'] */
|
|
430
|
+
columns: ObjectBrowserPossibleColumns[] | null;
|
|
431
|
+
columnsForAdmin: Record<string, CustomAdminColumnStored[]> | null;
|
|
432
|
+
columnsSelectorShow: boolean;
|
|
433
|
+
columnsAuto: boolean;
|
|
434
|
+
columnsWidths: Record<string, number>;
|
|
435
|
+
columnsDialogTransparent: number;
|
|
436
|
+
columnsEditCustomDialog: null | {
|
|
437
|
+
obj: ioBroker.Object;
|
|
438
|
+
item: TreeItem;
|
|
439
|
+
it: AdapterColumn;
|
|
440
|
+
};
|
|
441
|
+
customColumnDialogValueChanged: boolean;
|
|
442
|
+
showExportDialog: false | number;
|
|
443
|
+
showImportDialog: boolean;
|
|
444
|
+
showAllExportOptions: boolean;
|
|
445
|
+
linesEnabled: boolean;
|
|
446
|
+
showDescription: boolean;
|
|
447
|
+
showContextMenu: {
|
|
448
|
+
item: TreeItem;
|
|
449
|
+
position: { left: number; top: number };
|
|
450
|
+
subItem?: string;
|
|
451
|
+
subAnchor?: HTMLLIElement;
|
|
452
|
+
} | null;
|
|
453
|
+
noStatesByExportImport: boolean;
|
|
454
|
+
beautifyJsonExport: boolean;
|
|
455
|
+
excludeSystemRepositoriesFromExport: boolean;
|
|
456
|
+
excludeTranslations: boolean;
|
|
457
|
+
updating?: boolean;
|
|
458
|
+
modalNewObj?: null | { id: string; initialType?: ioBroker.ObjectType; initialStateType?: ioBroker.CommonType };
|
|
459
|
+
error?: any;
|
|
460
|
+
modalEditOfAccess?: boolean;
|
|
461
|
+
modalEditOfAccessObjData?: TreeItemData;
|
|
462
|
+
updateOpened?: boolean;
|
|
463
|
+
tooltipInfo: null | { el: React.JSX.Element[]; id: string };
|
|
464
|
+
/** Show the menu with aliases for state */
|
|
465
|
+
aliasMenu: string;
|
|
466
|
+
/** Show rename dialog */
|
|
467
|
+
showRenameDialog: {
|
|
468
|
+
id: string;
|
|
469
|
+
childrenIds: string[];
|
|
470
|
+
} | null;
|
|
471
|
+
showImportMenu: HTMLButtonElement | null;
|
|
472
|
+
}
|