@iobroker/gui-components 8.0.1 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +834 -543
- package/build/AdminConnection.js.map +1 -1
- package/build/Components/404.js +13 -13
- package/build/Components/404.js.map +1 -1
- package/build/Components/ColorPicker.js.map +1 -1
- package/build/Components/ComplexCron.js +2 -2
- package/build/Components/ComplexCron.js.map +1 -1
- package/build/Components/CopyToClipboard.js.map +1 -1
- package/build/Components/CustomModal.js +1 -1
- package/build/Components/CustomModal.js.map +1 -1
- package/build/Components/DeviceType/DeviceTypeIcon.js +1 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js.map +1 -1
- package/build/Components/DeviceType/DeviceTypeSelector.js +2 -2
- package/build/Components/DeviceType/DeviceTypeSelector.js.map +1 -1
- package/build/Components/DeviceType/i18n/de.json +1 -0
- package/build/Components/DeviceType/i18n/en.json +1 -0
- package/build/Components/DeviceType/i18n/fr.json +1 -0
- package/build/Components/DeviceType/i18n/it.json +1 -0
- package/build/Components/DeviceType/i18n/nl.json +1 -0
- package/build/Components/DeviceType/i18n/pl.json +1 -0
- package/build/Components/DeviceType/i18n/pt.json +1 -0
- package/build/Components/DeviceType/i18n/ru.json +1 -0
- package/build/Components/DeviceType/i18n/uk.json +1 -0
- package/build/Components/DeviceType/i18n/zh-cn.json +1 -0
- package/build/Components/FileBrowser.d.ts +39 -4
- package/build/Components/FileBrowser.js +104 -11
- package/build/Components/FileBrowser.js.map +1 -1
- package/build/Components/FileViewer.js +2 -4
- package/build/Components/FileViewer.js.map +1 -1
- package/build/Components/Icon.d.ts +1 -3
- package/build/Components/Icon.js +11 -11
- package/build/Components/Icon.js.map +1 -1
- package/build/Components/Image.js +8 -4
- package/build/Components/Image.js.map +1 -1
- package/build/Components/InfoBox.js +1 -1
- package/build/Components/InfoBox.js.map +1 -1
- package/build/Components/IobUri.js +5 -5
- package/build/Components/IobUri.js.map +1 -1
- package/build/Components/Loader.d.ts +2 -3
- package/build/Components/Loader.js +25 -257
- package/build/Components/Loader.js.map +1 -1
- package/build/Components/Loaders/Community.d.ts +31 -0
- package/build/Components/Loaders/Community.js +265 -0
- package/build/Components/Loaders/Community.js.map +1 -0
- package/build/Components/Loaders/HA.d.ts +17 -0
- package/build/Components/Loaders/HA.js +99 -0
- package/build/Components/Loaders/HA.js.map +1 -0
- package/build/Components/Loaders/MV.js.map +1 -1
- package/build/Components/Loaders/NW.d.ts +17 -0
- package/build/Components/Loaders/NW.js +70 -0
- package/build/Components/Loaders/NW.js.map +1 -0
- package/build/Components/Loaders/PT.js +103 -103
- package/build/Components/Loaders/PT.js.map +1 -1
- package/build/Components/Loaders/Vendor.js +7 -7
- package/build/Components/Loaders/Vendor.js.map +1 -1
- package/build/Components/MDUtils.js.map +1 -1
- package/build/Components/ObjectBrowser.d.ts +25 -406
- package/build/Components/ObjectBrowser.js +460 -1543
- package/build/Components/ObjectBrowser.js.map +1 -1
- package/build/Components/Router.js.map +1 -1
- package/build/Components/SaveCloseButtons.js.map +1 -1
- package/build/Components/Schedule.d.ts +27 -1
- package/build/Components/Schedule.js +60 -50
- package/build/Components/Schedule.js.map +1 -1
- package/build/Components/SelectWithIcon.js +1 -1
- package/build/Components/SelectWithIcon.js.map +1 -1
- package/build/Components/SimpleCron/cronText.js.map +1 -1
- package/build/Components/SimpleCron/index.js +3 -3
- package/build/Components/SimpleCron/index.js.map +1 -1
- package/build/Components/TabContainer.js +7 -2
- package/build/Components/TabContainer.js.map +1 -1
- package/build/Components/TabContent.d.ts +1 -1
- package/build/Components/TabContent.js +5 -5
- package/build/Components/TabContent.js.map +1 -1
- package/build/Components/TabHeader.js +2 -2
- package/build/Components/TabHeader.js.map +1 -1
- package/build/Components/TableResize.js.map +1 -1
- package/build/Components/TextWithIcon.js.map +1 -1
- package/build/Components/TreeTable.d.ts +1 -0
- package/build/Components/TreeTable.js +16 -6
- package/build/Components/TreeTable.js.map +1 -1
- package/build/Components/UploadImage.js +305 -305
- package/build/Components/UploadImage.js.map +1 -1
- package/build/Components/Utils.d.ts +17 -3
- package/build/Components/Utils.js +167 -9
- package/build/Components/Utils.js.map +1 -1
- package/build/Components/objectBrowser.types.d.ts +496 -0
- package/build/Components/objectBrowserUtils.d.ts +170 -0
- package/build/Components/objectBrowserUtils.js +1375 -0
- package/build/Components/objectBrowserUtils.js.map +1 -0
- package/build/Connection.js.map +1 -1
- package/build/Dialogs/ComplexCron.js.map +1 -1
- package/build/Dialogs/Confirm.js.map +1 -1
- package/build/Dialogs/Cron.js.map +1 -1
- package/build/Dialogs/Error.js.map +1 -1
- package/build/Dialogs/Message.js.map +1 -1
- package/build/Dialogs/SelectFile.d.ts +1 -1
- package/build/Dialogs/SelectFile.js +1 -1
- package/build/Dialogs/SelectFile.js.map +1 -1
- package/build/Dialogs/SelectID.d.ts +1 -1
- package/build/Dialogs/SelectID.js +1 -1
- package/build/Dialogs/SelectID.js.map +1 -1
- package/build/Dialogs/SimpleCron.js.map +1 -1
- package/build/Dialogs/TextInput.js +1 -1
- package/build/Dialogs/TextInput.js.map +1 -1
- package/build/GenericApp.d.ts +6 -4
- package/build/GenericApp.js +22 -16
- package/build/GenericApp.js.map +1 -1
- package/build/Prompt.js +7 -7
- package/build/Prompt.js.map +1 -1
- package/build/Theme.js +57 -11
- package/build/Theme.js.map +1 -1
- package/build/assets/devices/parseNames.js +1 -0
- package/build/assets/devices/parseNames.js.map +1 -1
- package/build/assets/rooms/parseNames.js +1 -0
- package/build/assets/rooms/parseNames.js.map +1 -1
- package/build/dictionary.js.map +1 -1
- package/build/globals.d.ts +2 -0
- package/build/i18n/de.json +5 -66
- package/build/i18n/en.json +5 -66
- package/build/i18n/es.json +5 -66
- package/build/i18n/fr.json +5 -66
- package/build/i18n/it.json +5 -61
- package/build/i18n/nl.json +5 -61
- package/build/i18n/pl.json +5 -61
- package/build/i18n/pt.json +5 -61
- package/build/i18n/ru.json +5 -61
- package/build/i18n/uk.json +5 -61
- package/build/i18n/zh-cn.json +5 -61
- package/build/i18n.js +12 -15
- package/build/i18n.js.map +1 -1
- package/build/index.css +56 -56
- package/build/index.d.ts +9 -4
- package/build/index.js +5 -2
- package/build/index.js.map +1 -1
- package/build/modulefederation.admin.config.d.ts +1 -0
- package/build/modulefederation.admin.config.js +1 -1
- package/build/modulefederation.admin.config.js.map +1 -1
- package/build/types.d.ts +4 -84
- package/i18n/de.json +5 -66
- package/i18n/en.json +5 -66
- package/i18n/es.json +5 -66
- package/i18n/fr.json +5 -66
- package/i18n/it.json +5 -61
- package/i18n/nl.json +5 -61
- package/i18n/pl.json +5 -61
- package/i18n/pt.json +5 -61
- package/i18n/ru.json +5 -61
- package/i18n/uk.json +5 -61
- package/i18n/zh-cn.json +5 -61
- package/index.css +56 -56
- package/modulefederation.admin.config.d.ts +1 -0
- package/modulefederation.admin.config.js +1 -2
- package/package.json +49 -34
- package/tasksExample.ts +93 -0
- package/build/LegacyConnection.d.ts +0 -938
- package/build/LegacyConnection.js +0 -2849
- package/build/LegacyConnection.js.map +0 -1
- package/tasksExample.js +0 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceTypeIcon.js","sourceRoot":"./src/","sources":["Components/DeviceType/DeviceTypeIcon.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,gBAAg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utlineLineChart 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';\nimport { extendDeviceTypeTranslation } from './deviceTypeTranslations';\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.locationOne]: 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 DeviceTypeIcon(props: TypeIconProps): React.JSX.Element | null {\n const [loaded, setLoaded] = React.useState(false);\n\n useEffect(() => {\n if (props.title && !loaded) {\n extendDeviceTypeTranslation();\n setLoaded(true);\n }\n }, [props.title, loaded]);\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 ||\n (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"]}
|
|
1
|
+
{"version":3,"file":"DeviceTypeIcon.js","sourceRoot":"./src/","sources":["Components/DeviceType/DeviceTypeIcon.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,gBAAgB,GAC/B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,iBAAiB,IAAI,WAAW,EAChC,iBAAiB,IAAI,UAAU,EAC/B,SAAS,IAAI,eAAe,EAC5B,cAAc,IAAI,eAAe,EACjC,mBAAmB,IAAI,mBAAmB,EAC1C,WAAW,IAAI,YAAY,EAC3B,UAAU,IAAI,YAAY,EAC1B,KAAK,IAAI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AG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAQ,CAClG,CAAC,CAAC,CAAC,IAAI,CAAC;IACb,CAAC;IAED,MAAM,IAAI,GAAG,CACT,oBAAC,QAAQ,IACL,KAAK,EAAE,EAAE,GAAG,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC,EAAE,EACzD,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,EAAE,EAAE,KAAK,CAAC,EAAE,GACd,CACL,CAAC;IAEF,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO,CACH,oBAAC,OAAO,IACJ,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,EACxD,KAAK,EAAE,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK;YAElE,6BAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,IAAI,CAAO,CACvC,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';\nimport { extendDeviceTypeTranslation } from './deviceTypeTranslations';\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.locationOne]: TypeIconLocationOne,\n [Types.media]: TypeIconMedia,\n [Types.motion]: TypeIconMotion,\n [Types.ct]: TypeIconCT,\n [Types.percentage]: TypeIconSlider,\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 DeviceTypeIcon(props: TypeIconProps): React.JSX.Element | null {\n const [loaded, setLoaded] = React.useState(false);\n\n useEffect(() => {\n if (props.title && !loaded) {\n extendDeviceTypeTranslation();\n setLoaded(true);\n }\n }, [props.title, loaded]);\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 ||\n (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"]}
|
|
@@ -53,7 +53,7 @@ export function DeviceTypeSelector(props) {
|
|
|
53
53
|
if (_typesWords[a] === _typesWords[b]) {
|
|
54
54
|
return 0;
|
|
55
55
|
}
|
|
56
|
-
return _typesWords[a]
|
|
56
|
+
return _typesWords[a]?.localeCompare(_typesWords[b] || '', 'de') || 0;
|
|
57
57
|
});
|
|
58
58
|
extendDeviceTypeTranslation();
|
|
59
59
|
setTypes(_types);
|
|
@@ -78,6 +78,6 @@ export function DeviceTypeSelector(props) {
|
|
|
78
78
|
color: props.themeType === 'dark' ? '#FFFFFF' : '#000',
|
|
79
79
|
} }),
|
|
80
80
|
React.createElement("span", { style: styles.selectText }, typesWords[typeId])),
|
|
81
|
-
props.showApplications?.TYPE_OPTIONS[typeId] ? (React.createElement("div", { style: styles.iconWrapper }, Object.keys(props.showApplications.TYPE_OPTIONS[typeId]).map(key => props.showApplications
|
|
81
|
+
props.showApplications?.TYPE_OPTIONS[typeId] ? (React.createElement("div", { style: styles.iconWrapper }, Object.keys(props.showApplications.TYPE_OPTIONS[typeId]).map(key => props.showApplications?.TYPE_OPTIONS[typeId]?.[key] ? (React.createElement(Icon, { key: key, style: styles.iconStyle, src: props.showApplications.ICONS_TYPE[key] })) : (React.createElement("div", { key: key, style: styles.emptyIcon }))))) : null)))))));
|
|
82
82
|
}
|
|
83
83
|
//# sourceMappingURL=DeviceTypeSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceTypeSelector.js","sourceRoot":"./src/","sources":["Components/DeviceType/DeviceTypeSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OA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putLabel, MenuItem, Select } from '@mui/material';\n\nimport { Types } from '@iobroker/type-detector';\n\nimport { I18n } from '../../i18n';\nimport { Icon } from '../Icon';\nimport type { ThemeType } from '../../types';\n\nimport { DeviceTypeIcon } from './DeviceTypeIcon';\nimport { extendDeviceTypeTranslation } from './deviceTypeTranslations';\n\nconst styles: Record<\n 'itemChildrenWrapper' | 'type' | 'selectIcon' | 'selectText' | 'iconWrapper' | 'iconStyle' | 'emptyIcon',\n React.CSSProperties\n> = {\n itemChildrenWrapper: {\n display: 'flex',\n width: '100%',\n justifyContent: 'space-between',\n },\n type: {\n marginTop: 10,\n },\n selectIcon: {\n paddingRight: 8,\n verticalAlign: 'middle',\n width: 20,\n height: 20,\n },\n selectText: {\n verticalAlign: 'middle',\n },\n iconWrapper: {\n display: 'flex',\n alignItems: 'center',\n },\n iconStyle: {\n width: 16,\n height: 16,\n margin: '0 3px',\n },\n emptyIcon: {\n width: 16,\n height: 16,\n margin: '0 3px',\n },\n};\n\nexport function DeviceTypeSelector(props: {\n themeType: ThemeType;\n supportedDevices?: Types[];\n unsupportedDevices?: Types[];\n value?: Types | '';\n onChange: (value: Types) => void;\n label?: string;\n style?: React.CSSProperties;\n sx?: Record<string, any>;\n disabled?: boolean;\n error?: boolean;\n /** Show icons for applications: google, amazon, material, alias. Used in devices */\n showApplications?: {\n TYPE_OPTIONS: Partial<Record<Types, Record<string, boolean>>>;\n ICONS_TYPE: Record<string, React.JSX.Element>;\n };\n}): React.JSX.Element {\n const [typesWords, setTypesWords] = React.useState<Partial<Record<Types, string>>>({});\n const [types, setTypes] = React.useState<Types[] | null>([]);\n\n useEffect(() => {\n const _typesWords: Partial<Record<Types, string>> = {};\n Object.keys(Types)\n .filter(\n id =>\n (!props.supportedDevices || props.supportedDevices?.includes(id as Types)) &&\n !props.unsupportedDevices?.includes(id as Types),\n )\n .forEach(typeId => (_typesWords[typeId as Types] = I18n.t(`type-${Types[typeId as Types]}`)));\n\n // sort types by ABC in the current language\n const _types: Types[] = Object.keys(_typesWords) as Types[];\n\n _types.sort((a, b) => {\n if (_typesWords[a] === _typesWords[b]) {\n return 0;\n }\n return _typesWords[a]?.localeCompare(_typesWords[b] || '', 'de') || 0;\n });\n\n extendDeviceTypeTranslation();\n\n setTypes(_types);\n setTypesWords(_typesWords);\n }, [props.supportedDevices, props.unsupportedDevices]);\n\n if (!types) {\n return (\n <Box\n style={{\n ...styles.type,\n ...props.style,\n }}\n sx={props.sx}\n />\n );\n }\n\n return (\n <FormControl\n style={{\n ...styles.type,\n ...props.style,\n }}\n sx={props.sx}\n variant=\"standard\"\n error={!!props.error}\n >\n <InputLabel>{props.label || I18n.t('type-Device type')}</InputLabel>\n <Select\n variant=\"standard\"\n disabled={!!props.disabled}\n value={props.value}\n onChange={e => props.onChange(e.target.value)}\n >\n {types.map(typeId => (\n <MenuItem\n key={Types[typeId]}\n value={Types[typeId]}\n >\n <div style={styles.itemChildrenWrapper}>\n <div>\n <DeviceTypeIcon\n type={Types[typeId]}\n style={{\n ...styles.selectIcon,\n color: props.themeType === 'dark' ? '#FFFFFF' : '#000',\n }}\n />\n <span style={styles.selectText}>{typesWords[typeId]}</span>\n </div>\n {props.showApplications?.TYPE_OPTIONS[typeId] ? (\n <div style={styles.iconWrapper}>\n {Object.keys(props.showApplications.TYPE_OPTIONS[typeId]).map(key =>\n props.showApplications?.TYPE_OPTIONS[typeId]?.[key] ? (\n <Icon\n key={key}\n style={styles.iconStyle}\n src={props.showApplications.ICONS_TYPE[key]}\n />\n ) : (\n <div\n key={key}\n style={styles.emptyIcon}\n />\n ),\n )}\n </div>\n ) : null}\n </div>\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n );\n}\n"]}
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"type-lock": "Lock",
|
|
27
27
|
"type-media": "Media-player",
|
|
28
28
|
"type-motion": "Motion sensor",
|
|
29
|
+
"type-percentage": "Percentage",
|
|
29
30
|
"type-rgb": "RGB light",
|
|
30
31
|
"type-rgbSingle": "R,G,B light - single states",
|
|
31
32
|
"type-rgbwSingle": "R,G,B,W light - single states",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"type-lock": "Замок",
|
|
27
27
|
"type-media": "Медиа-плейер",
|
|
28
28
|
"type-motion": "Датчик движения",
|
|
29
|
+
"type-percentage": "Проценты",
|
|
29
30
|
"type-rgb": "RGB свет",
|
|
30
31
|
"type-rgbSingle": "R,G,B как отдельные значение",
|
|
31
32
|
"type-rgbwSingle": "R,G,B,W как отдельные значение",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2026, Denis Haev <dogafox@gmail.com>
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -14,9 +14,18 @@ export interface MetaACL extends ioBroker.ObjectACL {
|
|
|
14
14
|
export interface MetaObject extends ioBroker.MetaObject {
|
|
15
15
|
acl: MetaACL;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A navigation target the parent can use to drive the browser (and that the browser reports back).
|
|
19
|
+
* Maps cleanly to a route like `#tab-files/<mode>/<encoded-id>` (the parent encodes the file path,
|
|
20
|
+
* whose `/` separators would otherwise clash with the hash). The browser never reads the URL.
|
|
21
|
+
*/
|
|
22
|
+
export interface FileBrowserNavigation {
|
|
23
|
+
/** `select` = just highlight the file; `view` = open the file viewer. */
|
|
24
|
+
mode: 'select' | 'view';
|
|
25
|
+
/** The file path/ID (e.g. `email.admin/custom/assets/Components.js`). */
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
17
28
|
export interface FileBrowserProps {
|
|
18
|
-
/** The key to identify this component. */
|
|
19
|
-
key?: string;
|
|
20
29
|
/** Additional styling for this component. */
|
|
21
30
|
style?: React.CSSProperties;
|
|
22
31
|
/** The CSS class name. */
|
|
@@ -61,6 +70,17 @@ export interface FileBrowserProps {
|
|
|
61
70
|
filterByType?: 'images' | 'code' | 'txt';
|
|
62
71
|
/** Callback for file selection. */
|
|
63
72
|
onSelect?: (id: string | string[], isDoubleClick?: boolean, isFolder?: boolean) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Drive selection and the file viewer from the parent (e.g. from the URL). When this prop
|
|
75
|
+
* changes the browser selects the file and opens the requested viewer. The browser does NOT
|
|
76
|
+
* read the URL itself — all URL parsing/writing lives in the parent component.
|
|
77
|
+
*/
|
|
78
|
+
navigateTo?: FileBrowserNavigation | null;
|
|
79
|
+
/**
|
|
80
|
+
* Called when the user navigates inside the browser (selects a file or opens/closes the viewer)
|
|
81
|
+
* so the parent can reflect it in the URL. The browser never touches the URL itself.
|
|
82
|
+
*/
|
|
83
|
+
onNavigateTo?: (navigation: FileBrowserNavigation | null) => void;
|
|
64
84
|
/** Theme name */
|
|
65
85
|
themeName?: ThemeName;
|
|
66
86
|
/** Theme type. */
|
|
@@ -132,6 +152,10 @@ export declare class FileBrowserClass extends Component<FileBrowserProps, FileBr
|
|
|
132
152
|
private readonly limitToObjectID;
|
|
133
153
|
private readonly limitToPath;
|
|
134
154
|
private lastSelect;
|
|
155
|
+
/** Last navigation applied from `navigateTo` or reported via `onNavigateTo` (loop guard). */
|
|
156
|
+
private lastNav;
|
|
157
|
+
/** True while applying `navigateTo`, so the derived-state watcher does not echo it back. */
|
|
158
|
+
private applyingNav;
|
|
135
159
|
private setOpacityTimer;
|
|
136
160
|
private cacheFoldersTimeout;
|
|
137
161
|
private foldersLoading;
|
|
@@ -168,7 +192,18 @@ export declare class FileBrowserClass extends Component<FileBrowserProps, FileBr
|
|
|
168
192
|
renderToolbar(): JSX.Element;
|
|
169
193
|
findItem(id: string, folders?: Folders | null): null | FolderOrFileItem;
|
|
170
194
|
renderInputDialog(): JSX.Element | null;
|
|
171
|
-
|
|
195
|
+
/** Strip the image prefix from a viewer href to get back the raw file path. */
|
|
196
|
+
private viewerToId;
|
|
197
|
+
/** Derive the current navigation target from the viewer/selection state. */
|
|
198
|
+
private getStateNav;
|
|
199
|
+
private static navEqual;
|
|
200
|
+
/** Apply a navigation target coming from the parent (`navigateTo`): select + open the viewer. */
|
|
201
|
+
private applyNavigateTo;
|
|
202
|
+
/** Apply the initial `navigateTo` once the browser is ready (called from componentDidMount). */
|
|
203
|
+
applyInitialNavigateTo(): void;
|
|
204
|
+
/** Reconcile `navigateTo` (parent/URL) with the browser's selection/viewer state. */
|
|
205
|
+
private reconcileNavigation;
|
|
206
|
+
componentDidUpdate(prevProps: FileBrowserProps): void;
|
|
172
207
|
findFirstFolder(id: string): string | null;
|
|
173
208
|
uploadFile(fileName: string, data: string): Promise<void>;
|
|
174
209
|
renderUpload(): JSX.Element[] | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2020-
|
|
2
|
+
* Copyright 2020-2026, Denis Haev <dogafox@gmail.com>
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
@@ -394,6 +394,10 @@ export class FileBrowserClass extends Component {
|
|
|
394
394
|
limitToObjectID = null;
|
|
395
395
|
limitToPath = null;
|
|
396
396
|
lastSelect = null;
|
|
397
|
+
/** Last navigation applied from `navigateTo` or reported via `onNavigateTo` (loop guard). */
|
|
398
|
+
lastNav = null;
|
|
399
|
+
/** True while applying `navigateTo`, so the derived-state watcher does not echo it back. */
|
|
400
|
+
applyingNav = false;
|
|
397
401
|
setOpacityTimer = null;
|
|
398
402
|
cacheFoldersTimeout = null;
|
|
399
403
|
foldersLoading = null;
|
|
@@ -505,14 +509,14 @@ export class FileBrowserClass extends Component {
|
|
|
505
509
|
}
|
|
506
510
|
async loadFolders() {
|
|
507
511
|
this.initialReadFinished = false;
|
|
508
|
-
let folders =
|
|
512
|
+
let folders = await this.browseFolder('/');
|
|
509
513
|
if (this.state.viewType === TABLE) {
|
|
510
|
-
folders =
|
|
514
|
+
folders = await this.browseFolders([...this.state.expanded], folders);
|
|
511
515
|
}
|
|
512
516
|
else if (this.state.currentDir &&
|
|
513
517
|
this.state.currentDir !== '/' &&
|
|
514
518
|
(!this.limitToObjectID || this.state.currentDir.startsWith(this.limitToObjectID))) {
|
|
515
|
-
folders =
|
|
519
|
+
folders = await this.browseFolder(this.state.currentDir, folders);
|
|
516
520
|
}
|
|
517
521
|
this.setState({ folders }, () => {
|
|
518
522
|
if (this.state.viewType === TABLE && !this.findItem(this.state.selected)) {
|
|
@@ -543,7 +547,9 @@ export class FileBrowserClass extends Component {
|
|
|
543
547
|
}
|
|
544
548
|
async componentDidMount() {
|
|
545
549
|
this.mounted = true;
|
|
546
|
-
this.loadFolders()
|
|
550
|
+
this.loadFolders()
|
|
551
|
+
.then(() => this.applyInitialNavigateTo())
|
|
552
|
+
.catch(error => console.error(`Cannot load folders: ${error}`));
|
|
547
553
|
this.browseList = [];
|
|
548
554
|
this.browseListRunning = false;
|
|
549
555
|
this.supportSubscribes = await this.props.socket.checkFeatureSupported('BINARY_STATE_EVENT');
|
|
@@ -604,7 +610,7 @@ export class FileBrowserClass extends Component {
|
|
|
604
610
|
if (this.browseList) {
|
|
605
611
|
// if component still mounted
|
|
606
612
|
this.browseList.push({
|
|
607
|
-
resolve
|
|
613
|
+
resolve,
|
|
608
614
|
reject,
|
|
609
615
|
adapter,
|
|
610
616
|
relPath,
|
|
@@ -1341,8 +1347,8 @@ export class FileBrowserClass extends Component {
|
|
|
1341
1347
|
return null;
|
|
1342
1348
|
}
|
|
1343
1349
|
return (React.createElement(DialogTextInput, { key: "inputDialog", applyText: this.props.t('ra_Create'), cancelText: this.props.t('ra_Cancel'), titleText: this.props.t('ra_Create new folder in %s', this.state.selected), promptText: this.props.t('ra_If no file will be created in the folder, it will disappear after the browser closed'), labelText: this.props.t('ra_Folder name'), verify: (text) => this.state.folders[parentFolder].find(item => item.name === text)
|
|
1344
|
-
? ''
|
|
1345
|
-
:
|
|
1350
|
+
? this.props.t('ra_Duplicate name')
|
|
1351
|
+
: '', onClose: (name) => {
|
|
1346
1352
|
if (name) {
|
|
1347
1353
|
const folders = {};
|
|
1348
1354
|
Object.keys(this.state.folders).forEach(folder => (folders[folder] = this.state.folders[folder]));
|
|
@@ -1372,7 +1378,86 @@ export class FileBrowserClass extends Component {
|
|
|
1372
1378
|
}
|
|
1373
1379
|
return null;
|
|
1374
1380
|
}
|
|
1375
|
-
|
|
1381
|
+
// --- Routing (navigateTo / onNavigateTo) ---
|
|
1382
|
+
// The browser never reads the URL; the parent drives it via `navigateTo` and is informed of user
|
|
1383
|
+
// navigation via `onNavigateTo`. All URL parsing/encoding lives in the parent component.
|
|
1384
|
+
/** Strip the image prefix from a viewer href to get back the raw file path. */
|
|
1385
|
+
viewerToId(viewer) {
|
|
1386
|
+
return viewer.startsWith(this.imagePrefix) ? viewer.substring(this.imagePrefix.length) : viewer;
|
|
1387
|
+
}
|
|
1388
|
+
/** Derive the current navigation target from the viewer/selection state. */
|
|
1389
|
+
getStateNav() {
|
|
1390
|
+
if (this.state.viewer) {
|
|
1391
|
+
return { mode: 'view', id: this.viewerToId(this.state.viewer) };
|
|
1392
|
+
}
|
|
1393
|
+
if (this.state.selected) {
|
|
1394
|
+
return { mode: 'select', id: this.state.selected };
|
|
1395
|
+
}
|
|
1396
|
+
return null;
|
|
1397
|
+
}
|
|
1398
|
+
static navEqual(a, b) {
|
|
1399
|
+
if (!a || !b) {
|
|
1400
|
+
return !a && !b;
|
|
1401
|
+
}
|
|
1402
|
+
return a.mode === b.mode && a.id === b.id;
|
|
1403
|
+
}
|
|
1404
|
+
/** Apply a navigation target coming from the parent (`navigateTo`): select + open the viewer. */
|
|
1405
|
+
applyNavigateTo(nav) {
|
|
1406
|
+
this.applyingNav = true;
|
|
1407
|
+
const done = () => {
|
|
1408
|
+
this.applyingNav = false;
|
|
1409
|
+
};
|
|
1410
|
+
if (!nav?.id) {
|
|
1411
|
+
this.setState({ viewer: '', formatEditFile: '' }, done);
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
const { id } = nav;
|
|
1415
|
+
this.select(id, null, () => {
|
|
1416
|
+
this.scrollToSelected();
|
|
1417
|
+
if (nav.mode === 'view') {
|
|
1418
|
+
this.setState({ viewer: this.imagePrefix + id, formatEditFile: Utils.getFileExtension(id) }, done);
|
|
1419
|
+
}
|
|
1420
|
+
else {
|
|
1421
|
+
this.setState({ viewer: '', formatEditFile: '' }, done);
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
/** Apply the initial `navigateTo` once the browser is ready (called from componentDidMount). */
|
|
1426
|
+
applyInitialNavigateTo() {
|
|
1427
|
+
const nav = this.props.navigateTo ?? null;
|
|
1428
|
+
if (nav?.id) {
|
|
1429
|
+
this.lastNav = nav;
|
|
1430
|
+
this.applyNavigateTo(nav);
|
|
1431
|
+
}
|
|
1432
|
+
else {
|
|
1433
|
+
// Don't push the restored-from-localStorage selection into the URL on load.
|
|
1434
|
+
this.lastNav = this.getStateNav();
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
/** Reconcile `navigateTo` (parent/URL) with the browser's selection/viewer state. */
|
|
1438
|
+
reconcileNavigation(prevProps) {
|
|
1439
|
+
if (this.props.navigateTo === undefined && !this.props.onNavigateTo) {
|
|
1440
|
+
return; // routing not used by this consumer
|
|
1441
|
+
}
|
|
1442
|
+
if (this.applyingNav) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
const propNav = this.props.navigateTo ?? null;
|
|
1446
|
+
const stateNav = this.getStateNav();
|
|
1447
|
+
if (FileBrowserClass.navEqual(propNav, stateNav)) {
|
|
1448
|
+
this.lastNav = stateNav;
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
if (!FileBrowserClass.navEqual(propNav, prevProps.navigateTo ?? null)) {
|
|
1452
|
+
this.lastNav = propNav;
|
|
1453
|
+
this.applyNavigateTo(propNav);
|
|
1454
|
+
}
|
|
1455
|
+
else if (!FileBrowserClass.navEqual(stateNav, this.lastNav)) {
|
|
1456
|
+
this.lastNav = stateNav;
|
|
1457
|
+
this.props.onNavigateTo?.(stateNav);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
componentDidUpdate(prevProps /* , prevState, snapshot */) {
|
|
1376
1461
|
if (this.setOpacityTimer) {
|
|
1377
1462
|
clearTimeout(this.setOpacityTimer);
|
|
1378
1463
|
}
|
|
@@ -1383,6 +1468,7 @@ export class FileBrowserClass extends Component {
|
|
|
1383
1468
|
items[i].style.opacity = '1';
|
|
1384
1469
|
}
|
|
1385
1470
|
}, 100);
|
|
1471
|
+
this.reconcileNavigation(prevProps);
|
|
1386
1472
|
}
|
|
1387
1473
|
findFirstFolder(id) {
|
|
1388
1474
|
let parentFolder = id;
|
|
@@ -1561,7 +1647,7 @@ export class FileBrowserClass extends Component {
|
|
|
1561
1647
|
renderDeleteDialog() {
|
|
1562
1648
|
if (this.state.deleteItem) {
|
|
1563
1649
|
return (React.createElement(Dialog, { key: "deleteDialog", open: !0, onClose: () => this.setState({ deleteItem: '' }), "aria-labelledby": "ar_dialog_file_delete_title" },
|
|
1564
|
-
React.createElement(DialogTitle, { id: "ar_dialog_file_delete_title" }, this.props.t('ra_Confirm deletion of %s', this.state.deleteItem.split('/').pop())),
|
|
1650
|
+
React.createElement(DialogTitle, { id: "ar_dialog_file_delete_title" }, this.props.t('ra_Confirm deletion of %s', this.state.deleteItem.split('/').pop() || '')),
|
|
1565
1651
|
React.createElement(DialogContent, null,
|
|
1566
1652
|
React.createElement(DialogContentText, null, this.props.t('ra_Are you sure?')),
|
|
1567
1653
|
React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { checked: this.state.suppressDeleteConfirm, onChange: () => {
|
|
@@ -1682,7 +1768,14 @@ export class FileBrowserClass extends Component {
|
|
|
1682
1768
|
this.state.viewType === TILE ? this.renderPath() : null,
|
|
1683
1769
|
React.createElement("div", { style: {
|
|
1684
1770
|
...styles.filesDiv,
|
|
1685
|
-
...styles[
|
|
1771
|
+
...styles[this.state.viewType === 'Tile' ? 'filesDivTile' : 'filesDivTable'],
|
|
1772
|
+
height: this.props.showToolbar
|
|
1773
|
+
? this.state.viewType === 'Tile'
|
|
1774
|
+
? `calc(100% - ${48 + 8}px)`
|
|
1775
|
+
: 'calc(100% - 56px)'
|
|
1776
|
+
: this.state.viewType === 'Tile'
|
|
1777
|
+
? `calc(100% - ${48 * 2 + 8}px)`
|
|
1778
|
+
: 'calc(100% - 8px)',
|
|
1686
1779
|
}, onClick: e => {
|
|
1687
1780
|
if (this.state.viewType !== TABLE) {
|
|
1688
1781
|
if (this.state.selected !== (this.state.currentDir || '/')) {
|