@iobroker/adapter-react-v5 7.6.8 → 7.6.9

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.
Files changed (167) hide show
  1. package/build/Components/InfoBox.d.ts +1 -1
  2. package/build/Components/InfoBox.js +1 -1
  3. package/build/Components/InfoBox.js.map +1 -1
  4. package/build/Components/SelectWithIcon.d.ts +0 -1
  5. package/build/Components/SelectWithIcon.js +3 -3
  6. package/build/Components/SelectWithIcon.js.map +1 -1
  7. package/build/Components/TextWithIcon.d.ts +0 -1
  8. package/build/Components/TextWithIcon.js +3 -3
  9. package/build/Components/TextWithIcon.js.map +1 -1
  10. package/build/Components/TypeSelector/TypeIcon.d.ts +29 -0
  11. package/build/Components/TypeSelector/TypeIcon.js +111 -0
  12. package/build/Components/TypeSelector/TypeIcon.js.map +1 -0
  13. package/build/Components/TypeSelector/TypeOptions.d.ts +8 -0
  14. package/build/Components/TypeSelector/TypeOptions.js +125 -0
  15. package/build/Components/TypeSelector/TypeOptions.js.map +1 -0
  16. package/build/Components/TypeSelector/TypeSelector.d.ts +22 -0
  17. package/build/Components/TypeSelector/TypeSelector.js +92 -0
  18. package/build/Components/TypeSelector/TypeSelector.js.map +1 -0
  19. package/build/Components/TypeSelector/icons/Cleaner.d.ts +3 -0
  20. package/build/Components/TypeSelector/icons/Cleaner.js +14 -0
  21. package/build/Components/TypeSelector/icons/Cleaner.js.map +1 -0
  22. package/build/Components/TypeSelector/icons/DoorClosed.d.ts +3 -0
  23. package/build/Components/TypeSelector/icons/DoorClosed.js +7 -0
  24. package/build/Components/TypeSelector/icons/DoorClosed.js.map +1 -0
  25. package/build/Components/TypeSelector/icons/DoorOpened.d.ts +3 -0
  26. package/build/Components/TypeSelector/icons/DoorOpened.js +7 -0
  27. package/build/Components/TypeSelector/icons/DoorOpened.js.map +1 -0
  28. package/build/Components/TypeSelector/icons/FireOff.d.ts +3 -0
  29. package/build/Components/TypeSelector/icons/FireOff.js +8 -0
  30. package/build/Components/TypeSelector/icons/FireOff.js.map +1 -0
  31. package/build/Components/TypeSelector/icons/FireOn.d.ts +3 -0
  32. package/build/Components/TypeSelector/icons/FireOn.js +14 -0
  33. package/build/Components/TypeSelector/icons/FireOn.js.map +1 -0
  34. package/build/Components/TypeSelector/icons/FloodOff.d.ts +3 -0
  35. package/build/Components/TypeSelector/icons/FloodOff.js +11 -0
  36. package/build/Components/TypeSelector/icons/FloodOff.js.map +1 -0
  37. package/build/Components/TypeSelector/icons/FloodOn.d.ts +3 -0
  38. package/build/Components/TypeSelector/icons/FloodOn.js +18 -0
  39. package/build/Components/TypeSelector/icons/FloodOn.js.map +1 -0
  40. package/build/Components/TypeSelector/icons/Gate.d.ts +3 -0
  41. package/build/Components/TypeSelector/icons/Gate.js +8 -0
  42. package/build/Components/TypeSelector/icons/Gate.js.map +1 -0
  43. package/build/Components/TypeSelector/icons/HeatValve.d.ts +3 -0
  44. package/build/Components/TypeSelector/icons/HeatValve.js +6 -0
  45. package/build/Components/TypeSelector/icons/HeatValve.js.map +1 -0
  46. package/build/Components/TypeSelector/icons/Home.d.ts +3 -0
  47. package/build/Components/TypeSelector/icons/Home.js +6 -0
  48. package/build/Components/TypeSelector/icons/Home.js.map +1 -0
  49. package/build/Components/TypeSelector/icons/Humidity.d.ts +3 -0
  50. package/build/Components/TypeSelector/icons/Humidity.js +8 -0
  51. package/build/Components/TypeSelector/icons/Humidity.js.map +1 -0
  52. package/build/Components/TypeSelector/icons/IconHome.d.ts +5 -0
  53. package/build/Components/TypeSelector/icons/IconHome.js +21 -0
  54. package/build/Components/TypeSelector/icons/IconHome.js.map +1 -0
  55. package/build/Components/TypeSelector/icons/Jalousie.d.ts +3 -0
  56. package/build/Components/TypeSelector/icons/Jalousie.js +7 -0
  57. package/build/Components/TypeSelector/icons/Jalousie.js.map +1 -0
  58. package/build/Components/TypeSelector/icons/Material.d.ts +3 -0
  59. package/build/Components/TypeSelector/icons/Material.js +8 -0
  60. package/build/Components/TypeSelector/icons/Material.js.map +1 -0
  61. package/build/Components/TypeSelector/icons/MotionOff.d.ts +3 -0
  62. package/build/Components/TypeSelector/icons/MotionOff.js +11 -0
  63. package/build/Components/TypeSelector/icons/MotionOff.js.map +1 -0
  64. package/build/Components/TypeSelector/icons/MotionOn.d.ts +3 -0
  65. package/build/Components/TypeSelector/icons/MotionOn.js +7 -0
  66. package/build/Components/TypeSelector/icons/MotionOn.js.map +1 -0
  67. package/build/Components/TypeSelector/icons/PushButton.d.ts +3 -0
  68. package/build/Components/TypeSelector/icons/PushButton.js +9 -0
  69. package/build/Components/TypeSelector/icons/PushButton.js.map +1 -0
  70. package/build/Components/TypeSelector/icons/RGB.d.ts +3 -0
  71. package/build/Components/TypeSelector/icons/RGB.js +43 -0
  72. package/build/Components/TypeSelector/icons/RGB.js.map +1 -0
  73. package/build/Components/TypeSelector/icons/RepairExpert.d.ts +3 -0
  74. package/build/Components/TypeSelector/icons/RepairExpert.js +6 -0
  75. package/build/Components/TypeSelector/icons/RepairExpert.js.map +1 -0
  76. package/build/Components/TypeSelector/icons/Socket.d.ts +3 -0
  77. package/build/Components/TypeSelector/icons/Socket.js +8 -0
  78. package/build/Components/TypeSelector/icons/Socket.js.map +1 -0
  79. package/build/Components/TypeSelector/icons/Thermometer.d.ts +3 -0
  80. package/build/Components/TypeSelector/icons/Thermometer.js +7 -0
  81. package/build/Components/TypeSelector/icons/Thermometer.js.map +1 -0
  82. package/build/Components/TypeSelector/icons/ThermometerSimple.d.ts +3 -0
  83. package/build/Components/TypeSelector/icons/ThermometerSimple.js +8 -0
  84. package/build/Components/TypeSelector/icons/ThermometerSimple.js.map +1 -0
  85. package/build/Components/TypeSelector/icons/Thermostat.d.ts +3 -0
  86. package/build/Components/TypeSelector/icons/Thermostat.js +9 -0
  87. package/build/Components/TypeSelector/icons/Thermostat.js.map +1 -0
  88. package/build/Components/TypeSelector/icons/Valve.d.ts +3 -0
  89. package/build/Components/TypeSelector/icons/Valve.js +7 -0
  90. package/build/Components/TypeSelector/icons/Valve.js.map +1 -0
  91. package/build/Components/TypeSelector/icons/WindowClosed.d.ts +3 -0
  92. package/build/Components/TypeSelector/icons/WindowClosed.js +8 -0
  93. package/build/Components/TypeSelector/icons/WindowClosed.js.map +1 -0
  94. package/build/Components/TypeSelector/icons/WindowOpened.d.ts +3 -0
  95. package/build/Components/TypeSelector/icons/WindowOpened.js +9 -0
  96. package/build/Components/TypeSelector/icons/WindowOpened.js.map +1 -0
  97. package/build/Components/TypeSelector/icons/WindowTilted.d.ts +3 -0
  98. package/build/Components/TypeSelector/icons/WindowTilted.js +8 -0
  99. package/build/Components/TypeSelector/icons/WindowTilted.js.map +1 -0
  100. package/build/Components/TypeSelector/icons/index.d.ts +28 -0
  101. package/build/Components/TypeSelector/icons/index.js +28 -0
  102. package/build/Components/TypeSelector/icons/index.js.map +1 -0
  103. package/build/Dialogs/TextInput.d.ts +1 -1
  104. package/build/icons/IconAdapter.d.ts +2 -2
  105. package/build/icons/IconAdapter.js +4 -2
  106. package/build/icons/IconAdapter.js.map +1 -1
  107. package/build/icons/IconAlias.d.ts +2 -2
  108. package/build/icons/IconAlias.js +4 -2
  109. package/build/icons/IconAlias.js.map +1 -1
  110. package/build/icons/IconButtonImage.d.ts +2 -2
  111. package/build/icons/IconButtonImage.js +6 -4
  112. package/build/icons/IconButtonImage.js.map +1 -1
  113. package/build/icons/IconChannel.d.ts +2 -2
  114. package/build/icons/IconChannel.js +8 -6
  115. package/build/icons/IconChannel.js.map +1 -1
  116. package/build/icons/IconClearFilter.d.ts +2 -2
  117. package/build/icons/IconClearFilter.js +4 -2
  118. package/build/icons/IconClearFilter.js.map +1 -1
  119. package/build/icons/IconClosed.d.ts +2 -2
  120. package/build/icons/IconClosed.js +4 -2
  121. package/build/icons/IconClosed.js.map +1 -1
  122. package/build/icons/IconCopy.d.ts +2 -2
  123. package/build/icons/IconCopy.js +4 -2
  124. package/build/icons/IconCopy.js.map +1 -1
  125. package/build/icons/IconDevice.d.ts +2 -2
  126. package/build/icons/IconDevice.js +14 -12
  127. package/build/icons/IconDevice.js.map +1 -1
  128. package/build/icons/IconDocument.d.ts +2 -2
  129. package/build/icons/IconDocument.js +4 -2
  130. package/build/icons/IconDocument.js.map +1 -1
  131. package/build/icons/IconDocumentReadOnly.d.ts +2 -2
  132. package/build/icons/IconDocumentReadOnly.js +5 -3
  133. package/build/icons/IconDocumentReadOnly.js.map +1 -1
  134. package/build/icons/IconExpert.d.ts +2 -2
  135. package/build/icons/IconExpert.js +5 -3
  136. package/build/icons/IconExpert.js.map +1 -1
  137. package/build/icons/IconFx.d.ts +2 -2
  138. package/build/icons/IconFx.js +4 -2
  139. package/build/icons/IconFx.js.map +1 -1
  140. package/build/icons/IconInstance.d.ts +2 -2
  141. package/build/icons/IconInstance.js +4 -2
  142. package/build/icons/IconInstance.js.map +1 -1
  143. package/build/icons/IconLogout.d.ts +2 -2
  144. package/build/icons/IconLogout.js +5 -3
  145. package/build/icons/IconLogout.js.map +1 -1
  146. package/build/icons/IconNoIcon.d.ts +2 -2
  147. package/build/icons/IconNoIcon.js +4 -2
  148. package/build/icons/IconNoIcon.js.map +1 -1
  149. package/build/icons/IconOpen.d.ts +2 -2
  150. package/build/icons/IconOpen.js +4 -2
  151. package/build/icons/IconOpen.js.map +1 -1
  152. package/build/icons/IconState.d.ts +2 -2
  153. package/build/icons/IconState.js +5 -3
  154. package/build/icons/IconState.js.map +1 -1
  155. package/build/icons/IconVacuum.d.ts +2 -2
  156. package/build/icons/IconVacuum.js +10 -8
  157. package/build/icons/IconVacuum.js.map +1 -1
  158. package/build/index.d.ts +5 -2
  159. package/build/index.js +3 -1
  160. package/build/index.js.map +1 -1
  161. package/package.json +8 -6
  162. package/build/Components/IconDeviceType.d.ts +0 -8
  163. package/build/Components/IconDeviceType.js +0 -212
  164. package/build/Components/IconDeviceType.js.map +0 -1
  165. package/build/icons/IconProps.d.ts +0 -15
  166. package/build/icons/IconProps.js +0 -2
  167. package/build/icons/IconProps.js.map +0 -1
