@digigov/form 0.4.6 → 0.4.7
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/CHANGELOG.md +9 -1
- package/Field/index.js +35 -45
- package/Fieldset/index.js +10 -14
- package/es/Field/index.js +29 -41
- package/es/Fieldset/index.js +9 -14
- package/es/inputs/Checkboxes/index.js +12 -50
- package/es/inputs/FileInput/index.js +7 -42
- package/es/inputs/Input/index.js +19 -16
- package/es/inputs/Label/index.js +6 -34
- package/es/inputs/Radio/index.js +24 -87
- package/es/inputs/Select/index.js +10 -31
- package/esm/Field/index.js +29 -41
- package/esm/Fieldset/index.js +9 -14
- package/esm/index.js +1 -1
- package/esm/inputs/Checkboxes/index.js +12 -50
- package/esm/inputs/FileInput/index.js +7 -42
- package/esm/inputs/Input/index.js +19 -16
- package/esm/inputs/Label/index.js +6 -34
- package/esm/inputs/Radio/index.js +24 -87
- package/esm/inputs/Select/index.js +10 -31
- package/inputs/Checkboxes/index.js +12 -52
- package/inputs/FileInput/index.js +7 -45
- package/inputs/Input/index.js +20 -16
- package/inputs/Label/index.js +6 -37
- package/inputs/Radio/index.js +26 -95
- package/inputs/Select/index.js +10 -34
- package/libs/form/src/Field/index.d.ts +3 -1
- package/libs/form/src/index.d.ts +1 -0
- package/libs/form/src/inputs/Input/index.d.ts +1 -1
- package/libs/form/src/inputs/Radio/index.d.ts +1 -11
- package/libs/ui/src/core/Button/BackButton.d.ts +1 -1
- package/libs/ui/src/core/Button/ButtonLink.d.ts +1 -1
- package/libs/ui/src/core/Button/index.d.ts +1 -1
- package/libs/ui/src/core/NavList/NavListItemBase.d.ts +1 -1
- package/libs/ui/src/typography/Caption.d.ts +1 -1
- package/libs-ui/react-core/src/BackLink/index.d.ts +1 -1
- package/libs-ui/react-core/src/Button/index.d.ts +1 -1
- package/libs-ui/react-core/src/ButtonLink/index.d.ts +1 -1
- package/libs-ui/react-core/src/CallToAction/index.d.ts +1 -1
- package/libs-ui/react-core/src/Checkbox/index.d.ts +11 -0
- package/libs-ui/react-core/src/CheckboxItem/index.d.ts +19 -0
- package/libs-ui/react-core/src/ErrorMessage/index.d.ts +11 -0
- package/libs-ui/react-core/src/Field/index.d.ts +13 -0
- package/libs-ui/react-core/src/Fieldset/index.d.ts +10 -0
- package/libs-ui/react-core/src/FieldsetLegend/index.d.ts +19 -0
- package/libs-ui/react-core/src/FileUpload/index.d.ts +14 -0
- package/libs-ui/react-core/src/Heading/index.d.ts +1 -1
- package/libs-ui/react-core/src/HeadingCaption/index.d.ts +1 -1
- package/libs-ui/react-core/src/Hint/index.d.ts +9 -0
- package/libs-ui/react-core/src/Label/index.d.ts +9 -0
- package/libs-ui/react-core/src/LabelTitle/index.d.ts +19 -0
- package/libs-ui/react-core/src/Radio/index.d.ts +10 -0
- package/libs-ui/react-core/src/RadioItem/index.d.ts +18 -0
- package/libs-ui/react-core/src/SectionBreak/index.d.ts +1 -1
- package/libs-ui/react-core/src/Select/index.d.ts +14 -0
- package/libs-ui/react-core/src/SelectOption/index.d.ts +18 -0
- package/libs-ui/react-core/src/TabsHeading/index.d.ts +1 -1
- package/libs-ui/react-core/src/TabsListItem/index.d.ts +1 -1
- package/libs-ui/react-core/src/TextArea/index.d.ts +23 -0
- package/libs-ui/react-core/src/TextInput/index.d.ts +28 -0
- package/package.json +2 -2
package/es/inputs/Label/index.js
CHANGED
|
@@ -1,29 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
-
import NormalText from '@digigov/ui/typography/NormalText';
|
|
2
|
+
import LabelTitle from '@digigov/react-core/LabelTitle';
|
|
3
|
+
import Hint from '@digigov/react-core/Hint';
|
|
6
4
|
import { useTranslation } from '@digigov/ui/app/i18n';
|
|
7
|
-
var useLabelStyles = makeStyles(function (theme) {
|
|
8
|
-
return {
|
|
9
|
-
labels: {
|
|
10
|
-
padding: theme.spacing(1, 0)
|
|
11
|
-
},
|
|
12
|
-
primaryLabel: {
|
|
13
|
-
fontWeight: 500,
|
|
14
|
-
lineHeight: '1.5em'
|
|
15
|
-
},
|
|
16
|
-
secondaryLabel: {
|
|
17
|
-
fontWeight: 'normal',
|
|
18
|
-
color: theme.palette.grey['700']
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
5
|
export var Label = function Label(_ref) {
|
|
23
6
|
var className = _ref.className,
|
|
24
7
|
label = _ref.label,
|
|
25
8
|
value = _ref.value;
|
|
26
|
-
var classes = useLabelStyles();
|
|
27
9
|
|
|
28
10
|
var _useTranslation = useTranslation(),
|
|
29
11
|
t = _useTranslation.t;
|
|
@@ -32,20 +14,10 @@ export var Label = function Label(_ref) {
|
|
|
32
14
|
return null;
|
|
33
15
|
}
|
|
34
16
|
|
|
35
|
-
return /*#__PURE__*/React.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, /*#__PURE__*/React.createElement(
|
|
39
|
-
item: true,
|
|
40
|
-
xs: 12
|
|
41
|
-
}, /*#__PURE__*/React.createElement(NormalText, {
|
|
42
|
-
className: classes.primaryLabel
|
|
43
|
-
}, label && label.primary && t(label.primary) || value)), label && label.secondary && /*#__PURE__*/React.createElement(Grid, {
|
|
44
|
-
item: true,
|
|
45
|
-
xs: 12
|
|
46
|
-
}, /*#__PURE__*/React.createElement(NormalText, {
|
|
47
|
-
className: classes.secondaryLabel
|
|
48
|
-
}, t(label.secondary))));
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabelTitle, {
|
|
18
|
+
className: className,
|
|
19
|
+
size: "s"
|
|
20
|
+
}, label && label.primary && t(label.primary) || value), label && label.secondary && /*#__PURE__*/React.createElement(Hint, null, t(label.secondary)));
|
|
49
21
|
};
|
|
50
22
|
Label.defaultProps = {
|
|
51
23
|
label: {}
|
package/es/inputs/Radio/index.js
CHANGED
|
@@ -1,79 +1,18 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import RadioGroup from '@material-ui/core/RadioGroup';
|
|
7
|
-
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
8
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
9
|
-
import Label from '@digigov/form/inputs/Label';
|
|
3
|
+
import Radio from '@digigov/react-core/Radio';
|
|
4
|
+
import RadioItem from '@digigov/react-core/RadioItem';
|
|
5
|
+
import { useTranslation } from '@digigov/ui/app/i18n';
|
|
10
6
|
import { useWatch } from 'react-hook-form';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
margin: theme.spacing(1, 0)
|
|
15
|
-
},
|
|
16
|
-
formControlLabelActive: {
|
|
17
|
-
backgroundColor: theme.palette.grey['200'],
|
|
18
|
-
border: "2px solid ".concat(theme.palette.primary.main)
|
|
19
|
-
},
|
|
20
|
-
formControlLabel: {
|
|
21
|
-
width: '100%',
|
|
22
|
-
alignItems: 'flex-start',
|
|
23
|
-
fontWeight: 'bolder',
|
|
24
|
-
padding: theme.spacing(0.5),
|
|
25
|
-
margin: theme.spacing(0.5, 0)
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
var _ref2 = /*#__PURE__*/React.createElement(Radio, {
|
|
31
|
-
color: "primary"
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export var RadioButton = function RadioButton(_ref) {
|
|
35
|
-
var dense = _ref.dense,
|
|
36
|
-
value = _ref.value,
|
|
37
|
-
label = _ref.label,
|
|
38
|
-
register = _ref.register,
|
|
39
|
-
active = _ref.active,
|
|
7
|
+
import Hint from '@digigov/react-core/Hint';
|
|
8
|
+
export var RadioButtonsGroup = function RadioButtonsGroup(_ref) {
|
|
9
|
+
var register = _ref.register,
|
|
40
10
|
name = _ref.name,
|
|
11
|
+
control = _ref.control,
|
|
12
|
+
_ref$extra = _ref.extra,
|
|
13
|
+
options = _ref$extra.options,
|
|
14
|
+
className = _ref$extra.className,
|
|
41
15
|
disabled = _ref.disabled;
|
|
42
|
-
var classes = useRadioButtonStyles();
|
|
43
|
-
return /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
44
|
-
className: clsx(classes.formControlLabel, active && classes.formControlLabelActive, dense && classes.dense),
|
|
45
|
-
value: value,
|
|
46
|
-
name: name,
|
|
47
|
-
disabled: disabled,
|
|
48
|
-
inputRef: register,
|
|
49
|
-
control: _ref2,
|
|
50
|
-
label: /*#__PURE__*/React.createElement(Label, {
|
|
51
|
-
label: label,
|
|
52
|
-
value: value
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
var useRadioButtonsGroupStyles = makeStyles(function (theme) {
|
|
57
|
-
return {
|
|
58
|
-
formControl: {
|
|
59
|
-
margin: theme.spacing(0, 0, 2, 0),
|
|
60
|
-
width: '100%'
|
|
61
|
-
},
|
|
62
|
-
dense: {
|
|
63
|
-
margin: theme.spacing(1, 0)
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
export var RadioButtonsGroup = function RadioButtonsGroup(_ref3) {
|
|
68
|
-
var name = _ref3.name,
|
|
69
|
-
register = _ref3.register,
|
|
70
|
-
control = _ref3.control,
|
|
71
|
-
_ref3$extra = _ref3.extra,
|
|
72
|
-
options = _ref3$extra.options,
|
|
73
|
-
dense = _ref3$extra.dense,
|
|
74
|
-
className = _ref3$extra.className,
|
|
75
|
-
disabled = _ref3.disabled;
|
|
76
|
-
var classes = useRadioButtonsGroupStyles();
|
|
77
16
|
var currentValue = useWatch({
|
|
78
17
|
control: control,
|
|
79
18
|
name: name
|
|
@@ -83,26 +22,24 @@ export var RadioButtonsGroup = function RadioButtonsGroup(_ref3) {
|
|
|
83
22
|
_useState2 = _slicedToArray(_useState, 1),
|
|
84
23
|
defaultValue = _useState2[0];
|
|
85
24
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
25
|
+
var _useTranslation = useTranslation(),
|
|
26
|
+
t = _useTranslation.t;
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/React.createElement(Radio, {
|
|
29
|
+
className: className,
|
|
90
30
|
defaultValue: defaultValue,
|
|
91
|
-
id: name
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
31
|
+
id: name
|
|
32
|
+
}, options.map(function (_ref2) {
|
|
33
|
+
var label = _ref2.label,
|
|
34
|
+
v = _ref2.value,
|
|
35
|
+
optionDisabled = _ref2.disabled;
|
|
36
|
+
return /*#__PURE__*/React.createElement(RadioItem, {
|
|
37
|
+
ref: register,
|
|
98
38
|
key: v,
|
|
99
|
-
label: label,
|
|
100
39
|
name: name,
|
|
101
|
-
active: v === currentValue,
|
|
102
40
|
value: v,
|
|
103
|
-
register: register,
|
|
104
41
|
disabled: disabled || optionDisabled
|
|
105
|
-
});
|
|
106
|
-
}))
|
|
42
|
+
}, label && label.primary && t(label.primary) || v, label && label.secondary && /*#__PURE__*/React.createElement(Hint, null, t(label.secondary)));
|
|
43
|
+
}));
|
|
107
44
|
};
|
|
108
45
|
export default RadioButtonsGroup;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
5
|
-
import MuiSelect from '@material-ui/core/Select';
|
|
6
|
-
var useSelectStyles = makeStyles(function (theme) {
|
|
7
|
-
return {
|
|
8
|
-
formControl: {
|
|
9
|
-
minWidth: 120
|
|
10
|
-
},
|
|
11
|
-
selectEmpty: {
|
|
12
|
-
marginTop: theme.spacing(2)
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
});
|
|
2
|
+
import CoreSelect from '@digigov/react-core/Select';
|
|
3
|
+
import SelectOption from '@digigov/react-core/SelectOption';
|
|
16
4
|
|
|
17
|
-
var _ref2 = /*#__PURE__*/React.createElement(
|
|
5
|
+
var _ref2 = /*#__PURE__*/React.createElement(SelectOption, {
|
|
18
6
|
value: ""
|
|
19
7
|
});
|
|
20
8
|
|
|
@@ -24,27 +12,18 @@ export var Select = /*#__PURE__*/React.forwardRef(function WrappedSelect(_ref, r
|
|
|
24
12
|
options = _ref$extra.options,
|
|
25
13
|
className = _ref$extra.className,
|
|
26
14
|
disabled = _ref.disabled;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, /*#__PURE__*/React.createElement(MuiSelect, {
|
|
32
|
-
"native": true,
|
|
33
|
-
autoWidth: true,
|
|
34
|
-
inputRef: ref,
|
|
35
|
-
inputProps: {
|
|
36
|
-
name: name,
|
|
37
|
-
id: name
|
|
38
|
-
},
|
|
15
|
+
return /*#__PURE__*/React.createElement(CoreSelect, {
|
|
16
|
+
className: className,
|
|
17
|
+
ref: ref,
|
|
18
|
+
name: name,
|
|
39
19
|
disabled: disabled
|
|
40
20
|
}, _ref2, options.map(function (_ref3) {
|
|
41
21
|
var value = _ref3.value,
|
|
42
22
|
label = _ref3.label;
|
|
43
|
-
return /*#__PURE__*/React.createElement(
|
|
23
|
+
return /*#__PURE__*/React.createElement(SelectOption, {
|
|
44
24
|
key: value,
|
|
45
|
-
value: value
|
|
46
|
-
title: label && label.secondary
|
|
25
|
+
value: value
|
|
47
26
|
}, label && label.primary ? label.primary : value);
|
|
48
|
-
}))
|
|
27
|
+
}));
|
|
49
28
|
});
|
|
50
29
|
export default Select;
|
package/esm/Field/index.js
CHANGED
|
@@ -5,15 +5,18 @@ import React, { useContext, useMemo } from 'react';
|
|
|
5
5
|
import { ConditionalField } from '@digigov/form/Field/ConditionalField';
|
|
6
6
|
import { Controller } from 'react-hook-form';
|
|
7
7
|
import { FormContext } from '@digigov/form';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import CoreField from '@digigov/react-core/Field';
|
|
9
|
+
import CoreLabel from '@digigov/react-core/Label';
|
|
10
|
+
import CoreFieldset from '@digigov/react-core/Fieldset';
|
|
11
|
+
import Hint from '@digigov/react-core/Hint';
|
|
12
|
+
import FieldsetLegend from '@digigov/react-core/FieldsetLegend';
|
|
13
|
+
import ErrorMessage from '@digigov/react-core/ErrorMessage';
|
|
10
14
|
import Input from '@digigov/form/inputs/Input';
|
|
11
15
|
import Checkboxes from '@digigov/form/inputs/Checkboxes';
|
|
12
16
|
import Radio from '@digigov/form/inputs/Radio';
|
|
13
17
|
import Select from '@digigov/form/inputs/Select';
|
|
14
18
|
import FileInput from '@digigov/form/inputs/FileInput';
|
|
15
19
|
import Label from '@digigov/form/inputs/Label';
|
|
16
|
-
import NormalText from '@digigov/ui/typography/NormalText';
|
|
17
20
|
import { useTranslation } from '@digigov/ui/app/i18n';
|
|
18
21
|
var FIELD_COMPONENTS = {
|
|
19
22
|
text: {
|
|
@@ -26,10 +29,12 @@ var FIELD_COMPONENTS = {
|
|
|
26
29
|
component: FileInput
|
|
27
30
|
},
|
|
28
31
|
'choice:multiple': {
|
|
32
|
+
wrapper: "fieldset",
|
|
29
33
|
controlled: true,
|
|
30
34
|
component: Checkboxes
|
|
31
35
|
},
|
|
32
36
|
'choice:single': {
|
|
37
|
+
wrapper: "fieldset",
|
|
33
38
|
controlled: false,
|
|
34
39
|
component: Radio
|
|
35
40
|
}
|
|
@@ -40,56 +45,35 @@ var ALTERNATIVE_COMPONENTS = {
|
|
|
40
45
|
controlled: false
|
|
41
46
|
}
|
|
42
47
|
};
|
|
43
|
-
export var useFieldContainerStyles = makeStyles(function (theme) {
|
|
44
|
-
return {
|
|
45
|
-
fieldContainer: {
|
|
46
|
-
marginBottom: theme.spacing(2)
|
|
47
|
-
},
|
|
48
|
-
fieldLabel: {
|
|
49
|
-
fontWeight: 500
|
|
50
|
-
},
|
|
51
|
-
hint: {
|
|
52
|
-
color: theme.palette.grey['700']
|
|
53
|
-
},
|
|
54
|
-
errorContainer: {
|
|
55
|
-
borderLeft: "".concat(theme.spacing(0.5), "px solid ").concat(theme.palette.error.main, " "),
|
|
56
|
-
paddingLeft: theme.spacing(2)
|
|
57
|
-
},
|
|
58
|
-
error: {
|
|
59
|
-
color: theme.palette.error.main,
|
|
60
|
-
fontWeight: 'bolder',
|
|
61
|
-
margin: theme.spacing(2, 0)
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
48
|
|
|
66
49
|
var FieldContainer = function FieldContainer(_ref) {
|
|
67
|
-
var
|
|
50
|
+
var wrapper = _ref.wrapper,
|
|
68
51
|
label = _ref.label,
|
|
69
52
|
children = _ref.children,
|
|
70
53
|
error = _ref.error;
|
|
71
|
-
var classes = useFieldContainerStyles();
|
|
72
54
|
|
|
73
55
|
var _useTranslation = useTranslation(),
|
|
74
56
|
t = _useTranslation.t;
|
|
75
57
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
if (wrapper === 'fieldset') {
|
|
59
|
+
return /*#__PURE__*/React.createElement(CoreField, {
|
|
60
|
+
error: !!error
|
|
61
|
+
}, /*#__PURE__*/React.createElement(CoreFieldset, null, /*#__PURE__*/React.createElement(FieldsetLegend, {
|
|
62
|
+
size: "s"
|
|
63
|
+
}, label && label.primary, label && label.secondary && /*#__PURE__*/React.createElement(Hint, null, t(label.secondary)), error && /*#__PURE__*/React.createElement(ErrorMessage, null, t((error === null || error === void 0 ? void 0 : error.message) || '')))), children);
|
|
64
|
+
} else {
|
|
65
|
+
return /*#__PURE__*/React.createElement(CoreField, {
|
|
66
|
+
error: !!error
|
|
67
|
+
}, /*#__PURE__*/React.createElement(CoreLabel, null, label && /*#__PURE__*/React.createElement(Label, {
|
|
68
|
+
label: label
|
|
69
|
+
}), error && /*#__PURE__*/React.createElement(ErrorMessage, null, t((error === null || error === void 0 ? void 0 : error.message) || '')), children));
|
|
70
|
+
}
|
|
88
71
|
};
|
|
89
72
|
|
|
90
73
|
export var FieldBase = function FieldBase(props) {
|
|
91
74
|
var name = props.name,
|
|
92
75
|
Component = props.component,
|
|
76
|
+
wrapper = props.wrapper,
|
|
93
77
|
control = props.control,
|
|
94
78
|
type = props.type,
|
|
95
79
|
_props$controlled = props.controlled,
|
|
@@ -113,7 +97,8 @@ export var FieldBase = function FieldBase(props) {
|
|
|
113
97
|
return /*#__PURE__*/React.createElement(FieldContainer, {
|
|
114
98
|
label: label,
|
|
115
99
|
layout: layout,
|
|
116
|
-
error: error
|
|
100
|
+
error: error,
|
|
101
|
+
wrapper: wrapper
|
|
117
102
|
}, /*#__PURE__*/React.createElement(Controller, {
|
|
118
103
|
control: control,
|
|
119
104
|
name: name,
|
|
@@ -139,7 +124,8 @@ export var FieldBase = function FieldBase(props) {
|
|
|
139
124
|
return /*#__PURE__*/React.createElement(FieldContainer, {
|
|
140
125
|
label: label,
|
|
141
126
|
layout: layout,
|
|
142
|
-
error: error
|
|
127
|
+
error: error,
|
|
128
|
+
wrapper: wrapper
|
|
143
129
|
}, Component !== null && Component !== void 0 && Component.render ? /*#__PURE__*/React.createElement(Component, {
|
|
144
130
|
name: name,
|
|
145
131
|
ref: register,
|
|
@@ -202,6 +188,7 @@ function calculateField(children, field) {
|
|
|
202
188
|
var _FIELD_COMPONENTS$fie;
|
|
203
189
|
|
|
204
190
|
calculatedField.component = FIELD_COMPONENTS[field.type].component;
|
|
191
|
+
calculatedField.wrapper = FIELD_COMPONENTS[field.type].wrapper;
|
|
205
192
|
calculatedField.controlled = ((_FIELD_COMPONENTS$fie = FIELD_COMPONENTS[field.type]) === null || _FIELD_COMPONENTS$fie === void 0 ? void 0 : _FIELD_COMPONENTS$fie.controlled) || false;
|
|
206
193
|
} else {
|
|
207
194
|
var _FIELD_COMPONENTS$str2;
|
|
@@ -210,6 +197,7 @@ function calculateField(children, field) {
|
|
|
210
197
|
calculatedField.controlled = ((_FIELD_COMPONENTS$str2 = FIELD_COMPONENTS.string) === null || _FIELD_COMPONENTS$str2 === void 0 ? void 0 : _FIELD_COMPONENTS$str2.controlled) || false;
|
|
211
198
|
}
|
|
212
199
|
|
|
200
|
+
calculatedField.wrapper = calculatedField.wrapper || 'label';
|
|
213
201
|
return calculatedField;
|
|
214
202
|
}
|
|
215
203
|
|
package/esm/Fieldset/index.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import Grid from '@material-ui/core/Grid';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import CoreFieldset from '@digigov/react-core/Fieldset';
|
|
4
|
+
import FieldsetLegend from '@digigov/react-core/FieldsetLegend';
|
|
5
|
+
import Hint from '@digigov/react-core/Hint';
|
|
5
6
|
import { FormContext } from '@digigov/form';
|
|
6
7
|
import Field from '@digigov/form/Field';
|
|
7
8
|
import NormalText from '@digigov/ui/typography/NormalText';
|
|
8
9
|
import { useTranslation } from '@digigov/ui/app/i18n';
|
|
9
10
|
export var FieldsetLabel = function FieldsetLabel(_ref) {
|
|
10
11
|
var children = _ref.children;
|
|
11
|
-
return /*#__PURE__*/React.createElement(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
12
|
+
return /*#__PURE__*/React.createElement(FieldsetLegend, {
|
|
13
|
+
heading: true,
|
|
14
|
+
size: "xl"
|
|
15
|
+
}, children);
|
|
15
16
|
};
|
|
16
17
|
export var FieldsetCaption = function FieldsetCaption(_ref2) {
|
|
17
18
|
var children = _ref2.children;
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
19
|
-
item: true,
|
|
20
|
-
xs: 12
|
|
21
|
-
}, /*#__PURE__*/React.createElement(Caption, null, children));
|
|
19
|
+
return /*#__PURE__*/React.createElement(Hint, null, children);
|
|
22
20
|
};
|
|
23
21
|
export var FieldsetBody = function FieldsetBody(_ref3) {
|
|
24
22
|
var children = _ref3.children;
|
|
@@ -74,9 +72,6 @@ export var Fieldset = function Fieldset(_ref6) {
|
|
|
74
72
|
});
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
return /*#__PURE__*/React.createElement(
|
|
78
|
-
container: true,
|
|
79
|
-
spacing: 1
|
|
80
|
-
}, children);
|
|
75
|
+
return /*#__PURE__*/React.createElement(CoreFieldset, null, children);
|
|
81
76
|
};
|
|
82
77
|
export default Fieldset;
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
8
|
-
import Label from '@digigov/form/inputs/Label';
|
|
3
|
+
import { useTranslation } from '@digigov/ui/app/i18n';
|
|
4
|
+
import CoreCheckboxes from '@digigov/react-core/Checkbox';
|
|
5
|
+
import CheckboxItem from '@digigov/react-core/CheckboxItem';
|
|
6
|
+
import Hint from '@digigov/react-core/Hint';
|
|
9
7
|
|
|
10
8
|
var Checkboxes = function Checkboxes(_ref) {
|
|
11
9
|
var name = _ref.name,
|
|
@@ -33,56 +31,20 @@ var Checkboxes = function Checkboxes(_ref) {
|
|
|
33
31
|
};
|
|
34
32
|
};
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
var _useTranslation = useTranslation(),
|
|
35
|
+
t = _useTranslation.t;
|
|
36
|
+
|
|
37
|
+
return /*#__PURE__*/React.createElement(CoreCheckboxes, {
|
|
38
38
|
className: className
|
|
39
39
|
}, options.map(function (option, key) {
|
|
40
|
-
return /*#__PURE__*/React.createElement(
|
|
40
|
+
return /*#__PURE__*/React.createElement(CheckboxItem, _extends({
|
|
41
|
+
name: name,
|
|
41
42
|
disabled: disabled,
|
|
42
43
|
key: key,
|
|
43
44
|
checked: value.includes(option.value),
|
|
44
|
-
onChange: handleChange
|
|
45
|
-
}, option));
|
|
45
|
+
onChange: handleChange(option.value)
|
|
46
|
+
}, option), option.label && option.label.primary && t(option.label.primary) || value, option.label && option.label.secondary && /*#__PURE__*/React.createElement(Hint, null, t(option.label.secondary)));
|
|
46
47
|
}));
|
|
47
48
|
};
|
|
48
49
|
|
|
49
|
-
var useCheckboxStyles = makeStyles(function (theme) {
|
|
50
|
-
return {
|
|
51
|
-
formControlLabelActive: {
|
|
52
|
-
backgroundColor: theme.palette.grey['200'],
|
|
53
|
-
border: "2px solid ".concat(theme.palette.primary.main)
|
|
54
|
-
},
|
|
55
|
-
formControlLabel: {
|
|
56
|
-
fontWeight: 'bolder',
|
|
57
|
-
padding: theme.spacing(0.5),
|
|
58
|
-
margin: theme.spacing(0.5, 0)
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
var Checkbox = function Checkbox(_ref2) {
|
|
64
|
-
var className = _ref2.className,
|
|
65
|
-
checked = _ref2.checked,
|
|
66
|
-
value = _ref2.value,
|
|
67
|
-
label = _ref2.label,
|
|
68
|
-
onChange = _ref2.onChange,
|
|
69
|
-
disabled = _ref2.disabled;
|
|
70
|
-
var classes = useCheckboxStyles();
|
|
71
|
-
return /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
72
|
-
key: value,
|
|
73
|
-
className: clsx(classes.formControlLabel, checked && classes.formControlLabelActive, className),
|
|
74
|
-
control: /*#__PURE__*/React.createElement(MuiCheckbox, {
|
|
75
|
-
checked: checked,
|
|
76
|
-
disabled: disabled,
|
|
77
|
-
color: "primary",
|
|
78
|
-
onChange: onChange(value),
|
|
79
|
-
name: value
|
|
80
|
-
}),
|
|
81
|
-
label: /*#__PURE__*/React.createElement(Label, {
|
|
82
|
-
label: label,
|
|
83
|
-
value: value
|
|
84
|
-
})
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
|
|
88
50
|
export default Checkboxes;
|
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import NormalText from '@digigov/ui/typography/NormalText';
|
|
6
|
-
import Button from '@digigov/ui/core/Button';
|
|
7
|
-
var useStyles = makeStyles(function (theme) {
|
|
8
|
-
return {
|
|
9
|
-
root: {
|
|
10
|
-
'& > *': {
|
|
11
|
-
margin: theme.spacing(1)
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
input: {
|
|
15
|
-
display: 'none'
|
|
16
|
-
},
|
|
17
|
-
button: {
|
|
18
|
-
margin: 0
|
|
19
|
-
},
|
|
20
|
-
text: {
|
|
21
|
-
marginLeft: theme.spacing(2),
|
|
22
|
-
position: 'relative',
|
|
23
|
-
top: theme.spacing(0.5)
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
});
|
|
3
|
+
import NormalText from '@digigov/react-core/NormalText';
|
|
4
|
+
import FileUpload from '@digigov/react-core/FileUpload';
|
|
27
5
|
var FileInput = /*#__PURE__*/React.forwardRef(function FileInput(_ref, ref) {
|
|
28
6
|
var name = _ref.name,
|
|
29
7
|
_ref$extra = _ref.extra,
|
|
30
8
|
extra = _ref$extra === void 0 ? {} : _ref$extra,
|
|
31
9
|
disabled = _ref.disabled;
|
|
32
|
-
var classes = useStyles();
|
|
33
10
|
|
|
34
11
|
var _useState = useState([]),
|
|
35
12
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -38,16 +15,13 @@ var FileInput = /*#__PURE__*/React.forwardRef(function FileInput(_ref, ref) {
|
|
|
38
15
|
|
|
39
16
|
var filesLabel = extra.multiple ? 'αρχεία' : 'αρχείο';
|
|
40
17
|
return /*#__PURE__*/React.createElement("div", {
|
|
41
|
-
className:
|
|
42
|
-
}, /*#__PURE__*/React.createElement(
|
|
18
|
+
className: extra.className
|
|
19
|
+
}, /*#__PURE__*/React.createElement(FileUpload, {
|
|
20
|
+
ref: ref,
|
|
43
21
|
name: name,
|
|
44
22
|
id: name,
|
|
45
23
|
disabled: disabled,
|
|
46
24
|
type: 'file',
|
|
47
|
-
inputProps: {
|
|
48
|
-
multiple: extra.multiple,
|
|
49
|
-
accept: extra.accept
|
|
50
|
-
},
|
|
51
25
|
onChange: function onChange(e) {
|
|
52
26
|
var target = e.target;
|
|
53
27
|
var selectedFiles = Array.from(target.files).map(function (_ref2) {
|
|
@@ -55,16 +29,7 @@ var FileInput = /*#__PURE__*/React.forwardRef(function FileInput(_ref, ref) {
|
|
|
55
29
|
return name;
|
|
56
30
|
});
|
|
57
31
|
setFiles(selectedFiles);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
inputRef: ref
|
|
61
|
-
}), /*#__PURE__*/React.createElement("label", {
|
|
62
|
-
htmlFor: name
|
|
63
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
64
|
-
color: "secondary",
|
|
65
|
-
className: classes.button
|
|
66
|
-
}, "\u0395\u03C0\u03B9\u03BB\u03AD\u03BE\u03C4\u03B5 ", filesLabel)), /*#__PURE__*/React.createElement(NormalText, {
|
|
67
|
-
className: classes.text
|
|
68
|
-
}, files.length ? files.join(', ') : "\u0394\u03B5\u03BD \u03AD\u03C7\u03B5\u03C4\u03B5 \u03B5\u03C0\u03B9\u03BB\u03AD\u03BE\u03B5\u03B9 ".concat(filesLabel)));
|
|
32
|
+
}
|
|
33
|
+
}), /*#__PURE__*/React.createElement(NormalText, null, files.length ? files.join(', ') : "\u0394\u03B5\u03BD \u03AD\u03C7\u03B5\u03C4\u03B5 \u03B5\u03C0\u03B9\u03BB\u03AD\u03BE\u03B5\u03B9 ".concat(filesLabel)));
|
|
69
34
|
});
|
|
70
35
|
export default FileInput;
|
|
@@ -2,7 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["name", "type", "extra"];
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import TextInput from '@digigov/react-core/TextInput';
|
|
6
|
+
import TextArea from '@digigov/react-core/TextArea';
|
|
6
7
|
var TYPES_MAP = {
|
|
7
8
|
string: 'text',
|
|
8
9
|
"int": 'number',
|
|
@@ -16,10 +17,9 @@ var Input = /*#__PURE__*/React.forwardRef(function WrappedInput(_ref, ref) {
|
|
|
16
17
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
17
18
|
|
|
18
19
|
var _ref2 = extra || {},
|
|
19
|
-
multiline = _ref2.multiline,
|
|
20
|
+
_ref2$multiline = _ref2.multiline,
|
|
21
|
+
multiline = _ref2$multiline === void 0 ? false : _ref2$multiline,
|
|
20
22
|
rows = _ref2.rows,
|
|
21
|
-
_ref2$fullWidth = _ref2.fullWidth,
|
|
22
|
-
fullWidth = _ref2$fullWidth === void 0 ? true : _ref2$fullWidth,
|
|
23
23
|
className = _ref2.className; // if enforced to multiline use true. Derive from type otherwise.
|
|
24
24
|
|
|
25
25
|
|
|
@@ -28,17 +28,20 @@ var Input = /*#__PURE__*/React.forwardRef(function WrappedInput(_ref, ref) {
|
|
|
28
28
|
rows = rows || (multiline ? 4 : 1); // translate dilosi type to HTML Input type
|
|
29
29
|
|
|
30
30
|
var fieldType = TYPES_MAP[type || 'text'] || 'text';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
|
|
32
|
+
if (multiline === true) {
|
|
33
|
+
return /*#__PURE__*/React.createElement(TextArea, _extends({
|
|
34
|
+
name: name,
|
|
35
|
+
className: className,
|
|
36
|
+
rows: rows,
|
|
37
|
+
ref: ref
|
|
38
|
+
}, props));
|
|
39
|
+
} else {
|
|
40
|
+
return /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
41
|
+
name: name,
|
|
42
|
+
type: fieldType,
|
|
43
|
+
ref: ref
|
|
44
|
+
}, props));
|
|
45
|
+
}
|
|
43
46
|
});
|
|
44
47
|
export default Input;
|