@iobroker/gui-components 8.0.2 → 10.0.2

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 (160) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +834 -543
  3. package/build/AdminConnection.js.map +1 -1
  4. package/build/Components/404.js +13 -13
  5. package/build/Components/404.js.map +1 -1
  6. package/build/Components/ColorPicker.js.map +1 -1
  7. package/build/Components/ComplexCron.js +2 -2
  8. package/build/Components/ComplexCron.js.map +1 -1
  9. package/build/Components/CopyToClipboard.js.map +1 -1
  10. package/build/Components/CustomModal.js +1 -1
  11. package/build/Components/CustomModal.js.map +1 -1
  12. package/build/Components/DeviceType/DeviceTypeIcon.js +1 -0
  13. package/build/Components/DeviceType/DeviceTypeIcon.js.map +1 -1
  14. package/build/Components/DeviceType/DeviceTypeSelector.js +2 -2
  15. package/build/Components/DeviceType/DeviceTypeSelector.js.map +1 -1
  16. package/build/Components/DeviceType/i18n/de.json +1 -0
  17. package/build/Components/DeviceType/i18n/en.json +1 -0
  18. package/build/Components/DeviceType/i18n/fr.json +1 -0
  19. package/build/Components/DeviceType/i18n/it.json +1 -0
  20. package/build/Components/DeviceType/i18n/nl.json +1 -0
  21. package/build/Components/DeviceType/i18n/pl.json +1 -0
  22. package/build/Components/DeviceType/i18n/pt.json +1 -0
  23. package/build/Components/DeviceType/i18n/ru.json +1 -0
  24. package/build/Components/DeviceType/i18n/uk.json +1 -0
  25. package/build/Components/DeviceType/i18n/zh-cn.json +1 -0
  26. package/build/Components/FileBrowser.d.ts +39 -4
  27. package/build/Components/FileBrowser.js +104 -11
  28. package/build/Components/FileBrowser.js.map +1 -1
  29. package/build/Components/FileViewer.js +2 -4
  30. package/build/Components/FileViewer.js.map +1 -1
  31. package/build/Components/Icon.d.ts +1 -3
  32. package/build/Components/Icon.js +11 -11
  33. package/build/Components/Icon.js.map +1 -1
  34. package/build/Components/Image.js +8 -4
  35. package/build/Components/Image.js.map +1 -1
  36. package/build/Components/InfoBox.js +1 -1
  37. package/build/Components/InfoBox.js.map +1 -1
  38. package/build/Components/IobUri.js +5 -5
  39. package/build/Components/IobUri.js.map +1 -1
  40. package/build/Components/Loader.d.ts +2 -3
  41. package/build/Components/Loader.js +25 -257
  42. package/build/Components/Loader.js.map +1 -1
  43. package/build/Components/Loaders/Community.d.ts +31 -0
  44. package/build/Components/Loaders/Community.js +265 -0
  45. package/build/Components/Loaders/Community.js.map +1 -0
  46. package/build/Components/Loaders/HA.d.ts +17 -0
  47. package/build/Components/Loaders/HA.js +99 -0
  48. package/build/Components/Loaders/HA.js.map +1 -0
  49. package/build/Components/Loaders/MV.js.map +1 -1
  50. package/build/Components/Loaders/NW.d.ts +17 -0
  51. package/build/Components/Loaders/NW.js +70 -0
  52. package/build/Components/Loaders/NW.js.map +1 -0
  53. package/build/Components/Loaders/PT.js +103 -103
  54. package/build/Components/Loaders/PT.js.map +1 -1
  55. package/build/Components/Loaders/Vendor.js +7 -7
  56. package/build/Components/Loaders/Vendor.js.map +1 -1
  57. package/build/Components/MDUtils.js.map +1 -1
  58. package/build/Components/ObjectBrowser.d.ts +25 -406
  59. package/build/Components/ObjectBrowser.js +460 -1543
  60. package/build/Components/ObjectBrowser.js.map +1 -1
  61. package/build/Components/Router.js.map +1 -1
  62. package/build/Components/SaveCloseButtons.js.map +1 -1
  63. package/build/Components/Schedule.d.ts +27 -1
  64. package/build/Components/Schedule.js +60 -50
  65. package/build/Components/Schedule.js.map +1 -1
  66. package/build/Components/SelectWithIcon.js +1 -1
  67. package/build/Components/SelectWithIcon.js.map +1 -1
  68. package/build/Components/SimpleCron/cronText.js.map +1 -1
  69. package/build/Components/SimpleCron/index.js +3 -3
  70. package/build/Components/SimpleCron/index.js.map +1 -1
  71. package/build/Components/TabContainer.js +7 -2
  72. package/build/Components/TabContainer.js.map +1 -1
  73. package/build/Components/TabContent.d.ts +1 -1
  74. package/build/Components/TabContent.js +5 -5
  75. package/build/Components/TabContent.js.map +1 -1
  76. package/build/Components/TabHeader.js +2 -2
  77. package/build/Components/TabHeader.js.map +1 -1
  78. package/build/Components/TableResize.js.map +1 -1
  79. package/build/Components/TextWithIcon.js.map +1 -1
  80. package/build/Components/TreeTable.d.ts +1 -0
  81. package/build/Components/TreeTable.js +16 -6
  82. package/build/Components/TreeTable.js.map +1 -1
  83. package/build/Components/UploadImage.js +305 -305
  84. package/build/Components/UploadImage.js.map +1 -1
  85. package/build/Components/Utils.d.ts +17 -3
  86. package/build/Components/Utils.js +167 -9
  87. package/build/Components/Utils.js.map +1 -1
  88. package/build/Components/objectBrowser.types.d.ts +496 -0
  89. package/build/Components/objectBrowserUtils.d.ts +170 -0
  90. package/build/Components/objectBrowserUtils.js +1375 -0
  91. package/build/Components/objectBrowserUtils.js.map +1 -0
  92. package/build/Connection.js.map +1 -1
  93. package/build/Dialogs/ComplexCron.js.map +1 -1
  94. package/build/Dialogs/Confirm.js.map +1 -1
  95. package/build/Dialogs/Cron.js.map +1 -1
  96. package/build/Dialogs/Error.js.map +1 -1
  97. package/build/Dialogs/Message.js.map +1 -1
  98. package/build/Dialogs/SelectFile.d.ts +1 -1
  99. package/build/Dialogs/SelectFile.js +1 -1
  100. package/build/Dialogs/SelectFile.js.map +1 -1
  101. package/build/Dialogs/SelectID.d.ts +1 -1
  102. package/build/Dialogs/SelectID.js +1 -1
  103. package/build/Dialogs/SelectID.js.map +1 -1
  104. package/build/Dialogs/SimpleCron.js.map +1 -1
  105. package/build/Dialogs/TextInput.js +1 -1
  106. package/build/Dialogs/TextInput.js.map +1 -1
  107. package/build/GenericApp.d.ts +6 -4
  108. package/build/GenericApp.js +22 -16
  109. package/build/GenericApp.js.map +1 -1
  110. package/build/Prompt.js +7 -7
  111. package/build/Prompt.js.map +1 -1
  112. package/build/Theme.js +57 -11
  113. package/build/Theme.js.map +1 -1
  114. package/build/assets/devices/parseNames.js +1 -0
  115. package/build/assets/devices/parseNames.js.map +1 -1
  116. package/build/assets/rooms/parseNames.js +1 -0
  117. package/build/assets/rooms/parseNames.js.map +1 -1
  118. package/build/dictionary.js.map +1 -1
  119. package/build/globals.d.ts +2 -0
  120. package/build/i18n/de.json +5 -66
  121. package/build/i18n/en.json +5 -66
  122. package/build/i18n/es.json +5 -66
  123. package/build/i18n/fr.json +5 -66
  124. package/build/i18n/it.json +5 -61
  125. package/build/i18n/nl.json +5 -61
  126. package/build/i18n/pl.json +5 -61
  127. package/build/i18n/pt.json +5 -61
  128. package/build/i18n/ru.json +5 -61
  129. package/build/i18n/uk.json +5 -61
  130. package/build/i18n/zh-cn.json +5 -61
  131. package/build/i18n.js +12 -15
  132. package/build/i18n.js.map +1 -1
  133. package/build/index.css +56 -56
  134. package/build/index.d.ts +9 -4
  135. package/build/index.js +5 -2
  136. package/build/index.js.map +1 -1
  137. package/build/modulefederation.admin.config.d.ts +1 -0
  138. package/build/modulefederation.admin.config.js +1 -1
  139. package/build/modulefederation.admin.config.js.map +1 -1
  140. package/build/types.d.ts +4 -84
  141. package/i18n/de.json +5 -66
  142. package/i18n/en.json +5 -66
  143. package/i18n/es.json +5 -66
  144. package/i18n/fr.json +5 -66
  145. package/i18n/it.json +5 -61
  146. package/i18n/nl.json +5 -61
  147. package/i18n/pl.json +5 -61
  148. package/i18n/pt.json +5 -61
  149. package/i18n/ru.json +5 -61
  150. package/i18n/uk.json +5 -61
  151. package/i18n/zh-cn.json +5 -61
  152. package/index.css +56 -56
  153. package/modulefederation.admin.config.d.ts +1 -0
  154. package/modulefederation.admin.config.js +1 -2
  155. package/package.json +50 -35
  156. package/tasksExample.ts +93 -0
  157. package/build/LegacyConnection.d.ts +0 -938
  158. package/build/LegacyConnection.js +0 -2849
  159. package/build/LegacyConnection.js.map +0 -1
  160. package/tasksExample.js +0 -91