@@ -23,7 +23,7 @@ interface InfoBoxState {
23
23
  /**
24
24
  * This component can be used to show important information or warnings to the user
25
25
  */
26
- export default class InfoBox extends React.Component<InfoBoxProps, InfoBoxState> {
26
+ export declare class InfoBox extends React.Component<InfoBoxProps, InfoBoxState> {
27
27
  private readonly refTypo;
28
28
  private height;
29
29
  private width;
@@ -4,7 +4,7 @@ import { Info, Warning, Close, Visibility, Check } from '@mui/icons-material';
4
4
  /**
5
5
  * This component can be used to show important information or warnings to the user
6
6
  */
7
- export default class InfoBox extends React.Component {
7
+ export class InfoBox extends React.Component {
8
8
  refTypo;
9
9
  height;
10
10
  width;
@@ -1 +1 @@
1
- {"version":3,"file":"InfoBox.js","sourceRoot":"./src/","sources":["Components/InfoBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAyB,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAwBrG;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,KAAK,CAAC,SAAqC;IAC3D,OAAO,CAAkC;IAClD,MAAM,CAAS;IACf,KAAK,CAAS;IAEtB,YAAY,KAAmB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK;SAClG,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACrC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oBACT,QAAQ,EAAE,UAAU;oBACpB,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,CAAC;oBACR,MAAM,EAAE,EAAE;iBACb,GACH,CACL,CAAC,CAAC,CAAC,IAAI,CACN,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from 'react';\nimport { Box, Typography } from '@mui/material';\nimport { Info, Warning, Close, Visibility, type SvgIconComponent, Check } from '@mui/icons-material';\n\ninterface InfoBoxProps {\n /** Text to display in the info box */\n children: string | (string | React.JSX.Element | null)[] | React.JSX.Element;\n /** The type determines the color and symbol */\n type: 'warning' | 'info' | 'error' | 'ok';\n /** If the Box is closeable */\n closeable?: boolean;\n /** Use together with `closeable: true`. You can specify in which variable in local storage the state of this info box could be stored */\n storeId?: string;\n /** Use together with `closeable: true`, listener called if close button clicked */\n onClose?: (desiredState: boolean) => void;\n /** Custom style */\n style?: React.CSSProperties;\n /** Icon position */\n iconPosition?: 'top' | 'middle';\n /** Use together with `closeable: true`. If the box is closed or not. In this case, it will be controlled from outside */\n closed?: boolean;\n}\n\ninterface InfoBoxState {\n closed: boolean;\n}\n/**\n * This component can be used to show important information or warnings to the user\n */\nexport default class InfoBox extends React.Component<InfoBoxProps, InfoBoxState> {\n private readonly refTypo: React.RefObject<HTMLDivElement>;\n private height: number;\n private width: number;\n\n constructor(props: InfoBoxProps) {\n super(props);\n this.state = {\n closed: this.props.storeId ? window.localStorage.getItem(this.props.storeId) === 'true' : false,\n };\n this.height = 0;\n this.width = 0;\n\n this.refTypo = React.createRef();\n }\n\n componentDidMount(): void {\n this.detectHeight();\n }\n\n onClick(): void {\n if (this.props.storeId && this.props.closed === undefined) {\n if (this.state.closed) {\n window.localStorage.removeItem(this.props.storeId);\n } else {\n window.localStorage.setItem(this.props.storeId, 'true');\n }\n }\n if (this.props.closed === undefined) {\n this.setState({ closed: !this.state.closed }, () => {\n // Inform about state change\n if (this.props.onClose) {\n this.props.onClose(this.state.closed);\n }\n });\n } else if (this.props.onClose) {\n this.props.onClose(!this.props.closed);\n }\n }\n\n detectHeight(): void {\n const closed = this.props.closed !== undefined ? this.props.closed : this.state.closed;\n // We must get the height of the element when it is open to make transition\n if (this.props.closeable && !closed && this.refTypo.current) {\n window.requestAnimationFrame(() => {\n const closed = this.props.closed !== undefined ? this.props.closed : this.state.closed;\n if (closed) {\n return;\n }\n if (this.refTypo.current && (!this.height || this.width !== this.refTypo.current.clientWidth)) {\n this.height = this.refTypo.current.clientHeight;\n this.width = this.refTypo.current.clientWidth;\n this.forceUpdate();\n }\n });\n }\n }\n\n componentDidUpdate(): void {\n this.detectHeight();\n }\n\n render(): React.ReactNode {\n const closed = this.props.closed !== undefined ? this.props.closed : this.state.closed;\n\n const Icon: SvgIconComponent = closed ? Visibility : Close;\n\n return (\n <Box\n className=\"iom-info-box\"\n style={{\n whiteSpace: 'preserve',\n display: 'flex',\n gap: 8,\n alignItems: closed || this.props.iconPosition === 'top' ? 'flex-start' : 'center',\n borderWidth: 1,\n borderStyle: 'solid',\n padding: 4,\n borderRadius: 5,\n marginBottom: 8,\n maxWidth: '100%',\n transition: 'height 0.5s',\n height: this.props.closeable ? (closed ? 30 : this.height || undefined) : undefined,\n overflow: this.props.closeable ? 'hidden' : undefined,\n position: 'relative',\n ...this.props.style,\n }}\n sx={{\n borderColor: theme =>\n this.props.type === 'ok' ? theme.palette.info.main : theme.palette[this.props.type].main,\n }}\n >\n {this.props.type === 'ok' ? (\n <Check style={{ color: '#0F0' }} />\n ) : this.props.type === 'info' ? (\n <Info color=\"primary\" />\n ) : (\n <Warning color={this.props.type} />\n )}\n <Typography ref={this.refTypo}>{this.props.children}</Typography>\n {this.props.closeable ? (\n <Icon\n sx={{\n color: theme => (theme.palette.mode === 'dark' ? 'lightgray' : 'gray'),\n // alignSelf: 'flex-start',\n cursor: 'pointer',\n position: 'absolute',\n top: 4,\n right: 4,\n }}\n onClick={() => this.onClick()}\n />\n ) : null}\n {/* Reserve place for button so it will not overlap the text */}\n {this.props.closeable ? <div style={{ width: 22 }} /> : null}\n {closed ? (\n <Box\n // This is a shadow box at the bottom of the InfoBox when it closed\n component=\"div\"\n sx={theme => {\n const color = theme.palette[this.props.type === 'ok' ? 'info' : this.props.type].main;\n return {\n background: `linear-gradient(${color}00 0%, ${color}10 60%, ${color}90 100%)`,\n };\n }}\n style={{\n bottom: 0,\n position: 'absolute',\n left: 0,\n right: 0,\n height: 10,\n }}\n />\n ) : null}\n </Box>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"InfoBox.js","sourceRoot":"./src/","sources":["Components/InfoBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAyB,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAwBrG;;GAEG;AACH,MAAM,OAAO,OAAQ,SAAQ,KAAK,CAAC,SAAqC;IACnD,OAAO,CAAkC;IAClD,MAAM,CAAS;IACf,KAAK,CAAS;IAEtB,YAAY,KAAmB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK;SAClG,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,iBAAiB;QACb,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,OAAO;QACH,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CA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AAI,CACN,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from 'react';\nimport { Box, Typography } from '@mui/material';\nimport { Info, Warning, Close, Visibility, type SvgIconComponent, Check } from '@mui/icons-material';\n\ninterface InfoBoxProps {\n /** Text to display in the info box */\n children: string | (string | React.JSX.Element | null)[] | React.JSX.Element;\n /** The type determines the color and symbol */\n type: 'warning' | 'info' | 'error' | 'ok';\n /** If the Box is closeable */\n closeable?: boolean;\n /** Use together with `closeable: true`. You can specify in which variable in local storage the state of this info box could be stored */\n storeId?: string;\n /** Use together with `closeable: true`, listener called if close button clicked */\n onClose?: (desiredState: boolean) => void;\n /** Custom style */\n style?: React.CSSProperties;\n /** Icon position */\n iconPosition?: 'top' | 'middle';\n /** Use together with `closeable: true`. If the box is closed or not. In this case, it will be controlled from outside */\n closed?: boolean;\n}\n\ninterface InfoBoxState {\n closed: boolean;\n}\n/**\n * This component can be used to show important information or warnings to the user\n */\nexport class InfoBox extends React.Component<InfoBoxProps, InfoBoxState> {\n private readonly refTypo: React.RefObject<HTMLDivElement>;\n private height: number;\n private width: number;\n\n constructor(props: InfoBoxProps) {\n super(props);\n this.state = {\n closed: this.props.storeId ? window.localStorage.getItem(this.props.storeId) === 'true' : false,\n };\n this.height = 0;\n this.width = 0;\n\n this.refTypo = React.createRef();\n }\n\n componentDidMount(): void {\n this.detectHeight();\n }\n\n onClick(): void {\n if (this.props.storeId && this.props.closed === undefined) {\n if (this.state.closed) {\n window.localStorage.removeItem(this.props.storeId);\n } else {\n window.localStorage.setItem(this.props.storeId, 'true');\n }\n }\n if (this.props.closed === undefined) {\n this.setState({ closed: !this.state.closed }, () => {\n // Inform about state change\n if (this.props.onClose) {\n this.props.onClose(this.state.closed);\n }\n });\n } else if (this.props.onClose) {\n this.props.onClose(!this.props.closed);\n }\n }\n\n detectHeight(): void {\n const closed = this.props.closed !== undefined ? this.props.closed : this.state.closed;\n // We must get the height of the element when it is open to make transition\n if (this.props.closeable && !closed && this.refTypo.current) {\n window.requestAnimationFrame(() => {\n const closed = this.props.closed !== undefined ? this.props.closed : this.state.closed;\n if (closed) {\n return;\n }\n if (this.refTypo.current && (!this.height || this.width !== this.refTypo.current.clientWidth)) {\n this.height = this.refTypo.current.clientHeight;\n this.width = this.refTypo.current.clientWidth;\n this.forceUpdate();\n }\n });\n }\n }\n\n componentDidUpdate(): void {\n this.detectHeight();\n }\n\n render(): React.ReactNode {\n const closed = this.props.closed !== undefined ? this.props.closed : this.state.closed;\n\n const Icon: SvgIconComponent = closed ? Visibility : Close;\n\n return (\n <Box\n className=\"iom-info-box\"\n style={{\n whiteSpace: 'preserve',\n display: 'flex',\n gap: 8,\n alignItems: closed || this.props.iconPosition === 'top' ? 'flex-start' : 'center',\n borderWidth: 1,\n borderStyle: 'solid',\n padding: 4,\n borderRadius: 5,\n marginBottom: 8,\n maxWidth: '100%',\n transition: 'height 0.5s',\n height: this.props.closeable ? (closed ? 30 : this.height || undefined) : undefined,\n overflow: this.props.closeable ? 'hidden' : undefined,\n position: 'relative',\n ...this.props.style,\n }}\n sx={{\n borderColor: theme =>\n this.props.type === 'ok' ? theme.palette.info.main : theme.palette[this.props.type].main,\n }}\n >\n {this.props.type === 'ok' ? (\n <Check style={{ color: '#0F0' }} />\n ) : this.props.type === 'info' ? (\n <Info color=\"primary\" />\n ) : (\n <Warning color={this.props.type} />\n )}\n <Typography ref={this.refTypo}>{this.props.children}</Typography>\n {this.props.closeable ? (\n <Icon\n sx={{\n color: theme => (theme.palette.mode === 'dark' ? 'lightgray' : 'gray'),\n // alignSelf: 'flex-start',\n cursor: 'pointer',\n position: 'absolute',\n top: 4,\n right: 4,\n }}\n onClick={() => this.onClick()}\n />\n ) : null}\n {/* Reserve place for button so it will not overlap the text */}\n {this.props.closeable ? <div style={{ width: 22 }} /> : null}\n {closed ? (\n <Box\n // This is a shadow box at the bottom of the InfoBox when it closed\n component=\"div\"\n sx={theme => {\n const color = theme.palette[this.props.type === 'ok' ? 'info' : this.props.type].main;\n return {\n background: `linear-gradient(${color}00 0%, ${color}10 60%, ${color}90 100%)`,\n };\n }}\n style={{\n bottom: 0,\n position: 'absolute',\n left: 0,\n right: 0,\n height: 10,\n }}\n />\n ) : null}\n </Box>\n );\n }\n}\n"]}
@@ -9,7 +9,6 @@ interface SelectWithIconProps {
9
9
  onChange: (id: string) => void;
10
10
  disabled?: boolean;
11
11
  list?: ioBroker.Object[] | Record<string, ioBroker.Object>;
12
- options?: Record<string, any>;
13
12
  different?: string | boolean;
14
13
  label?: string;
15
14
  fullWidth?: boolean;
@@ -22,8 +22,8 @@ export class SelectWithIcon extends Component {
22
22
  this.wordDifferent = props.t('ra___different__');
23
23
  }
24
24
  let list;
25
- if (Array.isArray(props.list || props.options)) {
26
- list = (props.list || props.options).map(obj => ({
25
+ if (Array.isArray(props.list)) {
26
+ list = props.list.filter(obj => obj?._id && obj.common).map(obj => ({
27
27
  name: Utils.getObjectNameFromObj(obj, props.lang)
28
28
  .replace('system.group.', '')
29
29
  .replace('system.user.', '')
@@ -35,7 +35,7 @@ export class SelectWithIcon extends Component {
35
35
  }));
36
36
  }
37
37
  else {
38
- list = Object.values((props.list || props.options)).map(obj => ({
38
+ list = Object.values(props.list).filter(obj => obj?._id && obj.common).map(obj => ({
39
39
  name: Utils.getObjectNameFromObj(obj, props.lang)
40
40
  .replace('system.group.', '')
41
41
  .replace('system.user.', '')
@@ -1 +1 @@
1
- {"version":3,"file":"SelectWithIcon.js","sourceRoot":"./src/","sources":["Components/SelectWithIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK1E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS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AE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAE/B,oBAAC,UAAU,QAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAc;YAC1C,MAAM,CACG,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { Component } from 'react';\n\nimport { FormControl, InputLabel, MenuItem, Select } from '@mui/material';\nimport type { InputProps } from '@mui/material/Input';\n\nimport type { ThemeType, Translate } from '../types';\n\nimport { Icon } from './Icon';\nimport { Utils } from './Utils';\nimport { I18n } from '../i18n';\n\nconst styles: Record<string, React.CSSProperties> = {\n different: {\n opacity: 0.5,\n },\n icon: {\n width: 16,\n height: 16,\n marginRight: 8,\n },\n};\n\ninterface SelectWithIconProps {\n t: Translate;\n lang: ioBroker.Languages;\n themeType: ThemeType;\n value?: string;\n onChange: (id: string) => void;\n disabled?: boolean;\n list?: ioBroker.Object[] | Record<string, ioBroker.Object>; // one of \"list\"(Array) or \"options\"(object) is required\n options?: Record<string, any>; // one of \"list\"(Array) or \"options\"(object) is required\n different?: string | boolean;\n label?: string;\n fullWidth?: boolean;\n className?: string;\n style?: React.CSSProperties;\n removePrefix?: string;\n allowNone?: boolean;\n inputProps?: InputProps['inputProps'];\n dense?: boolean;\n}\n\ninterface TextWithIconItem {\n name: string;\n value: string;\n icon?: string;\n color?: string;\n}\n\ninterface SelectWithIconState {\n list: TextWithIconItem[];\n}\n\nexport class SelectWithIcon extends Component<SelectWithIconProps, SelectWithIconState> {\n private readonly wordDifferent: string | undefined;\n\n private timeout: ReturnType<typeof setTimeout> | null = null;\n\n constructor(props: SelectWithIconProps) {\n super(props);\n\n if (props.different) {\n this.wordDifferent = props.t('ra___different__');\n }\n\n let list: TextWithIconItem[];\n if (Array.isArray(props.list || props.options)) {\n list = ((props.list || props.options) as ioBroker.Object[]).map(obj => ({\n name: Utils.getObjectNameFromObj(obj, props.lang)\n .replace('system.group.', '')\n .replace('system.user.', '')\n .replace('enum.rooms.', '')\n .replace('enum.functions.', ''),\n value: obj._id,\n icon: obj.common?.icon,\n color: obj.common?.color,\n }));\n } else {\n list = Object.values((props.list || props.options) as Record<string, ioBroker.Object>).map(obj => ({\n name: Utils.getObjectNameFromObj(obj, props.lang)\n .replace('system.group.', '')\n .replace('system.user.', '')\n .replace('enum.rooms.', '')\n .replace('enum.functions.', ''),\n value: obj._id,\n icon: obj.common?.icon,\n color: obj.common?.color,\n }));\n }\n\n if (props.different && props.value === props.different) {\n list.unshift({ value: props.different, name: this.wordDifferent || '' });\n }\n\n if (props.allowNone) {\n list.unshift({ value: '', name: I18n.t('ra_none') });\n }\n\n this.state = {\n list,\n };\n }\n\n render(): React.JSX.Element {\n if (this.props.allowNone && !this.state.list.find(obj => obj.value === '')) {\n this.timeout =\n this.timeout ||\n setTimeout(() => {\n this.timeout = null;\n const list: TextWithIconItem[] = JSON.parse(JSON.stringify(this.state.list));\n list.unshift({ value: '', name: I18n.t('ra_none') });\n this.setState({ list });\n }, 100);\n } else if (!this.props.allowNone && this.state.list.find(obj => obj.value === '')) {\n this.timeout =\n this.timeout ||\n setTimeout(() => {\n this.timeout = null;\n const list: TextWithIconItem[] = JSON.parse(JSON.stringify(this.state.list));\n const i = this.state.list.findIndex(obj => obj.value === '');\n list.splice(i, 1);\n this.setState({ list });\n }, 100);\n }\n\n const item = this.state.list.find(\n it =>\n it.value === this.props.value ||\n (this.props.removePrefix && it.value.replace(this.props.removePrefix, '') === this.props.value),\n );\n\n const style =\n this.props.value === this.props.different\n ? {}\n : {\n color: item?.color || undefined,\n backgroundColor: Utils.getInvertedColor(item?.color || '', this.props.themeType),\n };\n\n if (this.props.dense && this.props.style) {\n Object.assign(style, this.props.style);\n }\n\n const select = (\n <Select\n variant=\"standard\"\n disabled={this.props.disabled}\n value={this.props.value}\n slotProps={{\n input: this.props.inputProps,\n }}\n renderValue={\n (/* value */) => (\n <span>\n {item?.icon ? (\n <Icon\n src={item?.icon}\n style={styles.icon}\n />\n ) : null}\n {item?.name}\n </span>\n )\n }\n sx={{\n '&.MuiSelect-root': this.props.value === this.props.different ? styles.different : {},\n }}\n classes={{\n root: this.props.dense ? this.props.className : '',\n }}\n style={style}\n onChange={el => {\n if (this.props.different && el.target.value !== this.props.different) {\n let pos = null;\n for (let i = 0; i < this.state.list.length; i++) {\n if (this.state.list[i].value === this.props.different) {\n pos = i;\n break;\n }\n }\n if (pos !== null) {\n const list: TextWithIconItem[] = Utils.clone(this.state.list) as TextWithIconItem[];\n list.splice(pos, 1);\n this.setState({ list }, () => this.props.onChange(el.target.value));\n return;\n }\n }\n\n this.props.onChange(\n this.props.removePrefix\n ? el.target.value.replace(this.props.removePrefix, '')\n : el.target.value,\n );\n }}\n >\n {this.state.list.map(el => (\n <MenuItem\n style={\n this.props.different && el.value === this.props.different\n ? styles.different\n : {\n color: el.color || undefined,\n backgroundColor: Utils.getInvertedColor(el.color || '', this.props.themeType),\n }\n }\n key={el.value}\n value={el.value}\n >\n {el.icon ? (\n <Icon\n src={el.icon}\n style={styles.icon}\n />\n ) : null}\n {el.name}\n </MenuItem>\n ))}\n </Select>\n );\n\n if (this.props.dense) {\n return select;\n }\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth={!!this.props.fullWidth}\n style={this.props.style}\n className={this.props.className}\n >\n <InputLabel>{this.props.label}</InputLabel>\n {select}\n </FormControl>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"SelectWithIcon.js","sourceRoot":"./src/","sources":["Components/SelectWithIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK1E,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SA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AC,UAAU,EAClB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAE/B,oBAAC,UAAU,QAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAc;YAC1C,MAAM,CACG,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { Component } from 'react';\n\nimport { FormControl, InputLabel, MenuItem, Select } from '@mui/material';\nimport type { InputProps } from '@mui/material/Input';\n\nimport type { ThemeType, Translate } from '../types';\n\nimport { Icon } from './Icon';\nimport { Utils } from './Utils';\nimport { I18n } from '../i18n';\n\nconst styles: Record<string, React.CSSProperties> = {\n different: {\n opacity: 0.5,\n },\n icon: {\n width: 16,\n height: 16,\n marginRight: 8,\n },\n};\n\ninterface SelectWithIconProps {\n t: Translate;\n lang: ioBroker.Languages;\n themeType: ThemeType;\n value?: string;\n onChange: (id: string) => void;\n disabled?: boolean;\n list?: ioBroker.Object[] | Record<string, ioBroker.Object>; // one of \"list\"(Array) or \"options\"(object) is required\n different?: string | boolean;\n label?: string;\n fullWidth?: boolean;\n className?: string;\n style?: React.CSSProperties;\n removePrefix?: string;\n allowNone?: boolean;\n inputProps?: InputProps['inputProps'];\n dense?: boolean;\n}\n\ninterface TextWithIconItem {\n name: string;\n value: string;\n icon?: string;\n color?: string;\n}\n\ninterface SelectWithIconState {\n list: TextWithIconItem[];\n}\n\nexport class SelectWithIcon extends Component<SelectWithIconProps, SelectWithIconState> {\n private readonly wordDifferent: string | undefined;\n\n private timeout: ReturnType<typeof setTimeout> | null = null;\n\n constructor(props: SelectWithIconProps) {\n super(props);\n\n if (props.different) {\n this.wordDifferent = props.t('ra___different__');\n }\n\n let list: TextWithIconItem[];\n if (Array.isArray(props.list)) {\n list = props.list.filter(obj => obj?._id && obj.common).map(obj => ({\n name: Utils.getObjectNameFromObj(obj, props.lang)\n .replace('system.group.', '')\n .replace('system.user.', '')\n .replace('enum.rooms.', '')\n .replace('enum.functions.', ''),\n value: obj._id,\n icon: obj.common?.icon,\n color: obj.common?.color,\n }));\n } else {\n list = Object.values(props.list as Record<string, ioBroker.Object>).filter(obj => obj?._id && obj.common).map(obj => ({\n name: Utils.getObjectNameFromObj(obj, props.lang)\n .replace('system.group.', '')\n .replace('system.user.', '')\n .replace('enum.rooms.', '')\n .replace('enum.functions.', ''),\n value: obj._id,\n icon: obj.common?.icon,\n color: obj.common?.color,\n }));\n }\n\n if (props.different && props.value === props.different) {\n list.unshift({ value: props.different, name: this.wordDifferent || '' });\n }\n\n if (props.allowNone) {\n list.unshift({ value: '', name: I18n.t('ra_none') });\n }\n\n this.state = {\n list,\n };\n }\n\n render(): React.JSX.Element {\n if (this.props.allowNone && !this.state.list.find(obj => obj.value === '')) {\n this.timeout =\n this.timeout ||\n setTimeout(() => {\n this.timeout = null;\n const list: TextWithIconItem[] = JSON.parse(JSON.stringify(this.state.list));\n list.unshift({ value: '', name: I18n.t('ra_none') });\n this.setState({ list });\n }, 100);\n } else if (!this.props.allowNone && this.state.list.find(obj => obj.value === '')) {\n this.timeout =\n this.timeout ||\n setTimeout(() => {\n this.timeout = null;\n const list: TextWithIconItem[] = JSON.parse(JSON.stringify(this.state.list));\n const i = this.state.list.findIndex(obj => obj.value === '');\n list.splice(i, 1);\n this.setState({ list });\n }, 100);\n }\n\n const item = this.state.list.find(\n it =>\n it.value === this.props.value ||\n (this.props.removePrefix && it.value.replace(this.props.removePrefix, '') === this.props.value),\n );\n\n const style =\n this.props.value === this.props.different\n ? {}\n : {\n color: item?.color || undefined,\n backgroundColor: Utils.getInvertedColor(item?.color || '', this.props.themeType),\n };\n\n if (this.props.dense && this.props.style) {\n Object.assign(style, this.props.style);\n }\n\n const select = (\n <Select\n variant=\"standard\"\n disabled={this.props.disabled}\n value={this.props.value}\n slotProps={{\n input: this.props.inputProps,\n }}\n renderValue={\n (/* value */) => (\n <span>\n {item?.icon ? (\n <Icon\n src={item?.icon}\n style={styles.icon}\n />\n ) : null}\n {item?.name}\n </span>\n )\n }\n sx={{\n '&.MuiSelect-root': this.props.value === this.props.different ? styles.different : {},\n }}\n classes={{\n root: this.props.dense ? this.props.className : '',\n }}\n style={style}\n onChange={el => {\n if (this.props.different && el.target.value !== this.props.different) {\n let pos = null;\n for (let i = 0; i < this.state.list.length; i++) {\n if (this.state.list[i].value === this.props.different) {\n pos = i;\n break;\n }\n }\n if (pos !== null) {\n const list: TextWithIconItem[] = Utils.clone(this.state.list) as TextWithIconItem[];\n list.splice(pos, 1);\n this.setState({ list }, () => this.props.onChange(el.target.value));\n return;\n }\n }\n\n this.props.onChange(\n this.props.removePrefix\n ? el.target.value.replace(this.props.removePrefix, '')\n : el.target.value,\n );\n }}\n >\n {this.state.list.map(el => (\n <MenuItem\n style={\n this.props.different && el.value === this.props.different\n ? styles.different\n : {\n color: el.color || undefined,\n backgroundColor: Utils.getInvertedColor(el.color || '', this.props.themeType),\n }\n }\n key={el.value}\n value={el.value}\n >\n {el.icon ? (\n <Icon\n src={el.icon}\n style={styles.icon}\n />\n ) : null}\n {el.name}\n </MenuItem>\n ))}\n </Select>\n );\n\n if (this.props.dense) {\n return select;\n }\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth={!!this.props.fullWidth}\n style={this.props.style}\n className={this.props.className}\n >\n <InputLabel>{this.props.label}</InputLabel>\n {select}\n </FormControl>\n );\n }\n}\n"]}
@@ -5,7 +5,6 @@ interface TextWithIconProps {
5
5
  themeType?: ThemeType;
6
6
  value: string | Record<string, any>;
7
7
  list?: ioBroker.Object[] | Record<string, ioBroker.Object>;
8
- options?: Record<string, any>;
9
8
  className?: string;
10
9
  style?: React.CSSProperties;
11
10
  title?: string;
@@ -28,11 +28,11 @@ export function TextWithIcon(props) {
28
28
  let item;
29
29
  const prefix = props.removePrefix || '';
30
30
  if (typeof value === 'string') {
31
- const list = props.list || props.options;
31
+ const list = props.list;
32
32
  if (list) {
33
33
  // if a list is array, then it is list of ioBroker.Object
34
34
  if (Array.isArray(list)) {
35
- const _item = list.find((obj) => obj._id === prefix + value);
35
+ const _item = list.find((obj) => obj?._id === prefix + value);
36
36
  if (_item) {
37
37
  item = {
38
38
  name: Utils.getObjectNameFromObj(_item, props.lang).replace('system.group.', ''),
@@ -49,7 +49,7 @@ export function TextWithIcon(props) {
49
49
  }
50
50
  }
51
51
  else if (list[prefix + value]) {
52
- // List is object with key-value pairs: {'enum.rooms.1': {common: {name: 'Room 1'}}}
52
+ // List is the object with key-value pairs: {'enum.rooms.1': {common: {name: 'Room 1'}}}
53
53
  const obj = list[prefix + value];
54
54
  item = {
55
55
  name: Utils.getObjectNameFromObj(obj, props.lang).replace('system.group.', ''),
@@ -1 +1 @@
1
- {"version":3,"file":"TextWithIcon.js","sourceRoot":"./src/","sources":["Components/TextWithIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,MAAM,MAAM,GAAwC;IAChD,GAAG,EAAE;QACD,YAAY,EAAE,CAAC;QACf,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,QAAQ;QACpB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;KACvB;IACD,IAAI,EAAE;QACF,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,CAAC;QACd,aAAa,EAAE,QAAQ;KAC1B;IACD,IAAI,EAAE;QACF,OAAO,EAAE,cAAc;QACvB,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,UAAU;KAC3B;CACJ,CAAC;AA4BF,MAAM,UAAU,YAAY,CAAC,KAAwB;IACjD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IA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\nimport { Icon } from './Icon';\nimport { Utils } from './Utils';\nimport type { ThemeType } from '../types';\n\nconst styles: Record<string, React.CSSProperties> = {\n div: {\n borderRadius: 3,\n padding: '0 3px',\n lineHeight: '20px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n display: 'flex',\n alignItems: 'center',\n },\n icon: {\n width: 16,\n height: 16,\n marginRight: 8,\n verticalAlign: 'middle',\n },\n text: {\n display: 'inline-block',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n },\n};\n\ninterface TextWithIconProps {\n lang: ioBroker.Languages;\n themeType?: ThemeType;\n value: string | Record<string, any>;\n list?: ioBroker.Object[] | Record<string, ioBroker.Object>;\n options?: Record<string, any>;\n className?: string;\n style?: React.CSSProperties;\n title?: string;\n removePrefix?: string;\n moreClasses?: {\n root?: string;\n icon?: string;\n text?: string;\n };\n icon?: string;\n color?: string;\n}\n\ninterface TextWithIconItem {\n name: string;\n value: string;\n icon?: string;\n color?: string;\n}\n\nexport function TextWithIcon(props: TextWithIconProps): React.JSX.Element {\n const value = props.value;\n let item: TextWithIconItem;\n const prefix = props.removePrefix || '';\n\n if (typeof value === 'string') {\n const list = props.list || props.options;\n if (list) {\n // if a list is array, then it is list of ioBroker.Object\n if (Array.isArray(list)) {\n const _item: ioBroker.Object = list.find((obj: ioBroker.Object) => obj._id === prefix + value);\n if (_item) {\n item = {\n name: Utils.getObjectNameFromObj(_item, props.lang).replace('system.group.', ''),\n value: _item._id,\n icon: props.icon || _item.common?.icon,\n color: props.color || _item.common?.color,\n };\n } else {\n item = {\n name: value,\n value: prefix + value,\n };\n }\n } else if (list[prefix + value]) {\n // List is object with key-value pairs: {'enum.rooms.1': {common: {name: 'Room 1'}}}\n const obj: ioBroker.Object = list[prefix + value];\n item = {\n name: Utils.getObjectNameFromObj(obj, props.lang).replace('system.group.', ''),\n value: obj._id,\n icon: props.icon || obj.common?.icon,\n color: props.color || obj.common?.color,\n };\n } else {\n // value is a string, ignore list\n item = {\n name: value,\n value: prefix + value,\n icon: props.icon,\n color: props.color,\n };\n }\n } else {\n item = {\n name: value,\n value: prefix + value,\n icon: props.icon,\n color: props.color,\n };\n }\n } else if (!value || typeof value !== 'object') {\n item = {\n name: '',\n value: '',\n icon: props.icon,\n color: props.color,\n };\n } else {\n // Item is an ioBroker.Object\n const obj: ioBroker.Object = value as ioBroker.Object;\n item = {\n name: Utils.getObjectNameFromObj(obj, props.lang)\n .replace('system.group.', '')\n .replace('system.user.', '')\n .replace('enum.rooms.', '')\n .replace('enum.functions.', ''),\n value: obj._id,\n icon: props.icon || obj.common?.icon,\n color: props.color || obj.common?.color,\n };\n }\n\n const style = item?.color\n ? {\n border: `1px solid ${Utils.invertColor(item?.color)}`,\n color: Utils.getInvertedColor(item?.color, props.themeType || 'light', true) || undefined,\n backgroundColor: item?.color,\n }\n : {};\n\n return (\n <div\n style={{ ...(props.style || undefined), ...styles.div, ...(style || undefined) }}\n className={Utils.clsx(props.className, props.moreClasses?.root)}\n title={props.title || item.value}\n >\n {item?.icon ? (\n <Icon\n src={item?.icon}\n className={props.moreClasses?.icon}\n style={styles.icon}\n />\n ) : null}\n <div\n style={styles.text}\n className={props.moreClasses?.text}\n >\n {item?.name}\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"TextWithIcon.js","sourceRoot":"./src/","sources":["Components/TextWithIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,MAAM,MAAM,GAAwC;IAChD,GAAG,EAAE;QACD,YAAY,EAAE,CAAC;QACf,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,QAAQ;QACpB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;KACvB;IACD,IAAI,EAAE;QACF,KAAK,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CAAC,WAAW,EAAE,IAAI,EAClC,KAAK,EAAE,MAAM,CAAC,IAAI,GACpB,CACL,CAAC,CAAC,CAAC,IAAI;QACR,6BACI,KAAK,EAAE,MAAM,CAAC,IAAI,EAClB,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,IAEjC,IAAI,EAAE,IAAI,CACT,CACJ,CACT,CAAC;AACN,CAAC","sourcesContent":["import React from 'react';\n\nimport { Icon } from './Icon';\nimport { Utils } from './Utils';\nimport type { ThemeType } from '../types';\n\nconst styles: Record<string, React.CSSProperties> = {\n div: {\n borderRadius: 3,\n padding: '0 3px',\n lineHeight: '20px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n display: 'flex',\n alignItems: 'center',\n },\n icon: {\n width: 16,\n height: 16,\n marginRight: 8,\n verticalAlign: 'middle',\n },\n text: {\n display: 'inline-block',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n },\n};\n\ninterface TextWithIconProps {\n lang: ioBroker.Languages;\n themeType?: ThemeType;\n value: string | Record<string, any>;\n list?: ioBroker.Object[] | Record<string, ioBroker.Object>;\n className?: string;\n style?: React.CSSProperties;\n title?: string;\n removePrefix?: string;\n moreClasses?: {\n root?: string;\n icon?: string;\n text?: string;\n };\n icon?: string;\n color?: string;\n}\n\ninterface TextWithIconItem {\n name: string;\n value: string;\n icon?: string;\n color?: string;\n}\n\nexport function TextWithIcon(props: TextWithIconProps): React.JSX.Element {\n const value = props.value;\n let item: TextWithIconItem;\n const prefix = props.removePrefix || '';\n\n if (typeof value === 'string') {\n const list = props.list;\n if (list) {\n // if a list is array, then it is list of ioBroker.Object\n if (Array.isArray(list)) {\n const _item: ioBroker.Object = list.find((obj: ioBroker.Object) => obj?._id === prefix + value);\n if (_item) {\n item = {\n name: Utils.getObjectNameFromObj(_item, props.lang).replace('system.group.', ''),\n value: _item._id,\n icon: props.icon || _item.common?.icon,\n color: props.color || _item.common?.color,\n };\n } else {\n item = {\n name: value,\n value: prefix + value,\n };\n }\n } else if (list[prefix + value]) {\n // List is the object with key-value pairs: {'enum.rooms.1': {common: {name: 'Room 1'}}}\n const obj: ioBroker.Object = list[prefix + value];\n item = {\n name: Utils.getObjectNameFromObj(obj, props.lang).replace('system.group.', ''),\n value: obj._id,\n icon: props.icon || obj.common?.icon,\n color: props.color || obj.common?.color,\n };\n } else {\n // value is a string, ignore list\n item = {\n name: value,\n value: prefix + value,\n icon: props.icon,\n color: props.color,\n };\n }\n } else {\n item = {\n name: value,\n value: prefix + value,\n icon: props.icon,\n color: props.color,\n };\n }\n } else if (!value || typeof value !== 'object') {\n item = {\n name: '',\n value: '',\n icon: props.icon,\n color: props.color,\n };\n } else {\n // Item is an ioBroker.Object\n const obj: ioBroker.Object = value as ioBroker.Object;\n item = {\n name: Utils.getObjectNameFromObj(obj, props.lang)\n .replace('system.group.', '')\n .replace('system.user.', '')\n .replace('enum.rooms.', '')\n .replace('enum.functions.', ''),\n value: obj._id,\n icon: props.icon || obj.common?.icon,\n color: props.color || obj.common?.color,\n };\n }\n\n const style = item?.color\n ? {\n border: `1px solid ${Utils.invertColor(item?.color)}`,\n color: Utils.getInvertedColor(item?.color, props.themeType || 'light', true) || undefined,\n backgroundColor: item?.color,\n }\n : {};\n\n return (\n <div\n style={{ ...(props.style || undefined), ...styles.div, ...(style || undefined) }}\n className={Utils.clsx(props.className, props.moreClasses?.root)}\n title={props.title || item.value}\n >\n {item?.icon ? (\n <Icon\n src={item?.icon}\n className={props.moreClasses?.icon}\n style={styles.icon}\n />\n ) : null}\n <div\n style={styles.text}\n className={props.moreClasses?.text}\n >\n {item?.name}\n </div>\n </div>\n );\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { Types } from '@iobroker/type-detector';
3
+ export type TypesExtended = Types | 'invalid' | 'hub3' | 'node' | 'hub5' | 'controller';
4
+ export interface IconProps {
5
+ /** URL, UTF-8 character, or svg code (data:image/svg...) */
6
+ src?: string | React.JSX.Element | null | undefined;
7
+ /** Class name */
8
+ className?: string;
9
+ /** Style for image */
10
+ style?: React.CSSProperties;
11
+ /** Styles for mui */
12
+ sx?: Record<string, any>;
13
+ /** Tooltip */
14
+ title?: string | true;
15
+ /** Styles for utf-8 characters */
16
+ styleUTF8?: React.CSSProperties;
17
+ /** On error handler */
18
+ onError?: React.ReactEventHandler<HTMLImageElement>;
19
+ /** Reference to image */
20
+ ref?: React.RefObject<HTMLImageElement>;
21
+ /** Alternative text for image */
22
+ alt?: string;
23
+ /** On click handler */
24
+ onClick?: React.MouseEventHandler<any>;
25
+ }
26
+ export type TypeIconProps = IconProps & {
27
+ type?: TypesExtended;
28
+ };
29
+ export declare function TypeIcon(props: TypeIconProps): React.JSX.Element | null;
@@ -0,0 +1,111 @@
1
+ import React, { useEffect } from 'react';
2
+ import { Box, Tooltip } from '@mui/material';
3
+ import { AiOutlineLineChart as TypeIconChart } from 'react-icons/ai';
4
+ import { GoDeviceCameraVideo as TypeIconCamera } from 'react-icons/go';
5
+ import {
6
+ // FaExternalLinkSquareAlt as TypeIconURL,
7
+ FaImage as TypeIconImage, FaRegLightbulb as TypeIconDimmer, FaInfoCircle as TypeIconInfo, FaLightbulb as TypeIconLight, FaLock as TypeIconLock, FaStreetView as TypeIconLocation, FaStepForward as TypeIconMedia, FaSlidersH as TypeIconSlider, FaVolumeDown as TypeIconVolume, FaVolumeUp as TypeIconVolumeGroup, FaFan as TypeIconAC, FaWrench as TypeIconInstance, } from 'react-icons/fa';
8
+ import { MdFormatColorFill as TypeIconHUE, MdFormatColorFill as TypeIconCT, MdWarning as TypeIconWarning, MdQuestionMark as TypeIconUnknown, MdOutlineMyLocation as TypeIconLocationOne, MdDeviceHub as TypeIconHub3, MdPolyline as TypeIconNode, MdHub as TypeIconHub5, MdControlCamera as TypeIconController, } from 'react-icons/md';
9
+ import { WiCloudy as TypeIconWeather } from 'react-icons/wi';
10
+ import { IoIosRadioButtonOn as TypeIconButtonSensor } from 'react-icons/io';
11
+ import { TbSunElectricity as TypeIconIlluminance } from 'react-icons/tb';
12
+ import { PiPaletteDuotone as TypeIconRGBWSingle } from 'react-icons/pi';
13
+ import { Types } from '@iobroker/type-detector';
14
+ import { I18n } from '../../i18n';
15
+ import { Icon } from '../Icon';
16
+ import { Cleaner as TypeIconVacuumCleaner, Humidity as TypeIconHumidity, Jalousie as TypeIconBlinds, PushButton as TypeIconButton, DoorOpened as TypeIconDoor, FireOn as TypeIconFireAlarm, FloodOn as TypeIconFloodAlarm, Gate as TypeIconGate, MotionOn as TypeIconMotion, RGB as TypeIconRGB, Socket as TypeIconSocket, Thermometer as TypeIconTemperature, Thermostat as TypeIconThermostat,
17
+ // HeatValve as TypeIconValve,
18
+ WindowOpened as TypeIconWindow, WindowTilted as TypeIconWindowTilt, } from './icons';
19
+ const TYPE_ICONS = {
20
+ [Types.airCondition]: TypeIconAC,
21
+ [Types.blind]: TypeIconBlinds,
22
+ [Types.blindButtons]: TypeIconBlinds,
23
+ [Types.button]: TypeIconButton,
24
+ [Types.buttonSensor]: TypeIconButtonSensor,
25
+ [Types.camera]: TypeIconCamera,
26
+ [Types.chart]: TypeIconChart,
27
+ // [Types.url]: TypeIconURL,
28
+ [Types.image]: TypeIconImage,
29
+ [Types.dimmer]: TypeIconDimmer,
30
+ [Types.door]: TypeIconDoor,
31
+ [Types.fireAlarm]: TypeIconFireAlarm,
32
+ // @ts-expect-error special case
33
+ 'sensor.alarm.fire': TypeIconFireAlarm,
34
+ [Types.floodAlarm]: TypeIconFloodAlarm,
35
+ 'sensor.alarm.flood': TypeIconFloodAlarm,
36
+ [Types.gate]: TypeIconGate,
37
+ [Types.humidity]: TypeIconHumidity,
38
+ [Types.illuminance]: TypeIconIlluminance,
39
+ [Types.info]: TypeIconInfo,
40
+ [Types.light]: TypeIconLight,
41
+ [Types.lock]: TypeIconLock,
42
+ [Types.location]: TypeIconLocation,
43
+ [Types.location_one]: TypeIconLocationOne,
44
+ [Types.media]: TypeIconMedia,
45
+ [Types.motion]: TypeIconMotion,
46
+ [Types.ct]: TypeIconCT,
47
+ [Types.rgb]: TypeIconRGB,
48
+ [Types.rgbSingle]: TypeIconRGB,
49
+ [Types.rgbwSingle]: TypeIconRGBWSingle,
50
+ [Types.hue]: TypeIconHUE,
51
+ [Types.cie]: TypeIconRGB,
52
+ [Types.slider]: TypeIconSlider,
53
+ [Types.socket]: TypeIconSocket,
54
+ [Types.temperature]: TypeIconTemperature,
55
+ [Types.thermostat]: TypeIconThermostat,
56
+ // [Types.valve]: TypeIconValve,
57
+ [Types.vacuumCleaner]: TypeIconVacuumCleaner,
58
+ [Types.volume]: TypeIconVolume,
59
+ [Types.volumeGroup]: TypeIconVolumeGroup,
60
+ [Types.window]: TypeIconWindow,
61
+ [Types.windowTilt]: TypeIconWindowTilt,
62
+ [Types.weatherCurrent]: TypeIconWeather,
63
+ [Types.weatherForecast]: TypeIconWeather,
64
+ [Types.warning]: TypeIconWarning,
65
+ [Types.unknown]: TypeIconUnknown,
66
+ [Types.instance]: TypeIconInstance,
67
+ // Special matter types
68
+ invalid: TypeIconWarning,
69
+ hub3: TypeIconHub3,
70
+ node: TypeIconNode,
71
+ hub5: TypeIconHub5,
72
+ controller: TypeIconController,
73
+ };
74
+ const defaultStyle = {
75
+ width: 32,
76
+ height: 32,
77
+ };
78
+ export function TypeIcon(props) {
79
+ const language = I18n.getLanguage();
80
+ const [loaded, setLoaded] = React.useState(window.iobTypeWordsLoaded === language);
81
+ useEffect(() => {
82
+ if (props.title && window.iobTypeWordsLoaded !== language) {
83
+ // Load translations dynamically
84
+ void import(`./i18n/${language}.json`).then(i18n => {
85
+ I18n.extendTranslations(i18n.default, language);
86
+ window.iobTypeWordsLoaded = language;
87
+ setLoaded(true);
88
+ });
89
+ }
90
+ }, [language, props.title]);
91
+ if (!loaded && props.title) {
92
+ return (React.createElement(Box, { style: { ...defaultStyle, ...(props.style || undefined) }, className: props.className, sx: props.sx }));
93
+ }
94
+ // src could contain a device type too, so detect if it is a type
95
+ const type = props.type || (props.src ? Object.keys(TYPE_ICONS).find(type => props.src === type) : undefined);
96
+ if (!type && props.src) {
97
+ return (React.createElement(Icon, { style: defaultStyle, ...props, title: props.title === true ? undefined : props.title, src: props.src }));
98
+ }
99
+ const TypeIcon = type && TYPE_ICONS[type];
100
+ if (!TypeIcon) {
101
+ // Show the first letter of a type
102
+ return type ? (React.createElement("span", { style: { ...defaultStyle, ...(props.style || undefined) } }, type[0].toUpperCase())) : null;
103
+ }
104
+ const icon = (React.createElement(TypeIcon, { style: { ...defaultStyle, ...(props.style || undefined) }, onClick: props.onClick, className: props.className, sx: props.sx }));
105
+ if (props.title) {
106
+ return (React.createElement(Tooltip, { slotProps: { popper: { sx: { pointerEvents: 'none' } } }, title: props.title === true ? I18n.t(`type-${type}`) : props.title },
107
+ React.createElement("div", { style: { display: 'flex' } }, icon)));
108
+ }
109
+ return icon;
110
+ }
111
+ //# sourceMappingURL=TypeIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeIcon.js","sourceRoot":"./src/","sources":["Components/TypeSelector/TypeIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO;AACH,0CAA0C;AAC1C,OAAO,IAAI,aAAa,EACxB,cAAc,IAAI,cAAc,EAChC,YAAY,IAAI,YAAY,EAC5B,WAAW,IAAI,aAAa,EAC5B,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,gBAAgB,EAChC,aAAa,IAAI,aAAa,EAC9B,UAAU,IAAI,cAAc,EAC5B,YAAY,IAAI,cAAc,EAC9B,UAAU,IAAI,mBAAmB,EACjC,KAAK,IAAI,UAAU,EACnB,QAAQ,IAAI,g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C,CACb,CAAC;IACN,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import React, { useEffect } from 'react';\n\nimport { Box, Tooltip } from '@mui/material';\n\nimport { AiOutlineLineChart as TypeIconChart } from 'react-icons/ai';\nimport { GoDeviceCameraVideo as TypeIconCamera } from 'react-icons/go';\n\nimport {\n // FaExternalLinkSquareAlt as TypeIconURL,\n FaImage as TypeIconImage,\n FaRegLightbulb as TypeIconDimmer,\n FaInfoCircle as TypeIconInfo,\n FaLightbulb as TypeIconLight,\n FaLock as TypeIconLock,\n FaStreetView as TypeIconLocation,\n FaStepForward as TypeIconMedia,\n FaSlidersH as TypeIconSlider,\n FaVolumeDown as TypeIconVolume,\n FaVolumeUp as TypeIconVolumeGroup,\n FaFan as TypeIconAC,\n FaWrench as TypeIconInstance,\n} from 'react-icons/fa';\n\nimport {\n MdFormatColorFill as TypeIconHUE,\n MdFormatColorFill as TypeIconCT,\n MdWarning as TypeIconWarning,\n MdQuestionMark as TypeIconUnknown,\n MdOutlineMyLocation as TypeIconLocationOne,\n MdDeviceHub as TypeIconHub3,\n MdPolyline as TypeIconNode,\n MdHub as TypeIconHub5,\n MdControlCamera as TypeIconController,\n} from 'react-icons/md';\nimport { WiCloudy as TypeIconWeather } from 'react-icons/wi';\nimport { IoIosRadioButtonOn as TypeIconButtonSensor } from 'react-icons/io';\nimport { TbSunElectricity as TypeIconIlluminance } from 'react-icons/tb';\nimport { PiPaletteDuotone as TypeIconRGBWSingle } from 'react-icons/pi';\n\nimport { Types } from '@iobroker/type-detector';\n\nimport { I18n } from '../../i18n';\nimport { Icon } from '../Icon';\n\nimport {\n Cleaner as TypeIconVacuumCleaner,\n Humidity as TypeIconHumidity,\n Jalousie as TypeIconBlinds,\n PushButton as TypeIconButton,\n DoorOpened as TypeIconDoor,\n FireOn as TypeIconFireAlarm,\n FloodOn as TypeIconFloodAlarm,\n Gate as TypeIconGate,\n MotionOn as TypeIconMotion,\n RGB as TypeIconRGB,\n Socket as TypeIconSocket,\n Thermometer as TypeIconTemperature,\n Thermostat as TypeIconThermostat,\n // HeatValve as TypeIconValve,\n WindowOpened as TypeIconWindow,\n WindowTilted as TypeIconWindowTilt,\n type IconPropsSVG,\n} from './icons';\n\nexport type TypesExtended = Types | 'invalid' | 'hub3' | 'node' | 'hub5' | 'controller';\n\nconst TYPE_ICONS: Record<TypesExtended, React.FC<IconPropsSVG>> = {\n [Types.airCondition]: TypeIconAC,\n [Types.blind]: TypeIconBlinds,\n [Types.blindButtons]: TypeIconBlinds,\n [Types.button]: TypeIconButton,\n [Types.buttonSensor]: TypeIconButtonSensor,\n [Types.camera]: TypeIconCamera,\n [Types.chart]: TypeIconChart,\n // [Types.url]: TypeIconURL,\n [Types.image]: TypeIconImage,\n [Types.dimmer]: TypeIconDimmer,\n [Types.door]: TypeIconDoor,\n [Types.fireAlarm]: TypeIconFireAlarm,\n // @ts-expect-error special case\n 'sensor.alarm.fire': TypeIconFireAlarm,\n [Types.floodAlarm]: TypeIconFloodAlarm,\n 'sensor.alarm.flood': TypeIconFloodAlarm,\n [Types.gate]: TypeIconGate,\n [Types.humidity]: TypeIconHumidity,\n [Types.illuminance]: TypeIconIlluminance,\n [Types.info]: TypeIconInfo,\n [Types.light]: TypeIconLight,\n [Types.lock]: TypeIconLock,\n [Types.location]: TypeIconLocation,\n [Types.location_one]: TypeIconLocationOne,\n [Types.media]: TypeIconMedia,\n [Types.motion]: TypeIconMotion,\n [Types.ct]: TypeIconCT,\n [Types.rgb]: TypeIconRGB,\n [Types.rgbSingle]: TypeIconRGB,\n [Types.rgbwSingle]: TypeIconRGBWSingle,\n [Types.hue]: TypeIconHUE,\n [Types.cie]: TypeIconRGB,\n [Types.slider]: TypeIconSlider,\n [Types.socket]: TypeIconSocket,\n [Types.temperature]: TypeIconTemperature,\n [Types.thermostat]: TypeIconThermostat,\n // [Types.valve]: TypeIconValve,\n [Types.vacuumCleaner]: TypeIconVacuumCleaner,\n [Types.volume]: TypeIconVolume,\n [Types.volumeGroup]: TypeIconVolumeGroup,\n [Types.window]: TypeIconWindow,\n [Types.windowTilt]: TypeIconWindowTilt,\n [Types.weatherCurrent]: TypeIconWeather,\n [Types.weatherForecast]: TypeIconWeather,\n [Types.warning]: TypeIconWarning,\n\n [Types.unknown]: TypeIconUnknown,\n [Types.instance]: TypeIconInstance,\n\n // Special matter types\n invalid: TypeIconWarning,\n hub3: TypeIconHub3,\n node: TypeIconNode,\n hub5: TypeIconHub5,\n controller: TypeIconController,\n};\n\nconst defaultStyle: React.CSSProperties = {\n width: 32,\n height: 32,\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 | true;\n /** Styles for utf-8 characters */\n styleUTF8?: React.CSSProperties;\n /** On error handler */\n onError?: React.ReactEventHandler<HTMLImageElement>;\n /** Reference to image */\n ref?: React.RefObject<HTMLImageElement>;\n /** Alternative text for image */\n alt?: string;\n /** On click handler */\n onClick?: React.MouseEventHandler<any>;\n}\n\nexport type TypeIconProps = IconProps & { type?: TypesExtended };\n\nexport function TypeIcon(props: TypeIconProps): React.JSX.Element | null {\n const language = I18n.getLanguage();\n const [loaded, setLoaded] = React.useState(window.iobTypeWordsLoaded === language);\n\n useEffect(() => {\n if (props.title && window.iobTypeWordsLoaded !== language) {\n // Load translations dynamically\n void import(`./i18n/${language}.json`).then(i18n => {\n I18n.extendTranslations(i18n.default, language);\n window.iobTypeWordsLoaded = language;\n setLoaded(true);\n });\n }\n }, [language, props.title]);\n\n if (!loaded && props.title) {\n return (\n <Box\n style={{ ...defaultStyle, ...(props.style || undefined) }}\n className={props.className}\n sx={props.sx}\n />\n );\n }\n // src could contain a device type too, so detect if it is a type\n const type: TypesExtended | undefined =\n props.type || (props.src ? (Object.keys(TYPE_ICONS).find(type => props.src === type) as TypesExtended) : undefined);\n\n if (!type && props.src) {\n return (\n <Icon\n style={defaultStyle}\n {...props}\n title={props.title === true ? undefined : props.title}\n src={props.src}\n />\n );\n }\n\n const TypeIcon = type && TYPE_ICONS[type];\n if (!TypeIcon) {\n // Show the first letter of a type\n return type ? (\n <span style={{ ...defaultStyle, ...(props.style || undefined) }}>{type[0].toUpperCase()}</span>\n ) : null;\n }\n\n const icon = (\n <TypeIcon\n style={{ ...defaultStyle, ...(props.style || undefined) }}\n onClick={props.onClick}\n className={props.className}\n sx={props.sx}\n />\n );\n\n if (props.title) {\n return (\n <Tooltip\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\n title={props.title === true ? I18n.t(`type-${type}`) : props.title}\n >\n <div style={{ display: 'flex' }}>{icon}</div>\n </Tooltip>\n );\n }\n\n return icon;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { Types } from '@iobroker/type-detector';
3
+ import type { IconType } from 'react-icons';
4
+ export type ApplicationType = 'alexa' | 'alisa' | 'google' | 'material';
5
+ declare const TYPE_OPTIONS: Record<Types, Record<ApplicationType, boolean>>;
6
+ export declare const ICONS_TYPE: Record<ApplicationType, React.JSX.Element>;
7
+ export declare const STATES_NAME_ICONS: Record<string, IconType>;
8
+ export default TYPE_OPTIONS;
@@ -0,0 +1,125 @@
1
+ import React from 'react';
2
+ import { Types } from '@iobroker/type-detector';
3
+ import { FcGoogle, FcElectricalSensor } from 'react-icons/fc';
4
+ import { SiAmazonalexa, SiBoost } from 'react-icons/si';
5
+ import { TiCogOutline as IconWorking } from 'react-icons/ti';
6
+ import { MdPermScanWifi as IconUnreach, MdPriorityHigh as IconMaintain, MdBatteryAlert as IconLowbat, MdError as IconError, MdDirections, MdGpsFixed, MdWork, MdDeveloperMode, } from 'react-icons/md';
7
+ import { AiOutlineAppstoreAdd, AiOutlineRadiusBottomleft, AiOutlineColumnHeight, AiOutlineColumnWidth, AiOutlineSwap, AiFillPauseCircle, AiOutlinePoweroff, } from 'react-icons/ai';
8
+ import { BiLastPage } from 'react-icons/bi';
9
+ import { FaCompressArrowsAlt, FaRunning, FaSun, FaCompress, FaVolumeMute, FaToggleOn, FaDoorOpen, } from 'react-icons/fa';
10
+ import { GiElectricalResistance, GiLaserPrecision, GiStopSign, GiNuclearWaste, GiMatterStates, GiTreeSwing, GiSpeedometer, GiElectric, GiLightningFrequency, } from 'react-icons/gi';
11
+ import { IoIosColorPalette, IoIosWater } from 'react-icons/io';
12
+ import { WiDaySunny, WiFire, WiHumidity, WiSmoke, WiThermometer } from 'react-icons/wi';
13
+ import { FiPower } from 'react-icons/fi';
14
+ import { HiOutlineLightBulb } from 'react-icons/hi';
15
+ import { ImPower } from 'react-icons/im';
16
+ import { I18n } from '../../i18n';
17
+ import { WindowTilted, Material as MaterialIcon } from './icons';
18
+ const TYPE_OPTIONS = {
19
+ [Types.airCondition]: { alexa: false, alisa: true, google: false, material: false },
20
+ [Types.blindButtons]: { alexa: false, alisa: false, google: false, material: false },
21
+ [Types.blind]: { alexa: false, alisa: true, google: true, material: true },
22
+ [Types.buttonSensor]: { alexa: false, alisa: false, google: false, material: false },
23
+ [Types.button]: { alexa: false, alisa: false, google: true, material: true },
24
+ [Types.camera]: { alexa: false, alisa: false, google: false, material: false },
25
+ [Types.ct]: { alexa: true, alisa: true, google: true, material: false },
26
+ [Types.dimmer]: { alexa: true, alisa: true, google: true, material: true },
27
+ [Types.door]: { alexa: false, alisa: true, google: true, material: false },
28
+ [Types.fireAlarm]: { alexa: false, alisa: false, google: false, material: false },
29
+ [Types.floodAlarm]: { alexa: false, alisa: false, google: false, material: false },
30
+ [Types.gate]: { alexa: false, alisa: false, google: false, material: false },
31
+ [Types.hue]: { alexa: true, alisa: false, google: true, material: true },
32
+ [Types.humidity]: { alexa: false, alisa: true, google: false, material: true },
33
+ [Types.image]: { alexa: false, alisa: false, google: false, material: false },
34
+ [Types.info]: { alexa: false, alisa: false, google: true, material: false },
35
+ [Types.light]: { alexa: true, alisa: true, google: true, material: false },
36
+ [Types.location]: { alexa: false, alisa: false, google: false, material: false },
37
+ [Types.lock]: { alexa: true, alisa: true, google: false, material: true },
38
+ [Types.media]: { alexa: false, alisa: false, google: true, material: true },
39
+ [Types.motion]: { alexa: false, alisa: true, google: false, material: false },
40
+ [Types.rgbSingle]: { alexa: false, alisa: true, google: true, material: false },
41
+ [Types.rgb]: { alexa: false, alisa: false, google: true, material: true },
42
+ [Types.cie]: { alexa: false, alisa: false, google: false, material: false },
43
+ [Types.slider]: { alexa: false, alisa: false, google: true, material: false },
44
+ [Types.socket]: { alexa: true, alisa: true, google: true, material: false },
45
+ [Types.temperature]: { alexa: false, alisa: true, google: true, material: true },
46
+ [Types.thermostat]: { alexa: true, alisa: true, google: true, material: true },
47
+ // [Types.url]: { alexa: false, alisa: false, google: false, material: false },
48
+ [Types.vacuumCleaner]: { alexa: false, alisa: true, google: false, material: false },
49
+ // [Types.valve]: { alexa: false, alisa: false, google: false, material: false },
50
+ [Types.volumeGroup]: { alexa: false, alisa: false, google: false, material: true },
51
+ [Types.volume]: { alexa: false, alisa: false, google: false, material: true },
52
+ [Types.warning]: { alexa: false, alisa: false, google: false, material: true },
53
+ [Types.weatherCurrent]: { alexa: false, alisa: false, google: false, material: false },
54
+ [Types.weatherForecast]: { alexa: false, alisa: false, google: false, material: true },
55
+ [Types.windowTilt]: { alexa: false, alisa: false, google: true, material: true },
56
+ [Types.window]: { alexa: false, alisa: true, google: true, material: true },
57
+ [Types.unknown]: { alexa: false, alisa: false, google: false, material: false },
58
+ [Types.chart]: { alexa: false, alisa: false, google: false, material: false },
59
+ [Types.illuminance]: { alexa: false, alisa: false, google: false, material: false },
60
+ [Types.instance]: { alexa: false, alisa: false, google: false, material: false },
61
+ [Types.location_one]: { alexa: false, alisa: false, google: false, material: false },
62
+ [Types.rgbwSingle]: { alexa: false, alisa: false, google: false, material: false },
63
+ };
64
+ export const ICONS_TYPE = {
65
+ alexa: (React.createElement(SiAmazonalexa, { style: { margin: '0 3px', width: 16, height: 16 }, title: I18n.t('Supported by %s', 'Amazon Alexa') })),
66
+ alisa: (React.createElement("img", { title: I18n.t('Supported by %s', 'Yandex Alisa'), style: { margin: '0 3px', width: 16, height: 16 }, src: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMzcwcHgiIGhlaWdodD0iMzcwcHgiIHZpZXdCb3g9IjAgMCAzNzAgMzcwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA0Ni4yICg0NDQ5NikgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+CiAgICA8dGl0bGU+R3JvdXA8L3RpdGxlPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjAlIiB5MT0iMTAwJSIgeDI9IjEwMCUiIHkyPSIwJSIgaWQ9ImxpbmVhckdyYWRpZW50LTEiPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjQzkyNkZGIiBvZmZzZXQ9IjAlIj48L3N0b3A+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiM0QTI2RkYiIG9mZnNldD0iMTAwJSI+PC9zdG9wPgogICAgICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgICA8L2RlZnM+CiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0iR3JvdXAiPgogICAgICAgICAgICA8cmVjdCBpZD0iUmVjdGFuZ2xlIiBmaWxsPSIjRkZGRkZGIiB4PSI3NyIgeT0iNzIiIHdpZHRoPSIyMTUiIGhlaWdodD0iMTk5Ij48L3JlY3Q+CiAgICAgICAgICAgIDxnIGlkPSJhbGljZV9sb2dvIiBmaWxsLXJ1bGU9Im5vbnplcm8iIGZpbGw9InVybCgjbGluZWFyR3JhZGllbnQtMSkiPgogICAgICAgICAgICAgICAgPHBhdGggZD0iTTE4NSwzNzAgQzgyLjgyNzMyMDksMzcwIDAsMjg3LjE3MjY3OCAwLDE4NSBDMCw4Mi44MjczMjA5IDgyLjgyNzMyMDksMCAxODUsMCBDMjg3LjE3MjY3OCwwIDM3MCw4Mi44MjczMjA5IDM3MCwxODUgQzM3MCwyODcuMTcyNjc4IDI4Ny4xNzI2NzgsMzcwIDE4NSwzNzAgWiBNMTAwLjI4Nzk1MiwyNDQuNzA4MjQ0IEMxMTMuNTY4OTA4LDI1Ny45MjM4NzUgMTQ4Ljk0NTcxNiwyNjUuODU5NTc3IDE4NSwyNjUuOTk4Njc3IEMyMjEuMDUzMTgzLDI2NS44NTk1NzcgMjU2LjQzMTA5MiwyNTcuOTIzODc1IDI2OS43MTIwNDgsMjQ0LjcwODI0NCBDMzAyLjcwODYwOCwyMTEuODczOTg0IDIyMi41MDAwNDQsODYuMDgwMTUgMTg1LjA0MTI3Niw4NS44OTcyMzgzIEMxNDcuNDk5OTU2LDg2LjA4MDE1IDY3LjI5MTM5MTIsMjExLjg3Mzk4NCAxMDAuMjg3OTUyLDI0NC43MDgyNDQgWiIgaWQ9ImFsaXNhLXN5bWJvbCI+PC9wYXRoPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=", alt: "alisa" })),
67
+ google: (React.createElement(FcGoogle, { style: { margin: '0 3px', width: 16, height: 16 }, title: I18n.t('Supported by %s', 'Google Home') })),
68
+ material: (React.createElement(MaterialIcon, { style: { margin: '0 3px', width: 16, height: 16 }, title: I18n.t('Supported by %s', 'Material Adapter') })),
69
+ };
70
+ export const STATES_NAME_ICONS = {
71
+ SET: AiOutlineAppstoreAdd,
72
+ WORKING: MdWork,
73
+ UNREACH: IconUnreach,
74
+ LOWBAT: IconLowbat,
75
+ MAINTAIN: IconMaintain,
76
+ ERROR: IconError,
77
+ DIRECTION: MdDirections,
78
+ CONNECTED: IconUnreach,
79
+ ACTUAL: IconWorking,
80
+ SECOND: BiLastPage,
81
+ PRESS_LONG: FaCompressArrowsAlt,
82
+ PRESS: FaCompress,
83
+ MUTE: FaVolumeMute,
84
+ ACCURACY: GiLaserPrecision,
85
+ RADIUS: AiOutlineRadiusBottomleft,
86
+ ELEVATION: AiOutlineColumnHeight,
87
+ LATITUDE: AiOutlineColumnWidth,
88
+ LONGITUDE: AiOutlineSwap,
89
+ GPS: MdGpsFixed,
90
+ ON_ACTUAL: FaToggleOn,
91
+ ON_SET: FaToggleOn,
92
+ OPEN: FaDoorOpen,
93
+ STOP: GiStopSign,
94
+ WATER_ALARM: IoIosWater, // water
95
+ WASTE_ALARM: GiNuclearWaste,
96
+ PAUSE: AiFillPauseCircle,
97
+ STATE: GiMatterStates,
98
+ BATTERY: IconLowbat,
99
+ WASTE: GiNuclearWaste,
100
+ WATER: IoIosWater,
101
+ WORK_MODE: MdWork,
102
+ MODE: MdDeveloperMode,
103
+ POWER: AiOutlinePoweroff,
104
+ BOOST: SiBoost,
105
+ HUMIDITY: WiHumidity,
106
+ TEMPERATURE: WiThermometer,
107
+ BRIGHTNESS: WiDaySunny,
108
+ MOTION: FaRunning,
109
+ FIRE: WiFire,
110
+ WINDOW: WindowTilted,
111
+ SMOKE: WiSmoke,
112
+ SWING: GiTreeSwing,
113
+ SPEED: GiSpeedometer,
114
+ DIMMER: HiOutlineLightBulb,
115
+ ON: FiPower,
116
+ COLOR_TEMP: FaSun,
117
+ ELECTRIC_POWER: ImPower,
118
+ CURRENT: GiElectric,
119
+ VOLTAGE: GiElectricalResistance,
120
+ CONSUMPTION: FcElectricalSensor,
121
+ FREQUENCY: GiLightningFrequency,
122
+ HUE: IoIosColorPalette,
123
+ };
124
+ export default TYPE_OPTIONS;
125
+ //# sourceMappingURL=TypeOptions.js.map