@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
|
@@ -1,107 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _Tooltip = _interopRequireDefault(require("./Tooltip"));
|
|
13
|
-
var _excluded = ["children", "className", "extraMargin", "description", "fieldMessage", "inline", "label", "name", "selectedValue", "tooltip"];
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
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); }
|
|
16
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
|
-
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; }
|
|
22
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
23
|
-
var RadioButtonInputGroup = function RadioButtonInputGroup(props) {
|
|
24
|
-
var children = props.children,
|
|
25
|
-
className = props.className,
|
|
26
|
-
_props$extraMargin = props.extraMargin,
|
|
27
|
-
extraMargin = _props$extraMargin === void 0 ? true : _props$extraMargin,
|
|
28
|
-
description = props.description,
|
|
29
|
-
fieldMessage = props.fieldMessage,
|
|
30
|
-
inline = props.inline,
|
|
31
|
-
label = props.label,
|
|
32
|
-
name = props.name,
|
|
33
|
-
selectedValue = props.selectedValue,
|
|
34
|
-
tooltip = props.tooltip,
|
|
35
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
36
|
-
if (tooltip && description) {
|
|
37
|
-
throw new Error('Don\'t use both "tooltip" and "description" on an <RadioButtonInputGroup />, pick one of them');
|
|
38
|
-
}
|
|
39
|
-
var buttonProps = {
|
|
40
|
-
inline: inline,
|
|
41
|
-
name: name,
|
|
42
|
-
onChange: /* istanbul ignore next */function onChange(f) {
|
|
43
|
-
return f;
|
|
44
|
-
},
|
|
45
|
-
selectedValue: selectedValue
|
|
46
|
-
};
|
|
47
|
-
return /*#__PURE__*/_react.default.createElement("fieldset", _extends({
|
|
48
|
-
className: (0, _classnames.default)('ffe-input-group', {
|
|
49
|
-
'ffe-input-group--no-extra-margin': !extraMargin
|
|
50
|
-
}, {
|
|
51
|
-
'ffe-input-group--message': !!fieldMessage
|
|
52
|
-
}, className)
|
|
53
|
-
}, rest), label && /*#__PURE__*/_react.default.createElement("legend", {
|
|
54
|
-
className: (0, _classnames.default)('ffe-form-label', 'ffe-form-label--block')
|
|
55
|
-
}, label, typeof tooltip === 'string' && /*#__PURE__*/_react.default.createElement(_Tooltip.default, null, tooltip), /*#__PURE__*/_react.default.isValidElement(tooltip) && tooltip), typeof description === 'string' && /*#__PURE__*/_react.default.createElement("div", {
|
|
56
|
-
className: "ffe-small-text"
|
|
57
|
-
}, description), /*#__PURE__*/_react.default.isValidElement(description) && description, children(_objectSpread({}, buttonProps)), typeof fieldMessage === 'string' && /*#__PURE__*/_react.default.createElement(_ErrorFieldMessage.default, {
|
|
58
|
-
element: "p"
|
|
59
|
-
}, fieldMessage), /*#__PURE__*/_react.default.isValidElement(fieldMessage) && fieldMessage);
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
60
12
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
* */
|
|
72
|
-
children: _propTypes.func.isRequired,
|
|
73
|
-
/** Additional class names applied to the fieldset */
|
|
74
|
-
className: _propTypes.string,
|
|
75
|
-
/** To just render a static, always visible tooltip, use this. */
|
|
76
|
-
description: (0, _propTypes.oneOfType)([_propTypes.node, _propTypes.string]),
|
|
77
|
-
/** Reserve space for showing `fieldMessage`s so content below don't move
|
|
78
|
-
* vertically if an errormessage shows up. Note that this will only reserve
|
|
79
|
-
* space for one line of content, so keep messages short.
|
|
80
|
-
*/
|
|
81
|
-
extraMargin: _propTypes.bool,
|
|
82
|
-
/** String or ErrorFieldMessage component with message */
|
|
83
|
-
fieldMessage: (0, _propTypes.oneOfType)([_propTypes.node, _propTypes.string]),
|
|
84
|
-
/**
|
|
85
|
-
* Indicates whether the radio buttons inside this radio button group is
|
|
86
|
-
* rendered inline or as a block.
|
|
87
|
-
* */
|
|
88
|
-
inline: _propTypes.bool,
|
|
89
|
-
/**
|
|
90
|
-
* The text describing the radio button set. Note that if you don't use this
|
|
91
|
-
* prop but provide your own label you should make sure your solution passes
|
|
92
|
-
* acessibility validation using a tool such as aXe DevTools.
|
|
93
|
-
*/
|
|
94
|
-
label: (0, _propTypes.oneOfType)([_propTypes.node, _propTypes.string]),
|
|
95
|
-
/** The name of the radio button, required to avoid missing name */
|
|
96
|
-
name: _propTypes.string.isRequired,
|
|
97
|
-
/** Change handler, receives value of selected radio button */
|
|
98
|
-
onChange: _propTypes.func,
|
|
99
|
-
/** The currently selected value */
|
|
100
|
-
selectedValue: (0, _propTypes.oneOfType)([_propTypes.bool, _propTypes.string, _propTypes.number]),
|
|
101
|
-
/**
|
|
102
|
-
* String or Tooltip component with further detail about the radio button
|
|
103
|
-
* set
|
|
104
|
-
* */
|
|
105
|
-
tooltip: (0, _propTypes.oneOfType)([_propTypes.node, _propTypes.string])
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
106
23
|
};
|
|
107
|
-
var
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.RadioButtonInputGroup = void 0;
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
31
|
+
var message_1 = require("./message");
|
|
32
|
+
var Tooltip_1 = require("./Tooltip");
|
|
33
|
+
var RadioButtonInputGroup = function (_a) {
|
|
34
|
+
var children = _a.children, className = _a.className, _b = _a.extraMargin, extraMargin = _b === void 0 ? true : _b, description = _a.description, fieldMessage = _a.fieldMessage, inline = _a.inline, label = _a.label, name = _a.name, selectedValue = _a.selectedValue, tooltip = _a.tooltip, onChange = _a.onChange, rest = __rest(_a, ["children", "className", "extraMargin", "description", "fieldMessage", "inline", "label", "name", "selectedValue", "tooltip", "onChange"]);
|
|
35
|
+
if (tooltip && description) {
|
|
36
|
+
throw new Error('Don\'t use both "tooltip" and "description" on an <RadioButtonInputGroup />, pick one of them');
|
|
37
|
+
}
|
|
38
|
+
return (react_1.default.createElement("fieldset", __assign({ className: (0, classnames_1.default)('ffe-input-group', { 'ffe-input-group--no-extra-margin': !extraMargin }, { 'ffe-input-group--message': !!fieldMessage }, className) }, rest),
|
|
39
|
+
label && (react_1.default.createElement("legend", { className: (0, classnames_1.default)('ffe-form-label', 'ffe-form-label--block') },
|
|
40
|
+
label,
|
|
41
|
+
typeof tooltip === 'string' && (react_1.default.createElement(Tooltip_1.Tooltip, null, tooltip)),
|
|
42
|
+
react_1.default.isValidElement(tooltip) && tooltip)),
|
|
43
|
+
typeof description === 'string' ? (react_1.default.createElement("div", { className: "ffe-small-text" }, description)) : (description),
|
|
44
|
+
children({
|
|
45
|
+
inline: inline,
|
|
46
|
+
name: name,
|
|
47
|
+
onChange: function (e) {
|
|
48
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
49
|
+
},
|
|
50
|
+
selectedValue: selectedValue,
|
|
51
|
+
}),
|
|
52
|
+
typeof fieldMessage === 'string' ? (react_1.default.createElement(message_1.ErrorFieldMessage, { as: "p" }, fieldMessage)) : (fieldMessage)));
|
|
53
|
+
};
|
|
54
|
+
exports.RadioButtonInputGroup = RadioButtonInputGroup;
|
package/lib/RadioSwitch.js
CHANGED
|
@@ -1,76 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _excluded = ["className", "leftLabel", "leftValue", "leftInnerRef", "rightLabel", "rightValue", "rightInnerRef", "condensed", "aria-invalid"];
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
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); }
|
|
17
|
-
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
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
19
|
-
var RadioSwitch = function RadioSwitch(props) {
|
|
20
|
-
var className = props.className,
|
|
21
|
-
leftLabel = props.leftLabel,
|
|
22
|
-
leftValue = props.leftValue,
|
|
23
|
-
leftInnerRef = props.leftInnerRef,
|
|
24
|
-
rightLabel = props.rightLabel,
|
|
25
|
-
rightValue = props.rightValue,
|
|
26
|
-
rightInnerRef = props.rightInnerRef,
|
|
27
|
-
condensed = props.condensed,
|
|
28
|
-
ariaInvalid = props['aria-invalid'],
|
|
29
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
30
|
-
var noneSelected = [null, undefined, ''].includes(props.selectedValue);
|
|
31
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_BaseRadioButton.default, _extends({
|
|
32
|
-
className: (0, _classnames.default)('ffe-radio-switch', className, {
|
|
33
|
-
'ffe-radio-switch--condensed': condensed
|
|
34
|
-
}),
|
|
35
|
-
value: leftValue,
|
|
36
|
-
innerRef: leftInnerRef,
|
|
37
|
-
"aria-invalid": String(ariaInvalid === 'true' && (props.selectedValue === leftValue || noneSelected))
|
|
38
|
-
}, rest), leftLabel), /*#__PURE__*/_react.default.createElement(_BaseRadioButton.default, _extends({
|
|
39
|
-
className: (0, _classnames.default)('ffe-radio-switch', className, {
|
|
40
|
-
'ffe-radio-switch--condensed': condensed
|
|
41
|
-
}),
|
|
42
|
-
value: rightValue,
|
|
43
|
-
innerRef: rightInnerRef,
|
|
44
|
-
"aria-invalid": String(ariaInvalid === 'true' && (props.selectedValue === rightValue || noneSelected))
|
|
45
|
-
}, rest), rightLabel));
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
46
12
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})]),
|
|
58
|
-
/** The label of the choice to the right */
|
|
59
|
-
rightLabel: _propTypes.string.isRequired,
|
|
60
|
-
/** The value of the choice to the right */
|
|
61
|
-
rightValue: (0, _propTypes.oneOfType)([_propTypes.bool, _propTypes.string, _propTypes.number]).isRequired,
|
|
62
|
-
/** Ref-setting function, or ref created by useRef, passed to the input element */
|
|
63
|
-
rightInnerRef: (0, _propTypes.oneOfType)([_propTypes.func, (0, _propTypes.shape)({
|
|
64
|
-
current: _propTypes.object
|
|
65
|
-
})]),
|
|
66
|
-
/** The selected value of the radio button set */
|
|
67
|
-
selectedValue: (0, _propTypes.oneOfType)([_propTypes.bool, _propTypes.string, _propTypes.number]),
|
|
68
|
-
/** Condensed modifier. Use in condensed designs */
|
|
69
|
-
condensed: _propTypes.bool,
|
|
70
|
-
/**
|
|
71
|
-
* Indicates whether the radio buttons inside this radio button group is
|
|
72
|
-
* invalid or not. Propagated to all children.
|
|
73
|
-
* */
|
|
74
|
-
'aria-invalid': (0, _propTypes.oneOf)(['true', 'false'])
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
75
23
|
};
|
|
76
|
-
var
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.RadioSwitch = void 0;
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
31
|
+
var BaseRadioButton_1 = require("./BaseRadioButton");
|
|
32
|
+
var RadioSwitch = function (_a) {
|
|
33
|
+
var className = _a.className, leftLabel = _a.leftLabel, leftValue = _a.leftValue, leftInnerRef = _a.leftInnerRef, rightLabel = _a.rightLabel, rightValue = _a.rightValue, rightInnerRef = _a.rightInnerRef, condensed = _a.condensed, ariaInvalid = _a["aria-invalid"], selectedValue = _a.selectedValue, rest = __rest(_a, ["className", "leftLabel", "leftValue", "leftInnerRef", "rightLabel", "rightValue", "rightInnerRef", "condensed", 'aria-invalid', "selectedValue"]);
|
|
34
|
+
var noneSelected = selectedValue === null ||
|
|
35
|
+
selectedValue === undefined ||
|
|
36
|
+
selectedValue === '';
|
|
37
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
38
|
+
react_1.default.createElement(BaseRadioButton_1.BaseRadioButton, __assign({ className: (0, classnames_1.default)('ffe-radio-switch', className, {
|
|
39
|
+
'ffe-radio-switch--condensed': condensed,
|
|
40
|
+
}), value: leftValue, ref: leftInnerRef, "aria-invalid": ariaInvalid === 'true' &&
|
|
41
|
+
(selectedValue === leftValue || noneSelected) }, rest), leftLabel),
|
|
42
|
+
react_1.default.createElement(BaseRadioButton_1.BaseRadioButton, __assign({ className: (0, classnames_1.default)('ffe-radio-switch', className, {
|
|
43
|
+
'ffe-radio-switch--condensed': condensed,
|
|
44
|
+
}), value: rightValue, ref: rightInnerRef, "aria-invalid": ariaInvalid === 'true' &&
|
|
45
|
+
(selectedValue === rightValue || noneSelected) }, rest), rightLabel)));
|
|
46
|
+
};
|
|
47
|
+
exports.RadioSwitch = RadioSwitch;
|
package/lib/TextArea.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
TextArea.propTypes = {
|
|
24
|
-
className: _propTypes.string
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
25
23
|
};
|
|
26
|
-
var
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.TextArea = void 0;
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
31
|
+
exports.TextArea = react_1.default.forwardRef(function (_a, ref) {
|
|
32
|
+
var className = _a.className, rest = __rest(_a, ["className"]);
|
|
33
|
+
return (react_1.default.createElement("textarea", __assign({ className: (0, classnames_1.default)('ffe-textarea', className), ref: ref }, rest)));
|
|
34
|
+
});
|
package/lib/ToggleSwitch.js
CHANGED
|
@@ -1,109 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
22
|
-
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); }
|
|
23
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
24
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
26
|
-
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); }
|
|
27
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
28
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
30
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
31
|
-
var ToggleSwitch = /*#__PURE__*/function (_React$Component) {
|
|
32
|
-
function ToggleSwitch() {
|
|
33
|
-
var _this;
|
|
34
|
-
_classCallCheck(this, ToggleSwitch);
|
|
35
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
-
args[_key] = arguments[_key];
|
|
37
|
-
}
|
|
38
|
-
_this = _callSuper(this, ToggleSwitch, [].concat(args));
|
|
39
|
-
_defineProperty(_this, "id", "toggle-".concat((0, _uuid.v4)()));
|
|
40
|
-
return _this;
|
|
41
|
-
}
|
|
42
|
-
_inherits(ToggleSwitch, _React$Component);
|
|
43
|
-
return _createClass(ToggleSwitch, [{
|
|
44
|
-
key: "render",
|
|
45
|
-
value: function render() {
|
|
46
|
-
var _this$props = this.props,
|
|
47
|
-
children = _this$props.children,
|
|
48
|
-
className = _this$props.className,
|
|
49
|
-
description = _this$props.description,
|
|
50
|
-
hideOnOff = _this$props.hideOnOff,
|
|
51
|
-
onText = _this$props.onText,
|
|
52
|
-
offText = _this$props.offText,
|
|
53
|
-
id = _this$props.id,
|
|
54
|
-
_this$props$value = _this$props.value,
|
|
55
|
-
value = _this$props$value === void 0 ? 'on' : _this$props$value,
|
|
56
|
-
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
57
|
-
var supportedLocales = ['nb', 'nn', 'en'];
|
|
58
|
-
var text = _i18n.default[supportedLocales.indexOf(this.props.locale) !== -1 ? this.props.locale : 'nb'];
|
|
59
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
-
className: (0, _classnames.default)('ffe-toggle-switch', {
|
|
61
|
-
'ffe-toggle-switch--hide-on-off': hideOnOff
|
|
62
|
-
}, className)
|
|
63
|
-
}, /*#__PURE__*/_react.default.createElement("input", _extends({
|
|
64
|
-
className: "ffe-toggle-switch__input",
|
|
65
|
-
type: "checkbox",
|
|
66
|
-
id: id || this.id,
|
|
67
|
-
value: value
|
|
68
|
-
}, rest)), /*#__PURE__*/_react.default.createElement("label", {
|
|
69
|
-
className: "ffe-toggle-switch__label",
|
|
70
|
-
htmlFor: id || this.id
|
|
71
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
72
|
-
className: "ffe-toggle-switch__label-text"
|
|
73
|
-
}, children, description && /*#__PURE__*/_react.default.createElement("span", {
|
|
74
|
-
className: "ffe-toggle-switch__label-description"
|
|
75
|
-
}, description)), !hideOnOff && /*#__PURE__*/_react.default.createElement("span", {
|
|
76
|
-
className: "ffe-toggle-switch__label-off",
|
|
77
|
-
"aria-hidden": "true"
|
|
78
|
-
}, offText ? offText : text.OFF), /*#__PURE__*/_react.default.createElement("span", {
|
|
79
|
-
className: "ffe-toggle-switch__switch",
|
|
80
|
-
"aria-hidden": "true"
|
|
81
|
-
}), !hideOnOff && /*#__PURE__*/_react.default.createElement("span", {
|
|
82
|
-
className: "ffe-toggle-switch__label-on",
|
|
83
|
-
id: "test",
|
|
84
|
-
"aria-hidden": "true"
|
|
85
|
-
}, onText ? onText : text.ON)));
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
86
18
|
}
|
|
87
|
-
|
|
88
|
-
}(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.ToggleSwitch = void 0;
|
|
52
|
+
var react_1 = __importStar(require("react"));
|
|
53
|
+
var uuid_1 = require("uuid");
|
|
54
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
55
|
+
var i18n_1 = __importDefault(require("./i18n/i18n"));
|
|
56
|
+
var ToggleSwitch = function (_a) {
|
|
57
|
+
var children = _a.children, className = _a.className, description = _a.description, hideOnOff = _a.hideOnOff, onText = _a.onText, offText = _a.offText, id = _a.id, _b = _a.value, value = _b === void 0 ? 'on' : _b, _c = _a.locale, locale = _c === void 0 ? 'nb' : _c, rest = __rest(_a, ["children", "className", "description", "hideOnOff", "onText", "offText", "id", "value", "locale"]);
|
|
58
|
+
var generatedId = (0, react_1.useRef)(id !== null && id !== void 0 ? id : "toggle-".concat((0, uuid_1.v4)())).current;
|
|
59
|
+
var text = i18n_1.default[locale];
|
|
60
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('ffe-toggle-switch', { 'ffe-toggle-switch--hide-on-off': hideOnOff }, className) },
|
|
61
|
+
react_1.default.createElement("input", __assign({ className: "ffe-toggle-switch__input", type: "checkbox", id: generatedId, value: value }, rest)),
|
|
62
|
+
react_1.default.createElement("label", { className: "ffe-toggle-switch__label", htmlFor: generatedId },
|
|
63
|
+
react_1.default.createElement("span", { className: "ffe-toggle-switch__label-text" },
|
|
64
|
+
children,
|
|
65
|
+
description && (react_1.default.createElement("span", { className: "ffe-toggle-switch__label-description" }, description))),
|
|
66
|
+
!hideOnOff && (react_1.default.createElement("span", { className: "ffe-toggle-switch__label-off", "aria-hidden": "true" }, offText ? offText : text.OFF)),
|
|
67
|
+
react_1.default.createElement("span", { className: "ffe-toggle-switch__switch", "aria-hidden": "true" }),
|
|
68
|
+
!hideOnOff && (react_1.default.createElement("span", { className: "ffe-toggle-switch__label-on", id: "test", "aria-hidden": "true" }, onText ? onText : text.ON)))));
|
|
108
69
|
};
|
|
109
|
-
|
|
70
|
+
exports.ToggleSwitch = ToggleSwitch;
|