@iobroker/json-config 7.4.13 → 7.4.15

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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { Tabs, Tab } from '@mui/material';
2
+ import { Tabs, Tab, IconButton, Toolbar, Menu, MenuItem, ListItemIcon } from '@mui/material';
3
+ import { Menu as MenuIcon } from '@mui/icons-material';
3
4
  import ConfigGeneric from './ConfigGeneric';
4
5
  import ConfigPanel from './ConfigPanel';
5
6
  const styles = {
@@ -19,6 +20,8 @@ const styles = {
19
20
  },
20
21
  };
21
22
  class ConfigTabs extends ConfigGeneric {
23
+ resizeTimeout = null;
24
+ refDiv;
22
25
  constructor(props) {
23
26
  super(props);
24
27
  let tab;
@@ -48,9 +51,14 @@ class ConfigTabs extends ConfigGeneric {
48
51
  tab = Object.keys(this.props.schema.items)[0];
49
52
  }
50
53
  }
51
- Object.assign(this.state, { tab });
54
+ this.refDiv = React.createRef();
55
+ Object.assign(this.state, { tab, width: 0, openMenu: null });
52
56
  }
53
57
  componentWillUnmount() {
58
+ if (this.resizeTimeout) {
59
+ clearTimeout(this.resizeTimeout);
60
+ this.resizeTimeout = null;
61
+ }
54
62
  window.removeEventListener('hashchange', this.onHashTabsChanged, false);
55
63
  super.componentWillUnmount();
56
64
  }
@@ -74,41 +82,95 @@ class ConfigTabs extends ConfigGeneric {
74
82
  }
75
83
  }
76
84
  };
