@true-engineering/true-react-common-ui-kit 4.0.0-alpha62 → 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.
@@ -1,4 +1,4 @@
1
1
  import { ITweakStyles } from '../../../../theme';
2
2
  import { IListSizes as IListItemSizes } from '../../types';
3
- export declare const useStyles: import('../../../../theme').IUseStyles<"content" | "root" | "default" | "destructive" | "focused" | "disabledItem" | "spacer" | "withIconGap" | "icon">;
3
+ export declare const useStyles: import('../../../../theme').IUseStyles<"content" | "root" | "default" | "destructive" | "focused" | "disabledItem" | "spacer" | "withIconGap" | "icon" | "chevron">;
4
4
  export type IListItemStyles = ITweakStyles<typeof useStyles, IListItemSizes>;
@@ -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() };
@@ -3157,7 +3162,8 @@ const useStyles$V = createThemedStyles("ListItem", {
3157
3162
  },
3158
3163
  content: {
3159
3164
  flexGrow: 1
3160
- }
3165
+ },
3166
+ chevron: {}
3161
3167
  });
3162
3168
  const ListItem = ({
3163
3169
  icon,
@@ -3191,7 +3197,7 @@ const ListItem = ({
3191
3197
  children: [
3192
3198
  isReactNodeNotEmpty(icon) && /* @__PURE__ */ jsx("span", { className: classes.icon, children: renderIcon(icon) }),
3193
3199
  /* @__PURE__ */ jsx("span", { className: classes.content, children: item }),
3194
- isArrayNotEmpty(nestedItems) && /* @__PURE__ */ jsx("span", { className: classes.icon, children: /* @__PURE__ */ jsx(Icon, { type: "chevron-right" }) })
3200
+ isArrayNotEmpty(nestedItems) && /* @__PURE__ */ jsx("span", { className: clsx(classes.icon, classes.chevron), children: /* @__PURE__ */ jsx(Icon, { type: "chevron-right" }) })
3195
3201
  ]
3196
3202
  }
3197
3203
  ),
@@ -4147,13 +4153,9 @@ const ControlWrapper = ({
4147
4153
  className: "tweakPreloader",
4148
4154
  currentComponentName: "ControlWrapper"
4149
4155
  });
4150
- const startControlsRef = useCallback(
4151
- (node) => {
4152
- setStartControlsWidth(node?.clientWidth);
4153
- },
4154
- // eslint-disable-next-line react-hooks/exhaustive-deps
4155
- [startIcon, size2]
4156
- );
4156
+ const startControlsRef = useResizeRef({
4157
+ onTargetChange: (target) => setStartControlsWidth(target.clientWidth)
4158
+ });
4157
4159
  const renderIconControl = ({ key, iconComponent, onClick, shouldResetSize = false }, iconType, index) => /* @__PURE__ */ jsx(
4158
4160
  "div",
4159
4161
  {
@@ -4375,12 +4377,9 @@ const InputBase = forwardRef(function InputBase2({
4375
4377
  await onChange("", event, "clear");
4376
4378
  inputRef.current?.focus();
4377
4379
  };
4378
- const unitsRef = useCallback(
4379
- (node) => {
4380
- setUnitsWidth(node?.clientWidth);
4381
- },
4382
- [units]
4383
- );
4380
+ const unitsRef = useResizeRef({
4381
+ onTargetChange: (target) => setUnitsWidth(target.clientWidth)
4382
+ });
4384
4383
  const props = {
4385
4384
  className: clsx(classes.input, {
4386
4385
  [classes.withUnits]: hasUnits,