@digital-ai/dot-components 3.6.0 → 3.7.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
@@ -2852,18 +2852,46 @@ const DotListDivider = ({
2852
2852
  };
2853
2853
 
2854
2854
  const rootClassName$11 = 'dot-progress';
2855
- const StyledCircularProgress = styled(CircularProgress)`
2855
+ const StyledProgress = styled.div`
2856
2856
  ${({
2857
2857
  theme
2858
2858
  }) => css`
2859
2859
  &.${rootClassName$11} {
2860
- &.MuiCircularProgress-colorPrimary {
2861
- color: ${theme.palette.figma.inProgress.normal};
2860
+ line-height: 0;
2861
+
2862
+ .dot-progress-with-label-wrapper {
2863
+ position: relative;
2864
+ display: inline-flex;
2865
+
2866
+ .progress-label-typography {
2867
+ position: absolute;
2868
+ display: flex;
2869
+ align-items: center;
2870
+ justify-content: center;
2871
+ inset: 0;
2872
+ }
2862
2873
  }
2863
2874
 
2864
- &.MuiCircularProgress-colorSecondary {
2865
- color: ${theme.palette.figma.inProgress.secondary};
2875
+ .dot-progress-background-wrapper {
2876
+ position: relative;
2877
+
2878
+ .dot-progress-background {
2879
+ color: ${theme.palette.grey[100]};
2880
+ position: absolute;
2881
+ left: 0;
2882
+ }
2883
+ }
2884
+
2885
+ .dot-circular-progress {
2886
+ &.MuiCircularProgress-colorPrimary {
2887
+ color: ${theme.palette.figma.inProgress.normal};
2888
+ }
2889
+
2890
+ &.MuiCircularProgress-colorSecondary {
2891
+ color: ${theme.palette.figma.inProgress.secondary};
2892
+ }
2866
2893
  }
2894
+ }
2867
2895
  `}
2868
2896
  `;
2869
2897
 
@@ -2872,6 +2900,7 @@ const DotProgress = ({
2872
2900
  color = 'secondary',
2873
2901
  className,
2874
2902
  'data-testid': dataTestId,
2903
+ hasPercentageLabel = false,
2875
2904
  size = 40,
2876
2905
  thickness = 3.6,
2877
2906
  tooltip = 'loading data',
@@ -2884,13 +2913,10 @@ const DotProgress = ({
2884
2913
  console.warn('a11y: DotProgress must have an ariaLabel to describe the progress component');
2885
2914
  }
2886
2915
  }, []);
2887
- return jsx(DotTooltip, {
2888
- title: tooltip,
2889
- children: jsx(StyledCircularProgress, {
2916
+ const renderCircularProgress = (hasBackgroundProgress = false) => {
2917
+ const circularProgress = jsx(CircularProgress, {
2890
2918
  "aria-label": ariaLabel || tooltip,
2891
- classes: {
2892
- root: rootClasses
2893
- },
2919
+ className: "dot-circular-progress",
2894
2920
  color: color,
2895
2921
  "data-testid": dataTestId,
2896
2922
  role: "progressbar",
@@ -2898,6 +2924,34 @@ const DotProgress = ({
2898
2924
  thickness: thickness,
2899
2925
  value: value,
2900
2926
  variant: variant
2927
+ });
2928
+ if (hasBackgroundProgress) {
2929
+ return jsxs("div", {
2930
+ className: "dot-progress-background-wrapper",
2931
+ children: [jsx(CircularProgress, {
2932
+ "aria-label": "background progress",
2933
+ className: "dot-progress-background",
2934
+ size: size,
2935
+ thickness: thickness,
2936
+ value: 100,
2937
+ variant: "determinate"
2938
+ }), circularProgress]
2939
+ });
2940
+ }
2941
+ return circularProgress;
2942
+ };
2943
+ return jsx(StyledProgress, {
2944
+ className: rootClasses,
2945
+ children: jsx(DotTooltip, {
2946
+ title: tooltip,
2947
+ children: hasPercentageLabel ? jsxs("div", {
2948
+ className: "dot-progress-with-label-wrapper",
2949
+ children: [renderCircularProgress(true), jsxs(DotTypography, {
2950
+ className: "progress-label-typography",
2951
+ variant: "caption",
2952
+ children: [value, "%"]
2953
+ })]
2954
+ }) : renderCircularProgress()
2901
2955
  })
2902
2956
  });
2903
2957
  };
@@ -5400,7 +5454,7 @@ const StyledSidebar = styled.aside`
5400
5454
 
5401
5455
  .toggle-nav {
5402
5456
  border-top: 1px solid ${theme.palette.figma.border.default};
5403
- padding: ${theme.spacing(1)};
5457
+ padding: ${theme.spacing(1, 2)};
5404
5458
  text-align: right;
5405
5459
 
5406
5460
  .dot-icon {
@@ -5612,6 +5666,7 @@ const DotSidebar = ({
5612
5666
  const hasBackItem = goBack && backItem;
5613
5667
  const displayHeader = title || hasAppLogo;
5614
5668
  const openClass = isOpen ? 'open' : 'collapsed';
5669
+ const collapseKey = 'q';
5615
5670
  const checkPrimaryNavMissingIcons = () => navItems.some(item => !item.divider && !item.startIcon);
5616
5671
  useEffect(() => {
5617
5672
  // Incorrect usage warning
@@ -5625,10 +5680,22 @@ const DotSidebar = ({
5625
5680
  useEffect(() => {
5626
5681
  setSidebarWidth(isOpen ? width : 58);
5627
5682
  }, [isOpen]);
5628
- const collapseNav = () => {
5683
+ const toggleNavCollapseState = () => {
5629
5684
  onCollapseChange && onCollapseChange(isOpen);
5630
5685
  setIsOpen(!isOpen);
5631
5686
  };
5687
+ useEffect(() => {
5688
+ const handleKeyPress = event => {
5689
+ const element = event.target;
5690
+ if (event.key === collapseKey && !['INPUT', 'TEXTAREA'].includes(element.nodeName) && !element.isContentEditable) {
5691
+ toggleNavCollapseState();
5692
+ }
5693
+ };
5694
+ window.addEventListener('keydown', handleKeyPress);
5695
+ return () => {
5696
+ window.removeEventListener('keydown', handleKeyPress);
5697
+ };
5698
+ }, [isOpen]);
5632
5699
  const sidebarClasses = useStylesWithRootClass('side-nav', openClass);
5633
5700
  const rootClasses = useStylesWithRootClass(rootClassName$R, openClass, className);
5634
5701
  return jsxs(StyledSidebar, {
@@ -5681,13 +5748,14 @@ const DotSidebar = ({
5681
5748
  }), collapsable && jsx("div", {
5682
5749
  className: "toggle-nav",
5683
5750
  children: jsx(DotTooltip, {
5684
- title: isOpen ? 'Collapse' : 'Expand',
5751
+ title: (isOpen ? 'Collapse' : 'Expand') + ` ${collapseKey}`,
5752
+ placement: "right",
5685
5753
  children: jsx(DotIconButton, {
5686
5754
  ariaLabel: "collapse sidebar navigation",
5687
5755
  "data-testid": "toggle-nav",
5688
- iconId: isOpen ? 'chevron-left' : 'chevron-right',
5756
+ iconId: isOpen ? 'collapse' : 'expand',
5689
5757
  iconSize: "small",
5690
- onClick: collapseNav,
5758
+ onClick: toggleNavCollapseState,
5691
5759
  size: "small"
5692
5760
  })
5693
5761
  })
@@ -6555,6 +6623,7 @@ const DotAutoComplete = ({
6555
6623
  getOptionLabel: option => parseAutoCompleteValue(option),
6556
6624
  getOptionDisabled: checkIfOptionDisabled,
6557
6625
  groupBy: group ? option => option.group : undefined,
6626
+ id: inputId,
6558
6627
  inputValue: inputValue,
6559
6628
  isOptionEqualToValue: isOptionEqualToValue,
6560
6629
  ListboxComponent: ListboxComponent,
@@ -8190,7 +8259,7 @@ const StyledEmptyState = styled.div`
8190
8259
  }
8191
8260
 
8192
8261
  .empty-state-image {
8193
- min-height: 239px;
8262
+ min-height: ${theme.spacing(10)};
8194
8263
  margin-bottom: ${theme.spacing(5)};
8195
8264
  }
8196
8265
 
@@ -8857,8 +8926,8 @@ const StyledProgressButton = styled(DotButton)`
8857
8926
  // button's dimensions don't change
8858
8927
  visibility: hidden;
8859
8928
  }
8860
- .progress-circle {
8861
- color: ${theme.palette.figma.typography.black};
8929
+ .dot-circular-progress {
8930
+ color: ${theme.palette.figma.typography.black} !important;
8862
8931
  position: absolute;
8863
8932
  top: 0;
8864
8933
  right: 0;
@@ -8911,6 +8980,7 @@ const DotProgressButton = ({
8911
8980
  className: titleClasses,
8912
8981
  children: children
8913
8982
  }), isLoading && jsx(DotProgress, {
8983
+ ariaLabel: "loading",
8914
8984
  className: "progress-circle",
8915
8985
  size: progressCircleSize
8916
8986
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN <LICENSE.md>",
6
6
  "contributors": [
@@ -4,6 +4,8 @@ export type progressVariantOptions = 'determinate' | 'indeterminate';
4
4
  export interface ProgressProps extends CommonProps {
5
5
  /** color of the loading spinner border */
6
6
  color?: progressColorOptions;
7
+ /** If true, it will display percentage label at the center of the circle */
8
+ hasPercentageLabel?: boolean;
7
9
  /** controls the diameter of the loading spinner */
8
10
  size?: number | string;
9
11
  /** controls thickness of the loading spinner border */
@@ -15,4 +17,4 @@ export interface ProgressProps extends CommonProps {
15
17
  /** type of progress spinner displayed */
16
18
  variant?: progressVariantOptions;
17
19
  }
18
- export declare const DotProgress: ({ ariaLabel, color, className, "data-testid": dataTestId, size, thickness, tooltip, value, variant, }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const DotProgress: ({ ariaLabel, color, className, "data-testid": dataTestId, hasPercentageLabel, size, thickness, tooltip, value, variant, }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,2 @@
1
- import { CircularProgress } from '@mui/material';
2
1
  export declare const rootClassName = "dot-progress";
3
- export declare const StyledCircularProgress: import("styled-components").StyledComponent<typeof CircularProgress, any, {}, never>;
2
+ export declare const StyledProgress: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,4 +1,4 @@
1
- import { ButtonProps } from '../button/Button';
1
+ import { ButtonProps } from '../button';
2
2
  export declare const SPINNER_DEFAULT_SIZE = 20;
3
3
  export declare const SPINNER_LARGE_SIZE = 24;
4
4
  export interface ProgressButtonProps extends ButtonProps {
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  export declare const rootClassName = "dot-progress-button";
3
- export declare const StyledProgressButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../button/Button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, {}, never>;
3
+ export declare const StyledProgressButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, {}, never>;