85
+ getCurrentBreakpoint() {
86
+ if (!this.state.width) {
87
+ return 'md';
88
+ }
89
+ if (this.state.width < 600) {
90
+ return 'xs';
91
+ }
92
+ if (this.state.width < 900) {
93
+ return 'sm';
94
+ }
95
+ if (this.state.width < 1200) {
96
+ return 'md';
97
+ }
98
+ if (this.state.width < 1536) {
99
+ return 'lg';
100
+ }
101
+ return 'xl';
102
+ }
103
+ componentDidUpdate() {
104
+ if (this.refDiv.current?.clientWidth && this.refDiv.current.clientWidth !== this.state.width) {
105
+ if (this.resizeTimeout) {
106
+ clearTimeout(this.resizeTimeout);
107
+ }
108
+ this.resizeTimeout = setTimeout(() => {
109
+ this.resizeTimeout = null;
110
+ this.setState({ width: this.refDiv.current?.clientWidth });
111
+ }, 50);
112
+ }
113
+ }
114
+ onMenuChange(tab) {
115
+ (window._localStorage || window.localStorage).setItem(`${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`, tab);
116
+ this.setState({ tab }, () => {
117
+ if (this.props.root) {
118
+ const hash = (window.location.hash || '').split('/');
119
+ if (hash.length >= 3 && hash[1] === 'config') {
120
+ hash[3] = this.state.tab;
121
+ window.location.hash = hash.join('/');
122
+ }
123
+ }
124
+ });
125
+ }
77
126
  render() {
78
127
  const items = this.props.schema.items;
79
128
  let withIcons = false;
80
- return (React.createElement("div", { style: styles.tabs },
81
- React.createElement(Tabs, { variant: "scrollable", scrollButtons: "auto", style: this.props.schema.tabsStyle, value: this.state.tab, onChange: (e, tab) => {
82
- (window._localStorage || window.localStorage).setItem(`${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`, tab);
83
- this.setState({ tab }, () => {
84
- if (this.props.root) {
85
- const hash = (window.location.hash || '').split('/');
86
- if (hash.length >= 3 && hash[1] === 'config') {
87
- hash[3] = this.state.tab;
88
- window.location.hash = hash.join('/');
89
- }
90
- }
91
- });
92
- } }, Object.keys(items).map(name => {
93
- let disabled;
94
- if (this.props.custom) {
95
- const hidden = this.executeCustom(items[name].hidden, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.index, this.props.globalData);
96
- if (hidden) {
97
- return null;
98
- }
99
- disabled = this.executeCustom(items[name].disabled, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.index, this.props.globalData);
129
+ const elements = [];
130
+ Object.keys(items).map(name => {
131
+ let disabled;
132
+ if (this.props.custom) {
133
+ const hidden = this.executeCustom(items[name].hidden, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.index, this.props.globalData);
134
+ if (hidden) {
135
+ return;
100
136
  }
101
- else {
102
- const hidden = this.execute(items[name].hidden, false, this.props.data, this.props.index, this.props.globalData);
103
- if (hidden) {
104
- return null;
105
- }
106
- disabled = this.execute(items[name].disabled, false, this.props.data, this.props.index, this.props.globalData);
137
+ disabled = this.executeCustom(items[name].disabled, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.index, this.props.globalData);
138
+ }
139
+ else {
140
+ const hidden = this.execute(items[name].hidden, false, this.props.data, this.props.index, this.props.globalData);
141
+ if (hidden) {
142
+ return;
107
143
  }
108
- const icon = this.getIcon(items[name].icon);
109
- withIcons = withIcons || !!icon;
110
- return (React.createElement(Tab, { id: name, wrapped: true, disabled: disabled, key: name, value: name, iconPosition: this.props.schema.iconPosition || 'start', icon: icon, label: this.getText(items[name].label) }));
111
- })),
144
+ disabled = this.execute(items[name].disabled, false, this.props.data, this.props.index, this.props.globalData);
145
+ }
146
+ const icon = this.getIcon(items[name].icon);
147
+ withIcons = withIcons || !!icon;
148
+ elements.push({ icon, disabled, label: this.getText(items[name].label), name });
149
+ });
150
+ const currentBreakpoint = this.getCurrentBreakpoint();
151
+ let tabs;
152
+ if (currentBreakpoint === 'xs' || currentBreakpoint === 'sm') {
153
+ tabs = (React.createElement(Toolbar, { style: {
154
+ width: '100%',
155
+ backgroundColor: this.props.oContext.themeType === 'dark' ? '#222' : '#DDD',
156
+ }, variant: "dense" },
157
+ React.createElement(IconButton, { onClick: (event) => this.setState({ openMenu: event.currentTarget }) },
158
+ React.createElement(MenuIcon, null)),
159
+ this.state.openMenu ? (React.createElement(Menu, { open: !0, anchorEl: this.state.openMenu, onClose: () => this.setState({ openMenu: null }) }, elements.map(el => {
160
+ return (React.createElement(MenuItem, { disabled: el.disabled, key: el.name, onClick: () => {
161
+ this.setState({ openMenu: null }, () => this.onMenuChange(el.name));
162
+ }, selected: el.name === this.state.tab },
163
+ withIcons ? React.createElement(ListItemIcon, null, el.icon) : null,
164
+ el.label));
165
+ }))) : null));
166
+ }
167
+ else {
168
+ tabs = (React.createElement(Tabs, { variant: "scrollable", scrollButtons: "auto", style: this.props.schema.tabsStyle, value: this.state.tab, onChange: (_e, tab) => this.onMenuChange(tab) }, elements.map(el => {
169
+ return (React.createElement(Tab, { id: el.name, wrapped: true, disabled: el.disabled, key: el.name, value: el.name, iconPosition: this.props.schema.iconPosition || 'start', icon: el.icon, label: el.label }));
170
+ })));
171
+ }
172
+ return (React.createElement("div", { style: styles.tabs, ref: this.refDiv },
173
+ tabs,
112
174
  React.createElement(ConfigPanel, { oContext: this.props.oContext, isParentTab: true, changed: this.props.changed, key: this.state.tab, index: 1001, arrayIndex: this.props.arrayIndex, globalData: this.props.globalData, commandRunning: this.props.commandRunning, style: {
113
175
  ...styles.panel,
114
176
  ...(withIcons ? styles.panelWithIcons : styles.panelWithoutIcons),
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigTabs.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KAChB;IACD,KAAK,EAAE;QACH,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,OAAO;KACnB;IACD,cAAc,EAAE;QACZ,MAAM,EAAE,mBAAmB;KAC9B;IACD,iBAAiB,EAAE;QACf,MAAM,EAAE,mBAAmB;KAC9B;CACJ,CAAC;AAWF,MAAM,UAAW,SAAQ,aAA+C;IACpE,YAAY,KAAsB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,GAAuB,CAAC;QAE5B,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACjB,0BAA0B;YAC1B,kEAA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,QACX,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EACnB,KAAK,EAAE,IAAI,EACX,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EACzC,KAAK,EAAE;oBACH,GAAG,MAAM,CAAC,KAAK;oBACf,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;iBACpE,EACD,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,SAAS,GACtB,CACA,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Tabs, Tab } from '@mui/material';\n\nimport type { ConfigItemTabs } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport ConfigPanel from './ConfigPanel';\n\nconst styles: Record<string, React.CSSProperties> = {\n tabs: {\n height: '100%',\n width: '100%',\n },\n panel: {\n width: '100%',\n display: 'block',\n },\n panelWithIcons: {\n height: 'calc(100% - 72px)',\n },\n panelWithoutIcons: {\n height: 'calc(100% - 48px)',\n },\n};\n\ninterface ConfigTabsProps extends ConfigGenericProps {\n schema: ConfigItemTabs;\n dialogName?: string;\n}\n\ninterface ConfigTabsState extends ConfigGenericState {\n tab?: string;\n}\n\nclass ConfigTabs extends ConfigGeneric<ConfigTabsProps, ConfigTabsState> {\n constructor(props: ConfigTabsProps) {\n super(props);\n let tab: string | undefined;\n\n if (this.props.root) {\n // read the path from hash\n // #tab-instances/config/system.adapter.ping.0/<TAB-NAME-OR-INDEX>\n const hash = (window.location.hash || '').replace(/^#/, '').split('/');\n if (hash.length >= 3 && hash[1] === 'config') {\n const tabS = hash[3];\n const tabN = parseInt(tabS, 10);\n if (tabS && tabN.toString() === tabS) {\n if (tabN >= 0 && tabN < Object.keys(this.props.schema.items).length) {\n tab = Object.keys(this.props.schema.items)[tabN];\n }\n } else if (tabS && Object.keys(this.props.schema.items).includes(tabS)) {\n tab = tabS;\n }\n\n // install on hash change handler\n window.addEventListener('hashchange', this.onHashTabsChanged, false);\n }\n }\n\n if (tab === undefined) {\n tab =\n (((window as any)._localStorage as Storage) || window.localStorage).getItem(\n `${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`,\n ) || Object.keys(this.props.schema.items)[0];\n if (!Object.keys(this.props.schema.items).includes(tab)) {\n tab = Object.keys(this.props.schema.items)[0];\n }\n }\n\n Object.assign(this.state, { tab });\n }\n\n componentWillUnmount(): void {\n window.removeEventListener('hashchange', this.onHashTabsChanged, false);\n super.componentWillUnmount();\n }\n\n onHashTabsChanged = (): void => {\n const hash = (window.location.hash || '').replace(/^#/, '').split('/');\n if (hash.length > 3 && hash[1] === 'config') {\n const tabS = hash[3];\n const tabN = parseInt(tabS, 10);\n let tab;\n if (tabN.toString() === tabS) {\n if (tabN >= 0 && tabN < Object.keys(this.props.schema.items).length) {\n tab = Object.keys(this.props.schema.items)[tabN];\n }\n } else if (Object.keys(this.props.schema.items).includes(tabS)) {\n tab = tabS;\n }\n if (tab !== undefined && tab !== this.state.tab) {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`,\n tab,\n );\n this.setState({ tab });\n }\n }\n };\n\n render(): JSX.Element {\n const items = this.props.schema.items;\n let withIcons = false;\n\n return (\n <div style={styles.tabs}>\n <Tabs\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n style={this.props.schema.tabsStyle}\n value={this.state.tab}\n onChange={(e, tab) => {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`,\n tab,\n );\n this.setState({ tab }, () => {\n if (this.props.root) {\n const hash = (window.location.hash || '').split('/');\n if (hash.length >= 3 && hash[1] === 'config') {\n hash[3] = this.state.tab;\n window.location.hash = hash.join('/');\n }\n }\n });\n }}\n >\n {Object.keys(items).map(name => {\n let disabled: boolean;\n if (this.props.custom) {\n const hidden = this.executeCustom(\n items[name].hidden,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.index,\n this.props.globalData,\n );\n if (hidden) {\n return null;\n }\n disabled = this.executeCustom(\n items[name].disabled,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.index,\n this.props.globalData,\n ) as boolean;\n } else {\n const hidden: boolean = this.execute(\n items[name].hidden,\n false,\n this.props.data,\n this.props.index,\n this.props.globalData,\n ) as boolean;\n if (hidden) {\n return null;\n }\n disabled = this.execute(\n items[name].disabled,\n false,\n this.props.data,\n this.props.index,\n this.props.globalData,\n ) as boolean;\n }\n const icon = this.getIcon(items[name].icon);\n withIcons = withIcons || !!icon;\n\n return (\n <Tab\n id={name}\n wrapped\n disabled={disabled}\n key={name}\n value={name}\n iconPosition={this.props.schema.iconPosition || 'start'}\n icon={icon}\n label={this.getText(items[name].label)}\n />\n );\n })}\n </Tabs>\n <ConfigPanel\n oContext={this.props.oContext}\n isParentTab\n changed={this.props.changed}\n key={this.state.tab}\n index={1001}\n arrayIndex={this.props.arrayIndex}\n globalData={this.props.globalData}\n commandRunning={this.props.commandRunning}\n style={{\n ...styles.panel,\n ...(withIcons ? styles.panelWithIcons : styles.panelWithoutIcons),\n }}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={this.props.data}\n originalData={this.props.originalData}\n onChange={this.props.onChange}\n onError={this.props.onError}\n customObj={this.props.customObj}\n custom={this.props.custom}\n schema={items[this.state.tab]}\n table={this.props.table}\n withIcons={withIcons}\n />\n </div>\n );\n }\n}\n\nexport default ConfigTabs;\n"]}
1
+ {"version":3,"file":"ConfigTabs.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KAChB;IACD,KAAK,EAAE;QACH,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,OAAO;KACnB;IACD,cAAc,EAAE;QACZ,MAAM,EAAE,mBAAmB;KAC9B;IACD,iBAAiB,EAAE;QACf,MAAM,EAAE,mBAAmB;KAC9B;CACJ,CAAC;AAaF,MAAM,UAAW,SAAQ,aAA+C;IAC5D,aAAa,GAAyC,IAAI,CAAC;IAElD,MAAM,CAAkC;IAEzD,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CAAC,MAAM,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EACrC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,SAAS,GACtB,CACA,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Tabs, Tab, IconButton, Toolbar, Menu, MenuItem, ListItemIcon } from '@mui/material';\nimport { Menu as MenuIcon } from '@mui/icons-material';\n\nimport type { ConfigItemTabs } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport ConfigPanel from './ConfigPanel';\n\nconst styles: Record<string, React.CSSProperties> = {\n tabs: {\n height: '100%',\n width: '100%',\n },\n panel: {\n width: '100%',\n display: 'block',\n },\n panelWithIcons: {\n height: 'calc(100% - 72px)',\n },\n panelWithoutIcons: {\n height: 'calc(100% - 48px)',\n },\n};\n\ninterface ConfigTabsProps extends ConfigGenericProps {\n schema: ConfigItemTabs;\n dialogName?: string;\n}\n\ninterface ConfigTabsState extends ConfigGenericState {\n tab?: string;\n width: number;\n openMenu: HTMLButtonElement | null;\n}\n\nclass ConfigTabs extends ConfigGeneric<ConfigTabsProps, ConfigTabsState> {\n private resizeTimeout: ReturnType<typeof setTimeout> | null = null;\n\n private readonly refDiv: React.RefObject<HTMLDivElement>;\n\n constructor(props: ConfigTabsProps) {\n super(props);\n let tab: string | undefined;\n\n if (this.props.root) {\n // read the path from hash\n // #tab-instances/config/system.adapter.ping.0/<TAB-NAME-OR-INDEX>\n const hash = (window.location.hash || '').replace(/^#/, '').split('/');\n if (hash.length >= 3 && hash[1] === 'config') {\n const tabS = hash[3];\n const tabN = parseInt(tabS, 10);\n if (tabS && tabN.toString() === tabS) {\n if (tabN >= 0 && tabN < Object.keys(this.props.schema.items).length) {\n tab = Object.keys(this.props.schema.items)[tabN];\n }\n } else if (tabS && Object.keys(this.props.schema.items).includes(tabS)) {\n tab = tabS;\n }\n\n // install on hash change handler\n window.addEventListener('hashchange', this.onHashTabsChanged, false);\n }\n }\n\n if (tab === undefined) {\n tab =\n (((window as any)._localStorage as Storage) || window.localStorage).getItem(\n `${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`,\n ) || Object.keys(this.props.schema.items)[0];\n if (!Object.keys(this.props.schema.items).includes(tab)) {\n tab = Object.keys(this.props.schema.items)[0];\n }\n }\n this.refDiv = React.createRef();\n\n Object.assign(this.state, { tab, width: 0, openMenu: null });\n }\n\n componentWillUnmount(): void {\n if (this.resizeTimeout) {\n clearTimeout(this.resizeTimeout);\n this.resizeTimeout = null;\n }\n window.removeEventListener('hashchange', this.onHashTabsChanged, false);\n super.componentWillUnmount();\n }\n\n onHashTabsChanged = (): void => {\n const hash = (window.location.hash || '').replace(/^#/, '').split('/');\n if (hash.length > 3 && hash[1] === 'config') {\n const tabS = hash[3];\n const tabN = parseInt(tabS, 10);\n let tab;\n if (tabN.toString() === tabS) {\n if (tabN >= 0 && tabN < Object.keys(this.props.schema.items).length) {\n tab = Object.keys(this.props.schema.items)[tabN];\n }\n } else if (Object.keys(this.props.schema.items).includes(tabS)) {\n tab = tabS;\n }\n if (tab !== undefined && tab !== this.state.tab) {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`,\n tab,\n );\n this.setState({ tab });\n }\n }\n };\n\n getCurrentBreakpoint(): 'xs' | 'sm' | 'md' | 'lg' | 'xl' {\n if (!this.state.width) {\n return 'md';\n }\n if (this.state.width < 600) {\n return 'xs';\n }\n if (this.state.width < 900) {\n return 'sm';\n }\n if (this.state.width < 1200) {\n return 'md';\n }\n if (this.state.width < 1536) {\n return 'lg';\n }\n return 'xl';\n }\n\n componentDidUpdate(): void {\n if (this.refDiv.current?.clientWidth && this.refDiv.current.clientWidth !== this.state.width) {\n if (this.resizeTimeout) {\n clearTimeout(this.resizeTimeout);\n }\n this.resizeTimeout = setTimeout(() => {\n this.resizeTimeout = null;\n this.setState({ width: this.refDiv.current?.clientWidth });\n }, 50);\n }\n }\n\n onMenuChange(tab: string): void {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.dialogName || 'App'}.${this.props.oContext.adapterName}`,\n tab,\n );\n this.setState({ tab }, () => {\n if (this.props.root) {\n const hash = (window.location.hash || '').split('/');\n if (hash.length >= 3 && hash[1] === 'config') {\n hash[3] = this.state.tab;\n window.location.hash = hash.join('/');\n }\n }\n });\n }\n\n render(): JSX.Element {\n const items = this.props.schema.items;\n let withIcons = false;\n const elements: { icon: React.JSX.Element | null; label: string; name: string; disabled: boolean }[] = [];\n\n Object.keys(items).map(name => {\n let disabled: boolean;\n if (this.props.custom) {\n const hidden = this.executeCustom(\n items[name].hidden,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.index,\n this.props.globalData,\n );\n if (hidden) {\n return;\n }\n disabled = this.executeCustom(\n items[name].disabled,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.index,\n this.props.globalData,\n ) as boolean;\n } else {\n const hidden: boolean = this.execute(\n items[name].hidden,\n false,\n this.props.data,\n this.props.index,\n this.props.globalData,\n ) as boolean;\n if (hidden) {\n return;\n }\n disabled = this.execute(\n items[name].disabled,\n false,\n this.props.data,\n this.props.index,\n this.props.globalData,\n ) as boolean;\n }\n const icon = this.getIcon(items[name].icon);\n withIcons = withIcons || !!icon;\n elements.push({ icon, disabled, label: this.getText(items[name].label), name });\n });\n\n const currentBreakpoint = this.getCurrentBreakpoint();\n let tabs: React.JSX.Element;\n if (currentBreakpoint === 'xs' || currentBreakpoint === 'sm') {\n tabs = (\n <Toolbar\n style={{\n width: '100%',\n backgroundColor: this.props.oContext.themeType === 'dark' ? '#222' : '#DDD',\n }}\n variant=\"dense\"\n >\n <IconButton\n onClick={(event: React.MouseEvent<HTMLButtonElement>) =>\n this.setState({ openMenu: event.currentTarget })\n }\n >\n <MenuIcon />\n </IconButton>\n {this.state.openMenu ? (\n <Menu\n open={!0}\n anchorEl={this.state.openMenu}\n onClose={() => this.setState({ openMenu: null })}\n >\n {elements.map(el => {\n return (\n <MenuItem\n disabled={el.disabled}\n key={el.name}\n onClick={() => {\n this.setState({ openMenu: null }, () => this.onMenuChange(el.name));\n }}\n selected={el.name === this.state.tab}\n >\n {withIcons ? <ListItemIcon>{el.icon}</ListItemIcon> : null}\n {el.label}\n </MenuItem>\n );\n })}\n </Menu>\n ) : null}\n </Toolbar>\n );\n } else {\n tabs = (\n <Tabs\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n style={this.props.schema.tabsStyle}\n value={this.state.tab}\n onChange={(_e, tab: string): void => this.onMenuChange(tab)}\n >\n {elements.map(el => {\n return (\n <Tab\n id={el.name}\n wrapped\n disabled={el.disabled}\n key={el.name}\n value={el.name}\n iconPosition={this.props.schema.iconPosition || 'start'}\n icon={el.icon}\n label={el.label}\n />\n );\n })}\n </Tabs>\n );\n }\n\n return (\n <div\n style={styles.tabs}\n ref={this.refDiv}\n >\n {tabs}\n <ConfigPanel\n oContext={this.props.oContext}\n isParentTab\n changed={this.props.changed}\n key={this.state.tab}\n index={1001}\n arrayIndex={this.props.arrayIndex}\n globalData={this.props.globalData}\n commandRunning={this.props.commandRunning}\n style={{\n ...styles.panel,\n ...(withIcons ? styles.panelWithIcons : styles.panelWithoutIcons),\n }}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={this.props.data}\n originalData={this.props.originalData}\n onChange={this.props.onChange}\n onError={this.props.onError}\n customObj={this.props.customObj}\n custom={this.props.custom}\n schema={items[this.state.tab]}\n table={this.props.table}\n withIcons={withIcons}\n />\n </div>\n );\n }\n}\n\nexport default ConfigTabs;\n"]}
package/build/types.d.ts CHANGED
@@ -5,6 +5,7 @@ import type {
5
5
  ObjectBrowserCustomFilter,
6
6
  ObjectBrowserType,
7
7
  ThemeType,
8
+ ThemeName,
8
9
  } from '@iobroker/adapter-react-v5';
9
10
  import type { ConfigGeneric, DeviceManagerPropsProps } from '#JC/JsonConfigComponent/ConfigGeneric';
10
11
 
@@ -779,6 +780,8 @@ export interface ConfigItemTable extends ConfigItem {
779
780
  uniqueColumns?: string[];
780
781
  /** These items will be encrypted before saving with simple (not SHA) encryption method */
781
782
  encryptedAttributes?: string[];
783
+ /** Breakpoint that will be rendered as cards */
784
+ useCardFor?: ('xs' | 'sm' | 'md' | 'lg' | 'xl')[];
782
785
  }
783
786
 
784
787
  export interface ConfigItemTimePicker extends ConfigItem {
@@ -1006,18 +1009,24 @@ export type ConfigItemAny =
1006
1009
  | ConfigItemQrCode;
1007
1010
 
1008
1011
  export type JsonConfigContext = {
1009
- DeviceManager?: React.FC<DeviceManagerPropsProps>;
1010
1012
  adapterName: string;
1013
+ dateFormat: string;
1014
+ forceUpdate: (attr: string | string[], data: any) => void;
1015
+ instance: number;
1016
+ isFloatComma: boolean;
1017
+ socket: AdminConnection;
1018
+ systemConfig: ioBroker.SystemConfigCommon;
1019
+ theme: IobTheme;
1020
+ themeType: ThemeType;
1021
+ _themeName: ThemeName;
1022
+
1023
+ DeviceManager?: React.FC<DeviceManagerPropsProps>;
1011
1024
  changeLanguage?: () => void;
1012
1025
  customs?: Record<string, typeof ConfigGeneric>;
1013
- dateFormat: string;
1014
1026
  embedded?: boolean;
1015
1027
  expertMode?: boolean;
1016
- forceUpdate: (attr: string | string[], data: any) => void;
1017
1028
  imagePrefix?: string;
1018
- instance: number;
1019
1029
  instanceObj?: ioBroker.InstanceObject;
1020
- isFloatComma: boolean;
1021
1030
  /** If true, this field edits multiple data points at once and thus contains an array, should not be saved if not changed */
1022
1031
  multiEdit?: boolean;
1023
1032
  /** Backend request to refresh data */
@@ -1025,11 +1034,6 @@ export type JsonConfigContext = {
1025
1034
  onCommandRunning: (commandRunning: boolean) => void;
1026
1035
  onValueChange?: (attr: string, value: any, saveConfig: boolean) => void;
1027
1036
  registerOnForceUpdate?: (attr: string, cb?: (data: any) => void) => void;
1028
- socket: AdminConnection;
1029
- systemConfig: ioBroker.SystemConfigCommon;
1030
- theme: IobTheme;
1031
- themeType: ThemeType;
1032
- _themeName: ThemeName;
1033
1037
  };
1034
1038
 
1035
1039
  // Notification GUI
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iobroker/json-config",
3
3
  "description": "This package contains the ioBroker JSON config UI components",
4
- "version": "7.4.13",
4
+ "version": "7.4.15",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
7
  "scripts": {
@@ -18,7 +18,7 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@iobroker/adapter-react-v5": "7.4.13",
21
+ "@iobroker/adapter-react-v5": "7.4.15",
22
22
  "@mui/x-date-pickers": "^7.23.0",
23
23
  "crypto-js": "^4.2.0",
24
24
  "react-ace": "^13.0.0",
@@ -34,5 +34,5 @@
34
34
  "build/",
35
35
  "LICENSE"
36
36
  ],
37
- "gitHead": "15a253034892cbc6eea2ed8884b7d6ad02b7d162"
37
+ "gitHead": "f03fbf8452636f396acf33277562a4572d629317"
38
38
  }