@sb1/ffe-form-react 18.0.4 → 19.0.1

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.
Files changed (86) hide show
  1. package/es/BaseRadioButton.js +35 -95
  2. package/es/Checkbox.js +43 -49
  3. package/es/Input.js +25 -26
  4. package/es/InputGroup.js +91 -109
  5. package/es/InputTextLike.js +25 -19
  6. package/es/Label.js +27 -28
  7. package/es/PhoneNumber.js +48 -158
  8. package/es/RadioBlock.js +37 -98
  9. package/es/RadioButton.js +26 -22
  10. package/es/RadioButtonInputGroup.js +47 -98
  11. package/es/RadioSwitch.js +38 -64
  12. package/es/TextArea.js +25 -16
  13. package/es/ToggleSwitch.js +36 -98
  14. package/es/Tooltip.js +29 -75
  15. package/es/i18n/en.js +6 -6
  16. package/es/i18n/i18n.js +4 -4
  17. package/es/i18n/nb.js +6 -6
  18. package/es/i18n/nn.js +6 -6
  19. package/es/index.js +14 -17
  20. package/es/message/BaseFieldMessage.js +49 -0
  21. package/es/message/ErrorFieldMessage.js +28 -0
  22. package/es/message/InfoFieldMessage.js +28 -0
  23. package/es/message/SuccessFieldMessage.js +28 -0
  24. package/es/message/index.js +3 -0
  25. package/es/types.js +1 -0
  26. package/lib/BaseRadioButton.js +63 -103
  27. package/lib/Checkbox.js +72 -56
  28. package/lib/Input.js +32 -34
  29. package/lib/InputGroup.js +121 -119
  30. package/lib/InputTextLike.js +32 -27
  31. package/lib/Label.js +34 -35
  32. package/lib/PhoneNumber.js +79 -165
  33. package/lib/RadioBlock.js +65 -106
  34. package/lib/RadioButton.js +33 -29
  35. package/lib/RadioButtonInputGroup.js +75 -103
  36. package/lib/RadioSwitch.js +44 -73
  37. package/lib/TextArea.js +32 -24
  38. package/lib/ToggleSwitch.js +67 -106
  39. package/lib/Tooltip.js +59 -86
  40. package/lib/i18n/en.js +8 -12
  41. package/lib/i18n/i18n.js +12 -14
  42. package/lib/i18n/nb.js +8 -12
  43. package/lib/i18n/nn.js +8 -12
  44. package/lib/index.js +32 -117
  45. package/lib/message/BaseFieldMessage.js +56 -0
  46. package/lib/message/ErrorFieldMessage.js +35 -0
  47. package/lib/message/InfoFieldMessage.js +35 -0
  48. package/lib/message/SuccessFieldMessage.js +35 -0
  49. package/lib/message/index.js +9 -0
  50. package/lib/types.js +2 -0
  51. package/package.json +6 -5
  52. package/types/BaseRadioButton.d.ts +14 -0
  53. package/types/Checkbox.d.ts +13 -0
  54. package/types/Input.d.ts +8 -0
  55. package/types/InputGroup.d.ts +36 -0
  56. package/types/InputTextLike.d.ts +5 -0
  57. package/types/Label.d.ts +9 -0
  58. package/types/PhoneNumber.d.ts +40 -0
  59. package/types/RadioBlock.d.ts +18 -0
  60. package/types/RadioButton.d.ts +7 -0
  61. package/types/RadioButtonInputGroup.d.ts +48 -0
  62. package/types/RadioSwitch.d.ts +23 -0
  63. package/types/TextArea.d.ts +4 -0
  64. package/types/ToggleSwitch.d.ts +16 -0
  65. package/types/Tooltip.d.ts +6 -0
  66. package/types/i18n/en.d.ts +8 -0
  67. package/types/i18n/i18n.d.ts +24 -0
  68. package/types/i18n/nb.d.ts +8 -0
  69. package/types/i18n/nn.d.ts +8 -0
  70. package/types/index.d.ts +14 -212
  71. package/types/message/BaseFieldMessage.d.ts +11 -0
  72. package/types/message/ErrorFieldMessage.d.ts +6 -0
  73. package/types/message/InfoFieldMessage.d.ts +6 -0
  74. package/types/message/SuccessFieldMessage.d.ts +6 -0
  75. package/types/message/index.d.ts +3 -0
  76. package/types/types.d.ts +11 -0
  77. package/es/BaseFieldMessage.js +0 -67
  78. package/es/ErrorFieldMessage.js +0 -21
  79. package/es/InfoFieldMessage.js +0 -9
  80. package/es/SuccessFieldMessage.js +0 -9
  81. package/es/index.d.js +0 -5
  82. package/lib/BaseFieldMessage.js +0 -73
  83. package/lib/ErrorFieldMessage.js +0 -28
  84. package/lib/InfoFieldMessage.js +0 -16
  85. package/lib/SuccessFieldMessage.js +0 -16
  86. package/lib/index.d.js +0 -6
