@scenid/react-formulator 0.5.1 → 0.5.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/index.cjs.js +7276 -264
- package/dist/index.esm.js +7273 -261
- package/package.json +1 -2
- package/src/Editable/FormAutocomplete/FormAutocomplete.jsx +1 -10
- package/src/Editable/FormAutocomplete/useFetchOptions.js +1 -1
- package/src/FormulatorFormSection.jsx +1 -2
- package/src/ReadOnly/FormReadOnlyRepeater.jsx +24 -8
- package/src/ReadOnly/FormReadOnlyText.jsx +7 -3
- package/stories/Forms.stories.jsx +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scenid/react-formulator",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.esm.js",
|
|
6
6
|
"repository": "https://dennykoch@bitbucket.org/scenid/react-formulator.git",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@material-ui/icons": "^4.11.3",
|
|
24
24
|
"@material-ui/styles": "^4.11.5",
|
|
25
25
|
"classnames": "^2.3.1",
|
|
26
|
-
"luxon": "^2.3.2",
|
|
27
26
|
"prop-types": "^15.8.1",
|
|
28
27
|
"react": "16.11.0",
|
|
29
28
|
"react-dom": "16.11.0"
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
CircularProgress
|
|
12
12
|
} from '@material-ui/core'
|
|
13
13
|
|
|
14
|
-
import FormField from '../FormField'
|
|
15
14
|
import FormReadOnlyText from '../../ReadOnly/FormReadOnlyText'
|
|
16
15
|
import SelectOrCreate from '../../Components/SelectOrCreate'
|
|
17
16
|
|
|
@@ -44,15 +43,7 @@ const FormAutocomplete = ({
|
|
|
44
43
|
}, [])
|
|
45
44
|
|
|
46
45
|
if (readOnly) {
|
|
47
|
-
return
|
|
48
|
-
<FormField
|
|
49
|
-
component={FormReadOnlyText}
|
|
50
|
-
type="text"
|
|
51
|
-
componentProps={{}}
|
|
52
|
-
name={name}
|
|
53
|
-
value={value}
|
|
54
|
-
/>
|
|
55
|
-
)
|
|
46
|
+
return <FormReadOnlyText name={name} value={value} />
|
|
56
47
|
}
|
|
57
48
|
|
|
58
49
|
if (!options) {
|
|
@@ -110,7 +110,6 @@ class FormulatorFormSection extends React.Component {
|
|
|
110
110
|
const mapEntry = isRender ? renderComponentMap[field] : componentMap[mapKey]
|
|
111
111
|
let component = mapEntry, props = {}
|
|
112
112
|
|
|
113
|
-
console.log(schema.properties, fieldEntry)
|
|
114
113
|
if (mapKey === 'array' && schema.properties[fieldEntry].options) {
|
|
115
114
|
props.options = (
|
|
116
115
|
schema.properties[fieldEntry].options
|
|
@@ -124,7 +123,7 @@ class FormulatorFormSection extends React.Component {
|
|
|
124
123
|
if (mapKey === 'select') {
|
|
125
124
|
props.options = (
|
|
126
125
|
type.map(value => ({
|
|
127
|
-
label: translations?.field?.value || value,
|
|
126
|
+
label: translations?.[field]?.[value] || value,
|
|
128
127
|
value
|
|
129
128
|
}))
|
|
130
129
|
)
|
|
@@ -2,35 +2,51 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
Box,
|
|
6
5
|
List,
|
|
7
6
|
ListItem,
|
|
8
7
|
ListItemText
|
|
9
8
|
} from '@material-ui/core'
|
|
10
9
|
|
|
10
|
+
import { makeStyles } from '@material-ui/core/styles'
|
|
11
|
+
|
|
12
|
+
const useStyles = makeStyles(() => ({
|
|
13
|
+
formRepeater: {
|
|
14
|
+
padding: 0,
|
|
15
|
+
margin: 0
|
|
16
|
+
}
|
|
17
|
+
}))
|
|
18
|
+
|
|
11
19
|
const getValue = (value, catalog) => {
|
|
12
20
|
if (catalog && catalog[value] !== undefined) return catalog[value]
|
|
13
21
|
return value
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
const FormReadOnlyRepeater = ({ value,
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
const FormReadOnlyRepeater = ({ value, options }) => {
|
|
25
|
+
const styles = useStyles()
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<List
|
|
29
|
+
className={styles.formRepeater}
|
|
30
|
+
dense
|
|
31
|
+
>
|
|
19
32
|
{
|
|
20
33
|
value && value.map((entry, index) => (
|
|
21
34
|
// eslint-disable-next-line react/no-array-index-key
|
|
22
35
|
<ListItem key={`entry-${index}`}>
|
|
23
|
-
<ListItemText
|
|
36
|
+
<ListItemText
|
|
37
|
+
primary={getValue(entry, options)}
|
|
38
|
+
style={{ margin: 0 }}
|
|
39
|
+
/>
|
|
24
40
|
</ListItem>
|
|
25
41
|
))
|
|
26
42
|
}
|
|
27
43
|
</List>
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
)
|
|
45
|
+
}
|
|
30
46
|
|
|
31
47
|
FormReadOnlyRepeater.propTypes = {
|
|
32
48
|
value: PropTypes.array,
|
|
33
|
-
|
|
49
|
+
options: PropTypes.object
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
export default FormReadOnlyRepeater
|
|
@@ -5,7 +5,7 @@ import { Typography } from '@material-ui/core'
|
|
|
5
5
|
|
|
6
6
|
import { DateTime } from 'luxon'
|
|
7
7
|
|
|
8
|
-
const FormReadOnlyText = ({ value, type, renderFormat }) => {
|
|
8
|
+
const FormReadOnlyText = ({ value, type, renderFormat, multiline }) => {
|
|
9
9
|
let finalValue = value
|
|
10
10
|
|
|
11
11
|
if (type === 'date' || type === 'datetime-local') {
|
|
@@ -20,7 +20,10 @@ const FormReadOnlyText = ({ value, type, renderFormat }) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<Typography
|
|
23
|
+
<Typography
|
|
24
|
+
variant="body1"
|
|
25
|
+
style={{ whiteSpace: multiline ? 'pre-line' : 'inherit' }}
|
|
26
|
+
>
|
|
24
27
|
{finalValue}
|
|
25
28
|
</Typography>
|
|
26
29
|
)
|
|
@@ -35,7 +38,8 @@ FormReadOnlyText.propTypes = {
|
|
|
35
38
|
renderFormat: PropTypes.oneOfType([
|
|
36
39
|
PropTypes.string,
|
|
37
40
|
PropTypes.object
|
|
38
|
-
])
|
|
41
|
+
]),
|
|
42
|
+
multiline: PropTypes.bool
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
export default FormReadOnlyText
|
|
@@ -137,6 +137,12 @@ Types.args = {
|
|
|
137
137
|
},
|
|
138
138
|
translations: {
|
|
139
139
|
...typesTranslations,
|
|
140
|
+
simpleSelect: {
|
|
141
|
+
Citrus: 'Zitrone',
|
|
142
|
+
Banana: 'Banane',
|
|
143
|
+
Apple: 'Apfel',
|
|
144
|
+
Date: 'Dattel'
|
|
145
|
+
},
|
|
140
146
|
arrayCatalogRepeater: {
|
|
141
147
|
cat: 'Mieze',
|
|
142
148
|
dog: 'Doggo',
|
|
@@ -145,6 +151,16 @@ Types.args = {
|
|
|
145
151
|
}
|
|
146
152
|
},
|
|
147
153
|
data: {
|
|
154
|
+
simpleText: 'My first input text',
|
|
155
|
+
multilineText: 'A lot of lines\nin my input\nare fun!',
|
|
156
|
+
simpleSwitch: true,
|
|
157
|
+
simpleCheckbox: true,
|
|
158
|
+
booleanLabelPlace: false,
|
|
159
|
+
simpleNumber: 5,
|
|
160
|
+
advancedNumber: 1.25,
|
|
161
|
+
simpleSelect: 'Banana',
|
|
162
|
+
arrayRepeater: ['First Entry', 'Second Entry', 'And a third one'],
|
|
163
|
+
arrayCatalogRepeater: ['cat', 'dog', 'fish'],
|
|
148
164
|
hiddenDataInput: 'Data we do not want to show in Video Calls',
|
|
149
165
|
hiddenGroupInput1: 'sensitive data',
|
|
150
166
|
hiddenGroupInput2: 'non-public information',
|