@sb1/ffe-form-react 10.0.0 → 10.0.2
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/BaseFieldMessage.js +5 -11
- package/es/BaseRadioButton.js +10 -47
- package/es/Checkbox.js +4 -12
- package/es/ErrorFieldMessage.js +0 -3
- package/es/InfoFieldMessage.js +0 -3
- package/es/Input.js +4 -12
- package/es/InputGroup.js +13 -41
- package/es/Label.js +4 -11
- package/es/PhoneNumber.js +14 -50
- package/es/RadioBlock.js +11 -48
- package/es/RadioButton.js +2 -10
- package/es/RadioButtonInputGroup.js +11 -35
- package/es/RadioSwitch.js +9 -25
- package/es/SuccessFieldMessage.js +0 -3
- package/es/TextArea.js +1 -6
- package/es/ToggleSwitch.js +8 -44
- package/es/Tooltip.js +7 -38
- package/lib/BaseFieldMessage.js +4 -15
- package/lib/BaseRadioButton.js +10 -55
- package/lib/Checkbox.js +4 -22
- package/lib/ErrorFieldMessage.js +0 -6
- package/lib/InfoFieldMessage.js +0 -6
- package/lib/Input.js +4 -18
- package/lib/InputGroup.js +13 -52
- package/lib/Label.js +4 -15
- package/lib/PhoneNumber.js +14 -57
- package/lib/RadioBlock.js +11 -55
- package/lib/RadioButton.js +2 -15
- package/lib/RadioButtonInputGroup.js +11 -41
- package/lib/RadioSwitch.js +9 -33
- package/lib/SuccessFieldMessage.js +0 -6
- package/lib/TextArea.js +1 -12
- package/lib/ToggleSwitch.js +8 -50
- package/lib/Tooltip.js +7 -44
- package/lib/i18n/i18n.js +0 -5
- package/lib/index.js +0 -16
- package/package.json +47 -47
package/es/BaseFieldMessage.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
var _excluded = ["children", "className", "element", "type"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
-
|
|
7
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
5
|
import React from 'react';
|
|
10
6
|
import { node, string, oneOf } from 'prop-types';
|
|
11
7
|
import classNames from 'classnames';
|
|
8
|
+
|
|
12
9
|
/**
|
|
13
10
|
* Internal factory component
|
|
14
11
|
* @ignore
|
|
15
12
|
*/
|
|
16
|
-
|
|
17
13
|
var BaseFieldMessage = function BaseFieldMessage(props) {
|
|
18
14
|
var children = props.children,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
className = props.className,
|
|
16
|
+
Element = props.element,
|
|
17
|
+
type = props.type,
|
|
18
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
24
19
|
return /*#__PURE__*/React.createElement(Element, _extends({
|
|
25
20
|
className: classNames("ffe-field-".concat(type, "-message"), className)
|
|
26
21
|
}, rest), children);
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
BaseFieldMessage.defaultProps = {
|
|
30
24
|
element: 'div'
|
|
31
25
|
};
|
package/es/BaseRadioButton.js
CHANGED
|
@@ -1,77 +1,51 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
|
|
3
2
|
var _excluded = ["children", "checked", "className", "labelProps", "selectedValue", "tooltip", "tooltipProps", "value", "innerRef"];
|
|
4
|
-
|
|
5
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
|
-
|
|
7
4
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
-
|
|
9
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
-
|
|
11
6
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
-
|
|
13
7
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
14
|
-
|
|
15
8
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
-
|
|
17
9
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
|
-
|
|
19
10
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
-
|
|
21
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
22
|
-
|
|
23
12
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
-
|
|
25
13
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
-
|
|
27
14
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
-
|
|
29
15
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
-
|
|
31
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
|
-
|
|
33
17
|
import React, { Component, Fragment } from 'react';
|
|
34
18
|
import classNames from 'classnames';
|
|
35
19
|
import { bool, node, oneOfType, shape, string, func, object, number } from 'prop-types';
|
|
36
20
|
import { v4 as uuid } from 'uuid';
|
|
37
21
|
import Tooltip from './Tooltip';
|
|
38
|
-
|
|
39
22
|
var BaseRadioButton = /*#__PURE__*/function (_Component) {
|
|
40
23
|
_inherits(BaseRadioButton, _Component);
|
|
41
|
-
|
|
42
24
|
var _super = _createSuper(BaseRadioButton);
|
|
43
|
-
|
|
44
25
|
function BaseRadioButton() {
|
|
45
26
|
var _this;
|
|
46
|
-
|
|
47
27
|
_classCallCheck(this, BaseRadioButton);
|
|
48
|
-
|
|
49
28
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
50
29
|
args[_key] = arguments[_key];
|
|
51
30
|
}
|
|
52
|
-
|
|
53
31
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
54
|
-
|
|
55
32
|
_defineProperty(_assertThisInitialized(_this), "id", "base-radio-button-".concat(uuid()));
|
|
56
|
-
|
|
57
33
|
return _this;
|
|
58
34
|
}
|
|
59
|
-
|
|
60
35
|
_createClass(BaseRadioButton, [{
|
|
61
36
|
key: "render",
|
|
62
37
|
value: function render() {
|
|
63
38
|
var _this$props = this.props,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
39
|
+
children = _this$props.children,
|
|
40
|
+
checked = _this$props.checked,
|
|
41
|
+
className = _this$props.className,
|
|
42
|
+
labelProps = _this$props.labelProps,
|
|
43
|
+
selectedValue = _this$props.selectedValue,
|
|
44
|
+
tooltip = _this$props.tooltip,
|
|
45
|
+
tooltipProps = _this$props.tooltipProps,
|
|
46
|
+
value = _this$props.value,
|
|
47
|
+
innerRef = _this$props.innerRef,
|
|
48
|
+
inputProps = _objectWithoutProperties(_this$props, _excluded);
|
|
75
49
|
var labelClasses = classNames({
|
|
76
50
|
'ffe-radio-button--with-tooltip': tooltip
|
|
77
51
|
}, className);
|
|
@@ -90,10 +64,8 @@ var BaseRadioButton = /*#__PURE__*/function (_Component) {
|
|
|
90
64
|
}), children), tooltip && /*#__PURE__*/React.createElement(Tooltip, tooltipProps, tooltip));
|
|
91
65
|
}
|
|
92
66
|
}]);
|
|
93
|
-
|
|
94
67
|
return BaseRadioButton;
|
|
95
68
|
}(Component);
|
|
96
|
-
|
|
97
69
|
BaseRadioButton.defaultProps = {
|
|
98
70
|
labelProps: {},
|
|
99
71
|
tooltipProps: {}
|
|
@@ -101,31 +73,22 @@ BaseRadioButton.defaultProps = {
|
|
|
101
73
|
BaseRadioButton.propTypes = {
|
|
102
74
|
/** Whether or not the radio button is selected */
|
|
103
75
|
checked: bool,
|
|
104
|
-
|
|
105
76
|
/** The label of the radio button */
|
|
106
77
|
children: node.isRequired,
|
|
107
|
-
|
|
108
78
|
/** Additional class names applied to the label */
|
|
109
79
|
className: string,
|
|
110
|
-
|
|
111
80
|
/** Additional props passed to the label element */
|
|
112
81
|
labelProps: shape({}),
|
|
113
|
-
|
|
114
82
|
/** The name of the radio button */
|
|
115
83
|
name: string.isRequired,
|
|
116
|
-
|
|
117
84
|
/** The selected value of the radio button set */
|
|
118
85
|
selectedValue: oneOfType([bool, string, number]),
|
|
119
|
-
|
|
120
86
|
/** Tooltip providing further detail about the choice */
|
|
121
87
|
tooltip: string,
|
|
122
|
-
|
|
123
88
|
/** Additional props passed to the Tooltip component */
|
|
124
89
|
tooltipProps: shape({}),
|
|
125
|
-
|
|
126
90
|
/** The value of the radio button */
|
|
127
91
|
value: oneOfType([bool, string, number]).isRequired,
|
|
128
|
-
|
|
129
92
|
/** Ref-setting function, or ref created by useRef, passed to the input element */
|
|
130
93
|
innerRef: oneOfType([func, shape({
|
|
131
94
|
current: object
|
package/es/Checkbox.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
var _excluded = ["children", "hiddenLabel", "inline", "noMargins"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
-
|
|
7
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
5
|
import React, { Fragment } from 'react';
|
|
10
6
|
import { bool, node, string, func, oneOfType } from 'prop-types';
|
|
11
7
|
import { v4 as hash } from 'uuid';
|
|
12
8
|
import classNames from 'classnames';
|
|
13
9
|
var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
14
10
|
var children = props.children,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
hiddenLabel = props.hiddenLabel,
|
|
12
|
+
inline = props.inline,
|
|
13
|
+
noMargins = props.noMargins,
|
|
14
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
20
15
|
var id = props.id || "checkbox-".concat(hash());
|
|
21
16
|
var labelProps = {
|
|
22
17
|
className: classNames({
|
|
@@ -40,14 +35,11 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
40
35
|
Checkbox.propTypes = {
|
|
41
36
|
/** Removes vertical margins from the checkbox */
|
|
42
37
|
noMargins: bool,
|
|
43
|
-
|
|
44
38
|
/** If you plan to render the checkbox without a visible label */
|
|
45
39
|
hiddenLabel: bool,
|
|
46
|
-
|
|
47
40
|
/** Override the automatically generated ID */
|
|
48
41
|
id: string,
|
|
49
42
|
inline: bool,
|
|
50
|
-
|
|
51
43
|
/** The label for the checkbox */
|
|
52
44
|
children: oneOfType([node, func])
|
|
53
45
|
};
|
package/es/ErrorFieldMessage.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import BaseFieldMessage from './BaseFieldMessage';
|
|
5
|
-
|
|
6
4
|
var ErrorFieldMessage = function ErrorFieldMessage(props) {
|
|
7
5
|
return /*#__PURE__*/React.createElement(BaseFieldMessage, _extends({}, props, {
|
|
8
6
|
type: "error",
|
|
9
7
|
role: "alert"
|
|
10
8
|
}));
|
|
11
9
|
};
|
|
12
|
-
|
|
13
10
|
export default ErrorFieldMessage;
|
package/es/InfoFieldMessage.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import BaseFieldMessage from './BaseFieldMessage';
|
|
5
|
-
|
|
6
4
|
var InfoFieldMessage = function InfoFieldMessage(props) {
|
|
7
5
|
return /*#__PURE__*/React.createElement(BaseFieldMessage, _extends({}, props, {
|
|
8
6
|
type: "info"
|
|
9
7
|
}));
|
|
10
8
|
};
|
|
11
|
-
|
|
12
9
|
export default InfoFieldMessage;
|
package/es/Input.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
var _excluded = ["className", "inline", "textLike", "textRightAlign"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
-
|
|
7
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
5
|
import React from 'react';
|
|
10
6
|
import { bool, string } from 'prop-types';
|
|
11
7
|
import classNames from 'classnames';
|
|
12
8
|
var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
13
9
|
var className = props.className,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
inline = props.inline,
|
|
11
|
+
textLike = props.textLike,
|
|
12
|
+
textRightAlign = props.textRightAlign,
|
|
13
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
19
14
|
return /*#__PURE__*/React.createElement("input", _extends({
|
|
20
15
|
className: classNames('ffe-input-field', {
|
|
21
16
|
'ffe-input-field--inline': inline
|
|
@@ -29,13 +24,10 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
29
24
|
});
|
|
30
25
|
Input.propTypes = {
|
|
31
26
|
className: string,
|
|
32
|
-
|
|
33
27
|
/** Input fields default to `display: block;`. Set this to `true` to apply the inline modifier. */
|
|
34
28
|
inline: bool,
|
|
35
|
-
|
|
36
29
|
/** Apply the text-like modifier by setting this to `true`. */
|
|
37
30
|
textLike: bool,
|
|
38
|
-
|
|
39
31
|
/** Make the text right aligned */
|
|
40
32
|
textRightAlign: bool
|
|
41
33
|
};
|
package/es/InputGroup.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
var _excluded = ["inputId", "children", "className", "extraMargin", "description", "label", "fieldMessage", "tooltip", "onTooltipToggle", "labelId"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
|
|
7
4
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
|
|
9
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
|
|
11
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
-
|
|
13
7
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14
|
-
|
|
15
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
|
|
17
9
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
-
|
|
19
10
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
-
|
|
21
11
|
import React, { useState } from 'react';
|
|
22
12
|
import { bool, func, node, oneOfType, string } from 'prop-types';
|
|
23
13
|
import { v4 as uuid } from 'uuid';
|
|
@@ -25,52 +15,42 @@ import Tooltip from './Tooltip';
|
|
|
25
15
|
import Label from './Label';
|
|
26
16
|
import classNames from 'classnames';
|
|
27
17
|
import ErrorFieldMessage from './ErrorFieldMessage';
|
|
28
|
-
|
|
29
18
|
var InputGroup = function InputGroup(_ref) {
|
|
30
19
|
var inputId = _ref.inputId,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
children = _ref.children,
|
|
21
|
+
className = _ref.className,
|
|
22
|
+
_ref$extraMargin = _ref.extraMargin,
|
|
23
|
+
extraMargin = _ref$extraMargin === void 0 ? true : _ref$extraMargin,
|
|
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);
|
|
43
31
|
var _useState = useState(inputId ? inputId : "input-".concat(uuid())),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
33
|
+
id = _useState2[0];
|
|
47
34
|
var descriptionId = description ? "".concat(id, "-description") : undefined;
|
|
48
35
|
var fieldMessageReturn = typeof fieldMessage === 'function' ? fieldMessage("".concat(id, "-fieldmessage")) : null;
|
|
49
|
-
|
|
50
36
|
if (React.Children.count(children) > 1) {
|
|
51
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.');
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
var getFieldMessageId = function getFieldMessageId() {
|
|
55
40
|
var _fieldMessage$props;
|
|
56
|
-
|
|
57
41
|
if (fieldMessage !== null && fieldMessage !== void 0 && (_fieldMessage$props = fieldMessage.props) !== null && _fieldMessage$props !== void 0 && _fieldMessage$props.id) {
|
|
58
42
|
return fieldMessage.props.id;
|
|
59
43
|
} else if (typeof fieldMessage === 'string' || fieldMessageReturn) {
|
|
60
44
|
return "".concat(id, "-fieldmessage");
|
|
61
45
|
}
|
|
62
46
|
};
|
|
63
|
-
|
|
64
47
|
var fieldMessageId = getFieldMessageId();
|
|
65
|
-
|
|
66
48
|
if (onTooltipToggle && typeof tooltip !== 'boolean' && typeof tooltip !== 'string') {
|
|
67
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');
|
|
68
50
|
}
|
|
69
|
-
|
|
70
51
|
if (tooltip && description) {
|
|
71
52
|
throw new Error('Don\'t use both "tooltip" and "description" on an <InputGroup />, pick one of them');
|
|
72
53
|
}
|
|
73
|
-
|
|
74
54
|
var isInvalid = !!fieldMessage && (typeof fieldMessage === 'string' || fieldMessage.type === ErrorFieldMessage || !!fieldMessageReturn);
|
|
75
55
|
var hasMessage = !!fieldMessage;
|
|
76
56
|
var ariaDescribedBy = "".concat(fieldMessageId || '', " ").concat(descriptionId || '').trim() || undefined;
|
|
@@ -106,34 +86,26 @@ var InputGroup = function InputGroup(_ref) {
|
|
|
106
86
|
id: fieldMessageId
|
|
107
87
|
}), fieldMessageReturn);
|
|
108
88
|
};
|
|
109
|
-
|
|
110
89
|
InputGroup.propTypes = {
|
|
111
90
|
/** The id that will be used on the input child if you don't want a generated one */
|
|
112
91
|
inputId: string,
|
|
113
|
-
|
|
114
92
|
/** The id used on the label in this component. Could be necessary if your component needs a aria-labelledby. */
|
|
115
93
|
labelId: string,
|
|
116
|
-
|
|
117
94
|
/** Unless you only have one element in your `InputGroup` you will have to use the function-as-a-child pattern. */
|
|
118
95
|
children: oneOfType([func, node]).isRequired,
|
|
119
96
|
className: string,
|
|
120
|
-
|
|
121
97
|
/** Reserve space for showing `fieldMessage`s so content below don't move
|
|
122
98
|
* vertically if an errormessage shows up. Note that this will only reserve
|
|
123
99
|
* space for one line of content, so keep messages short.
|
|
124
100
|
*/
|
|
125
101
|
extraMargin: bool,
|
|
126
|
-
|
|
127
102
|
/** Use the ErrorFieldMessage component if you need more flexibility in how the content is rendered. */
|
|
128
103
|
fieldMessage: oneOfType([string, node, func]),
|
|
129
|
-
|
|
130
104
|
/** To just render a static, always visible tooltip, use this. */
|
|
131
105
|
description: string,
|
|
132
|
-
|
|
133
106
|
/** Use the Label component if you need more flexibility in how the content is rendered. */
|
|
134
107
|
label: oneOfType([node, string]),
|
|
135
108
|
onTooltipToggle: func,
|
|
136
|
-
|
|
137
109
|
/** Use the Tooltip component if you need more flexibility in how the content is rendered. */
|
|
138
110
|
tooltip: oneOfType([bool, node])
|
|
139
111
|
};
|
package/es/Label.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
var _excluded = ["block", "children", "className", "htmlFor"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
-
|
|
7
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
5
|
import React from 'react';
|
|
10
6
|
import { bool, node, string } from 'prop-types';
|
|
11
7
|
import classNames from 'classnames';
|
|
12
|
-
|
|
13
8
|
var Label = function Label(_ref) {
|
|
14
9
|
var block = _ref.block,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
children = _ref.children,
|
|
11
|
+
className = _ref.className,
|
|
12
|
+
htmlFor = _ref.htmlFor,
|
|
13
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
14
|
return /*#__PURE__*/React.createElement("label", _extends({
|
|
21
15
|
className: classNames('ffe-form-label', className, {
|
|
22
16
|
'ffe-form-label--block': block
|
|
@@ -24,7 +18,6 @@ var Label = function Label(_ref) {
|
|
|
24
18
|
htmlFor: htmlFor
|
|
25
19
|
}, rest), children);
|
|
26
20
|
};
|
|
27
|
-
|
|
28
21
|
Label.propTypes = {
|
|
29
22
|
/**
|
|
30
23
|
* Labels default to `display: inline-block;` to have tooltips appear immediately to the right.
|
package/es/PhoneNumber.js
CHANGED
|
@@ -1,81 +1,56 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
|
|
3
2
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
|
-
|
|
7
4
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
-
|
|
9
5
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
-
|
|
11
6
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
7
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
8
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
9
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
11
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
|
|
25
13
|
import React from 'react';
|
|
26
14
|
import { string, bool, func, oneOfType, object, shape, node } from 'prop-types';
|
|
27
15
|
import { v4 as uuid } from 'uuid';
|
|
28
16
|
import classNames from 'classnames';
|
|
29
17
|
import i18n from './i18n/i18n';
|
|
30
18
|
import ErrorFieldMessage from './ErrorFieldMessage';
|
|
31
|
-
|
|
32
19
|
var PhoneNumber = /*#__PURE__*/function (_React$Component) {
|
|
33
20
|
_inherits(PhoneNumber, _React$Component);
|
|
34
|
-
|
|
35
21
|
var _super = _createSuper(PhoneNumber);
|
|
36
|
-
|
|
37
22
|
function PhoneNumber() {
|
|
38
23
|
var _this;
|
|
39
|
-
|
|
40
24
|
_classCallCheck(this, PhoneNumber);
|
|
41
|
-
|
|
42
25
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
26
|
args[_key] = arguments[_key];
|
|
44
27
|
}
|
|
45
|
-
|
|
46
28
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
47
|
-
|
|
48
29
|
_defineProperty(_assertThisInitialized(_this), "numberId", uuid());
|
|
49
|
-
|
|
50
30
|
_defineProperty(_assertThisInitialized(_this), "countryCodeId", uuid());
|
|
51
|
-
|
|
52
31
|
_defineProperty(_assertThisInitialized(_this), "fieldMessageId", "input-".concat(uuid(), "-fieldmessage"));
|
|
53
|
-
|
|
54
32
|
return _this;
|
|
55
33
|
}
|
|
56
|
-
|
|
57
34
|
_createClass(PhoneNumber, [{
|
|
58
35
|
key: "render",
|
|
59
36
|
value: function render() {
|
|
60
37
|
var _fieldMessage, _fieldMessage$props;
|
|
61
|
-
|
|
62
38
|
var _this$props = this.props,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
39
|
+
number = _this$props.number,
|
|
40
|
+
countryCode = _this$props.countryCode,
|
|
41
|
+
onCountryCodeChange = _this$props.onCountryCodeChange,
|
|
42
|
+
onNumberChange = _this$props.onNumberChange,
|
|
43
|
+
onCountryCodeBlur = _this$props.onCountryCodeBlur,
|
|
44
|
+
onNumberBlur = _this$props.onNumberBlur,
|
|
45
|
+
disabled = _this$props.disabled,
|
|
46
|
+
countryCodeFieldMessage = _this$props.countryCodeFieldMessage,
|
|
47
|
+
numberFieldMessage = _this$props.numberFieldMessage,
|
|
48
|
+
countryCodeAndNumberFieldMessage = _this$props.countryCodeAndNumberFieldMessage,
|
|
49
|
+
className = _this$props.className,
|
|
50
|
+
extraMargin = _this$props.extraMargin,
|
|
51
|
+
countryCodeRef = _this$props.countryCodeRef,
|
|
52
|
+
numberRef = _this$props.numberRef;
|
|
77
53
|
var fieldMessage;
|
|
78
|
-
|
|
79
54
|
if (countryCodeAndNumberFieldMessage) {
|
|
80
55
|
fieldMessage = countryCodeAndNumberFieldMessage;
|
|
81
56
|
} else if (countryCodeFieldMessage && numberFieldMessage) {
|
|
@@ -85,7 +60,6 @@ var PhoneNumber = /*#__PURE__*/function (_React$Component) {
|
|
|
85
60
|
} else if (numberFieldMessage) {
|
|
86
61
|
fieldMessage = numberFieldMessage;
|
|
87
62
|
}
|
|
88
|
-
|
|
89
63
|
var fieldMessageId = ((_fieldMessage = fieldMessage) === null || _fieldMessage === void 0 ? void 0 : (_fieldMessage$props = _fieldMessage.props) === null || _fieldMessage$props === void 0 ? void 0 : _fieldMessage$props.id) || this.fieldMessageId;
|
|
90
64
|
var supportedLocales = ['nb', 'nn', 'en'];
|
|
91
65
|
var text = i18n[supportedLocales.indexOf(this.props.locale) !== -1 ? this.props.locale : 'nb'];
|
|
@@ -141,14 +115,10 @@ var PhoneNumber = /*#__PURE__*/function (_React$Component) {
|
|
|
141
115
|
}));
|
|
142
116
|
}
|
|
143
117
|
}]);
|
|
144
|
-
|
|
145
118
|
return PhoneNumber;
|
|
146
119
|
}(React.Component);
|
|
147
|
-
|
|
148
120
|
export { PhoneNumber as default };
|
|
149
|
-
|
|
150
121
|
var noop = function noop() {};
|
|
151
|
-
|
|
152
122
|
PhoneNumber.propTypes = {
|
|
153
123
|
number: string,
|
|
154
124
|
countryCode: string,
|
|
@@ -158,13 +128,10 @@ PhoneNumber.propTypes = {
|
|
|
158
128
|
onNumberBlur: func,
|
|
159
129
|
locale: string,
|
|
160
130
|
disabled: bool,
|
|
161
|
-
|
|
162
131
|
/** String or ErrorFieldMessage component with message */
|
|
163
132
|
countryCodeFieldMessage: oneOfType([string, node]),
|
|
164
|
-
|
|
165
133
|
/** String or ErrorFieldMessage component with message */
|
|
166
134
|
numberFieldMessage: oneOfType([string, node]),
|
|
167
|
-
|
|
168
135
|
/** String or ErrorFieldMessage component with message,
|
|
169
136
|
* this should should be set when both countryCode and number is in an invalid state.
|
|
170
137
|
* If both countryCodeFieldMessage and numberFieldMessage is set and not this prop,
|
|
@@ -172,18 +139,15 @@ PhoneNumber.propTypes = {
|
|
|
172
139
|
*/
|
|
173
140
|
countryCodeAndNumberFieldMessage: oneOfType([string, node]),
|
|
174
141
|
className: string,
|
|
175
|
-
|
|
176
142
|
/** Reserve space for showing `fieldMessage`s so content below don't move
|
|
177
143
|
* vertically if an errormessage shows up. Note that this will only reserve
|
|
178
144
|
* space for one line of content, so keep messages short.
|
|
179
145
|
*/
|
|
180
146
|
extraMargin: bool,
|
|
181
|
-
|
|
182
147
|
/** Ref-setting function, or ref created by useRef, passed to the country code input element */
|
|
183
148
|
countryCodeRef: oneOfType([func, shape({
|
|
184
149
|
current: object
|
|
185
150
|
})]),
|
|
186
|
-
|
|
187
151
|
/** Ref-setting function, or ref created by useRef, passed to the number input element */
|
|
188
152
|
numberRef: oneOfType([func, shape({
|
|
189
153
|
current: object
|