@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.js
CHANGED
|
@@ -4945,10 +4945,39 @@ const borderColorClasses$3 = [
|
|
|
4945
4945
|
/**
|
|
4946
4946
|
* TextArea.
|
|
4947
4947
|
*/
|
|
4948
|
-
const TextArea = ({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }) => {
|
|
4948
|
+
const TextArea = React.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) => {
|
|
4949
4949
|
const appliedClasses = `${baseClasses$4} ${extraClassNames} ${lightTheme$2} ${darkTheme$2} ${showError ? errorClasses$3 : borderColorClasses$3}`;
|
|
4950
|
-
|
|
4951
|
-
|
|
4950
|
+
const textareaRef = React.useRef(null);
|
|
4951
|
+
// Handle selection change events
|
|
4952
|
+
React.useEffect(() => {
|
|
4953
|
+
if (!onSelectionChange || !textareaRef.current) {
|
|
4954
|
+
return;
|
|
4955
|
+
}
|
|
4956
|
+
const textarea = textareaRef.current;
|
|
4957
|
+
const handleSelectionChange = (e) => {
|
|
4958
|
+
onSelectionChange(e);
|
|
4959
|
+
};
|
|
4960
|
+
// Add event listeners for selection changes
|
|
4961
|
+
textarea.addEventListener('selectionchange', handleSelectionChange);
|
|
4962
|
+
// Also listen for mouse and keyboard events that change selection
|
|
4963
|
+
textarea.addEventListener('mouseup', handleSelectionChange);
|
|
4964
|
+
textarea.addEventListener('keyup', handleSelectionChange);
|
|
4965
|
+
return () => {
|
|
4966
|
+
textarea.removeEventListener('selectionchange', handleSelectionChange);
|
|
4967
|
+
textarea.removeEventListener('mouseup', handleSelectionChange);
|
|
4968
|
+
textarea.removeEventListener('keyup', handleSelectionChange);
|
|
4969
|
+
};
|
|
4970
|
+
}, [onSelectionChange]);
|
|
4971
|
+
return (jsxRuntime.jsx("textarea", { ref: (element) => {
|
|
4972
|
+
textareaRef.current = element;
|
|
4973
|
+
if (typeof ref === 'function') {
|
|
4974
|
+
ref(element);
|
|
4975
|
+
}
|
|
4976
|
+
else if (ref) {
|
|
4977
|
+
ref.current = element;
|
|
4978
|
+
}
|
|
4979
|
+
}, "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 }));
|
|
4980
|
+
});
|
|
4952
4981
|
|
|
4953
4982
|
/**
|
|
4954
4983
|
* @deprecated
|