ab-ui-library 1.39.0-alpha.4 → 1.39.0-alpha.6
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.
|
@@ -2,7 +2,7 @@ import { _ as _extends } from '../../extends-d0c248d6.js';
|
|
|
2
2
|
import { _ as _typeof } from '../../typeof-f5583e42.js';
|
|
3
3
|
import { _ as _toConsumableArray } from '../../toConsumableArray-96c5590c.js';
|
|
4
4
|
import { _ as _slicedToArray } from '../../slicedToArray-31c0261f.js';
|
|
5
|
-
import React, { useState, useRef,
|
|
5
|
+
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
|
6
6
|
import { Chips } from '../Chips/Chips.js';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { ErrorMessage } from '../../helperComponents/ErrorMessage/ErrorMessage.js';
|
|
@@ -64,7 +64,8 @@ var MultiTextareaWithChips = function MultiTextareaWithChips(_ref) {
|
|
|
64
64
|
noOptionsPlaceholderText = _ref$noOptionsPlaceho === void 0 ? 'No more options available' : _ref$noOptionsPlaceho,
|
|
65
65
|
_ref$fieldName = _ref.fieldName,
|
|
66
66
|
fieldName = _ref$fieldName === void 0 ? 'skills' : _ref$fieldName,
|
|
67
|
-
formProps = _ref.formProps
|
|
67
|
+
formProps = _ref.formProps,
|
|
68
|
+
onFormSubmit = _ref.onFormSubmit;
|
|
68
69
|
var _useState = useState(''),
|
|
69
70
|
_useState2 = _slicedToArray(_useState, 2),
|
|
70
71
|
inputValue = _useState2[0],
|
|
@@ -92,11 +93,27 @@ var MultiTextareaWithChips = function MultiTextareaWithChips(_ref) {
|
|
|
92
93
|
var inputRef = useRef(null);
|
|
93
94
|
var containerRef = useRef(null);
|
|
94
95
|
var _useFormProps = useFormProps(),
|
|
95
|
-
setValue = _useFormProps.setValue
|
|
96
|
+
setValue = _useFormProps.setValue,
|
|
97
|
+
isSubmitting = _useFormProps.isSubmitting;
|
|
96
98
|
var chipTexts = localChips.map(function (chip) {
|
|
97
99
|
return typeof chip === 'string' ? chip : chip.text;
|
|
98
100
|
});
|
|
99
101
|
var isUserInteraction = useRef(false);
|
|
102
|
+
|
|
103
|
+
// Function to handle form submission - automatically create chip from remaining text
|
|
104
|
+
useCallback(function () {
|
|
105
|
+
if (inputValue.trim() && allowCustomValues) {
|
|
106
|
+
handleAddCustomValue(inputValue.trim());
|
|
107
|
+
}
|
|
108
|
+
onFormSubmit === null || onFormSubmit === void 0 || onFormSubmit();
|
|
109
|
+
}, [inputValue, allowCustomValues, onFormSubmit]);
|
|
110
|
+
|
|
111
|
+
// Watch for form submission and automatically create chip from remaining text
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
if (isSubmitting && inputValue.trim() && allowCustomValues) {
|
|
114
|
+
handleAddCustomValue(inputValue.trim());
|
|
115
|
+
}
|
|
116
|
+
}, [isSubmitting, inputValue, allowCustomValues]);
|
|
100
117
|
useEffect(function () {
|
|
101
118
|
if (!isUserInteraction.current) {
|
|
102
119
|
setLocalChips(chips);
|
|
@@ -392,6 +409,7 @@ var MultiTextareaWithChips = function MultiTextareaWithChips(_ref) {
|
|
|
392
409
|
}), /*#__PURE__*/React.createElement("div", {
|
|
393
410
|
className: "multi-textarea-chips__input-container"
|
|
394
411
|
}, /*#__PURE__*/React.createElement("input", _extends({}, formProps, {
|
|
412
|
+
autoComplete: "off",
|
|
395
413
|
ref: inputRef,
|
|
396
414
|
type: "text",
|
|
397
415
|
value: inputValue,
|