@juspay/blend-design-system 0.0.37-beta.4 → 0.0.37-beta.5

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.
Files changed (72) hide show
  1. package/dist/components/Breadcrumb/Breadcrumb.d.ts +2 -5
  2. package/dist/components/Breadcrumb/types.d.ts +6 -0
  3. package/dist/components/Charts/ChartUtils.d.ts +2 -0
  4. package/dist/components/Charts/types.d.ts +2 -2
  5. package/dist/components/DateRangePicker/types.d.ts +1 -1
  6. package/dist/components/DateRangePicker/utils.d.ts +2 -0
  7. package/dist/components/Directory/Directory.d.ts +1 -1
  8. package/dist/components/Directory/types.d.ts +1 -1
  9. package/dist/components/Directory/utils.d.ts +2 -0
  10. package/dist/components/Radio/StyledRadio.d.ts +0 -1
  11. package/dist/components/Sidebar/SidebarContent.d.ts +1 -1
  12. package/dist/components/Sidebar/types.d.ts +10 -1
  13. package/dist/components/Sidebar/utils.d.ts +1 -1
  14. package/dist/components/SidebarV2/SidebarV2Panel.d.ts +1 -1
  15. package/dist/components/SidebarV2/index.d.ts +1 -1
  16. package/dist/components/SidebarV2/types.d.ts +3 -0
  17. package/dist/components/Stepper/types.d.ts +2 -0
  18. package/dist/main.js +27657 -27314
  19. package/dist/tokens.js +17 -16
  20. package/lib/components/Avatar/Avatar.tsx +6 -1
  21. package/lib/components/AvatarGroup/AvatarGroup.tsx +1 -1
  22. package/lib/components/AvatarV2/AvatarV2.tsx +10 -1
  23. package/lib/components/Breadcrumb/Breadcrumb.tsx +9 -8
  24. package/lib/components/Breadcrumb/types.ts +12 -0
  25. package/lib/components/Button/ButtonBase.tsx +1 -1
  26. package/lib/components/Card/CardComponents.tsx +52 -17
  27. package/lib/components/Charts/ChartUtils.tsx +7 -0
  28. package/lib/components/Charts/Charts.tsx +4 -2
  29. package/lib/components/Charts/CoreChart.tsx +4 -2
  30. package/lib/components/Charts/types.tsx +2 -2
  31. package/lib/components/ChartsV2/ChartV2.tsx +1 -1
  32. package/lib/components/Checkbox/Checkbox.tsx +29 -7
  33. package/lib/components/CodeBlock/CodeBlock.tsx +47 -1
  34. package/lib/components/CodeBlock/codeBlock.token.ts +5 -5
  35. package/lib/components/CodeEditor/CodeEditor.tsx +26 -4
  36. package/lib/components/CodeEditor/MonacoEditorWrapper.tsx +13 -1
  37. package/lib/components/DataTable/DataTable.tsx +8 -0
  38. package/lib/components/DataTable/TableHeader/FilterComponents.tsx +4 -0
  39. package/lib/components/DateRangePicker/DateRangePicker.tsx +34 -17
  40. package/lib/components/DateRangePicker/types.ts +5 -5
  41. package/lib/components/DateRangePicker/utils.ts +5 -0
  42. package/lib/components/Directory/Directory.tsx +3 -2
  43. package/lib/components/Directory/types.ts +1 -1
  44. package/lib/components/Directory/utils.ts +6 -0
  45. package/lib/components/Drawer/components/DrawerBase.tsx +16 -0
  46. package/lib/components/Drawer/components/NestedSelectDrawer.tsx +13 -1
  47. package/lib/components/Drawer/components/SelectDrawer.tsx +9 -1
  48. package/lib/components/Inputs/OTPInput/OTPInput.tsx +5 -3
  49. package/lib/components/Menu/Menu.tsx +9 -1
  50. package/lib/components/Modal/useModal.ts +7 -0
  51. package/lib/components/Radio/Radio.tsx +12 -5
  52. package/lib/components/Radio/StyledRadio.tsx +33 -17
  53. package/lib/components/Sidebar/Sidebar.tsx +11 -1
  54. package/lib/components/Sidebar/SidebarContent.tsx +5 -2
  55. package/lib/components/Sidebar/TenantPanel.tsx +52 -34
  56. package/lib/components/Sidebar/types.ts +11 -1
  57. package/lib/components/Sidebar/utils.ts +1 -1
  58. package/lib/components/SidebarV2/SecondarySidebar.tsx +86 -44
  59. package/lib/components/SidebarV2/SidebarV2Panel.tsx +4 -2
  60. package/lib/components/SidebarV2/index.ts +1 -0
  61. package/lib/components/SidebarV2/types.ts +4 -0
  62. package/lib/components/StatCard/statcard.tokens.ts +1 -1
  63. package/lib/components/Stepper/VerticalStepper.tsx +209 -171
  64. package/lib/components/Stepper/types.ts +2 -0
  65. package/lib/components/StepperV2/Stepper/Steps.tsx +15 -1
  66. package/lib/components/Text/Text.tsx +1 -0
  67. package/lib/components/Upload/Upload.tsx +6 -0
  68. package/lib/components/Upload/components/FileListDisplay.tsx +159 -16
  69. package/lib/components/Upload/utils.ts +10 -2
  70. package/lib/context/ThemeProvider.tsx +19 -8
  71. package/lib/hooks/useDebounce.ts +9 -1
  72. package/package.json +1 -1