package/es/RadioSwitch.js CHANGED
@@ -1,66 +1,40 @@
1
- var _excluded = ["className", "leftLabel", "leftValue", "leftInnerRef", "rightLabel", "rightValue", "rightInnerRef", "condensed", "aria-invalid"];
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); }
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; }
4
- 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; }
5
- import React, { Fragment } from 'react';
6
- import { bool, oneOf, oneOfType, string, number, func, object, shape } from 'prop-types';
7
- import classNames from 'classnames';
8
- import BaseRadioButton from './BaseRadioButton';
9
- var RadioSwitch = function RadioSwitch(props) {
10
- var className = props.className,
11
- leftLabel = props.leftLabel,
12
- leftValue = props.leftValue,
13
- leftInnerRef = props.leftInnerRef,
14
- rightLabel = props.rightLabel,
15
- rightValue = props.rightValue,
16
- rightInnerRef = props.rightInnerRef,
17
- condensed = props.condensed,
18
- ariaInvalid = props['aria-invalid'],
19
- rest = _objectWithoutProperties(props, _excluded);
20
- var noneSelected = [null, undefined, ''].includes(props.selectedValue);
21
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(BaseRadioButton, _extends({
22
- className: classNames('ffe-radio-switch', className, {
23
- 'ffe-radio-switch--condensed': condensed
24
- }),
25
- value: leftValue,
26
- innerRef: leftInnerRef,
27
- "aria-invalid": String(ariaInvalid === 'true' && (props.selectedValue === leftValue || noneSelected))
28
- }, rest), leftLabel), /*#__PURE__*/React.createElement(BaseRadioButton, _extends({
29
- className: classNames('ffe-radio-switch', className, {
30
- 'ffe-radio-switch--condensed': condensed
31
- }),
32
- value: rightValue,
33
- innerRef: rightInnerRef,
34
- "aria-invalid": String(ariaInvalid === 'true' && (props.selectedValue === rightValue || noneSelected))
35
- }, rest), rightLabel));
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;
36
22
  };
