@iobroker/gui-components 8.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 -0
- package/README.md +1450 -0
- package/build/AdminConnection.d.ts +1 -0
- package/build/AdminConnection.js +2 -0
- package/build/AdminConnection.js.map +1 -0
- package/build/Components/404.d.ts +4 -0
- package/build/Components/404.js +97 -0
- package/build/Components/404.js.map +1 -0
- package/build/Components/ColorPicker.d.ts +86 -0
- package/build/Components/ColorPicker.js +222 -0
- package/build/Components/ColorPicker.js.map +1 -0
- package/build/Components/ComplexCron.d.ts +40 -0
- package/build/Components/ComplexCron.js +401 -0
- package/build/Components/ComplexCron.js.map +1 -0
- package/build/Components/CopyToClipboard.d.ts +14 -0
- package/build/Components/CopyToClipboard.js +160 -0
- package/build/Components/CopyToClipboard.js.map +1 -0
- package/build/Components/CustomModal.d.ts +26 -0
- package/build/Components/CustomModal.js +62 -0
- package/build/Components/CustomModal.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeIcon.d.ts +29 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js +108 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeOptions.d.ts +2 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js +69 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeSelector.d.ts +20 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js +83 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js.map +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.d.ts +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js +30 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js.map +1 -0
- package/build/Components/DeviceType/i18n/de.json +46 -0
- package/build/Components/DeviceType/i18n/en.json +46 -0
- package/build/Components/DeviceType/i18n/fr.json +46 -0
- package/build/Components/DeviceType/i18n/it.json +46 -0
- package/build/Components/DeviceType/i18n/nl.json +46 -0
- package/build/Components/DeviceType/i18n/pl.json +46 -0
- package/build/Components/DeviceType/i18n/pt.json +46 -0
- package/build/Components/DeviceType/i18n/ru.json +46 -0
- package/build/Components/DeviceType/i18n/uk.json +46 -0
- package/build/Components/DeviceType/i18n/zh-cn.json +46 -0
- package/build/Components/DeviceType/icons/Cleaner.d.ts +3 -0
- package/build/Components/DeviceType/icons/Cleaner.js +14 -0
- package/build/Components/DeviceType/icons/Cleaner.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorClosed.js +7 -0
- package/build/Components/DeviceType/icons/DoorClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorOpened.js +7 -0
- package/build/Components/DeviceType/icons/DoorOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOff.js +8 -0
- package/build/Components/DeviceType/icons/FireOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOn.js +14 -0
- package/build/Components/DeviceType/icons/FireOn.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOff.js +11 -0
- package/build/Components/DeviceType/icons/FloodOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOn.js +18 -0
- package/build/Components/DeviceType/icons/FloodOn.js.map +1 -0
- package/build/Components/DeviceType/icons/Gate.d.ts +3 -0
- package/build/Components/DeviceType/icons/Gate.js +8 -0
- package/build/Components/DeviceType/icons/Gate.js.map +1 -0
- package/build/Components/DeviceType/icons/HeatValve.d.ts +3 -0
- package/build/Components/DeviceType/icons/HeatValve.js +6 -0
- package/build/Components/DeviceType/icons/HeatValve.js.map +1 -0
- package/build/Components/DeviceType/icons/Home.d.ts +3 -0
- package/build/Components/DeviceType/icons/Home.js +6 -0
- package/build/Components/DeviceType/icons/Home.js.map +1 -0
- package/build/Components/DeviceType/icons/Humidity.d.ts +3 -0
- package/build/Components/DeviceType/icons/Humidity.js +8 -0
- package/build/Components/DeviceType/icons/Humidity.js.map +1 -0
- package/build/Components/DeviceType/icons/IconHome.d.ts +5 -0
- package/build/Components/DeviceType/icons/IconHome.js +21 -0
- package/build/Components/DeviceType/icons/IconHome.js.map +1 -0
- package/build/Components/DeviceType/icons/Jalousie.d.ts +3 -0
- package/build/Components/DeviceType/icons/Jalousie.js +7 -0
- package/build/Components/DeviceType/icons/Jalousie.js.map +1 -0
- package/build/Components/DeviceType/icons/Material.d.ts +3 -0
- package/build/Components/DeviceType/icons/Material.js +8 -0
- package/build/Components/DeviceType/icons/Material.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOff.js +11 -0
- package/build/Components/DeviceType/icons/MotionOff.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOn.js +7 -0
- package/build/Components/DeviceType/icons/MotionOn.js.map +1 -0
- package/build/Components/DeviceType/icons/PushButton.d.ts +3 -0
- package/build/Components/DeviceType/icons/PushButton.js +9 -0
- package/build/Components/DeviceType/icons/PushButton.js.map +1 -0
- package/build/Components/DeviceType/icons/RGB.d.ts +3 -0
- package/build/Components/DeviceType/icons/RGB.js +43 -0
- package/build/Components/DeviceType/icons/RGB.js.map +1 -0
- package/build/Components/DeviceType/icons/RepairExpert.d.ts +3 -0
- package/build/Components/DeviceType/icons/RepairExpert.js +6 -0
- package/build/Components/DeviceType/icons/RepairExpert.js.map +1 -0
- package/build/Components/DeviceType/icons/Socket.d.ts +3 -0
- package/build/Components/DeviceType/icons/Socket.js +8 -0
- package/build/Components/DeviceType/icons/Socket.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermometer.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermometer.js +7 -0
- package/build/Components/DeviceType/icons/Thermometer.js.map +1 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.d.ts +3 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js +8 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermostat.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermostat.js +9 -0
- package/build/Components/DeviceType/icons/Thermostat.js.map +1 -0
- package/build/Components/DeviceType/icons/Valve.d.ts +3 -0
- package/build/Components/DeviceType/icons/Valve.js +7 -0
- package/build/Components/DeviceType/icons/Valve.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowClosed.js +8 -0
- package/build/Components/DeviceType/icons/WindowClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowOpened.js +9 -0
- package/build/Components/DeviceType/icons/WindowOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowTilted.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowTilted.js +8 -0
- package/build/Components/DeviceType/icons/WindowTilted.js.map +1 -0
- package/build/Components/DeviceType/icons/index.d.ts +28 -0
- package/build/Components/DeviceType/icons/index.js +28 -0
- package/build/Components/DeviceType/icons/index.js.map +1 -0
- package/build/Components/FileBrowser.d.ts +187 -0
- package/build/Components/FileBrowser.js +1711 -0
- package/build/Components/FileBrowser.js.map +1 -0
- package/build/Components/FileViewer.d.ts +49 -0
- package/build/Components/FileViewer.js +247 -0
- package/build/Components/FileViewer.js.map +1 -0
- package/build/Components/Icon.d.ts +35 -0
- package/build/Components/Icon.js +140 -0
- package/build/Components/Icon.js.map +1 -0
- package/build/Components/IconPicker.d.ts +25 -0
- package/build/Components/IconPicker.js +72 -0
- package/build/Components/IconPicker.js.map +1 -0
- package/build/Components/IconSelector.d.ts +33 -0
- package/build/Components/IconSelector.js +2086 -0
- package/build/Components/IconSelector.js.map +1 -0
- package/build/Components/Image.d.ts +31 -0
- package/build/Components/Image.js +126 -0
- package/build/Components/Image.js.map +1 -0
- package/build/Components/InfoBox.d.ts +37 -0
- package/build/Components/InfoBox.js +115 -0
- package/build/Components/InfoBox.js.map +1 -0
- package/build/Components/IobUri.d.ts +14 -0
- package/build/Components/IobUri.js +168 -0
- package/build/Components/IobUri.js.map +1 -0
- package/build/Components/Loader.d.ts +31 -0
- package/build/Components/Loader.js +265 -0
- package/build/Components/Loader.js.map +1 -0
- package/build/Components/Loaders/MV.d.ts +17 -0
- package/build/Components/Loaders/MV.js +61 -0
- package/build/Components/Loaders/MV.js.map +1 -0
- package/build/Components/Loaders/PT.d.ts +27 -0
- package/build/Components/Loaders/PT.js +150 -0
- package/build/Components/Loaders/PT.js.map +1 -0
- package/build/Components/Loaders/Vendor.d.ts +22 -0
- package/build/Components/Loaders/Vendor.js +52 -0
- package/build/Components/Loaders/Vendor.js.map +1 -0
- package/build/Components/Logo.d.ts +18 -0
- package/build/Components/Logo.js +109 -0
- package/build/Components/Logo.js.map +1 -0
- package/build/Components/MDUtils.d.ts +11 -0
- package/build/Components/MDUtils.js +99 -0
- package/build/Components/MDUtils.js.map +1 -0
- package/build/Components/ObjectBrowser.d.ts +665 -0
- package/build/Components/ObjectBrowser.js +6245 -0
- package/build/Components/ObjectBrowser.js.map +1 -0
- package/build/Components/Router.d.ts +21 -0
- package/build/Components/Router.js +77 -0
- package/build/Components/Router.js.map +1 -0
- package/build/Components/SaveCloseButtons.d.ts +20 -0
- package/build/Components/SaveCloseButtons.js +65 -0
- package/build/Components/SaveCloseButtons.js.map +1 -0
- package/build/Components/Schedule.d.ts +62 -0
- package/build/Components/Schedule.js +1266 -0
- package/build/Components/Schedule.js.map +1 -0
- package/build/Components/SelectWithIcon.d.ts +37 -0
- package/build/Components/SelectWithIcon.js +139 -0
- package/build/Components/SelectWithIcon.js.map +1 -0
- package/build/Components/SimpleCron/cronText.d.ts +10 -0
- package/build/Components/SimpleCron/cronText.js +14 -0
- package/build/Components/SimpleCron/cronText.js.map +1 -0
- package/build/Components/SimpleCron/index.d.ts +55 -0
- package/build/Components/SimpleCron/index.js +698 -0
- package/build/Components/SimpleCron/index.js.map +1 -0
- package/build/Components/TabContainer.d.ts +15 -0
- package/build/Components/TabContainer.js +23 -0
- package/build/Components/TabContainer.js.map +1 -0
- package/build/Components/TabContent.d.ts +11 -0
- package/build/Components/TabContent.js +20 -0
- package/build/Components/TabContent.js.map +1 -0
- package/build/Components/TabHeader.d.ts +6 -0
- package/build/Components/TabHeader.js +6 -0
- package/build/Components/TabHeader.js.map +1 -0
- package/build/Components/TableResize.d.ts +45 -0
- package/build/Components/TableResize.js +204 -0
- package/build/Components/TableResize.js.map +1 -0
- package/build/Components/TextWithIcon.d.ts +21 -0
- package/build/Components/TextWithIcon.js +113 -0
- package/build/Components/TextWithIcon.js.map +1 -0
- package/build/Components/ToggleThemeMenu.d.ts +12 -0
- package/build/Components/ToggleThemeMenu.js +13 -0
- package/build/Components/ToggleThemeMenu.js.map +1 -0
- package/build/Components/TreeTable.d.ts +79 -0
- package/build/Components/TreeTable.js +538 -0
- package/build/Components/TreeTable.js.map +1 -0
- package/build/Components/UploadImage.d.ts +23 -0
- package/build/Components/UploadImage.js +516 -0
- package/build/Components/UploadImage.js.map +1 -0
- package/build/Components/Utils.d.ts +331 -0
- package/build/Components/Utils.js +1605 -0
- package/build/Components/Utils.js.map +1 -0
- package/build/Components/withWidth.d.ts +2 -0
- package/build/Components/withWidth.js +22 -0
- package/build/Components/withWidth.js.map +1 -0
- package/build/Connection.d.ts +1 -0
- package/build/Connection.js +2 -0
- package/build/Connection.js.map +1 -0
- package/build/Dialogs/ComplexCron.d.ts +24 -0
- package/build/Dialogs/ComplexCron.js +85 -0
- package/build/Dialogs/ComplexCron.js.map +1 -0
- package/build/Dialogs/Confirm.d.ts +39 -0
- package/build/Dialogs/Confirm.js +83 -0
- package/build/Dialogs/Confirm.js.map +1 -0
- package/build/Dialogs/Cron.d.ts +29 -0
- package/build/Dialogs/Cron.js +72 -0
- package/build/Dialogs/Cron.js.map +1 -0
- package/build/Dialogs/Error.d.ts +18 -0
- package/build/Dialogs/Error.js +27 -0
- package/build/Dialogs/Error.js.map +1 -0
- package/build/Dialogs/Message.d.ts +20 -0
- package/build/Dialogs/Message.js +29 -0
- package/build/Dialogs/Message.js.map +1 -0
- package/build/Dialogs/SelectFile.d.ts +85 -0
- package/build/Dialogs/SelectFile.js +115 -0
- package/build/Dialogs/SelectFile.js.map +1 -0
- package/build/Dialogs/SelectID.d.ts +102 -0
- package/build/Dialogs/SelectID.js +151 -0
- package/build/Dialogs/SelectID.js.map +1 -0
- package/build/Dialogs/SimpleCron.d.ts +19 -0
- package/build/Dialogs/SimpleCron.js +46 -0
- package/build/Dialogs/SimpleCron.js.map +1 -0
- package/build/Dialogs/TextInput.d.ts +2 -0
- package/build/Dialogs/TextInput.js +31 -0
- package/build/Dialogs/TextInput.js.map +1 -0
- package/build/GenericApp.d.ts +209 -0
- package/build/GenericApp.js +842 -0
- package/build/GenericApp.js.map +1 -0
- package/build/LegacyConnection.d.ts +938 -0
- package/build/LegacyConnection.js +2849 -0
- package/build/LegacyConnection.js.map +1 -0
- package/build/Prompt.d.ts +5 -0
- package/build/Prompt.js +19 -0
- package/build/Prompt.js.map +1 -0
- package/build/Theme.d.ts +5 -0
- package/build/Theme.js +344 -0
- package/build/Theme.js.map +1 -0
- package/build/assets/devices/parseNames.d.ts +0 -0
- package/build/assets/devices/parseNames.js +35 -0
- package/build/assets/devices/parseNames.js.map +1 -0
- package/build/assets/devices.json +1 -0
- package/build/assets/lamp_ceiling.svg +9 -0
- package/build/assets/lamp_table.svg +8 -0
- package/build/assets/no_icon.svg +9 -0
- package/build/assets/rooms/parseNames.d.ts +0 -0
- package/build/assets/rooms/parseNames.js +35 -0
- package/build/assets/rooms/parseNames.js.map +1 -0
- package/build/assets/rooms.json +1 -0
- package/build/dictionary.d.ts +1 -0
- package/build/dictionary.js +25 -0
- package/build/dictionary.js.map +1 -0
- package/build/globals.d.ts +19 -0
- package/build/i18n/de.json +480 -0
- package/build/i18n/en.json +480 -0
- package/build/i18n/es.json +480 -0
- package/build/i18n/fr.json +480 -0
- package/build/i18n/it.json +475 -0
- package/build/i18n/nl.json +475 -0
- package/build/i18n/pl.json +475 -0
- package/build/i18n/pt.json +475 -0
- package/build/i18n/ru.json +475 -0
- package/build/i18n/uk.json +475 -0
- package/build/i18n/zh-cn.json +475 -0
- package/build/i18n.d.ts +84 -0
- package/build/i18n.js +224 -0
- package/build/i18n.js.map +1 -0
- package/build/icons/IconAdapter.d.ts +3 -0
- package/build/icons/IconAdapter.js +7 -0
- package/build/icons/IconAdapter.js.map +1 -0
- package/build/icons/IconAlias.d.ts +3 -0
- package/build/icons/IconAlias.js +7 -0
- package/build/icons/IconAlias.js.map +1 -0
- package/build/icons/IconButtonImage.d.ts +3 -0
- package/build/icons/IconButtonImage.js +9 -0
- package/build/icons/IconButtonImage.js.map +1 -0
- package/build/icons/IconChannel.d.ts +3 -0
- package/build/icons/IconChannel.js +10 -0
- package/build/icons/IconChannel.js.map +1 -0
- package/build/icons/IconClearFilter.d.ts +3 -0
- package/build/icons/IconClearFilter.js +8 -0
- package/build/icons/IconClearFilter.js.map +1 -0
- package/build/icons/IconClosed.d.ts +3 -0
- package/build/icons/IconClosed.js +7 -0
- package/build/icons/IconClosed.js.map +1 -0
- package/build/icons/IconCopy.d.ts +3 -0
- package/build/icons/IconCopy.js +6 -0
- package/build/icons/IconCopy.js.map +1 -0
- package/build/icons/IconDevice.d.ts +3 -0
- package/build/icons/IconDevice.js +16 -0
- package/build/icons/IconDevice.js.map +1 -0
- package/build/icons/IconDocument.d.ts +3 -0
- package/build/icons/IconDocument.js +7 -0
- package/build/icons/IconDocument.js.map +1 -0
- package/build/icons/IconDocumentReadOnly.d.ts +3 -0
- package/build/icons/IconDocumentReadOnly.js +8 -0
- package/build/icons/IconDocumentReadOnly.js.map +1 -0
- package/build/icons/IconExpert.d.ts +3 -0
- package/build/icons/IconExpert.js +7 -0
- package/build/icons/IconExpert.js.map +1 -0
- package/build/icons/IconFx.d.ts +3 -0
- package/build/icons/IconFx.js +6 -0
- package/build/icons/IconFx.js.map +1 -0
- package/build/icons/IconInstance.d.ts +3 -0
- package/build/icons/IconInstance.js +7 -0
- package/build/icons/IconInstance.js.map +1 -0
- package/build/icons/IconLogout.d.ts +3 -0
- package/build/icons/IconLogout.js +7 -0
- package/build/icons/IconLogout.js.map +1 -0
- package/build/icons/IconNoIcon.d.ts +3 -0
- package/build/icons/IconNoIcon.js +6 -0
- package/build/icons/IconNoIcon.js.map +1 -0
- package/build/icons/IconOpen.d.ts +3 -0
- package/build/icons/IconOpen.js +7 -0
- package/build/icons/IconOpen.js.map +1 -0
- package/build/icons/IconState.d.ts +3 -0
- package/build/icons/IconState.js +7 -0
- package/build/icons/IconState.js.map +1 -0
- package/build/icons/IconVacuum.d.ts +3 -0
- package/build/icons/IconVacuum.js +12 -0
- package/build/icons/IconVacuum.js.map +1 -0
- package/build/index.css +56 -0
- package/build/index.d.ts +87 -0
- package/build/index.js +85 -0
- package/build/index.js.map +1 -0
- package/build/modulefederation.admin.config.d.ts +13 -0
- package/build/modulefederation.admin.config.js +45 -0
- package/build/modulefederation.admin.config.js.map +1 -0
- package/build/types.d.ts +236 -0
- package/i18n/de.json +480 -0
- package/i18n/en.json +480 -0
- package/i18n/es.json +480 -0
- package/i18n/fr.json +480 -0
- package/i18n/it.json +475 -0
- package/i18n/nl.json +475 -0
- package/i18n/pl.json +475 -0
- package/i18n/pt.json +475 -0
- package/i18n/ru.json +475 -0
- package/i18n/uk.json +475 -0
- package/i18n/zh-cn.json +475 -0
- package/index.css +56 -0
- package/modulefederation.admin.config.d.ts +20 -0
- package/modulefederation.admin.config.js +54 -0
- package/package.json +86 -0
- package/tasksExample.js +91 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { HexColorPicker as ColorPicker } from 'react-colorful';
|
|
3
|
+
import { Fab, Table, TableBody, TableCell, TableHead, TableRow, TableSortLabel, IconButton, Select, MenuItem, TextField, Checkbox, Dialog, } from '@mui/material';
|
|
4
|
+
import { Edit as IconEdit, Delete as IconDelete, NavigateNext as IconExpand, ExpandMore as IconCollapse, Check as IconCheck, Close as IconClose, Add as IconAdd, ViewHeadline as IconList, Colorize as IconColor, } from '@mui/icons-material';
|
|
5
|
+
import { DialogSelectID } from '../Dialogs/SelectID';
|
|
6
|
+
import { Utils } from './Utils';
|
|
7
|
+
function getAttr(obj, attr, lookup) {
|
|
8
|
+
if (typeof attr === 'string') {
|
|
9
|
+
attr = attr.split('.');
|
|
10
|
+
}
|
|
11
|
+
if (!obj) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (attr.length === 1) {
|
|
15
|
+
if (lookup && lookup[obj[attr[0]]]) {
|
|
16
|
+
return lookup[obj[attr[0]]];
|
|
17
|
+
}
|
|
18
|
+
return obj[attr[0]];
|
|
19
|
+
}
|
|
20
|
+
const name = attr.shift();
|
|
21
|
+
return getAttr(obj[name], attr);
|
|
22
|
+
}
|
|
23
|
+
function setAttr(obj, attr, value) {
|
|
24
|
+
if (typeof attr === 'string') {
|
|
25
|
+
attr = attr.split('.');
|
|
26
|
+
}
|
|
27
|
+
if (attr.length === 1) {
|
|
28
|
+
return (obj[attr[0]] = value);
|
|
29
|
+
}
|
|
30
|
+
const name = attr.shift();
|
|
31
|
+
if (obj[name] === null || obj[name] === undefined) {
|
|
32
|
+
obj[name] = {};
|
|
33
|
+
}
|
|
34
|
+
return setAttr(obj[name], attr, value);
|
|
35
|
+
}
|
|
36
|
+
const styles = {
|
|
37
|
+
tableContainer: {
|
|
38
|
+
width: '100%',
|
|
39
|
+
height: '100%',
|
|
40
|
+
overflow: 'auto',
|
|
41
|
+
},
|
|
42
|
+
table: {
|
|
43
|
+
width: '100%',
|
|
44
|
+
minWidth: 800,
|
|
45
|
+
maxWidth: 1920,
|
|
46
|
+
},
|
|
47
|
+
cell: {
|
|
48
|
+
paddingTop: 0,
|
|
49
|
+
paddingBottom: 0,
|
|
50
|
+
paddingLeft: 4,
|
|
51
|
+
paddingRight: 4,
|
|
52
|
+
},
|
|
53
|
+
rowMainWithChildren: {},
|
|
54
|
+
rowMainWithoutChildren: {},
|
|
55
|
+
rowNoEdit: {
|
|
56
|
+
opacity: 0.3,
|
|
57
|
+
},
|
|
58
|
+
cellExpand: {
|
|
59
|
+
width: 30,
|
|
60
|
+
},
|
|
61
|
+
cellButton: {
|
|
62
|
+
width: 30,
|
|
63
|
+
},
|
|
64
|
+
cellHeader: {
|
|
65
|
+
fontWeight: 'bold',
|
|
66
|
+
background: (theme) => (theme.palette.mode === 'dark' ? '#888' : '#888'),
|
|
67
|
+
color: (theme) => (theme.palette.mode === 'dark' ? '#EEE' : '#111'),
|
|
68
|
+
height: 48,
|
|
69
|
+
wordBreak: 'break-word',
|
|
70
|
+
whiteSpace: 'pre',
|
|
71
|
+
},
|
|
72
|
+
width_name_nicknames: {
|
|
73
|
+
maxWidth: 150,
|
|
74
|
+
},
|
|
75
|
+
width_ioType: {
|
|
76
|
+
maxWidth: 100,
|
|
77
|
+
},
|
|
78
|
+
width_type: {
|
|
79
|
+
maxWidth: 100,
|
|
80
|
+
},
|
|
81
|
+
width_displayTraits: {
|
|
82
|
+
maxWidth: 100,
|
|
83
|
+
},
|
|
84
|
+
width_roomHint: {
|
|
85
|
+
maxWidth: 100,
|
|
86
|
+
},
|
|
87
|
+
rowSecondary: {
|
|
88
|
+
fontStyle: 'italic',
|
|
89
|
+
},
|
|
90
|
+
cellSecondary: {
|
|
91
|
+
fontSize: 10,
|
|
92
|
+
},
|
|
93
|
+
visuallyHidden: {
|
|
94
|
+
border: 0,
|
|
95
|
+
clip: 'rect(0 0 0 0)',
|
|
96
|
+
height: 1,
|
|
97
|
+
margin: -1,
|
|
98
|
+
overflow: 'hidden',
|
|
99
|
+
padding: 0,
|
|
100
|
+
position: 'absolute',
|
|
101
|
+
top: 20,
|
|
102
|
+
width: 1,
|
|
103
|
+
},
|
|
104
|
+
fieldEditWithButton: {
|
|
105
|
+
width: 'calc(100% - 33px)',
|
|
106
|
+
display: 'inline-block',
|
|
107
|
+
},
|
|
108
|
+
fieldEdit: {
|
|
109
|
+
width: '100%',
|
|
110
|
+
display: 'inline-block',
|
|
111
|
+
lineHeight: '50px',
|
|
112
|
+
verticalAlign: 'middle',
|
|
113
|
+
},
|
|
114
|
+
fieldButton: {
|
|
115
|
+
width: 30,
|
|
116
|
+
display: 'inline-block',
|
|
117
|
+
},
|
|
118
|
+
colorDialog: {
|
|
119
|
+
overflow: 'hidden',
|
|
120
|
+
padding: 15,
|
|
121
|
+
},
|
|
122
|
+
subText: {
|
|
123
|
+
fontSize: 10,
|
|
124
|
+
fontStyle: 'italic',
|
|
125
|
+
},
|
|
126
|
+
glow: {
|
|
127
|
+
animation: 'glow 0.2s 2 alternate',
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
function descendingComparator(a, b, orderBy, lookup) {
|
|
131
|
+
const _a = getAttr(a, orderBy, lookup) || '';
|
|
132
|
+
const _b = getAttr(b, orderBy, lookup) || '';
|
|
133
|
+
if (_b < _a) {
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
|
136
|
+
if (_b > _a) {
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
function getComparator(order, orderBy, lookup) {
|
|
142
|
+
return order === 'desc'
|
|
143
|
+
? (a, b) => descendingComparator(a, b, orderBy, lookup)
|
|
144
|
+
: (a, b) => -descendingComparator(a, b, orderBy, lookup);
|
|
145
|
+
}
|
|
146
|
+
function stableSort(array, comparator) {
|
|
147
|
+
const stabilizedThis = array.map((el, index) => ({ e: el, i: index }));
|
|
148
|
+
stabilizedThis.sort((a, b) => {
|
|
149
|
+
const order = comparator(a.e, b.e);
|
|
150
|
+
if (order) {
|
|
151
|
+
return order;
|
|
152
|
+
}
|
|
153
|
+
return a.i - b.i;
|
|
154
|
+
});
|
|
155
|
+
return stabilizedThis.map(item => item.e);
|
|
156
|
+
}
|
|
157
|
+
export class TreeTable extends Component {
|
|
158
|
+
selectCallback = null;
|
|
159
|
+
updateTimeout = null;
|
|
160
|
+
constructor(props) {
|
|
161
|
+
super(props);
|
|
162
|
+
let opened = (window._localStorage || window.localStorage).getItem(this.props.name || 'iob-table') || '[]';
|
|
163
|
+
try {
|
|
164
|
+
opened = JSON.parse(opened) || [];
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
opened = [];
|
|
168
|
+
}
|
|
169
|
+
if (!Array.isArray(opened)) {
|
|
170
|
+
opened = [];
|
|
171
|
+
}
|
|
172
|
+
this.state = {
|
|
173
|
+
opened,
|
|
174
|
+
editMode: false,
|
|
175
|
+
deleteMode: false,
|
|
176
|
+
editData: null,
|
|
177
|
+
order: 'asc',
|
|
178
|
+
update: null,
|
|
179
|
+
orderBy: this.props.columns[0].field,
|
|
180
|
+
showSelectColor: false,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
static getDerivedStateFromProps(props, state) {
|
|
184
|
+
if (props.glowOnChange) {
|
|
185
|
+
const update = [];
|
|
186
|
+
let count = 0;
|
|
187
|
+
if (props.data && state.data) {
|
|
188
|
+
props.data.forEach(line => {
|
|
189
|
+
count++;
|
|
190
|
+
const oldLine = state.data?.find(it => it.id === line.id);
|
|
191
|
+
if (oldLine) {
|
|
192
|
+
if (JSON.stringify(oldLine) !== JSON.stringify(line)) {
|
|
193
|
+
update.push(line.id);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
update.push(line.id);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (update.length && update.length !== count) {
|
|
202
|
+
return { data: props.data, update };
|
|
203
|
+
}
|
|
204
|
+
return { data: props.data };
|
|
205
|
+
}
|
|
206
|
+
return { data: props.data };
|
|
207
|
+
}
|
|
208
|
+
renderCellEdit(item, col) {
|
|
209
|
+
let val = getAttr(item, col.field);
|
|
210
|
+
if (Array.isArray(val)) {
|
|
211
|
+
val = val[0];
|
|
212
|
+
}
|
|
213
|
+
if (col.lookup) {
|
|
214
|
+
return this.renderCellEditSelect(col, val);
|
|
215
|
+
}
|
|
216
|
+
if (col.editComponent) {
|
|
217
|
+
return this.renderCellEditCustom(col, val, item);
|
|
218
|
+
}
|
|
219
|
+
if (col.type === 'boolean' || (!col.type && typeof val === 'boolean')) {
|
|
220
|
+
return this.renderCellEditBoolean(col, val);
|
|
221
|
+
}
|
|
222
|
+
if (col.type === 'color') {
|
|
223
|
+
return this.renderCellEditColor(col, val);
|
|
224
|
+
}
|
|
225
|
+
if (col.type === 'oid') {
|
|
226
|
+
return this.renderCellEditObjectID(col, val);
|
|
227
|
+
}
|
|
228
|
+
if (col.type === 'numeric') {
|
|
229
|
+
return this.renderCellEditNumber(col, val);
|
|
230
|
+
}
|
|
231
|
+
return this.renderCellEditString(col, val);
|
|
232
|
+
}
|
|
233
|
+
onChange(col, oldValue, newValue) {
|
|
234
|
+
const editData = this.state.editData ? { ...this.state.editData } : {};
|
|
235
|
+
if (newValue === oldValue) {
|
|
236
|
+
delete editData[col.field];
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
editData[col.field] = newValue;
|
|
240
|
+
}
|
|
241
|
+
this.setState({ editData });
|
|
242
|
+
}
|
|
243
|
+
renderCellEditSelect(col, val) {
|
|
244
|
+
return (React.createElement(Select, { variant: "standard", onChange: e => this.onChange(col, val, e.target.value), value: (this.state.editData && this.state.editData[col.field]) || val }, col.lookup &&
|
|
245
|
+
Object.keys(col.lookup).map((v, i) => (React.createElement(MenuItem, { key: i, value: v }, col.lookup?.[v])))));
|
|
246
|
+
}
|
|
247
|
+
renderCellEditString(col, val) {
|
|
248
|
+
return (React.createElement(TextField, { variant: "standard", style: styles.fieldEdit, fullWidth: true, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
249
|
+
? this.state.editData[col.field]
|
|
250
|
+
: val, onChange: e => this.onChange(col, val, e.target.value) }));
|
|
251
|
+
}
|
|
252
|
+
renderCellEditNumber(col, val) {
|
|
253
|
+
return (React.createElement(TextField, { variant: "standard", style: styles.fieldEdit, type: "number", fullWidth: true, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
254
|
+
? this.state.editData[col.field]
|
|
255
|
+
: val, onChange: e => this.onChange(col, val, e.target.value) }));
|
|
256
|
+
}
|
|
257
|
+
renderCellEditCustom(col, val, item) {
|
|
258
|
+
const EditComponent = col.editComponent;
|
|
259
|
+
// use new value if exists
|
|
260
|
+
if (this.state.editData && this.state.editData[col.field] !== undefined) {
|
|
261
|
+
val = this.state.editData[col.field];
|
|
262
|
+
item = JSON.parse(JSON.stringify(item));
|
|
263
|
+
item[col.field] = val;
|
|
264
|
+
}
|
|
265
|
+
return EditComponent ? (React.createElement(EditComponent, { value: val, rowData: item, onChange: (newVal) => this.onChange(col, val, newVal) })) : null;
|
|
266
|
+
}
|
|
267
|
+
renderCellEditBoolean(col, val) {
|
|
268
|
+
return (React.createElement(Checkbox, { checked: this.state.editData && this.state.editData[col.field] !== undefined
|
|
269
|
+
? !!this.state.editData[col.field]
|
|
270
|
+
: !!val, onChange: e => this.onChange(col, !!val, e.target.checked), inputProps: { 'aria-label': 'checkbox' } }));
|
|
271
|
+
}
|
|
272
|
+
renderSelectColorDialog() {
|
|
273
|
+
return (React.createElement(Dialog, { sx: {
|
|
274
|
+
'& .MuiPaper-root': styles.root,
|
|
275
|
+
'& .MuiPaper-paper': styles.paper,
|
|
276
|
+
}, onClose: () => {
|
|
277
|
+
this.selectCallback = null;
|
|
278
|
+
this.setState({ showSelectColor: false });
|
|
279
|
+
}, open: this.state.showSelectColor },
|
|
280
|
+
React.createElement(ColorPicker, { color: this.state.selectIdValue, onChange: color => this.setState({ selectIdValue: color }, () => {
|
|
281
|
+
if (this.selectCallback) {
|
|
282
|
+
this.selectCallback(color);
|
|
283
|
+
}
|
|
284
|
+
}) })));
|
|
285
|
+
}
|
|
286
|
+
renderCellEditColor(col, val) {
|
|
287
|
+
const _val = this.state.editData && this.state.editData[col.field] !== undefined ? this.state.editData[col.field] : val;
|
|
288
|
+
return (React.createElement("div", { style: styles.fieldEdit },
|
|
289
|
+
React.createElement(TextField, { variant: "standard", fullWidth: true, style: styles.fieldEditWithButton, value: _val, inputProps: { style: { backgroundColor: _val, color: Utils.isUseBright(_val) ? '#FFF' : '#000' } }, onChange: e => this.onChange(col, !!val, e.target.value) }),
|
|
290
|
+
React.createElement(IconButton, { style: styles.fieldButton, onClick: () => {
|
|
291
|
+
this.selectCallback = newColor => this.onChange(col, val, newColor);
|
|
292
|
+
this.setState({ showSelectColor: true, selectIdValue: val });
|
|
293
|
+
}, size: "large" },
|
|
294
|
+
React.createElement(IconColor, null))));
|
|
295
|
+
}
|
|
296
|
+
renderSelectIdDialog() {
|
|
297
|
+
if (this.state.showSelectId && this.props.socket) {
|
|
298
|
+
return (React.createElement(DialogSelectID, { key: "tableSelect", imagePrefix: "../..", dialogName: this.props.adapterName, themeType: this.props.themeType, theme: this.props.theme, socket: this.props.socket, selected: this.state.selectIdValue, onClose: () => this.setState({ showSelectId: false }), onOk: (selected) => {
|
|
299
|
+
this.setState({ showSelectId: false, selectIdValue: null });
|
|
300
|
+
const selectedStr = Array.isArray(selected) ? selected[0] : selected;
|
|
301
|
+
if (selectedStr && this.selectCallback) {
|
|
302
|
+
this.selectCallback && this.selectCallback(selectedStr);
|
|
303
|
+
this.selectCallback = null;
|
|
304
|
+
}
|
|
305
|
+
} }));
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
renderCellEditObjectID(col, val) {
|
|
310
|
+
return (React.createElement("div", { style: styles.fieldEdit },
|
|
311
|
+
React.createElement(TextField, { variant: "standard", fullWidth: true, style: styles.fieldEditWithButton, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
312
|
+
? this.state.editData[col.field]
|
|
313
|
+
: val, onChange: e => this.onChange(col, val, e.target.value) }),
|
|
314
|
+
React.createElement(IconButton, { style: styles.fieldButton, onClick: () => {
|
|
315
|
+
this.selectCallback = selected => this.onChange(col, val, selected);
|
|
316
|
+
this.setState({ showSelectId: true, selectIdValue: val });
|
|
317
|
+
}, size: "large" },
|
|
318
|
+
React.createElement(IconList, null))));
|
|
319
|
+
}
|
|
320
|
+
static renderCellNonEdit(item, col) {
|
|
321
|
+
let val = getAttr(item, col.field, col.lookup);
|
|
322
|
+
if (Array.isArray(val)) {
|
|
323
|
+
val = val[0];
|
|
324
|
+
}
|
|
325
|
+
if (col.type === 'boolean') {
|
|
326
|
+
return (React.createElement(Checkbox, { checked: !!val, disabled: true, inputProps: { 'aria-label': 'checkbox' } }));
|
|
327
|
+
}
|
|
328
|
+
return val;
|
|
329
|
+
}
|
|
330
|
+
renderCell(item, col, level, i) {
|
|
331
|
+
if (this.state.editMode === i && col.editable !== 'never' && col.editable !== false) {
|
|
332
|
+
return (React.createElement(TableCell, { key: col.field, style: { ...styles.cell, ...(level ? styles.cellSecondary : undefined), ...col.cellStyle }, component: "th" }, this.renderCellEdit(item, col)));
|
|
333
|
+
}
|
|
334
|
+
return (React.createElement(TableCell, { key: col.field, style: { ...styles.cell, ...(level ? styles.cellSecondary : undefined), ...col.cellStyle }, component: "th" }, TreeTable.renderCellNonEdit(item, col)));
|
|
335
|
+
}
|
|
336
|
+
static renderCellWithSubField(item, col) {
|
|
337
|
+
const main = getAttr(item, col.field, col.lookup);
|
|
338
|
+
if (col.subField) {
|
|
339
|
+
const sub = getAttr(item, col.subField, col.subLookup);
|
|
340
|
+
return (React.createElement("div", null,
|
|
341
|
+
React.createElement("div", { style: styles.mainText }, main),
|
|
342
|
+
React.createElement("div", { style: { ...styles.subText, ...(col.subStyle || undefined) } }, sub)));
|
|
343
|
+
}
|
|
344
|
+
return (React.createElement("div", null,
|
|
345
|
+
React.createElement("div", { style: styles.mainText }, main)));
|
|
346
|
+
}
|
|
347
|
+
renderLine(item, level) {
|
|
348
|
+
const levelShift = this.props.levelShift === undefined ? 24 : this.props.levelShift;
|
|
349
|
+
level = level || 0;
|
|
350
|
+
const i = this.props.data.indexOf(item);
|
|
351
|
+
if (!item) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
if (!level && item.parentId) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
if (level && !item.parentId) {
|
|
358
|
+
return null; // should never happen
|
|
359
|
+
}
|
|
360
|
+
// try to find children
|
|
361
|
+
const opened = this.state.opened.includes(item.id);
|
|
362
|
+
const children = this.props.data.filter(it => it.parentId === item.id);
|
|
363
|
+
const row = (React.createElement(TableRow, { key: item.id, className: `table-row-${(item.id || '').toString().replace(/[.$]/g, '_')}`, style: {
|
|
364
|
+
...((this.state.update && this.state.update.includes(item.id) && styles.glow) || undefined),
|
|
365
|
+
...styles.row,
|
|
366
|
+
...(level ? styles.rowSecondary : undefined),
|
|
367
|
+
...(!level && children.length ? styles.rowMainWithChildren : undefined),
|
|
368
|
+
...(!level && !children.length ? styles.rowMainWithoutChildren : undefined),
|
|
369
|
+
...(this.state.editMode !== false && this.state.editMode !== i ? styles.rowNoEdit : undefined),
|
|
370
|
+
...(this.state.deleteMode !== false && this.state.deleteMode !== i ? styles.rowNoEdit : undefined),
|
|
371
|
+
} },
|
|
372
|
+
React.createElement(TableCell, { style: { ...styles.cell, ...styles.cellExpand, ...(level ? styles.cellSecondary : undefined) } }, children.length ? (React.createElement(IconButton, { onClick: () => {
|
|
373
|
+
const _opened = [...this.state.opened];
|
|
374
|
+
const pos = _opened.indexOf(item.id);
|
|
375
|
+
if (pos === -1) {
|
|
376
|
+
_opened.push(item.id);
|
|
377
|
+
_opened.sort();
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
_opened.splice(pos, 1);
|
|
381
|
+
}
|
|
382
|
+
(window._localStorage || window.localStorage).setItem(this.props.name || 'iob-table', JSON.stringify(_opened));
|
|
383
|
+
this.setState({ opened: _opened });
|
|
384
|
+
}, size: "small" }, opened ? React.createElement(IconCollapse, null) : React.createElement(IconExpand, null))) : null),
|
|
385
|
+
React.createElement(TableCell, { scope: "row", style: {
|
|
386
|
+
...styles.cell,
|
|
387
|
+
...(level ? styles.cellSecondary : undefined),
|
|
388
|
+
...this.props.columns[0].cellStyle,
|
|
389
|
+
paddingLeft: levelShift * level,
|
|
390
|
+
} }, this.props.columns[0].subField
|
|
391
|
+
? TreeTable.renderCellWithSubField(item, this.props.columns[0])
|
|
392
|
+
: getAttr(item, this.props.columns[0].field, this.props.columns[0].lookup)),
|
|
393
|
+
this.props.columns.map((col, ii) => !ii && !col.hidden ? null : this.renderCell(item, col, level, i)),
|
|
394
|
+
this.props.onUpdate ? (React.createElement(TableCell, { style: { ...styles.cell, ...styles.cellButton } }, this.state.editMode === i || this.state.deleteMode === i ? (React.createElement(IconButton, { disabled: this.state.editMode !== false &&
|
|
395
|
+
(!this.state.editData || !Object.keys(this.state.editData).length), onClick: () => {
|
|
396
|
+
if (this.state.editMode !== false) {
|
|
397
|
+
const newData = JSON.parse(JSON.stringify(item));
|
|
398
|
+
this.state.editData &&
|
|
399
|
+
Object.keys(this.state.editData).forEach(attr => setAttr(newData, attr, this.state.editData?.[attr]));
|
|
400
|
+
this.setState({ editMode: false }, () => this.props.onUpdate && this.props.onUpdate(newData, item));
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
this.setState({ deleteMode: false }, () => this.props.onDelete && this.props.onDelete(item));
|
|
404
|
+
}
|
|
405
|
+
}, size: "large" },
|
|
406
|
+
React.createElement(IconCheck, null))) : (React.createElement(IconButton, { disabled: this.state.editMode !== false, onClick: () => this.setState({ editMode: i, editData: null }), size: "large" },
|
|
407
|
+
React.createElement(IconEdit, null))))) : null,
|
|
408
|
+
this.props.onDelete && !this.props.onUpdate ? (React.createElement(TableCell, { style: { ...styles.cell, ...styles.cellButton } }, this.state.deleteMode === i ? (React.createElement(IconButton, { disabled: this.state.editMode !== false &&
|
|
409
|
+
(!this.state.editData || !Object.keys(this.state.editData).length), onClick: () => this.setState({ deleteMode: false }, () => this.props.onDelete && this.props.onDelete(item)), size: "large" },
|
|
410
|
+
React.createElement(IconCheck, null))) : null)) : null,
|
|
411
|
+
this.props.onUpdate || this.props.onDelete ? (React.createElement(TableCell, { style: { ...styles.cell, ...styles.cellButton } }, this.state.editMode === i || this.state.deleteMode === i ? (React.createElement(IconButton, { onClick: () => this.setState({ editMode: false, deleteMode: false }), size: "large" },
|
|
412
|
+
React.createElement(IconClose, null))) : this.props.onDelete ? (React.createElement(IconButton, { disabled: this.state.deleteMode !== false, onClick: () => this.setState({ deleteMode: i }), size: "large" },
|
|
413
|
+
React.createElement(IconDelete, null))) : null)) : null));
|
|
414
|
+
if (!level && opened) {
|
|
415
|
+
const items = children.map(it => this.renderLine(it, level + 1));
|
|
416
|
+
items.unshift(row);
|
|
417
|
+
return items;
|
|
418
|
+
}
|
|
419
|
+
return row;
|
|
420
|
+
}
|
|
421
|
+
handleRequestSort(property) {
|
|
422
|
+
const isAsc = this.state.orderBy === property && this.state.order === 'asc';
|
|
423
|
+
this.setState({ order: isAsc ? 'desc' : 'asc', orderBy: property });
|
|
424
|
+
}
|
|
425
|
+
renderHead() {
|
|
426
|
+
return (React.createElement(TableHead, null,
|
|
427
|
+
React.createElement(TableRow, { key: "headerRow" },
|
|
428
|
+
React.createElement(TableCell, { component: "th", sx: Utils.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellExpand) }),
|
|
429
|
+
React.createElement(TableCell, { component: "th", sx: Utils.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles[`width_${this.props.columns[0].field.replace(/\./g, '_')}`]), style: this.props.columns[0].headerStyle || this.props.columns[0].cellStyle, sortDirection: this.props.noSort
|
|
430
|
+
? false
|
|
431
|
+
: this.state.orderBy === this.props.columns[0].field
|
|
432
|
+
? this.state.order
|
|
433
|
+
: false }, this.props.noSort ? null : (React.createElement(TableSortLabel, { active: this.state.orderBy === this.props.columns[0].field, direction: this.state.orderBy === this.props.columns[0].field ? this.state.order : 'asc', onClick: () => this.handleRequestSort(this.props.columns[0].field) },
|
|
434
|
+
this.props.columns[0].title || this.props.columns[0].field,
|
|
435
|
+
this.state.orderBy === this.props.columns[0].field ? (React.createElement("span", { style: styles.visuallyHidden }, this.state.order === 'desc' ? 'sorted descending' : 'sorted ascending')) : null))),
|
|
436
|
+
this.props.columns.map((col, i) => !i && !col.hidden ? null : (React.createElement(TableCell, { key: col.field, sx: Utils.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles[`width_${col.field.replace(/\./g, '_')}`]), style: col.headerStyle || col.cellStyle, component: "th" }, this.props.noSort ? null : (React.createElement(TableSortLabel, { active: this.state.orderBy === col.field, direction: this.state.orderBy === col.field ? this.state.order : 'asc', onClick: () => this.handleRequestSort(col.field) },
|
|
437
|
+
col.title || col.field,
|
|
438
|
+
this.state.orderBy === col.field ? (React.createElement("span", { style: styles.visuallyHidden }, this.state.order === 'desc' ? 'sorted descending' : 'sorted ascending')) : null))))),
|
|
439
|
+
this.props.onUpdate ? (React.createElement(TableCell, { component: "th", sx: Utils.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellButton) }, !this.props.noAdd ? (React.createElement(Fab, { color: "primary", size: "small", disabled: this.state.editMode !== false, onClick: () => this.props.onUpdate && this.props.onUpdate(true) },
|
|
440
|
+
React.createElement(IconAdd, null))) : null)) : null,
|
|
441
|
+
this.props.onDelete || this.props.onUpdate ? (React.createElement(TableCell, { component: "th", sx: Utils.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellButton) })) : null)));
|
|
442
|
+
}
|
|
443
|
+
render() {
|
|
444
|
+
const col = this.props.columns.find(_col => _col.field === this.state.orderBy);
|
|
445
|
+
if (col) {
|
|
446
|
+
const lookup = col.lookup;
|
|
447
|
+
const table = stableSort(this.props.data, getComparator(this.state.order, this.state.orderBy, lookup));
|
|
448
|
+
if (this.state.update && this.state.update.length) {
|
|
449
|
+
this.updateTimeout && clearTimeout(this.updateTimeout);
|
|
450
|
+
this.updateTimeout = setTimeout(() => {
|
|
451
|
+
this.updateTimeout = null;
|
|
452
|
+
this.setState({ update: null });
|
|
453
|
+
}, 500);
|
|
454
|
+
}
|
|
455
|
+
return (React.createElement("div", { style: styles.tableContainer, className: this.props.className },
|
|
456
|
+
React.createElement(Table, { style: styles.table, "aria-label": "simple table", size: "small", stickyHeader: true },
|
|
457
|
+
this.renderHead(),
|
|
458
|
+
React.createElement(TableBody, null, table.map(it => this.renderLine(it)))),
|
|
459
|
+
this.renderSelectIdDialog(),
|
|
460
|
+
this.renderSelectColorDialog()));
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/*
|
|
466
|
+
const columns = [
|
|
467
|
+
{
|
|
468
|
+
title: 'Name of field', // required, else it will be "field"
|
|
469
|
+
field: 'fieldIdInData', // required
|
|
470
|
+
editable: false, // or true [default - true]
|
|
471
|
+
cellStyle: { // CSS style - // optional
|
|
472
|
+
maxWidth: '12rem',
|
|
473
|
+
overflow: 'hidden',
|
|
474
|
+
wordBreak: 'break-word'
|
|
475
|
+
},
|
|
476
|
+
lookup: { // optional => edit will be automatically "SELECT"
|
|
477
|
+
'value1': 'text1',
|
|
478
|
+
'value2': 'text2',
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
title: 'Type', // required, else it will be "field"
|
|
483
|
+
field: 'myType', // required
|
|
484
|
+
editable: true, // or true [default - true]
|
|
485
|
+
lookup: { // optional => edit will be automatically "SELECT"
|
|
486
|
+
'number': 'Number',
|
|
487
|
+
'string': 'String',
|
|
488
|
+
'boolean': 'Boolean',
|
|
489
|
+
},
|
|
490
|
+
type: 'number/string/color/oid/icon/boolean', // oid=ObjectID,icon=base64-icon
|
|
491
|
+
editComponent: props =>
|
|
492
|
+
<div>Prefix{ <br/>
|
|
493
|
+
<textarea
|
|
494
|
+
rows={4}
|
|
495
|
+
style={{width: '100%', resize: 'vertical'}}
|
|
496
|
+
value={props.value}
|
|
497
|
+
onChange={e => props.onChange(e.target.value)}
|
|
498
|
+
/>
|
|
499
|
+
Suffix
|
|
500
|
+
</div>,
|
|
501
|
+
},
|
|
502
|
+
];
|
|
503
|
+
*/
|
|
504
|
+
/* const data = [
|
|
505
|
+
{
|
|
506
|
+
id: 'UniqueID1' // required
|
|
507
|
+
fieldIdInData: 'Name1',
|
|
508
|
+
myType: 'number',
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: 'UniqueID2' // required
|
|
512
|
+
fieldIdInData: 'Name12',
|
|
513
|
+
myType: 'string',
|
|
514
|
+
},
|
|
515
|
+
];
|
|
516
|
+
*/
|
|
517
|
+
/*
|
|
518
|
+
// STYLES
|
|
519
|
+
const styles = theme => ({
|
|
520
|
+
tableDiv: {
|
|
521
|
+
width: '100%',
|
|
522
|
+
overflow: 'hidden',
|
|
523
|
+
height: 'calc(100% - 48px)',
|
|
524
|
+
},
|
|
525
|
+
});
|
|
526
|
+
// renderTable
|
|
527
|
+
renderTable() {
|
|
528
|
+
return <div style={styles.tableDiv}>
|
|
529
|
+
<TreeTable
|
|
530
|
+
columns={this.columns}
|
|
531
|
+
data={lines}
|
|
532
|
+
onUpdate={(newData, oldData) => console.log('Update: ' + JSON.stringify(newData))}
|
|
533
|
+
onDelete={oldData => console.log('Delete: ' + JSON.stringify(oldData))}
|
|
534
|
+
/>
|
|
535
|
+
</div>;
|
|
536
|
+
}
|
|
537
|
+
*/
|
|
538
|
+
//# sourceMappingURL=TreeTable.js.map
|