@uncinc/uncinc-react-kitchen-sink 2.16.1 → 2.16.3

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.
@@ -27,7 +27,8 @@ var Select = function Select(props) {
27
27
  var _useExtendedFormikCon = useExtendedFormikContext(),
28
28
  errors = _useExtendedFormikCon.errors,
29
29
  touched = _useExtendedFormikCon.touched,
30
- displayRequiredIndicator = _useExtendedFormikCon.displayRequiredIndicator;
30
+ displayRequiredIndicator = _useExtendedFormikCon.displayRequiredIndicator,
31
+ setFieldTouched = _useExtendedFormikCon.setFieldTouched;
31
32
  var isTouched = getNestedFieldvalue(fieldName, touched);
32
33
  var error = getNestedFieldvalue(fieldName, errors);
33
34
  var errorId = "".concat(props.fieldName, "--error");
@@ -58,7 +59,10 @@ var Select = function Select(props) {
58
59
  required: required,
59
60
  validate: validation,
60
61
  error: error,
61
- errorId: errorId
62
+ errorId: errorId,
63
+ onBlur: function onBlur() {
64
+ setFieldTouched(fieldName, true, false);
65
+ }
62
66
  })));
63
67
  };
64
68
  export default Select;
@@ -1,16 +1,25 @@
1
- var _excluded = ["title", "required", "description", "placeholder", "fieldName", "validation", "onChange", "className", "wrapperClassName", "disabled", "descriptionAboveInput", "children"];
1
+ var _excluded = ["title", "required", "description", "placeholder", "fieldName", "validation", "onChange", "className", "wrapperClassName", "disabled", "showPasswordReveal", "descriptionAboveInput", "children", "type"];
2
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3
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; }
4
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; }
5
11
  import React from 'react';
6
12
  import { Field } from 'formik';
7
13
  import c from 'classnames';
8
14
  import { useTranslation } from 'react-i18next';
15
+ import Icon from '../../Icon';
9
16
  import withMapping from '../../../Context/withMapping';
10
17
  import GenericFormElement from '../GenericFormElement';
11
18
  import { useExtendedFormikContext } from '../FormikWrapper';
12
19
  import getNestedFieldvalue from '../getNestedFieldvalue';
13
20
  import './style.scss';
21
+ var INPUT_TYPE_TEXT = 'text';
22
+ var INPUT_TYPE_PASSWORD = 'password';
14
23
  export var TextField = function TextField(props) {
15
24
  var title = props.title,
16
25
  required = props.required,
@@ -23,10 +32,17 @@ export var TextField = function TextField(props) {
23
32
  wrapperClassName = props.wrapperClassName,
24
33
  _props$disabled = props.disabled,
25
34
  disabled = _props$disabled === void 0 ? false : _props$disabled,
35
+ _props$showPasswordRe = props.showPasswordReveal,
36
+ showPasswordReveal = _props$showPasswordRe === void 0 ? false : _props$showPasswordRe,
26
37
  descriptionAboveInput = props.descriptionAboveInput,
27
38
  children = props.children,
39
+ type = props.type,
28
40
  restProps = _objectWithoutProperties(props, _excluded);
29
- var type = props.type || 'text';
41
+ var _React$useState = React.useState(false),
42
+ _React$useState2 = _slicedToArray(_React$useState, 2),
43
+ revealPassword = _React$useState2[0],
44
+ setRevealPassword = _React$useState2[1];
45
+ var inputType = type || INPUT_TYPE_TEXT;
30
46
  var _useTranslation = useTranslation(),
31
47
  t = _useTranslation.t;
32
48
  var handleValidation = function handleValidation(value) {
@@ -57,32 +73,55 @@ export var TextField = function TextField(props) {
57
73
  var errorId = "".concat(props.fieldName, "--error");
58
74
  var descriptionId = "".concat(props.fieldName, "--description");
59
75
  return /*#__PURE__*/React.createElement(GenericFormElement, {
60
- className: c('TextField', wrapperClassName),
76
+ className: c('TextField', wrapperClassName, {
77
+ 'RevealPassword': inputType === INPUT_TYPE_PASSWORD
78
+ }),
79
+ touched: isTouched,
61
80
  title: title,
81
+ error: error,
62
82
  required: required,
63
- description: description,
64
83
  fieldName: fieldName,
65
- touched: isTouched,
66
- error: error,
67
- errorId: errorId,
68
- descriptionId: descriptionId,
84
+ description: description,
85
+ descriptionAboveInput: descriptionAboveInput,
69
86
  displayRequiredIndicator: displayRequiredIndicator,
70
- descriptionAboveInput: descriptionAboveInput
87
+ descriptionId: descriptionId,
88
+ errorId: errorId
71
89
  }, /*#__PURE__*/React.createElement(Field, _extends({}, restProps, {
72
90
  className: c(className, {
73
- 'error': error && isTouched
91
+ 'error': error && isTouched,
92
+ 'RevealPassword': inputType === INPUT_TYPE_PASSWORD
74
93
  }),
75
94
  id: fieldName,
76
95
  name: fieldName,
77
- type: type,
78
- value: value,
79
- placeholder: placeholder,
80
96
  validate: handleValidation,
81
97
  onKeyUp: handleChange,
98
+ "aria-describedby": "".concat(errorId, " ").concat(descriptionId),
99
+ "aria-invalid": Boolean(error && isTouched),
100
+ type: revealPassword ? 'text' : inputType,
101
+ value: value,
82
102
  disabled: disabled,
83
103
  required: required,
84
- "aria-describedby": "".concat(errorId, " ").concat(descriptionId),
85
- "aria-invalid": Boolean(error && isTouched)
86
- })), children);
104
+ placeholder: placeholder
105
+ })), children, inputType === 'password' && showPasswordReveal && /*#__PURE__*/React.createElement(RevealPasswordButton, {
106
+ onHandleRevealPassword: setRevealPassword,
107
+ revealPassword: revealPassword
108
+ }));
109
+ };
110
+ var RevealPasswordButton = function RevealPasswordButton(_ref) {
111
+ var onHandleRevealPassword = _ref.onHandleRevealPassword,
112
+ revealPassword = _ref.revealPassword;
113
+ var _useTranslation2 = useTranslation(),
114
+ t = _useTranslation2.t;
115
+ return /*#__PURE__*/React.createElement("button", {
116
+ onClick: function onClick() {
117
+ return onHandleRevealPassword(!revealPassword);
118
+ },
119
+ className: "RevealPasswordButton",
120
+ type: "button",
121
+ "aria-label": t('form.revealPassword')
122
+ }, /*#__PURE__*/React.createElement(Icon, {
123
+ name: revealPassword ? 'visibility_off' : 'visibility',
124
+ flair: "outlined"
125
+ }));
87
126
  };
