@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.
Files changed (132) 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.d.ts.map +1 -0
  4. package/dist/alert-dialog.js +47 -0
  5. package/dist/checkbox.d.ts +34 -0
  6. package/dist/checkbox.d.ts.map +1 -0
  7. package/dist/checkbox.js +57 -0
  8. package/dist/choice-configuration/feedback-menu.d.ts +33 -0
  9. package/dist/choice-configuration/feedback-menu.d.ts.map +1 -0
  10. package/dist/choice-configuration/feedback-menu.js +85 -0
  11. package/dist/choice-configuration/index.d.ts +63 -0
  12. package/dist/choice-configuration/index.d.ts.map +1 -0
  13. package/dist/choice-configuration/index.js +240 -0
  14. package/dist/choice-utils.d.ts +22 -0
  15. package/dist/choice-utils.d.ts.map +1 -0
  16. package/dist/choice-utils.js +15 -0
  17. package/dist/feedback-config/feedback-selector.d.ts +34 -0
  18. package/dist/feedback-config/feedback-selector.d.ts.map +1 -0
  19. package/dist/feedback-config/feedback-selector.js +92 -0
  20. package/dist/feedback-config/group.d.ts +21 -0
  21. package/dist/feedback-config/group.d.ts.map +1 -0
  22. package/dist/feedback-config/group.js +33 -0
  23. package/dist/feedback-config/index.d.ts +49 -0
  24. package/dist/feedback-config/index.d.ts.map +1 -0
  25. package/dist/feedback-config/index.js +96 -0
  26. package/dist/form-section.d.ts +25 -0
  27. package/dist/form-section.d.ts.map +1 -0
  28. package/dist/form-section.js +25 -0
  29. package/dist/help.d.ts +42 -0
  30. package/dist/help.d.ts.map +1 -0
  31. package/dist/help.js +61 -0
  32. package/dist/index.d.ts +32 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +34 -0
  35. package/dist/input.d.ts +30 -0
  36. package/dist/input.d.ts.map +1 -0
  37. package/dist/input.js +65 -0
  38. package/dist/inputs.d.ts +63 -0
  39. package/dist/inputs.d.ts.map +1 -0
  40. package/dist/inputs.js +70 -0
  41. package/dist/langs.d.ts +42 -0
  42. package/dist/langs.d.ts.map +1 -0
  43. package/dist/langs.js +76 -0
  44. package/dist/layout/config-layout.d.ts +11 -0
  45. package/dist/layout/config-layout.d.ts.map +1 -0
  46. package/dist/layout/config-layout.js +75 -0
  47. package/dist/layout/index.d.ts +12 -0
  48. package/dist/layout/index.d.ts.map +1 -0
  49. package/dist/layout/index.js +10 -0
  50. package/dist/layout/layout-contents.d.ts +22 -0
  51. package/dist/layout/layout-contents.d.ts.map +1 -0
  52. package/dist/layout/layout-contents.js +70 -0
  53. package/dist/layout/settings-box.d.ts +20 -0
  54. package/dist/layout/settings-box.d.ts.map +1 -0
  55. package/dist/layout/settings-box.js +31 -0
  56. package/dist/mui-box/index.d.ts +21 -0
  57. package/dist/mui-box/index.d.ts.map +1 -0
  58. package/dist/mui-box/index.js +47 -0
  59. package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  60. package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
  61. package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  62. package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
  63. package/dist/node_modules/.bun/react-measure@2.5.2_6dbf9a050bc9aadb/node_modules/react-measure/dist/index.esm.js +122 -0
  64. package/dist/node_modules/.bun/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +276 -0
  65. package/dist/number-text-field-custom.d.ts +52 -0
  66. package/dist/number-text-field-custom.d.ts.map +1 -0
  67. package/dist/number-text-field-custom.js +192 -0
  68. package/dist/number-text-field.d.ts +48 -0
  69. package/dist/number-text-field.d.ts.map +1 -0
  70. package/dist/number-text-field.js +122 -0
  71. package/dist/radio-with-label.d.ts +25 -0
  72. package/dist/radio-with-label.d.ts.map +1 -0
  73. package/dist/radio-with-label.js +27 -0
  74. package/dist/settings/display-size.d.ts +26 -0
  75. package/dist/settings/display-size.d.ts.map +1 -0
  76. package/dist/settings/display-size.js +45 -0
  77. package/dist/settings/index.d.ts +46 -0
  78. package/dist/settings/index.d.ts.map +1 -0
  79. package/dist/settings/index.js +63 -0
  80. package/dist/settings/panel.d.ts +28 -0
  81. package/dist/settings/panel.d.ts.map +1 -0
  82. package/dist/settings/panel.js +201 -0
  83. package/dist/settings/settings-radio-label.d.ts +25 -0
  84. package/dist/settings/settings-radio-label.d.ts.map +1 -0
  85. package/dist/settings/settings-radio-label.js +29 -0
  86. package/dist/settings/toggle.d.ts +25 -0
  87. package/dist/settings/toggle.d.ts.map +1 -0
  88. package/dist/settings/toggle.js +33 -0
  89. package/dist/tabs/index.d.ts +23 -0
  90. package/dist/tabs/index.d.ts.map +1 -0
  91. package/dist/tabs/index.js +39 -0
  92. package/dist/tags-input/index.d.ts +22 -0
  93. package/dist/tags-input/index.d.ts.map +1 -0
  94. package/dist/tags-input/index.js +83 -0
  95. package/dist/two-choice.d.ts +44 -0
  96. package/dist/two-choice.d.ts.map +1 -0
  97. package/dist/two-choice.js +79 -0
  98. package/dist/with-stateful-model.d.ts +22 -0
  99. package/dist/with-stateful-model.d.ts.map +1 -0
  100. package/dist/with-stateful-model.js +32 -0
  101. package/package.json +40 -0
  102. package/src/alert-dialog.tsx +85 -0
  103. package/src/checkbox.tsx +71 -0
  104. package/src/choice-configuration/feedback-menu.tsx +134 -0
  105. package/src/choice-configuration/index.tsx +400 -0
  106. package/src/choice-utils.ts +40 -0
  107. package/src/feedback-config/feedback-selector.tsx +153 -0
  108. package/src/feedback-config/group.tsx +61 -0
  109. package/src/feedback-config/index.tsx +121 -0
  110. package/src/form-section.tsx +41 -0
  111. package/src/help.tsx +89 -0
  112. package/src/index.ts +93 -0
  113. package/src/input.tsx +109 -0
  114. package/src/inputs.tsx +107 -0
  115. package/src/langs.tsx +121 -0
  116. package/src/layout/config-layout.tsx +113 -0
  117. package/src/layout/index.ts +14 -0
  118. package/src/layout/layout-contents.tsx +127 -0
  119. package/src/layout/settings-box.tsx +42 -0
  120. package/src/mui-box/index.tsx +66 -0
  121. package/src/number-text-field-custom.tsx +343 -0
  122. package/src/number-text-field.tsx +229 -0
  123. package/src/radio-with-label.tsx +40 -0
  124. package/src/settings/display-size.tsx +63 -0
  125. package/src/settings/index.ts +93 -0
  126. package/src/settings/panel.tsx +343 -0
  127. package/src/settings/settings-radio-label.tsx +42 -0
  128. package/src/settings/toggle.tsx +56 -0
  129. package/src/tabs/index.tsx +57 -0
  130. package/src/tags-input/index.tsx +126 -0
  131. package/src/two-choice.tsx +128 -0
  132. package/src/with-stateful-model.tsx +46 -0
