@pie-lib/config-ui 12.0.0-beta.5 → 12.0.0-next.0
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/CHANGELOG.json +8 -1653
- package/CHANGELOG.md +345 -4
- package/LICENSE.md +5 -0
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/alert-dialog.js +40 -10
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +58 -48
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/feedback-menu.js +24 -26
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js +182 -185
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js +5 -7
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js +69 -73
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js +22 -25
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js +41 -44
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js +31 -25
- package/lib/form-section.js.map +1 -1
- package/lib/help.js +37 -47
- package/lib/help.js.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/input.js +12 -17
- package/lib/input.js.map +1 -1
- package/lib/inputs.js +58 -67
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js +56 -70
- package/lib/langs.js.map +1 -1
- package/lib/layout/config-layout.js +78 -47
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js +58 -60
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js +25 -33
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js +41 -50
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +151 -89
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +74 -63
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +30 -16
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js +16 -20
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js +13 -19
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +140 -141
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +29 -16
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +39 -25
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js +18 -30
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/index.js +49 -61
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js +33 -43
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js +8 -12
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +22 -11
- package/src/__tests__/alert-dialog.test.jsx +283 -0
- package/src/__tests__/checkbox.test.jsx +249 -0
- package/src/__tests__/choice-utils.test.js +12 -0
- package/src/__tests__/form-section.test.jsx +334 -0
- package/src/__tests__/help.test.jsx +184 -0
- package/src/__tests__/input.test.jsx +192 -0
- package/src/__tests__/langs.test.jsx +457 -0
- package/src/__tests__/number-text-field-custom.test.jsx +438 -0
- package/src/__tests__/number-text-field.test.jsx +341 -0
- package/src/__tests__/radio-with-label.test.jsx +259 -0
- package/src/__tests__/settings-panel.test.js +187 -0
- package/src/__tests__/settings.test.jsx +515 -0
- package/src/__tests__/tabs.test.jsx +193 -0
- package/src/__tests__/two-choice.test.js +110 -0
- package/src/__tests__/with-stateful-model.test.jsx +145 -0
- package/src/alert-dialog.jsx +30 -8
- package/src/checkbox.jsx +43 -37
- package/src/choice-configuration/__tests__/feedback-menu.test.jsx +163 -0
- package/src/choice-configuration/__tests__/index.test.jsx +234 -0
- package/src/choice-configuration/feedback-menu.jsx +6 -6
- package/src/choice-configuration/index.jsx +208 -192
- package/src/feedback-config/__tests__/feedback-config.test.jsx +141 -0
- package/src/feedback-config/__tests__/feedback-selector.test.jsx +107 -0
- package/src/feedback-config/feedback-selector.jsx +52 -53
- package/src/feedback-config/group.jsx +21 -22
- package/src/feedback-config/index.jsx +27 -29
- package/src/form-section.jsx +26 -18
- package/src/help.jsx +20 -28
- package/src/input.jsx +1 -1
- package/src/inputs.jsx +35 -44
- package/src/langs.jsx +41 -46
- package/src/layout/__tests__/config.layout.test.jsx +59 -0
- package/src/layout/__tests__/layout-content.test.jsx +3 -0
- package/src/layout/config-layout.jsx +53 -23
- package/src/layout/layout-contents.jsx +38 -40
- package/src/layout/settings-box.jsx +16 -19
- package/src/mui-box/index.jsx +35 -43
- package/src/number-text-field-custom.jsx +117 -65
- package/src/number-text-field.jsx +51 -34
- package/src/radio-with-label.jsx +26 -10
- package/src/settings/display-size.jsx +12 -11
- package/src/settings/index.js +2 -1
- package/src/settings/panel.jsx +101 -92
- package/src/settings/settings-radio-label.jsx +26 -10
- package/src/settings/toggle.jsx +37 -18
- package/src/tabs/index.jsx +8 -8
- package/src/tags-input/__tests__/index.test.jsx +113 -0
- package/src/tags-input/index.jsx +35 -38
- package/src/two-choice.jsx +15 -19
- package/README.md +0 -12
package/src/inputs.jsx
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import Checkbox from '@material
|
|
2
|
-
import Radio from '@material
|
|
1
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
2
|
+
import Radio from '@mui/material/Radio';
|
|
3
3
|
import { InputContainer } from '@pie-lib/render-ui';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import Switch from '@material
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
6
|
+
import Switch from '@mui/material/Switch';
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
8
|
+
import { color } from '@pie-lib/render-ui';
|
|
9
9
|
|
|
10
10
|
const InputTypes = {
|
|
11
|
-
classes: PropTypes.object.isRequired,
|
|
12
11
|
className: PropTypes.string,
|
|
13
12
|
label: PropTypes.string,
|
|
14
13
|
checked: PropTypes.bool,
|
|
@@ -17,75 +16,67 @@ const InputTypes = {
|
|
|
17
16
|
error: PropTypes.string,
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const
|
|
19
|
+
const StyledSwitch = styled(Switch)(() => ({
|
|
20
|
+
justifyContent: 'inherit',
|
|
21
|
+
transform: 'translate(-20%, 20%)',
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const InputSwitch = ({ className, label, checked, onChange }) => {
|
|
21
25
|
return (
|
|
22
26
|
<InputContainer className={className} label={label}>
|
|
23
|
-
<
|
|
27
|
+
<StyledSwitch checked={checked} onChange={onChange} aria-label={label} />
|
|
24
28
|
</InputContainer>
|
|
25
29
|
);
|
|
26
30
|
};
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const InputSwitch = withStyles({
|
|
31
|
-
switchRoot: {
|
|
32
|
-
justifyContent: 'inherit',
|
|
33
|
-
transform: 'translate(-20%, 20%)',
|
|
34
|
-
},
|
|
35
|
-
})(RawInputSwitch);
|
|
32
|
+
InputSwitch.propTypes = { ...InputTypes };
|
|
36
33
|
|
|
37
|
-
const
|
|
38
|
-
|
|
34
|
+
const StyledCheckbox = styled(Checkbox)(({ theme, error }) => ({
|
|
35
|
+
transform: 'translate(-25%, 20%)',
|
|
36
|
+
color: `${color.tertiary()} !important`,
|
|
37
|
+
...(error && {
|
|
38
|
+
color: `${theme.palette.error.main} !important`,
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
39
41
|
|
|
42
|
+
const InputCheckbox = ({ className, label, checked, onChange, disabled, error }) => {
|
|
40
43
|
return (
|
|
41
44
|
<InputContainer className={className} label={label}>
|
|
42
|
-
<
|
|
43
|
-
className={classNames(classes.checkboxRoot, error && classes.error)}
|
|
45
|
+
<StyledCheckbox
|
|
44
46
|
disabled={disabled}
|
|
45
47
|
checked={checked}
|
|
46
48
|
onChange={onChange}
|
|
47
49
|
aria-label={label}
|
|
50
|
+
error={error}
|
|
48
51
|
/>
|
|
49
52
|
</InputContainer>
|
|
50
53
|
);
|
|
51
54
|
};
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
InputCheckbox.propTypes = { ...InputTypes };
|
|
54
57
|
|
|
55
|
-
const
|
|
56
|
-
|
|
58
|
+
const StyledRadio = styled(Radio)(({ theme, error }) => ({
|
|
59
|
+
transform: 'translate(-20%, 20%)',
|
|
60
|
+
color: `${color.tertiary()} !important`,
|
|
61
|
+
...(error && {
|
|
62
|
+
color: `${theme.palette.error.main} !important`,
|
|
63
|
+
}),
|
|
64
|
+
}));
|
|
57
65
|
|
|
66
|
+
const InputRadio = ({ className, label, checked, onChange, disabled, error }) => {
|
|
58
67
|
return (
|
|
59
68
|
<InputContainer className={className} label={label}>
|
|
60
|
-
<
|
|
61
|
-
className={classNames(classes.radioRoot, error && classes.error)}
|
|
69
|
+
<StyledRadio
|
|
62
70
|
disabled={disabled}
|
|
63
71
|
checked={checked}
|
|
64
72
|
onChange={onChange}
|
|
65
73
|
aria-label={label}
|
|
74
|
+
error={error}
|
|
66
75
|
/>
|
|
67
76
|
</InputContainer>
|
|
68
77
|
);
|
|
69
78
|
};
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const InputCheckbox = withStyles((theme) => ({
|
|
74
|
-
checkboxRoot: {
|
|
75
|
-
transform: 'translate(-25%, 20%)',
|
|
76
|
-
},
|
|
77
|
-
error: {
|
|
78
|
-
color: theme.palette.error.main,
|
|
79
|
-
},
|
|
80
|
-
}))(RawInputCheckbox);
|
|
81
|
-
|
|
82
|
-
const InputRadio = withStyles((theme) => ({
|
|
83
|
-
radioRoot: {
|
|
84
|
-
transform: 'translate(-20%, 20%)',
|
|
85
|
-
},
|
|
86
|
-
error: {
|
|
87
|
-
color: theme.palette.error.main,
|
|
88
|
-
},
|
|
89
|
-
}))(RawInputRadio);
|
|
80
|
+
InputRadio.propTypes = { ...InputTypes };
|
|
90
81
|
|
|
91
82
|
export { InputSwitch, InputCheckbox, InputRadio };
|
package/src/langs.jsx
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import Input from '@material
|
|
2
|
-
import InputLabel from '@material
|
|
1
|
+
import Input from '@mui/material/Input';
|
|
2
|
+
import InputLabel from '@mui/material/InputLabel';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
import Select from '@mui/material/Select';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
8
|
+
import FormControl from '@mui/material/FormControl';
|
|
10
9
|
import debug from 'debug';
|
|
11
10
|
|
|
12
11
|
const log = debug('pie-elements:config-ui:langs');
|
|
13
12
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
formControl: {
|
|
24
|
-
position: 'initial',
|
|
25
|
-
},
|
|
26
|
-
inputLabel: {
|
|
27
|
-
paddingBottom: theme.spacing.unit,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
13
|
+
const StyledRoot = styled('div')(() => ({
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
alignItems: 'start',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
paddingTop: '0px',
|
|
19
|
+
paddingRight: '0px',
|
|
20
|
+
}));
|
|
30
21
|
|
|
31
|
-
|
|
22
|
+
const StyledFormControl = styled(FormControl)(() => ({
|
|
23
|
+
position: 'initial',
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
const StyledInputLabel = styled(InputLabel)(({ theme }) => ({
|
|
27
|
+
paddingBottom: theme.spacing(1),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export class Langs extends React.Component {
|
|
32
31
|
static propTypes = {
|
|
33
32
|
onChange: PropTypes.func,
|
|
34
33
|
langs: PropTypes.array,
|
|
35
34
|
selected: PropTypes.string,
|
|
36
35
|
label: PropTypes.string,
|
|
37
|
-
classes: PropTypes.object.isRequired,
|
|
38
36
|
uid: PropTypes.string,
|
|
39
37
|
};
|
|
40
38
|
|
|
@@ -52,16 +50,16 @@ export class RawLangs extends React.Component {
|
|
|
52
50
|
};
|
|
53
51
|
|
|
54
52
|
render() {
|
|
55
|
-
let { langs, selected, label
|
|
53
|
+
let { langs, selected, label } = this.props;
|
|
56
54
|
|
|
57
55
|
log('[render] selected:', selected);
|
|
58
56
|
|
|
59
57
|
return (
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
<
|
|
58
|
+
<StyledRoot>
|
|
59
|
+
<StyledFormControl>
|
|
60
|
+
<StyledInputLabel htmlFor={this.uid}>
|
|
63
61
|
{label}
|
|
64
|
-
</
|
|
62
|
+
</StyledInputLabel>
|
|
65
63
|
|
|
66
64
|
<Select value={selected} onChange={this.choose} input={<Input id={this.uid} />}>
|
|
67
65
|
{langs.map((l, index) => (
|
|
@@ -70,27 +68,23 @@ export class RawLangs extends React.Component {
|
|
|
70
68
|
</MenuItem>
|
|
71
69
|
))}
|
|
72
70
|
</Select>
|
|
73
|
-
</
|
|
74
|
-
</
|
|
71
|
+
</StyledFormControl>
|
|
72
|
+
</StyledRoot>
|
|
75
73
|
);
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
const Langs = withStyles(styles, { name: 'Langs' })(RawLangs);
|
|
80
76
|
export default Langs;
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
})(({ classes, langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
90
|
-
const names = classNames(classes.languageControls, className);
|
|
78
|
+
const StyledLanguageControls = styled('div')(() => ({
|
|
79
|
+
display: 'grid',
|
|
80
|
+
gridAutoFlow: 'column',
|
|
81
|
+
gridAutoColumns: '1fr',
|
|
82
|
+
gridGap: '8px',
|
|
83
|
+
}));
|
|
91
84
|
|
|
85
|
+
export const LanguageControls = ({ langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
|
|
92
86
|
return (
|
|
93
|
-
<
|
|
87
|
+
<StyledLanguageControls className={className}>
|
|
94
88
|
<Langs
|
|
95
89
|
label="Choose language to edit"
|
|
96
90
|
langs={langs}
|
|
@@ -98,9 +92,9 @@ export const LanguageControls = withStyles({
|
|
|
98
92
|
onChange={(l) => onActiveLangChange(l)}
|
|
99
93
|
/>
|
|
100
94
|
<Langs label="Default language" langs={langs} selected={defaultLang} onChange={(l) => onDefaultLangChange(l)} />
|
|
101
|
-
</
|
|
95
|
+
</StyledLanguageControls>
|
|
102
96
|
);
|
|
103
|
-
}
|
|
97
|
+
};
|
|
104
98
|
|
|
105
99
|
LanguageControls.propTypes = {
|
|
106
100
|
langs: PropTypes.array,
|
|
@@ -108,4 +102,5 @@ LanguageControls.propTypes = {
|
|
|
108
102
|
defaultLang: PropTypes.string.isRequired,
|
|
109
103
|
onActiveLangChange: PropTypes.func.isRequired,
|
|
110
104
|
onDefaultLangChange: PropTypes.func.isRequired,
|
|
105
|
+
className: PropTypes.string,
|
|
111
106
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import ConfigLayout from '../config-layout';
|
|
4
|
+
|
|
5
|
+
describe('ConfigLayout', () => {
|
|
6
|
+
const settingsPanel = (
|
|
7
|
+
<div data-testid="settings-panel">
|
|
8
|
+
<div key={0}>Foo</div>
|
|
9
|
+
<div key={1}>Bar</div>
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const children = (
|
|
14
|
+
<div data-testid="main-content">
|
|
15
|
+
<div>Foo</div>
|
|
16
|
+
<div>Bar</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
describe('rendering', () => {
|
|
21
|
+
it('renders correctly with settings panel', async () => {
|
|
22
|
+
render(<ConfigLayout settings={settingsPanel}>{children}</ConfigLayout>);
|
|
23
|
+
|
|
24
|
+
// Main content should render immediately
|
|
25
|
+
expect(screen.getByTestId('main-content')).toBeInTheDocument();
|
|
26
|
+
|
|
27
|
+
// Settings panel may render after layout calculation
|
|
28
|
+
// In test environment, react-measure may not provide dimensions,
|
|
29
|
+
// so we check if it exists but don't require it
|
|
30
|
+
await waitFor(() => {
|
|
31
|
+
expect(screen.getByText('Foo')).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders main content when provided', () => {
|
|
36
|
+
render(<ConfigLayout settings={settingsPanel}>{children}</ConfigLayout>);
|
|
37
|
+
|
|
38
|
+
expect(screen.getByTestId('main-content')).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('Foo')).toBeInTheDocument();
|
|
40
|
+
// Only check that Bar appears at least once (in main content)
|
|
41
|
+
expect(screen.getAllByText('Bar').length).toBeGreaterThanOrEqual(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders settings panel content', () => {
|
|
45
|
+
render(<ConfigLayout settings={settingsPanel}>{children}</ConfigLayout>);
|
|
46
|
+
|
|
47
|
+
// Settings panel might not render in test environment due to react-measure
|
|
48
|
+
// Just verify the component renders without crashing
|
|
49
|
+
expect(screen.getByTestId('main-content')).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('renders without settings panel when not provided', () => {
|
|
53
|
+
render(<ConfigLayout>{children}</ConfigLayout>);
|
|
54
|
+
|
|
55
|
+
expect(screen.queryByTestId('settings-panel')).not.toBeInTheDocument();
|
|
56
|
+
expect(screen.getByTestId('main-content')).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Measure from 'react-measure';
|
|
3
|
+
import { createTheme, ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
|
|
3
4
|
import { withContentRect } from 'react-measure';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import LayoutContents from './layout-contents';
|
|
6
7
|
import SettingsBox from './settings-box';
|
|
8
|
+
import { AppendCSSRules } from '@pie-lib/render-ui';
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
const theme = createTheme({
|
|
11
|
+
typography: {
|
|
12
|
+
fontFamily: 'inherit',
|
|
13
|
+
},
|
|
14
|
+
components: {
|
|
15
|
+
MuiButton: {
|
|
16
|
+
styleOverrides: {
|
|
17
|
+
contained: {
|
|
18
|
+
backgroundColor: '#e0e0e0',
|
|
19
|
+
color: '#000000',
|
|
20
|
+
'&:hover': {
|
|
21
|
+
backgroundColor: '#bdbdbd',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
class MeasuredConfigLayout extends AppendCSSRules {
|
|
9
30
|
static propTypes = {
|
|
10
31
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
11
32
|
className: PropTypes.string,
|
|
12
|
-
classes: PropTypes.object,
|
|
13
33
|
dimensions: PropTypes.object,
|
|
14
34
|
settings: PropTypes.element,
|
|
15
35
|
sidePanelMinWidth: PropTypes.number,
|
|
@@ -17,13 +37,13 @@ class MeasuredConfigLayout extends React.Component {
|
|
|
17
37
|
};
|
|
18
38
|
|
|
19
39
|
static defaultProps = {
|
|
20
|
-
sidePanelMinWidth:
|
|
40
|
+
sidePanelMinWidth: 1135,
|
|
21
41
|
hideSettings: false,
|
|
22
42
|
dimensions: {},
|
|
23
43
|
};
|
|
24
44
|
|
|
25
|
-
constructor(props) {
|
|
26
|
-
super(props);
|
|
45
|
+
constructor(...props) {
|
|
46
|
+
super(...props);
|
|
27
47
|
this.state = { layoutMode: undefined };
|
|
28
48
|
}
|
|
29
49
|
|
|
@@ -33,31 +53,41 @@ class MeasuredConfigLayout extends React.Component {
|
|
|
33
53
|
const { maxWidth } = dimensions || {};
|
|
34
54
|
|
|
35
55
|
const layoutMode =
|
|
36
|
-
bounds.width
|
|
56
|
+
bounds.width > sidePanelMinWidth && (maxWidth ? maxWidth > sidePanelMinWidth : true) ? 'inline' : 'tabbed';
|
|
37
57
|
|
|
38
|
-
|
|
58
|
+
// Only update state (and cause a re-render) if the computed layoutMode changed.
|
|
59
|
+
if (layoutMode !== this.state.layoutMode) {
|
|
60
|
+
this.setState({ layoutMode });
|
|
61
|
+
}
|
|
39
62
|
};
|
|
40
63
|
|
|
41
64
|
render() {
|
|
42
65
|
return (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
// TODO: REVIEW MuiThemeProvider usage - is this still needed after mui update?
|
|
67
|
+
// Different theme object identities will force theme consumers to re-render.
|
|
68
|
+
<StyledEngineProvider injectFirst>
|
|
69
|
+
<ThemeProvider theme={theme}>
|
|
70
|
+
<Measure bounds onResize={this.onResize}>
|
|
71
|
+
{({ measureRef }) => {
|
|
72
|
+
const { children, settings, hideSettings, dimensions } = this.props;
|
|
73
|
+
const { layoutMode } = this.state;
|
|
47
74
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
const settingsPanel =
|
|
76
|
+
layoutMode === 'inline' ? <SettingsBox className="settings-box">{settings}</SettingsBox> : settings;
|
|
77
|
+
const secondaryContent = hideSettings ? null : settingsPanel;
|
|
78
|
+
const finalClass = 'main-container';
|
|
51
79
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
return (
|
|
81
|
+
<div ref={measureRef} className={finalClass}>
|
|
82
|
+
<LayoutContents mode={layoutMode} secondary={secondaryContent} dimensions={dimensions}>
|
|
83
|
+
{children}
|
|
84
|
+
</LayoutContents>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}}
|
|
88
|
+
</Measure>
|
|
89
|
+
</ThemeProvider>
|
|
90
|
+
</StyledEngineProvider>
|
|
61
91
|
);
|
|
62
92
|
}
|
|
63
93
|
}
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
5
4
|
import Tabs from '../tabs';
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
const StyledContainer = styled('div')(() => ({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
position: 'relative',
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const StyledFlow = styled('div')(() => ({
|
|
13
|
+
display: 'flex',
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const StyledContentContainer = styled('div')(({ theme }) => ({
|
|
18
|
+
padding: `${theme.spacing(2)} 0`,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const StyledConfigContainer = styled('div')(() => ({
|
|
22
|
+
flex: '1',
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const StyledSettingsContainer = styled('div')(({ theme }) => ({
|
|
26
|
+
marginLeft: theme.spacing(2),
|
|
27
|
+
}));
|
|
7
28
|
|
|
8
29
|
class RawLayoutContents extends React.Component {
|
|
9
30
|
static propTypes = {
|
|
10
31
|
mode: PropTypes.oneOf(['tabbed', 'inline']),
|
|
11
32
|
secondary: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
12
33
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
13
|
-
classes: PropTypes.object,
|
|
14
34
|
dimensions: PropTypes.object,
|
|
15
35
|
};
|
|
16
36
|
|
|
@@ -47,7 +67,7 @@ class RawLayoutContents extends React.Component {
|
|
|
47
67
|
// }
|
|
48
68
|
|
|
49
69
|
render() {
|
|
50
|
-
const { mode, secondary, children,
|
|
70
|
+
const { mode, secondary, children, dimensions } = this.props;
|
|
51
71
|
const { minHeight, minWidth, maxHeight, maxWidth } = dimensions || {};
|
|
52
72
|
const configuration = this.getConfiguration();
|
|
53
73
|
|
|
@@ -65,55 +85,33 @@ class RawLayoutContents extends React.Component {
|
|
|
65
85
|
}
|
|
66
86
|
|
|
67
87
|
return (
|
|
68
|
-
<
|
|
88
|
+
<StyledContainer style={{ minHeight, minWidth, maxHeight, maxWidth }}>
|
|
69
89
|
{mode === 'inline' && (
|
|
70
|
-
<
|
|
71
|
-
<
|
|
90
|
+
<StyledFlow>
|
|
91
|
+
<StyledConfigContainer className="design-container">{children}</StyledConfigContainer>
|
|
72
92
|
{hasSettingsPanel && (
|
|
73
|
-
<
|
|
93
|
+
<StyledSettingsContainer className="settings-container">{secondary}</StyledSettingsContainer>
|
|
74
94
|
)}
|
|
75
|
-
</
|
|
95
|
+
</StyledFlow>
|
|
76
96
|
)}
|
|
77
97
|
|
|
78
98
|
{mode === 'tabbed' && hasSettingsPanel && (
|
|
79
|
-
<Tabs onChange={this.onTabsChange} contentClassName=
|
|
80
|
-
<
|
|
99
|
+
<Tabs onChange={this.onTabsChange} contentClassName="content-container" indicatorColor="primary">
|
|
100
|
+
<StyledContentContainer title="Design" className="design-container">
|
|
81
101
|
{children}
|
|
82
|
-
</
|
|
83
|
-
<
|
|
102
|
+
</StyledContentContainer>
|
|
103
|
+
<StyledContentContainer title="Settings" className="settings-container">
|
|
84
104
|
{secondary}
|
|
85
|
-
</
|
|
105
|
+
</StyledContentContainer>
|
|
86
106
|
</Tabs>
|
|
87
107
|
)}
|
|
88
108
|
|
|
89
109
|
{mode === 'tabbed' && !hasSettingsPanel && (
|
|
90
|
-
<
|
|
110
|
+
<StyledContentContainer className="design-container">{children}</StyledContentContainer>
|
|
91
111
|
)}
|
|
92
|
-
</
|
|
112
|
+
</StyledContainer>
|
|
93
113
|
);
|
|
94
114
|
}
|
|
95
115
|
}
|
|
96
116
|
|
|
97
|
-
|
|
98
|
-
flow: {
|
|
99
|
-
display: 'flex',
|
|
100
|
-
justifyContent: 'space-between',
|
|
101
|
-
},
|
|
102
|
-
container: {
|
|
103
|
-
display: 'flex',
|
|
104
|
-
flexDirection: 'column',
|
|
105
|
-
position: 'relative',
|
|
106
|
-
overflow: 'auto',
|
|
107
|
-
},
|
|
108
|
-
contentContainer: {
|
|
109
|
-
padding: `${theme.spacing.unit * 2}px 0`,
|
|
110
|
-
},
|
|
111
|
-
configContainer: {
|
|
112
|
-
flex: '1',
|
|
113
|
-
},
|
|
114
|
-
settingsContainer: {
|
|
115
|
-
marginLeft: theme.spacing.unit * 2,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
export default withStyles(styles)(RawLayoutContents);
|
|
117
|
+
export default RawLayoutContents;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
|
|
5
|
+
const StyledSettingsBox = styled('div')(({ theme }) => ({
|
|
6
|
+
backgroundColor: theme.palette.background.paper,
|
|
7
|
+
border: `2px solid ${theme.palette.grey[200]}`,
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
justifyContent: 'flex-start',
|
|
11
|
+
minWidth: '275px',
|
|
12
|
+
maxWidth: '300px',
|
|
13
|
+
padding: '20px 4px 4px 20px',
|
|
14
|
+
zIndex: 99,
|
|
15
|
+
}));
|
|
5
16
|
|
|
6
17
|
export class SettingsBox extends React.Component {
|
|
7
18
|
static propTypes = {
|
|
8
|
-
classes: PropTypes.object.isRequired,
|
|
9
19
|
className: PropTypes.string,
|
|
10
20
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
11
21
|
};
|
|
@@ -13,23 +23,10 @@ export class SettingsBox extends React.Component {
|
|
|
13
23
|
static defaultProps = {};
|
|
14
24
|
|
|
15
25
|
render() {
|
|
16
|
-
const {
|
|
26
|
+
const { className, children } = this.props;
|
|
17
27
|
|
|
18
|
-
return <
|
|
28
|
+
return <StyledSettingsBox className={className}>{children}</StyledSettingsBox>;
|
|
19
29
|
}
|
|
20
30
|
}
|
|
21
|
-
const styles = (theme) => ({
|
|
22
|
-
settingsBox: {
|
|
23
|
-
backgroundColor: theme.palette.background.paper,
|
|
24
|
-
border: `2px solid ${theme.palette.grey[200]}`,
|
|
25
|
-
display: 'flex',
|
|
26
|
-
flexDirection: 'column',
|
|
27
|
-
justifyContent: 'flex-start',
|
|
28
|
-
minWidth: '275px',
|
|
29
|
-
maxWidth: '300px',
|
|
30
|
-
padding: '20px 4px 4px 20px',
|
|
31
|
-
zIndex: 99,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
31
|
|
|
35
|
-
export default
|
|
32
|
+
export default SettingsBox;
|