@vention/machine-ui 3.38.1 → 3.40.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, 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';
2
+ import { Typography, Button, Stack, Box as Box$1, Grid, IconButton, ClickAwayListener, Modal, CircularProgress as CircularProgress$1, 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
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 { forwardRef, useState, cloneElement, useRef, useEffect, useCallback, lazy, memo, Suspense, useMemo, createContext, useContext, useImperativeHandle, Children, Fragment as Fragment$1, useReducer } from 'react';
5
5
  import { tss } from 'tss-react/mui';
@@ -4178,7 +4178,9 @@ const VentionModal = props => {
4178
4178
  "data-testid": ventionModalTestIds.positiveIcon
4179
4179
  })), props.type === "info" && jsx(IconInfoSmall, Object.assign({}, iconProps, {
4180
4180
  "data-testid": ventionModalTestIds.infoIcon
4181
- })), props.type === "warning" && jsx(IconAlertTriangle, Object.assign({}, iconProps, {
4181
+ })), props.type === "loading" && jsx(CircularProgress$1, {
4182
+ "data-testid": ventionModalTestIds.loading
4183
+ }), props.type === "warning" && jsx(IconAlertTriangle, Object.assign({}, iconProps, {
4182
4184
  "data-testid": ventionModalTestIds.warningIcon
4183
4185
  })), props.type === "negative" && jsx(IconAlertTriangle, Object.assign({}, iconProps, {
4184
4186
  "data-testid": ventionModalTestIds.negativeIcon
@@ -4197,6 +4199,7 @@ const VentionModal = props => {
4197
4199
  "data-testid": ventionModalTestIds.modalActions,
4198
4200
  children: [props.secondaryButton && jsx(VentionButton, {
4199
4201
  size: buttonSize,
4202
+ "data-testid": props.secondaryButton.dataTestId,
4200
4203
  onClick: props.secondaryButton.onClick,
4201
4204
  variant: props.secondaryButton.variant || "outline",
4202
4205
  loading: props.secondaryButton.loading,
@@ -4204,6 +4207,7 @@ const VentionModal = props => {
4204
4207
  fullWidth: props.buttonPosition === undefined ? true : false,
4205
4208
  children: props.secondaryButton.text
4206
4209
  }), props.primaryButton && jsx(VentionButton, {
4210
+ "data-testid": props.primaryButton.dataTestId,
4207
4211
  size: buttonSize,
4208
4212
  onClick: props.primaryButton.onClick,
4209
4213
  variant: props.primaryButton.variant || "filled",
@@ -4251,7 +4255,7 @@ const useStyles$w = tss.withParams().create(({
4251
4255
  statusCircle: {
4252
4256
  width: status.containerSize,
4253
4257
  height: status.containerSize,
4254
- display: "flex",
4258
+ display: type === "loading" ? "block" : "flex",
4255
4259
  justifyContent: "center",
4256
4260
  alignItems: "center",
4257
4261
  borderRadius: "50%",
@@ -4303,7 +4307,7 @@ const getColors$2 = (type, theme) => {
4303
4307
  statusContainerColor: theme.palette.background.destructive,
4304
4308
  statusGlowColor: theme.palette.background.subtleDestructive
4305
4309
  };
4306
- case "none":
4310
+ default:
4307
4311
  return {
4308
4312
  statusContainerColor: "transparent",
4309
4313
  statusGlowColor: "transparent"
@@ -4339,6 +4343,7 @@ const getBodyTextTypography = (modalSize, isTouchDevice) => {
4339
4343
  const ventionModalTestIds = {
4340
4344
  positiveIcon: "vention-modal-positive-icon",
4341
4345
  infoIcon: "vention-modal-info-icon",
4346
+ loading: "vention-modal-loading-icon",
4342
4347
  warningIcon: "vention-modal-warning-icon",
4343
4348
  negativeIcon: "vention-modal-negative-icon",
4344
4349
  modalActions: "vention-modal-actions"
@@ -4928,7 +4933,7 @@ const VentionSteps = props => {
4928
4933
  classes,
4929
4934
  cx
4930
4935
  } = useStyles$u(props);
4931
- const typographyVariants = getTypographyVariants$1(props.size);
4936
+ const typographyVariants = getTypographyVariants(props.size);
4932
4937
  let variant = props.variant;
4933
4938
  if (props.size === "small" && variant === "number") {
4934
4939
  console.warn("The design system doesn't support vention-steps bullet numbering for the requested size. Defaulting to dots style.");
@@ -5121,7 +5126,7 @@ const ElementTestIds = {
5121
5126
  Description: "step-description",
5122
5127
  CheckIcon: "step-check-icon"
5123
5128
  };
5124
- const getTypographyVariants$1 = size => {
5129
+ const getTypographyVariants = size => {
5125
5130
  switch (size) {
5126
5131
  case "small":
5127
5132
  return {
@@ -5302,31 +5307,37 @@ const getInputPaddingStyles = (size, theme) => {
5302
5307
  const typographyNameFromSizeMap = {
5303
5308
  "x-small": {
5304
5309
  label: "uiText12SemiBold",
5310
+ labelDiminished: "uiText12Regular",
5305
5311
  text: "uiText12Regular",
5306
5312
  helperText: "uiText12Regular"
5307
5313
  },
5308
5314
  small: {
5309
5315
  label: "uiText12SemiBold",
5316
+ labelDiminished: "uiText12Regular",
5310
5317
  text: "uiText12Regular",
5311
5318
  helperText: "uiText12Regular"
5312
5319
  },
5313
5320
  medium: {
5314
5321
  label: "uiText14SemiBold",
5322
+ labelDiminished: "uiText14Regular",
5315
5323
  text: "uiText14Regular",
5316
5324
  helperText: "uiText12Regular"
5317
5325
  },
5318
5326
  large: {
5319
5327
  label: "uiText14SemiBold",
5328
+ labelDiminished: "uiText14Regular",
5320
5329
  text: "uiText14Regular",
5321
5330
  helperText: "uiText12Regular"
5322
5331
  },
5323
5332
  "x-large": {
5324
5333
  label: "heading18SemiBold",
5334
+ labelDiminished: "paragraph18Regular",
5325
5335
  text: "paragraph18Regular",
5326
5336
  helperText: "uiText12Regular"
5327
5337
  },
5328
5338
  "xx-large": {
5329
5339
  label: "hmiText20SemiBold",
5340
+ labelDiminished: "hmiText20Regular",
5330
5341
  text: "hmiText22Regular",
5331
5342
  helperText: "paragraph18Regular"
5332
5343
  }
@@ -5334,6 +5345,7 @@ const typographyNameFromSizeMap = {
5334
5345
  const getTypography = (size, theme) => {
5335
5346
  return {
5336
5347
  label: theme.typography[typographyNameFromSizeMap[size].label],
5348
+ labelDiminished: theme.typography[typographyNameFromSizeMap[size].labelDiminished],
5337
5349
  text: theme.typography[typographyNameFromSizeMap[size].text],
5338
5350
  helperText: theme.typography[typographyNameFromSizeMap[size].helperText]
5339
5351
  };
@@ -9417,6 +9429,10 @@ const useStyles$a = tss.withParams().create(({
9417
9429
  * This is needed for Machinebuilder for virtualization.
9418
9430
  */
9419
9431
  const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
9432
+ const hasAnyVisibleItem = (items, isHovering) => {
9433
+ if (items === undefined || items.length === 0) return false;
9434
+ return items.some(item => !item.showOnHover) || isHovering && items.some(item => item.showOnHover);
9435
+ };
9420
9436
  const defaultProps$2 = {
9421
9437
  indentLevel: 0,
9422
9438
  hasWarning: false,
@@ -9440,6 +9456,7 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
9440
9456
  captionsRight,
9441
9457
  onLabelChange,
9442
9458
  actionButtons,
9459
+ trailingElements,
9443
9460
  onClick,
9444
9461
  indentLevel,
9445
9462
  onContextMenu,
@@ -9484,10 +9501,10 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
9484
9501
  const handleRename = newLabel => {
9485
9502
  onLabelChange === null || onLabelChange === void 0 ? void 0 : onLabelChange(newLabel);
9486
9503
  };
9487
- const showActionButtonContainer = useCallback(() => {
9488
- if (actionButtons === undefined) return false;
9489
- return actionButtons.some(button => !button.showOnHover) || isHovering && actionButtons.some(button => button.showOnHover);
9490
- }, [actionButtons, isHovering]);
9504
+ const hasVisibleTrailingOrActionItems = hasAnyVisibleItem(trailingElements, isHovering) || hasAnyVisibleItem(actionButtons, isHovering);
9505
+ const handleTrailingElementClick = event => {
9506
+ event.stopPropagation();
9507
+ };
9491
9508
  const handleOnClick = event => {
9492
9509
  event.stopPropagation();
9493
9510
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
@@ -9551,10 +9568,15 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
9551
9568
  }
9552
9569
  }) : label
9553
9570
  })
9554
- }), showActionButtonContainer() && jsx("div", {
9571
+ }), hasVisibleTrailingOrActionItems && jsxs("div", {
9555
9572
  className: classes.actionButtonsContainer,
9556
9573
  "data-testid": "actionButtonContainer",
9557
- children: actionButtons.map((button, index) => {
9574
+ children: [trailingElements === null || trailingElements === void 0 ? void 0 : trailingElements.map((trailingElement, index) => jsx("div", {
9575
+ className: cx(classes.trailingElement, trailingElement.showOnHover && classes.trailingElementShowOnHover),
9576
+ "data-testid": `trailingElement-${index}`,
9577
+ onClick: handleTrailingElementClick,
9578
+ children: trailingElement.component
9579
+ }, index)), actionButtons === null || actionButtons === void 0 ? void 0 : actionButtons.map((button, index) => {
9558
9580
  const handleButtonOnClick = event => {
9559
9581
  event.stopPropagation();
9560
9582
  button.onClick(event);
@@ -9566,7 +9588,7 @@ const VentionTreeItem = /*#__PURE__*/forwardRef((inputProps, ref) => {
9566
9588
  onClick: handleButtonOnClick,
9567
9589
  children: button.component
9568
9590
  }, index);
9569
- })
9591
+ })]
9570
9592
  })]
9571
9593
  }), captionsRight && captionsRight.length > 0 && jsx("div", {
9572
9594
  className: classes.captionRightContainer,
@@ -9640,6 +9662,9 @@ const useStyles$9 = tss.withParams().withNestedSelectors().create(({
9640
9662
  [`&:hover .${classes.actionButton}`]: {
9641
9663
  visibility: "visible"
9642
9664
  },
9665
+ [`&:hover .${classes.trailingElementShowOnHover}`]: {
9666
+ visibility: "visible"
9667
+ },
9643
9668
  [`&:hover`]: {
9644
9669
  border: isSelected ? invisibleBorder : `1px solid ${theme.palette.border.blueSelected}`
9645
9670
  },
@@ -9718,6 +9743,17 @@ const useStyles$9 = tss.withParams().withNestedSelectors().create(({
9718
9743
  height: "24px",
9719
9744
  flexShrink: 0
9720
9745
  },
9746
+ trailingElement: {
9747
+ display: "flex",
9748
+ alignItems: "center",
9749
+ justifyContent: "center",
9750
+ width: "24px",
9751
+ height: "24px",
9752
+ flexShrink: 0
9753
+ },
9754
+ trailingElementShowOnHover: {
9755
+ visibility: "hidden"
9756
+ },
9721
9757
  showOnHover: {
9722
9758
  visibility: "hidden",
9723
9759
  [`${classes.actionButton}:hover &`]: {
@@ -11286,6 +11322,7 @@ const useStyles$1 = tss.withParams().create(({
11286
11322
  const defaultProps = {
11287
11323
  variant: "outlined",
11288
11324
  checkboxSize: "large",
11325
+ labelVariant: "default",
11289
11326
  checkboxPosition: "left",
11290
11327
  textAlign: "left",
11291
11328
  disabled: false,
@@ -11295,7 +11332,8 @@ const defaultProps = {
11295
11332
  const VentionCheckbox = checkboxProps => {
11296
11333
  const props = applyDefaultProps(checkboxProps, defaultProps);
11297
11334
  const {
11298
- classes
11335
+ classes,
11336
+ cx
11299
11337
  } = useStyles({
11300
11338
  variant: props.variant,
11301
11339
  checkboxSize: props.checkboxSize,
@@ -11303,37 +11341,31 @@ const VentionCheckbox = checkboxProps => {
11303
11341
  textAlign: props.textAlign,
11304
11342
  checkboxPosition: props.checkboxPosition
11305
11343
  });
11306
- // removing props that would be unknown to FormControlLabel Component
11307
- const {
11308
- labelText,
11309
- helperText,
11310
- checkboxSize,
11311
- checkboxPosition,
11312
- variant,
11313
- textAlign
11314
- } = props;
11315
- __rest(props, ["labelText", "helperText", "checkboxSize", "checkboxPosition", "variant", "textAlign"]);
11344
+ const typographyVariant = props.labelVariant === "default" ? typographyNameFromSizeMap[props.checkboxSize].labelDiminished : typographyNameFromSizeMap[props.checkboxSize].label;
11316
11345
  const sizeStyle = getSizeStyles(props.checkboxSize);
11317
11346
  const renderLabel = () => {
11318
11347
  if (!props.labelText && !props.helperText) {
11319
11348
  return null;
11320
11349
  }
11321
- const typography = getTypographyVariants(props.checkboxSize);
11322
11350
  return jsxs(Stack, {
11323
11351
  className: classes.textContainer,
11324
11352
  children: [props.labelText && jsx(Typography, {
11325
- variant: typography.labelVariant,
11326
- className: `${classes.labelText} ${props.disabled ? "Mui-disabled" : ""}`,
11353
+ variant: typographyVariant,
11354
+ className: cx(classes.labelText, {
11355
+ "Mui-disabled": props.disabled
11356
+ }),
11327
11357
  children: props.labelText
11328
11358
  }), props.labelText && props.helperText && jsx(Typography, {
11329
- variant: typography.helperVariant,
11330
- className: `${classes.helperText} ${props.disabled ? "Mui-disabled" : ""}`,
11359
+ variant: typographyVariant,
11360
+ className: cx(classes.helperText, {
11361
+ "Mui-disabled": props.disabled
11362
+ }),
11331
11363
  children: props.helperText
11332
11364
  })]
11333
11365
  });
11334
11366
  };
11335
11367
  return jsxs(Stack, {
11336
- className: `${classes.root} ${props.className || ""}`,
11368
+ className: cx(classes.root, props.className),
11337
11369
  children: [jsx(Box$1, {
11338
11370
  className: classes.checkboxContainer,
11339
11371
  children: jsx(Checkbox, {
@@ -11371,7 +11403,6 @@ const useStyles = tss.withParams().create(({
11371
11403
  }) => {
11372
11404
  const checkboxColors = getCheckboxColors(variant, disabled);
11373
11405
  const sizeStyle = getSizeStyles(checkboxSize);
11374
- getTypographyVariants(checkboxSize);
11375
11406
  return {
11376
11407
  root: {
11377
11408
  width: "100%",
@@ -11517,26 +11548,6 @@ const getCheckboxColors = (variant, disabled) => {
11517
11548
  };
11518
11549
  }
11519
11550
  };
11520
- const getTypographyVariants = checkboxSize => {
11521
- switch (checkboxSize) {
11522
- case "small":
11523
- return {
11524
- labelVariant: "uiText12Regular",
11525
- helperVariant: "uiText12Regular"
11526
- };
11527
- case "medium":
11528
- return {
11529
- labelVariant: "uiText14Regular",
11530
- helperVariant: "uiText12Regular"
11531
- };
11532
- case "large":
11533
- default:
11534
- return {
11535
- labelVariant: "uiText14Regular",
11536
- helperVariant: "uiText12Regular"
11537
- };
11538
- }
11539
- };
11540
11551
 
11541
11552
  const SIZE_CONFIG = {
11542
11553
  large: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-ui",
3
- "version": "3.38.1",
3
+ "version": "3.40.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"
@@ -8,9 +8,10 @@ export declare const getInputPaddingStyles: (size: Sizes, theme: Theme) => {
8
8
  paddingLeft: string;
9
9
  paddingRight: string;
10
10
  };
11
- export declare const typographyNameFromSizeMap: Record<"x-small" | "small" | "medium" | "large" | "x-large" | "xx-large", Record<"label" | "text" | "helperText", TypographyOwnProps["variant"]>>;
11
+ export declare const typographyNameFromSizeMap: Record<"x-small" | "small" | "medium" | "large" | "x-large" | "xx-large", Record<"label" | "labelDiminished" | "text" | "helperText", TypographyOwnProps["variant"]>>;
12
12
  export declare const getTypography: (size: Sizes, theme: Theme) => {
13
13
  label: any;
14
+ labelDiminished: any;
14
15
  text: any;
15
16
  helperText: any;
16
17
  };
@@ -2,6 +2,7 @@
2
2
  import { FormControlLabelProps } from "@mui/material";
3
3
  import "../../theme/machine-ui-theme";
4
4
  export type VentionCheckboxSizes = "small" | "medium" | "large";
5
+ export type VentionCheckboxLabelVariant = "default" | "bold";
5
6
  export type VentionCheckboxVariantStyle = "outlined";
6
7
  export type VentionCheckboxPosition = "left" | "right";
7
8
  export type VentionCheckboxTextAlign = "left" | "center" | "right";
@@ -9,6 +10,7 @@ export interface VentionCheckboxProps extends Omit<FormControlLabelProps, "contr
9
10
  labelText?: string;
10
11
  helperText?: string;
11
12
  variant?: VentionCheckboxVariantStyle;
13
+ labelVariant?: VentionCheckboxLabelVariant;
12
14
  checkboxSize?: VentionCheckboxSizes;
13
15
  checkboxPosition?: VentionCheckboxPosition;
14
16
  textAlign?: VentionCheckboxTextAlign;
@@ -8,7 +8,7 @@ export interface VentionModalProps {
8
8
  * This can be a simple string or your own React Component.
9
9
  */
10
10
  body: string | React.ReactElement;
11
- type: "positive" | "info" | "warning" | "negative" | "none";
11
+ type: "positive" | "info" | "warning" | "negative" | "loading" | "none";
12
12
  modalSize?: VentionModalBaseProps["modalSize"];
13
13
  isTouchDevice?: boolean;
14
14
  isOpen: VentionModalBaseProps["isOpen"];
@@ -20,6 +20,7 @@ export interface VentionModalProps {
20
20
  variant?: VentionButtonProps["variant"];
21
21
  loading?: VentionButtonProps["loading"];
22
22
  disabled?: VentionButtonProps["disabled"];
23
+ dataTestId?: string;
23
24
  };
24
25
  secondaryButton?: {
25
26
  text: string;
@@ -27,6 +28,7 @@ export interface VentionModalProps {
27
28
  variant?: VentionButtonProps["variant"];
28
29
  loading?: VentionButtonProps["loading"];
29
30
  disabled?: VentionButtonProps["disabled"];
31
+ dataTestId?: string;
30
32
  };
31
33
  backDropClickClosable?: boolean;
32
34
  /**
@@ -44,6 +46,7 @@ export declare const VentionModal: (props: VentionModalProps) => import("react/j
44
46
  export declare const ventionModalTestIds: {
45
47
  positiveIcon: string;
46
48
  infoIcon: string;
49
+ loading: string;
47
50
  warningIcon: string;
48
51
  negativeIcon: string;
49
52
  modalActions: string;
@@ -3,6 +3,10 @@ import { ReactElement, MouseEvent, ForwardRefExoticComponent, RefAttributes } fr
3
3
  * This is needed for Machinebuilder for virtualization.
4
4
  */
5
5
  export declare const DEFAULT_VENTION_TREE_ITEM_HEIGHT = 32;
6
+ export interface TrailingElementItem {
7
+ component: ReactElement;
8
+ showOnHover?: boolean;
9
+ }
6
10
  interface VentionTreeItemProps {
7
11
  labelText: string;
8
12
  indentLevel?: number | undefined;
@@ -18,6 +22,8 @@ interface VentionTreeItemProps {
18
22
  showOnHover?: boolean;
19
23
  onClick: (e: MouseEvent) => void;
20
24
  }[] | undefined;
25
+ /** React elements (e.g. icons with tooltips) rendered in the same area as action buttons but without button styling. */
26
+ trailingElements?: TrailingElementItem[] | undefined;
21
27
  onClick?: ((e: MouseEvent) => void) | undefined;
22
28
  onExpansionChange?: ((isExpanded: boolean) => void) | undefined;
23
29
  onLabelChange?: ((newLabel: string) => void) | undefined;
@@ -42,5 +48,5 @@ declare const useStyles: import("tss-react").Tss.UseStyles<{
42
48
  isExpanded: boolean;
43
49
  captionsRight: VentionTreeItemProps["captionsRight"];
44
50
  indentLevel: number;
45
- }, "actionButton" | "root" | "mainContent" | "singleLineContainer" | "iconContainer" | "labelContainer" | "label" | "captionRightContainer" | "captionRight" | "captionRightLabel" | "clickableCaptionRight" | "actionButtonsContainer" | "showOnHover" | "childrenItems" | "alertIcon", import("tss-react/mui").MuiThemeStyleOverridesPluginParams>;
51
+ }, "actionButton" | "trailingElement" | "trailingElementShowOnHover" | "root" | "mainContent" | "singleLineContainer" | "iconContainer" | "labelContainer" | "label" | "captionRightContainer" | "captionRight" | "captionRightLabel" | "clickableCaptionRight" | "actionButtonsContainer" | "showOnHover" | "childrenItems" | "alertIcon", import("tss-react/mui").MuiThemeStyleOverridesPluginParams>;
46
52
  export {};