@scenid/react-formulator 0.0.2 → 0.1.1
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 +1 -25
- package/dist/index.esm.js +1 -25
- package/package.json +3 -2
- package/rollup.config.js +7 -3
- package/src/Editable/{FormTextfield.jsx → FormText.jsx} +0 -0
- package/src/FormulatorFormSection.jsx +9 -9
- package/src/ReadOnly/{FormBoolean.jsx → FormReadOnlyBoolean.jsx} +3 -3
- package/src/ReadOnly/{FormField.jsx → FormReadOnlyField.jsx} +3 -3
- package/src/ReadOnly/{FormMarkdown.jsx → FormReadOnlyMarkdown.jsx} +3 -3
- package/src/ReadOnly/{FormNumber.jsx → FormReadOnlyNumber.jsx} +3 -3
- package/src/ReadOnly/{FormRepeater.jsx → FormReadOnlyRepeater.jsx} +3 -3
- package/src/ReadOnly/{FormSelect.jsx → FormReadOnlySelect.jsx} +3 -3
- package/src/index.js +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scenid/react-formulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/core": "^7.17.9",
|
|
30
|
+
"@babel/plugin-proposal-export-default-from": "^7.16.7",
|
|
30
31
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
31
32
|
"@material-ui/core": "^4.12.4",
|
|
32
33
|
"@material-ui/icons": "^4.11.3",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"remark-gfm": "^3.0.1",
|
|
69
70
|
"rollup": "^2.70.2",
|
|
70
71
|
"rollup-plugin-import-css": "^3.0.3",
|
|
71
|
-
"rollup-plugin-
|
|
72
|
+
"rollup-plugin-node-externals": "^4.0.0",
|
|
72
73
|
"rollup-plugin-terser": "^7.0.2"
|
|
73
74
|
}
|
|
74
75
|
}
|
package/rollup.config.js
CHANGED
|
@@ -3,7 +3,7 @@ import babel from '@rollup/plugin-babel'
|
|
|
3
3
|
import resolve from '@rollup/plugin-node-resolve'
|
|
4
4
|
import { terser } from 'rollup-plugin-terser'
|
|
5
5
|
import commonjs from '@rollup/plugin-commonjs'
|
|
6
|
-
import
|
|
6
|
+
import externals from 'rollup-plugin-node-externals'
|
|
7
7
|
import css from "rollup-plugin-import-css"
|
|
8
8
|
|
|
9
9
|
import pkg from './package.json'
|
|
@@ -15,12 +15,16 @@ export default {
|
|
|
15
15
|
{ file: pkg.module, format: 'esm' }
|
|
16
16
|
],
|
|
17
17
|
plugins: [
|
|
18
|
-
|
|
18
|
+
externals(),
|
|
19
19
|
babel({
|
|
20
20
|
babelHelpers: 'runtime',
|
|
21
21
|
exclude: 'node_modules/**',
|
|
22
|
-
presets: [
|
|
22
|
+
presets: [
|
|
23
|
+
'@babel/preset-env',
|
|
24
|
+
'@babel/preset-react'
|
|
25
|
+
],
|
|
23
26
|
plugins: [
|
|
27
|
+
'@babel/plugin-proposal-export-default-from',
|
|
24
28
|
[
|
|
25
29
|
'@babel/transform-runtime',
|
|
26
30
|
{ regenerator: true }
|
|
File without changes
|
|
@@ -9,19 +9,19 @@ import FormSectionCard from './FormSectionCard'
|
|
|
9
9
|
import FormSectionBlock from './FormSectionBlock'
|
|
10
10
|
|
|
11
11
|
import FormField from './Editable/FormField'
|
|
12
|
-
import
|
|
12
|
+
import FormText from './Editable/FormText'
|
|
13
13
|
import FormNumber from './Editable/FormNumber'
|
|
14
14
|
import FormSelect from './Editable/FormSelect'
|
|
15
15
|
import FormBoolean from './Editable/FormBoolean'
|
|
16
16
|
import FormRepeater from './Editable/FormRepeater'
|
|
17
17
|
|
|
18
|
-
import FormReadOnlyField from './ReadOnly/
|
|
18
|
+
import FormReadOnlyField from './ReadOnly/FormReadOnlyField'
|
|
19
19
|
import FormReadOnlyText from './ReadOnly/FormReadOnlyText'
|
|
20
|
-
import FormMarkdown from './ReadOnly/
|
|
21
|
-
import FormReadOnlyNumber from './ReadOnly/
|
|
22
|
-
import FormReadOnlySelect from './ReadOnly/
|
|
23
|
-
import FormReadOnlyBoolean from './ReadOnly/
|
|
24
|
-
import FormReadOnlyRepeater from './ReadOnly/
|
|
20
|
+
import FormMarkdown from './ReadOnly/FormReadOnlyMarkdown'
|
|
21
|
+
import FormReadOnlyNumber from './ReadOnly/FormReadOnlyNumber'
|
|
22
|
+
import FormReadOnlySelect from './ReadOnly/FormReadOnlySelect'
|
|
23
|
+
import FormReadOnlyBoolean from './ReadOnly/FormReadOnlyBoolean'
|
|
24
|
+
import FormReadOnlyRepeater from './ReadOnly/FormReadOnlyRepeater'
|
|
25
25
|
|
|
26
26
|
import HiddenData from './HiddenData'
|
|
27
27
|
|
|
@@ -36,8 +36,8 @@ const formReadOnlyComponentMap = {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const formComponentMap = {
|
|
39
|
-
default:
|
|
40
|
-
string:
|
|
39
|
+
default: FormText,
|
|
40
|
+
string: FormText,
|
|
41
41
|
number: FormNumber,
|
|
42
42
|
select: FormSelect,
|
|
43
43
|
boolean: FormBoolean,
|
|
@@ -6,7 +6,7 @@ import { Checkbox, Switch } from '@material-ui/core'
|
|
|
6
6
|
const isBoolean = val => val === false || val === true
|
|
7
7
|
const isChecked = (value, defaultValue) => isBoolean(value) ? value : (defaultValue || false)
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const FormReadOnlyBoolean = ({ variant, name, value, defaultValue }) => {
|
|
10
10
|
if (variant === 'checkbox') {
|
|
11
11
|
return (
|
|
12
12
|
<Checkbox
|
|
@@ -26,11 +26,11 @@ const FormBoolean = ({ variant, name, value, defaultValue }) => {
|
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
FormReadOnlyBoolean.propTypes = {
|
|
30
30
|
variant: PropTypes.string,
|
|
31
31
|
name: PropTypes.string.isRequired,
|
|
32
32
|
value: PropTypes.bool,
|
|
33
33
|
defaultValue: PropTypes.bool
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export default
|
|
36
|
+
export default FormReadOnlyBoolean
|
|
@@ -77,7 +77,7 @@ FormControlField.defaultProps = {
|
|
|
77
77
|
componentProps: {}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const
|
|
80
|
+
const FormReadOnlyField = ({
|
|
81
81
|
prepend,
|
|
82
82
|
append,
|
|
83
83
|
componentProps,
|
|
@@ -98,7 +98,7 @@ const FormField = ({
|
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
FormReadOnlyField.propTypes = {
|
|
102
102
|
component: PropTypes.any.isRequired,
|
|
103
103
|
componentProps: PropTypes.object,
|
|
104
104
|
type: PropTypes.string.isRequired,
|
|
@@ -123,4 +123,4 @@ FormField.propTypes = {
|
|
|
123
123
|
dirty: PropTypes.bool
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export default React.memo(
|
|
126
|
+
export default React.memo(FormReadOnlyField)
|
|
@@ -5,7 +5,7 @@ import ReactMarkdown from 'react-markdown'
|
|
|
5
5
|
import remarkGfm from 'remark-gfm'
|
|
6
6
|
import rehypeHighlight from 'rehype-highlight'
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const FormReadOnlyMarkdown = ({ content }) => (
|
|
9
9
|
<ReactMarkdown
|
|
10
10
|
children={content}
|
|
11
11
|
remarkPlugins={[remarkGfm]}
|
|
@@ -13,8 +13,8 @@ const FormMarkdown = ({ content }) => (
|
|
|
13
13
|
/>
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
FormReadOnlyMarkdown.propTypes = {
|
|
17
17
|
content: PropTypes.string
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default
|
|
20
|
+
export default FormReadOnlyMarkdown
|
|
@@ -5,13 +5,13 @@ import FormReadOnlyText from './FormReadOnlyText'
|
|
|
5
5
|
|
|
6
6
|
import { castToNumber } from '../helpers'
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const FormReadOnlyNumber = ({ value }) => <FormReadOnlyText value={castToNumber(value)} />
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
FormReadOnlyNumber.propTypes = {
|
|
11
11
|
value: PropTypes.oneOfType([
|
|
12
12
|
PropTypes.number,
|
|
13
13
|
PropTypes.string
|
|
14
14
|
])
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export default
|
|
17
|
+
export default FormReadOnlyNumber
|
|
@@ -13,7 +13,7 @@ const getValue = (value, catalog) => {
|
|
|
13
13
|
return value
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const FormReadOnlyRepeater = ({ value, catalog }) => (
|
|
17
17
|
<Box>
|
|
18
18
|
<List dense>
|
|
19
19
|
{
|
|
@@ -28,9 +28,9 @@ const FormRepeater = ({ value, catalog }) => (
|
|
|
28
28
|
</Box>
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
FormReadOnlyRepeater.propTypes = {
|
|
32
32
|
value: PropTypes.array,
|
|
33
33
|
catalog: PropTypes.object
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export default
|
|
36
|
+
export default FormReadOnlyRepeater
|
|
@@ -3,11 +3,11 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
|
|
4
4
|
import FormReadOnlyText from './FormReadOnlyText'
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const FormReadOnlySelect = ({ value, options }) => (
|
|
7
7
|
<FormReadOnlyText value={options.find(o => o.value === value)?.label} />
|
|
8
8
|
)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
FormReadOnlySelect.propTypes = {
|
|
11
11
|
value: PropTypes.string,
|
|
12
12
|
options: PropTypes.arrayOf(PropTypes.shape({
|
|
13
13
|
label: PropTypes.string.isRequired,
|
|
@@ -15,4 +15,4 @@ FormSelect.propTypes = {
|
|
|
15
15
|
})).isRequired
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export default
|
|
18
|
+
export default FormReadOnlySelect
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
export FormulatorForm from './FormulatorForm'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export FormField from './Editable/FormField'
|
|
4
|
+
export FormBoolean from './Editable/FormBoolean'
|
|
5
|
+
export FormNumber from './Editable/FormNumber'
|
|
6
|
+
export FormRepeater from './Editable/FormRepeater'
|
|
7
|
+
export FormSelect from './Editable/FormSelect'
|
|
8
|
+
export FormText from './Editable/FormText'
|
|
9
|
+
|
|
10
|
+
export FormReadOnlyField from './ReadOnly/FormReadOnlyField'
|
|
11
|
+
export FormReadOnlyBoolean from './ReadOnly/FormReadOnlyBoolean'
|
|
12
|
+
export FormReadOnlyNumber from './ReadOnly/FormReadOnlyNumber'
|
|
13
|
+
export FormReadOnlyRepeater from './ReadOnly/FormReadOnlyRepeater'
|
|
14
|
+
export FormReadOnlySelect from './ReadOnly/FormReadOnlySelect'
|
|
15
|
+
export FormReadOnlyText from './ReadOnly/FormReadOnlyText'
|