@iobroker/adapter-react-v5 7.0.2 → 7.1.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/Components/404.d.ts +3 -2
- package/Components/404.js +3 -2
- package/Components/ColorPicker.d.ts +22 -8
- package/Components/ColorPicker.js +34 -17
- package/Components/ComplexCron.js +24 -24
- package/Components/CopyToClipboard.d.ts +10 -1
- package/Components/CopyToClipboard.js +17 -8
- package/Components/CustomModal.d.ts +1 -1
- package/Components/CustomModal.js +8 -8
- package/Components/FileBrowser.d.ts +11 -11
- package/Components/FileBrowser.js +135 -152
- package/Components/FileViewer.js +34 -23
- package/Components/Icon.d.ts +16 -2
- package/Components/Icon.js +19 -8
- package/Components/IconPicker.js +10 -14
- package/Components/IconSelector.d.ts +1 -1
- package/Components/IconSelector.js +64 -74
- package/Components/Image.d.ts +8 -4
- package/Components/Image.js +13 -32
- package/Components/Loader.d.ts +2 -2
- package/Components/Loader.js +21 -18
- package/Components/Loaders/MV.d.ts +6 -1
- package/Components/Loaders/MV.js +23 -7
- package/Components/Loaders/PT.d.ts +7 -2
- package/Components/Loaders/PT.js +20 -7
- package/Components/Loaders/Vendor.d.ts +2 -2
- package/Components/Loaders/Vendor.js +15 -7
- package/Components/Logo.js +16 -18
- package/Components/MDUtils.d.ts +1 -1
- package/Components/MDUtils.js +8 -4
- package/Components/ObjectBrowser.d.ts +40 -39
- package/Components/ObjectBrowser.js +550 -435
- package/Components/Router.d.ts +1 -3
- package/Components/Router.js +3 -1
- package/Components/SaveCloseButtons.d.ts +3 -3
- package/Components/SaveCloseButtons.js +3 -3
- package/Components/Schedule.d.ts +15 -15
- package/Components/Schedule.js +177 -154
- package/Components/SelectWithIcon.d.ts +2 -2
- package/Components/SelectWithIcon.js +45 -34
- package/Components/SimpleCron/index.js +83 -43
- package/Components/TabContainer.js +2 -2
- package/Components/TabContent.js +1 -1
- package/Components/TabHeader.js +1 -1
- package/Components/TableResize.d.ts +2 -2
- package/Components/TableResize.js +5 -5
- package/Components/TextWithIcon.d.ts +1 -1
- package/Components/TextWithIcon.js +10 -8
- package/Components/ToggleThemeMenu.d.ts +2 -2
- package/Components/ToggleThemeMenu.js +3 -3
- package/Components/TreeTable.d.ts +18 -18
- package/Components/TreeTable.js +76 -72
- package/Components/UploadImage.d.ts +2 -2
- package/Components/UploadImage.js +25 -21
- package/Components/Utils.d.ts +42 -22
- package/Components/Utils.js +66 -65
- package/Components/withWidth.d.ts +2 -2
- package/Components/withWidth.js +10 -6
- package/Dialogs/ComplexCron.d.ts +2 -2
- package/Dialogs/ComplexCron.js +3 -3
- package/Dialogs/Confirm.d.ts +4 -4
- package/Dialogs/Confirm.js +18 -8
- package/Dialogs/Cron.d.ts +3 -3
- package/Dialogs/Cron.js +21 -17
- package/Dialogs/Error.d.ts +3 -3
- package/Dialogs/Error.js +6 -4
- package/Dialogs/Message.d.ts +3 -3
- package/Dialogs/Message.js +6 -4
- package/Dialogs/SelectFile.d.ts +4 -4
- package/Dialogs/SelectFile.js +6 -4
- package/Dialogs/SelectID.d.ts +12 -10
- package/Dialogs/SelectID.js +12 -8
- package/Dialogs/SimpleCron.d.ts +2 -2
- package/Dialogs/SimpleCron.js +2 -2
- package/Dialogs/TextInput.d.ts +2 -2
- package/Dialogs/TextInput.js +3 -3
- package/GenericApp.d.ts +19 -13
- package/GenericApp.js +128 -85
- package/LegacyConnection.d.ts +240 -248
- package/LegacyConnection.js +500 -525
- package/README.md +1264 -1171
- package/Theme.d.ts +1 -1
- package/Theme.js +9 -12
- package/assets/devices.json +1 -0
- package/assets/rooms.json +1 -0
- package/craco-module-federation.js +3 -12
- package/i18n/de.json +434 -434
- package/i18n/en.json +434 -434
- package/i18n/es.json +434 -434
- package/i18n/fr.json +434 -434
- package/i18n/it.json +434 -434
- package/i18n/nl.json +434 -434
- package/i18n/pl.json +434 -434
- package/i18n/pt.json +434 -434
- package/i18n/ru.json +434 -434
- package/i18n/uk.json +434 -434
- package/i18n/zh-cn.json +434 -434
- package/i18n.d.ts +26 -19
- package/i18n.js +28 -22
- package/icons/IconAdapter.js +2 -2
- package/icons/IconAlias.js +2 -2
- package/icons/IconChannel.js +2 -2
- package/icons/IconClearFilter.js +2 -2
- package/icons/IconClosed.js +2 -2
- package/icons/IconCopy.js +2 -2
- package/icons/IconDevice.js +2 -2
- package/icons/IconDocument.js +2 -2
- package/icons/IconDocumentReadOnly.js +2 -2
- package/icons/IconExpert.js +2 -2
- package/icons/IconFx.js +2 -2
- package/icons/IconInstance.js +2 -2
- package/icons/IconLogout.js +2 -2
- package/icons/IconNoIcon.js +2 -2
- package/icons/IconOpen.d.ts +2 -2
- package/icons/IconOpen.js +2 -2
- package/icons/IconProps.d.ts +4 -3
- package/icons/IconState.d.ts +2 -2
- package/icons/IconState.js +2 -2
- package/index.css +3 -2
- package/package.json +4 -4
- package/src/Components/404.tsx +32 -31
- package/src/Components/ColorPicker.tsx +142 -114
- package/src/Components/ComplexCron.tsx +174 -137
- package/src/Components/CopyToClipboard.tsx +22 -9
- package/src/Components/CustomModal.tsx +76 -69
- package/src/Components/FileBrowser.tsx +959 -852
- package/src/Components/FileViewer.tsx +146 -127
- package/src/Components/Icon.tsx +80 -52
- package/src/Components/IconPicker.tsx +83 -67
- package/src/Components/IconSelector.tsx +159 -141
- package/src/Components/Image.tsx +43 -26
- package/src/Components/Loader.tsx +56 -32
- package/src/Components/Logo.tsx +62 -52
- package/src/Components/MDUtils.tsx +10 -6
- package/src/Components/ObjectBrowser.tsx +3198 -2478
- package/src/Components/Router.tsx +11 -11
- package/src/Components/SaveCloseButtons.tsx +43 -39
- package/src/Components/Schedule.tsx +1091 -853
- package/src/Components/SelectWithIcon.tsx +135 -93
- package/src/Components/TabContainer.tsx +22 -20
- package/src/Components/TabContent.tsx +13 -12
- package/src/Components/TabHeader.tsx +10 -9
- package/src/Components/TableResize.tsx +52 -37
- package/src/Components/TextWithIcon.tsx +30 -19
- package/src/Components/ToggleThemeMenu.tsx +31 -13
- package/src/Components/TreeTable.tsx +468 -385
- package/src/Components/UploadImage.tsx +153 -121
- package/src/Components/Utils.tsx +135 -127
- package/src/Components/loader.css +40 -31
- package/src/Components/withWidth.tsx +23 -12
- package/src/Connection.tsx +1 -3
- package/src/Dialogs/ComplexCron.tsx +55 -61
- package/src/Dialogs/Confirm.tsx +88 -65
- package/src/Dialogs/Cron.tsx +122 -112
- package/src/Dialogs/Error.tsx +37 -42
- package/src/Dialogs/Message.tsx +39 -37
- package/src/Dialogs/SelectFile.tsx +95 -85
- package/src/Dialogs/SelectID.tsx +141 -129
- package/src/Dialogs/SimpleCron.tsx +44 -44
- package/src/Dialogs/TextInput.tsx +60 -68
- package/src/GenericApp.tsx +342 -242
- package/src/LegacyConnection.tsx +972 -842
- package/src/Prompt.tsx +3 -1
- package/src/Theme.tsx +19 -26
- package/src/icons/IconAdapter.tsx +16 -14
- package/src/icons/IconAlias.tsx +16 -14
- package/src/icons/IconChannel.tsx +55 -16
- package/src/icons/IconClearFilter.tsx +17 -15
- package/src/icons/IconClosed.tsx +16 -11
- package/src/icons/IconCopy.tsx +16 -11
- package/src/icons/IconDevice.tsx +121 -22
- package/src/icons/IconDocument.tsx +16 -11
- package/src/icons/IconDocumentReadOnly.tsx +21 -12
- package/src/icons/IconExpert.tsx +20 -12
- package/src/icons/IconFx.tsx +16 -14
- package/src/icons/IconInstance.tsx +16 -14
- package/src/icons/IconLogout.tsx +20 -18
- package/src/icons/IconNoIcon.tsx +16 -14
- package/src/icons/IconOpen.tsx +17 -12
- package/src/icons/IconProps.tsx +4 -3
- package/src/icons/IconState.tsx +34 -13
- package/src/index.css +3 -2
- package/tasks.js +91 -0
- package/types.d.ts +141 -0
- package/Components/Loaders/PT.css +0 -109
- package/Components/Loaders/Vendor.css +0 -13
- package/Components/loader.css +0 -222
- package/Components/types.d.ts +0 -82
- package/assets/devices/Alarm Systems.svg +0 -19
- package/assets/devices/Amplifier.svg +0 -22
- package/assets/devices/Awnings.svg +0 -5
- package/assets/devices/Battery Status.svg +0 -5
- package/assets/devices/Ceiling Spotlights.svg +0 -16
- package/assets/devices/Chandelier.svg +0 -7
- package/assets/devices/Climate.svg +0 -12
- package/assets/devices/Coffee Makers.svg +0 -6
- package/assets/devices/Cold Water.svg +0 -31
- package/assets/devices/Computer.svg +0 -21
- package/assets/devices/Consumption.svg +0 -8
- package/assets/devices/Curtains.svg +0 -43
- package/assets/devices/Dishwashers.svg +0 -12
- package/assets/devices/Doors.svg +0 -6
- package/assets/devices/Doorstep.svg +0 -35
- package/assets/devices/Dryer.svg +0 -14
- package/assets/devices/Fan.svg +0 -20
- package/assets/devices/Floor Lamps.svg +0 -5
- package/assets/devices/Garage Doors.svg +0 -9
- package/assets/devices/Gates.svg +0 -32
- package/assets/devices/Hairdryer.svg +0 -23
- package/assets/devices/Handle.svg +0 -6
- package/assets/devices/Hanging Lamps.svg +0 -9
- package/assets/devices/Heater.svg +0 -44
- package/assets/devices/Hoods.svg +0 -12
- package/assets/devices/Hot Water.svg +0 -10
- package/assets/devices/Humidity.svg +0 -41
- package/assets/devices/Iron.svg +0 -5
- package/assets/devices/Irrigation.svg +0 -23
- package/assets/devices/Led Strip.svg +0 -31
- package/assets/devices/Light.svg +0 -30
- package/assets/devices/Lightings.svg +0 -46
- package/assets/devices/Lock.svg +0 -19
- package/assets/devices/Louvre.svg +0 -7
- package/assets/devices/Mowing Machine.svg +0 -9
- package/assets/devices/Music.svg +0 -13
- package/assets/devices/Outdoor Blinds.svg +0 -7
- package/assets/devices/People.svg +0 -19
- package/assets/devices/Pool.svg +0 -8
- package/assets/devices/Power Consumption.svg +0 -13
- package/assets/devices/Printer.svg +0 -10
- package/assets/devices/Pump.svg +0 -10
- package/assets/devices/Receiver.svg +0 -19
- package/assets/devices/Sconces.svg +0 -10
- package/assets/devices/Security.svg +0 -34
- package/assets/devices/Shading.svg +0 -5
- package/assets/devices/Shutters.svg +0 -11
- package/assets/devices/SmokeDetector.svg +0 -13
- package/assets/devices/Sockets.svg +0 -13
- package/assets/devices/Speaker.svg +0 -35
- package/assets/devices/Stove.svg +0 -12
- package/assets/devices/Table Lamps.svg +0 -12
- package/assets/devices/Temperature Sensors.svg +0 -28
- package/assets/devices/Tv.svg +0 -8
- package/assets/devices/Vacuum Cleaner.svg +0 -16
- package/assets/devices/Ventilation.svg +0 -12
- package/assets/devices/Washing Machines.svg +0 -16
- package/assets/devices/Water Consumption.svg +0 -6
- package/assets/devices/Water Heater.svg +0 -8
- package/assets/devices/Water.svg +0 -40
- package/assets/devices/Weather.svg +0 -28
- package/assets/devices/Window.svg +0 -8
- package/assets/rooms/Anteroom.svg +0 -53
- package/assets/rooms/Attic.svg +0 -21
- package/assets/rooms/Balcony.svg +0 -13
- package/assets/rooms/Barn.svg +0 -6
- package/assets/rooms/Basement.svg +0 -5
- package/assets/rooms/Bathroom.svg +0 -38
- package/assets/rooms/Bedroom.svg +0 -5
- package/assets/rooms/Boiler Room.svg +0 -13
- package/assets/rooms/Carport.svg +0 -17
- package/assets/rooms/Cellar.svg +0 -89
- package/assets/rooms/Chamber.svg +0 -9
- package/assets/rooms/Corridor.svg +0 -53
- package/assets/rooms/Dining Area.svg +0 -37
- package/assets/rooms/Dining Room.svg +0 -37
- package/assets/rooms/Dining.svg +0 -37
- package/assets/rooms/Dressing Room.svg +0 -5
- package/assets/rooms/Driveway.svg +0 -15
- package/assets/rooms/Entrance.svg +0 -44
- package/assets/rooms/Equipment Room.svg +0 -15
- package/assets/rooms/Front Yard.svg +0 -64
- package/assets/rooms/Gallery.svg +0 -14
- package/assets/rooms/Garage.svg +0 -20
- package/assets/rooms/Garden.svg +0 -13
- package/assets/rooms/Ground Floor.svg +0 -95
- package/assets/rooms/Guest Bathroom.svg +0 -33
- package/assets/rooms/Guest Room.svg +0 -5
- package/assets/rooms/Gym.svg +0 -5
- package/assets/rooms/Hall.svg +0 -19
- package/assets/rooms/Home Theater.svg +0 -8
- package/assets/rooms/Kitchen.svg +0 -18
- package/assets/rooms/Laundry Room.svg +0 -12
- package/assets/rooms/Living Area.svg +0 -11
- package/assets/rooms/Living Room.svg +0 -10
- package/assets/rooms/Locker Room.svg +0 -17
- package/assets/rooms/Nursery.svg +0 -5
- package/assets/rooms/Office.svg +0 -8
- package/assets/rooms/Outdoors.svg +0 -7
- package/assets/rooms/Playroom.svg +0 -6
- package/assets/rooms/Pool.svg +0 -8
- package/assets/rooms/Rear Wall.svg +0 -30
- package/assets/rooms/Second Floor.svg +0 -95
- package/assets/rooms/Shed.svg +0 -16
- package/assets/rooms/Sleeping Area.svg +0 -22
- package/assets/rooms/Stairway.svg +0 -5
- package/assets/rooms/Stairwell.svg +0 -15
- package/assets/rooms/Storeroom.svg +0 -5
- package/assets/rooms/Summer House.svg +0 -27
- package/assets/rooms/Swimming Pool.svg +0 -21
- package/assets/rooms/Terrace.svg +0 -7
- package/assets/rooms/Toilet.svg +0 -10
- package/assets/rooms/Upstairs.svg +0 -6
- package/assets/rooms/Wardrobe.svg +0 -60
- package/assets/rooms/Washroom.svg +0 -20
- package/assets/rooms/Wc.svg +0 -10
- package/assets/rooms/Windscreen.svg +0 -60
- package/assets/rooms/Workshop.svg +0 -23
- package/assets/rooms/Workspace.svg +0 -8
package/Components/TreeTable.js
CHANGED
|
@@ -53,7 +53,7 @@ function setAttr(obj, attr, value) {
|
|
|
53
53
|
attr = attr.split('.');
|
|
54
54
|
}
|
|
55
55
|
if (attr.length === 1) {
|
|
56
|
-
return obj[attr[0]] = value;
|
|
56
|
+
return (obj[attr[0]] = value);
|
|
57
57
|
}
|
|
58
58
|
const name = attr.shift();
|
|
59
59
|
if (obj[name] === null || obj[name] === undefined) {
|
|
@@ -191,7 +191,7 @@ class TreeTable extends react_1.Component {
|
|
|
191
191
|
try {
|
|
192
192
|
opened = JSON.parse(opened) || [];
|
|
193
193
|
}
|
|
194
|
-
catch (
|
|
194
|
+
catch (_c) {
|
|
195
195
|
opened = [];
|
|
196
196
|
}
|
|
197
197
|
if (!Array.isArray(opened)) {
|
|
@@ -270,14 +270,21 @@ class TreeTable extends react_1.Component {
|
|
|
270
270
|
this.setState({ editData });
|
|
271
271
|
}
|
|
272
272
|
renderCellEditSelect(col, val) {
|
|
273
|
-
return react_1.default.createElement(material_1.Select, { variant: "standard", onChange: e => this.onChange(col, val, e.target.value), value: (this.state.editData && this.state.editData[col.field]) || val }, col.lookup &&
|
|
274
|
-
.map((v, i) => {
|
|
273
|
+
return (react_1.default.createElement(material_1.Select, { variant: "standard", onChange: e => this.onChange(col, val, e.target.value), value: (this.state.editData && this.state.editData[col.field]) || val }, col.lookup &&
|
|
274
|
+
Object.keys(col.lookup).map((v, i) => {
|
|
275
|
+
var _c;
|
|
276
|
+
return (react_1.default.createElement(material_1.MenuItem, { key: i, value: v }, (_c = col.lookup) === null || _c === void 0 ? void 0 : _c[v]));
|
|
277
|
+
})));
|
|
275
278
|
}
|
|
276
279
|
renderCellEditString(col, val) {
|
|
277
|
-
return react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.fieldEdit, fullWidth: true, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
280
|
+
return (react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.fieldEdit, fullWidth: true, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
281
|
+
? this.state.editData[col.field]
|
|
282
|
+
: val, onChange: e => this.onChange(col, val, e.target.value) }));
|
|
278
283
|
}
|
|
279
284
|
renderCellEditNumber(col, val) {
|
|
280
|
-
return react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.fieldEdit, type: "number", fullWidth: true, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
285
|
+
return (react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.fieldEdit, type: "number", fullWidth: true, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
286
|
+
? this.state.editData[col.field]
|
|
287
|
+
: val, onChange: e => this.onChange(col, val, e.target.value) }));
|
|
281
288
|
}
|
|
282
289
|
renderCellEditCustom(col, val, item) {
|
|
283
290
|
const EditComponent = col.editComponent;
|
|
@@ -287,49 +294,53 @@ class TreeTable extends react_1.Component {
|
|
|
287
294
|
item = JSON.parse(JSON.stringify(item));
|
|
288
295
|
item[col.field] = val;
|
|
289
296
|
}
|
|
290
|
-
return EditComponent ? react_1.default.createElement(EditComponent, { value: val, rowData: item, onChange: (newVal) => this.onChange(col, val, newVal) }) : null;
|
|
297
|
+
return EditComponent ? (react_1.default.createElement(EditComponent, { value: val, rowData: item, onChange: (newVal) => this.onChange(col, val, newVal) })) : null;
|
|
291
298
|
}
|
|
292
299
|
renderCellEditBoolean(col, val) {
|
|
293
|
-
return react_1.default.createElement(material_1.Checkbox, { checked: this.state.editData && this.state.editData[col.field] !== undefined
|
|
300
|
+
return (react_1.default.createElement(material_1.Checkbox, { checked: this.state.editData && this.state.editData[col.field] !== undefined
|
|
301
|
+
? !!this.state.editData[col.field]
|
|
302
|
+
: !!val, onChange: e => this.onChange(col, !!val, e.target.checked), inputProps: { 'aria-label': 'checkbox' } }));
|
|
294
303
|
}
|
|
295
304
|
renderSelectColorDialog() {
|
|
296
|
-
return react_1.default.createElement(material_1.Dialog, { sx: {
|
|
305
|
+
return (react_1.default.createElement(material_1.Dialog, { sx: {
|
|
297
306
|
'& .MuiPaper-root': styles.root,
|
|
298
307
|
'& .MuiPaper-paper': styles.paper,
|
|
299
308
|
}, onClose: () => {
|
|
300
309
|
this.selectCallback = null;
|
|
301
310
|
this.setState({ showSelectColor: false });
|
|
302
311
|
}, open: this.state.showSelectColor },
|
|
303
|
-
react_1.default.createElement(react_colorful_1.HexColorPicker, { color: this.state.selectIdValue, onChange: color => this.setState({ selectIdValue: color }, () => this.selectCallback && this.selectCallback(color)) }));
|
|
312
|
+
react_1.default.createElement(react_colorful_1.HexColorPicker, { color: this.state.selectIdValue, onChange: color => this.setState({ selectIdValue: color }, () => this.selectCallback && this.selectCallback(color)) })));
|
|
304
313
|
}
|
|
305
314
|
renderCellEditColor(col, val) {
|
|
306
315
|
const _val = this.state.editData && this.state.editData[col.field] !== undefined ? this.state.editData[col.field] : val;
|
|
307
|
-
return react_1.default.createElement("div", { style: styles.fieldEdit },
|
|
316
|
+
return (react_1.default.createElement("div", { style: styles.fieldEdit },
|
|
308
317
|
react_1.default.createElement(material_1.TextField, { variant: "standard", fullWidth: true, style: styles.fieldEditWithButton, value: _val, inputProps: { style: { backgroundColor: _val, color: Utils_1.default.isUseBright(_val) ? '#FFF' : '#000' } }, onChange: e => this.onChange(col, !!val, e.target.value) }),
|
|
309
318
|
react_1.default.createElement(material_1.IconButton, { style: styles.fieldButton, onClick: () => {
|
|
310
319
|
this.selectCallback = newColor => this.onChange(col, val, newColor);
|
|
311
320
|
this.setState({ showSelectColor: true, selectIdValue: val });
|
|
312
321
|
}, size: "large" },
|
|
313
|
-
react_1.default.createElement(icons_material_1.Colorize, null)));
|
|
322
|
+
react_1.default.createElement(icons_material_1.Colorize, null))));
|
|
314
323
|
}
|
|
315
324
|
renderSelectIdDialog() {
|
|
316
325
|
if (this.state.showSelectId && this.props.socket) {
|
|
317
|
-
return react_1.default.createElement(SelectID_1.default, { 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 /* , name */) => {
|
|
326
|
+
return (react_1.default.createElement(SelectID_1.default, { 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 /* , name */) => {
|
|
318
327
|
this.setState({ showSelectId: false, selectIdValue: null });
|
|
319
328
|
this.selectCallback && this.selectCallback(selected);
|
|
320
329
|
this.selectCallback = null;
|
|
321
|
-
} });
|
|
330
|
+
} }));
|
|
322
331
|
}
|
|
323
332
|
return null;
|
|
324
333
|
}
|
|
325
334
|
renderCellEditObjectID(col, val) {
|
|
326
|
-
return react_1.default.createElement("div", { style: styles.fieldEdit },
|
|
327
|
-
react_1.default.createElement(material_1.TextField, { variant: "standard", fullWidth: true, style: styles.fieldEditWithButton, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
335
|
+
return (react_1.default.createElement("div", { style: styles.fieldEdit },
|
|
336
|
+
react_1.default.createElement(material_1.TextField, { variant: "standard", fullWidth: true, style: styles.fieldEditWithButton, value: this.state.editData && this.state.editData[col.field] !== undefined
|
|
337
|
+
? this.state.editData[col.field]
|
|
338
|
+
: val, onChange: e => this.onChange(col, val, e.target.value) }),
|
|
328
339
|
react_1.default.createElement(material_1.IconButton, { style: styles.fieldButton, onClick: () => {
|
|
329
340
|
this.selectCallback = selected => this.onChange(col, val, selected);
|
|
330
341
|
this.setState({ showSelectId: true, selectIdValue: val });
|
|
331
342
|
}, size: "large" },
|
|
332
|
-
react_1.default.createElement(icons_material_1.ViewHeadline, null)));
|
|
343
|
+
react_1.default.createElement(icons_material_1.ViewHeadline, null))));
|
|
333
344
|
}
|
|
334
345
|
static renderCellNonEdit(item, col) {
|
|
335
346
|
let val = getAttr(item, col.field, col.lookup);
|
|
@@ -337,26 +348,26 @@ class TreeTable extends react_1.Component {
|
|
|
337
348
|
val = val[0];
|
|
338
349
|
}
|
|
339
350
|
if (col.type === 'boolean') {
|
|
340
|
-
return react_1.default.createElement(material_1.Checkbox, { checked: !!val, disabled: true, inputProps: { 'aria-label': 'checkbox' } });
|
|
351
|
+
return (react_1.default.createElement(material_1.Checkbox, { checked: !!val, disabled: true, inputProps: { 'aria-label': 'checkbox' } }));
|
|
341
352
|
}
|
|
342
353
|
return val;
|
|
343
354
|
}
|
|
344
355
|
renderCell(item, col, level, i) {
|
|
345
356
|
if (this.state.editMode === i && col.editable !== 'never' && col.editable !== false) {
|
|
346
|
-
return react_1.default.createElement(material_1.TableCell, { key: col.field, style: Object.assign(Object.assign(Object.assign({}, styles.cell), (level ? styles.cellSecondary : undefined)), col.cellStyle), component: "th" }, this.renderCellEdit(item, col));
|
|
357
|
+
return (react_1.default.createElement(material_1.TableCell, { key: col.field, style: Object.assign(Object.assign(Object.assign({}, styles.cell), (level ? styles.cellSecondary : undefined)), col.cellStyle), component: "th" }, this.renderCellEdit(item, col)));
|
|
347
358
|
}
|
|
348
|
-
return react_1.default.createElement(material_1.TableCell, { key: col.field, style: Object.assign(Object.assign(Object.assign({}, styles.cell), (level ? styles.cellSecondary : undefined)), col.cellStyle), component: "th" }, TreeTable.renderCellNonEdit(item, col));
|
|
359
|
+
return (react_1.default.createElement(material_1.TableCell, { key: col.field, style: Object.assign(Object.assign(Object.assign({}, styles.cell), (level ? styles.cellSecondary : undefined)), col.cellStyle), component: "th" }, TreeTable.renderCellNonEdit(item, col)));
|
|
349
360
|
}
|
|
350
361
|
static renderCellWithSubField(item, col) {
|
|
351
362
|
const main = getAttr(item, col.field, col.lookup);
|
|
352
363
|
if (col.subField) {
|
|
353
364
|
const sub = getAttr(item, col.subField, col.subLookup);
|
|
354
|
-
return react_1.default.createElement("div", null,
|
|
365
|
+
return (react_1.default.createElement("div", null,
|
|
355
366
|
react_1.default.createElement("div", { style: styles.mainText }, main),
|
|
356
|
-
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.subText), (col.subStyle || undefined)) }, sub));
|
|
367
|
+
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.subText), (col.subStyle || undefined)) }, sub)));
|
|
357
368
|
}
|
|
358
|
-
return react_1.default.createElement("div", null,
|
|
359
|
-
react_1.default.createElement("div", { style: styles.mainText }, main));
|
|
369
|
+
return (react_1.default.createElement("div", null,
|
|
370
|
+
react_1.default.createElement("div", { style: styles.mainText }, main)));
|
|
360
371
|
}
|
|
361
372
|
renderLine(item, level) {
|
|
362
373
|
const levelShift = this.props.levelShift === undefined ? 24 : this.props.levelShift;
|
|
@@ -374,8 +385,8 @@ class TreeTable extends react_1.Component {
|
|
|
374
385
|
// try to find children
|
|
375
386
|
const opened = this.state.opened.includes(item.id);
|
|
376
387
|
const children = this.props.data.filter(it => it.parentId === item.id);
|
|
377
|
-
const row = react_1.default.createElement(material_1.TableRow, { key: item.id, className: `table-row-${(item.id || '').toString().replace(/[.$]/g, '_')}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((this.state.update && this.state.update.includes(item.id) && styles.glow) || undefined)), styles.row), (level ? styles.rowSecondary : undefined)), (!level && children.length ? styles.rowMainWithChildren : undefined)), (!level && !children.length ? styles.rowMainWithoutChildren : undefined)), (this.state.editMode !== false && this.state.editMode !== i ? styles.rowNoEdit : undefined)), (this.state.deleteMode !== false && this.state.deleteMode !== i ? styles.rowNoEdit : undefined)) },
|
|
378
|
-
react_1.default.createElement(material_1.TableCell, { style: Object.assign(Object.assign(Object.assign({}, styles.cell), styles.cellExpand), (level ? styles.cellSecondary : undefined)) }, children.length ? react_1.default.createElement(material_1.IconButton, { onClick: () => {
|
|
388
|
+
const row = (react_1.default.createElement(material_1.TableRow, { key: item.id, className: `table-row-${(item.id || '').toString().replace(/[.$]/g, '_')}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((this.state.update && this.state.update.includes(item.id) && styles.glow) || undefined)), styles.row), (level ? styles.rowSecondary : undefined)), (!level && children.length ? styles.rowMainWithChildren : undefined)), (!level && !children.length ? styles.rowMainWithoutChildren : undefined)), (this.state.editMode !== false && this.state.editMode !== i ? styles.rowNoEdit : undefined)), (this.state.deleteMode !== false && this.state.deleteMode !== i ? styles.rowNoEdit : undefined)) },
|
|
389
|
+
react_1.default.createElement(material_1.TableCell, { style: Object.assign(Object.assign(Object.assign({}, styles.cell), styles.cellExpand), (level ? styles.cellSecondary : undefined)) }, children.length ? (react_1.default.createElement(material_1.IconButton, { onClick: () => {
|
|
379
390
|
const _opened = [...this.state.opened];
|
|
380
391
|
const pos = _opened.indexOf(item.id);
|
|
381
392
|
if (pos === -1) {
|
|
@@ -387,39 +398,31 @@ class TreeTable extends react_1.Component {
|
|
|
387
398
|
}
|
|
388
399
|
(window._localStorage || window.localStorage).setItem(this.props.name || 'iob-table', JSON.stringify(_opened));
|
|
389
400
|
this.setState({ opened: _opened });
|
|
390
|
-
}, size: "small" }, opened ? react_1.default.createElement(icons_material_1.ExpandMore, null) : react_1.default.createElement(icons_material_1.NavigateNext, null)) : null),
|
|
391
|
-
react_1.default.createElement(material_1.TableCell, { scope: "row", style: Object.assign(Object.assign(Object.assign(Object.assign({}, styles.cell), (level ? styles.cellSecondary : undefined)), this.props.columns[0].cellStyle), { paddingLeft: levelShift * level }) }, this.props.columns[0].subField
|
|
392
|
-
TreeTable.renderCellWithSubField(item, this.props.columns[0])
|
|
393
|
-
:
|
|
394
|
-
|
|
395
|
-
this.props.
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
:
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
:
|
|
416
|
-
null) : null,
|
|
417
|
-
this.props.onUpdate || this.props.onDelete ? react_1.default.createElement(material_1.TableCell, { style: Object.assign(Object.assign({}, styles.cell), styles.cellButton) }, this.state.editMode === i || this.state.deleteMode === i ?
|
|
418
|
-
react_1.default.createElement(material_1.IconButton, { onClick: () => this.setState({ editMode: false, deleteMode: false }), size: "large" },
|
|
419
|
-
react_1.default.createElement(icons_material_1.Close, null))
|
|
420
|
-
:
|
|
421
|
-
(this.props.onDelete ? react_1.default.createElement(material_1.IconButton, { disabled: this.state.deleteMode !== false, onClick: () => this.setState({ deleteMode: i }), size: "large" },
|
|
422
|
-
react_1.default.createElement(icons_material_1.Delete, null)) : null)) : null);
|
|
401
|
+
}, size: "small" }, opened ? react_1.default.createElement(icons_material_1.ExpandMore, null) : react_1.default.createElement(icons_material_1.NavigateNext, null))) : null),
|
|
402
|
+
react_1.default.createElement(material_1.TableCell, { scope: "row", style: Object.assign(Object.assign(Object.assign(Object.assign({}, styles.cell), (level ? styles.cellSecondary : undefined)), this.props.columns[0].cellStyle), { paddingLeft: levelShift * level }) }, this.props.columns[0].subField
|
|
403
|
+
? TreeTable.renderCellWithSubField(item, this.props.columns[0])
|
|
404
|
+
: getAttr(item, this.props.columns[0].field, this.props.columns[0].lookup)),
|
|
405
|
+
this.props.columns.map((col, ii) => !ii && !col.hidden ? null : this.renderCell(item, col, level, i)),
|
|
406
|
+
this.props.onUpdate ? (react_1.default.createElement(material_1.TableCell, { style: Object.assign(Object.assign({}, styles.cell), styles.cellButton) }, this.state.editMode === i || this.state.deleteMode === i ? (react_1.default.createElement(material_1.IconButton, { disabled: this.state.editMode !== false &&
|
|
407
|
+
(!this.state.editData || !Object.keys(this.state.editData).length), onClick: () => {
|
|
408
|
+
if (this.state.editMode !== false) {
|
|
409
|
+
const newData = JSON.parse(JSON.stringify(item));
|
|
410
|
+
this.state.editData &&
|
|
411
|
+
Object.keys(this.state.editData).forEach(attr => { var _c; return setAttr(newData, attr, (_c = this.state.editData) === null || _c === void 0 ? void 0 : _c[attr]); });
|
|
412
|
+
this.setState({ editMode: false }, () => this.props.onUpdate && this.props.onUpdate(newData, item));
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
this.setState({ deleteMode: false }, () => this.props.onDelete && this.props.onDelete(item));
|
|
416
|
+
}
|
|
417
|
+
}, size: "large" },
|
|
418
|
+
react_1.default.createElement(icons_material_1.Check, null))) : (react_1.default.createElement(material_1.IconButton, { disabled: this.state.editMode !== false, onClick: () => this.setState({ editMode: i, editData: null }), size: "large" },
|
|
419
|
+
react_1.default.createElement(icons_material_1.Edit, null))))) : null,
|
|
420
|
+
this.props.onDelete && !this.props.onUpdate ? (react_1.default.createElement(material_1.TableCell, { style: Object.assign(Object.assign({}, styles.cell), styles.cellButton) }, this.state.deleteMode === i ? (react_1.default.createElement(material_1.IconButton, { disabled: this.state.editMode !== false &&
|
|
421
|
+
(!this.state.editData || !Object.keys(this.state.editData).length), onClick: () => this.setState({ deleteMode: false }, () => this.props.onDelete && this.props.onDelete(item)), size: "large" },
|
|
422
|
+
react_1.default.createElement(icons_material_1.Check, null))) : null)) : null,
|
|
423
|
+
this.props.onUpdate || this.props.onDelete ? (react_1.default.createElement(material_1.TableCell, { style: Object.assign(Object.assign({}, styles.cell), styles.cellButton) }, this.state.editMode === i || this.state.deleteMode === i ? (react_1.default.createElement(material_1.IconButton, { onClick: () => this.setState({ editMode: false, deleteMode: false }), size: "large" },
|
|
424
|
+
react_1.default.createElement(icons_material_1.Close, null))) : this.props.onDelete ? (react_1.default.createElement(material_1.IconButton, { disabled: this.state.deleteMode !== false, onClick: () => this.setState({ deleteMode: i }), size: "large" },
|
|
425
|
+
react_1.default.createElement(icons_material_1.Delete, null))) : null)) : null));
|
|
423
426
|
if (!level && opened) {
|
|
424
427
|
const items = children.map(it => this.renderLine(it, level + 1));
|
|
425
428
|
items.unshift(row);
|
|
@@ -432,21 +435,22 @@ class TreeTable extends react_1.Component {
|
|
|
432
435
|
this.setState({ order: isAsc ? 'desc' : 'asc', orderBy: property });
|
|
433
436
|
}
|
|
434
437
|
renderHead() {
|
|
435
|
-
return react_1.default.createElement(material_1.TableHead, null,
|
|
438
|
+
return (react_1.default.createElement(material_1.TableHead, null,
|
|
436
439
|
react_1.default.createElement(material_1.TableRow, { key: "headerRow" },
|
|
437
440
|
react_1.default.createElement(material_1.TableCell, { component: "th", sx: Utils_1.default.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellExpand) }),
|
|
438
|
-
react_1.default.createElement(material_1.TableCell, { component: "th", sx: Utils_1.default.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
|
|
441
|
+
react_1.default.createElement(material_1.TableCell, { component: "th", sx: Utils_1.default.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
|
|
442
|
+
? false
|
|
443
|
+
: this.state.orderBy === this.props.columns[0].field
|
|
444
|
+
? this.state.order
|
|
445
|
+
: false }, this.props.noSort ? null : (react_1.default.createElement(material_1.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) },
|
|
439
446
|
this.props.columns[0].title || this.props.columns[0].field,
|
|
440
|
-
this.state.orderBy === this.props.columns[0].field ?
|
|
441
|
-
|
|
442
|
-
this.props.columns.map((col, i) => (!i && !col.hidden ? null : react_1.default.createElement(material_1.TableCell, { key: col.field, sx: Utils_1.default.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_1.default.createElement(material_1.TableSortLabel, { active: this.state.orderBy === col.field, direction: this.state.orderBy === col.field ? this.state.order : 'asc', onClick: () => this.handleRequestSort(col.field) },
|
|
447
|
+
this.state.orderBy === this.props.columns[0].field ? (react_1.default.createElement("span", { style: styles.visuallyHidden }, this.state.order === 'desc' ? 'sorted descending' : 'sorted ascending')) : null))),
|
|
448
|
+
this.props.columns.map((col, i) => !i && !col.hidden ? null : (react_1.default.createElement(material_1.TableCell, { key: col.field, sx: Utils_1.default.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_1.default.createElement(material_1.TableSortLabel, { active: this.state.orderBy === col.field, direction: this.state.orderBy === col.field ? this.state.order : 'asc', onClick: () => this.handleRequestSort(col.field) },
|
|
443
449
|
col.title || col.field,
|
|
444
|
-
this.state.orderBy === col.field ?
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
this.props.onDelete || this.props.onUpdate ?
|
|
449
|
-
react_1.default.createElement(material_1.TableCell, { component: "th", sx: Utils_1.default.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellButton) }) : null));
|
|
450
|
+
this.state.orderBy === col.field ? (react_1.default.createElement("span", { style: styles.visuallyHidden }, this.state.order === 'desc' ? 'sorted descending' : 'sorted ascending')) : null))))),
|
|
451
|
+
this.props.onUpdate ? (react_1.default.createElement(material_1.TableCell, { component: "th", sx: Utils_1.default.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellButton) }, !this.props.noAdd ? (react_1.default.createElement(material_1.Fab, { color: "primary", size: "small", disabled: this.state.editMode !== false, onClick: () => this.props.onUpdate && this.props.onUpdate(true) },
|
|
452
|
+
react_1.default.createElement(icons_material_1.Add, null))) : null)) : null,
|
|
453
|
+
this.props.onDelete || this.props.onUpdate ? (react_1.default.createElement(material_1.TableCell, { component: "th", sx: Utils_1.default.getStyle(this.props.theme, styles.cell, styles.cellHeader, styles.cellButton) })) : null)));
|
|
450
454
|
}
|
|
451
455
|
render() {
|
|
452
456
|
const col = this.props.columns.find(_col => _col.field === this.state.orderBy);
|
|
@@ -460,12 +464,12 @@ class TreeTable extends react_1.Component {
|
|
|
460
464
|
this.setState({ update: null });
|
|
461
465
|
}, 500);
|
|
462
466
|
}
|
|
463
|
-
return react_1.default.createElement("div", { style: styles.tableContainer, className: this.props.className },
|
|
467
|
+
return (react_1.default.createElement("div", { style: styles.tableContainer, className: this.props.className },
|
|
464
468
|
react_1.default.createElement(material_1.Table, { style: styles.table, "aria-label": "simple table", size: "small", stickyHeader: true },
|
|
465
469
|
this.renderHead(),
|
|
466
470
|
react_1.default.createElement(material_1.TableBody, null, table.map(it => this.renderLine(it)))),
|
|
467
471
|
this.renderSelectIdDialog(),
|
|
468
|
-
this.renderSelectColorDialog());
|
|
472
|
+
this.renderSelectColorDialog()));
|
|
469
473
|
}
|
|
470
474
|
return null;
|
|
471
475
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component, type JSX } from 'react';
|
|
2
2
|
interface UploadImageProps {
|
|
3
3
|
maxSize?: number;
|
|
4
4
|
disabled?: boolean;
|
|
@@ -18,6 +18,6 @@ declare class UploadImage extends Component<UploadImageProps, UploadImageState>
|
|
|
18
18
|
private readonly cropperRef;
|
|
19
19
|
constructor(props: UploadImageProps);
|
|
20
20
|
onDrop(acceptedFiles: File[]): void;
|
|
21
|
-
render():
|
|
21
|
+
render(): JSX.Element;
|
|
22
22
|
}
|
|
23
23
|
export default UploadImage;
|
|
@@ -457,8 +457,7 @@ class UploadImage extends react_1.Component {
|
|
|
457
457
|
window.alert(i18n_1.default.t('ra_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));
|
|
458
458
|
}
|
|
459
459
|
else {
|
|
460
|
-
const base64 = `data:${ext};base64,${btoa(new Uint8Array(reader.result)
|
|
461
|
-
.reduce((data, byte) => data + String.fromCharCode(byte), ''))}`;
|
|
460
|
+
const base64 = `data:${ext};base64,${btoa(new Uint8Array(reader.result).reduce((data, byte) => data + String.fromCharCode(byte), ''))}`;
|
|
462
461
|
if (onChange) {
|
|
463
462
|
onChange(base64);
|
|
464
463
|
}
|
|
@@ -470,34 +469,39 @@ class UploadImage extends react_1.Component {
|
|
|
470
469
|
reader.readAsArrayBuffer(file);
|
|
471
470
|
}
|
|
472
471
|
render() {
|
|
473
|
-
const { disabled, icon, removeIconFunc, error, crop, onChange
|
|
472
|
+
const { disabled, icon, removeIconFunc, error, crop, onChange } = this.props;
|
|
474
473
|
const maxSize = this.props.maxSize || 10 * 1024;
|
|
475
474
|
const accept = this.props.accept || { 'image/*': [] };
|
|
476
475
|
const { uploadFile, anchorEl, cropHandler } = this.state;
|
|
477
|
-
return react_1.default.createElement(react_dropzone_1.default, { disabled: !!disabled || cropHandler, key: "dropzone", multiple: false, accept: accept, maxSize: maxSize, onDragEnter: () => this.setState({ uploadFile: 'dragging' }), onDragLeave: () => this.setState({ uploadFile: true }), onDrop: (acceptedFiles, errors) => {
|
|
476
|
+
return (react_1.default.createElement(react_dropzone_1.default, { disabled: !!disabled || cropHandler, key: "dropzone", multiple: false, accept: accept, maxSize: maxSize, onDragEnter: () => this.setState({ uploadFile: 'dragging' }), onDragLeave: () => this.setState({ uploadFile: true }), onDrop: (acceptedFiles, errors) => {
|
|
478
477
|
this.setState({ uploadFile: false });
|
|
479
478
|
if (!acceptedFiles.length) {
|
|
480
|
-
window.alert((errors &&
|
|
479
|
+
window.alert((errors &&
|
|
480
|
+
errors[0] &&
|
|
481
|
+
errors[0].errors &&
|
|
482
|
+
errors[0].errors[0] &&
|
|
483
|
+
errors[0].errors[0].message) ||
|
|
484
|
+
i18n_1.default.t('ra_Cannot upload'));
|
|
481
485
|
}
|
|
482
486
|
else {
|
|
483
487
|
this.onDrop(acceptedFiles);
|
|
484
488
|
}
|
|
485
|
-
} }, ({ getRootProps, getInputProps }) => react_1.default.createElement("div", Object.assign({ style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, styles.uploadDiv), (uploadFile === 'dragging' ? styles.uploadDivDragging : undefined)), styles.dropZone), (disabled ? styles.disabledOpacity : undefined)), (!icon ? styles.dropZoneEmpty : undefined)) }, getRootProps()),
|
|
489
|
+
} }, ({ getRootProps, getInputProps }) => (react_1.default.createElement("div", Object.assign({ style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, styles.uploadDiv), (uploadFile === 'dragging' ? styles.uploadDivDragging : undefined)), styles.dropZone), (disabled ? styles.disabledOpacity : undefined)), (!icon ? styles.dropZoneEmpty : undefined)) }, getRootProps()),
|
|
486
490
|
react_1.default.createElement("input", Object.assign({}, getInputProps())),
|
|
487
491
|
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.uploadCenterDiv), (error ? styles.error : undefined)) },
|
|
488
|
-
!icon ? react_1.default.createElement("div", { style: styles.uploadCenterTextAndIcon },
|
|
492
|
+
!icon ? (react_1.default.createElement("div", { style: styles.uploadCenterTextAndIcon },
|
|
489
493
|
react_1.default.createElement(fa_1.FaFileUpload, { style: styles.uploadCenterIcon }),
|
|
490
|
-
react_1.default.createElement("div", { style: styles.uploadCenterText }, uploadFile === 'dragging'
|
|
491
|
-
i18n_1.default.t('
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
icon && crop && react_1.default.createElement("div", { style: styles.buttonCropWrapper },
|
|
494
|
+
react_1.default.createElement("div", { style: styles.uploadCenterText }, uploadFile === 'dragging'
|
|
495
|
+
? i18n_1.default.t('ra_Drop file here')
|
|
496
|
+
: i18n_1.default.t('ra_Place your files here or click here to open the browse dialog')))) : (removeIconFunc &&
|
|
497
|
+
!cropHandler && (react_1.default.createElement("div", { style: styles.buttonRemoveWrapper },
|
|
498
|
+
react_1.default.createElement(material_1.Tooltip, { title: i18n_1.default.t('ra_Clear'), componentsProps: { popper: { sx: { pointerEvents: 'none' } } } },
|
|
499
|
+
react_1.default.createElement(material_1.IconButton, { size: "large", onClick: e => {
|
|
500
|
+
removeIconFunc && removeIconFunc();
|
|
501
|
+
e.stopPropagation();
|
|
502
|
+
} },
|
|
503
|
+
react_1.default.createElement(icons_material_1.Close, null)))))),
|
|
504
|
+
icon && crop && (react_1.default.createElement("div", { style: styles.buttonCropWrapper },
|
|
501
505
|
react_1.default.createElement(material_1.Tooltip, { title: i18n_1.default.t('ra_Crop'), componentsProps: { popper: { sx: { pointerEvents: 'none' } } } },
|
|
502
506
|
react_1.default.createElement(material_1.IconButton, { size: "large", onClick: e => {
|
|
503
507
|
if (!cropHandler) {
|
|
@@ -522,9 +526,9 @@ class UploadImage extends react_1.Component {
|
|
|
522
526
|
}
|
|
523
527
|
}
|
|
524
528
|
}) }, i18n_1.default.t('ra_Save')),
|
|
525
|
-
react_1.default.createElement(material_1.MenuItem, { onClick: () => this.setState({ anchorEl: null, cropHandler: false }) }, i18n_1.default.t('ra_Close')))),
|
|
526
|
-
icon && !cropHandler ? react_1.default.createElement(Icon_1.default, { src: icon, style: styles.image, alt: "icon" }) : null,
|
|
527
|
-
icon && crop && cropHandler ? react_1.default.createElement(react_cropper_1.Cropper, { ref: this.cropperRef, style: styles.image, src: icon, initialAspectRatio: 1, viewMode: 1, guides: false, minCropBoxHeight: 10, minCropBoxWidth: 10, background: false, checkOrientation: false }) : null)));
|
|
529
|
+
react_1.default.createElement(material_1.MenuItem, { onClick: () => this.setState({ anchorEl: null, cropHandler: false }) }, i18n_1.default.t('ra_Close'))))),
|
|
530
|
+
icon && !cropHandler ? (react_1.default.createElement(Icon_1.default, { src: icon, style: styles.image, alt: "icon" })) : null,
|
|
531
|
+
icon && crop && cropHandler ? (react_1.default.createElement(react_cropper_1.Cropper, { ref: this.cropperRef, style: styles.image, src: icon, initialAspectRatio: 1, viewMode: 1, guides: false, minCropBoxHeight: 10, minCropBoxWidth: 10, background: false, checkOrientation: false })) : null)))));
|
|
528
532
|
}
|
|
529
533
|
}
|
|
530
534
|
exports.default = UploadImage;
|
package/Components/Utils.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MIT License
|
|
5
5
|
*
|
|
6
|
-
|
|
6
|
+
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import { IobTheme, ThemeName, ThemeType } from '../types';
|
|
8
|
+
import type { IobTheme, ThemeName, ThemeType } from '../types';
|
|
9
9
|
type SmartName = null | false | string | ({
|
|
10
10
|
[lang in ioBroker.Languages]?: string;
|
|
11
11
|
} & {
|
|
@@ -77,7 +77,13 @@ declare class Utils {
|
|
|
77
77
|
icon?: string;
|
|
78
78
|
color?: string;
|
|
79
79
|
language?: ioBroker.Languages;
|
|
80
|
-
}, defaultEnabling?: boolean):
|
|
80
|
+
}, defaultEnabling?: boolean): {
|
|
81
|
+
name: string;
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
useCustom?: boolean;
|
|
84
|
+
icon?: string;
|
|
85
|
+
color?: string;
|
|
86
|
+
};
|
|
81
87
|
/**
|
|
82
88
|
Sets smartName settings for the given object.
|
|
83
89
|
*/
|
|
@@ -162,6 +168,7 @@ declare class Utils {
|
|
|
162
168
|
static copyToClipboard(text: string, e?: Event): boolean;
|
|
163
169
|
/**
|
|
164
170
|
* Gets the extension of a file name.
|
|
171
|
+
*
|
|
165
172
|
* @param fileName the file name.
|
|
166
173
|
* @returns The extension in lower case.
|
|
167
174
|
*/
|
|
@@ -169,52 +176,52 @@ declare class Utils {
|
|
|
169
176
|
/**
|
|
170
177
|
* Format number of bytes as a string with B, KB, MB or GB.
|
|
171
178
|
* The base for all calculations is 1024.
|
|
179
|
+
*
|
|
180
|
+
* @param bytes The number of bytes.
|
|
172
181
|
* @returns The formatted string (e.g. '723.5 KB')
|
|
173
182
|
*/
|
|
174
|
-
static formatBytes(
|
|
175
|
-
/** The number of bytes. */
|
|
176
|
-
bytes: number): string;
|
|
183
|
+
static formatBytes(bytes: number): string;
|
|
177
184
|
/**
|
|
178
185
|
* Invert the given color according to a theme type to get the inverted text color for background
|
|
186
|
+
*
|
|
187
|
+
* @param color Color in the format '#rrggbb' or '#rgb' (or without a hash)
|
|
188
|
+
* @param themeType 'light' or 'dark'
|
|
189
|
+
* @param invert If true, the dark theme has a light color in the control, or the dark theme has a light color in the control
|
|
179
190
|
*/
|
|
180
|
-
static getInvertedColor(
|
|
181
|
-
/** Color in the format '#rrggbb' or '#rgb' (or without a hash) */
|
|
182
|
-
color: string, themeType: ThemeType,
|
|
183
|
-
/** dark theme has light color in control, or light theme has light color in control */
|
|
184
|
-
invert?: boolean): string | undefined;
|
|
191
|
+
static getInvertedColor(color: string, themeType: ThemeType, invert?: boolean): string | undefined;
|
|
185
192
|
/**
|
|
186
193
|
* Invert the given color
|
|
187
|
-
*
|
|
194
|
+
*
|
|
195
|
+
* @param hex Color in the format '#rrggbb' or '#rgb' (or without a hash)
|
|
188
196
|
* @param bw Set to black or white.
|
|
189
197
|
*/
|
|
190
198
|
static invertColor(hex: string, bw?: boolean): string;
|
|
191
199
|
/**
|
|
192
200
|
* Convert RGB to array [r, g, b]
|
|
201
|
+
*
|
|
193
202
|
* @param hex Color in the format '#rrggbb' or '#rgb' (or without hash) or rgb(r,g,b) or rgba(r,g,b,a)
|
|
194
203
|
* @returns Array with 3 elements [r, g, b]
|
|
195
204
|
*/
|
|
196
205
|
static color2rgb(hex: string): false | [number, number, number] | '';
|
|
197
206
|
/**
|
|
198
207
|
* Convert RGB to LAB
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
208
|
+
*
|
|
209
|
+
* @param rgb color in format [r,g,b]
|
|
210
|
+
* @returns lab color in format [l,a,b]
|
|
201
211
|
*/
|
|
202
212
|
static rgb2lab(rgb: [number, number, number]): [number, number, number];
|
|
203
213
|
/**
|
|
204
214
|
* Calculate the distance between two colors in LAB color space in the range 0-100^2
|
|
205
|
-
* If distance is less than 1000, the colors are similar
|
|
215
|
+
* If the distance is less than 1000, the colors are similar
|
|
216
|
+
*
|
|
206
217
|
* @param color1 Color in the format '#rrggbb' or '#rgb' (or without hash) or rgb(r,g,b) or rgba(r,g,b,a)
|
|
207
218
|
* @param color2 Color in the format '#rrggbb' or '#rgb' (or without hash) or rgb(r,g,b) or rgba(r,g,b,a)
|
|
208
219
|
* @returns distance in the range 0-100^2
|
|
209
220
|
*/
|
|
210
221
|
static colorDistance(color1: string, color2: string): number;
|
|
211
|
-
|
|
212
|
-
* @private
|
|
213
|
-
*/
|
|
214
|
-
static _toVal(mix: ClassValue): string;
|
|
222
|
+
private static _toVal;
|
|
215
223
|
/**
|
|
216
224
|
* Convert any object to a string with its values.
|
|
217
|
-
* @returns {string}
|
|
218
225
|
*/
|
|
219
226
|
static clsx(...inputs: ClassValue[]): string;
|
|
220
227
|
/**
|
|
@@ -231,11 +238,13 @@ declare class Utils {
|
|
|
231
238
|
static setThemeName(themeName: ThemeName): void;
|
|
232
239
|
/**
|
|
233
240
|
* Toggle the theme name between 'dark' and 'colored'.
|
|
241
|
+
*
|
|
234
242
|
* @returns the new theme name.
|
|
235
243
|
*/
|
|
236
244
|
static toggleTheme(themeName?: ThemeName | null): ThemeName;
|
|
237
245
|
/**
|
|
238
246
|
* Get the list of themes
|
|
247
|
+
*
|
|
239
248
|
* @returns list of possible themes
|
|
240
249
|
*/
|
|
241
250
|
static getThemeNames(): ThemeName[];
|
|
@@ -245,12 +254,19 @@ declare class Utils {
|
|
|
245
254
|
static parseQuery(query: string): Record<string, string | number | boolean>;
|
|
246
255
|
/**
|
|
247
256
|
* Returns parent ID.
|
|
257
|
+
*
|
|
248
258
|
* @returns parent ID or null if no parent
|
|
249
259
|
*/
|
|
250
260
|
static getParentId(id: string): string | null;
|
|
251
261
|
static formatDate(dateObj: Date, dateFormat: string): string;
|
|
262
|
+
/**
|
|
263
|
+
* Format seconds to string like 'h:mm:ss' or 'd.hh:mm:ss'
|
|
264
|
+
*/
|
|
252
265
|
static formatTime(seconds: number): string;
|
|
253
266
|
static MDtext2link(text: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* Open url link in the new target window
|
|
269
|
+
*/
|
|
254
270
|
static openLink(url: string, target?: string): void;
|
|
255
271
|
static MDgetTitle(text: string): string;
|
|
256
272
|
static MDextractHeader(text: string): {
|
|
@@ -266,6 +282,7 @@ declare class Utils {
|
|
|
266
282
|
json: Record<string, any>): void;
|
|
267
283
|
/**
|
|
268
284
|
* Convert quality code into text
|
|
285
|
+
*
|
|
269
286
|
* @returns lines that decode quality
|
|
270
287
|
*/
|
|
271
288
|
static quality2text(quality: ioBroker.STATE_QUALITY[keyof ioBroker.STATE_QUALITY]): string[];
|
|
@@ -275,18 +292,21 @@ declare class Utils {
|
|
|
275
292
|
static clone(object: Record<string, any>): Record<string, any>;
|
|
276
293
|
/**
|
|
277
294
|
* Get states of object
|
|
295
|
+
*
|
|
278
296
|
* @returns states as an object in form {"value1": "label1", "value2": "label2"} or null
|
|
279
297
|
*/
|
|
280
298
|
static getStates(obj: ioBroker.StateObject | null | undefined): Record<string, string> | null;
|
|
281
299
|
/**
|
|
282
300
|
* Get svg file as text
|
|
301
|
+
*
|
|
283
302
|
* @param url URL of SVG file
|
|
284
303
|
* @returns Promise with "data:image..."
|
|
285
304
|
*/
|
|
286
305
|
static getSvg(url: string): Promise<string>;
|
|
287
306
|
/**
|
|
288
|
-
* Detect file extension by its content
|
|
289
|
-
*
|
|
307
|
+
* Detect a file extension by its content
|
|
308
|
+
*
|
|
309
|
+
* @returns The detected extension, like 'jpg'
|
|
290
310
|
*/
|
|
291
311
|
static detectMimeType(
|
|
292
312
|
/** Base64 encoded binary file */
|