@pareto-engineering/design-system 4.2.1 → 4.2.3
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/cjs/f/FormInput/FormInput.js +6 -0
- package/dist/cjs/f/common/utils/index.js +8 -1
- package/dist/cjs/f/common/utils/validators.js +17 -0
- package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +3 -2
- package/dist/cjs/f/fields/FileUpload/FileUpload.js +228 -0
- package/dist/cjs/f/fields/FileUpload/common/FilePreview/FilePreview.js +90 -0
- package/dist/cjs/f/fields/FileUpload/common/FilePreview/index.js +13 -0
- package/dist/cjs/f/fields/FileUpload/common/FilePreview/styles.scss +92 -0
- package/dist/cjs/f/fields/FileUpload/common/index.js +12 -0
- package/dist/cjs/f/fields/FileUpload/fileUploadOptions.js +31 -0
- package/dist/cjs/f/fields/FileUpload/index.js +20 -0
- package/dist/cjs/f/fields/FileUpload/styles.scss +73 -0
- package/dist/cjs/f/fields/index.js +14 -1
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +34 -7
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
- package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +9 -3
- package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -2
- package/dist/es/f/FormInput/FormInput.js +7 -1
- package/dist/es/f/common/utils/index.js +2 -1
- package/dist/es/f/common/utils/validators.js +10 -0
- package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +3 -2
- package/dist/es/f/fields/FileUpload/FileUpload.js +218 -0
- package/dist/es/f/fields/FileUpload/common/FilePreview/FilePreview.js +80 -0
- package/dist/es/f/fields/FileUpload/common/FilePreview/index.js +2 -0
- package/dist/es/f/fields/FileUpload/common/FilePreview/styles.scss +92 -0
- package/dist/es/f/fields/FileUpload/common/index.js +2 -0
- package/dist/es/f/fields/FileUpload/fileUploadOptions.js +25 -0
- package/dist/es/f/fields/FileUpload/index.js +3 -0
- package/dist/es/f/fields/FileUpload/styles.scss +73 -0
- package/dist/es/f/fields/index.js +2 -1
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +35 -8
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
- package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +9 -3
- package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -1
- package/package.json +3 -3
- package/src/stories/f/FileUpload.stories.jsx +55 -0
- package/src/stories/g/FormBuilder.stories.jsx +19 -97
- package/src/ui/f/FormInput/FormInput.jsx +11 -0
- package/src/ui/f/common/utils/index.js +1 -0
- package/src/ui/f/common/utils/validators.js +10 -0
- package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +2 -0
- package/src/ui/f/fields/FileUpload/FileUpload.jsx +277 -0
- package/src/ui/f/fields/FileUpload/common/FilePreview/FilePreview.jsx +115 -0
- package/src/ui/f/fields/FileUpload/common/FilePreview/index.js +2 -0
- package/src/ui/f/fields/FileUpload/common/FilePreview/styles.scss +92 -0
- package/src/ui/f/fields/FileUpload/common/index.js +2 -0
- package/src/ui/f/fields/FileUpload/fileUploadOptions.js +32 -0
- package/src/ui/f/fields/FileUpload/index.js +3 -0
- package/src/ui/f/fields/FileUpload/styles.scss +73 -0
- package/src/ui/f/fields/index.js +1 -0
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +53 -11
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
- package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +13 -3
- package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +7 -2
- package/tests/__snapshots__/Storyshots.test.js.snap +163 -159
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.2 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-padding: 1rem;
|
|
6
|
+
$default-margin: 1rem;
|
|
7
|
+
|
|
8
|
+
.#{bem.$base}.file-upload {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: var(--gap);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
> p {
|
|
15
|
+
color: var(--y);
|
|
16
|
+
margin: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
> .#{bem.$base}.description {
|
|
20
|
+
height: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
> .#{bem.$base}.form-label {
|
|
24
|
+
align-items: center;
|
|
25
|
+
border: var(--theme-default-border-style) var(--ui-lines);
|
|
26
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
27
|
+
color: var(--heading);
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: calc(var(--gap) / 2);
|
|
31
|
+
padding: $default-padding;
|
|
32
|
+
width: fit-content;
|
|
33
|
+
|
|
34
|
+
&:has(>input:disabled) {
|
|
35
|
+
--icon-color: var(--hard-disabled);
|
|
36
|
+
color: var(--hard-disabled);
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:has(>input:not(:disabled)) {
|
|
41
|
+
&:hover,
|
|
42
|
+
&:active {
|
|
43
|
+
border: var(--theme-hover-input-border);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
> .ai-icon {
|
|
48
|
+
color: var(--icon-color, var(--interactive));
|
|
49
|
+
font-size: calc(var(--s2) * 1rem);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
> input[type="file"] {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
> .attached-files {
|
|
58
|
+
display: flex;
|
|
59
|
+
gap: var(--gap);
|
|
60
|
+
|
|
61
|
+
> p {
|
|
62
|
+
margin: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
> .files {
|
|
66
|
+
align-items: center;
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-wrap: wrap;
|
|
69
|
+
gap: var(--gap);
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -8,4 +8,5 @@ export { QuerySelect } from "./QuerySelect";
|
|
|
8
8
|
export { Checkbox } from "./Checkbox";
|
|
9
9
|
export { QueryChoices } from "./QueryChoices";
|
|
10
10
|
export { LinkInput } from "./LinkInput";
|
|
11
|
-
export { EditorInput } from "./EditorInput";
|
|
11
|
+
export { EditorInput } from "./EditorInput";
|
|
12
|
+
export { FileUpload, fileUploadOptions } from "./FileUpload";
|
|
@@ -4,7 +4,7 @@ import { useState } from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { FieldArray, useFormikContext } from 'formik';
|
|
6
6
|
import styleNames from '@pareto-engineering/bem/exports';
|
|
7
|
-
import { SelectInput, TextInput } from "../../../../../../f";
|
|
7
|
+
import { ChoicesInput, SelectInput, TextInput, integerAndGreaterThanZero, fileUploadOptions } from "../../../../../../f";
|
|
8
8
|
import { ToggleSwitch } from "../../../../../../a";
|
|
9
9
|
import "./styles.scss";
|
|
10
10
|
|
|
@@ -13,6 +13,9 @@ import "./styles.scss";
|
|
|
13
13
|
import { ActionsContainer } from "../ActionsContainer";
|
|
14
14
|
const baseClassName = styleNames.base;
|
|
15
15
|
const componentClassName = 'input-builder';
|
|
16
|
+
const getToggleSwitchStyles = condition => condition ? {
|
|
17
|
+
'--slider-background-color': 'var(--disabled)'
|
|
18
|
+
} : {};
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* This is the component description.
|
|
@@ -35,11 +38,6 @@ const InputBuilder = ({
|
|
|
35
38
|
const handleToggleRequired = () => {
|
|
36
39
|
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.required`, !input?.required);
|
|
37
40
|
};
|
|
38
|
-
const toggleSwitchStyles = {
|
|
39
|
-
...(!input?.required ? {
|
|
40
|
-
'--slider-background-color': 'var(--disabled)'
|
|
41
|
-
} : {})
|
|
42
|
-
};
|
|
43
41
|
const [hasDescription, setHasDescription] = useState(false);
|
|
44
42
|
|
|
45
43
|
// TODO: handle nav logic
|
|
@@ -59,6 +57,10 @@ const InputBuilder = ({
|
|
|
59
57
|
} = e.target;
|
|
60
58
|
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.options.${optionIndex}.label`, value);
|
|
61
59
|
};
|
|
60
|
+
const isFile = input?.type === 'file';
|
|
61
|
+
const handleToggleShowSpecificFileTypes = () => {
|
|
62
|
+
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.showSpecificFileTypes`, !input.showSpecificFileTypes);
|
|
63
|
+
};
|
|
62
64
|
return /*#__PURE__*/React.createElement("div", {
|
|
63
65
|
id: id,
|
|
64
66
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
@@ -92,6 +94,9 @@ const InputBuilder = ({
|
|
|
92
94
|
}, {
|
|
93
95
|
value: 'choices',
|
|
94
96
|
label: 'Radio buttons'
|
|
97
|
+
}, {
|
|
98
|
+
value: 'file',
|
|
99
|
+
label: 'File upload'
|
|
95
100
|
}]
|
|
96
101
|
}), /*#__PURE__*/React.createElement("div", {
|
|
97
102
|
className: "controls"
|
|
@@ -107,7 +112,7 @@ const InputBuilder = ({
|
|
|
107
112
|
}, "Required"), /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
108
113
|
handleOnChange: handleToggleRequired,
|
|
109
114
|
checked: input?.required,
|
|
110
|
-
style:
|
|
115
|
+
style: getToggleSwitchStyles(!input?.required),
|
|
111
116
|
inputId: `sections_${sectionIndex}_inputs.${inputIndex}_toggle`
|
|
112
117
|
})), /*#__PURE__*/React.createElement(ActionsContainer, null, /*#__PURE__*/React.createElement("p", null, "Show"), /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
113
118
|
className: `option ${hasDescription ? 'with-check-mark' : ''}`
|
|
@@ -168,7 +173,29 @@ const InputBuilder = ({
|
|
|
168
173
|
className: "icon"
|
|
169
174
|
}, "+")), /*#__PURE__*/React.createElement("span", {
|
|
170
175
|
className: "text x-paragraph c-x"
|
|
171
|
-
}, "Add Option"))))
|
|
176
|
+
}, "Add Option")))), isFile && /*#__PURE__*/React.createElement("div", {
|
|
177
|
+
className: "input-file-options"
|
|
178
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
179
|
+
label: "Maximum number of files",
|
|
180
|
+
name: `sections.${sectionIndex}.inputs.${inputIndex}.maxCount`,
|
|
181
|
+
placeholder: "1",
|
|
182
|
+
type: "number",
|
|
183
|
+
min: "0",
|
|
184
|
+
validate: integerAndGreaterThanZero
|
|
185
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: "specific-file-types"
|
|
187
|
+
}, /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
188
|
+
handleOnChange: handleToggleShowSpecificFileTypes,
|
|
189
|
+
checked: input?.showSpecificFileTypes,
|
|
190
|
+
style: getToggleSwitchStyles(!input?.showSpecificFileTypes),
|
|
191
|
+
inputId: `sections_${sectionIndex}_inputs.${inputIndex}_show_specific_file_types`
|
|
192
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
193
|
+
className: "s0"
|
|
194
|
+
}, "Allow only specific file types")), input?.showSpecificFileTypes && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ChoicesInput, {
|
|
195
|
+
name: `sections.${sectionIndex}.inputs.${inputIndex}.accept`,
|
|
196
|
+
options: fileUploadOptions,
|
|
197
|
+
multiple: true
|
|
198
|
+
})))));
|
|
172
199
|
};
|
|
173
200
|
InputBuilder.propTypes = {
|
|
174
201
|
/**
|
|
@@ -137,6 +137,17 @@ $default-list-width: var(--action-button-width, 18rem);
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
+
|
|
141
|
+
> .input-file-options {
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: var(--gap);
|
|
145
|
+
margin-bottom: $default-margin;
|
|
146
|
+
|
|
147
|
+
> .specific-file-types {
|
|
148
|
+
display: flex;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
|
|
@@ -17,9 +17,14 @@ const reconstructFormDataWithValues = (formData, values) => {
|
|
|
17
17
|
const newData = {
|
|
18
18
|
...formData
|
|
19
19
|
};
|
|
20
|
-
Object.keys(values).forEach(key => {
|
|
20
|
+
Object.keys(values).forEach(async key => {
|
|
21
21
|
const [sectionIdx, inputIdx] = key.match(/\d+/g).map(Number);
|
|
22
|
-
|
|
22
|
+
if (key.includes('files')) {
|
|
23
|
+
const files = values[key].map(file => URL.createObjectURL(file));
|
|
24
|
+
newData.sections[sectionIdx].inputs[inputIdx].files = files;
|
|
25
|
+
} else {
|
|
26
|
+
newData.sections[sectionIdx].inputs[inputIdx].value = values[key];
|
|
27
|
+
}
|
|
23
28
|
});
|
|
24
29
|
return newData;
|
|
25
30
|
};
|
|
@@ -118,7 +123,8 @@ const Renderer = ({
|
|
|
118
123
|
return /*#__PURE__*/React.createElement(Form, null, updatedFormData.sections.map((section, sectionIndex) => sectionIndex === currentSectionIndex && /*#__PURE__*/React.createElement(Section, _extends({
|
|
119
124
|
key: `${section.title}`
|
|
120
125
|
}, section, {
|
|
121
|
-
readOnly: readOnly
|
|
126
|
+
readOnly: readOnly,
|
|
127
|
+
setUpdatedFormData: setUpdatedFormData
|
|
122
128
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
123
129
|
className: "navigator-container"
|
|
124
130
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/* eslint-disable no-alert */
|
|
2
3
|
/* @pareto-engineering/generator-front 1.1.1-alpha.2 */
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
@@ -32,7 +33,7 @@ const Section = ({
|
|
|
32
33
|
}, title), /*#__PURE__*/React.createElement(ExpandableLexicalPreview, {
|
|
33
34
|
nodes: description,
|
|
34
35
|
name: "instructions"
|
|
35
|
-
}), inputs
|
|
36
|
+
}), inputs?.map(input => /*#__PURE__*/React.createElement(FormInput, _extends({
|
|
36
37
|
key: input.name
|
|
37
38
|
}, input, {
|
|
38
39
|
disabled: readOnly
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pareto-engineering/design-system",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@lexical/selection": "0.12.2",
|
|
60
60
|
"@lexical/table": "0.12.2",
|
|
61
61
|
"@lexical/utils": "0.12.2",
|
|
62
|
-
"@pareto-engineering/assets": "^4.2.
|
|
62
|
+
"@pareto-engineering/assets": "^4.2.3",
|
|
63
63
|
"@pareto-engineering/bem": "^4.2.1",
|
|
64
64
|
"@pareto-engineering/styles": "^4.2.0",
|
|
65
65
|
"@pareto-engineering/utils": "^4.0.0",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"relay-test-utils": "^15.0.0"
|
|
83
83
|
},
|
|
84
84
|
"browserslist": "> 2%",
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "77c5790a1e998600f0f61931a8fcbd2177f53efc"
|
|
86
86
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.2 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { Formik, Form } from 'formik'
|
|
5
|
+
|
|
6
|
+
import { FileUpload } from 'ui'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title :'f/fields/FileUpload',
|
|
10
|
+
component :FileUpload,
|
|
11
|
+
subcomponents:{
|
|
12
|
+
// Item:FileUpload.Item
|
|
13
|
+
},
|
|
14
|
+
decorators:[
|
|
15
|
+
(storyfn) => (
|
|
16
|
+
<Formik
|
|
17
|
+
initialValues={{ files: [] }}
|
|
18
|
+
>
|
|
19
|
+
<Form>
|
|
20
|
+
{ storyfn() }
|
|
21
|
+
</Form>
|
|
22
|
+
</Formik>
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
argTypes:{
|
|
26
|
+
backgroundColor:{ control: 'color' },
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Base = {
|
|
31
|
+
args:{
|
|
32
|
+
name :'section_0_input_0',
|
|
33
|
+
label :'The file upload ',
|
|
34
|
+
type :'file',
|
|
35
|
+
description:'',
|
|
36
|
+
accept :[
|
|
37
|
+
'.mp4,.ogg,.webm,video/mp4,video/ogg,video/webm',
|
|
38
|
+
'.pdf,application/pdf',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Multiple = {
|
|
44
|
+
args:{
|
|
45
|
+
...Base.args,
|
|
46
|
+
multiple:true,
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const WithLimitedCount = {
|
|
51
|
+
args:{
|
|
52
|
+
...Base.args,
|
|
53
|
+
maxCount:2,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
@@ -41,109 +41,28 @@ export const Builder = {
|
|
|
41
41
|
)
|
|
42
42
|
},
|
|
43
43
|
}
|
|
44
|
+
|
|
44
45
|
const sampleFormData = {
|
|
45
46
|
sections:[
|
|
46
47
|
{
|
|
47
|
-
title :'
|
|
48
|
-
description:'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"
|
|
48
|
+
title :'Hello',
|
|
49
|
+
description:'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Test file upload ","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}',
|
|
49
50
|
key :'section-0',
|
|
50
51
|
inputs :[
|
|
51
52
|
{
|
|
52
|
-
name
|
|
53
|
-
label
|
|
54
|
-
type
|
|
55
|
-
required
|
|
56
|
-
options
|
|
57
|
-
conditionalLogic:null,
|
|
58
|
-
description
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
required :false,
|
|
65
|
-
options :[],
|
|
66
|
-
conditionalLogic:null,
|
|
67
|
-
description :'brief model description',
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
orderedInputDragIds:[],
|
|
71
|
-
navigation :{
|
|
72
|
-
nextSection:'next',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
title :'Rate the Models',
|
|
77
|
-
description:'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Best LLM models for software developers","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Chat GPT","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Perplexity","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":2},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Gemini","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":3},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Claude","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":4}],"direction":"ltr","format":"","indent":0,"type":"list","version":1,"listType":"bullet","start":1,"tag":"ul"},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Please add more exciting models that we might missed","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"quote","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"You can make them ","type":"text","version":1},{"detail":0,"format":1,"mode":"normal","style":"","text":"bold","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":" or ","type":"text","version":1},{"detail":0,"format":2,"mode":"normal","style":"","text":"Italic or ","type":"text","version":1},{"detail":0,"format":10,"mode":"normal","style":"","text":"underlined","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":4,"mode":"normal","style":"","text":"You can also color them and strike through them!","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}',
|
|
78
|
-
key :'section-1',
|
|
79
|
-
inputs :[
|
|
80
|
-
{
|
|
81
|
-
type :'choices',
|
|
82
|
-
options:[
|
|
83
|
-
{
|
|
84
|
-
key :'sections-1-inputs-0-options--1',
|
|
85
|
-
value :'Chat GPT',
|
|
86
|
-
label :'Chat GPT',
|
|
87
|
-
nextSection:'',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
key :'sections-1-inputs-0-options-0',
|
|
91
|
-
value :'Gemini',
|
|
92
|
-
label :'Gemini',
|
|
93
|
-
nextSection:'',
|
|
94
|
-
},
|
|
53
|
+
name :'section_0_input_0',
|
|
54
|
+
label :'The file upload ',
|
|
55
|
+
type :'file',
|
|
56
|
+
required :false,
|
|
57
|
+
options :[],
|
|
58
|
+
conditionalLogic :null,
|
|
59
|
+
description :'',
|
|
60
|
+
maxCount :3,
|
|
61
|
+
showSpecificFileTypes:true,
|
|
62
|
+
accept :[
|
|
63
|
+
'.mp4,.ogg,.webm,video/mp4,video/ogg,video/webm',
|
|
64
|
+
'.pdf,application/pdf',
|
|
95
65
|
],
|
|
96
|
-
required :true,
|
|
97
|
-
description:'',
|
|
98
|
-
name :'section_1_input_0',
|
|
99
|
-
label :'Which is better between the 2?',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name :'section_1_input_1',
|
|
103
|
-
label :'Choose the worst of them ',
|
|
104
|
-
type :'multiple',
|
|
105
|
-
required:false,
|
|
106
|
-
options :[
|
|
107
|
-
{
|
|
108
|
-
key :'sections-1-inputs-1-options--1',
|
|
109
|
-
value :'Chat GPT',
|
|
110
|
-
label :'Chat GPT',
|
|
111
|
-
nextSection:'',
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
key :'sections-1-inputs-1-options-0',
|
|
115
|
-
value :'Gemini',
|
|
116
|
-
label :'Gemini',
|
|
117
|
-
nextSection:'',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
key :'sections-1-inputs-1-options-1',
|
|
121
|
-
value :'Claude',
|
|
122
|
-
label :'Claude',
|
|
123
|
-
nextSection:'',
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
conditionalLogic:null,
|
|
127
|
-
description :'',
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
orderedInputDragIds:[],
|
|
131
|
-
navigation :{
|
|
132
|
-
nextSection:'next',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
title :'General sentiments',
|
|
137
|
-
description:'{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Best LLM models for software developers","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"heading","version":1,"tag":"h3"},{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Chat GPT","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Perplexity","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":2},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Gemini","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":3},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Claude","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"listitem","version":1,"value":4}],"direction":"ltr","format":"","indent":0,"type":"list","version":1,"listType":"bullet","start":1,"tag":"ul"},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"Please add more exciting models that we might missed","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"quote","version":1},{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":"You can make them ","type":"text","version":1},{"detail":0,"format":1,"mode":"normal","style":"","text":"bold","type":"text","version":1},{"detail":0,"format":0,"mode":"normal","style":"","text":" or ","type":"text","version":1},{"detail":0,"format":2,"mode":"normal","style":"","text":"Italic or ","type":"text","version":1},{"detail":0,"format":10,"mode":"normal","style":"","text":"underlined","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1},{"children":[{"detail":0,"format":4,"mode":"normal","style":"","text":"You can also color them and strike through them!","type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}',
|
|
138
|
-
key :'section-2',
|
|
139
|
-
inputs :[
|
|
140
|
-
{
|
|
141
|
-
type :'textarea',
|
|
142
|
-
options :[],
|
|
143
|
-
required :true,
|
|
144
|
-
description:'',
|
|
145
|
-
name :'section_2_input_0',
|
|
146
|
-
label :'Give a final brief description of your findings',
|
|
147
66
|
},
|
|
148
67
|
],
|
|
149
68
|
orderedInputDragIds:[],
|
|
@@ -168,7 +87,10 @@ export const Renderer = {
|
|
|
168
87
|
|
|
169
88
|
return (
|
|
170
89
|
<>
|
|
171
|
-
<FormBuilder
|
|
90
|
+
<FormBuilder
|
|
91
|
+
{...args}
|
|
92
|
+
onRendererFormSave={handleFormDataUpdateWithValues}
|
|
93
|
+
/>
|
|
172
94
|
<pre>{JSON.stringify(values, null, 2)}</pre>
|
|
173
95
|
</>
|
|
174
96
|
)
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
QueryChoices,
|
|
18
18
|
LinkInput,
|
|
19
19
|
EditorInput,
|
|
20
|
+
FileUpload,
|
|
20
21
|
} from '../fields'
|
|
21
22
|
|
|
22
23
|
import './styles.scss'
|
|
@@ -147,6 +148,16 @@ const FormInput = ({
|
|
|
147
148
|
)
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
if (type === 'file') {
|
|
152
|
+
return (
|
|
153
|
+
<FileUpload
|
|
154
|
+
className={newClassName}
|
|
155
|
+
disabled={disabled}
|
|
156
|
+
{...otherProps}
|
|
157
|
+
/>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
150
161
|
if (extraTypes?.[type]) {
|
|
151
162
|
const Component = extraTypes[type]
|
|
152
163
|
return (
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const integerAndGreaterThanZero = (value) => {
|
|
2
|
+
let error = ''
|
|
3
|
+
if ((value && value <= 0) || value === 0) {
|
|
4
|
+
error = 'Value must be greator than zero.'
|
|
5
|
+
}
|
|
6
|
+
if (value && value % 1 !== 0) {
|
|
7
|
+
error = 'You must enter a whole number.'
|
|
8
|
+
}
|
|
9
|
+
return error
|
|
10
|
+
}
|
|
@@ -27,6 +27,7 @@ const Choice = ({
|
|
|
27
27
|
multiple,
|
|
28
28
|
validate,
|
|
29
29
|
disabled,
|
|
30
|
+
...otherProps
|
|
30
31
|
}) => {
|
|
31
32
|
const type = multiple ? 'checkbox' : 'radio'
|
|
32
33
|
|
|
@@ -53,6 +54,7 @@ const Choice = ({
|
|
|
53
54
|
id={id}
|
|
54
55
|
name={name}
|
|
55
56
|
{...field}
|
|
57
|
+
{...otherProps}
|
|
56
58
|
value={value}
|
|
57
59
|
disabled={disabled}
|
|
58
60
|
/>
|