@pie-lib/config-ui 0.1.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/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/alert-dialog.d.ts +44 -0
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert-dialog.js +47 -0
- package/dist/checkbox.d.ts +34 -0
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/checkbox.js +57 -0
- package/dist/choice-configuration/feedback-menu.d.ts +33 -0
- package/dist/choice-configuration/feedback-menu.d.ts.map +1 -0
- package/dist/choice-configuration/feedback-menu.js +85 -0
- package/dist/choice-configuration/index.d.ts +63 -0
- package/dist/choice-configuration/index.d.ts.map +1 -0
- package/dist/choice-configuration/index.js +240 -0
- package/dist/choice-utils.d.ts +22 -0
- package/dist/choice-utils.d.ts.map +1 -0
- package/dist/choice-utils.js +15 -0
- package/dist/feedback-config/feedback-selector.d.ts +34 -0
- package/dist/feedback-config/feedback-selector.d.ts.map +1 -0
- package/dist/feedback-config/feedback-selector.js +92 -0
- package/dist/feedback-config/group.d.ts +21 -0
- package/dist/feedback-config/group.d.ts.map +1 -0
- package/dist/feedback-config/group.js +33 -0
- package/dist/feedback-config/index.d.ts +49 -0
- package/dist/feedback-config/index.d.ts.map +1 -0
- package/dist/feedback-config/index.js +96 -0
- package/dist/form-section.d.ts +25 -0
- package/dist/form-section.d.ts.map +1 -0
- package/dist/form-section.js +25 -0
- package/dist/help.d.ts +42 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +61 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/input.d.ts +30 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +65 -0
- package/dist/inputs.d.ts +63 -0
- package/dist/inputs.d.ts.map +1 -0
- package/dist/inputs.js +70 -0
- package/dist/langs.d.ts +42 -0
- package/dist/langs.d.ts.map +1 -0
- package/dist/langs.js +76 -0
- package/dist/layout/config-layout.d.ts +11 -0
- package/dist/layout/config-layout.d.ts.map +1 -0
- package/dist/layout/config-layout.js +75 -0
- package/dist/layout/index.d.ts +12 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +10 -0
- package/dist/layout/layout-contents.d.ts +22 -0
- package/dist/layout/layout-contents.d.ts.map +1 -0
- package/dist/layout/layout-contents.js +70 -0
- package/dist/layout/settings-box.d.ts +20 -0
- package/dist/layout/settings-box.d.ts.map +1 -0
- package/dist/layout/settings-box.js +31 -0
- package/dist/mui-box/index.d.ts +21 -0
- package/dist/mui-box/index.d.ts.map +1 -0
- package/dist/mui-box/index.js +47 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
- package/dist/node_modules/.bun/react-measure@2.5.2_6dbf9a050bc9aadb/node_modules/react-measure/dist/index.esm.js +122 -0
- package/dist/node_modules/.bun/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +276 -0
- package/dist/number-text-field-custom.d.ts +52 -0
- package/dist/number-text-field-custom.d.ts.map +1 -0
- package/dist/number-text-field-custom.js +192 -0
- package/dist/number-text-field.d.ts +48 -0
- package/dist/number-text-field.d.ts.map +1 -0
- package/dist/number-text-field.js +122 -0
- package/dist/radio-with-label.d.ts +25 -0
- package/dist/radio-with-label.d.ts.map +1 -0
- package/dist/radio-with-label.js +27 -0
- package/dist/settings/display-size.d.ts +26 -0
- package/dist/settings/display-size.d.ts.map +1 -0
- package/dist/settings/display-size.js +45 -0
- package/dist/settings/index.d.ts +46 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +63 -0
- package/dist/settings/panel.d.ts +28 -0
- package/dist/settings/panel.d.ts.map +1 -0
- package/dist/settings/panel.js +201 -0
- package/dist/settings/settings-radio-label.d.ts +25 -0
- package/dist/settings/settings-radio-label.d.ts.map +1 -0
- package/dist/settings/settings-radio-label.js +29 -0
- package/dist/settings/toggle.d.ts +25 -0
- package/dist/settings/toggle.d.ts.map +1 -0
- package/dist/settings/toggle.js +33 -0
- package/dist/tabs/index.d.ts +23 -0
- package/dist/tabs/index.d.ts.map +1 -0
- package/dist/tabs/index.js +39 -0
- package/dist/tags-input/index.d.ts +22 -0
- package/dist/tags-input/index.d.ts.map +1 -0
- package/dist/tags-input/index.js +83 -0
- package/dist/two-choice.d.ts +44 -0
- package/dist/two-choice.d.ts.map +1 -0
- package/dist/two-choice.js +79 -0
- package/dist/with-stateful-model.d.ts +22 -0
- package/dist/with-stateful-model.d.ts.map +1 -0
- package/dist/with-stateful-model.js +32 -0
- package/package.json +40 -0
- package/src/alert-dialog.tsx +85 -0
- package/src/checkbox.tsx +71 -0
- package/src/choice-configuration/feedback-menu.tsx +134 -0
- package/src/choice-configuration/index.tsx +400 -0
- package/src/choice-utils.ts +40 -0
- package/src/feedback-config/feedback-selector.tsx +153 -0
- package/src/feedback-config/group.tsx +61 -0
- package/src/feedback-config/index.tsx +121 -0
- package/src/form-section.tsx +41 -0
- package/src/help.tsx +89 -0
- package/src/index.ts +93 -0
- package/src/input.tsx +109 -0
- package/src/inputs.tsx +107 -0
- package/src/langs.tsx +121 -0
- package/src/layout/config-layout.tsx +113 -0
- package/src/layout/index.ts +14 -0
- package/src/layout/layout-contents.tsx +127 -0
- package/src/layout/settings-box.tsx +42 -0
- package/src/mui-box/index.tsx +66 -0
- package/src/number-text-field-custom.tsx +343 -0
- package/src/number-text-field.tsx +229 -0
- package/src/radio-with-label.tsx +40 -0
- package/src/settings/display-size.tsx +63 -0
- package/src/settings/index.ts +93 -0
- package/src/settings/panel.tsx +343 -0
- package/src/settings/settings-radio-label.tsx +42 -0
- package/src/settings/toggle.tsx +56 -0
- package/src/tabs/index.tsx +57 -0
- package/src/tags-input/index.tsx +126 -0
- package/src/two-choice.tsx +128 -0
- package/src/with-stateful-model.tsx +46 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/feedback-config/feedback-selector.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
//import EditableHTML from '@pie-lib/editable-html-tip-tap';
|
|
12
|
+
import { InputContainer as InputContainerImport } from '@pie-lib/render-ui';
|
|
13
|
+
|
|
14
|
+
function isRenderableReactInteropType(value: any) {
|
|
15
|
+
return (
|
|
16
|
+
typeof value === 'function' ||
|
|
17
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
22
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
23
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
24
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
25
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
26
|
+
return maybeSymbol[namedExport];
|
|
27
|
+
}
|
|
28
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
29
|
+
return maybeSymbol[namedExport].default;
|
|
30
|
+
}
|
|
31
|
+
return maybeSymbol;
|
|
32
|
+
}
|
|
33
|
+
const InputContainer = unwrapReactInteropSymbol(InputContainerImport, 'InputContainer') || unwrapReactInteropSymbol(renderUi.InputContainer, 'InputContainer');
|
|
34
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
35
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
36
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
37
|
+
const renderUi =
|
|
38
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
39
|
+
? renderUiDefaultMaybe
|
|
40
|
+
: renderUiNamespaceAny;
|
|
41
|
+
import PropTypes from 'prop-types';
|
|
42
|
+
import React from 'react';
|
|
43
|
+
import { styled } from '@mui/material/styles';
|
|
44
|
+
import Group from './group.js';
|
|
45
|
+
|
|
46
|
+
// - mathquill error window not defined
|
|
47
|
+
import EditableHtmlImport from '@pie-lib/editable-html-tip-tap';
|
|
48
|
+
|
|
49
|
+
const EditableHtml = EditableHtmlImport;
|
|
50
|
+
const StyledEditableHTML: any = styled(EditableHtml)(({ theme }) => ({
|
|
51
|
+
fontFamily: theme.typography.fontFamily,
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
const feedbackLabels = {
|
|
55
|
+
default: 'Simple Feedback',
|
|
56
|
+
none: 'No Feedback',
|
|
57
|
+
custom: 'Customized Feedback',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const StyledFeedbackSelector: any = styled('div')(({ theme }) => ({
|
|
61
|
+
marginBottom: theme.spacing(1),
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
const StyledInputContainer: any = styled(InputContainer)(() => ({
|
|
65
|
+
paddingBottom: 0,
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
const StyledCustomHolder: any = styled('div')(({ theme }) => ({
|
|
69
|
+
marginTop: '0px',
|
|
70
|
+
background: theme.palette.grey[300],
|
|
71
|
+
padding: 0,
|
|
72
|
+
marginBottom: theme.spacing(2),
|
|
73
|
+
borderRadius: '4px',
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
const StyledDefaultHolder: any = styled('div')(({ theme }) => ({
|
|
77
|
+
marginTop: '0px',
|
|
78
|
+
background: theme.palette.grey[300],
|
|
79
|
+
padding: theme.spacing(2),
|
|
80
|
+
marginBottom: theme.spacing(2),
|
|
81
|
+
borderRadius: '4px',
|
|
82
|
+
fontFamily: theme.typography.fontFamily,
|
|
83
|
+
cursor: 'default',
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
const StyledGroup: any = styled(Group)(({ theme }) => ({
|
|
87
|
+
paddingTop: theme.spacing(1),
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
export const FeedbackType = {
|
|
91
|
+
type: PropTypes.oneOf(['default', 'custom', 'none']),
|
|
92
|
+
default: PropTypes.string,
|
|
93
|
+
custom: PropTypes.string,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export class FeedbackSelector extends React.Component {
|
|
97
|
+
static propTypes = {
|
|
98
|
+
keys: PropTypes.arrayOf(PropTypes.string),
|
|
99
|
+
label: PropTypes.string.isRequired,
|
|
100
|
+
feedback: PropTypes.shape(FeedbackType).isRequired,
|
|
101
|
+
onChange: PropTypes.func.isRequired,
|
|
102
|
+
toolbarOpts: PropTypes.object,
|
|
103
|
+
mathMlOptions: PropTypes.object,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
changeType: any = (type) => {
|
|
107
|
+
const { onChange, feedback } = this.props;
|
|
108
|
+
|
|
109
|
+
onChange({ ...feedback, type });
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
changeCustom: any = (custom) => {
|
|
113
|
+
const { onChange, feedback } = this.props;
|
|
114
|
+
|
|
115
|
+
onChange({ ...feedback, type: 'custom', custom });
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
render() {
|
|
119
|
+
const { keys, label, feedback, toolbarOpts, mathMlOptions = {} } = this.props;
|
|
120
|
+
|
|
121
|
+
const feedbackKeys = keys || Object.keys(feedbackLabels);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<StyledFeedbackSelector>
|
|
125
|
+
<StyledInputContainer label={label} extraClasses={{ label: { transform: 'translateY(-20%)' } }}>
|
|
126
|
+
<StyledGroup
|
|
127
|
+
keys={feedbackKeys}
|
|
128
|
+
label={label}
|
|
129
|
+
value={feedback.type}
|
|
130
|
+
onChange={this.changeType}
|
|
131
|
+
feedbackLabels={feedbackLabels}
|
|
132
|
+
/>
|
|
133
|
+
</StyledInputContainer>
|
|
134
|
+
|
|
135
|
+
{feedback.type === 'custom' && (
|
|
136
|
+
<StyledCustomHolder>
|
|
137
|
+
<StyledEditableHTML
|
|
138
|
+
onChange={this.changeCustom}
|
|
139
|
+
markup={feedback.custom || ''}
|
|
140
|
+
toolbarOpts={toolbarOpts}
|
|
141
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
142
|
+
mathMlOptions={mathMlOptions}
|
|
143
|
+
/>
|
|
144
|
+
</StyledCustomHolder>
|
|
145
|
+
)}
|
|
146
|
+
|
|
147
|
+
{feedback.type === 'default' && <StyledDefaultHolder> {feedback.default}</StyledDefaultHolder>}
|
|
148
|
+
</StyledFeedbackSelector>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default FeedbackSelector;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/feedback-config/group.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import RadioWithLabel from '../radio-with-label.js';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
|
|
16
|
+
const StyledChoiceHolder: any = styled('div')(() => ({
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const StyledChoice: any = styled('div')(() => ({
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
const StyledRadioWithLabel: any = styled(RadioWithLabel)(({ theme }) => ({
|
|
27
|
+
'& .MuiFormControlLabel-label': {
|
|
28
|
+
fontSize: theme.typography.fontSize - 2,
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const Group = (props) => {
|
|
33
|
+
const { feedbackLabels, value, className, onChange, keys } = props;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<StyledChoiceHolder className={className}>
|
|
37
|
+
{keys.map((key) => {
|
|
38
|
+
return (
|
|
39
|
+
<StyledChoice key={key}>
|
|
40
|
+
<StyledRadioWithLabel
|
|
41
|
+
value={key}
|
|
42
|
+
checked={value === key}
|
|
43
|
+
onChange={(e) => onChange(e.currentTarget.value)}
|
|
44
|
+
label={feedbackLabels[key]}
|
|
45
|
+
/>
|
|
46
|
+
</StyledChoice>
|
|
47
|
+
);
|
|
48
|
+
})}
|
|
49
|
+
</StyledChoiceHolder>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Group.propTypes = {
|
|
54
|
+
className: PropTypes.string,
|
|
55
|
+
feedbackLabels: PropTypes.object.isRequired,
|
|
56
|
+
value: PropTypes.string.isRequired,
|
|
57
|
+
keys: PropTypes.arrayOf(PropTypes.string),
|
|
58
|
+
onChange: PropTypes.func,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default Group;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/feedback-config/index.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import FeedbackSelector, { FeedbackType } from './feedback-selector.js';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { merge } from 'lodash-es';
|
|
15
|
+
|
|
16
|
+
import { styled } from '@mui/material/styles';
|
|
17
|
+
import Accordion from '@mui/material/Accordion';
|
|
18
|
+
import AccordionSummary from '@mui/material/AccordionSummary';
|
|
19
|
+
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
20
|
+
import Typography from '@mui/material/Typography';
|
|
21
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
22
|
+
|
|
23
|
+
export { FeedbackSelector };
|
|
24
|
+
|
|
25
|
+
const StyledFeedbackContainer: any = styled('div')(() => ({
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flex: 1,
|
|
28
|
+
flexDirection: 'column',
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const StyledAccordionDetails: any = styled(AccordionDetails)(() => ({
|
|
32
|
+
paddingTop: 0,
|
|
33
|
+
paddingBottom: 0,
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
export const buildDefaults = (input) => {
|
|
37
|
+
return merge(
|
|
38
|
+
{},
|
|
39
|
+
{
|
|
40
|
+
correct: { type: 'default', default: 'Correct' },
|
|
41
|
+
incorrect: { type: 'default', default: 'Incorrect' },
|
|
42
|
+
partial: { type: 'default', default: 'Nearly' },
|
|
43
|
+
},
|
|
44
|
+
input,
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export class FeedbackConfig extends React.Component {
|
|
49
|
+
static propTypes = {
|
|
50
|
+
allowPartial: PropTypes.bool,
|
|
51
|
+
className: PropTypes.string,
|
|
52
|
+
feedback: PropTypes.shape({
|
|
53
|
+
correct: PropTypes.shape(FeedbackType),
|
|
54
|
+
incorrect: PropTypes.shape(FeedbackType),
|
|
55
|
+
partial: PropTypes.shape(FeedbackType),
|
|
56
|
+
}),
|
|
57
|
+
onChange: PropTypes.func.isRequired,
|
|
58
|
+
toolbarOpts: PropTypes.object,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
static defaultProps = {
|
|
62
|
+
allowPartial: true,
|
|
63
|
+
feedback: buildDefaults(),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
onChange(key, config) {
|
|
67
|
+
const { feedback, onChange } = this.props;
|
|
68
|
+
const update = { ...feedback, [key]: config };
|
|
69
|
+
|
|
70
|
+
onChange(update);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
onCorrectChange = this.onChange.bind(this, 'correct');
|
|
74
|
+
|
|
75
|
+
onIncorrectChange = this.onChange.bind(this, 'incorrect');
|
|
76
|
+
|
|
77
|
+
onPartialChange = this.onChange.bind(this, 'partial');
|
|
78
|
+
|
|
79
|
+
render() {
|
|
80
|
+
const { className, allowPartial, feedback, toolbarOpts } = this.props;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div className={className}>
|
|
84
|
+
<Accordion slotProps={{ transition: { timeout: { enter: 225, exit: 195 } } }}>
|
|
85
|
+
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
86
|
+
<Typography>Feedback</Typography>
|
|
87
|
+
</AccordionSummary>
|
|
88
|
+
|
|
89
|
+
<StyledAccordionDetails>
|
|
90
|
+
<StyledFeedbackContainer>
|
|
91
|
+
<FeedbackSelector
|
|
92
|
+
label="If correct, show"
|
|
93
|
+
feedback={feedback.correct}
|
|
94
|
+
onChange={this.onCorrectChange}
|
|
95
|
+
toolbarOpts={toolbarOpts}
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
{allowPartial && (
|
|
99
|
+
<FeedbackSelector
|
|
100
|
+
label="If partially correct, show"
|
|
101
|
+
feedback={feedback.partial}
|
|
102
|
+
onChange={this.onPartialChange}
|
|
103
|
+
toolbarOpts={toolbarOpts}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
|
|
107
|
+
<FeedbackSelector
|
|
108
|
+
label="If incorrect, show"
|
|
109
|
+
feedback={feedback.incorrect}
|
|
110
|
+
onChange={this.onIncorrectChange}
|
|
111
|
+
toolbarOpts={toolbarOpts}
|
|
112
|
+
/>
|
|
113
|
+
</StyledFeedbackContainer>
|
|
114
|
+
</StyledAccordionDetails>
|
|
115
|
+
</Accordion>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default FeedbackConfig;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/form-section.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import Typography from '@mui/material/Typography';
|
|
14
|
+
import { styled } from '@mui/material/styles';
|
|
15
|
+
|
|
16
|
+
const StyledFormSection: any = styled('div')(({ theme }) => ({
|
|
17
|
+
marginTop: theme.spacing(2),
|
|
18
|
+
marginBottom: theme.spacing(2),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const StyledTypography: any = styled(Typography)(({ theme }) => ({
|
|
22
|
+
marginBottom: theme.spacing(1),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const FormSection = ({ className, label, children, labelExtraStyle }) => (
|
|
26
|
+
<StyledFormSection className={className}>
|
|
27
|
+
<StyledTypography variant="subtitle1" style={labelExtraStyle}>
|
|
28
|
+
{label}
|
|
29
|
+
</StyledTypography>
|
|
30
|
+
{children}
|
|
31
|
+
</StyledFormSection>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
FormSection.propTypes = {
|
|
35
|
+
className: PropTypes.string,
|
|
36
|
+
label: PropTypes.string,
|
|
37
|
+
children: PropTypes.node,
|
|
38
|
+
labelExtraStyle: PropTypes.object,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default FormSection;
|
package/src/help.tsx
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/help.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Dialog from '@mui/material/Dialog';
|
|
12
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
13
|
+
import DialogContentText from '@mui/material/DialogContentText';
|
|
14
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
15
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
16
|
+
import PropTypes from 'prop-types';
|
|
17
|
+
|
|
18
|
+
import Button from '@mui/material/Button';
|
|
19
|
+
import HelpIcon from '@mui/icons-material/Help';
|
|
20
|
+
import IconButton from '@mui/material/IconButton';
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import { styled } from '@mui/material/styles';
|
|
23
|
+
|
|
24
|
+
const StyledIconButton: any = styled(IconButton)(({ theme }) => ({
|
|
25
|
+
'&:hover': {
|
|
26
|
+
color: theme.palette.grey[300],
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export const HelpButton = ({ onClick }) => (
|
|
31
|
+
<StyledIconButton onClick={onClick} size="large">
|
|
32
|
+
<HelpIcon />
|
|
33
|
+
</StyledIconButton>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
HelpButton.propTypes = {
|
|
37
|
+
onClick: PropTypes.func,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const HelpDialog = ({ open, onClose, children, title }) => (
|
|
41
|
+
<Dialog open={open} onClose={onClose}>
|
|
42
|
+
<DialogTitle>{title}</DialogTitle>
|
|
43
|
+
<DialogContent>
|
|
44
|
+
<DialogContentText>{children}</DialogContentText>
|
|
45
|
+
</DialogContent>
|
|
46
|
+
<DialogActions>
|
|
47
|
+
<Button onClick={onClose} color="primary">
|
|
48
|
+
OK
|
|
49
|
+
</Button>
|
|
50
|
+
</DialogActions>
|
|
51
|
+
</Dialog>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
HelpDialog.propTypes = {
|
|
55
|
+
open: PropTypes.bool,
|
|
56
|
+
onClose: PropTypes.func,
|
|
57
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
58
|
+
title: PropTypes.string.isRequired,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
class Help extends React.Component {
|
|
62
|
+
static propTypes = {
|
|
63
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
64
|
+
title: PropTypes.string,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
constructor(props) {
|
|
68
|
+
super(props);
|
|
69
|
+
this.state = {
|
|
70
|
+
open: false,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const { children, title } = this.props;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div>
|
|
79
|
+
<HelpButton color="accent" onClick={() => this.setState({ open: true })} />
|
|
80
|
+
|
|
81
|
+
<HelpDialog open={this.state.open} title={title} onClose={() => this.setState({ open: false })}>
|
|
82
|
+
{children}
|
|
83
|
+
</HelpDialog>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default Help;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/index.js
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import AlertDialog from './alert-dialog.js';
|
|
12
|
+
import FeedbackConfig, { buildDefaults as feedbackConfigDefaults, FeedbackSelector } from './feedback-config/index.js';
|
|
13
|
+
import { InputCheckbox, InputRadio, InputSwitch } from './inputs.js';
|
|
14
|
+
import Langs, { LanguageControls } from './langs.js';
|
|
15
|
+
import Tabs from './tabs/index.js';
|
|
16
|
+
import Checkbox from './checkbox.js';
|
|
17
|
+
import FormSection from './form-section.js';
|
|
18
|
+
import Help from './help.js';
|
|
19
|
+
import Input from './input.js';
|
|
20
|
+
import { InputContainer as InputContainerImport } from '@pie-lib/render-ui';
|
|
21
|
+
|
|
22
|
+
function isRenderableReactInteropType(value: any) {
|
|
23
|
+
return (
|
|
24
|
+
typeof value === 'function' ||
|
|
25
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
30
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
31
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
32
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
33
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
34
|
+
return maybeSymbol[namedExport];
|
|
35
|
+
}
|
|
36
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
37
|
+
return maybeSymbol[namedExport].default;
|
|
38
|
+
}
|
|
39
|
+
return maybeSymbol;
|
|
40
|
+
}
|
|
41
|
+
const InputContainer = unwrapReactInteropSymbol(InputContainerImport, 'InputContainer') || unwrapReactInteropSymbol(renderUi.InputContainer, 'InputContainer');
|
|
42
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
43
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
44
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
45
|
+
const renderUi =
|
|
46
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
47
|
+
? renderUiDefaultMaybe
|
|
48
|
+
: renderUiNamespaceAny;
|
|
49
|
+
import NumberTextField from './number-text-field.js';
|
|
50
|
+
import NumberTextFieldCustom from './number-text-field-custom.js';
|
|
51
|
+
import TwoChoice, { NChoice } from './two-choice.js';
|
|
52
|
+
import TagsInput from './tags-input/index.js';
|
|
53
|
+
import MuiBox from './mui-box/index.js';
|
|
54
|
+
import ChoiceConfiguration from './choice-configuration/index.js';
|
|
55
|
+
import * as layout from './layout/index.js';
|
|
56
|
+
|
|
57
|
+
import * as choiceUtils from './choice-utils.js';
|
|
58
|
+
import withStatefulModel from './with-stateful-model.js';
|
|
59
|
+
import Toggle from './settings/toggle.js';
|
|
60
|
+
import DisplaySize from './settings/display-size.js';
|
|
61
|
+
|
|
62
|
+
import * as settings from './settings/index.js';
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
AlertDialog,
|
|
66
|
+
FeedbackConfig,
|
|
67
|
+
FeedbackSelector,
|
|
68
|
+
feedbackConfigDefaults,
|
|
69
|
+
InputCheckbox,
|
|
70
|
+
InputSwitch,
|
|
71
|
+
InputRadio,
|
|
72
|
+
Langs,
|
|
73
|
+
LanguageControls,
|
|
74
|
+
Tabs,
|
|
75
|
+
Checkbox,
|
|
76
|
+
FormSection,
|
|
77
|
+
Help,
|
|
78
|
+
Input,
|
|
79
|
+
InputContainer,
|
|
80
|
+
NumberTextField,
|
|
81
|
+
NumberTextFieldCustom,
|
|
82
|
+
TwoChoice,
|
|
83
|
+
NChoice,
|
|
84
|
+
TagsInput,
|
|
85
|
+
MuiBox,
|
|
86
|
+
ChoiceConfiguration,
|
|
87
|
+
layout,
|
|
88
|
+
choiceUtils,
|
|
89
|
+
withStatefulModel,
|
|
90
|
+
Toggle,
|
|
91
|
+
DisplaySize,
|
|
92
|
+
settings,
|
|
93
|
+
};
|
package/src/input.tsx
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/config-ui/src/input.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { default as MaterialInput } from '@mui/material/Input';
|
|
14
|
+
import { InputContainer as InputContainerImport } from '@pie-lib/render-ui';
|
|
15
|
+
|
|
16
|
+
function isRenderableReactInteropType(value: any) {
|
|
17
|
+
return (
|
|
18
|
+
typeof value === 'function' ||
|
|
19
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
24
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
25
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
26
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
27
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
28
|
+
return maybeSymbol[namedExport];
|
|
29
|
+
}
|
|
30
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
31
|
+
return maybeSymbol[namedExport].default;
|
|
32
|
+
}
|
|
33
|
+
return maybeSymbol;
|
|
34
|
+
}
|
|
35
|
+
const InputContainer = unwrapReactInteropSymbol(InputContainerImport, 'InputContainer') || unwrapReactInteropSymbol(renderUi.InputContainer, 'InputContainer');
|
|
36
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
37
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
38
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
39
|
+
const renderUi =
|
|
40
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
41
|
+
? renderUiDefaultMaybe
|
|
42
|
+
: renderUiNamespaceAny;
|
|
43
|
+
export default class Input extends React.Component {
|
|
44
|
+
static propTypes = {
|
|
45
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
46
|
+
onChange: PropTypes.func.isRequired,
|
|
47
|
+
label: PropTypes.string,
|
|
48
|
+
type: PropTypes.string.isRequired,
|
|
49
|
+
error: PropTypes.func,
|
|
50
|
+
noModelUpdateOnError: PropTypes.bool,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
static defaultProps = {
|
|
54
|
+
type: 'text',
|
|
55
|
+
error: (value, type) => (type === 'number' ? !value || isNaN(value) : !value),
|
|
56
|
+
noModelUpdateOnError: false,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
constructor(props) {
|
|
60
|
+
super(props);
|
|
61
|
+
|
|
62
|
+
this.state = {
|
|
63
|
+
value: props.value,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
UNSAFE_componentWillReceiveProps(newProps) {
|
|
68
|
+
this.setState({
|
|
69
|
+
value: newProps.value,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
onChange: any = (event) => {
|
|
74
|
+
const { type, onChange, error } = this.props;
|
|
75
|
+
const value = event.target.value;
|
|
76
|
+
|
|
77
|
+
if (error(value, type)) {
|
|
78
|
+
this.setState({
|
|
79
|
+
error: true,
|
|
80
|
+
value: event.target.value,
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
this.setState({
|
|
84
|
+
error: false,
|
|
85
|
+
value: event.target.value,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
onChange(event);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
render() {
|
|
93
|
+
const {
|
|
94
|
+
label,
|
|
95
|
+
type,
|
|
96
|
+
noModelUpdateOnError, // eslint-disable-line no-unused-vars
|
|
97
|
+
...rest
|
|
98
|
+
} = this.props;
|
|
99
|
+
const { value, error } = this.state;
|
|
100
|
+
|
|
101
|
+
return label ? (
|
|
102
|
+
<InputContainer label={label}>
|
|
103
|
+
<MaterialInput type={type} {...rest} value={value} onChange={this.onChange} error={error} />
|
|
104
|
+
</InputContainer>
|
|
105
|
+
) : (
|
|
106
|
+
<MaterialInput type={type} {...rest} value={value} onChange={this.onChange} error={error} />
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|