@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.
- package/dist/components/List/List.d.ts +2 -1
- package/dist/components/List/List.styles.d.ts +2 -1
- package/dist/components/List/components/ListItem/ListItem.d.ts +2 -0
- package/dist/components/List/components/ListItem/ListItem.styles.d.ts +2 -1
- package/dist/components/List/index.d.ts +1 -1
- package/dist/components/List/types.d.ts +4 -0
- package/dist/components/NewMoreMenu/NewMoreMenu.d.ts +5 -2
- package/dist/true-react-common-ui-kit.js +50 -38
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/List/List.stories.tsx +12 -0
- package/src/components/List/List.styles.ts +2 -1
- package/src/components/List/List.tsx +10 -4
- package/src/components/List/components/ListItem/ListItem.styles.ts +2 -1
- package/src/components/List/components/ListItem/ListItem.tsx +5 -1
- package/src/components/List/index.ts +1 -1
- package/src/components/List/types.ts +6 -0
- package/src/components/NewMoreMenu/NewMoreMenu.stories.tsx +10 -0
- package/src/components/NewMoreMenu/NewMoreMenu.tsx +28 -19
|
@@ -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,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(
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
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:
|
|
11927
|
-
|
|
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
|
};
|