37
- RadioSwitch.propTypes = {
38
- /** Additional class names applied to both radio buttons */
39
- className: string,
40
- /** The label of the choice to the left */
41
- leftLabel: string.isRequired,
42
- /** The value of the choice to the left */
43
- leftValue: oneOfType([bool, string, number]).isRequired,
44
- /** Ref-setting function, or ref created by useRef, passed to the input element */
45
- leftInnerRef: oneOfType([func, shape({
46
- current: object
47
- })]),
48
- /** The label of the choice to the right */
49
- rightLabel: string.isRequired,
50
- /** The value of the choice to the right */
51
- rightValue: oneOfType([bool, string, number]).isRequired,
52
- /** Ref-setting function, or ref created by useRef, passed to the input element */
53
- rightInnerRef: oneOfType([func, shape({
54
- current: object
55
- })]),
56
- /** The selected value of the radio button set */
57
- selectedValue: oneOfType([bool, string, number]),
58
- /** Condensed modifier. Use in condensed designs */
59
- condensed: bool,
60
- /**
61
- * Indicates whether the radio buttons inside this radio button group is
62
- * invalid or not. Propagated to all children.
63
- * */
64
- 'aria-invalid': oneOf(['true', 'false'])
23
+ import React from 'react';
24
+ import classNames from 'classnames';
25
+ import { BaseRadioButton } from './BaseRadioButton';
26
+ export var RadioSwitch = function (_a) {
27
+ 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"]);
28
+ var noneSelected = selectedValue === null ||
29
+ selectedValue === undefined ||
30
+ selectedValue === '';
31
+ return (React.createElement(React.Fragment, null,
32
+ React.createElement(BaseRadioButton, __assign({ className: classNames('ffe-radio-switch', className, {
33
+ 'ffe-radio-switch--condensed': condensed,
34
+ }), value: leftValue, ref: leftInnerRef, "aria-invalid": ariaInvalid === 'true' &&
35
+ (selectedValue === leftValue || noneSelected) }, rest), leftLabel),
36
+ React.createElement(BaseRadioButton, __assign({ className: classNames('ffe-radio-switch', className, {
37
+ 'ffe-radio-switch--condensed': condensed,
38
+ }), value: rightValue, ref: rightInnerRef, "aria-invalid": ariaInvalid === 'true' &&
39
+ (selectedValue === rightValue || noneSelected) }, rest), rightLabel)));
65
40
  };
66
- export default RadioSwitch;
package/es/TextArea.js CHANGED
@@ -1,19 +1,28 @@
1
- var _excluded = ["className"];
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); }
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; }
4
- 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; }
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 TextArea = /*#__PURE__*/React.forwardRef(function (props, ref) {
9
- var className = props.className,
10
- rest = _objectWithoutProperties(props, _excluded);
11
- return /*#__PURE__*/React.createElement("textarea", _extends({
12
- className: classNames('ffe-textarea', className),
13
- ref: ref
14
- }, rest));
25
+ export var TextArea = React.forwardRef(function (_a, ref) {
26
+ var className = _a.className, rest = __rest(_a, ["className"]);
27
+ return (React.createElement("textarea", __assign({ className: classNames('ffe-textarea', className), ref: ref }, rest)));
15
28
  });
16
- TextArea.propTypes = {
17
- className: string
18
- };
19
- export default TextArea;
@@ -1,102 +1,40 @@
1
- var _excluded = ["children", "className", "description", "hideOnOff", "onText", "offText", "id", "value"];
2
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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); }
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; }
5
- 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; }
6
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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, _toPropertyKey(descriptor.key), descriptor); } }
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; }
9
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
- 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); }
11
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14
- 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); }
15
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
- 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; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
- 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); }
19
- import React from 'react';
20
- import { bool, node, string, oneOf } from 'prop-types';
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';
21
24
  import { v4 as uuidv4 } from 'uuid';
22
25
  import classNames from 'classnames';
23
26
  import i18n from './i18n/i18n';
