@pie-lib/config-ui 13.1.0-beta.9 → 14.0.0-next.36

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 (167) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +11 -0
  2. package/dist/alert-dialog.d.ts +44 -0
  3. package/dist/alert-dialog.js +47 -0
  4. package/dist/checkbox.d.ts +34 -0
  5. package/dist/checkbox.js +57 -0
  6. package/dist/choice-configuration/feedback-menu.d.ts +32 -0
  7. package/dist/choice-configuration/feedback-menu.js +85 -0
  8. package/dist/choice-configuration/index.d.ts +62 -0
  9. package/dist/choice-configuration/index.js +240 -0
  10. package/dist/choice-utils.d.ts +21 -0
  11. package/dist/choice-utils.js +15 -0
  12. package/dist/feedback-config/feedback-selector.d.ts +33 -0
  13. package/dist/feedback-config/feedback-selector.js +92 -0
  14. package/dist/feedback-config/group.d.ts +21 -0
  15. package/dist/feedback-config/group.js +33 -0
  16. package/dist/feedback-config/index.d.ts +48 -0
  17. package/dist/feedback-config/index.js +96 -0
  18. package/dist/form-section.d.ts +25 -0
  19. package/dist/form-section.js +25 -0
  20. package/dist/fraction-to-number.d.ts +7 -0
  21. package/dist/fraction-to-number.js +9 -0
  22. package/dist/help.d.ts +41 -0
  23. package/dist/help.js +62 -0
  24. package/dist/index.d.ts +31 -0
  25. package/dist/index.js +34 -0
  26. package/dist/input.d.ts +29 -0
  27. package/dist/input.js +65 -0
  28. package/dist/inputs.d.ts +63 -0
  29. package/dist/inputs.js +70 -0
  30. package/dist/langs.d.ts +41 -0
  31. package/dist/langs.js +76 -0
  32. package/dist/layout/config-layout.d.ts +10 -0
  33. package/dist/layout/config-layout.js +75 -0
  34. package/dist/layout/index.d.ts +11 -0
  35. package/dist/layout/index.js +10 -0
  36. package/dist/layout/layout-contents.d.ts +21 -0
  37. package/dist/layout/layout-contents.js +70 -0
  38. package/dist/layout/settings-box.d.ts +19 -0
  39. package/dist/layout/settings-box.js +32 -0
  40. package/dist/mui-box/index.d.ts +21 -0
  41. package/dist/mui-box/index.js +47 -0
  42. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  43. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
  44. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  45. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
  46. package/dist/node_modules/.bun/react-measure@2.5.2_6dbf9a050bc9aadb/node_modules/react-measure/dist/index.esm.js +122 -0
  47. package/dist/node_modules/.bun/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +276 -0
  48. package/dist/number-text-field-custom.d.ts +51 -0
  49. package/dist/number-text-field-custom.js +192 -0
  50. package/dist/number-text-field.d.ts +47 -0
  51. package/dist/number-text-field.js +122 -0
  52. package/dist/radio-with-label.d.ts +25 -0
  53. package/dist/radio-with-label.js +27 -0
  54. package/dist/settings/display-size.d.ts +26 -0
  55. package/dist/settings/display-size.js +45 -0
  56. package/dist/settings/index.d.ts +45 -0
  57. package/dist/settings/index.js +63 -0
  58. package/dist/settings/panel.d.ts +27 -0
  59. package/dist/settings/panel.js +201 -0
  60. package/dist/settings/settings-radio-label.d.ts +25 -0
  61. package/dist/settings/settings-radio-label.js +29 -0
  62. package/dist/settings/toggle.d.ts +25 -0
  63. package/dist/settings/toggle.js +33 -0
  64. package/dist/tabs/index.d.ts +22 -0
  65. package/dist/tabs/index.js +39 -0
  66. package/dist/tags-input/index.d.ts +21 -0
  67. package/dist/tags-input/index.js +83 -0
  68. package/dist/two-choice.d.ts +43 -0
  69. package/dist/two-choice.js +79 -0
  70. package/dist/with-stateful-model.d.ts +42 -0
  71. package/dist/with-stateful-model.js +32 -0
  72. package/package.json +31 -19
  73. package/CHANGELOG.json +0 -32
  74. package/CHANGELOG.md +0 -2419
  75. package/lib/alert-dialog.js +0 -68
  76. package/lib/alert-dialog.js.map +0 -1
  77. package/lib/checkbox.js +0 -84
  78. package/lib/checkbox.js.map +0 -1
  79. package/lib/choice-configuration/feedback-menu.js +0 -129
  80. package/lib/choice-configuration/feedback-menu.js.map +0 -1
  81. package/lib/choice-configuration/index.js +0 -381
  82. package/lib/choice-configuration/index.js.map +0 -1
  83. package/lib/choice-utils.js +0 -42
  84. package/lib/choice-utils.js.map +0 -1
  85. package/lib/feedback-config/feedback-selector.js +0 -155
  86. package/lib/feedback-config/feedback-selector.js.map +0 -1
  87. package/lib/feedback-config/group.js +0 -61
  88. package/lib/feedback-config/group.js.map +0 -1
  89. package/lib/feedback-config/index.js +0 -146
  90. package/lib/feedback-config/index.js.map +0 -1
  91. package/lib/form-section.js +0 -44
  92. package/lib/form-section.js.map +0 -1
  93. package/lib/help.js +0 -106
  94. package/lib/help.js.map +0 -1
  95. package/lib/index.js +0 -186
  96. package/lib/index.js.map +0 -1
  97. package/lib/input.js +0 -106
  98. package/lib/input.js.map +0 -1
  99. package/lib/inputs.js +0 -105
  100. package/lib/inputs.js.map +0 -1
  101. package/lib/langs.js +0 -136
  102. package/lib/langs.js.map +0 -1
  103. package/lib/layout/config-layout.js +0 -137
  104. package/lib/layout/config-layout.js.map +0 -1
  105. package/lib/layout/index.js +0 -21
  106. package/lib/layout/index.js.map +0 -1
  107. package/lib/layout/layout-contents.js +0 -160
  108. package/lib/layout/layout-contents.js.map +0 -1
  109. package/lib/layout/settings-box.js +0 -57
  110. package/lib/layout/settings-box.js.map +0 -1
  111. package/lib/mui-box/index.js +0 -63
  112. package/lib/mui-box/index.js.map +0 -1
  113. package/lib/number-text-field-custom.js +0 -376
  114. package/lib/number-text-field-custom.js.map +0 -1
  115. package/lib/number-text-field.js +0 -229
  116. package/lib/number-text-field.js.map +0 -1
  117. package/lib/radio-with-label.js +0 -48
  118. package/lib/radio-with-label.js.map +0 -1
  119. package/lib/settings/display-size.js +0 -61
  120. package/lib/settings/display-size.js.map +0 -1
  121. package/lib/settings/index.js +0 -110
  122. package/lib/settings/index.js.map +0 -1
  123. package/lib/settings/panel.js +0 -392
  124. package/lib/settings/panel.js.map +0 -1
  125. package/lib/settings/settings-radio-label.js +0 -51
  126. package/lib/settings/settings-radio-label.js.map +0 -1
  127. package/lib/settings/toggle.js +0 -63
  128. package/lib/settings/toggle.js.map +0 -1
  129. package/lib/tabs/index.js +0 -75
  130. package/lib/tabs/index.js.map +0 -1
  131. package/lib/tags-input/index.js +0 -149
  132. package/lib/tags-input/index.js.map +0 -1
  133. package/lib/two-choice.js +0 -136
  134. package/lib/two-choice.js.map +0 -1
  135. package/lib/with-stateful-model.js +0 -61
  136. package/lib/with-stateful-model.js.map +0 -1
  137. package/src/alert-dialog.jsx +0 -75
  138. package/src/checkbox.jsx +0 -61
  139. package/src/choice-configuration/feedback-menu.jsx +0 -96
  140. package/src/choice-configuration/index.jsx +0 -357
  141. package/src/choice-utils.js +0 -30
  142. package/src/feedback-config/feedback-selector.jsx +0 -112
  143. package/src/feedback-config/group.jsx +0 -51
  144. package/src/feedback-config/index.jsx +0 -111
  145. package/src/form-section.jsx +0 -31
  146. package/src/help.jsx +0 -79
  147. package/src/index.js +0 -55
  148. package/src/input.jsx +0 -72
  149. package/src/inputs.jsx +0 -69
  150. package/src/langs.jsx +0 -111
  151. package/src/layout/config-layout.jsx +0 -103
  152. package/src/layout/index.js +0 -4
  153. package/src/layout/layout-contents.jsx +0 -117
  154. package/src/layout/settings-box.jsx +0 -32
  155. package/src/mui-box/index.jsx +0 -56
  156. package/src/number-text-field-custom.jsx +0 -333
  157. package/src/number-text-field.jsx +0 -215
  158. package/src/radio-with-label.jsx +0 -30
  159. package/src/settings/display-size.jsx +0 -53
  160. package/src/settings/index.js +0 -83
  161. package/src/settings/panel.jsx +0 -333
  162. package/src/settings/settings-radio-label.jsx +0 -32
  163. package/src/settings/toggle.jsx +0 -46
  164. package/src/tabs/index.jsx +0 -47
  165. package/src/tags-input/index.jsx +0 -116
  166. package/src/two-choice.jsx +0 -90
  167. package/src/with-stateful-model.jsx +0 -36
