@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
@@ -1,12 +1,21 @@
1
1
  import { type ReactNode } from 'react'
2
+ import type { BadgeColor, BadgePosition, BadgeSize } from '../Badge/Badge.types'
2
3
  import type { DirectoryData, NavbarItem } from '../Directory/types'
3
4
  import type { MerchantInfo } from '../Topbar/types'
4
5
 
6
+ export type TenantBadge = {
7
+ text: string
8
+ size?: BadgeSize
9
+ color?: BadgeColor
10
+ position?: BadgePosition
11
+ }
12
+
5
13
  export type LeftPanelItem = {
6
14
  label: string
7
15
  icon: ReactNode
8
16
  value?: string
9
17
  showInPanel?: boolean
18
+ badge?: TenantBadge
10
19
  }
11
20
 
12
21
  export type LeftPanelInfo = {
@@ -23,6 +32,7 @@ export type TenantItem = {
23
32
  value?: string
24
33
  icon: ReactNode
25
34
  showInPanel?: boolean
35
+ badge?: TenantBadge
26
36
  }
27
37
 
28
38
  export type SidebarMerchantInfo = {
@@ -39,7 +49,7 @@ export type SidebarStateChangeType = 'collapsed' | 'expanded' | 'intermediate'
39
49
  export type SidebarProps = {
40
50
  showLeftPanel?: boolean
41
51
  children: ReactNode
42
- data: DirectoryData[]
52
+ data: DirectoryData[] | null
43
53
  leftPanel?: LeftPanelInfo
44
54
  topbar: ReactNode
45
55
  footer?: ReactNode
@@ -144,7 +144,7 @@ export const isControlledSidebar = (
144
144
  }
145
145
 
146
146
  export const getMobileNavigationItems = (
147
- directory: DirectoryData[]
147
+ directory?: DirectoryData[] | null
148
148
  ): MobileNavigationItem[] => {
149
149
  if (!directory || !Array.isArray(directory)) {
150
150
  return []
@@ -1,8 +1,10 @@
1
+ import type { ButtonHTMLAttributes } from 'react'
1
2
  import { SidebarV2TokensType } from './sidebarV2.tokens'
2
- import type { SecondarySidebarInfo } from './types'
3
+ import type { SecondarySidebarInfo, SecondarySidebarItem } from './types'
3
4
  import Block from '../Primitives/Block/Block'
4
5
  import PrimitiveButton from '../Primitives/PrimitiveButton/PrimitiveButton'
5
6
  import { TooltipV2, TooltipV2Side, TooltipV2Size } from '../TooltipV2'
7
+ import { Badge, BadgeColor, BadgeSize } from '../Badge'
6
8
  import styled from 'styled-components'
7
9
 
8
10
  const ScrollableContainer = styled(Block)`
@@ -22,6 +24,82 @@ type Props = {
22
24
  tokens: SidebarV2TokensType
23
25
  }
24
26
 
27
+ type SecondarySidebarItemButtonProps = {
28
+ item: SecondarySidebarItem
29
+ isSelected: boolean
30
+ onSelect: (value: string) => void
31
+ buttonProps?: ButtonHTMLAttributes<HTMLButtonElement>
32
+ tokens: SidebarV2TokensType
33
+ }
34
+
35
+ function SecondarySidebarItemButton({
36
+ item,
37
+ isSelected,
38
+ onSelect,
39
+ buttonProps,
40
+ tokens,
41
+ }: SecondarySidebarItemButtonProps) {
42
+ const itemButton = (
43
+ <PrimitiveButton
44
+ {...buttonProps}
45
+ type="button"
46
+ cursor="pointer"
47
+ display="flex"
48
+ alignItems="center"
49
+ justifyContent="center"
50
+ width={tokens.secondarySidebar.item.width}
51
+ height={tokens.secondarySidebar.item.height}
52
+ borderRadius={tokens.secondarySidebar.item.borderRadius}
53
+ border={
54
+ isSelected
55
+ ? tokens.secondarySidebar.item.border.active
56
+ : tokens.secondarySidebar.item.border.default
57
+ }
58
+ _hover={{
59
+ backgroundColor:
60
+ tokens.secondarySidebar.item.backgroundColor.hover,
61
+ outline: 'none',
62
+ border: isSelected
63
+ ? tokens.secondarySidebar.item.border.active
64
+ : tokens.secondarySidebar.item.border.hover,
65
+ }}
66
+ onClick={(e) => {
67
+ onSelect(item.value)
68
+ buttonProps?.onClick?.(e)
69
+ }}
70
+ aria-label={`Select tenant: ${item.label}`}
71
+ aria-pressed={isSelected}
72
+ >
73
+ <span aria-hidden="true">{item.icon}</span>
74
+ </PrimitiveButton>
75
+ )
76
+
77
+ const trigger = item.badge ? (
78
+ <Badge
79
+ text={item.badge.text.slice(0, 2)}
80
+ size={item.badge.size || BadgeSize.SM}
81
+ color={item.badge.color || BadgeColor.PRIMARY}
82
+ position={item.badge.position || 'bottom-right'}
83
+ isCircular
84
+ >
85
+ {itemButton}
86
+ </Badge>
87
+ ) : (
88
+ itemButton
89
+ )
90
+
91
+ return (
92
+ <TooltipV2
93
+ content={item.label}
94
+ side={TooltipV2Side.RIGHT}
95
+ delayDuration={500}
96
+ size={TooltipV2Size.SM}
97
+ >
98
+ {trigger}
99
+ </TooltipV2>
100
+ )
101
+ }
102
+
25
103
  export function SecondarySidebar({ id, secondarySidebar, tokens }: Props) {
26
104
  if (!secondarySidebar || (secondarySidebar?.items?.length ?? 0) === 0) {
27
105
  return null
@@ -59,50 +137,14 @@ export function SecondarySidebar({ id, secondarySidebar, tokens }: Props) {
59
137
  style={{ minHeight: 0 }}
60
138
  >
61
139
  {items?.map((item) => (
62
- <TooltipV2
140
+ <SecondarySidebarItemButton
63
141
  key={item.value}
64
- content={item.label}
65
- side={TooltipV2Side.RIGHT}
66
- delayDuration={500}
67
- size={TooltipV2Size.SM}
68
- >
69
- <PrimitiveButton
70
- {...buttonProps}
71
- type="button"
72
- cursor="pointer"
73
- display="flex"
74
- alignItems="center"
75
- justifyContent="center"
76
- width={tokens.secondarySidebar.item.width}
77
- height={tokens.secondarySidebar.item.height}
78
- borderRadius={
79
- tokens.secondarySidebar.item.borderRadius
80
- }
81
- border={
82
- isSelected(item.value)
83
- ? tokens.secondarySidebar.item.border.active
84
- : tokens.secondarySidebar.item.border
85
- .default
86
- }
87
- _hover={{
88
- backgroundColor:
89
- tokens.secondarySidebar.item.backgroundColor
90
- .hover,
91
- outline: 'none',
92
- border: isSelected(item.value)
93
- ? tokens.secondarySidebar.item.border.active
94
- : tokens.secondarySidebar.item.border.hover,
95
- }}
96
- onClick={(e) => {
97
- onSelect?.(item.value)
98
- buttonProps?.onClick?.(e)
99
- }}
100
- aria-label={`Select tenant: ${item.label}`}
101
- aria-pressed={isSelected(item.value)}
102
- >
103
- <span aria-hidden="true">{item.icon}</span>
104
- </PrimitiveButton>
105
- </TooltipV2>
142
+ item={item}
143
+ isSelected={isSelected(item.value)}
144
+ onSelect={onSelect}
145
+ buttonProps={buttonProps}
146
+ tokens={tokens}
147
+ />
106
148
  ))}
107
149
  </ScrollableContainer>
108
150
 
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react'
2
2
  import styled from 'styled-components'
3
3
  import Block from '../Primitives/Block/Block'
4
4
  import Directory from '../Directory/Directory'
5
+ import { normalizeDirectoryData } from '../Directory/utils'
5
6
  import type { DirectoryData } from '../Directory/types'
6
7
  import SidebarV2Header from './SidebarV2Header'
7
8
  import SidebarV2Footer from './SidebarV2Footer'
@@ -43,7 +44,7 @@ export type SidebarV2PanelProps = {
43
44
  sidebarCollapseKey: string
44
45
  onToggle: () => void
45
46
  sidebarNavId?: string
46
- data: DirectoryData[]
47
+ data: DirectoryData[] | null
47
48
  idPrefix: string
48
49
  activeItem?: string | null
49
50
  onActiveItemChange?: (item: string | null) => void
@@ -77,6 +78,7 @@ const SidebarV2Panel = ({
77
78
  tokens,
78
79
  }: SidebarV2PanelProps) => {
79
80
  const trackHover = shouldTrackHover(setIsHovering)
81
+ const directoryData = normalizeDirectoryData(data)
80
82
 
81
83
  return (
82
84
  <Block
@@ -118,7 +120,7 @@ const SidebarV2Panel = ({
118
120
  }
119
121
  >
120
122
  <Directory
121
- directoryData={data}
123
+ directoryData={directoryData}
122
124
  idPrefix={idPrefix}
123
125
  activeItem={activeItem}
124
126
  onActiveItemChange={onActiveItemChange}
@@ -8,6 +8,7 @@ export type {
8
8
  SecondarySidebarItem,
9
9
  SidebarV2Props,
10
10
  SidebarV2StateChangeType,
11
+ TenantBadge,
11
12
  } from './types'
12
13
  export { SidebarV2StateChange } from './types'
13
14
  export type { SidebarV2PanelProps } from './SidebarV2Panel'
@@ -1,6 +1,9 @@
1
1
  import type { ButtonHTMLAttributes, ReactNode } from 'react'
2
2
  import type { DirectoryData } from '../Directory/types'
3
3
  import type { MerchantInfo } from '../Topbar/types'
4
+ import type { TenantBadge } from '../Sidebar/types'
5
+
6
+ export type { TenantBadge } from '../Sidebar/types'
4
7
 
5
8
  export enum SidebarV2StateChange {
6
9
  COLLAPSED = 'collapsed',
@@ -14,6 +17,7 @@ export type SecondarySidebarItem = {
14
17
  label: string
15
18
  value: string
16
19
  icon: ReactNode
20
+ badge?: TenantBadge
17
21
  }
18
22
 
19
23
  export type SecondarySidebarInfo = {
@@ -325,7 +325,7 @@ export const getStatCardToken = (
325
325
  width: foundationToken.unit[20],
326
326
  },
327
327
  title: {
328
- fontSize: foundationToken.font.size.body.md.fontSize,
328
+ fontSize: foundationToken.font.size.body.lg.fontSize,
329
329
  fontWeight: foundationToken.font.weight[500],
330
330
  color: foundationToken.colors.gray[400],
331
331
  },