onekijs-ui 0.19.13 → 0.19.14

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.
@@ -10641,7 +10641,7 @@ const selectColumn = (id, options) => {
10641
10641
  };
10642
10642
 
10643
10643
  const TextareaComponent = (props) => {
10644
- const { className, size = 'medium', status, onFocus: forwardFocus, onBlur: forwardBlur, ...textareaProps } = props;
10644
+ const { className, size = 'medium', status, onFocus: forwardFocus, onBlur: forwardBlur, onChange: forwardChange, value, ...textareaProps } = props;
10645
10645
  const [focus, setFocus] = useState(false);
10646
10646
  const classNames = addClassname(`o-textarea o-textarea-size-${size}${focus ? ' o-textarea-focus' : ''}${status ? ' o-textarea-status-' + status.toLowerCase() : ''}`, className);
10647
10647
  const onFocus = (e) => {
@@ -10652,8 +10652,20 @@ const TextareaComponent = (props) => {
10652
10652
  setFocus(false);
10653
10653
  forwardBlur && forwardBlur(e);
10654
10654
  };
10655
+ const ref = useRef(null);
10656
+ const selectorRef = useRef();
10657
+ const onChange = (e) => {
10658
+ selectorRef.current = e.target.selectionStart;
10659
+ forwardChange && forwardChange(e);
10660
+ };
10661
+ useEffect(() => {
10662
+ if (selectorRef.current !== undefined && selectorRef.current !== null && ref.current) {
10663
+ ref.current.setSelectionRange(selectorRef.current, selectorRef.current);
10664
+ selectorRef.current = undefined;
10665
+ }
10666
+ }, [value]);
10655
10667
  return (React.createElement("div", { className: classNames },
10656
- React.createElement("textarea", { className: "o-textarea-field", ...textareaProps, onFocus: onFocus, onBlur: onBlur })));
10668
+ React.createElement("textarea", { className: "o-textarea-field", ...textareaProps, ref: ref, onFocus: onFocus, onBlur: onBlur, onChange: value === undefined ? undefined : onChange, value: value })));
10657
10669
  };
10658
10670
  TextareaComponent.displayName = 'TextareaComponent';
10659
10671