@pie-lib/config-ui 13.0.3-next.3 → 13.0.4-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.
Files changed (188) 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/help.d.ts +41 -0
  21. package/dist/help.js +61 -0
  22. package/dist/index.d.ts +31 -0
  23. package/dist/index.js +34 -0
  24. package/dist/input.d.ts +29 -0
  25. package/dist/input.js +65 -0
  26. package/dist/inputs.d.ts +63 -0
  27. package/dist/inputs.js +70 -0
  28. package/dist/langs.d.ts +41 -0
  29. package/dist/langs.js +76 -0
  30. package/dist/layout/config-layout.d.ts +10 -0
  31. package/dist/layout/config-layout.js +75 -0
  32. package/dist/layout/index.d.ts +11 -0
  33. package/dist/layout/index.js +10 -0
  34. package/dist/layout/layout-contents.d.ts +21 -0
  35. package/dist/layout/layout-contents.js +70 -0
  36. package/dist/layout/settings-box.d.ts +19 -0
  37. package/dist/layout/settings-box.js +31 -0
  38. package/dist/mui-box/index.d.ts +21 -0
  39. package/dist/mui-box/index.js +47 -0
  40. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  41. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
  42. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  43. package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
  44. package/dist/node_modules/.bun/react-measure@2.5.2_6dbf9a050bc9aadb/node_modules/react-measure/dist/index.esm.js +122 -0
  45. package/dist/node_modules/.bun/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +276 -0
  46. package/dist/number-text-field-custom.d.ts +51 -0
  47. package/dist/number-text-field-custom.js +192 -0
  48. package/dist/number-text-field.d.ts +47 -0
  49. package/dist/number-text-field.js +122 -0
  50. package/dist/radio-with-label.d.ts +25 -0
  51. package/dist/radio-with-label.js +27 -0
  52. package/dist/settings/display-size.d.ts +26 -0
  53. package/dist/settings/display-size.js +45 -0
  54. package/dist/settings/index.d.ts +45 -0
  55. package/dist/settings/index.js +63 -0
  56. package/dist/settings/panel.d.ts +27 -0
  57. package/dist/settings/panel.js +201 -0
  58. package/dist/settings/settings-radio-label.d.ts +25 -0
  59. package/dist/settings/settings-radio-label.js +29 -0
  60. package/dist/settings/toggle.d.ts +25 -0
  61. package/dist/settings/toggle.js +33 -0
  62. package/dist/tabs/index.d.ts +22 -0
  63. package/dist/tabs/index.js +39 -0
  64. package/dist/tags-input/index.d.ts +21 -0
  65. package/dist/tags-input/index.js +83 -0
  66. package/dist/two-choice.d.ts +43 -0
  67. package/dist/two-choice.js +79 -0
  68. package/dist/with-stateful-model.d.ts +42 -0
  69. package/dist/with-stateful-model.js +32 -0
  70. package/package.json +30 -18
  71. package/CHANGELOG.json +0 -32
  72. package/CHANGELOG.md +0 -2415
  73. package/LICENSE.md +0 -5
  74. package/lib/alert-dialog.js +0 -68
  75. package/lib/alert-dialog.js.map +0 -1
  76. package/lib/checkbox.js +0 -84
  77. package/lib/checkbox.js.map +0 -1
  78. package/lib/choice-configuration/feedback-menu.js +0 -129
  79. package/lib/choice-configuration/feedback-menu.js.map +0 -1
  80. package/lib/choice-configuration/index.js +0 -381
  81. package/lib/choice-configuration/index.js.map +0 -1
  82. package/lib/choice-utils.js +0 -42
  83. package/lib/choice-utils.js.map +0 -1
  84. package/lib/feedback-config/feedback-selector.js +0 -155
  85. package/lib/feedback-config/feedback-selector.js.map +0 -1
  86. package/lib/feedback-config/group.js +0 -61
  87. package/lib/feedback-config/group.js.map +0 -1
  88. package/lib/feedback-config/index.js +0 -146
  89. package/lib/feedback-config/index.js.map +0 -1
  90. package/lib/form-section.js +0 -44
  91. package/lib/form-section.js.map +0 -1
  92. package/lib/help.js +0 -106
  93. package/lib/help.js.map +0 -1
  94. package/lib/index.js +0 -186
  95. package/lib/index.js.map +0 -1
  96. package/lib/input.js +0 -106
  97. package/lib/input.js.map +0 -1
  98. package/lib/inputs.js +0 -105
  99. package/lib/inputs.js.map +0 -1
  100. package/lib/langs.js +0 -136
  101. package/lib/langs.js.map +0 -1
  102. package/lib/layout/config-layout.js +0 -137
  103. package/lib/layout/config-layout.js.map +0 -1
  104. package/lib/layout/index.js +0 -21
  105. package/lib/layout/index.js.map +0 -1
  106. package/lib/layout/layout-contents.js +0 -160
  107. package/lib/layout/layout-contents.js.map +0 -1
  108. package/lib/layout/settings-box.js +0 -57
  109. package/lib/layout/settings-box.js.map +0 -1
  110. package/lib/mui-box/index.js +0 -63
  111. package/lib/mui-box/index.js.map +0 -1
  112. package/lib/number-text-field-custom.js +0 -376
  113. package/lib/number-text-field-custom.js.map +0 -1
  114. package/lib/number-text-field.js +0 -229
  115. package/lib/number-text-field.js.map +0 -1
  116. package/lib/radio-with-label.js +0 -48
  117. package/lib/radio-with-label.js.map +0 -1
  118. package/lib/settings/display-size.js +0 -61
  119. package/lib/settings/display-size.js.map +0 -1
  120. package/lib/settings/index.js +0 -110
  121. package/lib/settings/index.js.map +0 -1
  122. package/lib/settings/panel.js +0 -392
  123. package/lib/settings/panel.js.map +0 -1
  124. package/lib/settings/settings-radio-label.js +0 -51
  125. package/lib/settings/settings-radio-label.js.map +0 -1
  126. package/lib/settings/toggle.js +0 -63
  127. package/lib/settings/toggle.js.map +0 -1
  128. package/lib/tabs/index.js +0 -75
  129. package/lib/tabs/index.js.map +0 -1
  130. package/lib/tags-input/index.js +0 -149
  131. package/lib/tags-input/index.js.map +0 -1
  132. package/lib/two-choice.js +0 -136
  133. package/lib/two-choice.js.map +0 -1
  134. package/lib/with-stateful-model.js +0 -61
  135. package/lib/with-stateful-model.js.map +0 -1
  136. package/src/__tests__/alert-dialog.test.jsx +0 -183
  137. package/src/__tests__/checkbox.test.jsx +0 -152
  138. package/src/__tests__/choice-utils.test.js +0 -12
  139. package/src/__tests__/form-section.test.jsx +0 -328
  140. package/src/__tests__/help.test.jsx +0 -184
  141. package/src/__tests__/input.test.jsx +0 -156
  142. package/src/__tests__/langs.test.jsx +0 -376
  143. package/src/__tests__/number-text-field-custom.test.jsx +0 -255
  144. package/src/__tests__/number-text-field.test.jsx +0 -263
  145. package/src/__tests__/radio-with-label.test.jsx +0 -155
  146. package/src/__tests__/settings-panel.test.js +0 -187
  147. package/src/__tests__/settings.test.jsx +0 -452
  148. package/src/__tests__/tabs.test.jsx +0 -188
  149. package/src/__tests__/two-choice.test.js +0 -110
  150. package/src/__tests__/with-stateful-model.test.jsx +0 -139
  151. package/src/alert-dialog.jsx +0 -75
  152. package/src/checkbox.jsx +0 -61
  153. package/src/choice-configuration/__tests__/feedback-menu.test.jsx +0 -151
  154. package/src/choice-configuration/__tests__/index.test.jsx +0 -234
  155. package/src/choice-configuration/feedback-menu.jsx +0 -96
  156. package/src/choice-configuration/index.jsx +0 -357
  157. package/src/choice-utils.js +0 -30
  158. package/src/feedback-config/__tests__/feedback-config.test.jsx +0 -141
  159. package/src/feedback-config/__tests__/feedback-selector.test.jsx +0 -97
  160. package/src/feedback-config/feedback-selector.jsx +0 -112
  161. package/src/feedback-config/group.jsx +0 -51
  162. package/src/feedback-config/index.jsx +0 -111
  163. package/src/form-section.jsx +0 -31
  164. package/src/help.jsx +0 -79
  165. package/src/index.js +0 -55
  166. package/src/input.jsx +0 -72
  167. package/src/inputs.jsx +0 -69
  168. package/src/langs.jsx +0 -111
  169. package/src/layout/__tests__/config.layout.test.jsx +0 -59
  170. package/src/layout/__tests__/layout-content.test.jsx +0 -3
  171. package/src/layout/config-layout.jsx +0 -103
  172. package/src/layout/index.js +0 -4
  173. package/src/layout/layout-contents.jsx +0 -117
  174. package/src/layout/settings-box.jsx +0 -32
  175. package/src/mui-box/index.jsx +0 -56
  176. package/src/number-text-field-custom.jsx +0 -333
  177. package/src/number-text-field.jsx +0 -215
  178. package/src/radio-with-label.jsx +0 -30
  179. package/src/settings/display-size.jsx +0 -53
  180. package/src/settings/index.js +0 -83
  181. package/src/settings/panel.jsx +0 -333
  182. package/src/settings/settings-radio-label.jsx +0 -32
  183. package/src/settings/toggle.jsx +0 -46
  184. package/src/tabs/index.jsx +0 -47
  185. package/src/tags-input/__tests__/index.test.jsx +0 -113
  186. package/src/tags-input/index.jsx +0 -116
  187. package/src/two-choice.jsx +0 -90
  188. package/src/with-stateful-model.jsx +0 -36
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,59 +0,0 @@
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,3 +0,0 @@
1
- describe('layout-content', () => {
2
- it.todo('add tests!');
3
- });
@@ -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 };
@@ -1,117 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
- import Tabs from '../tabs';
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
- }));
28
-
29
- class RawLayoutContents extends React.Component {
30
- static propTypes = {
31
- mode: PropTypes.oneOf(['tabbed', 'inline']),
32
- secondary: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
33
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
34
- dimensions: PropTypes.object,
35
- };
36
-
37
- getConfiguration = () => {
38
- const { secondary } = this.props;
39
- // in config-layout, secondary can be: <SettingsBox>{settings}</SettingsBox>, settings, null
40
-
41
- return secondary?.props?.configuration || secondary?.props?.children?.props?.configuration || undefined;
42
- };
43
-
44
- // // eslint-disable-next-line no-unused-vars
45
- // componentDidUpdate(prevProps, prevState, snapshot) {
46
- // const configuration = this.getConfiguration();
47
- // const { mode } = this.props;
48
- //
49
- // // promptHolder class is used to wrap up inputs:
50
- // // we don't want inputs to fill the entire scrollable container,
51
- // // but instead we want inputs to fit in the first view,
52
- // // so we calculate the maximum space inputs need
53
- // try {
54
- // if (
55
- // configuration?.maxWidth &&
56
- // getComputedStyle(document.documentElement).getPropertyValue('--pie-prompt-holder-max-width') !==
57
- // configuration?.maxWidth
58
- // ) {
59
- // document.documentElement.style.setProperty(
60
- // '--pie-prompt-holder-max-width',
61
- // mode === 'inline' ? `calc(${configuration.maxWidth} - 340px)` : configuration.maxWidth,
62
- // );
63
- // }
64
- // } catch (e) {
65
- // console.log(e.toString());
66
- // }
67
- // }
68
-
69
- render() {
70
- const { mode, secondary, children, dimensions } = this.props;
71
- const { minHeight, minWidth, maxHeight, maxWidth } = dimensions || {};
72
- const configuration = this.getConfiguration();
73
-
74
- let hasSettingsPanel = Object.entries(configuration || {}).some(([, obj]) => !!obj?.settings);
75
- // ebsr has configuration.partA and configuration.partB
76
- // because we might have nested configuration for other item types as well, let's add this simple regex to check values for settings
77
-
78
- if (!hasSettingsPanel) {
79
- try {
80
- hasSettingsPanel = JSON.stringify(configuration)?.match(/settings":true/)?.length;
81
- } catch (e) {
82
- // eslint-disable-next-line no-console
83
- console.log(e.toString());
84
- }
85
- }
86
-
87
- return (
88
- <StyledContainer style={{ minHeight, minWidth, maxHeight, maxWidth }}>
89
- {mode === 'inline' && (
90
- <StyledFlow>
91
- <StyledConfigContainer className="design-container">{children}</StyledConfigContainer>
92
- {hasSettingsPanel && (
93
- <StyledSettingsContainer className="settings-container">{secondary}</StyledSettingsContainer>
94
- )}
95
- </StyledFlow>
96
- )}
97
-
98
- {mode === 'tabbed' && hasSettingsPanel && (
99
- <Tabs onChange={this.onTabsChange} contentClassName="content-container" indicatorColor="primary">
100
- <StyledContentContainer title="Design" className="design-container">
101
- {children}
102
- </StyledContentContainer>
103
- <StyledContentContainer title="Settings" className="settings-container">
104
- {secondary}
105
- </StyledContentContainer>
106
- </Tabs>
107
- )}
108
-
109
- {mode === 'tabbed' && !hasSettingsPanel && (
110
- <StyledContentContainer className="design-container">{children}</StyledContentContainer>
111
- )}
112
- </StyledContainer>
113
- );
114
- }
115
- }
116
-
117
- export default RawLayoutContents;
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
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
- }));
16
-
17
- export class SettingsBox extends React.Component {
18
- static propTypes = {
19
- className: PropTypes.string,
20
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
21
- };
22
-
23
- static defaultProps = {};
24
-
25
- render() {
26
- const { className, children } = this.props;
27
-
28
- return <StyledSettingsBox className={className}>{children}</StyledSettingsBox>;
29
- }
30
- }
31
-
32
- export default SettingsBox;
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { styled } from '@mui/material/styles';
4
- import debug from 'debug';
5
-
6
- const log = debug('pie-elements:config-ui:mui-box');
7
-
8
- const StyledMuiBox = styled('div')(({ theme, focused }) => {
9
- const light = theme.palette.mode === 'light';
10
- const bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)';
11
-
12
- log(theme.palette.primary[theme.palette.mode || 'light']);
13
-
14
- return {
15
- paddingTop: theme.spacing(1),
16
- paddingBottom: theme.spacing(1),
17
- position: 'relative',
18
- '&:before': {
19
- left: 0,
20
- right: 0,
21
- bottom: 0,
22
- height: '1px',
23
- content: '""',
24
- position: 'absolute',
25
- transition: 'background-color 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
26
- pointerEvents: 'none',
27
- backgroundColor: bottomLineColor,
28
- },
29
- '&:hover:before': {
30
- height: '2px',
31
- },
32
- '&:after': {
33
- left: 0,
34
- right: 0,
35
- bottom: 0,
36
- height: '2px',
37
- content: '""',
38
- position: 'absolute',
39
- transform: focused ? 'scaleX(1)' : 'scaleX(0)',
40
- transition: 'transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms',
41
- pointerEvents: 'none',
42
- backgroundColor: theme.palette.primary[theme.palette.mode], //'#304ffe'
43
- },
44
- };
45
- });
46
-
47
- const MuiBox = ({ children, focused }) => {
48
- return <StyledMuiBox focused={focused}>{children}</StyledMuiBox>;
49
- };
50
-
51
- MuiBox.propTypes = {
52
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
53
- focused: PropTypes.bool.isRequired,
54
- };
55
-
56
- export default MuiBox;