@vention/machine-ui 5.30.20 → 6.0.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
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { Typography, useTheme, Button, Stack, Box as Box$1, Grid, IconButton, ClickAwayListener, Modal, CircularProgress as CircularProgress$1, linearProgressClasses, LinearProgress, Skeleton, InputAdornment, TextField, MenuList, MenuItem, ListItemIcon, ListItemText, Popover, Popper, Radio, FormControlLabel, FormControl, Select, FormHelperText, ButtonGroup, Paper, Card, CardMedia, CardContent, Drawer, Autocomplete, Tooltip, Checkbox } from '@mui/material';
2
+ import { Typography, useTheme, Button, Stack, Box as Box$1, Grid, darken, alpha, IconButton, ClickAwayListener, Modal, CircularProgress as CircularProgress$1, linearProgressClasses, LinearProgress, Skeleton, InputAdornment, TextField, MenuList, MenuItem, ListItemIcon, ListItemText, Popover, Popper, Radio, FormControlLabel, FormControl, Select, FormHelperText, ButtonGroup, Paper, Card, CardMedia, CardContent, Drawer, Autocomplete, Tooltip, Checkbox } from '@mui/material';
3
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
4
  import * as React from 'react';
5
5
  import { lazy, memo, Suspense, forwardRef, useState, cloneElement, useRef, useEffect, useCallback, createContext, useContext, useImperativeHandle, useMemo, Children, Fragment as Fragment$1, useReducer, useLayoutEffect } from 'react';
@@ -6086,6 +6086,8 @@ function getVentionAvatarColors(color, variant, theme) {
6086
6086
  return avatarStyleMap[color][variant](theme);
6087
6087
  }
6088
6088
 