@@ -0,0 +1,93 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-lib/packages/config-ui/src/settings/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 Panel from './panel.js';
12
+
13
+ export { Panel };
14
+
15
+ export const textField = (label, isConfigProperty = true) => ({
16
+ label,
17
+ type: 'textField',
18
+ isConfigProperty,
19
+ });
20
+
21
+ export const toggle = (label, isConfigProperty = false, disabled = false) => ({
22
+ type: 'toggle',
23
+ label,
24
+ isConfigProperty,
25
+ disabled,
26
+ });
27
+
28
+ const toChoice = (opt) => {
29
+ if (typeof opt === 'string') {
30
+ return { label: opt, value: opt };
31
+ } else {
32
+ return opt;
33
+ }
34
+ };
35
+
36
+ export const radio = function () {
37
+ const args = Array.prototype.slice.call(arguments);
38
+ const [label, choices, isConfigProperty = false] = args;
39
+
40
+ return {
41
+ type: 'radio',
42
+ label,
43
+ choices: choices && choices.map((o) => toChoice(o)),
44
+ isConfigProperty,
45
+ };
46
+ };
47
+
48
+ export const dropdown = (label, choices, isConfigProperty = false) => {
49
+ return {
50
+ type: 'dropdown',
51
+ label,
52
+ choices,
53
+ isConfigProperty,
54
+ };
55
+ };
56
+
57
+ export const numberField = (label, options, isConfigProperty = false) => ({
58
+ ...options,
59
+ label,
60
+ type: 'numberField',
61
+ isConfigProperty,
62
+ });
63
+
64
+ export const numberFields = (label, fields, isConfigProperty = false) => {
65
+ Object.keys(fields).map((key) => {
66
+ fields[key] = numberField(fields[key].label, fields[key], isConfigProperty);
67
+ });
68
+
69
+ return {
70
+ type: 'numberFields',
71
+ label,
72
+ fields,
73
+ };
74
+ };
75
+
76
+ export const checkbox = (label, settings, isConfigProperty = false) => ({
77
+ ...settings,
78
+ label,
79
+ type: 'checkbox',
80
+ isConfigProperty,
81
+ });
82
+
83
+ export const checkboxes = (label, choices, isConfigProperty = false) => {
84
+ Object.keys(choices).map((key) => {
85
+ choices[key] = checkbox(choices[key].label, choices[key], isConfigProperty);
86
+ });
87
+
88
+ return {
89
+ type: 'checkboxes',
90
+ label,
91
+ choices,
92
+ };
93
+ };
@@ -0,0 +1,343 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-lib/packages/config-ui/src/settings/panel.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 { get, set } from 'lodash-es';
14
+ import { styled } from '@mui/material/styles';
15
+ import Select from '@mui/material/Select';
16
+ import Input from '@mui/material/Input';
17
+ import MenuItem from '@mui/material/MenuItem';
18
+ import Typography from '@mui/material/Typography';
19
+ import debug from 'debug';
20
+
21
+ import Toggle from './toggle.js';
22
+ import { NChoice } from '../two-choice.js';
23
+ import SettingsRadioLabel from './settings-radio-label.js';
24
+ import NumberTextField from '../number-text-field.js';
25
+ import Checkbox from '../checkbox.js';
26
+
27
+ const log = debug('pie-lib:config-ui:settings:panel');
28
+
29
+ const labelValue = {
30
+ label: PropTypes.string,
31
+ value: PropTypes.string,
32
+ };
33
+
34
+ const baseTypes = {
35
+ label: PropTypes.string,
36
+ value: PropTypes.string,
37
+ onChange: PropTypes.func,
38
+ };
39
+
40
+ const CheckboxChoice = ({ label, value, onChange }) => {
41
+ return (
42
+ <Checkbox
43
+ checked={value}
44
+ label={label}
45
+ onChange={(event) => {
46
+ onChange(event.target.checked);
47
+ }}
48
+ />
49
+ );
50
+ };
51
+
52
+ CheckboxChoice.propTypes = {
53
+ label: PropTypes.string,
54
+ value: PropTypes.bool,
55
+ onChange: PropTypes.func,
56
+ };
57
+
58
+ const StyledNChoice: any = styled(NChoice)(({ theme }) => ({
59
+ marginTop: theme.spacing(0.5),
60
+ paddingBottom: theme.spacing(0.5),
61
+ width: '100%',
62
+ '& > label': {
63
+ color: 'rgba(0, 0, 0, 0.89)',
64
+ transform: 'translate(0, 10px) scale(1)',
65
+ fontSize: '18px',
66
+ marginTop: theme.spacing(2.5),
67
+ },
68
+ '& > div': {
69
+ marginTop: theme.spacing(2.5),
70
+ },
71
+ }));
72
+
73
+ const Radio = ({ label, value, onChange, choices }) => {
74
+ return (
75
+ <StyledNChoice
76
+ direction="horizontal"
77
+ customLabel={SettingsRadioLabel}
78
+ value={value}
79
+ header={label}
80
+ opts={choices}
81
+ onChange={onChange}
82
+ />
83
+ );
84
+ };
85
+
86
+ Radio.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.shape(labelValue)) };
87
+
88
+ const StyledRadio = Radio;
89
+
90
+ const StyledLabel: any = styled('p')(({ theme }) => ({
91
+ margin: 0,
92
+ fontSize: theme.typography.fontSize,
93
+ }));
94
+
95
+ const StyledSelect: any = styled(Select)(({ theme }) => ({
96
+ marginTop: theme.spacing(0.5),
97
+ border: '2px solid lightgrey',
98
+ padding: `0 ${theme.spacing(1)}`,
99
+ borderRadius: '4px',
100
+ }));
101
+
102
+ const Dropdown = ({ label, value, onChange, choices = [] }) => {
103
+ const getItemLabel = (l) => (typeof l === 'string' ? l : l.label);
104
+ const getItemValue = (l) => (typeof l === 'string' ? l : l.value);
105
+ return (
106
+ <div>
107
+ {label && <StyledLabel>{label}</StyledLabel>}
108
+ <StyledSelect
109
+ value={value || (choices && choices[0])}
110
+ onChange={({ target }) => onChange(target.value)}
111
+ input={<Input id={`dropdown-${label}`} />}
112
+ disableUnderline
113
+ MenuProps={{ transitionDuration: { enter: 225, exit: 195 } }}
114
+ >
115
+ {choices.map((l, index) => (
116
+ <MenuItem key={index} value={getItemValue(l)}>
117
+ {getItemLabel(l)}
118
+ </MenuItem>
119
+ ))}
120
+ </StyledSelect>
121
+ </div>
122
+ );
123
+ };
124
+
125
+ Dropdown.propTypes = { ...baseTypes, choices: PropTypes.arrayOf(PropTypes.string) };
126
+
127
+ const StyledTypography: any = styled(Typography)(({ theme }) => ({
128
+ marginRight: theme.spacing(3),
129
+ marginTop: theme.spacing(1),
130
+ }));
131
+
132
+ const TextField = ({ label }) => {
133
+ return <StyledTypography>{label}</StyledTypography>;
134
+ };
135
+
136
+ const StyledNumberTextField: any = styled(NumberTextField)(({ theme }) => ({
137
+ width: '35%',
138
+ marginRight: theme.spacing(3),
139
+ marginTop: theme.spacing(1),
140
+ '& .MuiInputBase-root': {
141
+ marginTop: theme.spacing(0.5),
142
+ border: '2px solid lightgrey',
143
+ borderRadius: '4px',
144
+ padding: `0 ${theme.spacing(1)}`,
145
+ backgroundColor: 'transparent',
146
+ },
147
+ }));
148
+
149
+ const NumberField = ({ label, value, onChange = () => {}, suffix, min, max }) => {
150
+ return (
151
+ <StyledNumberTextField
152
+ variant={'standard'}
153
+ label={label || 'Label'}
154
+ value={value}
155
+ max={max}
156
+ min={min}
157
+ onChange={(ev, value) => onChange(value)}
158
+ suffix={suffix}
159
+ showErrorWhenOutsideRange
160
+ disableUnderline
161
+ />
162
+ );
163
+ };
164
+
165
+ NumberField.propTypes = {
166
+ ...baseTypes,
167
+ suffix: PropTypes.string,
168
+ min: PropTypes.number,
169
+ max: PropTypes.number,
170
+ value: PropTypes.number,
171
+ };
172
+
173
+ TextField.propTypes = {
174
+ ...baseTypes,
175
+ };
176
+
177
+ const ToggleWrapper = ({ disabled, label, value, onChange }) => (
178
+ <Toggle label={label} checked={!!value} disabled={!!disabled} toggle={onChange} />
179
+ );
180
+
181
+ ToggleWrapper.propTypes = { ...baseTypes, value: PropTypes.bool };
182
+
183
+ const tagMap = {
184
+ toggle: ToggleWrapper,
185
+ radio: StyledRadio,
186
+ dropdown: Dropdown,
187
+ numberField: NumberField,
188
+ checkbox: CheckboxChoice,
189
+ textField: TextField,
190
+ };
191
+
192
+ const StyledGroup: any = styled('div')(({ theme }) => ({
193
+ margin: `0 0 ${theme.spacing(2)} 0`,
194
+ }));
195
+
196
+ const StyledGroupHeader: any = styled('div')(({ theme }) => ({
197
+ color: '#495B8F',
198
+ fontSize: theme.typography.fontSize + 2,
199
+ fontWeight: 600,
200
+ marginBottom: theme.spacing(1),
201
+ }));
202
+
203
+ const StyledNumberFields: any = styled('p')(({ theme }) => ({
204
+ fontSize: theme.typography.fontSize,
205
+ marginBottom: 0,
206
+ }));
207
+
208
+ const Group = (props) => {
209
+ const { model, label, group, configuration, onChange } = props;
210
+
211
+ /**
212
+ * @param group - the group of settings
213
+ * @param key - the key(or path) to be used to set or get from model or configuration
214
+ * @param innerKey - the key(or path) to be used to get from the group (used only for numberField type)
215
+ * @returns tag that corresponds to element type */
216
+ const getTag = (group, key, innerKey) => {
217
+ const { isConfigProperty, ...properties } = get(group, innerKey || key);
218
+ const value = isConfigProperty ? get(configuration, key) : get(model, key);
219
+ const tagProps = { ...properties, key, value };
220
+ const Tag = tagMap[tagProps.type];
221
+
222
+ return <Tag key={key} {...tagProps} onChange={(v) => onChange(key, v, isConfigProperty)} />;
223
+ };
224
+
225
+ const content = (group, key) => {
226
+ const currentGroup = group[key];
227
+
228
+ if (!currentGroup) {
229
+ return null;
230
+ }
231
+
232
+ const { type, label, fields, choices } = currentGroup;
233
+
234
+ if (type === 'numberFields') {
235
+ return (
236
+ <div key={`numberField-${label}`}>
237
+ <StyledNumberFields>{label}</StyledNumberFields>
238
+ {Object.keys(fields).map((fieldKey) => {
239
+ return getTag(group, `${key}.${fieldKey}`, `${key}.fields.${fieldKey}`);
240
+ })}
241
+ </div>
242
+ );
243
+ }
244
+
245
+ if (type === 'checkboxes') {
246
+ return (
247
+ <div key={`checkbox-${label}`}>
248
+ <p>{label}</p>
249
+ {Object.keys(choices).map((choiceKey) => {
250
+ return getTag(group, `${key}.${choiceKey}`, `${key}.choices.${choiceKey}`);
251
+ })}
252
+ </div>
253
+ );
254
+ }
255
+
256
+ // if type is toggle, radio, dropdown, numberField or numberText
257
+ return getTag(group, key);
258
+ };
259
+
260
+ return (
261
+ <StyledGroup>
262
+ <StyledGroupHeader>{label}</StyledGroupHeader>
263
+
264
+ {Object.keys(group).map((key) => {
265
+ return content(group, key);
266
+ })}
267
+ </StyledGroup>
268
+ );
269
+ };
270
+
271
+ Group.propTypes = {
272
+ model: PropTypes.object,
273
+ label: PropTypes.string,
274
+ group: PropTypes.object,
275
+ configuration: PropTypes.object,
276
+ onChange: PropTypes.func,
277
+ };
278
+
279
+ export class Panel extends React.Component {
280
+ static propTypes = {
281
+ model: PropTypes.object,
282
+ configuration: PropTypes.object,
283
+ groups: PropTypes.object,
284
+ onChangeModel: PropTypes.func,
285
+ onChangeConfiguration: PropTypes.func,
286
+ modal: PropTypes.object,
287
+ };
288
+
289
+ static defaultProps = {
290
+ onChangeModel: () => {},
291
+ onChangeConfiguration: () => {},
292
+ };
293
+
294
+ change: any = (key, value, isConfigProperty = false) => {
295
+ log('[changeModel]', key, value);
296
+
297
+ const { onChangeModel, onChangeConfiguration } = this.props;
298
+ const model = { ...this.props.model };
299
+ const configuration = { ...this.props.configuration };
300
+
301
+ if (isConfigProperty) {
302
+ set(configuration, key, value);
303
+ onChangeConfiguration(configuration, key);
304
+ } else {
305
+ set(model, key, value);
306
+ onChangeModel(model, key);
307
+ }
308
+ };
309
+
310
+ render() {
311
+ const { groups, model, configuration, modal } = this.props;
312
+
313
+ log('render:', model);
314
+
315
+ const renderedGroups = Object.keys(groups || {}).map((group) => {
316
+ const showGroup = Object.entries(groups[group]).some(([, propVal]) => !!propVal);
317
+
318
+ if (showGroup) {
319
+ return (
320
+ <Group
321
+ label={group}
322
+ key={group}
323
+ model={model}
324
+ configuration={configuration}
325
+ group={groups[group]}
326
+ onChange={this.change}
327
+ />
328
+ );
329
+ }
330
+
331
+ return null;
332
+ });
333
+
334
+ return (
335
+ <div>
336
+ {renderedGroups}
337
+ {modal}
338
+ </div>
339
+ );
340
+ }
341
+ }
342
+
343
+ export default Panel;
@@ -0,0 +1,42 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-lib/packages/config-ui/src/settings/settings-radio-label.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 FormControlLabel from '@mui/material/FormControlLabel';
12
+ import Radio from '@mui/material/Radio';
13
+ import React from 'react';
14
+ import PropTypes from 'prop-types';
15
+ import { styled } from '@mui/material/styles';
16
+ import { color } from '@pie-lib/render-ui';
17
+
18
+ const StyledFormControlLabel: any = styled(FormControlLabel)(({ theme }) => ({
19
+ '& .MuiFormControlLabel-label': {
20
+ color: 'rgba(0, 0, 0, 0.89)',
21
+ fontSize: theme.typography.fontSize - 2,
22
+ left: '-5px',
23
+ position: 'relative',
24
+ },
25
+ }));
26
+
27
+ const StyledRadio: any = styled(Radio)(() => ({
28
+ color: `${color.tertiary()} !important`,
29
+ }));
30
+
31
+ const SettingsRadioLabel = ({ label, value, checked, onChange }) => (
32
+ <StyledFormControlLabel value={value} control={<StyledRadio checked={checked} onChange={onChange} />} label={label} />
33
+ );
34
+
35
+ SettingsRadioLabel.propTypes = {
36
+ label: PropTypes.string,
37
+ value: PropTypes.string,
38
+ checked: PropTypes.bool,
39
+ onChange: PropTypes.func,
40
+ };
41
+
42
+ export default SettingsRadioLabel;
@@ -0,0 +1,56 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-lib/packages/config-ui/src/settings/toggle.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 InputLabel from '@mui/material/InputLabel';
14
+ import { styled } from '@mui/material/styles';
15
+ import Switch from '@mui/material/Switch';
16
+ import { color } from '@pie-lib/render-ui';
17
+
18
+ const StyledToggle: any = styled('div')(() => ({
19
+ display: 'flex',
20
+ width: '100%',
21
+ justifyContent: 'space-between',
22
+ }));
23
+
24
+ const StyledInputLabel: any = styled(InputLabel)(({ theme }) => ({
25
+ color: 'rgba(0, 0, 0, 0.89)',
26
+ fontSize: theme.typography.fontSize,
27
+ paddingTop: theme.spacing(2),
28
+ }));
29
+
30
+ const StyledSwitch: any = styled(Switch)(({ checked }) => ({
31
+ '&.Mui-checked .MuiSwitch-thumb': {
32
+ color: `${color.tertiary()} !important`,
33
+ },
34
+ '&.Mui-checked .MuiSwitch-track': {
35
+ backgroundColor: `${color.tertiaryLight()} !important`,
36
+ },
37
+ '& .MuiSwitch-track': {
38
+ backgroundColor: checked ? `${color.tertiaryLight()} !important` : undefined,
39
+ },
40
+ }));
41
+
42
+ const Toggle = ({ checked, disabled, label, toggle }) => (
43
+ <StyledToggle>
44
+ <StyledInputLabel>{label}</StyledInputLabel>
45
+ <StyledSwitch checked={checked} disabled={disabled} onChange={(e) => toggle(e.target.checked)} />
46
+ </StyledToggle>
47
+ );
48
+
49
+ Toggle.propTypes = {
50
+ checked: PropTypes.bool,
51
+ disabled: PropTypes.bool,
52
+ label: PropTypes.string.isRequired,
53
+ toggle: PropTypes.func.isRequired,
54
+ };
55
+
56
+ export default Toggle;
@@ -0,0 +1,57 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * @synced-from pie-lib/packages/config-ui/src/tabs/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 React from 'react';
12
+
13
+ import MuiTabs from '@mui/material/Tabs';
14
+ import MuiTab from '@mui/material/Tab';
15
+ import PropTypes from 'prop-types';
16
+ import { styled } from '@mui/material/styles';
17
+
18
+ const StyledMuiTab: any = styled(MuiTab)(() => ({}));
19
+
20
+ export class Tabs extends React.Component {
21
+ static propTypes = {
22
+ className: PropTypes.string,
23
+ contentClassName: PropTypes.string,
24
+ contentStyle: PropTypes.object,
25
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
26
+ };
27
+
28
+ constructor(props) {
29
+ super(props);
30
+ this.state = { value: 0 };
31
+ }
32
+
33
+ handleChange: any = (event, value) => {
34
+ this.setState({ value });
35
+ };
36
+
37
+ render() {
38
+ const { value } = this.state;
39
+ const { children, className, contentClassName, contentStyle = {} } = this.props;
40
+
41
+ return (
42
+ <div className={className}>
43
+ <MuiTabs indicatorColor="primary" value={value} onChange={this.handleChange}>
44
+ {React.Children.map(children, (c, index) =>
45
+ c && c.props.title ? <StyledMuiTab key={index} label={c.props.title} /> : null,
46
+ )}
47
+ </MuiTabs>
48
+
49
+ <div className={contentClassName} style={contentStyle}>
50
+ {children[value]}
51
+ </div>
52
+ </div>
53
+ );
54
+ }
55
+ }
56
+
57
+ export default Tabs;