@iobroker/dm-gui-components 0.0.10 → 6.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +3 -0
  2. package/build/Communication.js +247 -0
  3. package/build/Communication.js.map +1 -0
  4. package/build/DeviceActionButton.js +10 -0
  5. package/build/DeviceActionButton.js.map +1 -0
  6. package/build/DeviceCard.js +307 -0
  7. package/build/DeviceCard.js.map +1 -0
  8. package/build/DeviceControl.js +119 -0
  9. package/build/DeviceControl.js.map +1 -0
  10. package/{DeviceImageUpload.js → build/DeviceImageUpload.js} +5 -9
  11. package/build/DeviceImageUpload.js.map +1 -0
  12. package/build/DeviceList.js +235 -0
  13. package/build/DeviceList.js.map +1 -0
  14. package/build/DeviceStatus.js +106 -0
  15. package/build/DeviceStatus.js.map +1 -0
  16. package/build/InstanceActionButton.js +11 -0
  17. package/build/InstanceActionButton.js.map +1 -0
  18. package/{JsonConfig.js → build/JsonConfig.js} +10 -36
  19. package/build/JsonConfig.js.map +1 -0
  20. package/build/TooltipButton.js +17 -0
  21. package/build/TooltipButton.js.map +1 -0
  22. package/build/Utils.js +149 -0
  23. package/build/Utils.js.map +1 -0
  24. package/build/index.js +3 -0
  25. package/build/index.js.map +1 -0
  26. package/package.json +14 -14
  27. package/Communication.js +0 -268
  28. package/DeviceActionButton.js +0 -15
  29. package/DeviceCard.js +0 -338
  30. package/DeviceControl.js +0 -146
  31. package/DeviceList.js +0 -226
  32. package/DeviceStatus.js +0 -111
  33. package/InstanceActionButton.js +0 -16
  34. package/TooltipButton.js +0 -22
  35. package/Utils.js +0 -157
  36. package/index.js +0 -7
  37. package/{Communication.d.ts → build/Communication.d.ts} +0 -0
  38. package/{DeviceActionButton.d.ts → build/DeviceActionButton.d.ts} +0 -0
  39. package/{DeviceCard.d.ts → build/DeviceCard.d.ts} +0 -0
  40. package/{DeviceControl.d.ts → build/DeviceControl.d.ts} +0 -0
  41. package/{DeviceImageUpload.d.ts → build/DeviceImageUpload.d.ts} +0 -0
  42. package/{DeviceList.d.ts → build/DeviceList.d.ts} +0 -0
  43. package/{DeviceStatus.d.ts → build/DeviceStatus.d.ts} +0 -0
  44. package/{InstanceActionButton.d.ts → build/InstanceActionButton.d.ts} +0 -0
  45. package/{JsonConfig.d.ts → build/JsonConfig.d.ts} +0 -0
  46. package/{TooltipButton.d.ts → build/TooltipButton.d.ts} +0 -0
  47. package/{Utils.d.ts → build/Utils.d.ts} +0 -0
  48. package/{i18n → build/i18n}/de.json +0 -0
  49. package/{i18n → build/i18n}/en.json +0 -0
  50. package/{i18n → build/i18n}/es.json +0 -0
  51. package/{i18n → build/i18n}/fr.json +0 -0
  52. package/{i18n → build/i18n}/it.json +0 -0
  53. package/{i18n → build/i18n}/nl.json +0 -0
  54. package/{i18n → build/i18n}/pl.json +0 -0
  55. package/{i18n → build/i18n}/pt.json +0 -0
  56. package/{i18n → build/i18n}/ru.json +0 -0
  57. package/{i18n → build/i18n}/uk.json +0 -0
  58. package/{i18n → build/i18n}/zh-cn.json +0 -0
  59. package/{index.d.ts → build/index.d.ts} +1 -1
