@iobroker/adapter-react-v5 2.1.1 → 2.1.4

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/Theme.js DELETED
@@ -1,422 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _styles = require("@mui/material/styles");
9
-
10
- var _colors = require("@mui/material/colors");
11
-
12
- var step = (16 - 5) / 23 / 100;
13
- /**
14
- * Convert hex color in the format '#rrggbb' or '#rgb' to an RGB object.
15
- * @param {string} hex
16
- * @returns {{r: number, g: number, b: number}}
17
- */
18
-
19
- function toInt(hex) {
20
- var rgb = {
21
- r: 0,
22
- g: 0,
23
- b: 0
24
- };
25
-
26
- if (hex.length === 7) {
27
- rgb.r = parseInt(hex.substr(1, 2), 16);
28
- rgb.g = parseInt(hex.substr(3, 2), 16);
29
- rgb.b = parseInt(hex.substr(5, 2), 16);
30
- } else if (hex.length === 4) {
31
- var r = hex.substr(1, 1);
32
- var g = hex.substr(2, 1);
33
- var b = hex.substr(3, 1);
34
- rgb.r = parseInt(r + r, 16);
35
- rgb.g = parseInt(g + g, 16);
36
- rgb.b = parseInt(b + b, 16);
37
- }
38
-
39
- return rgb;
40
- }
41
- /**
42
- * Convert an RGB object to a hex color string in the format '#rrggbb'.
43
- * @param {{r: number, g: number, b: number}} int
44
- * @returns {string}
45
- */
46
-
47
-
48
- function toHex(_int) {
49
- return "#".concat(Math.round(_int.r).toString(16)).concat(Math.round(_int.g).toString(16)).concat(Math.round(_int.b).toString(16));
50
- }
51
- /**
52
- * @param {string} color color in the format '#rrggbb' or '#rgb'
53
- * @param {string} overlayColor overlay color in the format '#rrggbb' or '#rgb'
54
- * @param {number} elevation elevation as an integer starting with 1
55
- * @returns {string} the hex color string in the format '#rrggbb'
56
- */
57
-
58
-
59
- function getElevation(color, overlayColor, elevation) {
60
- var rgb = toInt(color);
61
- var overlay = toInt(overlayColor);
62
- rgb.r += overlay.r * (0.05 + step * (elevation - 1));
63
- rgb.g += overlay.g * (0.05 + step * (elevation - 1));
64
- rgb.b += overlay.b * (0.05 + step * (elevation - 1));
65
- return toHex(rgb);
66
- }
67
- /**
68
- * Get all 24 elevations of the given color and overlay.
69
- * @param {string} color color in the format '#rrggbb' or '#rgb'
70
- * @param {string} overlay overlay color in the format '#rrggbb' or '#rgb'
71
- * @returns {import('@mui/material/styles/withStyles').CSSProperties}
72
- */
73
-
74
-
75
- function getElevations(color, overlay) {
76
- /** @type {import('@mui/material/styles/withStyles').CSSProperties} */
77
- var elevations = {};
78
-
79
- for (var i = 1; i <= 24; i++) {
80
- elevations["elevation".concat(i)] = {
81
- backgroundColor: getElevation(color, overlay, i)
82
- };
83
- }
84
-
85
- return elevations;
86
- }
87
-
88
- var buttonsPalette = function buttonsPalette(theme) {
89
- return {
90
- palette: {
91
- // mode: "dark",
92
- grey: {
93
- main: _colors.grey[300],
94
- dark: _colors.grey[400]
95
- }
96
- }
97
- };
98
- };
99
-
100
- var buttonsTheme = function buttonsTheme(theme) {
101
- return {
102
- components: {
103
- MuiButton: {
104
- variants: [{
105
- props: {
106
- variant: 'contained',
107
- color: 'grey'
108
- },
109
- style: {
110
- color: theme.palette.getContrastText(theme.palette.grey[300])
111
- }
112
- }, {
113
- props: {
114
- variant: 'outlined',
115
- color: 'grey'
116
- },
117
- style: {
118
- color: theme.palette.text.primary,
119
- borderColor: theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',
120
- '&.Mui-disabled': {
121
- border: "1px solid ".concat(theme.palette.action.disabledBackground)
122
- },
123
- '&:hover': {
124
- borderColor: theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',
125
- backgroundColor: (0, _styles.alpha)(theme.palette.text.primary, theme.palette.action.hoverOpacity)
126
- }
127
- }
128
- }, {
129
- props: {
130
- color: 'grey',
131
- variant: 'text'
132
- },
133
- style: {
134
- color: 'black',
135
- '&:hover': {
136
- backgroundColor: (0, _styles.alpha)(theme.palette.text.primary, theme.palette.action.hoverOpacity)
137
- }
138
- }
139
- }]
140
- }
141
- }
142
- };
143
- };
144
- /**
145
- * The theme creation factory function.
146
- * @param {string} type
147
- * @returns {import('./types').Theme}
148
- */
149
-
150
-
151
- var Theme = function Theme(type) {
152
- var theme;
153
-
154
- if (type === 'dark') {
155
- theme = {
156
- name: type,
157
- palette: {
158
- mode: 'dark',
159
- background: {
160
- paper: '#121212',
161
- "default": '#121212'
162
- },
163
- primary: {
164
- main: '#4dabf5'
165
- },
166
- secondary: {
167
- main: '#436a93'
168
- },
169
- expert: '#14bb00',
170
- text: {
171
- primary: '#ffffff',
172
- secondary: '#ffffff'
173
- }
174
- },
175
- overrides: {
176
- MuiAppBar: {
177
- colorDefault: {
178
- backgroundColor: '#272727'
179
- }
180
- },
181
- MuiLink: {
182
- root: {
183
- textTransform: 'uppercase',
184
- transition: 'color .3s ease',
185
- color: _colors.orange[200],
186
- '&:hover': {
187
- color: _colors.orange[100]
188
- }
189
- }
190
- },
191
- MuiPaper: getElevations('#121212', '#fff')
192
- }
193
- };
194
- } else if (type === 'blue') {
195
- theme = {
196
- name: type,
197
- palette: {
198
- mode: 'dark',
199
- background: {
200
- paper: '#151d21',
201
- "default": '#151d21'
202
- },
203
- primary: {
204
- main: '#4dabf5'
205
- },
206
- secondary: {
207
- main: '#436a93'
208
- },
209
- expert: '#14bb00',
210
- text: {
211
- primary: '#ffffff',
212
- secondary: '#ffffff'
213
- }
214
- },
215
- overrides: {
216
- MuiAppBar: {
217
- colorDefault: {
218
- backgroundColor: '#2a3135'
219
- }
220
- },
221
- MuiLink: {
222
- root: {
223
- textTransform: 'uppercase',
224
- transition: 'color .3s ease',
225
- color: _colors.orange[200],
226
- '&:hover': {
227
- color: _colors.orange[100]
228
- }
229
- }
230
- },
231
- MuiPaper: getElevations('#151d21', '#fff')
232
- }
233
- };
234
- } else if (type === 'colored') {
235
- theme = {
236
- name: type,
237
- palette: {
238
- mode: 'light',
239
- primary: {
240
- main: '#3399CC'
241
- },
242
- secondary: {
243
- main: '#164477'
244
- },
245
- expert: '#96fc96'
246
- },
247
- overrides: {
248
- MuiAppBar: {
249
- colorDefault: {
250
- backgroundColor: '#3399CC'
251
- }
252
- },
253
- MuiLink: {
254
- root: {
255
- textTransform: 'uppercase',
256
- transition: 'color .3s ease',
257
- color: _colors.orange[400],
258
- '&:hover': {
259
- color: _colors.orange[300]
260
- }
261
- }
262
- }
263
- }
264
- };
265
- } else if (type === 'PT') {
266
- theme = {
267
- name: type,
268
- palette: {
269
- mode: 'light',
270
- primary: {
271
- main: '#0F99DE'
272
- },
273
- secondary: {
274
- main: '#88A536'
275
- },
276
- expert: '#BD1B24'
277
- },
278
- overrides: {
279
- MuiAppBar: {
280
- colorDefault: {
281
- backgroundColor: '#0F99DE'
282
- }
283
- },
284
- MuiLink: {
285
- root: {
286
- textTransform: 'uppercase',
287
- transition: 'color .3s ease',
288
- color: _colors.orange[400],
289
- '&:hover': {
290
- color: _colors.orange[300]
291
- }
292
- }
293
- }
294
- }
295
- };
296
- } else if (type === 'DX') {
297
- theme = {
298
- name: type,
299
- palette: {
300
- mode: 'light',
301
- primary: {
302
- main: '#F5F5F7'
303
- },
304
- secondary: {
305
- main: '#a9a9a9'
306
- },
307
- expert: '#BD1B24',
308
- text: {
309
- primary: '#007AFE',
310
- secondary: '#007AFE',
311
- disabled: '#007AFEAA'
312
- }
313
- },
314
- overrides: {
315
- MuiAppBar: {
316
- colorDefault: {
317
- backgroundColor: '#a9a9a9'
318
- }
319
- },
320
- MuiLink: {
321
- root: {
322
- textTransform: 'uppercase',
323
- transition: 'color .3s ease',
324
- color: _colors.orange[400],
325
- '&:hover': {
326
- color: _colors.orange[300]
327
- }
328
- }
329
- }
330
- }
331
- };
332
- } else {
333
- theme = {
334
- name: type,
335
- palette: {
336
- mode: 'light',
337
- primary: {
338
- main: '#3399CC'
339
- },
340
- secondary: {
341
- main: '#164477'
342
- },
343
- expert: '#14bb00'
344
- },
345
- overrides: {
346
- MuiLink: {
347
- root: {
348
- textTransform: 'uppercase',
349
- transition: 'color .3s ease',
350
- color: _colors.orange[400],
351
- '&:hover': {
352
- color: _colors.orange[300]
353
- }
354
- }
355
- }
356
- }
357
- };
358
- }
359
-
360
- theme.toolbar = {
361
- height: 48
362
- }; // add save toolbar
363
-
364
- theme.saveToolbar = {
365
- background: theme.palette.primary.main,
366
- button: {
367
- borderRadius: 3,
368
- height: 32
369
- }
370
- };
371
- theme.palette.grey = {
372
- main: _colors.grey[300],
373
- dark: _colors.grey[400]
374
- };
375
- theme = (0, _styles.createTheme)((0, _styles.adaptV4Theme)(theme));
376
- return (0, _styles.createTheme)(theme, {
377
- components: {
378
- MuiButton: {
379
- variants: [{
380
- props: {
381
- variant: 'contained',
382
- color: 'grey'
383
- },
384
- style: {
385
- color: theme.palette.getContrastText(theme.palette.grey[300])
386
- }
387
- }, {
388
- props: {
389
- variant: 'outlined',
390
- color: 'grey'
391
- },
392
- style: {
393
- color: theme.palette.text.primary,
394
- borderColor: theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',
395
- '&.Mui-disabled': {
396
- border: "1px solid ".concat(theme.palette.action.disabledBackground)
397
- },
398
- '&:hover': {
399
- borderColor: theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',
400
- backgroundColor: (0, _styles.alpha)(theme.palette.text.primary, theme.palette.action.hoverOpacity)
401
- }
402
- }
403
- }, {
404
- props: {
405
- color: 'grey',
406
- variant: 'text'
407
- },
408
- style: {
409
- color: theme.palette.text.primary,
410
- '&:hover': {
411
- backgroundColor: (0, _styles.alpha)(theme.palette.text.primary, theme.palette.action.hoverOpacity)
412
- }
413
- }
414
- }]
415
- }
416
- }
417
- });
418
- };
419
-
420
- var _default = Theme;
421
- exports["default"] = _default;
422
- //# sourceMappingURL=Theme.js.map
package/Theme.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["Theme.js"],"names":["step","toInt","hex","rgb","r","g","b","length","parseInt","substr","toHex","int","Math","round","toString","getElevation","color","overlayColor","elevation","overlay","getElevations","elevations","i","backgroundColor","buttonsPalette","theme","palette","grey","main","dark","buttonsTheme","components","MuiButton","variants","props","variant","style","getContrastText","text","primary","borderColor","mode","border","action","disabledBackground","hoverOpacity","Theme","type","name","background","paper","secondary","expert","overrides","MuiAppBar","colorDefault","MuiLink","root","textTransform","transition","orange","MuiPaper","disabled","toolbar","height","saveToolbar","button","borderRadius"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA,IAAMA,IAAI,GAAG,CAAC,KAAK,CAAN,IAAW,EAAX,GAAgB,GAA7B;AAEA;AACA;AACA;AACA;AACA;;AACA,SAASC,KAAT,CAAeC,GAAf,EAAoB;AAChB,MAAMC,GAAG,GAAG;AACRC,IAAAA,CAAC,EAAE,CADK;AAERC,IAAAA,CAAC,EAAE,CAFK;AAGRC,IAAAA,CAAC,EAAE;AAHK,GAAZ;;AAMA,MAAIJ,GAAG,CAACK,MAAJ,KAAe,CAAnB,EAAsB;AAClBJ,IAAAA,GAAG,CAACC,CAAJ,GAAQI,QAAQ,CAACN,GAAG,CAACO,MAAJ,CAAW,CAAX,EAAc,CAAd,CAAD,EAAmB,EAAnB,CAAhB;AACAN,IAAAA,GAAG,CAACE,CAAJ,GAAQG,QAAQ,CAACN,GAAG,CAACO,MAAJ,CAAW,CAAX,EAAc,CAAd,CAAD,EAAmB,EAAnB,CAAhB;AACAN,IAAAA,GAAG,CAACG,CAAJ,GAAQE,QAAQ,CAACN,GAAG,CAACO,MAAJ,CAAW,CAAX,EAAc,CAAd,CAAD,EAAmB,EAAnB,CAAhB;AACH,GAJD,MAIO,IAAIP,GAAG,CAACK,MAAJ,KAAe,CAAnB,EAAsB;AACzB,QAAMH,CAAC,GAAGF,GAAG,CAACO,MAAJ,CAAW,CAAX,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AAd,CAAqBE,YAFR;AALV;AATR;AAFX,SAPM,EA8BN;AACIX,UAAAA,KAAK,EAAE;AAAElB,YAAAA,KAAK,EAAE,MAAT;AAAiBmB,YAAAA,OAAO,EAAE;AAA1B,WADX;AAEIC,UAAAA,KAAK,EAAE;AACHpB,YAAAA,KAAK,EAAES,KAAK,CAACC,OAAN,CAAcY,IAAd,CAAmBC,OADvB;AAEH,uBAAW;AACPhB,cAAAA,eAAe,EAAE,mBACbE,KAAK,CAACC,OAAN,CAAcY,IAAd,CAAmBC,OADN,EAEbd,KAAK,CAACC,OAAN,CAAciB,MAAd,CAAqBE,YAFR;AADV;AAFR;AAFX,SA9BM;AADH;AADH;AADU,GAAnB,CAAP;AAiDH,CArRD;;eAuReC,K","sourcesContent":["import { createTheme, adaptV4Theme, alpha } from '@mui/material/styles';\n\nimport { orange, grey } from '@mui/material/colors';\n\nconst step = (16 - 5) / 23 / 100;\n\n/**\n * Convert hex color in the format '#rrggbb' or '#rgb' to an RGB object.\n * @param {string} hex\n * @returns {{r: number, g: number, b: number}}\n */\nfunction toInt(hex) {\n const rgb = {\n r: 0,\n g: 0,\n b: 0,\n };\n\n if (hex.length === 7) {\n rgb.r = parseInt(hex.substr(1, 2), 16);\n rgb.g = parseInt(hex.substr(3, 2), 16);\n rgb.b = parseInt(hex.substr(5, 2), 16);\n } else if (hex.length === 4) {\n const r = hex.substr(1, 1);\n const g = hex.substr(2, 1);\n const b = hex.substr(3, 1);\n\n rgb.r = parseInt(r + r, 16);\n rgb.g = parseInt(g + g, 16);\n rgb.b = parseInt(b + b, 16);\n }\n\n return rgb;\n}\n\n/**\n * Convert an RGB object to a hex color string in the format '#rrggbb'.\n * @param {{r: number, g: number, b: number}} int\n * @returns {string}\n */\nfunction toHex(int) {\n return `#${Math.round(int.r).toString(16)}${Math.round(int.g).toString(16)}${Math.round(int.b).toString(16)}`;\n}\n\n/**\n * @param {string} color color in the format '#rrggbb' or '#rgb'\n * @param {string} overlayColor overlay color in the format '#rrggbb' or '#rgb'\n * @param {number} elevation elevation as an integer starting with 1\n * @returns {string} the hex color string in the format '#rrggbb'\n */\nfunction getElevation(color, overlayColor, elevation) {\n const rgb = toInt(color);\n const overlay = toInt(overlayColor);\n\n rgb.r += overlay.r * (0.05 + step * (elevation - 1));\n rgb.g += overlay.g * (0.05 + step * (elevation - 1));\n rgb.b += overlay.b * (0.05 + step * (elevation - 1));\n\n return toHex(rgb);\n}\n\n/**\n * Get all 24 elevations of the given color and overlay.\n * @param {string} color color in the format '#rrggbb' or '#rgb'\n * @param {string} overlay overlay color in the format '#rrggbb' or '#rgb'\n * @returns {import('@mui/material/styles/withStyles').CSSProperties}\n */\nfunction getElevations(color, overlay) {\n /** @type {import('@mui/material/styles/withStyles').CSSProperties} */\n const elevations = {};\n\n for (let i = 1; i <= 24; i++) {\n elevations[`elevation${i}`] = {\n backgroundColor: getElevation(color, overlay, i),\n };\n }\n\n return elevations;\n}\n\nconst buttonsPalette = theme => ({\n palette: {\n // mode: \"dark\",\n grey: {\n main: grey[300],\n dark: grey[400],\n },\n },\n});\n\nconst buttonsTheme = theme => ({\n components: {\n MuiButton: {\n variants: [\n {\n props: { variant: 'contained', color: 'grey' },\n style: {\n color: theme.palette.getContrastText(theme.palette.grey[300]),\n },\n },\n {\n props: { variant: 'outlined', color: 'grey' },\n style: {\n color: theme.palette.text.primary,\n borderColor:\n theme.palette.mode === 'light'\n ? 'rgba(0, 0, 0, 0.23)'\n : 'rgba(255, 255, 255, 0.23)',\n '&.Mui-disabled': {\n border: `1px solid ${theme.palette.action.disabledBackground}`,\n },\n '&:hover': {\n borderColor:\n theme.palette.mode === 'light'\n ? 'rgba(0, 0, 0, 0.23)'\n : 'rgba(255, 255, 255, 0.23)',\n backgroundColor: alpha(\n theme.palette.text.primary,\n theme.palette.action.hoverOpacity,\n ),\n },\n },\n },\n {\n props: { color: 'grey', variant: 'text' },\n style: {\n color: 'black',\n '&:hover': {\n backgroundColor: alpha(\n theme.palette.text.primary,\n theme.palette.action.hoverOpacity,\n ),\n },\n },\n },\n ],\n },\n },\n});\n\n/**\n * The theme creation factory function.\n * @param {string} type\n * @returns {import('./types').Theme}\n */\nconst Theme = type => {\n let theme;\n if (type === 'dark') {\n theme = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#4dabf5',\n },\n secondary: {\n main: '#436a93',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n overrides: {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[200],\n '&:hover': {\n color: orange[100],\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n },\n };\n } else if (type === 'blue') {\n theme = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#151d21',\n default: '#151d21',\n },\n primary: {\n main: '#4dabf5',\n },\n secondary: {\n main: '#436a93',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n overrides: {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#2a3135',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[200],\n '&:hover': {\n color: orange[100],\n },\n },\n },\n MuiPaper: getElevations('#151d21', '#fff'),\n },\n };\n } else if (type === 'colored') {\n theme = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#3399CC',\n },\n secondary: {\n main: '#164477',\n },\n expert: '#96fc96',\n },\n overrides: {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#3399CC',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n },\n };\n } else if (type === 'PT') {\n theme = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#0F99DE',\n },\n secondary: {\n main: '#88A536',\n },\n expert: '#BD1B24',\n },\n overrides: {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#0F99DE',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n },\n };\n } else if (type === 'DX') {\n theme = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#F5F5F7',\n },\n secondary: {\n main: '#a9a9a9',\n },\n expert: '#BD1B24',\n text: {\n primary: '#007AFE',\n secondary: '#007AFE',\n disabled: '#007AFEAA',\n },\n },\n overrides: {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#a9a9a9',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n },\n };\n } else {\n theme = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#3399CC',\n },\n secondary: {\n main: '#164477',\n },\n expert: '#14bb00',\n },\n overrides: {\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n },\n };\n }\n\n theme.toolbar = {\n height: 48,\n };\n\n // add save toolbar\n theme.saveToolbar = {\n background: theme.palette.primary.main,\n button: {\n borderRadius: 3,\n height: 32,\n },\n };\n\n theme.palette.grey = {\n main: grey[300],\n dark: grey[400],\n };\n\n theme = createTheme(adaptV4Theme(theme));\n\n return createTheme(theme, {\n components: {\n MuiButton: {\n variants: [\n {\n props: { variant: 'contained', color: 'grey' },\n style: {\n color: theme.palette.getContrastText(theme.palette.grey[300]),\n },\n },\n {\n props: { variant: 'outlined', color: 'grey' },\n style: {\n color: theme.palette.text.primary,\n borderColor:\n theme.palette.mode === 'light'\n ? 'rgba(0, 0, 0, 0.23)'\n : 'rgba(255, 255, 255, 0.23)',\n '&.Mui-disabled': {\n border: `1px solid ${theme.palette.action.disabledBackground}`,\n },\n '&:hover': {\n borderColor:\n theme.palette.mode === 'light'\n ? 'rgba(0, 0, 0, 0.23)'\n : 'rgba(255, 255, 255, 0.23)',\n backgroundColor: alpha(\n theme.palette.text.primary,\n theme.palette.action.hoverOpacity,\n ),\n },\n },\n },\n {\n props: { color: 'grey', variant: 'text' },\n style: {\n color: theme.palette.text.primary,\n '&:hover': {\n backgroundColor: alpha(\n theme.palette.text.primary,\n theme.palette.action.hoverOpacity,\n ),\n },\n },\n },\n ],\n },\n },\n });\n};\n\nexport default Theme;\n"],"file":"Theme.js"}
package/i18n.js DELETED
@@ -1,171 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11
-
12
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
16
- /***
17
- * Copyright 2018-2019 bluefox <dogafox@gmail.com>
18
- *
19
- * MIT License
20
- *
21
- ***/
22
-
23
- /**
24
- * Translation string management.
25
- */
26
- var I18n = /*#__PURE__*/function () {
27
- function I18n() {
28
- _classCallCheck(this, I18n);
29
- }
30
-
31
- _createClass(I18n, null, [{
32
- key: "setLanguage",
33
- value:
34
- /**
35
- * List of all languages with their translations.
36
- * @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}
37
- */
38
-
39
- /**
40
- * The currently displayed language.
41
- * @type {ioBroker.Languages}
42
- */
43
-
44
- /**
45
- * Set the language to display.
46
- * @param {ioBroker.Languages} lang
47
- */
48
- function setLanguage(lang) {
49
- if (lang) {
50
- I18n.lang = lang;
51
- }
52
- }
53
- /**
54
- * Add translations
55
- * User can provide two types of structures:
56
- * - {"word1": "translated word1", "word2": "translated word2"}, but in this case the lang must be provided
57
- * - {"word1": {"en": "translated en word1", "de": "translated de word1"}, "word2": {"en": "translated en word2", "de": "translated de word2"}}, but no lang must be provided
58
- * @param {object} words additional words for specific language
59
- * @param {ioBroker.Languages} lang
60
- */
61
-
62
- }, {
63
- key: "extendTranslations",
64
- value: function extendTranslations(words, lang) {
65
- try {
66
- if (!lang) {
67
- Object.keys(words).forEach(function (word) {
68
- Object.keys(words[word]).forEach(function (lang) {
69
- if (!I18n.translations[lang]) {
70
- console.warn("Used unknown language: ".concat(lang));
71
- }
72
-
73
- if (!I18n.translations[lang][word]) {
74
- I18n.translations[lang][word] = words[word][lang];
75
- } else if (I18n.translations[lang][word] !== words[word][lang]) {
76
- console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word][lang]));
77
- }
78
- });
79
- });
80
- } else {
81
- if (!I18n.translations[lang]) {
82
- console.warn("Used unknown language: ".concat(lang));
83
- }
84
-
85
- I18n.translations[lang] = I18n.translations[lang] || {};
86
- Object.keys(words).forEach(function (word) {
87
- if (!I18n.translations[lang][word]) {
88
- I18n.translations[lang][word] = words[word];
89
- } else if (I18n.translations[lang][word] !== words[word]) {
90
- console.warn("Translation for word \"".concat(word, "\" in \"").concat(lang, "\" was ignored: existing = \"").concat(I18n.translations[lang][word], "\", new = ").concat(words[word]));
91
- }
92
- });
93
- }
94
- } catch (e) {
95
- console.error("Cannot apply translations: ".concat(e));
96
- }
97
- }
98
- /**
99
- * Sets all translations (in all languages).
100
- * @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations
101
- */
102
-
103
- }, {
104
- key: "setTranslations",
105
- value: function setTranslations(translations) {
106
- if (translations) {
107
- I18n.translations = translations;
108
- }
109
- }
110
- /**
111
- * Get the currently chosen language.
112
- * @returns {ioBroker.Languages} The current language.
113
- */
114
-
115
- }, {
116
- key: "getLanguage",
117
- value: function getLanguage() {
118
- return I18n.lang;
119
- }
120
- /**
121
- * Translate the given string to the selected language.
122
- * @param {string} word The (key) word to look up the string.
123
- * @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurence of %s
124
- */
125
-
126
- }, {
127
- key: "t",
128
- value: function t(word) {
129
- var translation = I18n.translations[I18n.lang];
130
-
131
- if (translation) {
132
- var w = translation[word];
133
-
134
- if (w) {
135
- word = w;
136
- } else {
137
- console.log("Translate: ".concat(word));
138
- }
139
- }
140
-
141
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
142
- args[_key - 1] = arguments[_key];
143
- }
144
-
145
- for (var _i = 0, _args = args; _i < _args.length; _i++) {
146
- var arg = _args[_i];
147
- word = word.replace('%s', arg);
148
- }
149
-
150
- return word;
151
- }
152
- }]);
153
-
154
- return I18n;
155
- }();
156
- /*I18n.translations = {
157
- 'en': require('./i18n/en'),
158
- 'ru': require('./i18n/ru'),
159
- 'de': require('./i18n/de'),
160
- };
161
- I18n.fallbacks = true;
162
- I18n.t = function () {};*/
163
-
164
-
165
- _defineProperty(I18n, "translations", {});
166
-
167
- _defineProperty(I18n, "lang", window.sysLang || 'en');
168
-
169
- var _default = I18n;
170
- exports["default"] = _default;
171
- //# sourceMappingURL=i18n.js.map
package/i18n.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["i18n.js"],"names":["I18n","lang","words","Object","keys","forEach","word","translations","console","warn","e","error","translation","w","log","args","arg","replace","window","sysLang"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEC;AACD;AAC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,EAAiB;AACb,YAAMC,CAAC,GAAGD,WAAW,CAACN,IAAD,CAArB;;AACA,YAAIO,CAAJ,EAAO;AACHP,UAAAA,IAAI,GAAGO,CAAP;AACH,SAFD,MAEO;AACHL,UAAAA,OAAO,CAACM,GAAR,sBAA0BR,IAA1B;AACH;AACJ;;AATmB,wCAANS,IAAM;AAANA,QAAAA,IAAM;AAAA;;AAUpB,+BAAkBA,IAAlB,2BAAwB;AAAnB,YAAMC,GAAG,YAAT;AACDV,QAAAA,IAAI,GAAGA,IAAI,CAACW,OAAL,CAAa,IAAb,EAAmBD,GAAnB,CAAP;AACH;;AACD,aAAOV,IAAP;AACH;;;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;;;gBA/GMN,I,kBAKoB,E;;gBALpBA,I,UAWYkB,MAAM,CAACC,OAAP,IAAkB,I;;eAsGrBnB,I","sourcesContent":["/***\n * Copyright 2018-2019 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n ***/\n\n /**\n * Translation string management.\n */\nclass I18n {\n /**\n * List of all languages with their translations.\n * @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }}\n */\n static translations = {};\n\n /**\n * The currently displayed language.\n * @type {ioBroker.Languages}\n */\n static lang = window.sysLang || 'en';\n\n /**\n * Set the language to display.\n * @param {ioBroker.Languages} lang\n */\n static setLanguage(lang) {\n if (lang) {\n I18n.lang = lang;\n }\n }\n\n /**\n * Add translations\n * User can provide two types of structures:\n * - {\"word1\": \"translated word1\", \"word2\": \"translated word2\"}, but in this case the lang must be provided\n * - {\"word1\": {\"en\": \"translated en word1\", \"de\": \"translated de word1\"}, \"word2\": {\"en\": \"translated en word2\", \"de\": \"translated de word2\"}}, but no lang must be provided\n * @param {object} words additional words for specific language\n * @param {ioBroker.Languages} lang\n */\n static extendTranslations(words, lang) {\n try {\n if (!lang) {\n Object.keys(words).forEach(word => {\n Object.keys(words[word]).forEach(lang => {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word][lang];\n } else if (I18n.translations[lang][word] !== words[word][lang]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word][lang]}`);\n }\n });\n });\n } else {\n if (!I18n.translations[lang]) {\n console.warn(`Used unknown language: ${lang}`);\n }\n I18n.translations[lang] = I18n.translations[lang] || {};\n Object.keys(words)\n .forEach(word => {\n if (!I18n.translations[lang][word]) {\n I18n.translations[lang][word] = words[word];\n } else if (I18n.translations[lang][word] !== words[word]) {\n console.warn(`Translation for word \"${word}\" in \"${lang}\" was ignored: existing = \"${I18n.translations[lang][word]}\", new = ${words[word]}`);\n }\n });\n }\n } catch (e) {\n console.error(`Cannot apply translations: ${e}`);\n }\n }\n\n /**\n * Sets all translations (in all languages).\n * @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations\n */\n static setTranslations(translations) {\n if (translations) {\n I18n.translations = translations;\n }\n }\n\n /**\n * Get the currently chosen language.\n * @returns {ioBroker.Languages} The current language.\n */\n static getLanguage() {\n return I18n.lang;\n }\n\n /**\n * Translate the given string to the selected language.\n * @param {string} word The (key) word to look up the string.\n * @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurence of %s\n */\n static t(word, ...args) {\n const translation = I18n.translations[I18n.lang];\n if (translation) {\n const w = translation[word];\n if (w) {\n word = w;\n } else {\n console.log(`Translate: ${word}`);\n }\n }\n for (const arg of args) {\n word = word.replace('%s', arg);\n }\n return word;\n }\n}\n\n/*I18n.translations = {\n 'en': require('./i18n/en'),\n 'ru': require('./i18n/ru'),\n 'de': require('./i18n/de'),\n};\nI18n.fallbacks = true;\nI18n.t = function () {};*/\n\nexport default I18n;"],"file":"i18n.js"}