6089
+ /** How much a clickable badge's background darkens on hover. */
6090
+ const HOVER_DARKEN_AMOUNT = 0.05;
6089
6091
  const VentionBadge = props => {
6090
6092
  const {
6091
6093
  classes,
@@ -6093,11 +6095,13 @@ const VentionBadge = props => {
6093
6095
  } = useStyles$I({
6094
6096
  size: props.size,
6095
6097
  color: props.color,
6096
- variant: props.variant
6098
+ variant: props.variant,
6099
+ clickable: !!props.onClick
6097
6100
  });
6098
6101
  return jsxs("div", {
6099
6102
  className: cx(classes.root, props.className),
6100
6103
  "data-testid": props["data-testid"],
6104
+ onClick: props.onClick,
6101
6105
  children: [props.iconLeft, jsx(Typography, {
6102
6106
  textAlign: "center",
6103
6107
  variant: getBadgeTypographyVariant(props.size),
@@ -6113,6 +6117,7 @@ const useStyles$I = tss.withParams().create(({
6113
6117
  size,
6114
6118
  color,
6115
6119
  variant,
6120
+ clickable,
6116
6121
  theme
6117
6122
  }) => {
6118
6123
  const height = getBadgeHeight(size);
@@ -6123,7 +6128,7 @@ const useStyles$I = tss.withParams().create(({
6123
6128
  textColor
6124
6129
  } = getVentionBadgeColors(color, variant, theme);
6125
6130
  return {
6126
- root: {
6131
+ root: Object.assign({
6127
6132
  display: "flex",
6128
6133
  justifyContent: "center",
6129
6134
  alignItems: "center",
@@ -6132,12 +6137,18 @@ const useStyles$I = tss.withParams().create(({
6132
6137
  padding,
6133
6138
  background,
6134
6139
  color: textColor,
6135
- border: borderColor && `0.5px solid ${borderColor}`,
6140
+ border: `0.5px solid ${borderColor}`,
6136
6141
  borderRadius: size === "large" ? 6 : 4,
6137
6142
  maxWidth: "fit-content",
6138
6143
  whiteSpace: "nowrap",
6139
6144
  overflow: "hidden"
6140
- }
6145
+ }, clickable && {
6146
+ cursor: "pointer",
6147
+ "&:hover": {
6148
+ // Badges without a background (outlined) get a translucent black to match.
6149
+ background: background ? darken(background, HOVER_DARKEN_AMOUNT) : alpha(theme.palette.common.black, HOVER_DARKEN_AMOUNT)
6150
+ }
6151
+ })
6141
6152
  };
6142
6153
  });
6143
6154
  const getBadgeTypographyVariant = size => {
@@ -6195,7 +6206,7 @@ const badgeStyleMap = {
6195
6206
  blue: {
6196
6207
  filled: theme => ({
6197
6208
  background: theme.palette.background.blue,
6198
- borderColor: null,
6209
+ borderColor: theme.palette.background.blue,
6199
6210
  textColor: theme.palette.common.white
6200
6211
  }),
6201
6212
  subtle: theme => ({
@@ -6212,7 +6223,7 @@ const badgeStyleMap = {
6212
6223
  green: {
6213
6224
  filled: theme => ({
6214
6225
  background: theme.palette.background.success,
6215
- borderColor: null,
6226
+ borderColor: theme.palette.background.success,
6216
6227
  textColor: theme.palette.common.white
6217
6228
  }),
6218
6229
  subtle: theme => ({
@@ -6229,7 +6240,7 @@ const badgeStyleMap = {
6229
6240
  yellow: {
6230
6241
  filled: theme => ({
6231
6242
  background: theme.palette.background.warning,
6232
- borderColor: null,
6243
+ borderColor: theme.palette.background.warning,
6233
6244
  textColor: theme.palette.common.black
6234
6245
  }),
6235
6246
  subtle: theme => ({
@@ -6245,9 +6256,9 @@ const badgeStyleMap = {
6245
6256
  },
6246
6257
  slate: {
6247
6258
  filled: theme => ({
6248
- background: theme.palette.background.slate,
6249
- borderColor: null,
6250
- textColor: theme.palette.common.white
6259
+ background: theme.palette.background.mutedSlate,
6260
+ borderColor: theme.palette.background.mutedSlate,
6261
+ textColor: theme.palette.text.primary
6251
6262
  }),
6252
6263
  subtle: theme => ({
6253
6264
  background: theme.palette.background.subtleSlate,
@@ -11723,7 +11734,7 @@ const useStyles$e = tss.withParams().create(({
11723
11734
  };
11724
11735
  });
11725
11736
 
11726
- /** This is the default height of the tree item. This value only changes if you stack multiple captionRight elements.
11737
+ /** This is the default height of the tree item. This value only changes if you stack multiple right captions or show captions below.
11727
11738
  * This is needed for Machinebuilder for virtualization.
11728
11739
  */
11729
11740
  const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
@@ -11738,6 +11749,7 @@ const defaultProps$2 = {
11738
11749
  isSelected: false,
11739
11750
  isExpanded: true,
11740
11751
  isRenaming: false,
11752
+ captionsPosition: "right",
11741
11753
  classes: {},
11742
11754
  children: [],
11743
11755
  collapsible: true,
@@ -11752,7 +11764,8 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
11752
11764
  classes: classesOverrides,
11753
11765
  hasWarning,
11754
11766
  isSelected,
11755
- captionsRight,
11767
+ captions,
11768
+ captionsPosition,
11756
11769
  onLabelChange,
11757
11770
  actionButtons,
11758
11771
  trailingElements,
@@ -11779,7 +11792,7 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
11779
11792
  hasWarning: hasWarning,
11780
11793
  isSelected: isSelected,
11781
11794
  isExpanded,
11782
- captionsRight: captionsRight,
11795
+ collapsible,
11783
11796
  indentLevel: indentLevel,
11784
11797
  selectable
11785
11798
  });
@@ -11812,6 +11825,25 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
11812
11825
  };
11813
11826
  const isCaretVisible = Children.count(children) > 0;
11814
11827
  const testId = dataTestid !== null && dataTestid !== void 0 ? dataTestid : "vention-tree-item";
11828
+ const captionsElement = captions && captions.length > 0 && jsx("div", {
11829
+ className: classes.captionsContainer,
11830
+ "data-testid": `${testId}-captions`,
11831
+ children: captions.map((caption, index) => {
11832
+ var _a, _b;
11833
+ return jsx(VentionBadge, {
11834
+ variant: "filled",
11835
+ size: "small",
11836
+ color: (_a = caption.color) !== null && _a !== void 0 ? _a : "slate",
11837
+ className: classes.caption,
11838
+ text: caption.text,
11839
+ onClick: caption.onClick ? event => {
11840
+ event.stopPropagation();
11841
+ caption.onClick(event);
11842
+ } : undefined,
11843
+ "data-testid": `${testId}-${(_b = caption.testId) !== null && _b !== void 0 ? _b : `caption-${index}`}`
11844
+ }, index);
11845
+ })
11846
+ });
11815
11847
  return jsxs("div", {
11816
11848
  className: classes.root,
11817
11849
  onClick: handleOnClick,
@@ -11892,31 +11924,8 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
11892
11924
  children: button.component
11893
11925
  }, index);
11894
11926
  })]
11895
- })]
11896
- }), captionsRight && captionsRight.length > 0 && jsx("div", {
11897
- className: classes.captionRightContainer,
11898
- "data-testid": `${testId}-captionRightContainer`,
11899
- children: captionsRight.map((caption, index) => {
11900
- var _a;
11901
- return jsx("div", {
11902
- className: cx(classes.captionRight, !!caption.onClick && classes.clickableCaptionRight),
11903
- onClick: caption.onClick ? event => {
11904
- event.stopPropagation();
11905
- caption.onClick(event);
11906
- } : undefined,
11907
- style: {
11908
- color: caption.color
11909
- },
11910
- "data-testid": `${testId}-${(_a = caption.testId) !== null && _a !== void 0 ? _a : `captionRight-${index}`}`,
11911
- children: jsx(Typography, {
11912
- className: cx(classes.label, classes.captionRightLabel),
11913
- variant: "uiTableNumbers12Reg",
11914
- title: caption.text,
11915
- children: caption.text
11916
- })
11917
- }, index);
11918
- })
11919
- }), hasWarning && jsx(IconAlertTriangleFilled, {
11927
+ }), captionsPosition === "below" && captionsElement]
11928
+ }), captionsPosition === "right" && captionsElement, hasWarning && jsx(IconAlertTriangleFilled, {
11920
11929
  className: classes.alertIcon,
11921
11930
  size: 16,
11922
11931
  color: theme.palette.icon.warning
@@ -11933,7 +11942,7 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
11933
11942
  theme,
11934
11943
  classes,
11935
11944
  indentLevel,
11936
- captionsRight,
11945
+ collapsible,
11937
11946
  selectable
11938
11947
  }) => {
11939
11948
  const getBackgroundColor = () => {
@@ -11945,8 +11954,9 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
11945
11954
  const invisibleBorder = `1px solid transparent`;
11946
11955
  // 22 is padding per indent
11947
11956
  const paddingLeft = indentLevel * 22 + 16;
11948
- // Check if we have multiple captions
11949
- const hasMultipleCaptions = captionsRight && captionsRight.length > 1;
11957
+ // Captions render inside singleLineContainer when below the label, and directly in mainContent when on the right.
11958
+ const captionsBelow = `> .${classes.singleLineContainer} > .${classes.captionsContainer}`;
11959
+ const multipleCaptionsRight = `> .${classes.captionsContainer} > :nth-child(2)`;
11950
11960
  return {
11951
11961
  root: {
11952
11962
  display: "flex",
@@ -11956,8 +11966,8 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
11956
11966
  width: "100%"
11957
11967
  },
11958
11968
  mainContent: {
11959
- paddingTop: hasMultipleCaptions ? "5px" : "0px",
11960
- paddingBottom: hasMultipleCaptions ? "5px" : "0px",
11969
+ paddingTop: "0px",
11970
+ paddingBottom: "0px",
11961
11971
  paddingLeft: `${paddingLeft}px`,
11962
11972
  paddingRight: theme.spacing(3),
11963
11973
  border: invisibleBorder,
@@ -11977,15 +11987,45 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
11977
11987
  overflow: "hidden",
11978
11988
  gap: theme.spacing(2),
11979
11989
  minHeight: DEFAULT_VENTION_TREE_ITEM_HEIGHT,
11980
- boxSizing: "border-box"
11990
+ boxSizing: "border-box",
11991
+ // Stacked content (multiple right captions or captions below the label) needs vertical breathing room.
11992
+ [`&:has(${captionsBelow}), &:has(${multipleCaptionsRight})`]: {
11993
+ paddingTop: "5px",
11994
+ paddingBottom: "5px"
11995
+ },
11996
+ [`&:has(${multipleCaptionsRight}) > .${classes.singleLineContainer}`]: {
11997
+ alignSelf: "flex-start"
11998
+ },
11999
+ [`& > .${classes.captionsContainer}`]: {
12000
+ flexDirection: "column",
12001
+ alignItems: "flex-end",
12002
+ justifyContent: "center",
12003
+ gap: theme.spacing(2),
12004
+ maxWidth: "80px"
12005
+ }
11981
12006
  },
11982
12007
  singleLineContainer: {
11983
12008
  display: "flex",
11984
12009
  alignItems: "center",
11985
12010
  gap: theme.spacing(2),
11986
12011
  flex: 1,
11987
- alignSelf: hasMultipleCaptions ? "flex-start" : "center",
11988
- overflow: "hidden"
12012
+ alignSelf: "center",
12013
+ overflow: "hidden",
12014
+ // With captions below, a grid keeps [caret] icon label [trailing items] on row 1 and puts the
12015
+ // captions on row 2, starting under the icon. Trailing items land in an implicit column.
12016
+ [`&:has(> .${classes.captionsContainer})`]: {
12017
+ display: "grid",
12018
+ gridTemplateColumns: collapsible ? "auto auto minmax(0, 1fr)" : "auto minmax(0, 1fr)",
12019
+ gridAutoColumns: "auto",
12020
+ rowGap: theme.spacing(1)
12021
+ },
12022
+ [`& > .${classes.captionsContainer}`]: {
12023
+ gridRow: 2,
12024
+ gridColumn: collapsible ? "2 / -1" : "1 / -1",
12025
+ flexWrap: "wrap",
12026
+ alignItems: "center",
12027
+ gap: theme.spacing(1)
12028
+ }
11989
12029
  },
11990
12030
  iconContainer: {
11991
12031
  display: "flex",
@@ -12004,37 +12044,14 @@ const useStyles$d = tss.withParams().withNestedSelectors().create(({
12004
12044
  whiteSpace: "nowrap",
12005
12045
  userSelect: "none"
12006
12046
  },
12007
- captionRightContainer: {
12047
+ captionsContainer: {
12008
12048
  display: "flex",
12009
- flexDirection: "column",
12010
- alignItems: "flex-end",
12011
- justifyContent: "center",
12012
- overflow: "hidden",
12013
- gap: theme.spacing(2),
12014
- maxWidth: "80px"
12049
+ overflow: "hidden"
12015
12050
  },
12016
- captionRight: {
12017
- padding: theme.spacing(0, 1),
12018
- borderRadius: "2px",
12051
+ caption: {
12019
12052
  overflow: "hidden",
12020
12053
  textOverflow: "ellipsis",
12021
- maxWidth: "100%",
12022
- height: "16px",
12023
- color: theme.palette.text.secondary,
12024
- display: "flex",
12025
- alignItems: "center",
12026
- boxSizing: "border-box"
12027
- },
12028
- captionRightLabel: {
12029
- fontSize: "10px"
12030
- },
12031
- clickableCaptionRight: {
12032
- cursor: "pointer",
12033
- backgroundColor: COLORS.slate[200],
12034
- "&:hover": {
12035
- background: COLORS.slate[300],
12036
- color: theme.palette.text.primary
12037
- }
12054
+ maxWidth: "100%"
12038
12055
  },
12039
12056
  actionButtonsContainer: {
12040
12057
  gap: theme.spacing(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-ui",
3
- "version": "5.30.20",
3
+ "version": "6.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"
@@ -1,4 +1,5 @@
1
1
  import { Theme } from "@mui/material";
2
+ import { MouseEvent } from "react";
2
3
  import { Sizes, StrictExtract } from "../../theme/machine-ui-theme";
3
4
  type VentionBadgeSizes = StrictExtract<Sizes, "small" | "medium" | "large" | "xx-large">;
4
5
  export type VentionBadgeVariants = "filled" | "subtle" | "outlined";
@@ -11,11 +12,12 @@ interface VentionBadgeProps {
11
12
  iconLeft?: React.ReactNode;
12
13
  className?: string;
13
14
  "data-testid"?: string;
15
+ onClick?: ((event: MouseEvent) => void) | undefined;
14
16
  }
15
17
  export declare const VentionBadge: (props: VentionBadgeProps) => import("react/jsx-runtime").JSX.Element;
16
18
  type BadgeStyle = {
17
19
  background: string | null;
18
- borderColor: string | null;
20
+ borderColor: string;
19
21
  textColor: string;
20
22
  };
21
23
  export declare const getVentionBadgeColors: (color: VentionBadgeColors, variant: VentionBadgeVariants, theme: Theme) => BadgeStyle;
@@ -1,5 +1,6 @@
1
1
  import { ReactElement, MouseEvent, ForwardRefExoticComponent, RefAttributes } from "react";
2
- /** This is the default height of the tree item. This value only changes if you stack multiple captionRight elements.
2
+ import { VentionBadgeColors } from "../vention-badge/vention-badge";
3
+ /** This is the default height of the tree item. This value only changes if you stack multiple right captions or show captions below.
3
4
  * This is needed for Machinebuilder for virtualization.
4
5
  */
5
6
  export declare const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
@@ -7,17 +8,20 @@ export interface TrailingElementItem {
7
8
  component: ReactElement;
8
9
  showOnHover?: boolean;
9
10
  }
11
+ export interface VentionTreeItemCaption {
12
+ text: string;
13
+ color?: VentionBadgeColors | undefined;
14
+ testId?: string | undefined;
15
+ onClick?: (e: MouseEvent) => void;
16
+ }
17
+ export type VentionTreeItemCaptionsPosition = "right" | "below";
10
18
  interface VentionTreeItemProps {
11
19
  labelText: string;
12
20
  indentLevel?: number | undefined;
13
21
  hasWarning?: boolean | undefined;
14
22
  icon?: ReactElement | undefined;
15
- captionsRight?: {
16
- text: string;
17
- color?: string;
18
- onClick?: (e: MouseEvent) => void;
19
- testId?: string;
20
- }[] | undefined;
23
+ captions?: VentionTreeItemCaption[] | undefined;
24
+ captionsPosition?: VentionTreeItemCaptionsPosition | undefined;
21
25
  actionButtons?: {
22
26
  component: ReactElement;
23
27
  showOnHover?: boolean;
@@ -49,8 +53,8 @@ declare const useStyles: import("tss-react").Tss.UseStyles<{
49
53
  hasWarning: boolean;
50
54
  isSelected: boolean;
51
55
  isExpanded: boolean;
52
- captionsRight: VentionTreeItemProps["captionsRight"];
56
+ collapsible: boolean;
53
57
  indentLevel: number;
54
58
  selectable: boolean;
55
- }, "label" | "root" | "iconContainer" | "labelContainer" | "actionButton" | "trailingElement" | "trailingElementShowOnHover" | "mainContent" | "singleLineContainer" | "captionRightContainer" | "captionRight" | "captionRightLabel" | "clickableCaptionRight" | "actionButtonsContainer" | "showOnHover" | "childrenItems" | "alertIcon", import("tss-react/mui").MuiThemeStyleOverridesPluginParams>;
59
+ }, "caption" | "label" | "root" | "iconContainer" | "labelContainer" | "actionButton" | "trailingElement" | "trailingElementShowOnHover" | "singleLineContainer" | "captionsContainer" | "mainContent" | "actionButtonsContainer" | "showOnHover" | "childrenItems" | "alertIcon", import("tss-react/mui").MuiThemeStyleOverridesPluginParams>;
56
60
  export {};