@@ -1 +1 @@
1
- {"version":3,"file":"Router.js","sourceRoot":"./src/","sources":["Components/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,mEAAmE;AACnE,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AE;SACtB,CAAC;IACN,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CACb,GAA8B,EAC9B,MAAsB,EACtB,EAAkB,EAClB,GAAmB;QAEnB,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACtC,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,EAAE,EAAE,CAAC;YAC3B,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;QACrB,CAAC;QACD,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC7B,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACvB,CAAC;aAAM,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACtB,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACvB,CAAC;QAED,IAAI,GAAG,EAAE,CAAC;YACN,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACjB,IAAI,MAAM,EAAE,CAAC;gBACT,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBAErB,IAAI,EAAE,EAAE,CAAC;oBACL,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;oBACjB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;wBACpB,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;oBACtB,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;QAChC,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Component } from 'react';\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\r\nexport class Router<P = {}, S = {}> extends Component<P, S> {\r\n protected onHashChangedBound: () => void;\r\n\r\n constructor(props: P) {\r\n super(props);\r\n this.onHashChangedBound = this.onHashChanged.bind(this);\r\n }\r\n\r\n componentDidMount(): void {\r\n window.addEventListener('hashchange', this.onHashChangedBound);\r\n }\r\n\r\n componentWillUnmount(): void {\r\n window.removeEventListener('hashchange', this.onHashChangedBound);\r\n }\r\n\r\n // eslint-disable-next-line class-methods-use-this\r\n onHashChanged(): void {\r\n // override this function\r\n }\r\n\r\n /**\r\n * Gets the location object.\r\n */\r\n static getLocation(): { tab: string; dialog: string; id: string; arg: string } {\r\n let hash = window.location.hash;\r\n hash = hash.replace(/^#/, '');\r\n const parts = hash.split('/').map(item => {\r\n try {\r\n return item ? decodeURIComponent(item) : '';\r\n } catch {\r\n console.error(`Router: Cannot decode ${item}`);\r\n return item;\r\n }\r\n });\r\n // #tabName/dialogName/deviceId\r\n return {\r\n tab: parts[0] || '',\r\n dialog: parts[1] || '',\r\n id: parts[2] || '',\r\n arg: parts[3] || '',\r\n };\r\n }\r\n\r\n /**\r\n * Navigate to a new location. Any parameters that are not set will be taken from the current location.\r\n */\r\n static doNavigate(\r\n tab: string | undefined | null,\r\n dialog?: string | null,\r\n id?: string | null,\r\n arg?: string | null,\r\n ): void {\r\n let hash = '';\r\n const location = Router.getLocation();\r\n if (arg !== undefined && !id) {\r\n id = location.id;\r\n }\r\n if (id && !dialog) {\r\n dialog = location.dialog;\r\n }\r\n if (dialog && !tab) {\r\n tab = location.tab;\r\n } else if (tab === null) {\r\n tab = location.tab;\r\n }\r\n\r\n if (tab) {\r\n hash = `#${tab}`;\r\n if (dialog) {\r\n hash += `/${dialog}`;\r\n\r\n if (id) {\r\n hash += `/${id}`;\r\n if (arg !== undefined) {\r\n hash += `/${arg}`;\r\n }\r\n }\r\n }\r\n }\r\n if (window.location.hash !== hash) {\r\n window.location.hash = hash;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Router.js","sourceRoot":"./src/","sources":["Components/Router.tsx"],"names":[],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-disable-next-line @typescript-eslint/no-empty-object-type\nexport class Router<P = {}, S = {}> extends Component<P, S> {\n protected onHashChangedBound: () => void;\n\n constructor(props: P) {\n super(props);\n this.onHashChangedBound = this.onHashChanged.bind(this);\n }\n\n componentDidMount(): void {\n window.addEventListener('hashchange', this.onHashChangedBound);\n }\n\n componentWillUnmount(): void {\n window.removeEventListener('hashchange', this.onHashChangedBound);\n }\n\n // eslint-disable-next-line class-methods-use-this\n onHashChanged(): void {\n // override this function\n }\n\n /**\n * Gets the location object.\n */\n static getLocation(): { tab: string; dialog: string; id: string; arg: string } {\n let hash = window.location.hash;\n hash = hash.replace(/^#/, '');\n const parts = hash.split('/').map(item => {\n try {\n return item ? decodeURIComponent(item) : '';\n } catch {\n console.error(`Router: Cannot decode ${item}`);\n return item;\n }\n });\n // #tabName/dialogName/deviceId\n return {\n tab: parts[0] || '',\n dialog: parts[1] || '',\n id: parts[2] || '',\n arg: parts[3] || '',\n };\n }\n\n /**\n * Navigate to a new location. Any parameters that are not set will be taken from the current location.\n */\n static doNavigate(\n tab: string | undefined | null,\n dialog?: string | null,\n id?: string | null,\n arg?: string | null,\n ): void {\n let hash = '';\n const location = Router.getLocation();\n if (arg !== undefined && !id) {\n id = location.id;\n }\n if (id && !dialog) {\n dialog = location.dialog;\n }\n if (dialog && !tab) {\n tab = location.tab;\n } else if (tab === null) {\n tab = location.tab;\n }\n\n if (tab) {\n hash = `#${tab}`;\n if (dialog) {\n hash += `/${dialog}`;\n\n if (id) {\n hash += `/${id}`;\n if (arg !== undefined) {\n hash += `/${arg}`;\n }\n }\n }\n }\n if (window.location.hash !== hash) {\n window.location.hash = hash;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SaveCloseButtons.js","sourceRoot":"./src/","sources":["Components/SaveCloseButtons.tsx"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM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AAG,WAAW,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;gBAEhD,oBAAC,QAAQ,IAAC,KAAK,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,GAAI;gBACpE,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GAAG;gBACpD,eAAe,IAAI,oBAAC,SAAS,OAAG,CAC/B;YACN,6BAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAI;YAC/B,oBAAC,GAAG,IACA,OAAO,EAAC,UAAU,gBACP,OAAO,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EACnC,KAAK,EAAE,WAAW;gBAElB,oBAAC,SAAS,IAAC,KAAK,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,GAAI;gBACrE,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CACrC,CACA,CACb,CAAC;IACN,CAAC;CACJ","sourcesContent":["// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\r\nimport React, { type JSX } from 'react';\r\n\r\nimport { Fab, Toolbar } from '@mui/material';\r\n\r\nimport { Save as IconSave, Close as IconClose } from '@mui/icons-material';\r\n\r\nimport { I18n } from '../i18n';\r\nimport type { IobTheme } from '../types';\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n buttonIcon: {\r\n marginRight: 8,\r\n },\r\n};\r\n\r\ninterface SaveCloseButtonsProps {\r\n /* Are the buttons without text */\r\n noTextOnButtons?: boolean;\r\n /* Theme object (from this.state.theme) */\r\n theme: IobTheme;\r\n /* bottom position 0 or 38 for iFrame */\r\n isIFrame?: boolean;\r\n /* is used in new React */\r\n newReact?: boolean;\r\n /* on Save handler */\r\n onSave: (close: boolean) => void;\r\n /* on Close handler */\r\n onClose: () => void;\r\n dense?: boolean;\r\n paddingLeft?: number;\r\n changed: boolean;\r\n error?: boolean;\r\n}\r\n\r\nexport class SaveCloseButtons extends React.Component<SaveCloseButtonsProps> {\r\n private readonly isIFrame: boolean;\r\n\r\n constructor(props: SaveCloseButtonsProps) {\r\n super(props);\r\n const newReact = props.newReact === undefined ? true : props.newReact;\r\n\r\n if (props.isIFrame !== undefined) {\r\n this.isIFrame = props.isIFrame;\r\n } else {\r\n try {\r\n this.isIFrame = !newReact && window.self !== window.top;\r\n } catch {\r\n this.isIFrame = !newReact;\r\n }\r\n }\r\n }\r\n\r\n render(): JSX.Element {\r\n const noTextOnButtons = this.props.noTextOnButtons;\r\n const buttonStyle: React.CSSProperties = {\r\n borderRadius: this.props.theme.saveToolbar.button.borderRadius || 3,\r\n height: this.props.theme.saveToolbar.button.height || 32,\r\n };\r\n\r\n const style: React.CSSProperties = {\r\n bottom: this.isIFrame ? 38 : 0,\r\n left: this.props.paddingLeft || 0,\r\n right: 0,\r\n position: 'absolute',\r\n background: this.props.theme.saveToolbar.background,\r\n };\r\n if (this.props.dense) {\r\n style.minHeight = 48;\r\n }\r\n\r\n if (this.props.error) {\r\n buttonStyle.border = '1px solid red';\r\n }\r\n\r\n return (\r\n <Toolbar\r\n // position=\"absolute\"\r\n style={style}\r\n >\r\n <Fab\r\n variant=\"extended\"\r\n aria-label=\"Save\"\r\n disabled={!this.props.changed || this.props.error}\r\n onClick={() => this.props.onSave(false)}\r\n style={buttonStyle}\r\n >\r\n <IconSave style={!noTextOnButtons ? styles.buttonIcon : undefined} />\r\n {!noTextOnButtons && I18n.t('ra_Save')}\r\n </Fab>\r\n <Fab\r\n variant=\"extended\"\r\n aria-label=\"Save and close\"\r\n disabled={!this.props.changed || this.props.error}\r\n onClick={() => this.props.onSave(true)}\r\n style={{ ...buttonStyle, ...{ marginLeft: 10 } }}\r\n >\r\n <IconSave style={!noTextOnButtons ? styles.buttonIcon : undefined} />\r\n {!noTextOnButtons ? I18n.t('ra_Save and close') : '+'}\r\n {noTextOnButtons && <IconClose />}\r\n </Fab>\r\n <div style={{ flexGrow: 1 }} />\r\n <Fab\r\n variant=\"extended\"\r\n aria-label=\"Close\"\r\n onClick={() => this.props.onClose()}\r\n style={buttonStyle}\r\n >\r\n <IconClose style={!noTextOnButtons ? styles.buttonIcon : undefined} />\r\n {!noTextOnButtons && I18n.t('ra_Close')}\r\n </Fab>\r\n </Toolbar>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SaveCloseButtons.js","sourceRoot":"./src/","sources":["Components/SaveCloseButtons.tsx"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,MAAM,MAAM,GAAwC;IAChD,UAAU,EAAE;QACR,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAqBF,MAAM,OAAO,gBAAiB,SAAQ,KAAK,CAAC,SAAgC;IACvD,QAAQ,CAAU;IAEnC,YAAY,KAA4B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;QAEtE,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC;gBACD,IAAI,CAAC,QAAQ,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,IAA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C,CACrC,CACA,CACb,CAAC;IACN,CAAC;CACJ","sourcesContent":["// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\nimport React, { type JSX } from 'react';\n\nimport { Fab, Toolbar } from '@mui/material';\n\nimport { Save as IconSave, Close as IconClose } from '@mui/icons-material';\n\nimport { I18n } from '../i18n';\nimport type { IobTheme } from '../types';\n\nconst styles: Record<string, React.CSSProperties> = {\n buttonIcon: {\n marginRight: 8,\n },\n};\n\ninterface SaveCloseButtonsProps {\n /* Are the buttons without text */\n noTextOnButtons?: boolean;\n /* Theme object (from this.state.theme) */\n theme: IobTheme;\n /* bottom position 0 or 38 for iFrame */\n isIFrame?: boolean;\n /* is used in new React */\n newReact?: boolean;\n /* on Save handler */\n onSave: (close: boolean) => void;\n /* on Close handler */\n onClose: () => void;\n dense?: boolean;\n paddingLeft?: number;\n changed: boolean;\n error?: boolean;\n}\n\nexport class SaveCloseButtons extends React.Component<SaveCloseButtonsProps> {\n private readonly isIFrame: boolean;\n\n constructor(props: SaveCloseButtonsProps) {\n super(props);\n const newReact = props.newReact === undefined ? true : props.newReact;\n\n if (props.isIFrame !== undefined) {\n this.isIFrame = props.isIFrame;\n } else {\n try {\n this.isIFrame = !newReact && window.self !== window.top;\n } catch {\n this.isIFrame = !newReact;\n }\n }\n }\n\n render(): JSX.Element {\n const noTextOnButtons = this.props.noTextOnButtons;\n const buttonStyle: React.CSSProperties = {\n borderRadius: this.props.theme.saveToolbar.button.borderRadius || 3,\n height: this.props.theme.saveToolbar.button.height || 32,\n };\n\n const style: React.CSSProperties = {\n bottom: this.isIFrame ? 38 : 0,\n left: this.props.paddingLeft || 0,\n right: 0,\n position: 'absolute',\n background: this.props.theme.saveToolbar.background,\n };\n if (this.props.dense) {\n style.minHeight = 48;\n }\n\n if (this.props.error) {\n buttonStyle.border = '1px solid red';\n }\n\n return (\n <Toolbar\n // position=\"absolute\"\n style={style}\n >\n <Fab\n variant=\"extended\"\n aria-label=\"Save\"\n disabled={!this.props.changed || this.props.error}\n onClick={() => this.props.onSave(false)}\n style={buttonStyle}\n >\n <IconSave style={!noTextOnButtons ? styles.buttonIcon : undefined} />\n {!noTextOnButtons && I18n.t('ra_Save')}\n </Fab>\n <Fab\n variant=\"extended\"\n aria-label=\"Save and close\"\n disabled={!this.props.changed || this.props.error}\n onClick={() => this.props.onSave(true)}\n style={{ ...buttonStyle, ...{ marginLeft: 10 } }}\n >\n <IconSave style={!noTextOnButtons ? styles.buttonIcon : undefined} />\n {!noTextOnButtons ? I18n.t('ra_Save and close') : '+'}\n {noTextOnButtons && <IconClose />}\n </Fab>\n <div style={{ flexGrow: 1 }} />\n <Fab\n variant=\"extended\"\n aria-label=\"Close\"\n onClick={() => this.props.onClose()}\n style={buttonStyle}\n >\n <IconClose style={!noTextOnButtons ? styles.buttonIcon : undefined} />\n {!noTextOnButtons && I18n.t('ra_Close')}\n </Fab>\n </Toolbar>\n );\n }\n}\n"]}
@@ -1,5 +1,30 @@
1
1
  import { Component, type JSX } from 'react';
2
2
  import type { IobTheme } from '../types';
3
+ export interface ScheduleConfigSaved {
4
+ time?: {
5
+ exactTime: boolean;
6
+ } | {
7
+ start: string;
8
+ end: string;
9
+ mode: string;
10
+ interval: number;
11
+ };
12
+ period?: {
13
+ once: string;
14
+ days: number;
15
+ dows: string;
16
+ dates: string;
17
+ weeks: number;
18
+ months: string | number;
19
+ years: number;
20
+ yearMonth: number;
21
+ yearDate: number;
22
+ };
23
+ valid?: {
24
+ from?: string;
25
+ to?: string;
26
+ };
27
+ }
3
28
  export interface ScheduleConfig {
4
29
  time: {
5
30
  exactTime: boolean;
@@ -41,6 +66,7 @@ export declare class Schedule extends Component<ScheduleProps, ScheduleState> {
41
66
  private timerFrom;
42
67
  private timerTo;
43
68
  constructor(props: ScheduleProps);
69
+ componentWillUnmount(): void;
44
70
  onChange(schedule: ScheduleConfig, force?: boolean): void;
45
71
  static state2text(schedule: string | ScheduleConfig): string;
46
72
  getTimePeriodElements(): JSX.Element;
@@ -55,7 +81,7 @@ export declare class Schedule extends Component<ScheduleProps, ScheduleState> {
55
81
  getPeriodSettingsMonthly(): JSX.Element[] | null;
56
82
  getPeriodSettingsYearly(): JSX.Element[] | null;
57
83
  static now2string(isEnd?: boolean): string;
58
- static string2date(str: string): Date;
84
+ static string2date(str: string | undefined): Date;
59
85
  getValidSettings(): JSX.Element;
60
86
  render(): JSX.Element;
61
87
  }
@@ -185,6 +185,9 @@ const DEFAULT = {
185
185
  },
186
186
  };
187
187
  function string2USdate(date) {
188
+ if (!date) {
189
+ return '';
190
+ }
188
191
  const parts = date.split('.');
189
192
  if (parts.length === 3) {
190
193
  return `${parts[2]}-${parts[1]}-${parts[0]}`;
@@ -229,6 +232,20 @@ export class Schedule extends Component {
229
232
  setTimeout(() => this.props.onChange?.(JSON.stringify(schedule)), 100);
230
233
  }
231
234
  }
235
+ componentWillUnmount() {
236
+ if (this.timerOnce) {
237
+ clearTimeout(this.timerOnce);
238
+ this.timerOnce = null;
239
+ }
240
+ if (this.timerFrom) {
241
+ clearTimeout(this.timerFrom);
242
+ this.timerFrom = null;
243
+ }
244
+ if (this.timerTo) {
245
+ clearTimeout(this.timerTo);
246
+ this.timerTo = null;
247
+ }
248
+ }
232
249
  onChange(schedule, force) {
233
250
  const isDiff = JSON.stringify(schedule) !== JSON.stringify(this.state.schedule);
234
251
  if (force || isDiff) {
@@ -236,13 +253,13 @@ export class Schedule extends Component {
236
253
  this.setState({ schedule, desc: Schedule.state2text(schedule) });
237
254
  }
238
255
  const copy = JSON.parse(JSON.stringify(schedule));
239
- if (copy.period.once) {
256
+ if (copy.period?.once) {
240
257
  const once = copy.period.once;
241
258
  delete copy.period;
242
259
  copy.period = { once };
243
260
  delete copy.valid;
244
261
  }
245
- else if (copy.period.days) {
262
+ else if (copy.period?.days) {
246
263
  const days = copy.period.days;
247
264
  const daysOfWeek = copy.period.dows;
248
265
  delete copy.period;
@@ -251,7 +268,7 @@ export class Schedule extends Component {
251
268
  copy.period.dows = daysOfWeek;
252
269
  }
253
270
  }
254
- else if (copy.period.weeks) {
271
+ else if (copy.period?.weeks) {
255
272
  const weeks = copy.period.weeks;
256
273
  const daysOfWeek = copy.period.dows;
257
274
  delete copy.period;
@@ -260,7 +277,7 @@ export class Schedule extends Component {
260
277
  copy.period.dows = daysOfWeek;
261
278
  }
262
279
  }
263
- else if (copy.period.months) {
280
+ else if (copy.period?.months) {
264
281
  const months = copy.period.months;
265
282
  const dates = copy.period.dates;
266
283
  delete copy.period;
@@ -269,7 +286,7 @@ export class Schedule extends Component {
269
286
  copy.period.dates = dates;
270
287
  }
271
288
  }
272
- else if (copy.period.years) {
289
+ else if (copy.period?.years) {
273
290
  const years = copy.period.years;
274
291
  const yearMonth = copy.period.yearMonth;
275
292
  const yearDate = copy.period.yearDate;
@@ -279,23 +296,30 @@ export class Schedule extends Component {
279
296
  copy.period.yearMonth = yearMonth;
280
297
  }
281
298
  }
282
- if (copy.time.exactTime) {
283
- delete copy.time.end;
284
- delete copy.time.mode;
285
- delete copy.time.interval;
299
+ if (copy.time?.exactTime) {
300
+ copy.time = {
301
+ exactTime: copy.time?.exactTime,
302
+ };
286
303
  }
287
304
  else {
288
- delete copy.time.exactTime;
305
+ const _time = copy.time;
306
+ copy.time = {
307
+ start: _time.start,
308
+ end: _time.end,
309
+ mode: _time.mode,
310
+ interval: _time.interval,
311
+ };
289
312
  }
290
313
  if (copy.valid) {
291
314
  if (!copy.valid.to) {
292
315
  delete copy.valid.to;
293
316
  }
294
- if (copy.period.days === 1 ||
295
- copy.period.weeks === 1 ||
296
- copy.period.months === 1 ||
297
- copy.period.years === 1) {
298
- const from = Schedule.string2date(copy.valid.from);
317
+ if (copy.period &&
318
+ (copy.period.days === 1 ||
319
+ copy.period.weeks === 1 ||
320
+ copy.period.months === 1 ||
321
+ copy.period.years === 1)) {
322
+ const from = Schedule.string2date(copy.valid?.from);
299
323
  const today = new Date();
300
324
  today.setHours(0);
301
325
  today.setMinutes(0);
@@ -322,7 +346,7 @@ export class Schedule extends Component {
322
346
  }
323
347
  }
324
348
  const desc = [];
325
- const validFrom = Schedule.string2date(schedule.valid.from);
349
+ const validFrom = Schedule.string2date(schedule.valid?.from);
326
350
  if (schedule.period.once) {
327
351
  // once
328
352
  const once = Schedule.string2date(schedule.period.once);
@@ -526,17 +550,17 @@ export class Schedule extends Component {
526
550
  }
527
551
  if (!schedule.period.once) {
528
552
  // valid
529
- if (validFrom.getTime() > Date.now() && schedule.valid.to) {
553
+ if (validFrom.getTime() > Date.now() && schedule.valid?.to) {
530
554
  // from XXX to XXXX
531
- desc.push(I18n.t('sch_desc_validFromTo', schedule.valid.from, schedule.valid.to));
555
+ desc.push(I18n.t('sch_desc_validFromTo', schedule.valid?.from, schedule.valid?.to));
532
556
  }
533
557
  else if (validFrom.getTime() > Date.now()) {
534
558
  // from XXXX
535
- desc.push(I18n.t('sch_desc_validFrom', schedule.valid.from));
559
+ desc.push(I18n.t('sch_desc_validFrom', schedule.valid?.from));
536
560
  }
537
- else if (schedule.valid.to) {
561
+ else if (schedule.valid?.to) {
538
562
  // till XXXX
539
- desc.push(I18n.t('sch_desc_validTo', schedule.valid.to));
563
+ desc.push(I18n.t('sch_desc_validTo', schedule.valid?.to));
540
564
  }
541
565
  }
542
566
  return desc.join(' ');
@@ -671,7 +695,6 @@ export class Schedule extends Component {
671
695
  schedule.period.once = Schedule.now2string(true);
672
696
  }
673
697
  return [
674
- // ----- once ---
675
698
  React.createElement("div", { key: "once", style: { ...styles.rowDiv, ...styles.rowOnce } },
676
699
  React.createElement("div", { style: styles.modeDiv },
677
700
  React.createElement(FormControlLabel, { control: React.createElement(Radio, { style: styles.inputRadio, checked: !!isOnce, onClick: () => {
@@ -691,8 +714,9 @@ export class Schedule extends Component {
691
714
  React.createElement(TextField, { variant: "standard", style: styles.inputDate, type: "date", ref: this.refOnce, key: "exactDateAt", defaultValue: string2USdate(schedule.period.once),
692
715
  // InputProps={{inputComponent: TextTime}}
693
716
  onChange: e => {
694
- this.timerOnce && clearTimeout(this.timerOnce);
695
- this.timerOnce = null;
717
+ if (this.timerOnce) {
718
+ clearTimeout(this.timerOnce);
719
+ }
696
720
  if (this.refOnce.current) {
697
721
  this.refOnce.current.style.background = '#ff000030';
698
722
  }
@@ -711,7 +735,6 @@ export class Schedule extends Component {
711
735
  }, slotProps: {
712
736
  inputLabel: { shrink: true },
713
737
  }, label: I18n.t('sch_at'), margin: "normal" })))),
714
- // ----- days ---
715
738
  React.createElement(Box, { component: "div", key: "days", sx: Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowDays) },
716
739
  React.createElement("div", { style: styles.modeDiv },
717
740
  React.createElement(FormControlLabel, { control: React.createElement(Radio, { style: styles.inputRadio, checked: !!schedule.period.days, onClick: () => {
@@ -730,24 +753,6 @@ export class Schedule extends Component {
730
753
  React.createElement("div", { style: styles.settingsDiv },
731
754
  this.getPeriodSettingsDaily(),
732
755
  schedule.period.days ? this.getPeriodSettingsWeekdays() : null)),
733
- // ----- days of weeks ---
734
- /*
735
- !schedule.period.days && (
736
- <div key="dows" style={styles.rowDiv + ' ' + styles.rowDows}>
737
- <div style={styles.modeDiv}>
738
- <FormControlLabel control={<Radio style={styles.inputRadio} checked={!!schedule.period.dows} onClick={() => {
739
- const schedule = JSON.parse(JSON.stringify(this.state.schedule));
740
- schedule.period.dows = schedule.period.dows ? '' : '[0,1,2,3,4,5,6]';
741
- this.onChange(schedule);
742
- }}/>}
743
- label={I18n.t('sch_periodWeekdays')} />
744
- </div>
745
- <div style={styles.settingsDiv}>
746
- {this.getPeriodSettingsWeekdays()}
747
- </div>
748
- </div>,
749
- */
750
- // ----- weeks ---
751
756
  React.createElement(Box, { component: "div", key: "weeks", sx: Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowDows) },
752
757
  React.createElement("div", { style: styles.modeDiv },
753
758
  React.createElement(FormControlLabel, { control: React.createElement(Radio, { style: styles.inputRadio, checked: !!schedule.period.weeks, onClick: () => {
@@ -766,7 +771,6 @@ export class Schedule extends Component {
766
771
  React.createElement(Box, { component: "div", style: styles.settingsDiv },
767
772
  React.createElement("div", { style: styles.settingsDiv }, this.getPeriodSettingsWeekly()),
768
773
  React.createElement(Box, { component: "div", sx: Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowDowsDows) }, this.state.schedule.period.weeks ? this.getPeriodSettingsWeekdays() : null))),
769
- // ----- months ---
770
774
  React.createElement(Box, { component: "div", key: "months", sx: Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowMonths) },
771
775
  React.createElement("div", { style: styles.modeDiv },
772
776
  React.createElement(FormControlLabel, { control: React.createElement(Radio, { style: styles.inputRadio, checked: !!schedule.period.months, onClick: () => {
@@ -804,7 +808,6 @@ export class Schedule extends Component {
804
808
  this.onChange(_schedule);
805
809
  } }), label: I18n.t('sch_periodDates') })),
806
810
  React.createElement(Box, { component: "div", sx: Utils.getStyle(this.props.theme, styles.settingsDiv, styles.rowMonthsDates) }, this.getPeriodSettingsDates()))) : null)),
807
- // ----- years ---
808
811
  React.createElement(Box, { component: "div", key: "years", sx: Utils.getStyle(this.props.theme, styles.rowDiv, styles.rowYears) },
809
812
  React.createElement("div", { style: styles.modeDiv },
810
813
  React.createElement(FormControlLabel, { control: React.createElement(Radio, { style: styles.inputRadio, checked: !!schedule.period.years, onClick: () => {
@@ -1184,6 +1187,9 @@ export class Schedule extends Component {
1184
1187
  return `${padding(d.getDate())}.${padding(d.getMonth() + 1)}.${padding(d.getFullYear())}`;
1185
1188
  }
1186
1189
  static string2date(str) {
1190
+ if (!str) {
1191
+ return new Date();
1192
+ }
1187
1193
  let parts = str.split('.'); // 31.12.2019
1188
1194
  if (parts.length === 1) {
1189
1195
  parts = str.split('-'); // 2018-12-31
@@ -1199,10 +1205,12 @@ export class Schedule extends Component {
1199
1205
  React.createElement("span", { style: { fontWeight: 'bold', paddingRight: 10 } }, I18n.t('sch_valid')),
1200
1206
  React.createElement("span", null, I18n.t('sch_validFrom'))),
1201
1207
  React.createElement("div", { style: styles.settingsDiv },
1202
- React.createElement(TextField, { variant: "standard", style: { ...styles.inputDate, marginRight: 10 }, key: "exactTimeFrom", inputRef: this.refFrom, defaultValue: string2USdate(schedule.valid.from), type: "date",
1208
+ React.createElement(TextField, { variant: "standard", style: { ...styles.inputDate, marginRight: 10 }, key: "exactTimeFrom", inputRef: this.refFrom, defaultValue: string2USdate(schedule.valid?.from), type: "date",
1203
1209
  // inputComponent={TextDate}
1204
1210
  onChange: e => {
1205
- this.timerFrom && clearTimeout(this.timerFrom);
1211
+ if (this.timerFrom) {
1212
+ clearTimeout(this.timerFrom);
1213
+ }
1206
1214
  if (this.refFrom.current) {
1207
1215
  this.refFrom.current.style.background = '#ff000030';
1208
1216
  }
@@ -1221,15 +1229,17 @@ export class Schedule extends Component {
1221
1229
  }, slotProps: {
1222
1230
  inputLabel: { shrink: true },
1223
1231
  }, margin: "normal" }),
1224
- React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { style: styles.inputRadio, checked: !!schedule.valid.to, onClick: () => {
1232
+ React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { style: styles.inputRadio, checked: !!schedule.valid?.to, onClick: () => {
1225
1233
  const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1226
1234
  _schedule.valid.to = _schedule.valid.to ? '' : Schedule.now2string(true);
1227
1235
  this.onChange(_schedule);
1228
1236
  } }), label: I18n.t('sch_validTo') }),
1229
- !!schedule.valid.to && (React.createElement(TextField, { variant: "standard", inputRef: this.refTo, style: { ...styles.inputDate, marginRight: 10 }, key: "exactTimeFrom", type: "date", defaultValue: string2USdate(schedule.valid.to),
1237
+ !!schedule.valid?.to && (React.createElement(TextField, { variant: "standard", inputRef: this.refTo, style: { ...styles.inputDate, marginRight: 10 }, key: "exactTimeFrom", type: "date", defaultValue: string2USdate(schedule.valid.to),
1230
1238
  // inputComponent={TextDate}
1231
1239
  onChange: e => {
1232
- this.timerTo && clearTimeout(this.timerTo);
1240
+ if (this.timerTo) {
1241
+ clearTimeout(this.timerTo);
1242
+ }
1233
1243
  if (this.refTo.current) {
1234
1244
  this.refTo.current.style.background = '#ff000030';
1235
1245
  }