iguazio.dashboard-react-controls 0.0.6 → 0.0.9

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 (33) hide show
  1. package/dist/components/FormCheckBox/FormCheckBox.js +57 -0
  2. package/dist/components/FormCheckBox/formCheckBox.scss +33 -0
  3. package/dist/components/FormInput/FormInput.js +447 -0
  4. package/dist/components/FormInput/formInput.scss +93 -0
  5. package/dist/components/FormKeyValueTable/FormKeyValueTable.js +353 -0
  6. package/dist/components/FormKeyValueTable/formKeyValueTable.scss +117 -0
  7. package/dist/components/FormSelect/FormSelect.js +342 -0
  8. package/dist/components/FormSelect/FormSelect.test.js +158 -0
  9. package/dist/components/FormSelect/formSelect.scss +93 -0
  10. package/dist/components/Modal/Modal.js +9 -12
  11. package/dist/components/Tip/Tip.js +132 -0
  12. package/dist/components/Tip/Tip.test.js +96 -0
  13. package/dist/components/Tip/tip.scss +89 -0
  14. package/dist/components/Wizard/Wizard.js +50 -81
  15. package/dist/components/Wizard/Wizard.scss +11 -13
  16. package/dist/components/index.js +40 -0
  17. package/dist/constants.js +20 -2
  18. package/dist/elements/OptionsMenu/OptionsMenu.js +63 -0
  19. package/dist/elements/OptionsMenu/optionsMenu.scss +49 -0
  20. package/dist/elements/SelectOption/SelectOption.js +95 -0
  21. package/dist/elements/SelectOption/SelectOption.test.js +99 -0
  22. package/dist/elements/SelectOption/selectOption.scss +61 -0
  23. package/dist/elements/ValidationTemplate/ValidationTemplate.js +48 -0
  24. package/dist/elements/ValidationTemplate/ValidationTemplate.scss +36 -0
  25. package/dist/elements/index.js +31 -0
  26. package/dist/hooks/index.js +13 -0
  27. package/dist/hooks/useDetectOutsideClick.js +34 -0
  28. package/dist/index.js +13 -5
  29. package/dist/scss/mixins.scss +98 -23
  30. package/dist/types.js +34 -2
  31. package/dist/utils/form.util.js +22 -0
  32. package/dist/utils/validation.util.js +269 -0
  33. package/package.json +11 -7
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _checkboxUnchecked = require("../../images/checkbox-unchecked.svg");
13
+
14
+ var _checkboxChecked = require("../../images/checkbox-checked.svg");
15
+
16
+ require("./formCheckBox.scss");
17
+
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ var FormCheckBox = function FormCheckBox(_ref) {
23
+ var children = _ref.children,
24
+ className = _ref.className,
25
+ item = _ref.item,
26
+ onChange = _ref.onChange,
27
+ selectedId = _ref.selectedId;
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
29
+ className: "checkbox ".concat(className),
30
+ onClick: function onClick() {
31
+ onChange(item.id);
32
+ },
33
+ children: [item.id === selectedId ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkboxChecked.ReactComponent, {
34
+ className: "checked"
35
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkboxUnchecked.ReactComponent, {
36
+ className: "unchecked"
37
+ }), children || item.label]
38
+ });
39
+ };
40
+
41
+ FormCheckBox.defaultProps = {
42
+ className: '',
43
+ selectedId: ''
44
+ };
45
+ FormCheckBox.propTypes = {
46
+ className: _propTypes.default.string,
47
+ item: _propTypes.default.shape({
48
+ id: _propTypes.default.string.isRequired,
49
+ label: _propTypes.default.string
50
+ }).isRequired,
51
+ onChange: _propTypes.default.func.isRequired,
52
+ selectedId: _propTypes.default.string
53
+ };
54
+
55
+ var _default = /*#__PURE__*/_react.default.memo(FormCheckBox);
56
+
57
+ exports.default = _default;
@@ -0,0 +1,33 @@
1
+ @import '../../scss/colors';
2
+
3
+ .checkbox {
4
+ display: flex;
5
+ align-items: center;
6
+ color: $primary;
7
+ cursor: pointer;
8
+
9
+ &__label {
10
+ flex: 1;
11
+ font-size: 14px;
12
+
13
+ &-tip {
14
+ margin-left: 5px;
15
+ }
16
+ }
17
+
18
+ svg {
19
+ margin-right: 5px;
20
+
21
+ &.checked {
22
+ path {
23
+ fill: $malibu;
24
+ }
25
+ }
26
+
27
+ &.unchecked {
28
+ path {
29
+ fill: $spunPearl;
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,447 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ var _lodash = require("lodash");
17
+
18
+ var _reactFinalForm = require("react-final-form");
19
+
20
+ var _OptionsMenu = _interopRequireDefault(require("../../elements/OptionsMenu/OptionsMenu"));
21
+
22
+ var _TextTooltipTemplate = _interopRequireDefault(require("../TooltipTemplate/TextTooltipTemplate"));
23
+
24
+ var _Tip = _interopRequireDefault(require("../Tip/Tip"));
25
+
26
+ var _Tooltip = _interopRequireDefault(require("../Tooltip/Tooltip"));
27
+
28
+ var _ValidationTemplate = _interopRequireDefault(require("../../elements/ValidationTemplate/ValidationTemplate"));
29
+
30
+ var _validation = require("../../utils/validation.util");
31
+
32
+ var _useDetectOutsideClick = require("../../hooks/useDetectOutsideClick");
33
+
34
+ var _types = require("../../types");
35
+
36
+ var _invalid = require("../../images/invalid.svg");
37
+
38
+ var _popout = require("../../images/popout.svg");
39
+
40
+ var _warning = require("../../images/warning.svg");
41
+
42
+ require("./formInput.scss");
43
+
44
+ var _jsxRuntime = require("react/jsx-runtime");
45
+
46
+ var _excluded = ["className", "density", "disabled", "focused", "iconClass", "inputIcon", "invalidText", "label", "link", "name", "onBlur", "onChange", "pattern", "required", "suggestionList", "tip", "validationRules", "validator", "withoutBorder"];
47
+
48
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
49
+
50
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
51
+
52
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
53
+
54
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
55
+
56
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
57
+
58
+ 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; }
59
+
60
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
61
+
62
+ 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."); }
63
+
64
+ 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); }
65
+
66
+ 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; }
67
+
68
+ 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; }
69
+
70
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
71
+
72
+ 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; }
73
+
74
+ 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; }
75
+
76
+ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
77
+ var _ref2;
78
+
79
+ var className = _ref.className,
80
+ density = _ref.density,
81
+ disabled = _ref.disabled,
82
+ focused = _ref.focused,
83
+ iconClass = _ref.iconClass,
84
+ inputIcon = _ref.inputIcon,
85
+ invalidText = _ref.invalidText,
86
+ label = _ref.label,
87
+ link = _ref.link,
88
+ name = _ref.name,
89
+ onBlur = _ref.onBlur,
90
+ onChange = _ref.onChange,
91
+ pattern = _ref.pattern,
92
+ required = _ref.required,
93
+ suggestionList = _ref.suggestionList,
94
+ tip = _ref.tip,
95
+ rules = _ref.validationRules,
96
+ validator = _ref.validator,
97
+ withoutBorder = _ref.withoutBorder,
98
+ inputProps = _objectWithoutProperties(_ref, _excluded);
99
+
100
+ var _useField = (0, _reactFinalForm.useField)(name),
101
+ input = _useField.input,
102
+ meta = _useField.meta;
103
+
104
+ var _useState = (0, _react.useState)(false),
105
+ _useState2 = _slicedToArray(_useState, 2),
106
+ isInvalid = _useState2[0],
107
+ setIsInvalid = _useState2[1];
108
+
109
+ var _useState3 = (0, _react.useState)(false),
110
+ _useState4 = _slicedToArray(_useState3, 2),
111
+ isFocused = _useState4[0],
112
+ setIsFocused = _useState4[1];
113
+
114
+ var _useState5 = (0, _react.useState)(''),
115
+ _useState6 = _slicedToArray(_useState5, 2),
116
+ typedValue = _useState6[0],
117
+ setTypedValue = _useState6[1];
118
+
119
+ var _useState7 = (0, _react.useState)(RegExp(pattern)),
120
+ _useState8 = _slicedToArray(_useState7, 1),
121
+ validationPattern = _useState8[0];
122
+
123
+ var _useState9 = (0, _react.useState)(rules),
124
+ _useState10 = _slicedToArray(_useState9, 2),
125
+ validationRules = _useState10[0],
126
+ setValidationRules = _useState10[1];
127
+
128
+ var _useState11 = (0, _react.useState)(false),
129
+ _useState12 = _slicedToArray(_useState11, 2),
130
+ showValidationRules = _useState12[0],
131
+ setShowValidationRules = _useState12[1];
132
+
133
+ var wrapperRef = (0, _react.useRef)();
134
+ (_ref2 = ref) !== null && _ref2 !== void 0 ? _ref2 : ref = wrapperRef;
135
+ var inputRef = (0, _react.useRef)();
136
+ (0, _useDetectOutsideClick.useDetectOutsideClick)(ref, function () {
137
+ return setShowValidationRules(false);
138
+ });
139
+ var formFieldClassNames = (0, _classnames.default)('form-field', className);
140
+ var inputWrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
141
+ var labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
142
+ (0, _react.useEffect)(function () {
143
+ setTypedValue(String(input.value)); // convert from number to string
144
+ }, [input.value]);
145
+ (0, _react.useEffect)(function () {
146
+ setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
147
+ }, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
148
+ (0, _react.useEffect)(function () {
149
+ if (meta.valid && showValidationRules) {
150
+ setShowValidationRules(false);
151
+ }
152
+ }, [meta.valid, showValidationRules]);
153
+ (0, _react.useEffect)(function () {
154
+ if (showValidationRules) {
155
+ window.addEventListener('scroll', handleScroll, true);
156
+ }
157
+
158
+ return function () {
159
+ window.removeEventListener('scroll', handleScroll, true);
160
+ };
161
+ }, [showValidationRules]);
162
+ (0, _react.useEffect)(function () {
163
+ if (focused) {
164
+ inputRef.current.focus();
165
+ }
166
+ }, [focused]);
167
+
168
+ var getValidationRules = function getValidationRules() {
169
+ return validationRules.map(function (_ref3) {
170
+ var _ref3$isValid = _ref3.isValid,
171
+ isValid = _ref3$isValid === void 0 ? false : _ref3$isValid,
172
+ label = _ref3.label,
173
+ name = _ref3.name;
174
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ValidationTemplate.default, {
175
+ valid: isValid,
176
+ validationMessage: label
177
+ }, name);
178
+ });
179
+ };
180
+
181
+ var handleInputBlur = function handleInputBlur(event) {
182
+ var _event$relatedTarget;
183
+
184
+ input.onBlur(event);
185
+
186
+ if (!event.relatedTarget || !((_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 && _event$relatedTarget.closest('.form-field__suggestion-list'))) {
187
+ setIsFocused(false);
188
+ onBlur && onBlur(event);
189
+ }
190
+ };
191
+
192
+ var handleInputChange = function handleInputChange(event) {
193
+ input.onChange(event);
194
+ onChange && onChange(event.target.value);
195
+ };
196
+
197
+ var handleInputFocus = function handleInputFocus(event) {
198
+ input.onFocus(event);
199
+ setIsFocused(true);
200
+ };
201
+
202
+ var handleScroll = function handleScroll(event) {
203
+ if (!event.target.closest('.options-menu') && !event.target.classList.contains('form-field')) {
204
+ setShowValidationRules(false);
205
+ }
206
+ };
207
+
208
+ var handleSuggestionClick = function handleSuggestionClick(item) {
209
+ input.onChange && input.onChange(item);
210
+ setIsFocused(false);
211
+ onBlur();
212
+ };
213
+
214
+ var toggleValidationRulesMenu = function toggleValidationRulesMenu() {
215
+ inputRef.current.focus();
216
+ setShowValidationRules(!showValidationRules);
217
+ };
218
+
219
+ (0, _react.useEffect)(function () {
220
+ setValidationRules(function (prevState) {
221
+ return prevState.map(function (rule) {
222
+ return _objectSpread(_objectSpread({}, rule), {}, {
223
+ isValid: !meta.error || !Array.isArray(meta.error) ? true : !meta.error.some(function (err) {
224
+ return err.name === rule.name;
225
+ })
226
+ });
227
+ });
228
+ });
229
+ }, [meta.error]);
230
+
231
+ var validateField = function validateField(value) {
232
+ var valueToValidate = value !== null && value !== void 0 ? value : '';
233
+ var validationError = null;
234
+
235
+ if (!(0, _lodash.isEmpty)(validationRules)) {
236
+ var _checkPatternsValidit = (0, _validation.checkPatternsValidity)(rules, valueToValidate),
237
+ _checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 2),
238
+ newRules = _checkPatternsValidit2[0],
239
+ isValidField = _checkPatternsValidit2[1];
240
+
241
+ var invalidRules = newRules.filter(function (rule) {
242
+ return !rule.isValid;
243
+ });
244
+
245
+ if (!isValidField) {
246
+ validationError = invalidRules.map(function (rule) {
247
+ return {
248
+ name: rule.name,
249
+ label: rule.label
250
+ };
251
+ });
252
+ }
253
+ }
254
+
255
+ if ((0, _lodash.isEmpty)(validationError)) {
256
+ if (pattern && !validationPattern.test(valueToValidate)) {
257
+ validationError = {
258
+ name: 'pattern',
259
+ label: invalidText
260
+ };
261
+ } else if (valueToValidate.startsWith(' ')) {
262
+ validationError = {
263
+ name: 'empty',
264
+ label: invalidText
265
+ };
266
+ } else if (required && valueToValidate.trim().length === 0) {
267
+ validationError = {
268
+ name: 'required',
269
+ label: 'This field is required'
270
+ };
271
+ }
272
+ }
273
+
274
+ if (!validationError && validator) {
275
+ validationError = validator(value);
276
+ }
277
+
278
+ return validationError;
279
+ };
280
+
281
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
282
+ validate: validateField,
283
+ name: name,
284
+ children: function children(_ref4) {
285
+ var _inputProps$autocompl, _meta$error$label, _meta$error;
286
+
287
+ var input = _ref4.input,
288
+ meta = _ref4.meta;
289
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
290
+ ref: ref,
291
+ className: formFieldClassNames,
292
+ children: [label && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
293
+ className: labelClassNames,
294
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
295
+ "data-testid": "label",
296
+ htmlFor: input.name,
297
+ children: [label, (required || validationRules.find(function (rule) {
298
+ return rule.name === 'required';
299
+ })) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
300
+ className: "form-field__label-mandatory",
301
+ children: " *"
302
+ })]
303
+ }), link && link.show && typedValue.trim() && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
304
+ className: "form-field__label-icon",
305
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
306
+ template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
307
+ text: link.url || typedValue
308
+ }),
309
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
310
+ href: link.url || typedValue,
311
+ onClick: function onClick(event) {
312
+ return event.stopPropagation();
313
+ },
314
+ target: "_blank",
315
+ rel: "noreferrer",
316
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_popout.ReactComponent, {})
317
+ })
318
+ })
319
+ })]
320
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
321
+ className: inputWrapperClassNames,
322
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
323
+ className: "form-field__control",
324
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
325
+ "data-testid": "input",
326
+ id: input.name,
327
+ ref: inputRef,
328
+ required: isInvalid || required
329
+ }, _objectSpread(_objectSpread({
330
+ disabled: disabled,
331
+ pattern: pattern
332
+ }, inputProps), input)), {}, {
333
+ autoComplete: (_inputProps$autocompl = inputProps.autocomplete) !== null && _inputProps$autocompl !== void 0 ? _inputProps$autocompl : 'off',
334
+ onChange: handleInputChange,
335
+ onBlur: handleInputBlur,
336
+ onFocus: handleInputFocus
337
+ }))
338
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
339
+ className: "form-field__icons",
340
+ children: [isInvalid && !Array.isArray(meta.error) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
341
+ className: "form-field__warning",
342
+ template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
343
+ text: (_meta$error$label = (_meta$error = meta.error) === null || _meta$error === void 0 ? void 0 : _meta$error.label) !== null && _meta$error$label !== void 0 ? _meta$error$label : invalidText,
344
+ warning: true
345
+ }),
346
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_invalid.ReactComponent, {})
347
+ }), isInvalid && Array.isArray(meta.error) && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
348
+ className: "form-field__warning",
349
+ onClick: toggleValidationRulesMenu,
350
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_warning.ReactComponent, {})
351
+ }), tip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tip.default, {
352
+ text: tip,
353
+ className: "form-field__tip"
354
+ }), inputIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
355
+ "data-testid": "input-icon",
356
+ className: iconClass,
357
+ children: inputIcon
358
+ })]
359
+ })]
360
+ }), (suggestionList === null || suggestionList === void 0 ? void 0 : suggestionList.length) > 0 && isFocused && /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
361
+ className: "form-field__suggestion-list",
362
+ children: suggestionList.map(function (item, index) {
363
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
364
+ className: "suggestion-item",
365
+ onClick: function onClick() {
366
+ handleSuggestionClick(item);
367
+ },
368
+ tabIndex: index,
369
+ dangerouslySetInnerHTML: {
370
+ __html: item.replace(new RegExp(typedValue, 'gi'), function (match) {
371
+ return match ? "<b>".concat(match, "</b>") : match;
372
+ })
373
+ }
374
+ }, "".concat(item).concat(index));
375
+ })
376
+ }), !(0, _lodash.isEmpty)(validationRules) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_OptionsMenu.default, {
377
+ show: showValidationRules,
378
+ ref: ref,
379
+ children: getValidationRules()
380
+ })]
381
+ });
382
+ }
383
+ });
384
+ });
385
+
386
+ FormInput.defaultProps = {
387
+ className: '',
388
+ density: 'normal',
389
+ disabled: false,
390
+ focused: false,
391
+ iconClass: '',
392
+ inputIcon: null,
393
+ invalidText: 'This field is invalid',
394
+ label: '',
395
+ link: {
396
+ show: '',
397
+ value: ''
398
+ },
399
+ maxLength: null,
400
+ min: null,
401
+ onBlur: function onBlur() {},
402
+ onChange: function onChange() {},
403
+ onKeyDown: function onKeyDown() {},
404
+ pattern: null,
405
+ placeholder: '',
406
+ required: false,
407
+ step: '',
408
+ suggestionList: [],
409
+ tip: '',
410
+ type: 'text',
411
+ validationRules: [],
412
+ validator: function validator() {},
413
+ value: '',
414
+ withoutBorder: false
415
+ };
416
+ FormInput.propTypes = {
417
+ className: _propTypes.default.string,
418
+ density: _propTypes.default.oneOf(['dense', 'normal', 'medium', 'chunky']),
419
+ disabled: _propTypes.default.bool,
420
+ focused: _propTypes.default.bool,
421
+ iconClass: _propTypes.default.string,
422
+ inputIcon: _propTypes.default.element,
423
+ invalidText: _propTypes.default.string,
424
+ label: _propTypes.default.string,
425
+ link: _types.INPUT_LINK,
426
+ maxLength: _propTypes.default.number,
427
+ min: _propTypes.default.number,
428
+ name: _propTypes.default.string.isRequired,
429
+ onBlur: _propTypes.default.func,
430
+ onChange: _propTypes.default.func,
431
+ onKeyDown: _propTypes.default.func,
432
+ pattern: _propTypes.default.string,
433
+ placeholder: _propTypes.default.string,
434
+ required: _propTypes.default.bool,
435
+ step: _propTypes.default.string,
436
+ suggestionList: _propTypes.default.arrayOf(_propTypes.default.string),
437
+ tip: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
438
+ type: _propTypes.default.string,
439
+ validationRules: _types.INPUT_VALIDATION_RULES,
440
+ validator: _propTypes.default.func,
441
+ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
442
+ withoutBorder: _propTypes.default.bool
443
+ };
444
+
445
+ var _default = /*#__PURE__*/_react.default.memo(FormInput);
446
+
447
+ exports.default = _default;
@@ -0,0 +1,93 @@
1
+ @import '../../scss/colors';
2
+ @import '../../scss/borders';
3
+ @import '../../scss/shadows';
4
+ @import '../../scss/mixins';
5
+
6
+ .form-field {
7
+ @include formField;
8
+
9
+ &__label {
10
+ &-icon {
11
+ display: inline-flex;
12
+ margin-left: 3px;
13
+
14
+ & > *,
15
+ a {
16
+ display: inline-flex;
17
+ }
18
+
19
+ a {
20
+ transform: translateY(-1px);
21
+ }
22
+
23
+ svg {
24
+ width: 12px;
25
+ height: 12px;
26
+
27
+ path {
28
+ fill: $cornflowerBlue;
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ input {
35
+ border: 0;
36
+ color: inherit;
37
+ background-color: transparent;
38
+ padding: 0;
39
+ width: 100%;
40
+
41
+ &::placeholder {
42
+ color: $spunPearl;
43
+ }
44
+
45
+ &::-webkit-input-placeholder {
46
+ /* Chrome/Opera/Safari */
47
+ color: $spunPearl;
48
+ }
49
+
50
+ &::-moz-placeholder {
51
+ /* Firefox 19+ */
52
+ color: $spunPearl;
53
+ }
54
+
55
+ &:-ms-input-placeholder {
56
+ /* IE 10+ */
57
+ color: $spunPearl;
58
+ }
59
+
60
+ &:-moz-placeholder {
61
+ /* Firefox 18- */
62
+ color: $spunPearl;
63
+ }
64
+
65
+ &:disabled {
66
+ background: transparent;
67
+ cursor: not-allowed;
68
+ }
69
+ }
70
+
71
+ &__suggestion-list {
72
+ position: absolute;
73
+ top: 100%;
74
+ left: 0;
75
+ z-index: 5;
76
+ margin: 0;
77
+ padding: 7px 0;
78
+ background-color: $white;
79
+ border-radius: 4px;
80
+ box-shadow: $previewBoxShadow;
81
+
82
+ .suggestion-item {
83
+ padding: 7px 15px;
84
+ color: $mulledWine;
85
+ list-style-type: none;
86
+
87
+ &:hover {
88
+ background-color: $alabaster;
89
+ cursor: pointer;
90
+ }
91
+ }
92
+ }
93
+ }