package/DeviceList.js DELETED
@@ -1,226 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const material_1 = require("@mui/material");
8
- const icons_material_1 = require("@mui/icons-material");
9
- const adapter_react_v5_1 = require("@iobroker/adapter-react-v5");
10
- const DeviceCard_1 = __importDefault(require("./DeviceCard"));
11
- const Utils_1 = require("./Utils");
12
- const Communication_1 = __importDefault(require("./Communication"));
13
- const InstanceActionButton_1 = __importDefault(require("./InstanceActionButton"));
14
- const de_json_1 = __importDefault(require("./i18n/de.json"));
15
- const en_json_1 = __importDefault(require("./i18n/en.json"));
16
- const ru_json_1 = __importDefault(require("./i18n/ru.json"));
17
- const pt_json_1 = __importDefault(require("./i18n/pt.json"));
18
- const nl_json_1 = __importDefault(require("./i18n/nl.json"));
19
- const fr_json_1 = __importDefault(require("./i18n/fr.json"));
20
- const it_json_1 = __importDefault(require("./i18n/it.json"));
21
- const es_json_1 = __importDefault(require("./i18n/es.json"));
22
- const pl_json_1 = __importDefault(require("./i18n/pl.json"));
23
- const uk_json_1 = __importDefault(require("./i18n/uk.json"));
24
- const zh_cn_json_1 = __importDefault(require("./i18n/zh-cn.json"));
25
- /**
26
- * Device List Component
27
- * @param {object} params - Component parameters
28
- * @param {object} params.socket - socket object
29
- * @param {string} params.selectedInstance - Selected instance
30
- * @param {string} params.uploadImagesToInstance - Instance to upload images to
31
- * @param {string} params.filter - Filter
32
- * @param {string} params.empbedded - true if this list used with multiple instances and false if only with one
33
- * @param {string} params.title - Title in appbar (only in non-embedded mode)
34
- * @param {string} params.style - Style of devices list
35
- * @returns {*[]} - Array of device cards
36
- */
37
- class DeviceList extends Communication_1.default {
38
- constructor(props) {
39
- super(props);
40
- this.aliveHandler = (id, state) => {
41
- if (id === `system.adapter.${this.props.selectedInstance}.alive`) {
42
- const alive = !!(state === null || state === void 0 ? void 0 : state.val);
43
- if (alive !== this.state.alive) {
44
- this.setState({ alive }, () => {
45
- if (alive) {
46
- this.componentDidMount().catch(console.error);
47
- }
48
- });
49
- }
50
- }
51
- };
52
- if (!DeviceList.i18nInitialized) {
53
- DeviceList.i18nInitialized = true;
54
- // @ts-expect-error
55
- adapter_react_v5_1.I18n.extendTranslations({
56
- en: en_json_1.default,
57
- de: de_json_1.default,
58
- ru: ru_json_1.default,
59
- pt: pt_json_1.default,
60
- nl: nl_json_1.default,
61
- fr: fr_json_1.default,
62
- it: it_json_1.default,
63
- es: es_json_1.default,
64
- pl: pl_json_1.default,
65
- uk: uk_json_1.default,
66
- 'zh-cn': zh_cn_json_1.default,
67
- });
68
- }
69
- Object.assign(this.state, {
70
- devices: [],
71
- filteredDevices: [],
72
- filter: '',
73
- instanceInfo: null,
74
- loading: null,
75
- alive: null,
76
- });
77
- this.lastPropsFilter = this.props.filter;
78
- this.lastInstance = this.props.selectedInstance;
79
- this.filterTimeout = null;
80
- this.language = adapter_react_v5_1.I18n.getLanguage();
81
- }
82
- async componentDidMount() {
83
- let alive = false;
84
- if (this.state.alive === null) {
85
- try {
86
- // check if instance is alive
87
- const stateAlive = await this.props.socket.getState(`system.adapter.${this.props.selectedInstance}.alive`);
88
- if (stateAlive === null || stateAlive === void 0 ? void 0 : stateAlive.val) {
89
- alive = true;
90
- }
91
- }
92
- catch (error) {
93
- console.error(error);
94
- }
95
- this.setState({ alive }, () => this.props.socket.subscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler));
96
- if (!alive) {
97
- return;
98
- }
99
- }
100
- else {
101
- alive = this.state.alive;
102
- }
103
- if (!this.props.embedded && alive) {
104
- try {
105
- const instanceInfo = await this.loadInstanceInfos();
106
- this.setState({ instanceInfo });
107
- }
108
- catch (error) {
109
- console.error(error);
110
- }
111
- }
112
- if (alive) {
113
- this.loadData();
114
- }
115
- }
116
- componentWillUnmount() {
117
- this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler);
118
- }
119
- /**
120
- * Load devices
121
- */
122
- loadData() {
123
- this.setState({ loading: true }, async () => {
124
- console.log(`Loading devices for ${this.props.selectedInstance}...`);
125
- let devices;
126
- try {
127
- devices = await this.loadDevices();
128
- if (!devices || !Array.isArray(devices)) {
129
- console.error(`Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(devices)}`);
130
- devices = [];
131
- }
132
- }
133
- catch (error) {
134
- console.error(error);
135
- devices = [];
136
- }
137
- this.setState({ devices, loading: false }, () => this.applyFilter());
138
- });
139
- }
140
- getText(text) {
141
- if (typeof text === 'object') {
142
- return text[this.language] || text.en;
143
- }
144
- return text;
145
- }
146
- applyFilter() {
147
- const filter = this.props.embedded ? this.props.filter : this.state.filter;
148
- // filter devices name
149
- if (filter) {
150
- const filteredDevices = this.state.devices.filter(device => this.getText(device.name).toLowerCase().includes(filter.toLowerCase()));
151
- this.setState({ filteredDevices });
152
- }
153
- else {
154
- this.setState({ filteredDevices: this.state.devices });
155
- }
156
- }
157
- handleFilterChange(filter) {
158
- this.setState({ filter }, () => {
159
- this.filterTimeout && clearTimeout(this.filterTimeout);
160
- this.filterTimeout = setTimeout(() => {
161
- this.filterTimeout = null;
162
- this.applyFilter();
163
- }, 250);
164
- });
165
- }
166
- renderContent() {
167
- var _a, _b;
168
- /** @type {object} */
169
- const emptyStyle = {
170
- padding: 25,
171
- };
172
- if (this.props.embedded && this.lastPropsFilter !== this.props.filter) {
173
- this.lastPropsFilter = this.props.filter;
174
- setTimeout(() => this.applyFilter(), 50);
175
- }
176
- if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {
177
- this.lastInstance = this.props.selectedInstance;
178
- setTimeout(() => this.loadData(), 50);
179
- }
180
- let list;
181
- if (!this.props.embedded && !this.state.alive) {
182
- list = react_1.default.createElement("div", { style: emptyStyle },
183
- react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('instanceNotAlive')));
184
- }
185
- else if (!this.state.devices.length && this.props.selectedInstance) {
186
- list = react_1.default.createElement("div", { style: emptyStyle },
187
- react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('noDevicesFoundText')));
188
- }
189
- else if (this.state.devices.length && !this.state.filteredDevices.length) {
190
- list = react_1.default.createElement("div", { style: emptyStyle },
191
- react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('allDevicesFilteredOut')));
192
- }
193
- else {
194
- list = this.state.filteredDevices.map(device => react_1.default.createElement(DeviceCard_1.default, { alive: !!this.state.alive, key: device.id, id: device.id, title: this.getText(device.name), device: device, instanceId: this.props.selectedInstance, uploadImagesToInstance: this.props.uploadImagesToInstance, deviceHandler: this.deviceHandler, controlHandler: this.controlHandler, controlStateHandler: this.controlStateHandler, socket: this.props.socket }));
195
- }
196
- if (this.props.embedded) {
197
- return react_1.default.createElement(react_1.default.Fragment, null,
198
- this.state.loading ? react_1.default.createElement(material_1.LinearProgress, { style: { width: '100%' } }) : null,
199
- list);
200
- }
201
- return react_1.default.createElement("div", { style: { width: '100%', height: '100%', overflow: 'hidden' } },
202
- react_1.default.createElement(material_1.Toolbar, { variant: "dense", style: { backgroundColor: '#777', display: 'flex' } },
203
- this.props.title,
204
- this.props.selectedInstance ? react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('refreshTooltip') },
205
- react_1.default.createElement("span", null,
206
- react_1.default.createElement(material_1.IconButton, { onClick: () => this.loadData(), disabled: !this.state.alive, size: "small" },
207
- react_1.default.createElement(icons_material_1.Refresh, null)))) : null,
208
- this.state.alive && ((_b = (_a = this.state.instanceInfo) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.length) ? react_1.default.createElement("div", { style: { marginLeft: 20 } }, this.state.instanceInfo.actions.map(action => react_1.default.createElement(InstanceActionButton_1.default, { key: action.id, action: action, instanceHandler: this.instanceHandler }))) : null,
209
- react_1.default.createElement("div", { style: { flexGrow: 1 } }),
210
- this.state.alive ? react_1.default.createElement(material_1.TextField, { variant: "standard", style: { width: 200 }, size: "small", label: (0, Utils_1.getTranslation)('filterLabelText'), onChange: e => this.handleFilterChange(e.target.value), value: this.state.filter, autoComplete: "off", inputProps: {
211
- autoComplete: 'new-password',
212
- form: { autoComplete: 'off' },
213
- },
214
- // eslint-disable-next-line react/jsx-no-duplicate-props
215
- InputProps: {
216
- endAdornment: this.state.filter ? react_1.default.createElement(material_1.InputAdornment, { position: "end" },
217
- react_1.default.createElement(material_1.IconButton, { onClick: () => this.handleFilterChange(''), edge: "end" },
218
- react_1.default.createElement(icons_material_1.Clear, null))) : null,
219
- } }) : null),
220
- react_1.default.createElement("div", { style: Object.assign({ width: '100%', height: 'calc(100% - 56px)', marginTop: 8, overflow: 'auto' }, this.props.style) },
221
- this.state.loading ? react_1.default.createElement(material_1.LinearProgress, { style: { width: '100%' } }) : null,
222
- list));
223
- }
224
- }
225
- DeviceList.i18nInitialized = false;
226
- exports.default = DeviceList;
package/DeviceStatus.js DELETED
@@ -1,111 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const material_1 = require("@mui/material");
8
- const icons_material_1 = require("@mui/icons-material");
9
- const Utils_1 = require("./Utils");
10
- /**
11
- * Device Status component
12
- * @param {object} params - Parameters
13
- * @param {object} params.status - Status object, e.g. { connection: 'connected', battery: 100, rssi: -50 }
14
- * @returns {React.JSX.Element|null}
15
- * @constructor
16
- */
17
- function DeviceStatus(params) {
18
- if (!params.status) {
19
- return null;
20
- }
21
- let status;
22
- if (typeof params.status === 'string') {
23
- status = {
24
- connection: params.status,
25
- };
26
- }
27
- else {
28
- status = params.status;
29
- }
30
- /** @type {object} */
31
- const iconStyleOK = {
32
- fill: '#00ac00',
33
- };
34
- /** @type {object} */
35
- const iconStyleNotOK = {
36
- fill: '#ff0000',
37
- };
38
- /** @type {object} */
39
- const iconStyleWarning = {
40
- fill: '#ff9900',
41
- };
42
- /** @type {object} */
43
- let batteryIconTooltip;
44
- if (typeof status.battery === 'number') {
45
- if (status.battery >= 96 && status.battery <= 100) {
46
- batteryIconTooltip = react_1.default.createElement(icons_material_1.BatteryFull, { style: iconStyleOK });
47
- }
48
- else if (status.battery >= 90 && status.battery <= 95) {
49
- batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery90, { style: iconStyleOK });
50
- }
51
- else if (status.battery >= 80 && status.battery <= 89) {
52
- batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery80, { style: iconStyleOK });
53
- }
54
- else if (status.battery >= 60 && status.battery <= 79) {
55
- batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery60, { style: iconStyleOK });
56
- }
57
- else if (status.battery >= 50 && status.battery <= 59) {
58
- batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery50, { style: iconStyleOK });
59
- }
60
- else if (status.battery >= 30 && status.battery <= 49) {
61
- batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery30, { style: iconStyleOK });
62
- }
63
- else if (status.battery >= 20 && status.battery <= 29) {
64
- batteryIconTooltip = react_1.default.createElement(icons_material_1.Battery20, { style: iconStyleNotOK });
65
- }
66
- else {
67
- batteryIconTooltip = react_1.default.createElement(icons_material_1.BatteryAlert, { style: iconStyleNotOK });
68
- }
69
- }
70
- return react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
71
- status.connection === 'connected' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
72
- react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('connectedIconTooltip') },
73
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
74
- react_1.default.createElement(icons_material_1.Link, { style: iconStyleOK })))),
75
- status.connection === 'disconnected' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
76
- react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('disconnectedIconTooltip') },
77
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
78
- react_1.default.createElement(icons_material_1.LinkOff, { style: iconStyleNotOK })))),
79
- status.rssi && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
80
- react_1.default.createElement(material_1.Tooltip, { title: "RSSI" },
81
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
82
- react_1.default.createElement(icons_material_1.NetworkCheck, null),
83
- react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } }, status.rssi)))),
84
- typeof status.battery === 'number' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
85
- react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('batteryTooltip') },
86
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
87
- batteryIconTooltip,
88
- react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } },
89
- status.battery,
90
- "%")))),
91
- typeof status.battery === 'string' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
92
- react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('batteryTooltip') },
93
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
94
- status.battery === 'charging' ? react_1.default.createElement(icons_material_1.BatteryCharging50, null) : react_1.default.createElement(icons_material_1.BatteryFull, null),
95
- status.battery !== 'charging' ? (status.battery.includes('V') || status.battery.includes('mV') ?
96
- react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } }, status.battery) :
97
- react_1.default.createElement("p", { style: { fontSize: 'small', margin: 0 } },
98
- react_1.default.createElement("span", { style: { marginRight: 4 } }, status.battery),
99
- "mV")) : null))),
100
- typeof status.battery === 'boolean' && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
101
- react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('batteryTooltip') },
102
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } }, status.battery ? react_1.default.createElement(icons_material_1.BatteryFull, { style: iconStyleOK }) :
103
- react_1.default.createElement(icons_material_1.BatteryAlert, { style: iconStyleNotOK })))),
104
- status.warning && react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center' } }, typeof status.warning === 'string' || typeof status.warning === 'object' ?
105
- react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)(status.warning) },
106
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
107
- react_1.default.createElement(icons_material_1.Warning, { style: iconStyleWarning }))) :
108
- react_1.default.createElement("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'center' } },
109
- react_1.default.createElement(icons_material_1.Warning, { style: iconStyleWarning }))));
110
- }
111
- exports.default = DeviceStatus;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const TooltipButton_1 = __importDefault(require("./TooltipButton"));
8
- const Utils_1 = require("./Utils");
9
- function InstanceActionButton(params) {
10
- const { action, instanceHandler } = params;
11
- const tooltip = (0, Utils_1.getTranslation)((action === null || action === void 0 ? void 0 : action.description) ? action.description : '');
12
- const title = (0, Utils_1.getTranslation)((action === null || action === void 0 ? void 0 : action.title) ? action.title : '');
13
- const icon = (0, Utils_1.renderIcon)(action);
14
- return react_1.default.createElement(TooltipButton_1.default, { tooltip: tooltip, label: title, disabled: action.disabled, Icon: icon, onClick: instanceHandler(action) });
15
- }
16
- exports.default = InstanceActionButton;
package/TooltipButton.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const material_1 = require("@mui/material");
8
- function TooltipButton(props) {
9
- const { tooltip, label, disabled, Icon, onClick } = props;
10
- const text = !!label && react_1.default.createElement(material_1.Typography, { variant: "button", style: { marginLeft: 4 } }, label);
11
- if (tooltip) {
12
- return react_1.default.createElement(material_1.Tooltip, { title: tooltip },
13
- react_1.default.createElement("span", null,
14
- react_1.default.createElement(material_1.IconButton, { onClick: onClick, disabled: disabled, size: "small" },
15
- Icon,
16
- text)));
17
- }
18
- return react_1.default.createElement(material_1.IconButton, { onClick: onClick, disabled: disabled, size: "small" },
19
- Icon,
20
- text);
21
- }
22
- exports.default = TooltipButton;
package/Utils.js DELETED
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTranslation = exports.renderIcon = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const icons_material_1 = require("@mui/icons-material");
9
- const adapter_react_v5_1 = require("@iobroker/adapter-react-v5");
10
- function renderIcon(action, colors, value) {
11
- var _a, _b, _c, _d;
12
- if (!action) {
13
- return null;
14
- }
15
- let color = (value && action.colorOn) || action.color || (action.state ? 'primary' : 'inherit');
16
- if (colors) {
17
- if (color === 'primary') {
18
- color = colors.primary;
19
- }
20
- else if (color === 'secondary') {
21
- color = colors.secondary;
22
- }
23
- }
24
- if (((_a = action.icon) === null || _a === void 0 ? void 0 : _a.startsWith('fa-')) || ((_b = action.icon) === null || _b === void 0 ? void 0 : _b.startsWith('fas'))) {
25
- const iconStyle = action.icon.split(' ').map(s => s.trim()).filter(s => s !== 'fa-solid');
26
- if (iconStyle.includes('fa-trash-can') || iconStyle.includes('fa-trash')) {
27
- return react_1.default.createElement(icons_material_1.Delete, { style: { color } });
28
- }
29
- if (iconStyle.includes('fa-pen')) {
30
- return react_1.default.createElement(icons_material_1.Edit, { style: { color } });
31
- }
32
- if (iconStyle.includes('fa-redo-alt')) {
33
- return react_1.default.createElement(icons_material_1.Refresh, { style: { color } });
34
- }
35
- if (iconStyle.includes('fa-plus')) {
36
- return react_1.default.createElement(icons_material_1.Add, { style: { color } });
37
- }
38
- if (iconStyle.includes('fa-wifi')) {
39
- return react_1.default.createElement(icons_material_1.Wifi, { style: { color } });
40
- }
41
- if (iconStyle.includes('fa-wifi-slash')) {
42
- return react_1.default.createElement(icons_material_1.WifiOff, { style: { color } });
43
- }
44
- if (iconStyle.includes('fa-bluetooth')) {
45
- return react_1.default.createElement(icons_material_1.Bluetooth, { style: { color } });
46
- }
47
- if (iconStyle.includes('fa-bluetooth-slash')) {
48
- return react_1.default.createElement(icons_material_1.BluetoothDisabled, { style: { color } });
49
- }
50
- if (iconStyle.includes('fa-eye')) {
51
- return react_1.default.createElement(icons_material_1.Visibility, { style: { color } });
52
- }
53
- if (iconStyle.includes('fa-search')) {
54
- return react_1.default.createElement(icons_material_1.Search, { style: { color } });
55
- }
56
- if (iconStyle.includes('fa-unlink')) {
57
- return react_1.default.createElement(icons_material_1.LinkOff, { style: { color } });
58
- }
59
- if (iconStyle.includes('fa-link')) {
60
- return react_1.default.createElement(icons_material_1.Link, { style: { color } });
61
- }
62
- if (iconStyle.includes('fa-search-location')) {
63
- return react_1.default.createElement(icons_material_1.NotListedLocation, { style: { color } });
64
- }
65
- if (iconStyle.includes('fa-play')) {
66
- return react_1.default.createElement(icons_material_1.PlayArrow, { style: { color } });
67
- }
68
- if (iconStyle.includes('fa-stop')) {
69
- return react_1.default.createElement(icons_material_1.Stop, { style: { color } });
70
- }
71
- if (iconStyle.includes('fa-pause')) {
72
- return react_1.default.createElement(icons_material_1.Pause, { style: { color } });
73
- }
74
- if (iconStyle.includes('forward') || iconStyle.includes('fa-forward')) {
75
- return react_1.default.createElement(icons_material_1.FastForward, { style: { color } });
76
- }
77
- if (iconStyle.includes('rewind') || iconStyle.includes('fa-rewind')) {
78
- return react_1.default.createElement(icons_material_1.FastRewind, { style: { color } });
79
- }
80
- return null;
81
- }
82
- if (value && ((_c = action.iconOn) === null || _c === void 0 ? void 0 : _c.startsWith('data:image'))) {
83
- return react_1.default.createElement(adapter_react_v5_1.Icon, { src: action.iconOn, style: { color } });
84
- }
85
- if ((_d = action.icon) === null || _d === void 0 ? void 0 : _d.startsWith('data:image')) {
86
- return react_1.default.createElement(adapter_react_v5_1.Icon, { src: action.icon, style: { color } });
87
- }
88
- if (action.id === 'edit' || action.id === 'rename') {
89
- return react_1.default.createElement(icons_material_1.Edit, { style: { color } });
90
- }
91
- if (action.id === 'delete') {
92
- return react_1.default.createElement(icons_material_1.Delete, { style: { color } });
93
- }
94
- if (action.id === 'refresh') {
95
- return react_1.default.createElement(icons_material_1.Refresh, { style: { color } });
96
- }
97
- if (action.id === 'newDevice' || action.id === 'new' || action.id === 'add') {
98
- return react_1.default.createElement(icons_material_1.Add, { style: { color } });
99
- }
100
- if (action.id === 'discover' || action.id === 'search') {
101
- return react_1.default.createElement(icons_material_1.Search, { style: { color } });
102
- }
103
- if (action.id === 'unpairDevice') {
104
- return react_1.default.createElement(icons_material_1.LinkOff, { style: { color } });
105
- }
106
- if (action.id === 'pairDevice') {
107
- return react_1.default.createElement(icons_material_1.Link, { style: { color } });
108
- }
109
- if (action.id === 'identify') {
110
- return react_1.default.createElement(icons_material_1.NotListedLocation, { style: { color } });
111
- }
112
- if (action.id === 'play') {
113
- return react_1.default.createElement(icons_material_1.PlayArrow, { style: { color } });
114
- }
115
- if (action.id === 'stop') {
116
- return react_1.default.createElement(icons_material_1.Stop, { style: { color } });
117
- }
118
- if (action.id === 'pause') {
119
- return react_1.default.createElement(icons_material_1.Pause, { style: { color } });
120
- }
121
- if (action.id === 'forward' || action.id === 'next') {
122
- return react_1.default.createElement(icons_material_1.FastForward, { style: { color } });
123
- }
124
- if (action.id === 'rewind' || action.id === 'previous') {
125
- return react_1.default.createElement(icons_material_1.FastRewind, { style: { color } });
126
- }
127
- if (action.id === 'lamp' || action.id === 'light') {
128
- return react_1.default.createElement(icons_material_1.Lightbulb, { style: { color } });
129
- }
130
- if (action.id === 'backlight') {
131
- return react_1.default.createElement(icons_material_1.Fluorescent, { style: { color } });
132
- }
133
- if (action.id === 'dimmer') {
134
- return react_1.default.createElement(icons_material_1.WbIncandescent, { style: { color } });
135
- }
136
- if (action.id === 'socket') {
137
- return react_1.default.createElement(icons_material_1.Power, { style: { color } });
138
- }
139
- return null;
140
- }
141
- exports.renderIcon = renderIcon;
142
- let language;
143
- /**
144
- * Get Translation
145
- * @param {string | object} text - Text to translate
146
- * @returns {string}
147
- */
148
- function getTranslation(text) {
149
- language = language || adapter_react_v5_1.I18n.getLanguage();
150
- if (typeof text === 'object') {
151
- const words = text;
152
- // @ts-ignore
153
- return words[language] || text.en;
154
- }
155
- return adapter_react_v5_1.I18n.t(text);
156
- }
157
- exports.getTranslation = getTranslation;
package/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const DeviceList_1 = __importDefault(require("./DeviceList"));
7
- exports.default = DeviceList_1.default;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,2 +1,2 @@
1
- export default DeviceList;
2
1
  import DeviceList from './DeviceList';
2
+ export default DeviceList;