88
127
  export default withMapping(TextField);
@@ -1,4 +1,17 @@
1
+ @import "../../Icon/style";
2
+
3
+ $material-icon-names: (visibility, visibility_off);
4
+
5
+ @include generateMaterialIconClasses;
6
+
1
7
  .TextField {
8
+ &.RevealPassword__inner {
9
+ display: grid;
10
+ grid-template-columns: 1fr auto;
11
+ grid-template-areas: "field button";
12
+ border: solid 1px #888888;
13
+ }
14
+
2
15
  input {
3
16
  width: 100%;
4
17
  font-size: 1.8rem;
@@ -7,7 +20,30 @@
7
20
  color: #939393;
8
21
  padding: 1.2rem 5rem 1.4rem 2rem;
9
22
  border-radius: 5px;
10
- border: solid 1px #888888;
11
23
  background-color: #ffffff;
24
+ border: 1px solid #888888;
25
+
26
+ &.RevealPassword {
27
+ grid-area: field;
28
+ outline: none;
29
+ border: none;
30
+
31
+ &:hover {
32
+ border: none;
33
+ }
34
+ }
35
+ }
36
+
37
+ .RevealPasswordButton {
38
+ grid-area: button;
39
+ appearance: auto;
40
+ border: none;
41
+ background: none;
42
+ font-size: 110%;
43
+ padding-right: 20px;
44
+
45
+ & > .Icon {
46
+ margin-bottom: 0;
47
+ }
12
48
  }
13
49
  }
@@ -21,7 +21,8 @@
21
21
  },
22
22
  "form": {
23
23
  "required": "required",
24
- "optional": "optional"
24
+ "optional": "optional",
25
+ "revealPassword" : "Show password"
25
26
  },
26
27
  "searchkit": {
27
28
  "reset_search": "Reconfigure search"
@@ -55,7 +55,8 @@
55
55
  },
56
56
  "form": {
57
57
  "required": "vereist",
58
- "optional": "optioneel"
58
+ "optional": "optioneel",
59
+ "revealPassword": "Laat wachtwoord zien"
59
60
  },
60
61
  "searchkit": {
61
62
  "reset_search": "Zoeken opnieuw instellen"
@@ -84,4 +85,4 @@
84
85
  "of": "van"
85
86
  }
86
87
  }
87
- }
88
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.16.1",
3
+ "version": "2.16.3",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",