@@ -440,7 +440,7 @@ const StepComponent = forwardRef<
440
440
  display="flex"
441
441
  justifyContent="space-between"
442
442
  gap={8}
443
- alignItems="flex-start"
443
+ alignItems="center"
444
444
  >
445
445
  <Block
446
446
  display="flex"
@@ -566,6 +566,16 @@ const StepComponent = forwardRef<
566
566
  />
567
567
  </Block>
568
568
  )}
569
+ {step.slot && (
570
+ <Block
571
+ flexShrink={0}
572
+ onClick={(e: React.MouseEvent) => {
573
+ e.stopPropagation()
574
+ }}
575
+ >
576
+ {step.slot}
577
+ </Block>
578
+ )}
569
579
  </Block>
570
580
 
571
581
  {isExpanded &&
@@ -623,184 +633,212 @@ const StepComponent = forwardRef<
623
633
  }
624
634
  >
625
635
  <Block
626
- data-element="substep"
627
- data-id={`Substep ${index + 1}: ${subStep.title}${
628
- isSubstepCompleted
629
- ? ', completed'
630
- : isSubstepCurrent
631
- ? ', current'
632
- : isSubstepDisabled
633
- ? ', disabled'
634
- : isSubstepSkipped
635
- ? ', skipped'
636
- : ', pending'
637
- }`}
638
- data-numeric={subStep.id}
639
- ref={(el) => {
640
- substepRefs.current[index] =
641
- el
642
- }}
643
- role={
644
- clickable
645
- ? 'button'
646
- : 'group'
647
- }
648
- tabIndex={
649
- clickable &&
650
- !isSubstepDisabled
651
- ? 0
652
- : -1
653
- }
654
- aria-label={`Substep ${index + 1}: ${subStep.title}${
655
- isSubstepCompleted
656
- ? ', completed'
657
- : isSubstepCurrent
658
- ? ', current'
659
- : isSubstepDisabled
660
- ? ', disabled'
661
- : isSubstepSkipped
662
- ? ', skipped'
663
- : ', pending'
664
- }`}
665
- aria-disabled={
666
- isSubstepDisabled
667
- ? 'true'
668
- : undefined
669
- }
670
- aria-current={
671
- isSubstepCurrent
672
- ? 'step'
673
- : undefined
674
- }
675
- style={{
676
- cursor: clickable
677
- ? 'pointer'
678
- : 'default',
679
- }}
680
- onClick={
681
- clickable && onSubstepClick
682
- ? (
683
- e: React.MouseEvent
684
- ) => {
685
- e.preventDefault()
686
- e.stopPropagation()
687
- onSubstepClick(
688
- stepIndex,
689
- index
690
- )
691
- }
692
- : undefined
693
- }
694
- onKeyDown={(
695
- event: React.KeyboardEvent
696
- ) => {
697
- if (isSubstepDisabled)
698
- return
699
-
700
- switch (event.key) {
701
- case 'Enter':
702
- case ' ': {
703
- if (
704
- clickable &&
705
- onSubstepClick
706
- ) {
636
+ display="flex"
637
+ justifyContent="space-between"
638
+ alignItems="center"
639
+ gap={8}
640
+ >
641
+ <Block
642
+ data-element="substep"
643
+ data-id={`Substep ${index + 1}: ${subStep.title}${
644
+ isSubstepCompleted
645
+ ? ', completed'
646
+ : isSubstepCurrent
647
+ ? ', current'
648
+ : isSubstepDisabled
649
+ ? ', disabled'
650
+ : isSubstepSkipped
651
+ ? ', skipped'
652
+ : ', pending'
653
+ }`}
654
+ data-numeric={subStep.id}
655
+ ref={(el) => {
656
+ substepRefs.current[
657
+ index
658
+ ] = el
659
+ }}
660
+ role={
661
+ clickable
662
+ ? 'button'
663
+ : 'group'
664
+ }
665
+ tabIndex={
666
+ clickable &&
667
+ !isSubstepDisabled
668
+ ? 0
669
+ : -1
670
+ }
671
+ aria-label={`Substep ${index + 1}: ${subStep.title}${
672
+ isSubstepCompleted
673
+ ? ', completed'
674
+ : isSubstepCurrent
675
+ ? ', current'
676
+ : isSubstepDisabled
677
+ ? ', disabled'
678
+ : isSubstepSkipped
679
+ ? ', skipped'
680
+ : ', pending'
681
+ }`}
682
+ aria-disabled={
683
+ isSubstepDisabled
684
+ ? 'true'
685
+ : undefined
686
+ }
687
+ aria-current={
688
+ isSubstepCurrent
689
+ ? 'step'
690
+ : undefined
691
+ }
692
+ style={{
693
+ flex: 1,
694
+ cursor: clickable
695
+ ? 'pointer'
696
+ : 'default',
697
+ }}
698
+ onClick={
699
+ clickable &&
700
+ onSubstepClick
701
+ ? (
702
+ e: React.MouseEvent
703
+ ) => {
704
+ e.preventDefault()
705
+ e.stopPropagation()
706
+ onSubstepClick(
707
+ stepIndex,
708
+ index
709
+ )
710
+ }
711
+ : undefined
712
+ }
713
+ onKeyDown={(
714
+ event: React.KeyboardEvent
715
+ ) => {
716
+ if (isSubstepDisabled)
717
+ return
718
+
719
+ switch (event.key) {
720
+ case 'Enter':
721
+ case ' ': {
722
+ if (
723
+ clickable &&
724
+ onSubstepClick
725
+ ) {
726
+ event.preventDefault()
727
+ event.stopPropagation()
728
+ onSubstepClick(
729
+ stepIndex,
730
+ index
731
+ )
732
+ }
733
+ break
734
+ }
735
+ case 'ArrowUp': {
707
736
  event.preventDefault()
708
- event.stopPropagation()
709
- onSubstepClick(
710
- stepIndex,
711
- index
712
- )
737
+ const prevIndex =
738
+ Math.max(
739
+ index -
740
+ 1,
741
+ 0
742
+ )
743
+ if (
744
+ step.substeps &&
745
+ !step
746
+ .substeps[
747
+ prevIndex
748
+ ]
749
+ ?.disabled &&
750
+ substepRefs
751
+ .current[
752
+ prevIndex
753
+ ]
754
+ ) {
755
+ setFocusedSubstepIndex(
756
+ prevIndex
757
+ )
758
+ substepRefs.current[
759
+ prevIndex
760
+ ]?.focus()
761
+ }
762
+ break
713
763
  }
714
- break
715
- }
716
- case 'ArrowUp': {
717
- event.preventDefault()
718
- const prevIndex =
719
- Math.max(
720
- index - 1,
721
- 0
722
- )
723
- if (
724
- step.substeps &&
725
- !step.substeps[
726
- prevIndex
727
- ]?.disabled &&
728
- substepRefs
729
- .current[
730
- prevIndex
731
- ]
732
- ) {
733
- setFocusedSubstepIndex(
734
- prevIndex
735
- )
736
- substepRefs.current[
737
- prevIndex
738
- ]?.focus()
764
+ case 'ArrowDown': {
765
+ event.preventDefault()
766
+ const nextIndex =
767
+ Math.min(
768
+ index +
769
+ 1,
770
+ step.substeps
771
+ ? step
772
+ .substeps
773
+ .length -
774
+ 1
775
+ : 0
776
+ )
777
+ if (
778
+ step.substeps &&
779
+ !step
780
+ .substeps[
781
+ nextIndex
782
+ ]
783
+ ?.disabled &&
784
+ substepRefs
785
+ .current[
786
+ nextIndex
787
+ ]
788
+ ) {
789
+ setFocusedSubstepIndex(
790
+ nextIndex
791
+ )
792
+ substepRefs.current[
793
+ nextIndex
794
+ ]?.focus()
795
+ }
796
+ break
739
797
  }
740
- break
741
- }
742
- case 'ArrowDown': {
743
- event.preventDefault()
744
- const nextIndex =
745
- Math.min(
746
- index + 1,
747
- step.substeps
748
- ? step
749
- .substeps
750
- .length -
751
- 1
752
- : 0
753
- )
754
- if (
755
- step.substeps &&
756
- !step.substeps[
757
- nextIndex
758
- ]?.disabled &&
759
- substepRefs
760
- .current[
761
- nextIndex
762
- ]
763
- ) {
798
+ case 'ArrowLeft':
799
+ case 'ArrowRight': {
800
+ // Move back to parent step
801
+ event.preventDefault()
764
802
  setFocusedSubstepIndex(
765
- nextIndex
803
+ null
766
804
  )
767
- substepRefs.current[
768
- nextIndex
769
- ]?.focus()
805
+ if (
806
+ ref &&
807
+ typeof ref !==
808
+ 'function'
809
+ ) {
810
+ ref.current?.focus()
811
+ }
812
+ break
770
813
  }
771
- break
772
814
  }
773
- case 'ArrowLeft':
774
- case 'ArrowRight': {
775
- // Move back to parent step
776
- event.preventDefault()
777
- setFocusedSubstepIndex(
778
- null
779
- )
780
- if (
781
- ref &&
782
- typeof ref !==
783
- 'function'
784
- ) {
785
- ref.current?.focus()
786
- }
787
- break
788
- }
789
- }
790
- }}
791
- onFocus={() => {
792
- setFocusedSubstepIndex(
793
- index
794
- )
795
- }}
796
- >
797
- <Text
798
- fontSize={12}
799
- fontWeight={500}
800
- color={textColor}
815
+ }}
816
+ onFocus={() => {
817
+ setFocusedSubstepIndex(
818
+ index
819
+ )
820
+ }}
801
821
  >
802
- {subStep.title}
803
- </Text>
822
+ <Text
823
+ fontSize={12}
824
+ fontWeight={500}
825
+ color={textColor}
826
+ >
827
+ {subStep.title}
828
+ </Text>
829
+ </Block>
830
+ {subStep.slot && (
831
+ <Block
832
+ flexShrink={0}
833
+ onClick={(
834
+ e: React.MouseEvent
835
+ ) => {
836
+ e.stopPropagation()
837
+ }}
838
+ >
839
+ {subStep.slot}
840
+ </Block>
841
+ )}
804
842
  </Block>
805
843
  </Block>
806
844
  )
@@ -26,6 +26,7 @@ export type SubStep = {
26
26
  title: string
27
27
  status?: StepState
28
28
  disabled?: boolean
29
+ slot?: ReactNode
29
30
  }
30
31
 
31
32
  export type Step = {
@@ -35,6 +36,7 @@ export type Step = {
35
36
  disabled?: boolean
36
37
  description?: string
37
38
  icon?: ReactNode
39
+ slot?: ReactNode
38
40
  substeps?: SubStep[]
39
41
  isExpandable?: boolean
40
42
  isExpanded?: boolean
@@ -62,6 +62,9 @@ export const Steps = forwardRef<
62
62
  const [isExpanded, setIsExpanded] = useState<boolean>(
63
63
  step.isExpanded ?? hasSubsteps
64
64
  )
65
+ const focusTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(
66
+ null
67
+ )
65
68
 
66
69
  useEffect(() => {
67
70
  if (step.isExpanded !== undefined) {
@@ -84,6 +87,14 @@ export const Steps = forwardRef<
84
87
  return () => cancelAnimationFrame(animationFrameId)
85
88
  }, [isExpanded, hasSubsteps, step.substeps?.length])
86
89
 
90
+ useEffect(() => {
91
+ return () => {
92
+ if (focusTimeoutRef.current) {
93
+ clearTimeout(focusTimeoutRef.current)
94
+ }
95
+ }
96
+ }, [])
97
+
87
98
  const stepState = getStepState(step, isCompleted, isCurrent)
88
99
  const isClickable = Boolean(clickable && !step.disabled && onClick)
89
100
 
@@ -192,7 +203,10 @@ export const Steps = forwardRef<
192
203
  if (!isHorizontal && hasSubsteps && !isExpanded) {
193
204
  event.preventDefault()
194
205
  toggleExpand()
195
- setTimeout(() => focusFirstSubstep(), 100)
206
+ focusTimeoutRef.current = setTimeout(
207
+ () => focusFirstSubstep(),
208
+ 100
209
+ )
196
210
  return
197
211
  }
198
212
  if (!isHorizontal && hasSubsteps && isExpanded) {
@@ -119,6 +119,7 @@ const Text = ({
119
119
  fontWeight={fontWeight}
120
120
  color={color ?? 'inherit'}
121
121
  style={style}
122
+ truncate={truncate}
122
123
  {...rest}
123
124
  >
124
125
  {children}
@@ -146,6 +146,12 @@ const Upload: React.FC<UploadProps> = ({
146
146
 
147
147
  const uploadManager = useMemo(() => createUploadManager(), [])
148
148
 
149
+ useEffect(() => {
150
+ return () => {
151
+ uploadManager.cancelAllUploads()
152
+ }
153
+ }, [uploadManager])
154
+
149
155
  const handleInternalDrop = useMemo(
150
156
  () =>
151
157
  createComplexDropHandler(