@vention/machine-ui 6.0.4 → 6.1.0
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
|
@@ -4771,6 +4771,7 @@ const useStyles$L = tss.withParams().create(({
|
|
|
4771
4771
|
const getDefaultProps = (severity, setVisible) => {
|
|
4772
4772
|
return {
|
|
4773
4773
|
size: "medium",
|
|
4774
|
+
appearance: "subtle",
|
|
4774
4775
|
leftIcon: getAlertIcon(severity),
|
|
4775
4776
|
onCloseButtonClick: () => setVisible(false)
|
|
4776
4777
|
};
|
|
@@ -4870,24 +4871,25 @@ function getRootMaxWidth(isSingleLine, isFullWidth) {
|
|
|
4870
4871
|
if (isSingleLine) return "inherit";
|
|
4871
4872
|
return "560px";
|
|
4872
4873
|
}
|
|
4874
|
+
function getLeftIconMarginRight(size, appearance) {
|
|
4875
|
+
if (appearance === "elevated") return "16px";
|
|
4876
|
+
return size === "small" ? "8px" : "12px";
|
|
4877
|
+
}
|
|
4873
4878
|
const useStyles$K = tss.withParams().create(({
|
|
4874
4879
|
isSingleLine,
|
|
4875
4880
|
severity,
|
|
4876
4881
|
size,
|
|
4877
4882
|
isFullWidth,
|
|
4883
|
+
appearance,
|
|
4878
4884
|
theme,
|
|
4879
4885
|
hasControlProps
|
|
4880
4886
|
}) => {
|
|
4881
4887
|
const {
|
|
4882
|
-
backgroundColor,
|
|
4883
|
-
borderColor,
|
|
4884
4888
|
iconColor
|
|
4885
4889
|
} = getAlertColors(severity, theme);
|
|
4886
4890
|
const textSize = getFontSize$1(size);
|
|
4887
4891
|
return {
|
|
4888
|
-
root: {
|
|
4889
|
-
backgroundColor: backgroundColor,
|
|
4890
|
-
border: `${size === "large" ? 2 : 1}px solid var(--Border-Default-border-default, ${borderColor})`,
|
|
4892
|
+
root: Object.assign(Object.assign({}, getSurfaceStyles(appearance, severity, size, theme)), {
|
|
4891
4893
|
display: "flex",
|
|
4892
4894
|
justifyContent: "center",
|
|
4893
4895
|
alignItems: "center",
|
|
@@ -4899,12 +4901,11 @@ const useStyles$K = tss.withParams().create(({
|
|
|
4899
4901
|
width: isFullWidth ? "100%" : "fit-content",
|
|
4900
4902
|
minWidth: "inherit",
|
|
4901
4903
|
maxWidth: getRootMaxWidth(isSingleLine, isFullWidth),
|
|
4902
|
-
borderRadius: "4px",
|
|
4903
4904
|
padding: getAlertPadding({
|
|
4904
4905
|
isSingleLine,
|
|
4905
4906
|
size
|
|
4906
4907
|
})
|
|
4907
|
-
},
|
|
4908
|
+
}),
|
|
4908
4909
|
alertGridContainer: {
|
|
4909
4910
|
flexWrap: "nowrap",
|
|
4910
4911
|
lineHeight: "0px",
|
|
@@ -4957,7 +4958,7 @@ const useStyles$K = tss.withParams().create(({
|
|
|
4957
4958
|
item: true,
|
|
4958
4959
|
size: size === "small" ? 16 : 24,
|
|
4959
4960
|
width: "fit-content",
|
|
4960
|
-
marginRight: size
|
|
4961
|
+
marginRight: getLeftIconMarginRight(size, appearance),
|
|
4961
4962
|
alignSelf: isSingleLine ? "center" : "normal"
|
|
4962
4963
|
},
|
|
4963
4964
|
rightIcon: {
|
|
@@ -4986,6 +4987,25 @@ const getRootHeight = alertProps => {
|
|
|
4986
4987
|
};
|
|
4987
4988
|
return heights[alertProps.size];
|
|
4988
4989
|
};
|
|
4990
|
+
const getSurfaceStyles = (appearance, severity, size, theme) => {
|
|
4991
|
+
if (appearance === "elevated") {
|
|
4992
|
+
return {
|
|
4993
|
+
backgroundColor: theme.palette.background.surface1,
|
|
4994
|
+
border: `1px solid ${theme.palette.border.default}`,
|
|
4995
|
+
borderRadius: "8px",
|
|
4996
|
+
boxShadow: theme.shadows[4]
|
|
4997
|
+
};
|
|
4998
|
+
}
|
|
4999
|
+
const {
|
|
5000
|
+
backgroundColor,
|
|
5001
|
+
borderColor
|
|
5002
|
+
} = getAlertColors(severity, theme);
|
|
5003
|
+
return {
|
|
5004
|
+
backgroundColor,
|
|
5005
|
+
border: `${size === "large" ? 2 : 1}px solid var(--Border-Default-border-default, ${borderColor})`,
|
|
5006
|
+
borderRadius: "4px"
|
|
5007
|
+
};
|
|
5008
|
+
};
|
|
4989
5009
|
const getAlertColors = (severity, theme) => {
|
|
4990
5010
|
switch (severity) {
|
|
4991
5011
|
case "warn":
|
|
@@ -11693,17 +11713,24 @@ $$5({ target: 'Iterator', proto: true, real: true, forced: someWithoutClosingOnE
|
|
|
11693
11713
|
}
|
|
11694
11714
|
});
|
|
11695
11715
|
|
|
11716
|
+
/** This is the default height of the tree item. This value only changes if you stack multiple right captions or show captions below.
|
|
11717
|
+
* This is needed for Machinebuilder for virtualization.
|
|
11718
|
+
*/
|
|
11719
|
+
const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
|
|
11696
11720
|
const VentionCollapsibleCaretButton = ({
|
|
11697
11721
|
isVisible,
|
|
11698
11722
|
isExpanded,
|
|
11699
11723
|
onClick,
|
|
11700
|
-
dataTestid
|
|
11724
|
+
dataTestid,
|
|
11725
|
+
size,
|
|
11726
|
+
iconSize
|
|
11701
11727
|
}) => {
|
|
11702
11728
|
const {
|
|
11703
11729
|
classes
|
|
11704
11730
|
} = useStyles$e({
|
|
11705
11731
|
isVisible,
|
|
11706
|
-
isExpanded
|
|
11732
|
+
isExpanded,
|
|
11733
|
+
size
|
|
11707
11734
|
});
|
|
11708
11735
|
return jsx(Box$1, {
|
|
11709
11736
|
component: "div",
|
|
@@ -11712,13 +11739,14 @@ const VentionCollapsibleCaretButton = ({
|
|
|
11712
11739
|
"data-testid": dataTestid,
|
|
11713
11740
|
"aria-expanded": isExpanded,
|
|
11714
11741
|
children: jsx(IconCaretRightFilled, {
|
|
11715
|
-
size:
|
|
11742
|
+
size: iconSize
|
|
11716
11743
|
})
|
|
11717
11744
|
});
|
|
11718
11745
|
};
|
|
11719
11746
|
const useStyles$e = tss.withParams().create(({
|
|
11720
11747
|
isVisible,
|
|
11721
11748
|
isExpanded,
|
|
11749
|
+
size,
|
|
11722
11750
|
theme
|
|
11723
11751
|
}) => {
|
|
11724
11752
|
return {
|
|
@@ -11727,6 +11755,9 @@ const useStyles$e = tss.withParams().create(({
|
|
|
11727
11755
|
cursor: "pointer",
|
|
11728
11756
|
visibility: isVisible ? "visible" : "hidden",
|
|
11729
11757
|
alignItems: "center",
|
|
11758
|
+
justifyContent: "center",
|
|
11759
|
+
width: size,
|
|
11760
|
+
height: size,
|
|
11730
11761
|
transition: "transform 0.2s",
|
|
11731
11762
|
transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)",
|
|
11732
11763
|
color: theme.palette.icon.tertiaryHover
|
|
@@ -11734,10 +11765,11 @@ const useStyles$e = tss.withParams().create(({
|
|
|
11734
11765
|
};
|
|
11735
11766
|
});
|
|
11736
11767
|
|
|
11737
|
-
/**
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11768
|
+
/** Fixed minimum row height per size. Rows only grow past it for stacked right captions or captions below. */
|
|
11769
|
+
const MIN_HEIGHT_BY_SIZE = {
|
|
11770
|
+
medium: DEFAULT_VENTION_TREE_ITEM_HEIGHT,
|
|
11771
|
+
"xx-large": 64
|
|
11772
|
+
};
|
|
11741
11773
|
const hasAnyVisibleItem = (items, isHovering) => {
|
|
11742
11774
|
if (items === undefined || items.length === 0) return false;
|
|
11743
11775
|
return items.some(item => !item.showOnHover) || isHovering && items.some(item => item.showOnHover);
|
|
@@ -11753,7 +11785,8 @@ const defaultProps$2 = {
|
|
|
11753
11785
|
classes: {},
|
|
11754
11786
|
children: [],
|
|
11755
11787
|
collapsible: true,
|
|
11756
|
-
selectable: true
|
|
11788
|
+
selectable: true,
|
|
11789
|
+
size: "medium"
|
|
11757
11790
|
};
|
|
11758
11791
|
const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
11759
11792
|
const theme = useTheme();
|
|
@@ -11780,7 +11813,8 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
|
11780
11813
|
isRenaming,
|
|
11781
11814
|
onRenaming,
|
|
11782
11815
|
collapsible,
|
|
11783
|
-
selectable
|
|
11816
|
+
selectable,
|
|
11817
|
+
size
|
|
11784
11818
|
} = applyDefaultProps(inputProps, defaultProps$2);
|
|
11785
11819
|
const [isHovering, setIsHovering] = useState(false);
|
|
11786
11820
|
const [label, setLabel] = useState(labelText);
|
|
@@ -11789,12 +11823,13 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
|
11789
11823
|
cx
|
|
11790
11824
|
} = useStyles$d({
|
|
11791
11825
|
classesOverrides,
|
|
11792
|
-
hasWarning
|
|
11793
|
-
isSelected
|
|
11826
|
+
hasWarning,
|
|
11827
|
+
isSelected,
|
|
11794
11828
|
isExpanded,
|
|
11795
11829
|
collapsible,
|
|
11796
|
-
indentLevel
|
|
11797
|
-
selectable
|
|
11830
|
+
indentLevel,
|
|
11831
|
+
selectable,
|
|
11832
|
+
size
|
|
11798
11833
|
});
|
|
11799
11834
|
const handleRenaming = () => {
|
|
11800
11835
|
if (onRenaming) {
|
|
@@ -11832,7 +11867,7 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
|
11832
11867
|
var _a, _b;
|
|
11833
11868
|
return jsx(VentionBadge, {
|
|
11834
11869
|
variant: "filled",
|
|
11835
|
-
size: "small",
|
|
11870
|
+
size: size === "xx-large" ? "medium" : "small",
|
|
11836
11871
|
color: (_a = caption.color) !== null && _a !== void 0 ? _a : "slate",
|
|
11837
11872
|
className: classes.caption,
|
|
11838
11873
|
text: caption.text,
|
|
@@ -11871,7 +11906,9 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
|
11871
11906
|
isVisible: isCaretVisible,
|
|
11872
11907
|
isExpanded: isExpanded,
|
|
11873
11908
|
onClick: handleIsExpandedToggle,
|
|
11874
|
-
dataTestid: `${testId}-collapseButton
|
|
11909
|
+
dataTestid: `${testId}-collapseButton`,
|
|
11910
|
+
size: DEFAULT_VENTION_TREE_ITEM_HEIGHT,
|
|
11911
|
+
iconSize: size === "xx-large" ? 18 : 16
|
|
11875
11912
|
}), jsx("div", {
|
|
11876
11913
|
"data-testid": `${testId}-icon`,
|
|
11877
11914
|
className: classes.iconContainer,
|
|
@@ -11882,7 +11919,7 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
|
11882
11919
|
onDoubleClick: handleRenaming,
|
|
11883
11920
|
children: jsx(Typography, {
|
|
11884
11921
|
className: classes.label,
|
|
11885
|
-
variant: "uiText12Regular",
|
|
11922
|
+
variant: size === "xx-large" ? "uiText18SemiBold" : "uiText12Regular",
|
|
11886
11923
|
title: label,
|
|
11887
11924
|
children: isRenaming ? jsx(VentionTextInput, {
|
|
11888
11925
|
autoFocus: true,
|
|
@@ -11927,8 +11964,9 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
|
|
|
11927
11964
|
}), captionsPosition === "below" && captionsElement]
|
|
11928
11965
|
}), captionsPosition === "right" && captionsElement, hasWarning && jsx(IconAlertTriangleFilled, {
|
|
11929
11966
|
className: classes.alertIcon,
|
|
11930
|
-
size: 16,
|
|
11931
|
-
color: theme.palette.icon.warning
|
|
11967
|
+
size: size === "xx-large" ? 24 : 16,
|
|
11968
|
+
color: theme.palette.icon.warning,
|
|
11969
|
+
"data-testid": `${testId}-alertIcon`
|
|
11932
11970
|
})]
|
|
11933
11971
|
}), jsx("div", {
|
|
11934
11972
|
className: classes.childrenItems,
|
|
@@ -11943,17 +11981,13 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
|
|
|
11943
11981
|
classes,
|
|
11944
11982
|
indentLevel,
|
|
11945
11983
|
collapsible,
|
|
11946
|
-
selectable
|
|
11984
|
+
selectable,
|
|
11985
|
+
size
|
|
11947
11986
|
}) => {
|
|
11948
|
-
const getBackgroundColor = () => {
|
|
11949
|
-
if (isSelected) return theme.palette.button.shaded;
|
|
11950
|
-
return "white";
|
|
11951
|
-
};
|
|
11952
|
-
const backgroundColor = getBackgroundColor();
|
|
11953
11987
|
// We use an invisible border to avoid the content from shifting when the border is shown on hover
|
|
11954
11988
|
const invisibleBorder = `1px solid transparent`;
|
|
11955
|
-
//
|
|
11956
|
-
const paddingLeft = indentLevel * 22 + 16;
|
|
11989
|
+
// xx-large: 40px per indent (32px caret + 8px gap), so a child's caret sits under its parent's icon.
|
|
11990
|
+
const paddingLeft = size === "xx-large" ? indentLevel * 40 + 8 : indentLevel * 22 + 16;
|
|
11957
11991
|
// Captions render inside singleLineContainer when below the label, and directly in mainContent when on the right.
|
|
11958
11992
|
const captionsBelow = `> .${classes.singleLineContainer} > .${classes.captionsContainer}`;
|
|
11959
11993
|
const multipleCaptionsRight = `> .${classes.captionsContainer} > :nth-child(2)`;
|
|
@@ -11962,7 +11996,6 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
|
|
|
11962
11996
|
display: "flex",
|
|
11963
11997
|
flexDirection: "column",
|
|
11964
11998
|
cursor: selectable ? "pointer" : "default",
|
|
11965
|
-
backgroundColor: theme.palette.background.default,
|
|
11966
11999
|
width: "100%"
|
|
11967
12000
|
},
|
|
11968
12001
|
mainContent: {
|
|
@@ -11973,7 +12006,7 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
|
|
|
11973
12006
|
border: invisibleBorder,
|
|
11974
12007
|
display: "flex",
|
|
11975
12008
|
alignItems: "center",
|
|
11976
|
-
backgroundColor:
|
|
12009
|
+
backgroundColor: isSelected ? theme.palette.button.shaded : "transparent",
|
|
11977
12010
|
color: theme.palette.text.primary,
|
|
11978
12011
|
[`&:hover .${classes.actionButton}`]: {
|
|
11979
12012
|
visibility: "visible"
|
|
@@ -11986,7 +12019,7 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
|
|
|
11986
12019
|
},
|
|
11987
12020
|
overflow: "hidden",
|
|
11988
12021
|
gap: theme.spacing(2),
|
|
11989
|
-
minHeight:
|
|
12022
|
+
minHeight: MIN_HEIGHT_BY_SIZE[size],
|
|
11990
12023
|
boxSizing: "border-box",
|
|
11991
12024
|
// Stacked content (multiple right captions or captions below the label) needs vertical breathing room.
|
|
11992
12025
|
[`&:has(${captionsBelow}), &:has(${multipleCaptionsRight})`]: {
|
package/package.json
CHANGED
|
@@ -18,5 +18,6 @@ export interface VentionAlertProps {
|
|
|
18
18
|
isCloseable?: boolean;
|
|
19
19
|
isSingleLine?: boolean;
|
|
20
20
|
isFullWidth?: boolean;
|
|
21
|
+
appearance?: "subtle" | "elevated";
|
|
21
22
|
}
|
|
22
23
|
export declare function getGapSpaceForContent(isSingleLine: boolean, size: VentionAlertProps["size"]): "0px" | "12px" | "8px";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
+
/** This is the default height of the tree item. This value only changes if you stack multiple right captions or show captions below.
|
|
3
|
+
* This is needed for Machinebuilder for virtualization.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
|
|
2
6
|
/**
|
|
3
7
|
* Caret button that is used to collapse and expand the tree item
|
|
4
8
|
*/
|
|
@@ -7,6 +11,10 @@ interface VentionCollapsibleCaretButtonProps {
|
|
|
7
11
|
isVisible: boolean;
|
|
8
12
|
onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
9
13
|
dataTestid?: string | undefined;
|
|
14
|
+
/** Width and height of the clickable box, in px. */
|
|
15
|
+
size: number;
|
|
16
|
+
/** Size of the caret icon, in px. */
|
|
17
|
+
iconSize: number;
|
|
10
18
|
}
|
|
11
19
|
export declare const VentionCollapsibleCaretButton: FC<VentionCollapsibleCaretButtonProps>;
|
|
12
20
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ReactElement, MouseEvent, ForwardRefExoticComponent, RefAttributes } from "react";
|
|
2
|
+
import { DEFAULT_VENTION_TREE_ITEM_HEIGHT } from "./vention-collapsible-caret-button";
|
|
2
3
|
import { VentionBadgeColors } from "../vention-badge/vention-badge";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
|
|
4
|
+
import { Sizes, StrictExtract } from "../../theme/machine-ui-theme";
|
|
5
|
+
export { DEFAULT_VENTION_TREE_ITEM_HEIGHT };
|
|
7
6
|
export interface TrailingElementItem {
|
|
8
7
|
component: ReactElement;
|
|
9
8
|
showOnHover?: boolean;
|
|
@@ -15,6 +14,7 @@ export interface VentionTreeItemCaption {
|
|
|
15
14
|
onClick?: (e: MouseEvent) => void;
|
|
16
15
|
}
|
|
17
16
|
export type VentionTreeItemCaptionsPosition = "right" | "below";
|
|
17
|
+
export type VentionTreeItemSize = StrictExtract<Sizes, "medium" | "xx-large">;
|
|
18
18
|
interface VentionTreeItemProps {
|
|
19
19
|
labelText: string;
|
|
20
20
|
indentLevel?: number | undefined;
|
|
@@ -45,6 +45,8 @@ interface VentionTreeItemProps {
|
|
|
45
45
|
collapsible?: boolean | undefined;
|
|
46
46
|
/** When false, a row does not select and shows no hover highlight. The caret still works. Defaults to true. */
|
|
47
47
|
selectable?: boolean | undefined;
|
|
48
|
+
/** Defaults to "medium". */
|
|
49
|
+
size?: VentionTreeItemSize | undefined;
|
|
48
50
|
}
|
|
49
51
|
export declare const VentionTreeItem: ForwardRefExoticComponent<VentionTreeItemProps & RefAttributes<HTMLDivElement>>;
|
|
50
52
|
declare const useStyles: import("tss-react").Tss.UseStyles<{
|
|
@@ -56,5 +58,5 @@ declare const useStyles: import("tss-react").Tss.UseStyles<{
|
|
|
56
58
|
collapsible: boolean;
|
|
57
59
|
indentLevel: number;
|
|
58
60
|
selectable: boolean;
|
|
61
|
+
size: VentionTreeItemSize;
|
|
59
62
|
}, "caption" | "label" | "root" | "iconContainer" | "labelContainer" | "actionButton" | "trailingElement" | "trailingElementShowOnHover" | "singleLineContainer" | "captionsContainer" | "mainContent" | "actionButtonsContainer" | "showOnHover" | "childrenItems" | "alertIcon", import("tss-react/mui").MuiThemeStyleOverridesPluginParams>;
|
|
60
|
-
export {};
|