@true-engineering/true-react-common-ui-kit 4.0.0-alpha63 → 4.0.0-alpha64

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,6 +2,7 @@ import { RefCallback } from 'react';
2
2
  export interface IResizeRefOptions {
3
3
  /** @default false */
4
4
  isDisabled?: boolean;
5
- onChange: (entry: ResizeObserverEntry) => void;
5
+ onChange?: (entry: ResizeObserverEntry) => void;
6
+ onTargetChange?: (target: Element) => void;
6
7
  }
7
8
  export declare const useResizeRef: (options: IResizeRefOptions) => RefCallback<Element>;
@@ -2717,13 +2717,18 @@ const useResizeRef = (options) => {
2717
2717
  const observer = new ResizeObserver(([entry]) => {
2718
2718
  const { current } = optionsRef;
2719
2719
  if (!current.isDisabled) {
2720
- current?.onChange(entry);
2720
+ current.onChange?.(entry);
2721
+ current.onTargetChange?.(entry.target);
2721
2722
  }
2722
2723
  });
2723
2724
  const observerRef = (node) => {
2724
2725
  observer.disconnect();
2725
- if (isNotEmpty(node)) {
2726
- observer.observe(node);
2726
+ if (!isNotEmpty(node)) {
2727
+ return;
2728
+ }
2729
+ observer.observe(node);
2730
+ if (!optionsRef.current.isDisabled) {
2731
+ optionsRef.current.onTargetChange?.(node);
2727
2732
  }
2728
2733
  };
2729
2734
  return { ref: observerRef, disconnect: () => observer.disconnect() };
@@ -4148,13 +4153,9 @@ const ControlWrapper = ({
4148
4153
  className: "tweakPreloader",
4149
4154
  currentComponentName: "ControlWrapper"
4150
4155
  });
4151
- const startControlsRef = useCallback(
4152
- (node) => {
4153
- setStartControlsWidth(node?.clientWidth);
4154
- },
4155
- // eslint-disable-next-line react-hooks/exhaustive-deps
4156
- [startIcon, size2]
4157
- );
4156
+ const startControlsRef = useResizeRef({
4157
+ onTargetChange: (target) => setStartControlsWidth(target.clientWidth)
4158
+ });
4158
4159
  const renderIconControl = ({ key, iconComponent, onClick, shouldResetSize = false }, iconType, index) => /* @__PURE__ */ jsx(
4159
4160
  "div",
4160
4161
  {
@@ -4376,12 +4377,9 @@ const InputBase = forwardRef(function InputBase2({
4376
4377
  await onChange("", event, "clear");
4377
4378
  inputRef.current?.focus();
4378
4379
  };
4379
- const unitsRef = useCallback(
4380
- (node) => {
4381
- setUnitsWidth(node?.clientWidth);
4382
- },
4383
- [units]
4384
- );
4380
+ const unitsRef = useResizeRef({
4381
+ onTargetChange: (target) => setUnitsWidth(target.clientWidth)
4382
+ });
4385
4383
  const props = {
4386
4384
  className: clsx(classes.input, {
4387
4385
  [classes.withUnits]: hasUnits,