@true-engineering/true-react-common-ui-kit 4.0.0-alpha61 → 4.0.0-alpha62

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,9 +1,10 @@
1
1
  import { FC, KeyboardEvent, MouseEvent } from 'react';
2
2
  import { ICommonProps } from '../../types';
3
- import { IListItem } from './types';
3
+ import { IListItem, IListSize } from './types';
4
4
  import { IListStyles } from './List.styles';
5
5
  export interface IListProps extends ICommonProps<IListStyles> {
6
6
  items: IListItem[];
7
+ size?: IListSize;
7
8
  onClick?: (event: MouseEvent | KeyboardEvent) => void;
8
9
  }
9
10
  export declare const List: FC<IListProps>;
@@ -1,5 +1,6 @@
1
1
  import { ITweakStyles } from '../../theme';
2
2
  import { IWithPopupStyles } from '../WithPopup';
3
+ import { IListSizes } from './types';
3
4
  export declare const useStyles: import('../../theme').IUseStyles<"root" | "nestedItems">;
4
5
  export declare const withPopupStyles: IWithPopupStyles;
5
- export type IListStyles = ITweakStyles<typeof useStyles>;
6
+ export type IListStyles = ITweakStyles<typeof useStyles, IListSizes>;
@@ -1,12 +1,14 @@
1
1
  import { FC, MouseEvent, KeyboardEvent, ReactNode } from 'react';
2
2
  import { ICommonProps } from '../../../../types';
3
3
  import { IIcon } from '../../../Icon';
4
+ import { IListSize as IListItemSize } from '../../types';
4
5
  import { IListItemStyles } from './ListItem.styles';
