@vention/machine-ui 3.36.0 → 3.37.1
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/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Typography, Button, Stack, Box as Box$1, Grid, IconButton, Modal, linearProgressClasses, LinearProgress, InputAdornment, TextField, Radio, FormControlLabel, FormControl, Select, MenuItem, FormHelperText, ButtonGroup, Paper, Card, CardMedia, CardContent, ListItemIcon, ListItemText, Popover, MenuList,
|
|
3
|
-
import { IconCheck, IconAlertTriangleFilled, IconAlertTriangle, IconExclamationMark, IconExternalLink, IconX, IconInfoCircleFilled, IconCircleCheckFilled, IconChevronDown, IconInfoCircle, IconInfoSmall, IconMinus, IconPlus, IconLoader2, IconCaretRightFilled, IconChevronsRight, IconChevronsLeft, IconChevronRight } from '@tabler/icons-react';
|
|
4
|
-
import { forwardRef, useState, cloneElement, lazy, memo, Suspense, useMemo,
|
|
2
|
+
import { Typography, Button, Stack, Box as Box$1, Grid, IconButton, ClickAwayListener, Modal, linearProgressClasses, LinearProgress, InputAdornment, TextField, Radio, FormControlLabel, FormControl, Select, MenuItem, FormHelperText, ButtonGroup, Paper, Card, CardMedia, CardContent, ListItemIcon, ListItemText, Popover, MenuList, useTheme as useTheme$1, Drawer, Tooltip, Checkbox } from '@mui/material';
|
|
3
|
+
import { IconCheck, IconAlertTriangleFilled, IconAlertTriangle, IconExclamationMark, IconExternalLink, IconX, IconInfoCircleFilled, IconCircleCheckFilled, IconChevronUp, IconChevronDown, IconInfoCircle, IconInfoSmall, IconMinus, IconPlus, IconLoader2, IconCaretRightFilled, IconChevronsRight, IconChevronsLeft, IconChevronRight } from '@tabler/icons-react';
|
|
4
|
+
import { forwardRef, useState, cloneElement, useRef, useCallback, lazy, memo, Suspense, useMemo, useEffect, createContext, useContext, useImperativeHandle, Children, Fragment as Fragment$1, useReducer } from 'react';
|
|
5
5
|
import { tss } from 'tss-react/mui';
|
|
6
6
|
import Box from '@mui/material/Box';
|
|
7
7
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
@@ -3365,55 +3365,97 @@ const useStyles$B = tss.withParams().create(({
|
|
|
3365
3365
|
};
|
|
3366
3366
|
});
|
|
3367
3367
|
|
|
3368
|
+
const menuTestIds = {
|
|
3369
|
+
menuRootDiv: "menuRootDiv"
|
|
3370
|
+
};
|
|
3368
3371
|
const VentionDropdownButton = _a => {
|
|
3369
3372
|
var {
|
|
3370
3373
|
variant = "simple",
|
|
3371
3374
|
size = "small",
|
|
3372
3375
|
className,
|
|
3373
3376
|
disabled = false,
|
|
3374
|
-
|
|
3377
|
+
onClose,
|
|
3378
|
+
onOpen,
|
|
3375
3379
|
icon,
|
|
3376
3380
|
badgeText,
|
|
3377
3381
|
label,
|
|
3378
3382
|
stroke = 1,
|
|
3379
|
-
contentColor
|
|
3383
|
+
contentColor,
|
|
3384
|
+
children,
|
|
3385
|
+
menuPlacement = "bottom",
|
|
3386
|
+
menuAlignment = "start",
|
|
3387
|
+
onClick
|
|
3380
3388
|
} = _a,
|
|
3381
|
-
other = __rest(_a, ["variant", "size", "className", "disabled", "
|
|
3389
|
+
other = __rest(_a, ["variant", "size", "className", "disabled", "onClose", "onOpen", "icon", "badgeText", "label", "stroke", "contentColor", "children", "menuPlacement", "menuAlignment", "onClick"]);
|
|
3382
3390
|
const {
|
|
3383
3391
|
classes,
|
|
3384
3392
|
cx
|
|
3385
3393
|
} = useStyles$A({
|
|
3386
3394
|
variant,
|
|
3387
3395
|
size,
|
|
3388
|
-
contentColor
|
|
3396
|
+
contentColor,
|
|
3397
|
+
menuPlacement,
|
|
3398
|
+
menuAlignment
|
|
3399
|
+
});
|
|
3400
|
+
const ref = useRef(null);
|
|
3401
|
+
const [showDropdown, setShowDropdownInternal] = useState(false);
|
|
3402
|
+
const Chevron = showDropdown ? IconChevronUp : IconChevronDown;
|
|
3403
|
+
const handleClick = useCallback(event => {
|
|
3404
|
+
if (!showDropdown) {
|
|
3405
|
+
setShowDropdownInternal(true);
|
|
3406
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
3407
|
+
} else {
|
|
3408
|
+
setShowDropdownInternal(false);
|
|
3409
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
3410
|
+
}
|
|
3411
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
3412
|
+
}, [showDropdown, onClose, onOpen, onClick]);
|
|
3413
|
+
return jsx(ClickAwayListener, {
|
|
3414
|
+
onClickAway: () => {
|
|
3415
|
+
setShowDropdownInternal(false);
|
|
3416
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
3417
|
+
},
|
|
3418
|
+
children: jsxs("div", {
|
|
3419
|
+
style: {
|
|
3420
|
+
display: "inline-block",
|
|
3421
|
+
position: "relative"
|
|
3422
|
+
},
|
|
3423
|
+
children: [jsxs(IconButton, Object.assign({
|
|
3424
|
+
ref: ref,
|
|
3425
|
+
className: cx(classes.root, className),
|
|
3426
|
+
disableRipple: true
|
|
3427
|
+
}, other, {
|
|
3428
|
+
disabled: disabled,
|
|
3429
|
+
onClick: handleClick,
|
|
3430
|
+
children: [icon, label && jsx(Typography, {
|
|
3431
|
+
className: classes.label,
|
|
3432
|
+
variant: LABEL_VARIANTS[size],
|
|
3433
|
+
children: label
|
|
3434
|
+
}), badgeText && jsx(VentionBadge, {
|
|
3435
|
+
size: "small",
|
|
3436
|
+
color: "slate",
|
|
3437
|
+
text: badgeText,
|
|
3438
|
+
variant: "filled",
|
|
3439
|
+
className: classes.badge
|
|
3440
|
+
}), jsx(Chevron, {
|
|
3441
|
+
stroke: stroke,
|
|
3442
|
+
size: 16,
|
|
3443
|
+
color: contentColor
|
|
3444
|
+
})]
|
|
3445
|
+
})), showDropdown && jsx("div", {
|
|
3446
|
+
"data-testid": menuTestIds.menuRootDiv,
|
|
3447
|
+
className: classes.menuContainer,
|
|
3448
|
+
children: children
|
|
3449
|
+
})]
|
|
3450
|
+
})
|
|
3389
3451
|
});
|
|
3390
|
-
return jsxs(IconButton, Object.assign({
|
|
3391
|
-
className: cx(classes.root, className),
|
|
3392
|
-
disableRipple: true,
|
|
3393
|
-
disabled: disabled,
|
|
3394
|
-
onClick: onClick
|
|
3395
|
-
}, other, {
|
|
3396
|
-
children: [icon, label && jsx(Typography, {
|
|
3397
|
-
className: classes.label,
|
|
3398
|
-
variant: LABEL_VARIANTS[size],
|
|
3399
|
-
children: label
|
|
3400
|
-
}), badgeText && jsx(VentionBadge, {
|
|
3401
|
-
size: "small",
|
|
3402
|
-
color: "slate",
|
|
3403
|
-
text: badgeText,
|
|
3404
|
-
variant: "filled",
|
|
3405
|
-
className: classes.badge
|
|
3406
|
-
}), jsx(IconChevronDown, {
|
|
3407
|
-
stroke: stroke,
|
|
3408
|
-
size: 16,
|
|
3409
|
-
color: contentColor
|
|
3410
|
-
})]
|
|
3411
|
-
}));
|
|
3412
3452
|
};
|
|
3413
3453
|
const useStyles$A = tss.withParams().create(({
|
|
3414
3454
|
variant,
|
|
3415
3455
|
size,
|
|
3416
3456
|
contentColor,
|
|
3457
|
+
menuPlacement,
|
|
3458
|
+
menuAlignment,
|
|
3417
3459
|
theme
|
|
3418
3460
|
}) => {
|
|
3419
3461
|
const stylingProperties = getButtonStylingPropertiesGivenProps(variant, size, theme);
|
|
@@ -3424,9 +3466,8 @@ const useStyles$A = tss.withParams().create(({
|
|
|
3424
3466
|
height: getButtonHeight(size, theme),
|
|
3425
3467
|
padding: BUTTON_PADDINGS[size],
|
|
3426
3468
|
backgroundColor: stylingProperties.backgroundColor,
|
|
3427
|
-
borderColor: theme.palette.border.main,
|
|
3428
3469
|
borderRadius: stylingProperties.borderRadius,
|
|
3429
|
-
|
|
3470
|
+
border: stylingProperties.border,
|
|
3430
3471
|
color,
|
|
3431
3472
|
"&:hover": {
|
|
3432
3473
|
backgroundColor: stylingProperties.backgroundColorOnHover
|
|
@@ -3446,9 +3487,51 @@ const useStyles$A = tss.withParams().create(({
|
|
|
3446
3487
|
},
|
|
3447
3488
|
badge: {
|
|
3448
3489
|
maxWidth: "100px"
|
|
3449
|
-
}
|
|
3490
|
+
},
|
|
3491
|
+
menuContainer: Object.assign({
|
|
3492
|
+
position: "absolute",
|
|
3493
|
+
zIndex: theme.zIndex.modal
|
|
3494
|
+
}, getMenuPositionStyles(menuPlacement, menuAlignment))
|
|
3450
3495
|
};
|
|
3451
3496
|
});
|
|
3497
|
+
const getMenuPositionStyles = (placement, alignment) => {
|
|
3498
|
+
const gap = `calc(100% + ${BUTTON_MENU_GAP})`;
|
|
3499
|
+
const placementStyles = {
|
|
3500
|
+
bottom: {
|
|
3501
|
+
top: gap
|
|
3502
|
+
},
|
|
3503
|
+
top: {
|
|
3504
|
+
bottom: gap
|
|
3505
|
+
},
|
|
3506
|
+
right: {
|
|
3507
|
+
left: gap
|
|
3508
|
+
},
|
|
3509
|
+
left: {
|
|
3510
|
+
right: gap
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3513
|
+
const isHorizontalPlacement = placement === "bottom" || placement === "top";
|
|
3514
|
+
const alignmentStyles = {
|
|
3515
|
+
start: isHorizontalPlacement ? {
|
|
3516
|
+
left: 0
|
|
3517
|
+
} : {
|
|
3518
|
+
top: 0
|
|
3519
|
+
},
|
|
3520
|
+
middle: isHorizontalPlacement ? {
|
|
3521
|
+
left: "50%",
|
|
3522
|
+
transform: "translateX(-50%)"
|
|
3523
|
+
} : {
|
|
3524
|
+
top: "50%",
|
|
3525
|
+
transform: "translateY(-50%)"
|
|
3526
|
+
},
|
|
3527
|
+
end: isHorizontalPlacement ? {
|
|
3528
|
+
right: 0
|
|
3529
|
+
} : {
|
|
3530
|
+
bottom: 0
|
|
3531
|
+
}
|
|
3532
|
+
};
|
|
3533
|
+
return Object.assign(Object.assign({}, placementStyles[placement]), alignmentStyles[alignment]);
|
|
3534
|
+
};
|
|
3452
3535
|
const LABEL_VARIANTS = {
|
|
3453
3536
|
small: "uiText12Medium",
|
|
3454
3537
|
medium: "uiText14Medium",
|
|
@@ -3462,8 +3545,9 @@ const BUTTON_PADDINGS = {
|
|
|
3462
3545
|
const BUTTON_GAPS = {
|
|
3463
3546
|
small: "4px",
|
|
3464
3547
|
medium: "6px",
|
|
3465
|
-
large: "
|
|
3548
|
+
large: "8px"
|
|
3466
3549
|
};
|
|
3550
|
+
const BUTTON_MENU_GAP = "3px";
|
|
3467
3551
|
|
|
3468
3552
|
const defaultProps$6 = {
|
|
3469
3553
|
size: "medium",
|
|
@@ -12103,4 +12187,4 @@ function calcMenuPosition(anchorRect, menuSize, placement, alignment) {
|
|
|
12103
12187
|
}
|
|
12104
12188
|
}
|
|
12105
12189
|
|
|
12106
|
-
export { COLORS, DEFAULT_VENTION_TREE_ITEM_HEIGHT, ElementTestIds, IconSizes, POSITIONED_MENU_OFFSET, VentionAlert, VentionBadge, VentionBanner, VentionButton, VentionCallout, VentionCheckbox, VentionCombobox, VentionCounter, VentionDraggable, VentionDrawer, VentionDropZone, VentionDropdownButton, VentionIcon, VentionIconButton, VentionLink, VentionMenu, VentionModal, VentionModalBanner, VentionModalBase, VentionPopover, VentionPositionedComponent, VentionProgressBar, VentionRadio, VentionRadioTile, VentionSelect, VentionSidebarItem, VentionSlider, VentionSpinner, VentionStatusDot, VentionStatusIndicator, VentionStepper, VentionSteps, VentionSwitch, VentionTabs, VentionTextInput, VentionTooltip, VentionTreeItem, VentionUploadFile, calcMenuPosition, getSpinnerColor, getVentionBadgeColors, machineUiHmiTheme, machineUiTheme, testIds, useBannerColorStyles, ventionModalBaseTestIds, ventionModalTestIds, ventionPopoverArrowSize };
|
|
12190
|
+
export { COLORS, DEFAULT_VENTION_TREE_ITEM_HEIGHT, ElementTestIds, IconSizes, POSITIONED_MENU_OFFSET, VentionAlert, VentionBadge, VentionBanner, VentionButton, VentionCallout, VentionCheckbox, VentionCombobox, VentionCounter, VentionDraggable, VentionDrawer, VentionDropZone, VentionDropdownButton, VentionIcon, VentionIconButton, VentionLink, VentionMenu, VentionModal, VentionModalBanner, VentionModalBase, VentionPopover, VentionPositionedComponent, VentionProgressBar, VentionRadio, VentionRadioTile, VentionSelect, VentionSidebarItem, VentionSlider, VentionSpinner, VentionStatusDot, VentionStatusIndicator, VentionStepper, VentionSteps, VentionSwitch, VentionTabs, VentionTextInput, VentionTooltip, VentionTreeItem, VentionUploadFile, calcMenuPosition, getSpinnerColor, getVentionBadgeColors, machineUiHmiTheme, machineUiTheme, menuTestIds, testIds, useBannerColorStyles, ventionModalBaseTestIds, ventionModalTestIds, ventionPopoverArrowSize };
|
package/package.json
CHANGED
package/src/lib/components/vention-button/vention-dropdown-button/vention-dropdown-button.d.ts
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ButtonProps } from "@mui/material";
|
|
3
2
|
import { Sizes, StrictExtract } from "../../../theme/machine-ui-theme";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { PositionedMenuAlignment, PositionedMenuPlacement } from "../../../components/shared/vention-positioned-component";
|
|
5
|
+
export declare const menuTestIds: {
|
|
6
|
+
menuRootDiv: string;
|
|
7
|
+
};
|
|
4
8
|
export interface VentionDropdownButtonProps extends Omit<ButtonProps, "size" | "variant" | "color"> {
|
|
5
9
|
variant?: "simple" | "outline" | "shaded";
|
|
6
10
|
size?: StrictExtract<Sizes, "small" | "medium" | "large">;
|
|
7
|
-
icon?:
|
|
11
|
+
icon?: ReactNode;
|
|
8
12
|
stroke?: number | string;
|
|
9
13
|
disabled?: boolean;
|
|
10
14
|
className?: string;
|
|
11
15
|
label?: string;
|
|
12
16
|
badgeText?: string;
|
|
13
17
|
contentColor?: string;
|
|
14
|
-
|
|
18
|
+
/** Required children to show when the button is clicked */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/** Callback function called when the dropdown is closed. */
|
|
21
|
+
onClose?: (() => void) | undefined;
|
|
22
|
+
/** Callback function called when the dropdown is opened. */
|
|
23
|
+
onOpen?: (() => void) | undefined;
|
|
24
|
+
/** Placement of the menu relative to the button. */
|
|
25
|
+
menuPlacement?: PositionedMenuPlacement | undefined;
|
|
26
|
+
/** Alignment of the menu relative to the button. */
|
|
27
|
+
menuAlignment?: PositionedMenuAlignment | undefined;
|
|
15
28
|
}
|
|
16
|
-
export declare const VentionDropdownButton: ({ variant, size, className, disabled,
|
|
29
|
+
export declare const VentionDropdownButton: ({ variant, size, className, disabled, onClose, onOpen, icon, badgeText, label, stroke, contentColor, children, menuPlacement, menuAlignment, onClick, ...other }: VentionDropdownButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { VentionMenuListProps } from "./vention-menu-list";
|
|
|
2
2
|
import { MenuSize } from "./vention-menu-styling-helpers";
|
|
3
3
|
export type VentionMenuProps = VentionMenuListProps & {
|
|
4
4
|
showMenu?: boolean;
|
|
5
|
-
setShowMenu
|
|
5
|
+
setShowMenu: (show: boolean) => void;
|
|
6
6
|
closeMenuOnClick?: boolean;
|
|
7
7
|
size?: MenuSize;
|
|
8
8
|
menuWidth?: string;
|