envoc-form 3.0.0-3 → 3.2.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.
- package/es/ReactSelectField/ReactSelectField.js +36 -2
- package/es/index.js +14 -9
- package/lib/ReactSelectField/ReactSelectField.js +37 -2
- package/lib/index.js +84 -44
- package/package.json +100 -99
- package/src/AddressInput/__snapshots__/AddesssInput.test.js.snap +1 -1
- package/src/BoolInput/__snapshots__/BoolInput.test.js.snap +1 -1
- package/src/FormInput/__snapshots__/FormInput.test.js.snap +1 -1
- package/src/ReactSelectField/ReactSelectField.js +34 -1
- package/src/index.js +28 -16
@@ -7,6 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
7
7
|
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
9
9
|
|
10
|
+
import classNames from 'classnames';
|
10
11
|
import React, { useEffect, useRef } from 'react';
|
11
12
|
import { default as ReactSelect } from 'react-select';
|
12
13
|
export var overrideTheme = function overrideTheme(theme) {
|
@@ -22,6 +23,8 @@ var red = '#f86c6b';
|
|
22
23
|
var inputBorderColor = '#c2cfd6';
|
23
24
|
var inputBorderColorFocused = '#8ad4ee';
|
24
25
|
var inputBoxShadowFocused = '0 0 0 0.2rem rgba(32, 168, 216, 0.25)';
|
26
|
+
var placeholderColor = '#9ca3af';
|
27
|
+
var disabledSingleValueColor = '#4b5563';
|
25
28
|
export var customStyles = {
|
26
29
|
control: function control(provided, _ref) {
|
27
30
|
var isFocused = _ref.isFocused,
|
@@ -39,6 +42,17 @@ export var customStyles = {
|
|
39
42
|
return _objectSpread(_objectSpread({}, provided), {}, {
|
40
43
|
zIndex: 3
|
41
44
|
});
|
45
|
+
},
|
46
|
+
singleValue: function singleValue(provided, state) {
|
47
|
+
var color = state.isDisabled ? disabledSingleValueColor : '';
|
48
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
49
|
+
color: color
|
50
|
+
});
|
51
|
+
},
|
52
|
+
placeholder: function placeholder(defaultStyles) {
|
53
|
+
return _objectSpread(_objectSpread({}, defaultStyles), {}, {
|
54
|
+
color: placeholderColor
|
55
|
+
});
|
42
56
|
}
|
43
57
|
}; // internal to forms use only
|
44
58
|
|
@@ -48,7 +62,7 @@ export default function ReactSelectInput(_ref2) {
|
|
48
62
|
disabled = _ref2.disabled,
|
49
63
|
onSelected = _ref2.onSelected,
|
50
64
|
onChange = _ref2.onChange,
|
51
|
-
|
65
|
+
_onBlur = _ref2.onBlur,
|
52
66
|
value = _ref2.value,
|
53
67
|
options = _ref2.options,
|
54
68
|
defaultValue = _ref2.defaultValue,
|
@@ -61,6 +75,23 @@ export default function ReactSelectInput(_ref2) {
|
|
61
75
|
useEffect(function () {
|
62
76
|
onSelectedRef.current && onSelectedRef.current(selectedItems);
|
63
77
|
}, [selectedItems]);
|
78
|
+
var onBlurRef = useRef(_onBlur);
|
79
|
+
onBlurRef.current = _onBlur;
|
80
|
+
var touched = meta.touched;
|
81
|
+
useEffect(function () {
|
82
|
+
if (!touched) return; // without the timer set to 0, if the empty option is selected the required message doesn't appear until clicked away from the select input
|
83
|
+
|
84
|
+
var timerRef = setTimeout(function () {
|
85
|
+
onBlurRef.current && onBlurRef.current();
|
86
|
+
}, 0);
|
87
|
+
return function () {
|
88
|
+
clearTimeout(timerRef);
|
89
|
+
};
|
90
|
+
}, [value, touched]);
|
91
|
+
var classes = classNames(className, 'react-select-input', {
|
92
|
+
'is-invalid': !!meta.error,
|
93
|
+
disabled: disabled
|
94
|
+
});
|
64
95
|
return /*#__PURE__*/React.createElement(ReactSelect, _extends({}, props, {
|
65
96
|
options: options,
|
66
97
|
isDisabled: disabled,
|
@@ -71,7 +102,10 @@ export default function ReactSelectInput(_ref2) {
|
|
71
102
|
getOptionValue: getOptionValue,
|
72
103
|
value: selectedItems,
|
73
104
|
onChange: handleChange,
|
74
|
-
|
105
|
+
onBlur: function onBlur() {
|
106
|
+
return _onBlur();
|
107
|
+
},
|
108
|
+
className: classes,
|
75
109
|
theme: overrideTheme,
|
76
110
|
styles: customStyles,
|
77
111
|
menuPortalTarget: document.body,
|
package/es/index.js
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
+
import * as normalizers from './normalizers';
|
2
|
+
import { BoolInput, InlineBoolInput } from './BoolInput';
|
3
|
+
import { InlineMoneyInput, MoneyInput } from './MoneyInput';
|
4
|
+
import AddressInput from './AddressInput';
|
5
|
+
import ConfirmBaseForm from './ConfirmBaseForm';
|
6
|
+
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
7
|
+
import ErrorScrollTarget from './ErrorScrollTarget';
|
1
8
|
import Form from './Form';
|
9
|
+
import FormGroup from './FormGroup';
|
10
|
+
import FormGroupWrapper from './FormGroupWrapper';
|
2
11
|
import FormInput from './FormInput';
|
3
|
-
import InlineFormInput from './InlineFormInput';
|
4
12
|
import FormInputArray from './FormInputArray';
|
13
|
+
import FormSection from './FormSection';
|
5
14
|
import IconInput from './IconInput';
|
6
|
-
import
|
15
|
+
import InlineFormInput from './InlineFormInput';
|
7
16
|
import StandardFormActions from './StandardFormActions';
|
8
|
-
import validators from './validators';
|
9
|
-
import * as normalizers from './normalizers';
|
10
|
-
import ConfirmBaseForm from './ConfirmBaseForm';
|
11
|
-
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
12
17
|
import SubmitFormButton from './SubmitFormButton';
|
13
|
-
import
|
14
|
-
import
|
15
|
-
export { Form,
|
18
|
+
import useStandardFormInput from './useStandardFormInput';
|
19
|
+
import validators from './validators';
|
20
|
+
export { AddressInput, BoolInput, ConfirmBaseForm, ConfirmDeleteForm, ErrorScrollTarget, Form, FormGroup, FormGroupWrapper, FormInput, FormInputArray, FormSection, IconInput, InlineBoolInput, InlineFormInput, InlineMoneyInput, MoneyInput, normalizers, StandardFormActions, SubmitFormButton, useStandardFormInput, validators };
|
@@ -16,6 +16,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
16
16
|
|
17
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
18
18
|
|
19
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
20
|
+
|
19
21
|
var _react = _interopRequireWildcard(require("react"));
|
20
22
|
|
21
23
|
var _reactSelect = _interopRequireDefault(require("react-select"));
|
@@ -45,6 +47,8 @@ var red = '#f86c6b';
|
|
45
47
|
var inputBorderColor = '#c2cfd6';
|
46
48
|
var inputBorderColorFocused = '#8ad4ee';
|
47
49
|
var inputBoxShadowFocused = '0 0 0 0.2rem rgba(32, 168, 216, 0.25)';
|
50
|
+
var placeholderColor = '#9ca3af';
|
51
|
+
var disabledSingleValueColor = '#4b5563';
|
48
52
|
var customStyles = {
|
49
53
|
control: function control(provided, _ref) {
|
50
54
|
var isFocused = _ref.isFocused,
|
@@ -62,6 +66,17 @@ var customStyles = {
|
|
62
66
|
return _objectSpread(_objectSpread({}, provided), {}, {
|
63
67
|
zIndex: 3
|
64
68
|
});
|
69
|
+
},
|
70
|
+
singleValue: function singleValue(provided, state) {
|
71
|
+
var color = state.isDisabled ? disabledSingleValueColor : '';
|
72
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
73
|
+
color: color
|
74
|
+
});
|
75
|
+
},
|
76
|
+
placeholder: function placeholder(defaultStyles) {
|
77
|
+
return _objectSpread(_objectSpread({}, defaultStyles), {}, {
|
78
|
+
color: placeholderColor
|
79
|
+
});
|
65
80
|
}
|
66
81
|
}; // internal to forms use only
|
67
82
|
|
@@ -73,7 +88,7 @@ function ReactSelectInput(_ref2) {
|
|
73
88
|
disabled = _ref2.disabled,
|
74
89
|
onSelected = _ref2.onSelected,
|
75
90
|
onChange = _ref2.onChange,
|
76
|
-
|
91
|
+
_onBlur = _ref2.onBlur,
|
77
92
|
value = _ref2.value,
|
78
93
|
options = _ref2.options,
|
79
94
|
defaultValue = _ref2.defaultValue,
|
@@ -85,6 +100,23 @@ function ReactSelectInput(_ref2) {
|
|
85
100
|
(0, _react.useEffect)(function () {
|
86
101
|
onSelectedRef.current && onSelectedRef.current(selectedItems);
|
87
102
|
}, [selectedItems]);
|
103
|
+
var onBlurRef = (0, _react.useRef)(_onBlur);
|
104
|
+
onBlurRef.current = _onBlur;
|
105
|
+
var touched = meta.touched;
|
106
|
+
(0, _react.useEffect)(function () {
|
107
|
+
if (!touched) return; // without the timer set to 0, if the empty option is selected the required message doesn't appear until clicked away from the select input
|
108
|
+
|
109
|
+
var timerRef = setTimeout(function () {
|
110
|
+
onBlurRef.current && onBlurRef.current();
|
111
|
+
}, 0);
|
112
|
+
return function () {
|
113
|
+
clearTimeout(timerRef);
|
114
|
+
};
|
115
|
+
}, [value, touched]);
|
116
|
+
var classes = (0, _classnames["default"])(className, 'react-select-input', {
|
117
|
+
'is-invalid': !!meta.error,
|
118
|
+
disabled: disabled
|
119
|
+
});
|
88
120
|
return /*#__PURE__*/_react["default"].createElement(_reactSelect["default"], (0, _extends2["default"])({}, props, {
|
89
121
|
options: options,
|
90
122
|
isDisabled: disabled,
|
@@ -95,7 +127,10 @@ function ReactSelectInput(_ref2) {
|
|
95
127
|
getOptionValue: getOptionValue,
|
96
128
|
value: selectedItems,
|
97
129
|
onChange: handleChange,
|
98
|
-
|
130
|
+
onBlur: function onBlur() {
|
131
|
+
return _onBlur();
|
132
|
+
},
|
133
|
+
className: classes,
|
99
134
|
theme: overrideTheme,
|
100
135
|
styles: customStyles,
|
101
136
|
menuPortalTarget: document.body,
|
package/lib/index.js
CHANGED
@@ -7,127 +7,167 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
8
8
|
value: true
|
9
9
|
});
|
10
|
-
Object.defineProperty(exports, "
|
10
|
+
Object.defineProperty(exports, "BoolInput", {
|
11
11
|
enumerable: true,
|
12
12
|
get: function get() {
|
13
|
-
return
|
13
|
+
return _BoolInput.BoolInput;
|
14
14
|
}
|
15
15
|
});
|
16
|
-
Object.defineProperty(exports, "
|
16
|
+
Object.defineProperty(exports, "InlineBoolInput", {
|
17
17
|
enumerable: true,
|
18
18
|
get: function get() {
|
19
|
-
return
|
19
|
+
return _BoolInput.InlineBoolInput;
|
20
20
|
}
|
21
21
|
});
|
22
|
-
Object.defineProperty(exports, "
|
22
|
+
Object.defineProperty(exports, "InlineMoneyInput", {
|
23
23
|
enumerable: true,
|
24
24
|
get: function get() {
|
25
|
-
return
|
25
|
+
return _MoneyInput.InlineMoneyInput;
|
26
26
|
}
|
27
27
|
});
|
28
|
-
Object.defineProperty(exports, "
|
28
|
+
Object.defineProperty(exports, "MoneyInput", {
|
29
29
|
enumerable: true,
|
30
30
|
get: function get() {
|
31
|
-
return
|
31
|
+
return _MoneyInput.MoneyInput;
|
32
32
|
}
|
33
33
|
});
|
34
|
-
Object.defineProperty(exports, "
|
34
|
+
Object.defineProperty(exports, "AddressInput", {
|
35
35
|
enumerable: true,
|
36
36
|
get: function get() {
|
37
|
-
return
|
37
|
+
return _AddressInput["default"];
|
38
38
|
}
|
39
39
|
});
|
40
|
-
Object.defineProperty(exports, "
|
40
|
+
Object.defineProperty(exports, "ConfirmBaseForm", {
|
41
41
|
enumerable: true,
|
42
42
|
get: function get() {
|
43
|
-
return
|
43
|
+
return _ConfirmBaseForm["default"];
|
44
44
|
}
|
45
45
|
});
|
46
|
-
Object.defineProperty(exports, "
|
46
|
+
Object.defineProperty(exports, "ConfirmDeleteForm", {
|
47
47
|
enumerable: true,
|
48
48
|
get: function get() {
|
49
|
-
return
|
49
|
+
return _ConfirmDeleteForm["default"];
|
50
50
|
}
|
51
51
|
});
|
52
|
-
Object.defineProperty(exports, "
|
52
|
+
Object.defineProperty(exports, "ErrorScrollTarget", {
|
53
53
|
enumerable: true,
|
54
54
|
get: function get() {
|
55
|
-
return
|
55
|
+
return _ErrorScrollTarget["default"];
|
56
56
|
}
|
57
57
|
});
|
58
|
-
Object.defineProperty(exports, "
|
58
|
+
Object.defineProperty(exports, "Form", {
|
59
59
|
enumerable: true,
|
60
60
|
get: function get() {
|
61
|
-
return
|
61
|
+
return _Form["default"];
|
62
62
|
}
|
63
63
|
});
|
64
|
-
Object.defineProperty(exports, "
|
64
|
+
Object.defineProperty(exports, "FormGroup", {
|
65
65
|
enumerable: true,
|
66
66
|
get: function get() {
|
67
|
-
return
|
67
|
+
return _FormGroup["default"];
|
68
68
|
}
|
69
69
|
});
|
70
|
-
Object.defineProperty(exports, "
|
70
|
+
Object.defineProperty(exports, "FormGroupWrapper", {
|
71
71
|
enumerable: true,
|
72
72
|
get: function get() {
|
73
|
-
return
|
73
|
+
return _FormGroupWrapper["default"];
|
74
74
|
}
|
75
75
|
});
|
76
|
-
Object.defineProperty(exports, "
|
76
|
+
Object.defineProperty(exports, "FormInput", {
|
77
77
|
enumerable: true,
|
78
78
|
get: function get() {
|
79
|
-
return
|
79
|
+
return _FormInput["default"];
|
80
80
|
}
|
81
81
|
});
|
82
|
-
Object.defineProperty(exports, "
|
82
|
+
Object.defineProperty(exports, "FormInputArray", {
|
83
83
|
enumerable: true,
|
84
84
|
get: function get() {
|
85
|
-
return
|
85
|
+
return _FormInputArray["default"];
|
86
86
|
}
|
87
87
|
});
|
88
|
-
Object.defineProperty(exports, "
|
88
|
+
Object.defineProperty(exports, "FormSection", {
|
89
89
|
enumerable: true,
|
90
90
|
get: function get() {
|
91
|
-
return
|
91
|
+
return _FormSection["default"];
|
92
92
|
}
|
93
93
|
});
|
94
|
-
Object.defineProperty(exports, "
|
94
|
+
Object.defineProperty(exports, "IconInput", {
|
95
95
|
enumerable: true,
|
96
96
|
get: function get() {
|
97
|
-
return
|
97
|
+
return _IconInput["default"];
|
98
|
+
}
|
99
|
+
});
|
100
|
+
Object.defineProperty(exports, "InlineFormInput", {
|
101
|
+
enumerable: true,
|
102
|
+
get: function get() {
|
103
|
+
return _InlineFormInput["default"];
|
104
|
+
}
|
105
|
+
});
|
106
|
+
Object.defineProperty(exports, "StandardFormActions", {
|
107
|
+
enumerable: true,
|
108
|
+
get: function get() {
|
109
|
+
return _StandardFormActions["default"];
|
110
|
+
}
|
111
|
+
});
|
112
|
+
Object.defineProperty(exports, "SubmitFormButton", {
|
113
|
+
enumerable: true,
|
114
|
+
get: function get() {
|
115
|
+
return _SubmitFormButton["default"];
|
116
|
+
}
|
117
|
+
});
|
118
|
+
Object.defineProperty(exports, "useStandardFormInput", {
|
119
|
+
enumerable: true,
|
120
|
+
get: function get() {
|
121
|
+
return _useStandardFormInput["default"];
|
122
|
+
}
|
123
|
+
});
|
124
|
+
Object.defineProperty(exports, "validators", {
|
125
|
+
enumerable: true,
|
126
|
+
get: function get() {
|
127
|
+
return _validators["default"];
|
98
128
|
}
|
99
129
|
});
|
100
130
|
exports.normalizers = void 0;
|
101
131
|
|
102
|
-
var
|
132
|
+
var normalizers = _interopRequireWildcard(require("./normalizers"));
|
103
133
|
|
104
|
-
|
134
|
+
exports.normalizers = normalizers;
|
105
135
|
|
106
|
-
var
|
136
|
+
var _BoolInput = require("./BoolInput");
|
107
137
|
|
108
|
-
var
|
138
|
+
var _MoneyInput = require("./MoneyInput");
|
109
139
|
|
110
|
-
var
|
140
|
+
var _AddressInput = _interopRequireDefault(require("./AddressInput"));
|
111
141
|
|
112
|
-
var
|
142
|
+
var _ConfirmBaseForm = _interopRequireDefault(require("./ConfirmBaseForm"));
|
113
143
|
|
114
|
-
var
|
144
|
+
var _ConfirmDeleteForm = _interopRequireDefault(require("./ConfirmDeleteForm"));
|
115
145
|
|
116
|
-
var
|
146
|
+
var _ErrorScrollTarget = _interopRequireDefault(require("./ErrorScrollTarget"));
|
117
147
|
|
118
|
-
var
|
148
|
+
var _Form = _interopRequireDefault(require("./Form"));
|
119
149
|
|
120
|
-
|
150
|
+
var _FormGroup = _interopRequireDefault(require("./FormGroup"));
|
121
151
|
|
122
|
-
var
|
152
|
+
var _FormGroupWrapper = _interopRequireDefault(require("./FormGroupWrapper"));
|
123
153
|
|
124
|
-
var
|
154
|
+
var _FormInput = _interopRequireDefault(require("./FormInput"));
|
155
|
+
|
156
|
+
var _FormInputArray = _interopRequireDefault(require("./FormInputArray"));
|
157
|
+
|
158
|
+
var _FormSection = _interopRequireDefault(require("./FormSection"));
|
159
|
+
|
160
|
+
var _IconInput = _interopRequireDefault(require("./IconInput"));
|
161
|
+
|
162
|
+
var _InlineFormInput = _interopRequireDefault(require("./InlineFormInput"));
|
163
|
+
|
164
|
+
var _StandardFormActions = _interopRequireDefault(require("./StandardFormActions"));
|
125
165
|
|
126
166
|
var _SubmitFormButton = _interopRequireDefault(require("./SubmitFormButton"));
|
127
167
|
|
128
|
-
var
|
168
|
+
var _useStandardFormInput = _interopRequireDefault(require("./useStandardFormInput"));
|
129
169
|
|
130
|
-
var
|
170
|
+
var _validators = _interopRequireDefault(require("./validators"));
|
131
171
|
|
132
172
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
133
173
|
|
package/package.json
CHANGED
@@ -1,99 +1,100 @@
|
|
1
|
-
{
|
2
|
-
"name": "envoc-form",
|
3
|
-
"version": "3.
|
4
|
-
"description": "Envoc form components",
|
5
|
-
"keywords": [
|
6
|
-
"react-component",
|
7
|
-
"react",
|
8
|
-
"forms",
|
9
|
-
"components",
|
10
|
-
"envoc"
|
11
|
-
],
|
12
|
-
"homepage": "",
|
13
|
-
"repository": "",
|
14
|
-
"license": "MIT",
|
15
|
-
"author": "Envoc Developers",
|
16
|
-
"sideEffects": false,
|
17
|
-
"main": "lib/index.js",
|
18
|
-
"module": "es/index.js",
|
19
|
-
"files": [
|
20
|
-
"dist",
|
21
|
-
"src",
|
22
|
-
"lib",
|
23
|
-
"es"
|
24
|
-
],
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
35
|
-
|
36
|
-
|
37
|
-
"
|
38
|
-
"
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
|
45
|
-
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"@
|
53
|
-
"@
|
54
|
-
"
|
55
|
-
|
56
|
-
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"
|
75
|
-
|
76
|
-
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"
|
82
|
-
|
83
|
-
|
84
|
-
"
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
"
|
90
|
-
"
|
91
|
-
"
|
92
|
-
"
|
93
|
-
|
94
|
-
|
95
|
-
"
|
96
|
-
|
97
|
-
|
98
|
-
}
|
99
|
-
|
1
|
+
{
|
2
|
+
"name": "envoc-form",
|
3
|
+
"version": "3.2.0",
|
4
|
+
"description": "Envoc form components",
|
5
|
+
"keywords": [
|
6
|
+
"react-component",
|
7
|
+
"react",
|
8
|
+
"forms",
|
9
|
+
"components",
|
10
|
+
"envoc"
|
11
|
+
],
|
12
|
+
"homepage": "",
|
13
|
+
"repository": "",
|
14
|
+
"license": "MIT",
|
15
|
+
"author": "Envoc Developers",
|
16
|
+
"sideEffects": false,
|
17
|
+
"main": "lib/index.js",
|
18
|
+
"module": "es/index.js",
|
19
|
+
"files": [
|
20
|
+
"dist",
|
21
|
+
"src",
|
22
|
+
"lib",
|
23
|
+
"es"
|
24
|
+
],
|
25
|
+
"dependencies": {
|
26
|
+
"axios": "^0.21.1",
|
27
|
+
"classnames": "^2.3.1",
|
28
|
+
"date-fns": "^2.22.1",
|
29
|
+
"envoc-request": "^3.2.0",
|
30
|
+
"lru-cache": "^6.0.0",
|
31
|
+
"prop-types": "^15.7.2",
|
32
|
+
"react-date-picker": "^8.2.0",
|
33
|
+
"react-dropzone": "^11.3.4",
|
34
|
+
"react-router": "^6.2.1",
|
35
|
+
"react-select": "^3.1.1",
|
36
|
+
"react-textarea-autosize": "^8.3.3",
|
37
|
+
"react-toastify": "^7.0.4",
|
38
|
+
"reactstrap": "^8.9.0",
|
39
|
+
"smoothscroll-polyfill": "^0.4.4",
|
40
|
+
"uuid": "^8.3.2",
|
41
|
+
"@fortawesome/react-fontawesome": "~0.1.16",
|
42
|
+
"@fortawesome/free-solid-svg-icons": "~5.15.4",
|
43
|
+
"@fortawesome/fontawesome-svg-core": "~1.2.36"
|
44
|
+
},
|
45
|
+
"devDependencies": {
|
46
|
+
"@babel/cli": "^7.14.5",
|
47
|
+
"@babel/core": "^7.14.6",
|
48
|
+
"@babel/plugin-transform-runtime": "^7.14.5",
|
49
|
+
"@babel/preset-env": "^7.14.7",
|
50
|
+
"@babel/preset-react": "^7.14.5",
|
51
|
+
"@testing-library/jest-dom": "^5.14.1",
|
52
|
+
"@testing-library/react": "^11.2.5",
|
53
|
+
"@testing-library/user-event": "^12.7.1",
|
54
|
+
"babel-loader": "^8.2.2",
|
55
|
+
"bootstrap": "^4.6.0",
|
56
|
+
"clean-webpack-plugin": "^3.0.0",
|
57
|
+
"cross-env": "7.0.3",
|
58
|
+
"css-loader": "^5.0.2",
|
59
|
+
"html-webpack-plugin": "^5.3.2",
|
60
|
+
"identity-obj-proxy": "^3.0.0",
|
61
|
+
"jest-junit": "~12.2.0",
|
62
|
+
"react": "^17.0.1",
|
63
|
+
"react-dom": "^17.0.1",
|
64
|
+
"react-router-dom": "^6.2.1",
|
65
|
+
"react-scripts": "^4.0.3",
|
66
|
+
"rimraf": "~3.0.2",
|
67
|
+
"sass": "^1.35.2",
|
68
|
+
"sass-loader": "^11.0.1",
|
69
|
+
"style-loader": "^2.0.0",
|
70
|
+
"webpack": "^5.45.0",
|
71
|
+
"webpack-cli": "^4.7.2",
|
72
|
+
"webpack-dev-server": "^3.11.2",
|
73
|
+
"typedoc-plugin-markdown": "~3.10.3",
|
74
|
+
"typedoc": "~0.21.4"
|
75
|
+
},
|
76
|
+
"peerDependencies": {
|
77
|
+
"@babel/runtime": "^7.14.6",
|
78
|
+
"formik": "^2.2.9",
|
79
|
+
"react": ">=16.8.0",
|
80
|
+
"react-dom": ">=16.8.0",
|
81
|
+
"react-router-dom": "^6.2.1"
|
82
|
+
},
|
83
|
+
"jest": {
|
84
|
+
"transformIgnorePatterns": [
|
85
|
+
"^.+\\.module\\.(css|sass|scss)$"
|
86
|
+
]
|
87
|
+
},
|
88
|
+
"scripts": {
|
89
|
+
"build": "yarn verify-imports && yarn build:esm && yarn build:cjs && yarn build:css",
|
90
|
+
"rebuild": "rimraf ./{dist,es,lib} && yarn build",
|
91
|
+
"build:esm": "cross-env BABEL_ENV=esm-dir babel src --out-dir es --ignore \"src/**/*.spec.js\",\"src/**/*.test.js\"",
|
92
|
+
"build:css": "sass src/styles.scss dist/css/envoc-form-styles.css",
|
93
|
+
"build:cjs": "babel src --out-dir lib --ignore \"src/**/*.spec.js\",\"src/**/*.test.js\"",
|
94
|
+
"verify-imports": "node ../../scripts/check-for-scss-imports.js envoc-form",
|
95
|
+
"start": "webpack serve --config ./webpack.demo.config.js",
|
96
|
+
"test": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test --watchAll=false",
|
97
|
+
"coverage": "yarn test --reporters=jest-junit --coverage --coverageReporters=cobertura"
|
98
|
+
},
|
99
|
+
"readme": "# envoc-form\r\n\r\n[![npm package][npm-badge]][npm]\r\n\r\nBase form package for envoc projects.\r\n\r\n[npm-badge]: https://img.shields.io/npm/v/envoc-form.png?style=flat\r\n[npm]: https://www.npmjs.com/package/envoc-form"
|
100
|
+
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import classNames from 'classnames';
|
1
2
|
import React, { useEffect, useRef } from 'react';
|
2
3
|
import { default as ReactSelect } from 'react-select';
|
3
4
|
|
@@ -17,6 +18,8 @@ const red = '#f86c6b';
|
|
17
18
|
const inputBorderColor = '#c2cfd6';
|
18
19
|
const inputBorderColorFocused = '#8ad4ee';
|
19
20
|
const inputBoxShadowFocused = '0 0 0 0.2rem rgba(32, 168, 216, 0.25)';
|
21
|
+
const placeholderColor = '#9ca3af';
|
22
|
+
const disabledSingleValueColor = '#4b5563';
|
20
23
|
|
21
24
|
export const customStyles = {
|
22
25
|
control: (provided, { isFocused, selectProps }) => {
|
@@ -35,6 +38,13 @@ export const customStyles = {
|
|
35
38
|
};
|
36
39
|
},
|
37
40
|
menu: (provided) => ({ ...provided, zIndex: 3 }),
|
41
|
+
singleValue: (provided, state) => {
|
42
|
+
const color = state.isDisabled ? disabledSingleValueColor : '';
|
43
|
+
return { ...provided, color };
|
44
|
+
},
|
45
|
+
placeholder: (defaultStyles) => {
|
46
|
+
return { ...defaultStyles, color: placeholderColor };
|
47
|
+
},
|
38
48
|
};
|
39
49
|
|
40
50
|
// internal to forms use only
|
@@ -59,6 +69,28 @@ export default function ReactSelectInput({
|
|
59
69
|
onSelectedRef.current && onSelectedRef.current(selectedItems);
|
60
70
|
}, [selectedItems]);
|
61
71
|
|
72
|
+
const onBlurRef = useRef(onBlur);
|
73
|
+
onBlurRef.current = onBlur;
|
74
|
+
const { touched } = meta;
|
75
|
+
|
76
|
+
useEffect(() => {
|
77
|
+
if (!touched) return;
|
78
|
+
|
79
|
+
// without the timer set to 0, if the empty option is selected the required message doesn't appear until clicked away from the select input
|
80
|
+
const timerRef = setTimeout(() => {
|
81
|
+
onBlurRef.current && onBlurRef.current();
|
82
|
+
}, 0);
|
83
|
+
|
84
|
+
return () => {
|
85
|
+
clearTimeout(timerRef);
|
86
|
+
};
|
87
|
+
}, [value, touched]);
|
88
|
+
|
89
|
+
const classes = classNames(className, 'react-select-input', {
|
90
|
+
'is-invalid': !!meta.error,
|
91
|
+
disabled: disabled,
|
92
|
+
});
|
93
|
+
|
62
94
|
return (
|
63
95
|
<ReactSelect
|
64
96
|
{...props}
|
@@ -69,7 +101,8 @@ export default function ReactSelectInput({
|
|
69
101
|
getOptionValue={getOptionValue}
|
70
102
|
value={selectedItems}
|
71
103
|
onChange={handleChange}
|
72
|
-
|
104
|
+
onBlur={() => onBlur()}
|
105
|
+
className={classes}
|
73
106
|
theme={overrideTheme}
|
74
107
|
styles={customStyles}
|
75
108
|
menuPortalTarget={document.body}
|
package/src/index.js
CHANGED
@@ -1,33 +1,45 @@
|
|
1
|
+
import * as normalizers from './normalizers';
|
2
|
+
|
3
|
+
import { BoolInput, InlineBoolInput } from './BoolInput';
|
4
|
+
import { InlineMoneyInput, MoneyInput } from './MoneyInput';
|
5
|
+
|
6
|
+
import AddressInput from './AddressInput';
|
7
|
+
import ConfirmBaseForm from './ConfirmBaseForm';
|
8
|
+
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
9
|
+
import ErrorScrollTarget from './ErrorScrollTarget';
|
1
10
|
import Form from './Form';
|
11
|
+
import FormGroup from './FormGroup';
|
12
|
+
import FormGroupWrapper from './FormGroupWrapper';
|
2
13
|
import FormInput from './FormInput';
|
3
|
-
import InlineFormInput from './InlineFormInput';
|
4
14
|
import FormInputArray from './FormInputArray';
|
15
|
+
import FormSection from './FormSection';
|
5
16
|
import IconInput from './IconInput';
|
6
|
-
import
|
17
|
+
import InlineFormInput from './InlineFormInput';
|
7
18
|
import StandardFormActions from './StandardFormActions';
|
8
|
-
import validators from './validators';
|
9
|
-
import * as normalizers from './normalizers';
|
10
|
-
import ConfirmBaseForm from './ConfirmBaseForm';
|
11
|
-
import ConfirmDeleteForm from './ConfirmDeleteForm';
|
12
19
|
import SubmitFormButton from './SubmitFormButton';
|
13
|
-
import
|
14
|
-
import
|
20
|
+
import useStandardFormInput from './useStandardFormInput';
|
21
|
+
import validators from './validators';
|
15
22
|
|
16
23
|
export {
|
24
|
+
AddressInput,
|
25
|
+
BoolInput,
|
26
|
+
ConfirmBaseForm,
|
27
|
+
ConfirmDeleteForm,
|
28
|
+
ErrorScrollTarget,
|
17
29
|
Form,
|
30
|
+
FormGroup,
|
31
|
+
FormGroupWrapper,
|
18
32
|
FormInput,
|
19
|
-
InlineFormInput,
|
20
33
|
FormInputArray,
|
34
|
+
FormSection,
|
21
35
|
IconInput,
|
22
|
-
BoolInput,
|
23
36
|
InlineBoolInput,
|
24
|
-
|
37
|
+
InlineFormInput,
|
38
|
+
InlineMoneyInput,
|
39
|
+
MoneyInput,
|
25
40
|
normalizers,
|
26
41
|
StandardFormActions,
|
27
|
-
ConfirmBaseForm,
|
28
|
-
ConfirmDeleteForm,
|
29
42
|
SubmitFormButton,
|
30
|
-
|
31
|
-
|
32
|
-
InlineMoneyInput,
|
43
|
+
useStandardFormInput,
|
44
|
+
validators,
|
33
45
|
};
|