5
6
  export interface IListItemProps extends ICommonProps<IListItemStyles> {
6
7
  item: ReactNode;
7
8
  view?: 'default' | 'destructive';
8
9
  icon?: IIcon;
9
10
  nestedItems?: IListItemProps[];
11
+ size?: IListItemSize;
10
12
  isFocused?: boolean;
11
13
  disabled?: boolean;
12
14
  shouldDrawSpacerAbove?: boolean;
@@ -1,3 +1,4 @@
1
1
  import { ITweakStyles } from '../../../../theme';
2
+ import { IListSizes as IListItemSizes } from '../../types';
2
3
  export declare const useStyles: import('../../../../theme').IUseStyles<"content" | "root" | "default" | "destructive" | "focused" | "disabledItem" | "spacer" | "withIconGap" | "icon">;
3
- export type IListItemStyles = ITweakStyles<typeof useStyles>;
4
+ export type IListItemStyles = ITweakStyles<typeof useStyles, IListItemSizes>;
@@ -1,4 +1,4 @@
1
1
  export * from './List';
2
2
  export type { IListStyles } from './List.styles';
3
- export type { IListItem } from './types';
3
+ export * from './types';
4
4
  export { type IListItemStyles, type IListItemProps, ListItem } from './components';
@@ -1,4 +1,8 @@
1
1
  import { IListItemProps } from './components';
2
+ export interface IListSizes {
3
+ }
4
+ export type IListSize = keyof IListSizes;
2
5
  export interface IListItem extends IListItemProps {
3
6
  isHidden?: boolean;
7
+ size?: IListSize;
4
8
  }
@@ -1,10 +1,13 @@
1
1
  import { FC } from 'react';
2
- import { ICommonProps } from '../../types';
3
- import { IListItem } from '../List';
2
+ import { ICommonProps, IRenderNode } from '../../types';
3
+ import { IListItem, IListSize } from '../List';
4
4
  import { IWithPopupProps } from '../WithPopup';
5
+ import { IWithPopupTriggerProps } from '../WithPopup/types';
5
6
  import { INewMoreMenuStyles } from './NewMoreMenu.styles';
6
7
  export interface INewMoreMenuProps extends Pick<IWithPopupProps, 'placement' | 'middlewares' | 'shouldHideOnScroll' | 'shouldRenderInBody' | 'canBeFlipped' | 'onToggle'>, ICommonProps<INewMoreMenuStyles> {
7
8
  items: IListItem[];
9
+ renderTrigger?: IRenderNode<IWithPopupTriggerProps>;
10
+ listSize?: IListSize;
8
11
  /** @default false */
9
12
  isDisabled?: boolean;
10
13
  /** @default true */
@@ -3163,6 +3163,7 @@ const ListItem = ({
3163
3163
  icon,
3164
3164
  item,
3165
3165
  nestedItems,
3166
+ size: size2,
3166
3167
  disabled: isDisabled,
3167
3168
  isFocused,
3168
3169
  shouldDrawSpacerAbove,
@@ -3180,7 +3181,7 @@ const ListItem = ({
3180
3181
  /* @__PURE__ */ jsxs(
3181
3182
  "div",
3182
3183
  {
3183
- className: clsx(classes.root, classes[view], {
3184
+ className: clsx(classes.root, classes[view], isNotEmpty(size2) && classes[size2], {
3184
3185
  [classes.disabledItem]: isDisabled,
3185
3186
  [classes.withIconGap]: withIconGap,
3186
3187
  [classes.focused]: isFocused
@@ -3216,7 +3217,7 @@ const withPopupStyles$1 = {
3216
3217
  width: "100%"
3217
3218
  }
3218
3219
  };
3219
- const List = ({ items, testId, data, tweakStyles, onClick }) => {
3220
+ const List = ({ items, size: size2, testId, data, tweakStyles, onClick }) => {
3220
3221
  const classes = useStyles$U({ theme: tweakStyles });
3221
3222
  const handleItemClick = (event, { onClick: itemOnClick }) => {
3222
3223
  if (isNotEmpty(itemOnClick)) {
@@ -3225,27 +3226,35 @@ const List = ({ items, testId, data, tweakStyles, onClick }) => {
3225
3226
  }
3226
3227
  };
3227
3228
  const filteredItems = items.filter(({ isHidden }) => !isHidden);
3228
- return /* @__PURE__ */ jsx("div", { className: classes.root, ...addDataAttributes$1(data, testId), children: filteredItems.map((item, i) => {
3229
- const itemProps = {
3230
- testId: getTestId(testId, `item-${i}`),
3231
- ...item,
3232
- shouldDrawSpacerAbove: item.shouldDrawSpacerAbove && i !== 0,
3233
- shouldDrawSpacerBelow: item.shouldDrawSpacerBelow && i !== items.length - 1,
3234
- onClick: (event) => handleItemClick(event, item)
3235
- };
3236
- return /* @__PURE__ */ jsx(Fragment$1, { children: isArrayNotEmpty(item.nestedItems) ? /* @__PURE__ */ jsx(
3237
- WithPopup,
3238
- {
3239
- eventType: "hover",
3240
- tweakStyles: withPopupStyles$1,
3241
- placement: "right-start",
3242
- popupOffset: 0,
3243
- shouldRenderInBody: false,
3244
- trigger: ({ triggerProps }) => /* @__PURE__ */ jsx(ListItem, { ...itemProps, isFocused: triggerProps.isActive }),
3245
- children: /* @__PURE__ */ jsx("div", { className: classes.nestedItems, children: /* @__PURE__ */ jsx(List, { items: item.nestedItems, onClick }) })
3246
- }
3247
- ) : /* @__PURE__ */ jsx(ListItem, { ...itemProps }) }, i);
3248
- }) });
3229
+ return /* @__PURE__ */ jsx(
3230
+ "div",
3231
+ {
3232
+ className: clsx(classes.root, isNotEmpty(size2) && classes[size2]),
3233
+ ...addDataAttributes$1(data, testId),
3234
+ children: filteredItems.map((item, i) => {
3235
+ const itemProps = {
3236
+ testId: getTestId(testId, `item-${i}`),
3237
+ size: size2,
3238
+ ...item,
3239
+ shouldDrawSpacerAbove: item.shouldDrawSpacerAbove && i !== 0,
3240
+ shouldDrawSpacerBelow: item.shouldDrawSpacerBelow && i !== items.length - 1,
3241
+ onClick: (event) => handleItemClick(event, item)
3242
+ };
3243
+ return /* @__PURE__ */ jsx(Fragment$1, { children: isArrayNotEmpty(item.nestedItems) ? /* @__PURE__ */ jsx(
3244
+ WithPopup,
3245
+ {
3246
+ eventType: "hover",
3247
+ tweakStyles: withPopupStyles$1,
3248
+ placement: "right-start",
3249
+ popupOffset: 0,
3250
+ shouldRenderInBody: false,
3251
+ trigger: ({ triggerProps }) => /* @__PURE__ */ jsx(ListItem, { ...itemProps, isFocused: triggerProps.isActive }),
3252
+ children: /* @__PURE__ */ jsx("div", { className: classes.nestedItems, children: /* @__PURE__ */ jsx(List, { items: item.nestedItems, size: size2, onClick }) })
3253
+ }
3254
+ ) : /* @__PURE__ */ jsx(ListItem, { ...itemProps }) }, i);
3255
+ })
3256
+ }
3257
+ );
3249
3258
  };
3250
3259
  const ANIMATION_TIMEOUT = 150;
3251
3260
  const useStyles$T = createThemedStyles("AccountInfo", {
@@ -11902,6 +11911,8 @@ const NewMoreMenu = ({
11902
11911
  isDisabled = false,
11903
11912
  hasDefaultStateBackground = true,
11904
11913
  data,
11914
+ renderTrigger,
11915
+ listSize,
11905
11916
  testId,
11906
11917
  tweakStyles,
11907
11918
  ...rest
@@ -11917,27 +11928,28 @@ const NewMoreMenu = ({
11917
11928
  className: "tweakList",
11918
11929
  currentComponentName: "NewMoreMenu"
11919
11930
  });
11931
+ const defaultTrigger = ({ triggerProps, referenceProps }) => /* @__PURE__ */ jsx(
11932
+ "button",
11933
+ {
11934
+ className: clsx(classes.button, {
11935
+ [classes.hasCircle]: hasDefaultStateBackground,
11936
+ [classes.disabled]: triggerProps.isDisabled,
11937
+ [classes.active]: triggerProps.isActive
11938
+ }),
11939
+ disabled: triggerProps.isDisabled,
11940
+ ...addDataAttributes$1(data, testId),
11941
+ ...referenceProps,
11942
+ children: /* @__PURE__ */ jsx("div", { className: classes.icon, children: /* @__PURE__ */ jsx(Icon, { type: "menu" }) })
11943
+ }
11944
+ );
11920
11945
  return /* @__PURE__ */ jsx(
11921
11946
  WithPopup,
11922
11947
  {
11923
11948
  isDisabled: isDisabled || isArrayEmpty(items),
11924
11949
  tweakStyles: tweakWithPopupStyles,
11925
11950
  ...rest,
11926
- trigger: ({ triggerProps, referenceProps }) => /* @__PURE__ */ jsx(
11927
- "button",
11928
- {
11929
- className: clsx(classes.button, {
11930
- [classes.hasCircle]: hasDefaultStateBackground,
11931
- [classes.disabled]: triggerProps.isDisabled,
11932
- [classes.active]: triggerProps.isActive
11933
- }),
11934
- disabled: triggerProps.isDisabled,
11935
- ...addDataAttributes$1(data, testId),
11936
- ...referenceProps,
11937
- children: /* @__PURE__ */ jsx("div", { className: classes.icon, children: /* @__PURE__ */ jsx(Icon, { type: "menu" }) })
11938
- }
11939
- ),
11940
- children: ({ onClose }) => /* @__PURE__ */ jsx(List, { items, tweakStyles: tweakListStyles, onClick: onClose })
11951
+ trigger: renderTrigger ?? defaultTrigger,
11952
+ children: ({ onClose }) => /* @__PURE__ */ jsx(List, { items, size: listSize, tweakStyles: tweakListStyles, onClick: onClose })
11941
11953
  }
11942
11954
  );
11943
11955
  };