24
- var ToggleSwitch = /*#__PURE__*/function (_React$Component) {
25
- function ToggleSwitch() {
26
- var _this;
27
- _classCallCheck(this, ToggleSwitch);
28
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
- args[_key] = arguments[_key];
30
- }
31
- _this = _callSuper(this, ToggleSwitch, [].concat(args));
32
- _defineProperty(_this, "id", "toggle-".concat(uuidv4()));
33
- return _this;
34
- }
35
- _inherits(ToggleSwitch, _React$Component);
36
- return _createClass(ToggleSwitch, [{
37
- key: "render",
38
- value: function render() {
39
- var _this$props = this.props,
40
- children = _this$props.children,
41
- className = _this$props.className,
42
- description = _this$props.description,
43
- hideOnOff = _this$props.hideOnOff,
44
- onText = _this$props.onText,
45
- offText = _this$props.offText,
46
- id = _this$props.id,
47
- _this$props$value = _this$props.value,
48
- value = _this$props$value === void 0 ? 'on' : _this$props$value,
49
- rest = _objectWithoutProperties(_this$props, _excluded);
50
- var supportedLocales = ['nb', 'nn', 'en'];
51
- var text = i18n[supportedLocales.indexOf(this.props.locale) !== -1 ? this.props.locale : 'nb'];
52
- return /*#__PURE__*/React.createElement("div", {
53
- className: classNames('ffe-toggle-switch', {
54
- 'ffe-toggle-switch--hide-on-off': hideOnOff
55
- }, className)
56
- }, /*#__PURE__*/React.createElement("input", _extends({
57
- className: "ffe-toggle-switch__input",
58
- type: "checkbox",
59
- id: id || this.id,
60
- value: value
61
- }, rest)), /*#__PURE__*/React.createElement("label", {
62
- className: "ffe-toggle-switch__label",
63
- htmlFor: id || this.id
64
- }, /*#__PURE__*/React.createElement("span", {
65
- className: "ffe-toggle-switch__label-text"
66
- }, children, description && /*#__PURE__*/React.createElement("span", {
67
- className: "ffe-toggle-switch__label-description"
68
- }, description)), !hideOnOff && /*#__PURE__*/React.createElement("span", {
69
- className: "ffe-toggle-switch__label-off",
70
- "aria-hidden": "true"
71
- }, offText ? offText : text.OFF), /*#__PURE__*/React.createElement("span", {
72
- className: "ffe-toggle-switch__switch",
73
- "aria-hidden": "true"
74
- }), !hideOnOff && /*#__PURE__*/React.createElement("span", {
75
- className: "ffe-toggle-switch__label-on",
76
- id: "test",
77
- "aria-hidden": "true"
78
- }, onText ? onText : text.ON)));
79
- }
80
- }]);
81
- }(React.Component);
82
- ToggleSwitch.propTypes = {
83
- /** The label text */
84
- children: node.isRequired,
85
- /** Any extra classes */
86
- className: string,
87
- /** A second line of text in the label */
88
- locale: oneOf(['nb', 'nn', 'en']),
89
- /** On/Off text language */
90
- description: string,
91
- /** Custom text to specify the on-option */
92
- onText: string,
93
- /** Custom text to specify the off-option */
94
- offText: string,
95
- /** Hide On & Off labels next to switch */
96
- hideOnOff: bool,
97
- /** Override the generated id with a custom one */
98
- id: string,
99
- /** Override the value attribute of the input with a custom one */
100
- value: string
27
+ export var ToggleSwitch = function (_a) {
28
+ 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"]);
29
+ var generatedId = useRef(id !== null && id !== void 0 ? id : "toggle-".concat(uuidv4())).current;
30
+ var text = i18n[locale];
31
+ return (React.createElement("div", { className: classNames('ffe-toggle-switch', { 'ffe-toggle-switch--hide-on-off': hideOnOff }, className) },
32
+ React.createElement("input", __assign({ className: "ffe-toggle-switch__input", type: "checkbox", id: generatedId, value: value }, rest)),
33
+ React.createElement("label", { className: "ffe-toggle-switch__label", htmlFor: generatedId },
34
+ React.createElement("span", { className: "ffe-toggle-switch__label-text" },
35
+ children,
36
+ description && (React.createElement("span", { className: "ffe-toggle-switch__label-description" }, description))),
37
+ !hideOnOff && (React.createElement("span", { className: "ffe-toggle-switch__label-off", "aria-hidden": "true" }, offText ? offText : text.OFF)),
38
+ React.createElement("span", { className: "ffe-toggle-switch__switch", "aria-hidden": "true" }),
39
+ !hideOnOff && (React.createElement("span", { className: "ffe-toggle-switch__label-on", id: "test", "aria-hidden": "true" }, onText ? onText : text.ON)))));
101
40
  };
102
- export default ToggleSwitch;
package/es/Tooltip.js CHANGED
@@ -1,80 +1,34 @@
1
- var _excluded = ["isOpen", "aria-controls", "aria-label", "children", "className", "onClick", "tabIndex"];
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); }
3
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
7
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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; }
10
- 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; }
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
+ };
11
12
  import React, { useState, useRef } from 'react';
