@comicrelief/component-library 6.0.0 → 6.1.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/dist/components/Atoms/Select/Select.js +7 -3
- package/dist/components/Atoms/Select/__snapshots__/Select.test.js.snap +1 -0
- package/dist/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +1 -0
- package/package.json +1 -1
- package/src/components/Atoms/Select/Select.js +13 -3
- package/src/components/Atoms/Select/__snapshots__/Select.test.js.snap +1 -0
- package/src/components/Organisms/EmailSignUp/__snapshots__/EmailSignUp.test.js.snap +1 -0
|
@@ -23,7 +23,7 @@ var _dropDownDarkPurple = _interopRequireDefault(require("./assets/drop-down-dar
|
|
|
23
23
|
|
|
24
24
|
var _spacing = _interopRequireDefault(require("../../../theme/shared/spacing"));
|
|
25
25
|
|
|
26
|
-
var _excluded = ["errorMsg", "description", "label", "options", "hideLabel", "defaultValue", "onChange", "greyDescription", "className"];
|
|
26
|
+
var _excluded = ["errorMsg", "description", "label", "options", "hideLabel", "defaultValue", "onChange", "greyDescription", "className", "optional"];
|
|
27
27
|
|
|
28
28
|
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); }
|
|
29
29
|
|
|
@@ -68,6 +68,7 @@ var Select = /*#__PURE__*/_react.default.forwardRef(function (_ref8, ref) {
|
|
|
68
68
|
_onChange = _ref8.onChange,
|
|
69
69
|
greyDescription = _ref8.greyDescription,
|
|
70
70
|
className = _ref8.className,
|
|
71
|
+
optional = _ref8.optional,
|
|
71
72
|
rest = (0, _objectWithoutProperties2.default)(_ref8, _excluded);
|
|
72
73
|
|
|
73
74
|
var _useState = (0, _react.useState)(''),
|
|
@@ -79,7 +80,8 @@ var Select = /*#__PURE__*/_react.default.forwardRef(function (_ref8, ref) {
|
|
|
79
80
|
label: label,
|
|
80
81
|
hideLabel: hideLabel,
|
|
81
82
|
errorMsg: errorMsg,
|
|
82
|
-
className: className
|
|
83
|
+
className: className,
|
|
84
|
+
optional: optional
|
|
83
85
|
}, /*#__PURE__*/_react.default.createElement(StyledSelect, Object.assign({
|
|
84
86
|
onChange: function onChange(e) {
|
|
85
87
|
setValue(e.currentTarget.value);
|
|
@@ -91,6 +93,7 @@ var Select = /*#__PURE__*/_react.default.forwardRef(function (_ref8, ref) {
|
|
|
91
93
|
}, rest, {
|
|
92
94
|
error: errorMsg,
|
|
93
95
|
defaultValue: defaultValue,
|
|
96
|
+
required: optional === false,
|
|
94
97
|
hasValue: !!value,
|
|
95
98
|
greyDescription: greyDescription,
|
|
96
99
|
ref: ref
|
|
@@ -117,7 +120,8 @@ Select.defaultProps = {
|
|
|
117
120
|
/** If true, the 'description' option, which is initially selected but disabled, will be grey
|
|
118
121
|
* - like a text input's placeholder */
|
|
119
122
|
greyDescription: false,
|
|
120
|
-
className: ''
|
|
123
|
+
className: '',
|
|
124
|
+
optional: false
|
|
121
125
|
};
|
|
122
126
|
var _default = Select;
|
|
123
127
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -49,6 +49,7 @@ const Select = React.forwardRef(
|
|
|
49
49
|
onChange,
|
|
50
50
|
greyDescription,
|
|
51
51
|
className,
|
|
52
|
+
optional,
|
|
52
53
|
...rest
|
|
53
54
|
},
|
|
54
55
|
ref
|
|
@@ -56,7 +57,13 @@ const Select = React.forwardRef(
|
|
|
56
57
|
const [value, setValue] = useState('');
|
|
57
58
|
|
|
58
59
|
return (
|
|
59
|
-
<Label
|
|
60
|
+
<Label
|
|
61
|
+
label={label}
|
|
62
|
+
hideLabel={hideLabel}
|
|
63
|
+
errorMsg={errorMsg}
|
|
64
|
+
className={className}
|
|
65
|
+
optional={optional}
|
|
66
|
+
>
|
|
60
67
|
<StyledSelect
|
|
61
68
|
onChange={e => {
|
|
62
69
|
setValue(e.currentTarget.value);
|
|
@@ -67,6 +74,7 @@ const Select = React.forwardRef(
|
|
|
67
74
|
{...rest}
|
|
68
75
|
error={errorMsg}
|
|
69
76
|
defaultValue={defaultValue}
|
|
77
|
+
required={optional === false}
|
|
70
78
|
hasValue={!!value}
|
|
71
79
|
greyDescription={greyDescription}
|
|
72
80
|
ref={ref}
|
|
@@ -102,7 +110,8 @@ Select.propTypes = {
|
|
|
102
110
|
greyDescription: PropTypes.bool,
|
|
103
111
|
// className is needed so that styled(`Select`) will work
|
|
104
112
|
// (as `rest` is not spread on the outermost component)
|
|
105
|
-
className: PropTypes.string
|
|
113
|
+
className: PropTypes.string,
|
|
114
|
+
optional: PropTypes.bool
|
|
106
115
|
};
|
|
107
116
|
|
|
108
117
|
Select.defaultProps = {
|
|
@@ -112,7 +121,8 @@ Select.defaultProps = {
|
|
|
112
121
|
/** If true, the 'description' option, which is initially selected but disabled, will be grey
|
|
113
122
|
* - like a text input's placeholder */
|
|
114
123
|
greyDescription: false,
|
|
115
|
-
className: ''
|
|
124
|
+
className: '',
|
|
125
|
+
optional: false
|
|
116
126
|
};
|
|
117
127
|
|
|
118
128
|
export default Select;
|