@@ -1,111 +0,0 @@
1
- import FeedbackSelector, { FeedbackType } from './feedback-selector';
2
- import PropTypes from 'prop-types';
3
- import React from 'react';
4
- import { merge } from 'lodash-es';
5
-
6
- import { styled } from '@mui/material/styles';
7
- import Accordion from '@mui/material/Accordion';
8
- import AccordionSummary from '@mui/material/AccordionSummary';
9
- import AccordionDetails from '@mui/material/AccordionDetails';
10
- import Typography from '@mui/material/Typography';
11
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
12
-
13
- export { FeedbackSelector };
14
-
15
- const StyledFeedbackContainer = styled('div')(() => ({
16
- display: 'flex',
17
- flex: 1,
18
- flexDirection: 'column',
19
- }));
20
-
21
- const StyledAccordionDetails = styled(AccordionDetails)(() => ({
22
- paddingTop: 0,
23
- paddingBottom: 0,
24
- }));
25
-
26
- export const buildDefaults = (input) => {
27
- return merge(
28
- {},
29
- {
30
- correct: { type: 'default', default: 'Correct' },
31
- incorrect: { type: 'default', default: 'Incorrect' },
32
- partial: { type: 'default', default: 'Nearly' },
33
- },
34
- input,
35
- );
36
- };
37
-
38
- export class FeedbackConfig extends React.Component {
39
- static propTypes = {
40
- allowPartial: PropTypes.bool,
41
- className: PropTypes.string,
42
- feedback: PropTypes.shape({
43
- correct: PropTypes.shape(FeedbackType),
44
- incorrect: PropTypes.shape(FeedbackType),
45
- partial: PropTypes.shape(FeedbackType),
46
- }),
47
- onChange: PropTypes.func.isRequired,
48
- toolbarOpts: PropTypes.object,
49
- };
50
-
51
- static defaultProps = {
52
- allowPartial: true,
53
- feedback: buildDefaults(),
54
- };
55
-
56
- onChange(key, config) {
57
- const { feedback, onChange } = this.props;
58
- const update = { ...feedback, [key]: config };
59
-
60
- onChange(update);
61
- }
62
-
63
- onCorrectChange = this.onChange.bind(this, 'correct');
64
-
65
- onIncorrectChange = this.onChange.bind(this, 'incorrect');
66
-
67
- onPartialChange = this.onChange.bind(this, 'partial');
68
-
69
- render() {
70
- const { className, allowPartial, feedback, toolbarOpts } = this.props;
71
-
72
- return (
73
- <div className={className}>
74
- <Accordion slotProps={{ transition: { timeout: { enter: 225, exit: 195 } } }}>
75
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
76
- <Typography>Feedback</Typography>
77
- </AccordionSummary>
78
-
79
- <StyledAccordionDetails>
80
- <StyledFeedbackContainer>
81
- <FeedbackSelector
82
- label="If correct, show"
83
- feedback={feedback.correct}
84
- onChange={this.onCorrectChange}
85
- toolbarOpts={toolbarOpts}
86
- />
87
-
88
- {allowPartial && (
89
- <FeedbackSelector
90
- label="If partially correct, show"
91
- feedback={feedback.partial}
92
- onChange={this.onPartialChange}
93
- toolbarOpts={toolbarOpts}
94
- />
95
- )}
96
-
97
- <FeedbackSelector
98
- label="If incorrect, show"
99
- feedback={feedback.incorrect}
100
- onChange={this.onIncorrectChange}
101
- toolbarOpts={toolbarOpts}
102
- />
103
- </StyledFeedbackContainer>
104
- </StyledAccordionDetails>
105
- </Accordion>
106
- </div>
107
- );
108
- }
109
- }
110
-
111
- export default FeedbackConfig;
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import Typography from '@mui/material/Typography';
4
- import { styled } from '@mui/material/styles';
5
-
6
- const StyledFormSection = styled('div')(({ theme }) => ({
7
- marginTop: theme.spacing(2),
8
- marginBottom: theme.spacing(2),
9
- }));
10
-
11
- const StyledTypography = styled(Typography)(({ theme }) => ({
12
- marginBottom: theme.spacing(1),
13
- }));
14
-
15
- const FormSection = ({ className, label, children, labelExtraStyle }) => (
16
- <StyledFormSection className={className}>
17
- <StyledTypography variant="subtitle1" style={labelExtraStyle}>
18
- {label}
19
- </StyledTypography>
20
- {children}
21
- </StyledFormSection>
22
- );
23
-
24
- FormSection.propTypes = {
25
- className: PropTypes.string,
26
- label: PropTypes.string,
27
- children: PropTypes.node,
28
- labelExtraStyle: PropTypes.object,
29
- };
30
-
31
- export default FormSection;
package/src/help.jsx DELETED
@@ -1,79 +0,0 @@
1
- import Dialog from '@mui/material/Dialog';
2
- import DialogTitle from '@mui/material/DialogTitle';
3
- import DialogContentText from '@mui/material/DialogContentText';
4
- import DialogContent from '@mui/material/DialogContent';
5
- import DialogActions from '@mui/material/DialogActions';
6
- import PropTypes from 'prop-types';
7
-
8
- import Button from '@mui/material/Button';
9
- import HelpIcon from '@mui/icons-material/Help';
10
- import IconButton from '@mui/material/IconButton';
11
- import React from 'react';
12
- import { styled } from '@mui/material/styles';
13
-
14
- const StyledIconButton = styled(IconButton)(({ theme }) => ({
15
- '&:hover': {
16
- color: theme.palette.grey[300],
17
- },
18
- }));
19
-
20
- export const HelpButton = ({ onClick }) => (
21
- <StyledIconButton onClick={onClick} size="large">
22
- <HelpIcon />
23
- </StyledIconButton>
24
- );
25
-
26
- HelpButton.propTypes = {
27
- onClick: PropTypes.func,
28
- };
29
-
30
- export const HelpDialog = ({ open, onClose, children, title }) => (
31
- <Dialog open={open} onClose={onClose}>
32
- <DialogTitle>{title}</DialogTitle>
33
- <DialogContent>
34
- <DialogContentText>{children}</DialogContentText>
35
- </DialogContent>
36
- <DialogActions>
37
- <Button onClick={onClose} color="primary">
38
- OK
39
- </Button>
40
- </DialogActions>
41
- </Dialog>
42
- );
43
-
44
- HelpDialog.propTypes = {
45
- open: PropTypes.bool,
46
- onClose: PropTypes.func,
47
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
48
- title: PropTypes.string.isRequired,
49
- };
50
-
51
- class Help extends React.Component {
52
- static propTypes = {
53
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
54
- title: PropTypes.string,
55
- };
56
-
57
- constructor(props) {
58
- super(props);
59
- this.state = {
60
- open: false,
61
- };
62
- }
63
-
64
- render() {
65
- const { children, title } = this.props;
66
-
67
- return (
68
- <div>
69
- <HelpButton color="accent" onClick={() => this.setState({ open: true })} />
70
-
71
- <HelpDialog open={this.state.open} title={title} onClose={() => this.setState({ open: false })}>
72
- {children}
73
- </HelpDialog>
74
- </div>
75
- );
76
- }
77
- }
78
-
79
- export default Help;
package/src/index.js DELETED
@@ -1,55 +0,0 @@
1
- import AlertDialog from './alert-dialog';
2
- import FeedbackConfig, { buildDefaults as feedbackConfigDefaults, FeedbackSelector } from './feedback-config';
3
- import { InputCheckbox, InputRadio, InputSwitch } from './inputs';
4
- import Langs, { LanguageControls } from './langs';
5
- import Tabs from './tabs';
6
- import Checkbox from './checkbox';
7
- import FormSection from './form-section';
8
- import Help from './help';
9
- import Input from './input';
10
- import { InputContainer } from '@pie-lib/render-ui';
11
- import NumberTextField from './number-text-field';
12
- import NumberTextFieldCustom from './number-text-field-custom';
13
- import TwoChoice, { NChoice } from './two-choice';
14
- import TagsInput from './tags-input';
15
- import MuiBox from './mui-box';
16
- import ChoiceConfiguration from './choice-configuration';
17
- import * as layout from './layout';
18
-
19
- import * as choiceUtils from './choice-utils';
20
- import withStatefulModel from './with-stateful-model';
21
- import Toggle from './settings/toggle';
22
- import DisplaySize from './settings/display-size';
23
-
24
- import * as settings from './settings';
25
-
26
- export {
27
- AlertDialog,
28
- FeedbackConfig,
29
- FeedbackSelector,
30
- feedbackConfigDefaults,
31
- InputCheckbox,
32
- InputSwitch,
33
- InputRadio,
34
- Langs,
35
- LanguageControls,
36
- Tabs,
37
- Checkbox,
38
- FormSection,
39
- Help,
40
- Input,
41
- InputContainer,
42
- NumberTextField,
43
- NumberTextFieldCustom,
44
- TwoChoice,
45
- NChoice,
46
- TagsInput,
47
- MuiBox,
48
- ChoiceConfiguration,
49
- layout,
50
- choiceUtils,
51
- withStatefulModel,
52
- Toggle,
53
- DisplaySize,
54
- settings,
55
- };
package/src/input.jsx DELETED
@@ -1,72 +0,0 @@
1
- import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { default as MaterialInput } from '@mui/material/Input';
4
- import { InputContainer } from '@pie-lib/render-ui';
5
-
6
- export default class Input extends React.Component {
7
- static propTypes = {
8
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
9
- onChange: PropTypes.func.isRequired,
10
- label: PropTypes.string,
11
- type: PropTypes.string.isRequired,
12
- error: PropTypes.func,
13
- noModelUpdateOnError: PropTypes.bool,
14
- };
15
-
16
- static defaultProps = {
17
- type: 'text',
18
- error: (value, type) => (type === 'number' ? !value || isNaN(value) : !value),
19
- noModelUpdateOnError: false,
20
- };
21
-
22
- constructor(props) {
23
- super(props);
24
-
25
- this.state = {
26
- value: props.value,
27
- };
28
- }
29
-
30
- UNSAFE_componentWillReceiveProps(newProps) {
31
- this.setState({
32
- value: newProps.value,
33
- });
34
- }
35
-
36
- onChange = (event) => {
37
- const { type, onChange, error } = this.props;
38
- const value = event.target.value;
39
-
40
- if (error(value, type)) {
41
- this.setState({
42
- error: true,
43
- value: event.target.value,
44
- });
45
- } else {
46
- this.setState({
47
- error: false,
48
- value: event.target.value,
49
- });
50
-
51
- onChange(event);
52
- }
53
- };
54
-
55
- render() {
56
- const {
57
- label,
58
- type,
59
- noModelUpdateOnError, // eslint-disable-line no-unused-vars
60
- ...rest
61
- } = this.props;
62
- const { value, error } = this.state;
63
-
64
- return label ? (
65
- <InputContainer label={label}>
66
- <MaterialInput type={type} {...rest} value={value} onChange={this.onChange} error={error} />
67
- </InputContainer>
68
- ) : (
69
- <MaterialInput type={type} {...rest} value={value} onChange={this.onChange} error={error} />
70
- );
71
- }
72
- }
package/src/inputs.jsx DELETED
@@ -1,69 +0,0 @@
1
- import Checkbox from '@mui/material/Checkbox';
2
- import Radio from '@mui/material/Radio';
3
- import { color, InputContainer } from '@pie-lib/render-ui';
4
- import PropTypes from 'prop-types';
5
- import React from 'react';
6
- import Switch from '@mui/material/Switch';
7
- import { styled } from '@mui/material/styles';
8
-
9
- const InputTypes = {
10
- className: PropTypes.string,
11
- label: PropTypes.string,
12
- checked: PropTypes.bool,
13
- onChange: PropTypes.func,
14
- disabled: PropTypes.bool,
15
- error: PropTypes.string,
16
- };
17
-
18
- const StyledSwitch = styled(Switch)(() => ({
19
- justifyContent: 'inherit',
20
- transform: 'translate(-20%, 20%)',
21
- }));
22
-
23
- const InputSwitch = ({ className, label, checked, onChange }) => {
24
- return (
25
- <InputContainer className={className} label={label}>
26
- <StyledSwitch checked={checked} onChange={onChange} aria-label={label} />
27
- </InputContainer>
28
- );
29
- };
30
-
31
- InputSwitch.propTypes = { ...InputTypes };
32
-
33
- const StyledCheckbox = styled(Checkbox)(({ theme, error }) => ({
34
- transform: 'translate(-25%, 20%)',
35
- color: `${color.tertiary()} !important`,
36
- ...(error && {
37
- color: `${theme.palette.error.main} !important`,
38
- }),
39
- }));
40
-
41
- const InputCheckbox = ({ className, label, checked, onChange, disabled, error }) => {
42
- return (
43
- <InputContainer className={className} label={label}>
44
- <StyledCheckbox disabled={disabled} checked={checked} onChange={onChange} aria-label={label} error={error} />
45
- </InputContainer>
46
- );
47
- };
48
-
49
- InputCheckbox.propTypes = { ...InputTypes };
50
-
51
- const StyledRadio = styled(Radio)(({ theme, error }) => ({
52
- transform: 'translate(-20%, 20%)',
53
- color: `${color.tertiary()} !important`,
54
- ...(error && {
55
- color: `${theme.palette.error.main} !important`,
56
- }),
57
- }));
58
-
59
- const InputRadio = ({ className, label, checked, onChange, disabled, error }) => {
60
- return (
61
- <InputContainer className={className} label={label}>
62
- <StyledRadio disabled={disabled} checked={checked} onChange={onChange} aria-label={label} error={error} />
63
- </InputContainer>
64
- );
65
- };
66
-
67
- InputRadio.propTypes = { ...InputTypes };
68
-
69
- export { InputSwitch, InputCheckbox, InputRadio };
package/src/langs.jsx DELETED
@@ -1,111 +0,0 @@
1
- import Input from '@mui/material/Input';
2
- import InputLabel from '@mui/material/InputLabel';
3
- import PropTypes from 'prop-types';
4
- import React from 'react';
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';
9
- import debug from 'debug';
10
-
11
- const log = debug('pie-elements:config-ui:langs');
12
-
13
- const StyledRoot = styled('div')(() => ({
14
- flexDirection: 'column',
15
- alignItems: 'start',
16
- display: 'flex',
17
- position: 'relative',
18
- paddingTop: '0px',
19
- paddingRight: '0px',
20
- }));
21
-
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 {
31
- static propTypes = {
32
- onChange: PropTypes.func,
33
- langs: PropTypes.array,
34
- selected: PropTypes.string,
35
- label: PropTypes.string,
36
- uid: PropTypes.string,
37
- };
38
-
39
- constructor(props) {
40
- super(props);
41
- this.uid = props.uid || (Math.random() * 10000).toFixed();
42
- }
43
-
44
- choose = (event) => {
45
- log('[choose] event: ', event);
46
-
47
- if (this.props.onChange) {
48
- this.props.onChange(event.target.value);
49
- }
50
- };
51
-
52
- render() {
53
- let { langs, selected, label } = this.props;
54
-
55
- log('[render] selected:', selected);
56
-
57
- return (
58
- <StyledRoot>
59
- <StyledFormControl>
60
- <StyledInputLabel htmlFor={this.uid}>{label}</StyledInputLabel>
61
-
62
- <Select value={selected} onChange={this.choose} input={<Input id={this.uid} />}>
63
- {langs.map((l, index) => (
64
- <MenuItem key={index} value={l}>
65
- {l}
66
- </MenuItem>
67
- ))}
68
- </Select>
69
- </StyledFormControl>
70
- </StyledRoot>
71
- );
72
- }
73
- }
74
- export default Langs;
75
-
76
- const StyledLanguageControls = styled('div')(() => ({
77
- display: 'grid',
78
- gridAutoFlow: 'column',
79
- gridAutoColumns: '1fr',
80
- gridGap: '8px',
81
- }));
82
-
83
- export const LanguageControls = ({
84
- langs,
85
- activeLang,
86
- defaultLang,
87
- onActiveLangChange,
88
- onDefaultLangChange,
89
- className,
90
- }) => {
91
- return (
92
- <StyledLanguageControls className={className}>
93
- <Langs
94
- label="Choose language to edit"
95
- langs={langs}
96
- selected={activeLang}
97
- onChange={(l) => onActiveLangChange(l)}
98
- />
99
- <Langs label="Default language" langs={langs} selected={defaultLang} onChange={(l) => onDefaultLangChange(l)} />
100
- </StyledLanguageControls>
101
- );
102
- };
103
-
104
- LanguageControls.propTypes = {
105
- langs: PropTypes.array,
106
- activeLang: PropTypes.string.isRequired,
107
- defaultLang: PropTypes.string.isRequired,
108
- onActiveLangChange: PropTypes.func.isRequired,
109
- onDefaultLangChange: PropTypes.func.isRequired,
110
- className: PropTypes.string,
111
- };
@@ -1,103 +0,0 @@
1
- import React from 'react';
2
- import Measure, { withContentRect } from 'react-measure';
3
- import { createTheme, StyledEngineProvider, ThemeProvider } from '@mui/material/styles';
4
- import PropTypes from 'prop-types';
5
- import LayoutContents from './layout-contents';
6
- import SettingsBox from './settings-box';
7
-
8
- const theme = createTheme({
9
- typography: {
10
- fontFamily: 'inherit',
11
- },
12
- components: {
13
- MuiButton: {
14
- styleOverrides: {
15
- contained: {
16
- backgroundColor: '#e0e0e0',
17
- color: '#000000',
18
- '&:hover': {
19
- backgroundColor: '#bdbdbd',
20
- },
21
- },
22
- },
23
- },
24
- },
25
- });
26
-
27
- class MeasuredConfigLayout extends React.Component {
28
- static propTypes = {
29
- children: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
30
- className: PropTypes.string,
31
- dimensions: PropTypes.object,
32
- settings: PropTypes.element,
33
- sidePanelMinWidth: PropTypes.number,
34
- hideSettings: PropTypes.bool,
35
- extraCSSRules: PropTypes.shape({
36
- names: PropTypes.arrayOf(PropTypes.string),
37
- rules: PropTypes.string,
38
- }),
39
- };
40
-
41
- static defaultProps = {
42
- sidePanelMinWidth: 1135,
43
- hideSettings: false,
44
- dimensions: {},
45
- };
46
-
47
- constructor(...props) {
48
- super(...props);
49
- this.state = { layoutMode: undefined };
50
- }
51
-
52
- onResize = (contentRect) => {
53
- const { bounds } = contentRect;
54
- const { sidePanelMinWidth, dimensions } = this.props;
55
- const { maxWidth } = dimensions || {};
56
-
57
- const layoutMode =
58
- bounds.width > sidePanelMinWidth && (maxWidth ? maxWidth > sidePanelMinWidth : true) ? 'inline' : 'tabbed';
59
-
60
- // Only update state (and cause a re-render) if the computed layoutMode changed.
61
- if (layoutMode !== this.state.layoutMode) {
62
- this.setState({ layoutMode });
63
- }
64
- };
65
-
66
- render() {
67
- return (
68
- // TODO: REVIEW MuiThemeProvider usage - is this still needed after mui update?
69
- // Different theme object identities will force theme consumers to re-render.
70
- <StyledEngineProvider injectFirst>
71
- <ThemeProvider theme={theme}>
72
- <Measure bounds onResize={this.onResize}>
73
- {({ measureRef }) => {
74
- const { children, settings, hideSettings, dimensions, extraCSSRules } = this.props;
75
- const { layoutMode } = this.state;
76
-
77
- const settingsPanel =
78
- layoutMode === 'inline' ? <SettingsBox className="settings-box">{settings}</SettingsBox> : settings;
79
- const secondaryContent = hideSettings ? null : settingsPanel;
80
- const finalClass = 'main-container extraCSSRules';
81
-
82
- return (
83
- <div ref={measureRef} className={finalClass}>
84
- {extraCSSRules?.rules ? (
85
- <style dangerouslySetInnerHTML={{ __html: `.extraCSSRules { ${extraCSSRules.rules} }` }} />
86
- ) : null}
87
-
88
- <LayoutContents mode={layoutMode} secondary={secondaryContent} dimensions={dimensions}>
89
- {children}
90
- </LayoutContents>
91
- </div>
92
- );
93
- }}
94
- </Measure>
95
- </ThemeProvider>
96
- </StyledEngineProvider>
97
- );
98
- }
99
- }
100
-
101
- const ConfigLayout = withContentRect('bounds')(MeasuredConfigLayout);
102
-
103
- export default ConfigLayout;
@@ -1,4 +0,0 @@
1
- import ConfigLayout from './config-layout';
2
- import LayoutContents from './layout-contents';
3
-
4
- export { LayoutContents, ConfigLayout };