12
- import { bool, func, node, string, number } from 'prop-types';
13
13
  import classNames from 'classnames';
14
14
  import { Collapse } from '@sb1/ffe-collapse-react';
15
15
  import { v4 as uuid } from 'uuid';
16
- var Tooltip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
17
- var isOpen = _ref.isOpen,
18
- ariaControls = _ref['aria-controls'],
19
- _ref$ariaLabel = _ref['aria-label'],
20
- ariaLabel = _ref$ariaLabel === void 0 ? 'Vis hjelpetekst' : _ref$ariaLabel,
21
- children = _ref.children,
22
- className = _ref.className,
23
- onClick = _ref.onClick,
24
- tabIndex = _ref.tabIndex,
25
- rest = _objectWithoutProperties(_ref, _excluded);
26
- var tooltipButtonId = useRef(uuid()).current;
27
- var tooltipId = useRef(uuid()).current;
28
- var _useState = useState(!!isOpen),
29
- _useState2 = _slicedToArray(_useState, 2),
30
- _isOpen = _useState2[0],
31
- setIsOpen = _useState2[1];
32
- var handleClick = function handleClick(evt) {
33
- setIsOpen(function (prev) {
34
- return !prev;
35
- });
36
- if (onClick) {
37
- onClick(evt);
38
- }
39
- };
40
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
41
- className: classNames('ffe-tooltip', {
42
- 'ffe-tooltip--open': _isOpen
43
- })
44
- }), /*#__PURE__*/React.createElement("button", {
45
- ref: ref,
46
- "aria-expanded": _isOpen,
47
- "aria-controls": children ? tooltipId : ariaControls,
48
- "aria-label": ariaLabel,
49
- className: "ffe-tooltip__icon",
50
- onClick: handleClick,
51
- type: "button",
52
- tabIndex: tabIndex,
53
- id: tooltipButtonId
54
- }, /*#__PURE__*/React.createElement("span", {
55
- "aria-hidden": true
56
- }, "?")), children && /*#__PURE__*/React.createElement(Collapse, {
57
- className: "ffe-tooltip__text",
58
- id: tooltipId,
59
- isOpen: _isOpen
60
- }, /*#__PURE__*/React.createElement("span", {
61
- className: classNames('ffe-small-text', className),
62
- role: _isOpen ? 'status' : 'none'
63
- }, children)));
16
+ export var Tooltip = React.forwardRef(function (_a, ref) {
17
+ var initialIsOpen = _a.isOpen, ariaControls = _a["aria-controls"], _b = _a["aria-label"], ariaLabel = _b === void 0 ? 'Vis hjelpetekst' : _b, children = _a.children, className = _a.className, onClick = _a.onClick, tabIndex = _a.tabIndex, containerProps = _a.containerProps;
18
+ var tooltipButtonId = useRef(uuid()).current;
19
+ var tooltipId = useRef(uuid()).current;
20
+ var _c = useState(!!initialIsOpen), isOpen = _c[0], setIsOpen = _c[1];
21
+ var handleClick = function (evt) {
22
+ setIsOpen(function (prev) { return !prev; });
23
+ if (onClick) {
24
+ onClick(evt);
25
+ }
26
+ };
27
+ return (React.createElement("div", __assign({}, containerProps, { className: classNames('ffe-tooltip', {
28
+ 'ffe-tooltip--open': isOpen,
29
+ }) }),
30
+ React.createElement("button", { ref: ref, "aria-expanded": isOpen, "aria-controls": children ? tooltipId : ariaControls, "aria-label": ariaLabel, className: "ffe-tooltip__icon", onClick: handleClick, type: "button", tabIndex: tabIndex, id: tooltipButtonId },
31
+ React.createElement("span", { "aria-hidden": true }, "?")),
32
+ children && (React.createElement(Collapse, { className: "ffe-tooltip__text", id: tooltipId, isOpen: isOpen },
33
+ React.createElement("span", { className: classNames('ffe-small-text', className), role: isOpen ? 'status' : 'none' }, children)))));
64
34
  });
