@sb1/ffe-form-react 18.0.3 → 19.0.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/BaseRadioButton.js +35 -95
- package/es/Checkbox.js +43 -49
- package/es/Input.js +25 -26
- package/es/InputGroup.js +91 -109
- package/es/InputTextLike.js +25 -19
- package/es/Label.js +27 -28
- package/es/PhoneNumber.js +48 -158
- package/es/RadioBlock.js +37 -98
- package/es/RadioButton.js +26 -22
- package/es/RadioButtonInputGroup.js +44 -97
- package/es/RadioSwitch.js +38 -64
- package/es/TextArea.js +25 -16
- package/es/ToggleSwitch.js +36 -98
- package/es/Tooltip.js +29 -75
- package/es/i18n/en.js +6 -6
- package/es/i18n/i18n.js +4 -4
- package/es/i18n/nb.js +6 -6
- package/es/i18n/nn.js +6 -6
- package/es/index.js +14 -17
- package/es/message/BaseFieldMessage.js +49 -0
- package/es/message/ErrorFieldMessage.js +28 -0
- package/es/message/InfoFieldMessage.js +28 -0
- package/es/message/SuccessFieldMessage.js +28 -0
- package/es/message/index.js +3 -0
- package/es/types.js +1 -0
- package/lib/BaseRadioButton.js +63 -103
- package/lib/Checkbox.js +72 -56
- package/lib/Input.js +32 -34
- package/lib/InputGroup.js +121 -119
- package/lib/InputTextLike.js +32 -27
- package/lib/Label.js +34 -35
- package/lib/PhoneNumber.js +79 -165
- package/lib/RadioBlock.js +65 -106
- package/lib/RadioButton.js +33 -29
- package/lib/RadioButtonInputGroup.js +51 -104
- package/lib/RadioSwitch.js +44 -73
- package/lib/TextArea.js +32 -24
- package/lib/ToggleSwitch.js +67 -106
- package/lib/Tooltip.js +59 -86
- package/lib/i18n/en.js +8 -12
- package/lib/i18n/i18n.js +12 -14
- package/lib/i18n/nb.js +8 -12
- package/lib/i18n/nn.js +8 -12
- package/lib/index.js +32 -117
- package/lib/message/BaseFieldMessage.js +56 -0
- package/lib/message/ErrorFieldMessage.js +35 -0
- package/lib/message/InfoFieldMessage.js +35 -0
- package/lib/message/SuccessFieldMessage.js +35 -0
- package/lib/message/index.js +9 -0
- package/lib/types.js +2 -0
- package/package.json +6 -5
- package/types/BaseRadioButton.d.ts +14 -0
- package/types/Checkbox.d.ts +13 -0
- package/types/Input.d.ts +8 -0
- package/types/InputGroup.d.ts +36 -0
- package/types/InputTextLike.d.ts +5 -0
- package/types/Label.d.ts +9 -0
- package/types/PhoneNumber.d.ts +40 -0
- package/types/RadioBlock.d.ts +18 -0
- package/types/RadioButton.d.ts +7 -0
- package/types/RadioButtonInputGroup.d.ts +48 -0
- package/types/RadioSwitch.d.ts +23 -0
- package/types/TextArea.d.ts +4 -0
- package/types/ToggleSwitch.d.ts +16 -0
- package/types/Tooltip.d.ts +6 -0
- package/types/i18n/en.d.ts +8 -0
- package/types/i18n/i18n.d.ts +24 -0
- package/types/i18n/nb.d.ts +8 -0
- package/types/i18n/nn.d.ts +8 -0
- package/types/index.d.ts +14 -212
- package/types/message/BaseFieldMessage.d.ts +11 -0
- package/types/message/ErrorFieldMessage.d.ts +6 -0
- package/types/message/InfoFieldMessage.d.ts +6 -0
- package/types/message/SuccessFieldMessage.d.ts +6 -0
- package/types/message/index.d.ts +3 -0
- package/types/types.d.ts +11 -0
- package/es/BaseFieldMessage.js +0 -67
- package/es/ErrorFieldMessage.js +0 -21
- package/es/InfoFieldMessage.js +0 -9
- package/es/SuccessFieldMessage.js +0 -9
- package/es/index.d.js +0 -5
- package/lib/BaseFieldMessage.js +0 -73
- package/lib/ErrorFieldMessage.js +0 -28
- package/lib/InfoFieldMessage.js +0 -16
- package/lib/SuccessFieldMessage.js +0 -16
- package/lib/index.d.js +0 -6
package/es/BaseRadioButton.js
CHANGED
|
@@ -1,97 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React, { useRef } from 'react';
|
|
20
24
|
import classNames from 'classnames';
|
|
21
|
-
import { bool, node, oneOfType, shape, string, func, object, number } from 'prop-types';
|
|
22
25
|
import { v4 as uuid } from 'uuid';
|
|
23
|
-
import Tooltip from './Tooltip';
|
|
24
|
-
var BaseRadioButton =
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_inherits(BaseRadioButton, _Component);
|
|
36
|
-
return _createClass(BaseRadioButton, [{
|
|
37
|
-
key: "render",
|
|
38
|
-
value: function render() {
|
|
39
|
-
var _this$props = this.props,
|
|
40
|
-
children = _this$props.children,
|
|
41
|
-
checked = _this$props.checked,
|
|
42
|
-
className = _this$props.className,
|
|
43
|
-
_this$props$labelProp = _this$props.labelProps,
|
|
44
|
-
labelProps = _this$props$labelProp === void 0 ? {} : _this$props$labelProp,
|
|
45
|
-
selectedValue = _this$props.selectedValue,
|
|
46
|
-
tooltip = _this$props.tooltip,
|
|
47
|
-
_this$props$tooltipPr = _this$props.tooltipProps,
|
|
48
|
-
tooltipProps = _this$props$tooltipPr === void 0 ? {} : _this$props$tooltipPr,
|
|
49
|
-
value = _this$props.value,
|
|
50
|
-
innerRef = _this$props.innerRef,
|
|
51
|
-
inputProps = _objectWithoutProperties(_this$props, _excluded);
|
|
52
|
-
var labelClasses = classNames({
|
|
53
|
-
'ffe-radio-button--with-tooltip': tooltip
|
|
54
|
-
}, className);
|
|
55
|
-
var isSelected = selectedValue !== undefined ? selectedValue === value : checked;
|
|
56
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("input", _extends({
|
|
57
|
-
className: "ffe-radio-input",
|
|
58
|
-
id: this.id,
|
|
59
|
-
ref: innerRef,
|
|
60
|
-
type: "radio",
|
|
61
|
-
checked: isSelected,
|
|
62
|
-
value: value
|
|
63
|
-
}, inputProps)), /*#__PURE__*/React.createElement("label", _extends({
|
|
64
|
-
htmlFor: this.id
|
|
65
|
-
}, labelProps, {
|
|
66
|
-
className: labelClasses
|
|
67
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
68
|
-
className: "ffe-radio-input__content"
|
|
69
|
-
}, children)), tooltip && /*#__PURE__*/React.createElement(Tooltip, tooltipProps, tooltip));
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
}(Component);
|
|
73
|
-
BaseRadioButton.propTypes = {
|
|
74
|
-
/** Whether or not the radio button is selected */
|
|
75
|
-
checked: bool,
|
|
76
|
-
/** The label of the radio button */
|
|
77
|
-
children: node.isRequired,
|
|
78
|
-
/** Additional class names applied to the label */
|
|
79
|
-
className: string,
|
|
80
|
-
/** Additional props passed to the label element */
|
|
81
|
-
labelProps: shape({}),
|
|
82
|
-
/** The name of the radio button */
|
|
83
|
-
name: string.isRequired,
|
|
84
|
-
/** The selected value of the radio button set */
|
|
85
|
-
selectedValue: oneOfType([bool, string, number]),
|
|
86
|
-
/** Tooltip providing further detail about the choice */
|
|
87
|
-
tooltip: string,
|
|
88
|
-
/** Additional props passed to the Tooltip component */
|
|
89
|
-
tooltipProps: shape({}),
|
|
90
|
-
/** The value of the radio button */
|
|
91
|
-
value: oneOfType([bool, string, number]).isRequired,
|
|
92
|
-
/** Ref-setting function, or ref created by useRef, passed to the input element */
|
|
93
|
-
innerRef: oneOfType([func, shape({
|
|
94
|
-
current: object
|
|
95
|
-
})])
|
|
96
|
-
};
|
|
97
|
-
export default BaseRadioButton;
|
|
26
|
+
import { Tooltip } from './Tooltip';
|
|
27
|
+
export var BaseRadioButton = React.forwardRef(function (_a, ref) {
|
|
28
|
+
var children = _a.children, checked = _a.checked, className = _a.className, labelProps = _a.labelProps, selectedValue = _a.selectedValue, tooltip = _a.tooltip, _b = _a.tooltipProps, tooltipProps = _b === void 0 ? {} : _b, value = _a.value, inputProps = __rest(_a, ["children", "checked", "className", "labelProps", "selectedValue", "tooltip", "tooltipProps", "value"]);
|
|
29
|
+
var id = useRef("base-radio-button-".concat(uuid())).current;
|
|
30
|
+
var labelClasses = classNames({ 'ffe-radio-button--with-tooltip': tooltip }, className);
|
|
31
|
+
var isSelected = selectedValue === undefined ? checked : selectedValue === value;
|
|
32
|
+
return (React.createElement(React.Fragment, null,
|
|
33
|
+
React.createElement("input", __assign({ className: "ffe-radio-input", id: id, ref: ref, type: "radio", checked: isSelected, value: "".concat(value) }, inputProps)),
|
|
34
|
+
React.createElement("label", __assign({ htmlFor: id }, labelProps, { className: labelClasses }),
|
|
35
|
+
React.createElement("span", { className: "ffe-radio-input__content" }, children)),
|
|
36
|
+
tooltip && React.createElement(Tooltip, __assign({}, tooltipProps), tooltip)));
|
|
37
|
+
});
|
package/es/Checkbox.js
CHANGED
|
@@ -1,52 +1,46 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React, { useRef } from 'react';
|
|
7
24
|
import { v4 as uuid } from 'uuid';
|
|
8
25
|
import classNames from 'classnames';
|
|
9
|
-
var Checkbox =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
className: "ffe-hidden-checkbox",
|
|
30
|
-
id: id,
|
|
31
|
-
type: "checkbox"
|
|
32
|
-
}, rest)), typeof children === 'function' ? children(labelProps) :
|
|
33
|
-
/*#__PURE__*/
|
|
34
|
-
// eslint-disable-next-line jsx-a11y/label-has-for
|
|
35
|
-
React.createElement("label", labelProps, /*#__PURE__*/React.createElement("span", {
|
|
36
|
-
className: classNames('ffe-checkbox__content', {
|
|
37
|
-
'ffe-screenreader-only': hiddenLabel
|
|
38
|
-
})
|
|
39
|
-
}, children)));
|
|
26
|
+
export var Checkbox = React.forwardRef(function (_a, ref) {
|
|
27
|
+
var children = _a.children, hiddenLabel = _a.hiddenLabel, _b = _a.inline, inline = _b === void 0 ? true : _b, noMargins = _a.noMargins, id = _a.id, rest = __rest(_a, ["children", "hiddenLabel", "inline", "noMargins", "id"]);
|
|
28
|
+
var generatedId = useRef(id !== null && id !== void 0 ? id : "checkbox-".concat(uuid())).current;
|
|
29
|
+
var labelProps = {
|
|
30
|
+
className: classNames({
|
|
31
|
+
'ffe-checkbox': true,
|
|
32
|
+
'ffe-checkbox--inline': inline,
|
|
33
|
+
'ffe-checkbox--no-margin': noMargins,
|
|
34
|
+
'ffe-checkbox--hidden-label': hiddenLabel,
|
|
35
|
+
}),
|
|
36
|
+
htmlFor: generatedId,
|
|
37
|
+
};
|
|
38
|
+
return (React.createElement(React.Fragment, null,
|
|
39
|
+
React.createElement("input", __assign({ ref: ref, className: "ffe-hidden-checkbox", id: generatedId, type: "checkbox" }, rest)),
|
|
40
|
+
typeof children === 'function' ? (children(labelProps)) : (
|
|
41
|
+
// eslint-disable-next-line jsx-a11y/label-has-for
|
|
42
|
+
React.createElement("label", __assign({}, labelProps),
|
|
43
|
+
React.createElement("span", { className: classNames('ffe-checkbox__content', {
|
|
44
|
+
'ffe-screenreader-only': hiddenLabel,
|
|
45
|
+
}) }, children)))));
|
|
40
46
|
});
|
|
41
|
-
Checkbox.propTypes = {
|
|
42
|
-
/** Removes vertical margins from the checkbox */
|
|
43
|
-
noMargins: bool,
|
|
44
|
-
/** If you plan to render the checkbox without a visible label */
|
|
45
|
-
hiddenLabel: bool,
|
|
46
|
-
/** Override the automatically generated ID */
|
|
47
|
-
id: string,
|
|
48
|
-
inline: bool,
|
|
49
|
-
/** The label for the checkbox */
|
|
50
|
-
children: oneOfType([node, func]).isRequired
|
|
51
|
-
};
|
|
52
|
-
export default Checkbox;
|
package/es/Input.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
5
23
|
import React from 'react';
|
|
6
|
-
import { bool, string } from 'prop-types';
|
|
7
24
|
import classNames from 'classnames';
|
|
8
|
-
var Input =
|
|
9
|
-
|
|
10
|
-
inline
|
|
11
|
-
textRightAlign = props.textRightAlign,
|
|
12
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
13
|
-
return /*#__PURE__*/React.createElement("input", _extends({
|
|
14
|
-
className: classNames('ffe-input-field', {
|
|
15
|
-
'ffe-input-field--inline': inline
|
|
16
|
-
}, {
|
|
17
|
-
'ffe-input-field--text-right-align': textRightAlign
|
|
18
|
-
}, className),
|
|
19
|
-
ref: ref
|
|
20
|
-
}, rest));
|
|
25
|
+
export var Input = React.forwardRef(function (_a, ref) {
|
|
26
|
+
var className = _a.className, inline = _a.inline, textRightAlign = _a.textRightAlign, rest = __rest(_a, ["className", "inline", "textRightAlign"]);
|
|
27
|
+
return (React.createElement("input", __assign({ className: classNames('ffe-input-field', { 'ffe-input-field--inline': inline }, { 'ffe-input-field--text-right-align': textRightAlign }, className), ref: ref }, rest)));
|
|
21
28
|
});
|
|
22
|
-
Input.propTypes = {
|
|
23
|
-
className: string,
|
|
24
|
-
/** Input fields default to `display: block;`. Set this to `true` to apply the inline modifier. */
|
|
25
|
-
inline: bool,
|
|
26
|
-
/** Make the text right aligned */
|
|
27
|
-
textRightAlign: bool
|
|
28
|
-
};
|
|
29
|
-
export default Input;
|
package/es/InputGroup.js
CHANGED
|
@@ -1,114 +1,96 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React, { useRef } from 'react';
|
|
13
24
|
import { v4 as uuid } from 'uuid';
|
|
14
|
-
import Tooltip from './Tooltip';
|
|
15
|
-
import Label from './Label';
|
|
25
|
+
import { Tooltip } from './Tooltip';
|
|
26
|
+
import { Label } from './Label';
|
|
16
27
|
import classNames from 'classnames';
|
|
17
|
-
import ErrorFieldMessage from './
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
description = _ref.description,
|
|
25
|
-
label = _ref.label,
|
|
26
|
-
fieldMessage = _ref.fieldMessage,
|
|
27
|
-
tooltip = _ref.tooltip,
|
|
28
|
-
onTooltipToggle = _ref.onTooltipToggle,
|
|
29
|
-
labelId = _ref.labelId,
|
|
30
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
-
var _useState = useState(inputId ? inputId : "input-".concat(uuid())),
|
|
32
|
-
_useState2 = _slicedToArray(_useState, 1),
|
|
33
|
-
id = _useState2[0];
|
|
34
|
-
var descriptionId = description ? "".concat(id, "-description") : undefined;
|
|
35
|
-
var fieldMessageReturn = typeof fieldMessage === 'function' ? fieldMessage("".concat(id, "-fieldmessage")) : null;
|
|
36
|
-
if (React.Children.count(children) > 1) {
|
|
37
|
-
throw new Error('This element does not support more than one child. If you need more than one element inside your ' + 'InputGroup, please use the function-as-a-child pattern outlined in the documentation.');
|
|
38
|
-
}
|
|
39
|
-
var getFieldMessageId = function getFieldMessageId() {
|
|
40
|
-
var _fieldMessage$props;
|
|
41
|
-
if (fieldMessage !== null && fieldMessage !== void 0 && (_fieldMessage$props = fieldMessage.props) !== null && _fieldMessage$props !== void 0 && _fieldMessage$props.id) {
|
|
42
|
-
return fieldMessage.props.id;
|
|
43
|
-
} else if (typeof fieldMessage === 'string' || fieldMessageReturn) {
|
|
44
|
-
return "".concat(id, "-fieldmessage");
|
|
28
|
+
import { ErrorFieldMessage } from './message';
|
|
29
|
+
var getChildrenWithExtraProps = function (children, extraProps) {
|
|
30
|
+
if (typeof children === 'function') {
|
|
31
|
+
return children(extraProps);
|
|
32
|
+
}
|
|
33
|
+
else if (React.isValidElement(children)) {
|
|
34
|
+
return React.cloneElement(children, extraProps);
|
|
45
35
|
}
|
|
46
|
-
|
|
47
|
-
var fieldMessageId = getFieldMessageId();
|
|
48
|
-
if (onTooltipToggle && typeof tooltip !== 'boolean' && typeof tooltip !== 'string') {
|
|
49
|
-
throw new Error('Only use the "onTooltipToggle" prop if you\'re not sending a component of type ' + '<Tooltip /> in the "tooltip" prop. If you are, use "onClick" on that component instead');
|
|
50
|
-
}
|
|
51
|
-
if (tooltip && description) {
|
|
52
|
-
throw new Error('Don\'t use both "tooltip" and "description" on an <InputGroup />, pick one of them');
|
|
53
|
-
}
|
|
54
|
-
var isInvalid = !!fieldMessage && (typeof fieldMessage === 'string' || fieldMessage.type === ErrorFieldMessage || !!fieldMessageReturn);
|
|
55
|
-
var hasMessage = !!fieldMessage;
|
|
56
|
-
var ariaDescribedBy = "".concat(fieldMessageId || '', " ").concat(descriptionId || '').trim() || undefined;
|
|
57
|
-
var extraProps = {
|
|
58
|
-
id: id,
|
|
59
|
-
'aria-invalid': String(isInvalid),
|
|
60
|
-
'aria-describedby': ariaDescribedBy
|
|
61
|
-
};
|
|
62
|
-
var modifiedChildren = typeof children === 'function' ? children(extraProps) : /*#__PURE__*/React.cloneElement(children, extraProps);
|
|
63
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
|
64
|
-
className: classNames('ffe-input-group', {
|
|
65
|
-
'ffe-input-group--no-extra-margin': !extraMargin
|
|
66
|
-
}, {
|
|
67
|
-
'ffe-input-group--message': hasMessage
|
|
68
|
-
}, className)
|
|
69
|
-
}, rest), typeof label === 'string' && /*#__PURE__*/React.createElement(Label, {
|
|
70
|
-
htmlFor: id,
|
|
71
|
-
id: labelId
|
|
72
|
-
}, label), /*#__PURE__*/React.isValidElement(label) && /*#__PURE__*/React.cloneElement(label, {
|
|
73
|
-
htmlFor: id,
|
|
74
|
-
id: labelId
|
|
75
|
-
}), typeof tooltip === 'string' && /*#__PURE__*/React.createElement(Tooltip, {
|
|
76
|
-
onClick: onTooltipToggle
|
|
77
|
-
}, tooltip), tooltip === true && /*#__PURE__*/React.createElement(Tooltip, {
|
|
78
|
-
onClick: onTooltipToggle
|
|
79
|
-
}), /*#__PURE__*/React.isValidElement(tooltip) && tooltip, description && /*#__PURE__*/React.createElement("div", {
|
|
80
|
-
className: "ffe-small-text ffe-input-group__description",
|
|
81
|
-
id: descriptionId
|
|
82
|
-
}, description), modifiedChildren, /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
className: "ffe-input-group__field-message"
|
|
84
|
-
}, typeof fieldMessage === 'string' && /*#__PURE__*/React.createElement(ErrorFieldMessage, {
|
|
85
|
-
element: "p",
|
|
86
|
-
id: fieldMessageId
|
|
87
|
-
}, fieldMessage), /*#__PURE__*/React.isValidElement(fieldMessage) && /*#__PURE__*/React.cloneElement(fieldMessage, {
|
|
88
|
-
id: fieldMessageId
|
|
89
|
-
}), fieldMessageReturn));
|
|
36
|
+
return children;
|
|
90
37
|
};
|
|
91
|
-
InputGroup
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
38
|
+
export var InputGroup = function (_a) {
|
|
39
|
+
var inputId = _a.inputId, children = _a.children, className = _a.className, _b = _a.extraMargin, extraMargin = _b === void 0 ? true : _b, description = _a.description, label = _a.label, fieldMessage = _a.fieldMessage, tooltip = _a.tooltip, onTooltipToggle = _a.onTooltipToggle, labelId = _a.labelId, rest = __rest(_a, ["inputId", "children", "className", "extraMargin", "description", "label", "fieldMessage", "tooltip", "onTooltipToggle", "labelId"]);
|
|
40
|
+
var id = useRef(inputId ? inputId : "input-".concat(uuid())).current;
|
|
41
|
+
var descriptionId = description ? "".concat(id, "-description") : undefined;
|
|
42
|
+
if (React.Children.count(children) > 1) {
|
|
43
|
+
throw new Error('This element does not support more than one child. If you need more than one element inside your ' +
|
|
44
|
+
'InputGroup, please use the function-as-a-child pattern outlined in the documentation.');
|
|
45
|
+
}
|
|
46
|
+
var getFieldMessageId = function () {
|
|
47
|
+
var _a;
|
|
48
|
+
if (typeof fieldMessage === 'string') {
|
|
49
|
+
return "".concat(id, "-fieldmessage");
|
|
50
|
+
}
|
|
51
|
+
else if ((_a = fieldMessage === null || fieldMessage === void 0 ? void 0 : fieldMessage.props) === null || _a === void 0 ? void 0 : _a.id) {
|
|
52
|
+
return fieldMessage.props.id;
|
|
53
|
+
}
|
|
54
|
+
return fieldMessage ? "".concat(id, "-fieldmessage") : undefined;
|
|
55
|
+
};
|
|
56
|
+
var fieldMessageId = getFieldMessageId();
|
|
57
|
+
if (onTooltipToggle &&
|
|
58
|
+
typeof tooltip !== 'boolean' &&
|
|
59
|
+
typeof tooltip !== 'string') {
|
|
60
|
+
throw new Error('Only use the "onTooltipToggle" prop if you\'re not sending a component of type ' +
|
|
61
|
+
'<Tooltip /> in the "tooltip" prop. If you are, use "onClick" on that component instead');
|
|
62
|
+
}
|
|
63
|
+
if (tooltip && description) {
|
|
64
|
+
throw new Error('Don\'t use both "tooltip" and "description" on an <InputGroup />, pick one of them');
|
|
65
|
+
}
|
|
66
|
+
var isInvalid = !!fieldMessage &&
|
|
67
|
+
(typeof fieldMessage === 'string' ||
|
|
68
|
+
fieldMessage.type === ErrorFieldMessage);
|
|
69
|
+
var hasMessage = !!fieldMessage;
|
|
70
|
+
var ariaDescribedBy = fieldMessageId || descriptionId
|
|
71
|
+
? [fieldMessageId, descriptionId].filter(Boolean).join(' ')
|
|
72
|
+
: undefined;
|
|
73
|
+
var extraProps = {
|
|
74
|
+
id: id,
|
|
75
|
+
'aria-invalid': isInvalid ? 'true' : 'false',
|
|
76
|
+
'aria-describedby': ariaDescribedBy,
|
|
77
|
+
};
|
|
78
|
+
var modifiedChildren = getChildrenWithExtraProps(children, extraProps);
|
|
79
|
+
return (React.createElement("div", __assign({ className: classNames('ffe-input-group', { 'ffe-input-group--no-extra-margin': !extraMargin }, { 'ffe-input-group--message': hasMessage }, className) }, rest),
|
|
80
|
+
typeof label === 'string' ? (React.createElement(Label, { htmlFor: id, id: labelId }, label)) : (React.isValidElement(label) &&
|
|
81
|
+
React.cloneElement(label, {
|
|
82
|
+
htmlFor: id,
|
|
83
|
+
id: labelId,
|
|
84
|
+
})),
|
|
85
|
+
typeof tooltip === 'string' && (React.createElement(Tooltip, { onClick: onTooltipToggle }, tooltip)),
|
|
86
|
+
tooltip === true && React.createElement(Tooltip, { onClick: onTooltipToggle }),
|
|
87
|
+
React.isValidElement(tooltip) && tooltip,
|
|
88
|
+
description && (React.createElement("div", { className: "ffe-small-text ffe-input-group__description", id: descriptionId }, description)),
|
|
89
|
+
modifiedChildren,
|
|
90
|
+
React.createElement("div", { className: "ffe-input-group__field-message" },
|
|
91
|
+
typeof fieldMessage === 'string' && (React.createElement(ErrorFieldMessage, { as: "p", id: fieldMessageId }, fieldMessage)),
|
|
92
|
+
React.isValidElement(fieldMessage) &&
|
|
93
|
+
React.cloneElement(fieldMessage, {
|
|
94
|
+
id: fieldMessageId,
|
|
95
|
+
}))));
|
|
113
96
|
};
|
|
114
|
-
export default InputGroup;
|
package/es/InputTextLike.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
5
23
|
import React from 'react';
|
|
6
|
-
import { string } from 'prop-types';
|
|
7
24
|
import classNames from 'classnames';
|
|
8
|
-
var InputTextLike =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
12
|
-
return /*#__PURE__*/React.createElement("input", _extends({
|
|
13
|
-
className: classNames('ffe-input-field', 'ffe-input-field--text-like', className),
|
|
14
|
-
"aria-label": ariaLabel,
|
|
15
|
-
ref: ref
|
|
16
|
-
}, rest));
|
|
25
|
+
export var InputTextLike = React.forwardRef(function (_a, ref) {
|
|
26
|
+
var className = _a.className, ariaLabel = _a.ariaLabel, rest = __rest(_a, ["className", "ariaLabel"]);
|
|
27
|
+
return (React.createElement("input", __assign({ className: classNames('ffe-input-field', 'ffe-input-field--text-like', className), "aria-label": ariaLabel, ref: ref }, rest)));
|
|
17
28
|
});
|
|
18
|
-
InputTextLike.propTypes = {
|
|
19
|
-
ariaLabel: string.isRequired,
|
|
20
|
-
className: string
|
|
21
|
-
};
|
|
22
|
-
export default InputTextLike;
|
package/es/Label.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
5
23
|
import React from 'react';
|
|
6
|
-
import { bool, node, string } from 'prop-types';
|
|
7
24
|
import classNames from 'classnames';
|
|
8
|
-
var Label = function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
-
return /*#__PURE__*/React.createElement("label", _extends({
|
|
15
|
-
className: classNames('ffe-form-label', className, {
|
|
16
|
-
'ffe-form-label--block': block
|
|
17
|
-
}),
|
|
18
|
-
htmlFor: htmlFor
|
|
19
|
-
}, rest), children);
|
|
20
|
-
};
|
|
21
|
-
Label.propTypes = {
|
|
22
|
-
/**
|
|
23
|
-
* Labels default to `display: inline-block;` to have tooltips appear immediately to the right.
|
|
24
|
-
* Set this to `true` if you don't use tooltips and need the label to be `display: block;`.
|
|
25
|
-
*/
|
|
26
|
-
block: bool,
|
|
27
|
-
children: node.isRequired,
|
|
28
|
-
className: string,
|
|
29
|
-
htmlFor: string
|
|
25
|
+
export var Label = function (_a) {
|
|
26
|
+
var block = _a.block, children = _a.children, className = _a.className, htmlFor = _a.htmlFor, rest = __rest(_a, ["block", "children", "className", "htmlFor"]);
|
|
27
|
+
return (React.createElement("label", __assign({ className: classNames('ffe-form-label', className, {
|
|
28
|
+
'ffe-form-label--block': block,
|
|
29
|
+
}), htmlFor: htmlFor }, rest), children));
|
|
30
30
|
};
|
|
31
|
-
export default Label;
|