@true-engineering/true-react-common-ui-kit 4.0.0-alpha61 → 4.0.0-alpha63
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 +3 -2
- 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 +53 -40
- 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 +4 -1
- package/src/components/List/components/ListItem/ListItem.tsx +6 -2
- 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
|
-
|
|
3
|
-
export
|
|
2
|
+
import { IListSizes as IListItemSizes } from '../../types';
|
|
3
|
+
export declare const useStyles: import('../../../../theme').IUseStyles<"content" | "root" | "default" | "destructive" | "focused" | "disabledItem" | "spacer" | "withIconGap" | "icon" | "chevron">;
|
|
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 */
|
|
@@ -3157,12 +3157,14 @@ const useStyles$V = createThemedStyles("ListItem", {
|
|
|
3157
3157
|
},
|
|
3158
3158
|
content: {
|
|
3159
3159
|
flexGrow: 1
|
|
3160
|
-
}
|
|
3160
|
+
},
|
|
3161
|
+
chevron: {}
|
|
3161
3162
|
});
|
|
3162
3163
|
const ListItem = ({
|
|
3163
3164
|
icon,
|
|
3164
3165
|
item,
|
|
3165
3166
|
nestedItems,
|
|
3167
|
+
size: size2,
|
|
3166
3168
|
disabled: isDisabled,
|
|
3167
3169
|
isFocused,
|
|
3168
3170
|
shouldDrawSpacerAbove,
|
|
@@ -3180,7 +3182,7 @@ const ListItem = ({
|
|
|
3180
3182
|
/* @__PURE__ */ jsxs(
|
|
3181
3183
|
"div",
|
|
3182
3184
|
{
|
|
3183
|
-
className: clsx(classes.root, classes[view], {
|
|
3185
|
+
className: clsx(classes.root, classes[view], isNotEmpty(size2) && classes[size2], {
|
|
3184
3186
|
[classes.disabledItem]: isDisabled,
|
|
3185
3187
|
[classes.withIconGap]: withIconGap,
|
|
3186
3188
|
[classes.focused]: isFocused
|
|
@@ -3190,7 +3192,7 @@ const ListItem = ({
|
|
|
3190
3192
|
children: [
|
|
3191
3193
|
isReactNodeNotEmpty(icon) && /* @__PURE__ */ jsx("span", { className: classes.icon, children: renderIcon(icon) }),
|
|
3192
3194
|
/* @__PURE__ */ jsx("span", { className: classes.content, children: item }),
|
|
3193
|
-
isArrayNotEmpty(nestedItems) && /* @__PURE__ */ jsx("span", { className: classes.icon, children: /* @__PURE__ */ jsx(Icon, { type: "chevron-right" }) })
|
|
3195
|
+
isArrayNotEmpty(nestedItems) && /* @__PURE__ */ jsx("span", { className: clsx(classes.icon, classes.chevron), children: /* @__PURE__ */ jsx(Icon, { type: "chevron-right" }) })
|
|
3194
3196
|
]
|
|
3195
3197
|
}
|
|
3196
3198
|
),
|
|
@@ -3216,7 +3218,7 @@ const withPopupStyles$1 = {
|
|
|
3216
3218
|
width: "100%"
|
|
3217
3219
|
}
|
|
3218
3220
|
};
|
|
3219
|
-
const List = ({ items, testId, data, tweakStyles, onClick }) => {
|
|
3221
|
+
const List = ({ items, size: size2, testId, data, tweakStyles, onClick }) => {
|
|
3220
3222
|
const classes = useStyles$U({ theme: tweakStyles });
|
|
3221
3223
|
const handleItemClick = (event, { onClick: itemOnClick }) => {
|
|
3222
3224
|
if (isNotEmpty(itemOnClick)) {
|
|
@@ -3225,27 +3227,35 @@ const List = ({ items, testId, data, tweakStyles, onClick }) => {
|
|
|
3225
3227
|
}
|
|
3226
3228
|
};
|
|
3227
3229
|
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
|
-
|
|
3230
|
+
return /* @__PURE__ */ jsx(
|
|
3231
|
+
"div",
|
|
3232
|
+
{
|
|
3233
|
+
className: clsx(classes.root, isNotEmpty(size2) && classes[size2]),
|
|
3234
|
+
...addDataAttributes$1(data, testId),
|
|
3235
|
+
children: filteredItems.map((item, i) => {
|
|
3236
|
+
const itemProps = {
|
|
3237
|
+
testId: getTestId(testId, `item-${i}`),
|
|
3238
|
+
size: size2,
|
|
3239
|
+
...item,
|
|
3240
|
+
shouldDrawSpacerAbove: item.shouldDrawSpacerAbove && i !== 0,
|
|
3241
|
+
shouldDrawSpacerBelow: item.shouldDrawSpacerBelow && i !== items.length - 1,
|
|
3242
|
+
onClick: (event) => handleItemClick(event, item)
|
|
3243
|
+
};
|
|
3244
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: isArrayNotEmpty(item.nestedItems) ? /* @__PURE__ */ jsx(
|
|
3245
|
+
WithPopup,
|
|
3246
|
+
{
|
|
3247
|
+
eventType: "hover",
|
|
3248
|
+
tweakStyles: withPopupStyles$1,
|
|
3249
|
+
placement: "right-start",
|
|
3250
|
+
popupOffset: 0,
|
|
3251
|
+
shouldRenderInBody: false,
|
|
3252
|
+
trigger: ({ triggerProps }) => /* @__PURE__ */ jsx(ListItem, { ...itemProps, isFocused: triggerProps.isActive }),
|
|
3253
|
+
children: /* @__PURE__ */ jsx("div", { className: classes.nestedItems, children: /* @__PURE__ */ jsx(List, { items: item.nestedItems, size: size2, onClick }) })
|
|
3254
|
+
}
|
|
3255
|
+
) : /* @__PURE__ */ jsx(ListItem, { ...itemProps }) }, i);
|
|
3256
|
+
})
|
|
3257
|
+
}
|
|
3258
|
+
);
|
|
3249
3259
|
};
|
|
3250
3260
|
const ANIMATION_TIMEOUT = 150;
|
|
3251
3261
|
const useStyles$T = createThemedStyles("AccountInfo", {
|
|
@@ -11902,6 +11912,8 @@ const NewMoreMenu = ({
|
|
|
11902
11912
|
isDisabled = false,
|
|
11903
11913
|
hasDefaultStateBackground = true,
|
|
11904
11914
|
data,
|
|
11915
|
+
renderTrigger,
|
|
11916
|
+
listSize,
|
|
11905
11917
|
testId,
|
|
11906
11918
|
tweakStyles,
|
|
11907
11919
|
...rest
|
|
@@ -11917,27 +11929,28 @@ const NewMoreMenu = ({
|
|
|
11917
11929
|
className: "tweakList",
|
|
11918
11930
|
currentComponentName: "NewMoreMenu"
|
|
11919
11931
|
});
|
|
11932
|
+
const defaultTrigger = ({ triggerProps, referenceProps }) => /* @__PURE__ */ jsx(
|
|
11933
|
+
"button",
|
|
11934
|
+
{
|
|
11935
|
+
className: clsx(classes.button, {
|
|
11936
|
+
[classes.hasCircle]: hasDefaultStateBackground,
|
|
11937
|
+
[classes.disabled]: triggerProps.isDisabled,
|
|
11938
|
+
[classes.active]: triggerProps.isActive
|
|
11939
|
+
}),
|
|
11940
|
+
disabled: triggerProps.isDisabled,
|
|
11941
|
+
...addDataAttributes$1(data, testId),
|
|
11942
|
+
...referenceProps,
|
|
11943
|
+
children: /* @__PURE__ */ jsx("div", { className: classes.icon, children: /* @__PURE__ */ jsx(Icon, { type: "menu" }) })
|
|
11944
|
+
}
|
|
11945
|
+
);
|
|
11920
11946
|
return /* @__PURE__ */ jsx(
|
|
11921
11947
|
WithPopup,
|
|
11922
11948
|
{
|
|
11923
11949
|
isDisabled: isDisabled || isArrayEmpty(items),
|
|
11924
11950
|
tweakStyles: tweakWithPopupStyles,
|
|
11925
11951
|
...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 })
|
|
11952
|
+
trigger: renderTrigger ?? defaultTrigger,
|
|
11953
|
+
children: ({ onClose }) => /* @__PURE__ */ jsx(List, { items, size: listSize, tweakStyles: tweakListStyles, onClick: onClose })
|
|
11941
11954
|
}
|
|
11942
11955
|
);
|
|
11943
11956
|
};
|