65
- Tooltip.propTypes = {
66
- /** Provide the id of the controlled element *unless* you're sending in children */
67
- 'aria-controls': string,
68
- /** Descriptive text for the Tooltip expand icon */
69
- 'aria-label': string,
70
- /** The children are rendered in the expanded tooltip. */
71
- children: node,
72
- /** The className is set on the root node of the expanded tooltip. */
73
- className: string,
74
- isOpen: bool,
75
- /** Optional listener for clicks on the tooltip button. Is passed the event object. */
76
- onClick: func,
77
- /** Sets the tabIndex of the tooltip button. */
78
- tabIndex: number
79
- };
80
- export default Tooltip;
package/es/i18n/en.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export default {
2
- COUNTRY_CODE: 'Country code',
3
- PHONE_NUMBER: 'Phone number',
4
- MOBILE_NUMBER: 'Mobile number',
5
- ON: 'On',
6
- OFF: 'Off'
7
- };
2
+ COUNTRY_CODE: 'Country code',
3
+ PHONE_NUMBER: 'Phone number',
4
+ MOBILE_NUMBER: 'Mobile number',
5
+ ON: 'On',
6
+ OFF: 'Off',
7
+ };
package/es/i18n/i18n.js CHANGED
@@ -2,7 +2,7 @@ import en from './en';
2
2
  import nn from './nn';
3
3
  import nb from './nb';
