@seeqdev/qomponents 0.0.166 → 0.0.167
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/dist/index.esm.js +32 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/dist/src/TextArea/TextArea.types.d.ts +11 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4925,10 +4925,39 @@ const borderColorClasses$3 = [
|
|
|
4925
4925
|
/**
|
|
4926
4926
|
* TextArea.
|
|
4927
4927
|
*/
|
|
4928
|
-
const TextArea = ({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }) => {
|
|
4928
|
+
const TextArea = React__default.forwardRef(({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, onSelectionChange, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }, ref) => {
|
|
4929
4929
|
const appliedClasses = `${baseClasses$4} ${extraClassNames} ${lightTheme$2} ${darkTheme$2} ${showError ? errorClasses$3 : borderColorClasses$3}`;
|
|
4930
|
-
|
|
4931
|
-
|
|
4930
|
+
const textareaRef = useRef(null);
|
|
4931
|
+
// Handle selection change events
|
|
4932
|
+
useEffect(() => {
|
|
4933
|
+
if (!onSelectionChange || !textareaRef.current) {
|
|
4934
|
+
return;
|
|
4935
|
+
}
|
|
4936
|
+
const textarea = textareaRef.current;
|
|
4937
|
+
const handleSelectionChange = (e) => {
|
|
4938
|
+
onSelectionChange(e);
|
|
4939
|
+
};
|
|
4940
|
+
// Add event listeners for selection changes
|
|
4941
|
+
textarea.addEventListener('selectionchange', handleSelectionChange);
|
|
4942
|
+
// Also listen for mouse and keyboard events that change selection
|
|
4943
|
+
textarea.addEventListener('mouseup', handleSelectionChange);
|
|
4944
|
+
textarea.addEventListener('keyup', handleSelectionChange);
|
|
4945
|
+
return () => {
|
|
4946
|
+
textarea.removeEventListener('selectionchange', handleSelectionChange);
|
|
4947
|
+
textarea.removeEventListener('mouseup', handleSelectionChange);
|
|
4948
|
+
textarea.removeEventListener('keyup', handleSelectionChange);
|
|
4949
|
+
};
|
|
4950
|
+
}, [onSelectionChange]);
|
|
4951
|
+
return (jsx$1("textarea", { ref: (element) => {
|
|
4952
|
+
textareaRef.current = element;
|
|
4953
|
+
if (typeof ref === 'function') {
|
|
4954
|
+
ref(element);
|
|
4955
|
+
}
|
|
4956
|
+
else if (ref) {
|
|
4957
|
+
ref.current = element;
|
|
4958
|
+
}
|
|
4959
|
+
}, "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
|
|
4960
|
+
});
|
|
4932
4961
|
|
|
4933
4962
|
/**
|
|
4934
4963
|
* @deprecated
|