4
4
  export default {
5
- nb: nb,
6
- nn: nn,
7
- en: en
8
- };
5
+ nb: nb,
6
+ nn: nn,
7
+ en: en,
8
+ };
package/es/i18n/nb.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export default {
2
- COUNTRY_CODE: 'Landskode',
3
- PHONE_NUMBER: 'Telefonnummer',
4
- MOBILE_NUMBER: 'Mobilnummer',
5
- ON: 'På',
6
- OFF: 'Av'
7
- };
2
+ COUNTRY_CODE: 'Landskode',
3
+ PHONE_NUMBER: 'Telefonnummer',
4
+ MOBILE_NUMBER: 'Mobilnummer',
5
+ ON: 'På',
6
+ OFF: 'Av',
7
+ };
package/es/i18n/nn.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export default {
2
- COUNTRY_CODE: 'Landskode',
3
- PHONE_NUMBER: 'Telefonnummer',
4
- MOBILE_NUMBER: 'Mobilnummer',
5
- ON: 'På',
6
- OFF: 'Av'
7
- };
2
+ COUNTRY_CODE: 'Landskode',
3
+ PHONE_NUMBER: 'Telefonnummer',
4
+ MOBILE_NUMBER: 'Mobilnummer',
5
+ ON: 'På',
6
+ OFF: 'Av',
7
+ };
package/es/index.js CHANGED
@@ -1,17 +1,14 @@
1
- import Checkbox from './Checkbox';
2
- import ErrorFieldMessage from './ErrorFieldMessage';
3
- import InfoFieldMessage from './InfoFieldMessage';
4
- import SuccessFieldMessage from './SuccessFieldMessage';
5
- import Input from './Input';
6
- import InputTextLike from './InputTextLike';
7
- import InputGroup from './InputGroup';
8
- import Label from './Label';
9
- import PhoneNumber from './PhoneNumber';
10
- import RadioBlock from './RadioBlock';
11
- import RadioButton from './RadioButton';
12
- import RadioButtonInputGroup from './RadioButtonInputGroup';
13
- import RadioSwitch from './RadioSwitch';
14
- import TextArea from './TextArea';
15
- import Tooltip from './Tooltip';
16
- import ToggleSwitch from './ToggleSwitch';
17
- export { Checkbox, ErrorFieldMessage, InfoFieldMessage, SuccessFieldMessage, Input, InputTextLike, PhoneNumber, InputGroup, Label, RadioBlock, RadioButton, RadioButtonInputGroup, RadioSwitch, TextArea, Tooltip, ToggleSwitch };
1
+ export { ErrorFieldMessage, InfoFieldMessage, SuccessFieldMessage, } from './message';
2
+ export { Checkbox } from './Checkbox';
3
+ export { Input } from './Input';
4
+ export { InputTextLike } from './InputTextLike';
5
+ export { InputGroup } from './InputGroup';
6
+ export { Label } from './Label';
7
+ export { PhoneNumber } from './PhoneNumber';
8
+ export { RadioBlock } from './RadioBlock';
9
+ export { RadioButton } from './RadioButton';
10
+ export { RadioButtonInputGroup, } from './RadioButtonInputGroup';
11
+ export { RadioSwitch } from './RadioSwitch';
12
+ export { TextArea } from './TextArea';
13
+ export { Tooltip } from './Tooltip';
14
+ export { ToggleSwitch } from './ToggleSwitch';
@@ -0,0 +1,49 @@
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 from 'react';
24
+ import { Icon } from '@sb1/ffe-icons-react';
25
+ import classNames from 'classnames';
26
+ /**
27
+ * Internal factory component
28
+ * @ignore
29
+ */
30
+ export var BaseFieldMessage = function (props) {
31
+ var children = props.children, className = props.className, _a = props.as, Comp = _a === void 0 ? 'div' : _a, type = props.type, _b = props.role, role = _b === void 0 ? 'status' : _b, rest = __rest(props, ["children", "className", "as", "type", "role"]);
32
+ var priorityHighIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjAiPjxwYXRoIGQ9Ik00NzkuNzg4LTE4Ny4wOHEtMjEuNTM3IDAtMzYuNjYyLTE1LjMzN3QtMTUuMTI1LTM2Ljg3NHEwLTIxLjUzNyAxNS4zMzctMzYuNjYyIDE1LjMzNy0xNS4xMjQgMzYuODc0LTE1LjEyNCAyMS41MzcgMCAzNi42NjIgMTUuMzM3dDE1LjEyNSAzNi44NzRxMCAyMS41MzctMTUuMzM3IDM2LjY2MS0xNS4zMzcgMTUuMTI1LTM2Ljg3NCAxNS4xMjVabS0uMDYyLTE5Ni4xNTFxLTE5LjM0MSAwLTMyLjg0LTEzLjcwOS0xMy41LTEzLjcwOS0xMy41LTMyLjk2di0zMTYuNjg1cTAtMTkuMjUxIDEzLjc3NC0zMi43OTQgMTMuNzczLTEzLjU0MiAzMy4xMTQtMTMuNTQyIDE5LjM0MSAwIDMyLjg0IDEzLjcwOSAxMy41IDEzLjcwOSAxMy41IDMyLjk2djMxNi42ODVxMCAxOS4yNTEtMTMuNzc0IDMyLjc5NC0xMy43NzMgMTMuNTQyLTMzLjExNCAxMy41NDJaIi8+PC9zdmc+';
33
+ var checkIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjAiPjxwYXRoIGQ9Im0zOTUtMzcyLjM4NCAyNzAuNTM5LTI2OS41MzhxNy45MjMtNy45MjMgMTcuNjkyLTcuNjE2IDkuNzY5LjMwOCAxOC4wNzYgOC42MTYgOC4zMDggOC4zMDcgOC4zMDggMTcuODg0IDAgOS41NzYtOC4zMDggMTcuODg0bC0yODMgMjgyLjk5OXEtOS44NDYgOS44NDYtMjIuODA3IDkuODQ2LTEyLjk2MSAwLTIyLjgwNy05Ljg0NmwtMTE0LTExMy45OTlxLTcuOTIzLTcuOTIzLTguMzA4LTE3LjY5Mi0uMzg0LTkuNzY5IDcuOTIzLTE4LjA3NiA4LjMwOC04LjMwOCAxNy44ODQtOC4zMDggOS41NzcgMCAxNy44ODQgOC4zMDhMMzk1LTM3Mi4zODRaIi8+PC9zdmc+';
34
+ var infoIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjAiPjxwYXRoIGQ9Ik00NzkuNzg4LTY3MnEtMjUuOTQyIDAtNDMuODY0LTE4LjEzNS0xNy45MjMtMTguMTM2LTE3LjkyMy00NC4wNzd0MTguMTM1LTQzLjg2NHExOC4xMzUtMTcuOTIzIDQ0LjA3Ni0xNy45MjMgMjUuOTQyIDAgNDMuODY0IDE4LjEzNiAxNy45MjMgMTguMTM1IDE3LjkyMyA0NC4wNzZ0LTE4LjEzNSA0My44NjRRNTA1LjcyOS02NzIgNDc5Ljc4OC02NzJabS4yNTcgNTA3Ljk5OXEtMjAuODE0IDAtMzUuNDI5LTE0LjU4NC0xNC42MTUtMTQuNTgzLTE0LjYxNS0zNS40MTZ2LTI5Ni42MTRxMC0yMC44MzMgMTQuNTctMzUuNDE2IDE0LjU3LTE0LjU4MyAzNS4zODQtMTQuNTgzdDM1LjQyOSAxNC41ODNxMTQuNjE1IDE0LjU4MyAxNC42MTUgMzUuNDE2djI5Ni42MTRxMCAyMC44MzMtMTQuNTcgMzUuNDE2LTE0LjU3IDE0LjU4NC0zNS4zODQgMTQuNTg0WiIvPjwvc3ZnPg==';
35
+ return (React.createElement(Comp, __assign({ className: classNames("ffe-field-message", "ffe-field-message--".concat(type), className), role: role }, rest),
36
+ React.createElement("span", { className: classNames("ffe-field-message__icon", "ffe-field-message__icon--".concat(type, "'")) }, (function () {
37
+ switch (type) {
38
+ case 'error':
39
+ return (React.createElement(Icon, { fileUrl: priorityHighIcon, ariaLabel: "Utropstegn", size: "sm" }));
40
+ case 'success':
41
+ return (React.createElement(Icon, { fileUrl: checkIcon, ariaLabel: "hake-ikon", size: "sm" }));
42
+ case 'info':
43
+ return (React.createElement(Icon, { fileUrl: infoIcon, ariaLabel: "info-ikon", size: "sm" }));
44
+ default:
45
+ return (React.createElement(Icon, { fileUrl: infoIcon, ariaLabel: "info-ikon", size: "sm" }));
46
+ }
47
+ })()),
48
+ children));
49
+ };
@@ -0,0 +1,28 @@
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 from 'react';
24
+ import { BaseFieldMessage } from './BaseFieldMessage';
25
+ export var ErrorFieldMessage = function (_a) {
26
+ var _b = _a.role, role = _b === void 0 ? 'alert' : _b, rest = __rest(_a, ["role"]);
27
+ return React.createElement(BaseFieldMessage, __assign({ role: role }, rest, { type: "error" }));
28
+ };
@@ -0,0 +1,28 @@
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 from 'react';
24
+ import { BaseFieldMessage } from './BaseFieldMessage';
25
+ export var InfoFieldMessage = function (_a) {
26
+ var rest = __rest(_a, []);
27
+ return React.createElement(BaseFieldMessage, __assign({ role: "none" }, rest, { type: "info" }));
28
+ };