@juspay/blend-design-system 0.0.37-beta.3 → 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.
- package/dist/components/AccordionV2/index.d.ts +3 -0
- package/dist/components/AvatarV2/avatarV2.utils.d.ts +1 -1
- package/dist/components/AvatarV2/index.d.ts +1 -2
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +2 -5
- package/dist/components/Breadcrumb/types.d.ts +6 -0
- package/dist/components/BreadcrumbV2/index.d.ts +10 -0
- package/dist/components/ButtonV2/ButtonGroupV2/index.d.ts +1 -0
- package/dist/components/ButtonV2/buttonV2.types.d.ts +0 -4
- package/dist/components/ButtonV2/index.d.ts +3 -0
- package/dist/components/ButtonV2/utils.d.ts +1 -1
- package/dist/components/Charts/ChartUtils.d.ts +2 -0
- package/dist/components/Charts/types.d.ts +2 -2
- package/dist/components/ChartsV2/index.d.ts +5 -0
- package/dist/components/CodeEditorV2/CodeEditorV2.d.ts +1 -1
- package/dist/components/CodeEditorV2/codeEditorV2.tokens.d.ts +5 -5
- package/dist/components/CodeEditorV2/codeEditorV2.types.d.ts +5 -5
- package/dist/components/CodeEditorV2/index.d.ts +2 -0
- package/dist/components/CodeEditorV2/utils.d.ts +1 -1
- package/dist/components/DataTable/DataTable.d.ts +2 -1
- package/dist/components/DataTable/PivotTableModal/PivotPreviewPanel.d.ts +3 -0
- package/dist/components/DataTable/PivotTableModal/PivotTableIllustration.d.ts +7 -0
- package/dist/components/DataTable/PivotTableModal/index.d.ts +3 -0
- package/dist/components/DataTable/PivotTableModal/pivotModalStyleTokens.d.ts +123 -0
- package/dist/components/DataTable/PivotTableModal/types.d.ts +62 -0
- package/dist/components/DataTable/PivotTableModal/utils.d.ts +32 -0
- package/dist/components/DataTable/TableBody/types.d.ts +2 -0
- package/dist/components/DataTable/TableHeader/types.d.ts +1 -0
- package/dist/components/DataTable/index.d.ts +2 -0
- package/dist/components/DataTable/types.d.ts +56 -0
- package/dist/components/DataTable/utils.d.ts +19 -1
- package/dist/components/DateRangePicker/types.d.ts +1 -1
- package/dist/components/DateRangePicker/utils.d.ts +2 -0
- package/dist/components/Directory/Directory.d.ts +1 -1
- package/dist/components/Directory/types.d.ts +1 -1
- package/dist/components/Directory/utils.d.ts +2 -0
- package/dist/components/InputsV2/ChatInputV2/AttachmentDropdown.d.ts +3 -3
- package/dist/components/InputsV2/ChatInputV2/ChatInputTagV2.d.ts +2 -2
- package/dist/components/InputsV2/ChatInputV2/ChatInputV2.d.ts +4 -4
- package/dist/components/InputsV2/ChatInputV2/ChatInputV2.types.d.ts +8 -8
- package/dist/components/InputsV2/ChatInputV2/ChatInputV2AttachmentRow.d.ts +3 -3
- package/dist/components/InputsV2/ChatInputV2/MobileChatInputV2.d.ts +2 -2
- package/dist/components/InputsV2/ChatInputV2/utils.d.ts +4 -4
- package/dist/components/InputsV2/SearchInputV2/utils.d.ts +39 -0
- package/dist/components/InputsV2/TextInputV2/TextInputV2.types.d.ts +2 -2
- package/dist/components/InputsV2/TextInputV2/index.d.ts +2 -0
- package/dist/components/InputsV2/utils/utils.d.ts +1 -1
- package/dist/components/KeyValuePairV2/KeyValuePairV2.d.ts +1 -1
- package/dist/components/KeyValuePairV2/ResponsiveText.d.ts +2 -2
- package/dist/components/KeyValuePairV2/index.d.ts +3 -0
- package/dist/components/KeyValuePairV2/keyValuePairV2.types.d.ts +2 -2
- package/dist/components/KeyValuePairV2/responsiveTextStyles.d.ts +3 -3
- package/dist/components/KeyValuePairV2/utils.d.ts +2 -2
- package/dist/components/MenuV2/index.d.ts +1 -0
- package/dist/components/MenuV2/menuV2.utils.d.ts +2 -2
- package/dist/components/MultiSelectV2/index.d.ts +3 -0
- package/dist/components/MultiSelectV2/multiSelectV2.types.d.ts +1 -1
- package/dist/components/MultiSelectV2/utils.d.ts +2 -2
- package/dist/components/ProgressBarV2/index.d.ts +3 -0
- package/dist/components/ProgressBarV2/utils.d.ts +1 -1
- package/dist/components/Radio/StyledRadio.d.ts +0 -1
- package/dist/components/SelectV2/index.d.ts +1 -0
- package/dist/components/SelectorV2/CheckboxV2/index.d.ts +4 -0
- package/dist/components/SelectorV2/CheckboxV2/utils.d.ts +1 -1
- package/dist/components/SelectorV2/RadioV2/index.d.ts +3 -0
- package/dist/components/SelectorV2/SwitchV2/index.d.ts +1 -0
- package/dist/components/Sidebar/SidebarContent.d.ts +1 -1
- package/dist/components/Sidebar/types.d.ts +10 -1
- package/dist/components/Sidebar/utils.d.ts +1 -1
- package/dist/components/SidebarV2/SidebarV2Panel.d.ts +1 -1
- package/dist/components/SidebarV2/index.d.ts +6 -1
- package/dist/components/SidebarV2/types.d.ts +3 -0
- package/dist/components/SingleSelectV2/SingleSelectV2VirtualList.d.ts +2 -2
- package/dist/components/SingleSelectV2/index.d.ts +3 -0
- package/dist/components/SingleSelectV2/singleSelectV2.types.d.ts +2 -2
- package/dist/components/SingleSelectV2/utils.d.ts +6 -6
- package/dist/components/StatCardV2/index.d.ts +10 -1
- package/dist/components/Stepper/types.d.ts +2 -0
- package/dist/components/StepperV2/index.d.ts +3 -1
- package/dist/components/StepperV2/stepperV2.types.d.ts +2 -2
- package/dist/components/TabsV2/index.d.ts +3 -1
- package/dist/components/TagV2/index.d.ts +3 -0
- package/dist/components/TooltipV2/index.d.ts +1 -0
- package/dist/components/common/index.d.ts +1 -1
- package/dist/main.d.ts +30 -70
- package/dist/main.js +91851 -89103
- package/dist/{node-CRWdZOVN.js → node-C2uf3sNA.js} +1303 -1300
- package/dist/node.js +1 -1
- package/dist/tokens.js +17 -16
- package/lib/components/AccordionV2/index.ts +3 -0
- package/lib/components/Avatar/Avatar.tsx +6 -1
- package/lib/components/AvatarGroup/AvatarGroup.tsx +1 -1
- package/lib/components/AvatarV2/AvatarV2.tsx +12 -3
- package/lib/components/AvatarV2/avatarV2.utils.ts +1 -1
- package/lib/components/AvatarV2/index.ts +1 -12
- package/lib/components/Breadcrumb/Breadcrumb.tsx +9 -8
- package/lib/components/Breadcrumb/types.ts +12 -0
- package/lib/components/BreadcrumbV2/index.ts +10 -0
- package/lib/components/Button/ButtonBase.tsx +1 -1
- package/lib/components/ButtonV2/ButtonGroupV2/index.ts +1 -0
- package/lib/components/ButtonV2/ButtonV2.tsx +2 -2
- package/lib/components/ButtonV2/LinkButton.tsx +2 -2
- package/lib/components/ButtonV2/buttonV2.types.ts +0 -6
- package/lib/components/ButtonV2/index.ts +3 -0
- package/lib/components/ButtonV2/utils.ts +2 -2
- package/lib/components/Card/CardComponents.tsx +52 -17
- package/lib/components/Charts/BlendChart.tsx +1 -1
- package/lib/components/Charts/ChartUtils.tsx +7 -0
- package/lib/components/Charts/Charts.tsx +4 -2
- package/lib/components/Charts/CoreChart.tsx +4 -2
- package/lib/components/Charts/types.tsx +2 -2
- package/lib/components/ChartsV2/ChartV2.tsx +4 -3
- package/lib/components/ChartsV2/index.ts +5 -0
- package/lib/components/Checkbox/Checkbox.tsx +29 -7
- package/lib/components/CodeBlock/CodeBlock.tsx +47 -1
- package/lib/components/CodeBlock/codeBlock.token.ts +5 -5
- package/lib/components/CodeEditor/CodeEditor.tsx +26 -4
- package/lib/components/CodeEditor/MonacoEditorWrapper.tsx +13 -1
- package/lib/components/CodeEditorV2/CodeEditorV2.tsx +2 -2
- package/lib/components/CodeEditorV2/codeEditorV2.dark.tokens.ts +37 -25
- package/lib/components/CodeEditorV2/codeEditorV2.light.token.ts +37 -25
- package/lib/components/CodeEditorV2/codeEditorV2.tokens.ts +5 -5
- package/lib/components/CodeEditorV2/codeEditorV2.types.ts +5 -5
- package/lib/components/CodeEditorV2/index.ts +2 -0
- package/lib/components/CodeEditorV2/utils.ts +1 -1
- package/lib/components/DataTable/DataTable.tsx +156 -4
- package/lib/components/DataTable/PivotTableModal/PivotPreviewPanel.tsx +174 -0
- package/lib/components/DataTable/PivotTableModal/PivotTableIllustration.tsx +28 -0
- package/lib/components/DataTable/PivotTableModal/index.tsx +859 -0
- package/lib/components/DataTable/PivotTableModal/pivot-table-illustration.png +0 -0
- package/lib/components/DataTable/PivotTableModal/pivotModal.styled.ts +13 -0
- package/lib/components/DataTable/PivotTableModal/pivotModalStyleTokens.ts +250 -0
- package/lib/components/DataTable/PivotTableModal/types.ts +69 -0
- package/lib/components/DataTable/PivotTableModal/utils.ts +360 -0
- package/lib/components/DataTable/TableBody/index.tsx +16 -5
- package/lib/components/DataTable/TableBody/types.ts +2 -0
- package/lib/components/DataTable/TableHeader/FilterComponents.tsx +4 -0
- package/lib/components/DataTable/TableHeader/index.tsx +6 -3
- package/lib/components/DataTable/TableHeader/types.ts +1 -0
- package/lib/components/DataTable/index.ts +4 -0
- package/lib/components/DataTable/types.ts +57 -0
- package/lib/components/DataTable/utils.ts +197 -0
- package/lib/components/DateRangePicker/DateRangePicker.tsx +34 -17
- package/lib/components/DateRangePicker/types.ts +5 -5
- package/lib/components/DateRangePicker/utils.ts +5 -0
- package/lib/components/Directory/Directory.tsx +3 -2
- package/lib/components/Directory/types.ts +1 -1
- package/lib/components/Directory/utils.ts +6 -0
- package/lib/components/Drawer/components/DrawerBase.tsx +16 -0
- package/lib/components/Drawer/components/NestedSelectDrawer.tsx +13 -1
- package/lib/components/Drawer/components/SelectDrawer.tsx +9 -1
- package/lib/components/Inputs/OTPInput/OTPInput.tsx +5 -3
- package/lib/components/InputsV2/ChatInputV2/AttachmentDropdown.tsx +3 -3
- package/lib/components/InputsV2/ChatInputV2/ChatInputTagV2.tsx +3 -3
- package/lib/components/InputsV2/ChatInputV2/ChatInputV2.types.ts +8 -8
- package/lib/components/InputsV2/ChatInputV2/ChatInputV2AttachmentRow.tsx +7 -7
- package/lib/components/InputsV2/ChatInputV2/utils.ts +8 -8
- package/lib/components/InputsV2/SearchInputV2/utils.ts +14 -1
- package/lib/components/InputsV2/TextInputV2/TextInputV2.tsx +3 -3
- package/lib/components/InputsV2/TextInputV2/TextInputV2.types.ts +2 -2
- package/lib/components/InputsV2/TextInputV2/index.ts +2 -0
- package/lib/components/KeyValuePairV2/KeyValuePairV2.tsx +6 -2
- package/lib/components/KeyValuePairV2/ResponsiveText.tsx +2 -2
- package/lib/components/KeyValuePairV2/index.ts +3 -0
- package/lib/components/KeyValuePairV2/keyValuePairV2.types.ts +2 -2
- package/lib/components/KeyValuePairV2/responsiveTextStyles.ts +3 -3
- package/lib/components/KeyValuePairV2/utils.ts +3 -3
- package/lib/components/Menu/Menu.tsx +9 -1
- package/lib/components/MenuV2/MenuV2.tsx +2 -2
- package/lib/components/MenuV2/MenuV2SubMenu.tsx +2 -2
- package/lib/components/MenuV2/index.ts +1 -0
- package/lib/components/MenuV2/menuV2.utils.ts +4 -4
- package/lib/components/Modal/useModal.ts +7 -0
- package/lib/components/MultiSelectV2/MultiSelectV2.tsx +2 -2
- package/lib/components/MultiSelectV2/MultiSelectV2Menu.tsx +5 -2
- package/lib/components/MultiSelectV2/index.ts +3 -0
- package/lib/components/MultiSelectV2/mobile/MobileMultiSelectV2.tsx +7 -4
- package/lib/components/MultiSelectV2/multiSelectV2.types.ts +1 -1
- package/lib/components/MultiSelectV2/utils.ts +2 -2
- package/lib/components/ProgressBarV2/ProgressBarV2.tsx +5 -2
- package/lib/components/ProgressBarV2/index.ts +3 -0
- package/lib/components/ProgressBarV2/utils.ts +1 -1
- package/lib/components/Radio/Radio.tsx +12 -5
- package/lib/components/Radio/StyledRadio.tsx +33 -17
- package/lib/components/SelectV2/index.ts +1 -0
- package/lib/components/SelectorV2/CheckboxV2/CheckboxV2.tsx +2 -2
- package/lib/components/SelectorV2/CheckboxV2/index.ts +4 -0
- package/lib/components/SelectorV2/CheckboxV2/utils.ts +1 -1
- package/lib/components/SelectorV2/RadioV2/index.ts +3 -0
- package/lib/components/SelectorV2/SwitchV2/index.ts +1 -0
- package/lib/components/Sidebar/Sidebar.tsx +18 -3
- package/lib/components/Sidebar/SidebarContent.tsx +5 -2
- package/lib/components/Sidebar/TenantPanel.tsx +52 -34
- package/lib/components/Sidebar/types.ts +11 -1
- package/lib/components/Sidebar/utils.ts +1 -1
- package/lib/components/SidebarV2/SecondarySidebar.tsx +86 -44
- package/lib/components/SidebarV2/SidebarV2Panel.tsx +4 -2
- package/lib/components/SidebarV2/index.ts +6 -0
- package/lib/components/SidebarV2/types.ts +4 -0
- package/lib/components/SingleSelectV2/MobileSingleSelectV2.tsx +2 -2
- package/lib/components/SingleSelectV2/SingleSelectV2.tsx +10 -3
- package/lib/components/SingleSelectV2/SingleSelectV2Menu.tsx +4 -2
- package/lib/components/SingleSelectV2/SingleSelectV2VirtualList.tsx +5 -2
- package/lib/components/SingleSelectV2/index.ts +7 -0
- package/lib/components/SingleSelectV2/singleSelectV2.types.ts +2 -2
- package/lib/components/SingleSelectV2/utils.ts +10 -10
- package/lib/components/StatCard/statcard.tokens.ts +1 -1
- package/lib/components/StatCardV2/index.ts +13 -1
- package/lib/components/Stepper/VerticalStepper.tsx +209 -171
- package/lib/components/Stepper/types.ts +2 -0
- package/lib/components/StepperV2/Stepper/Steps.tsx +15 -1
- package/lib/components/StepperV2/index.ts +3 -1
- package/lib/components/StepperV2/stepperV2.types.ts +2 -2
- package/lib/components/TabsV2/index.ts +13 -1
- package/lib/components/TagV2/index.ts +3 -0
- package/lib/components/Text/Text.tsx +1 -0
- package/lib/components/TooltipV2/index.ts +1 -0
- package/lib/components/Upload/Upload.tsx +6 -0
- package/lib/components/Upload/components/FileListDisplay.tsx +159 -16
- package/lib/components/Upload/utils.ts +10 -2
- package/lib/components/common/index.ts +1 -1
- package/lib/context/ThemeProvider.tsx +19 -8
- package/lib/hooks/useDebounce.ts +9 -1
- package/lib/main.ts +34 -258
- package/lib/types/assets.d.ts +24 -0
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import React, {
|
|
2
2
|
useState,
|
|
3
3
|
useEffect,
|
|
4
4
|
useMemo,
|
|
@@ -61,6 +61,8 @@ import { MenuGroupType, MenuAlignment } from '../Menu/types'
|
|
|
61
61
|
|
|
62
62
|
import { useMobileDataTable } from './hooks/useMobileDataTable'
|
|
63
63
|
import MobileColumnDrawer from './MobileColumnDrawer'
|
|
64
|
+
import PivotTableModal from './PivotTableModal'
|
|
65
|
+
import type { PivotTableConfig } from './PivotTableModal/types'
|
|
64
66
|
import { useResponsiveTokens } from '../../hooks/useResponsiveTokens'
|
|
65
67
|
import styled from 'styled-components'
|
|
66
68
|
import { FOUNDATION_THEME } from '../../tokens'
|
|
@@ -115,6 +117,7 @@ const DataTable = forwardRef(
|
|
|
115
117
|
showSettings = false,
|
|
116
118
|
showFooter = true,
|
|
117
119
|
enableInlineEdit = false,
|
|
120
|
+
showActionsColumn = true,
|
|
118
121
|
enableRowExpansion = false,
|
|
119
122
|
enableRowSelection = false,
|
|
120
123
|
rowSelectionConfig,
|
|
@@ -153,6 +156,8 @@ const DataTable = forwardRef(
|
|
|
153
156
|
getRowStyle,
|
|
154
157
|
tableBodyHeight,
|
|
155
158
|
mobileColumnsToShow,
|
|
159
|
+
enablePivotTable = false,
|
|
160
|
+
pivotTableConfig,
|
|
156
161
|
...rest
|
|
157
162
|
}: DataTableProps<T>,
|
|
158
163
|
ref: React.Ref<HTMLDivElement>
|
|
@@ -314,6 +319,7 @@ const DataTable = forwardRef(
|
|
|
314
319
|
>({})
|
|
315
320
|
|
|
316
321
|
const [isFormatEnabled, setIsFormatEnabled] = useState<boolean>(true)
|
|
322
|
+
const [isPivotModalOpen, setIsPivotModalOpen] = useState<boolean>(false)
|
|
317
323
|
|
|
318
324
|
const [mobileDrawerOpen, setMobileDrawerOpen] = useState<boolean>(false)
|
|
319
325
|
const [selectedRowForDrawer, setSelectedRowForDrawer] =
|
|
@@ -651,6 +657,37 @@ const DataTable = forwardRef(
|
|
|
651
657
|
pagination?.pageSize,
|
|
652
658
|
])
|
|
653
659
|
|
|
660
|
+
// Stable row ID list for the current page. Used for selection state and
|
|
661
|
+
// as a cheap signal to remount the tbody when results change (e.g. server-side search).
|
|
662
|
+
const currentPageRowIds = useMemo(() => {
|
|
663
|
+
return currentData.map((row) => String(row[idField]))
|
|
664
|
+
}, [currentData, idField])
|
|
665
|
+
|
|
666
|
+
// Monotonically increasing "dataVersion" for the current page's row IDs.
|
|
667
|
+
// This avoids expensive per-character hashing in TableBody while still
|
|
668
|
+
// forcing a remount when IDs change but length/first/last stay the same.
|
|
669
|
+
const [tbodyDataVersion, setTbodyDataVersion] = useState(0)
|
|
670
|
+
const prevPageRowIdsRef = useRef<string[] | null>(null)
|
|
671
|
+
useEffect(() => {
|
|
672
|
+
const prev = prevPageRowIdsRef.current
|
|
673
|
+
let changed =
|
|
674
|
+
prev == null || prev.length !== currentPageRowIds.length
|
|
675
|
+
|
|
676
|
+
if (!changed && prev) {
|
|
677
|
+
for (let i = 0; i < prev.length; i++) {
|
|
678
|
+
if (prev[i] !== currentPageRowIds[i]) {
|
|
679
|
+
changed = true
|
|
680
|
+
break
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (changed) {
|
|
686
|
+
setTbodyDataVersion((v) => v + 1)
|
|
687
|
+
}
|
|
688
|
+
prevPageRowIdsRef.current = currentPageRowIds
|
|
689
|
+
}, [currentPageRowIds])
|
|
690
|
+
|
|
654
691
|
const updateSelectAllState = (
|
|
655
692
|
selectedRowsState: Record<string, boolean>
|
|
656
693
|
) => {
|
|
@@ -906,6 +943,14 @@ const DataTable = forwardRef(
|
|
|
906
943
|
|
|
907
944
|
const sortTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
908
945
|
|
|
946
|
+
useEffect(() => {
|
|
947
|
+
return () => {
|
|
948
|
+
if (sortTimeoutRef.current) {
|
|
949
|
+
clearTimeout(sortTimeoutRef.current)
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}, [])
|
|
953
|
+
|
|
909
954
|
const applySortConfig = (
|
|
910
955
|
field: keyof T,
|
|
911
956
|
newSortConfig: SortConfig | null
|
|
@@ -1241,7 +1286,8 @@ const DataTable = forwardRef(
|
|
|
1241
1286
|
effectiveVisibleColumns.length +
|
|
1242
1287
|
(enableRowSelection ? 1 : 0) +
|
|
1243
1288
|
(enableRowExpansion ? 1 : 0) +
|
|
1244
|
-
(
|
|
1289
|
+
(showActionsColumn &&
|
|
1290
|
+
(enableInlineEdit || rowActions) &&
|
|
1245
1291
|
!(mobileConfig.isMobile && mobileConfig.enableColumnOverflow)
|
|
1246
1292
|
? 1
|
|
1247
1293
|
: 0) +
|
|
@@ -1394,6 +1440,53 @@ const DataTable = forwardRef(
|
|
|
1394
1440
|
[ref]
|
|
1395
1441
|
)
|
|
1396
1442
|
|
|
1443
|
+
const pivotTriggerSlot = pivotTableConfig?.triggerSlot || 2
|
|
1444
|
+
|
|
1445
|
+
const pivotTriggerButton = useMemo(() => {
|
|
1446
|
+
if (!enablePivotTable || !pivotTableConfig?.triggerButton) {
|
|
1447
|
+
return null
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
const triggerNode = pivotTableConfig.triggerButton
|
|
1451
|
+
if (!React.isValidElement(triggerNode)) {
|
|
1452
|
+
return triggerNode
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
const existingOnClick = (
|
|
1456
|
+
triggerNode.props as { onClick?: (event: unknown) => void }
|
|
1457
|
+
).onClick
|
|
1458
|
+
|
|
1459
|
+
return React.cloneElement(
|
|
1460
|
+
triggerNode as React.ReactElement<{
|
|
1461
|
+
onClick?: (event: unknown) => void
|
|
1462
|
+
}>,
|
|
1463
|
+
{
|
|
1464
|
+
onClick: (event: unknown) => {
|
|
1465
|
+
existingOnClick?.(event)
|
|
1466
|
+
setIsPivotModalOpen(true)
|
|
1467
|
+
},
|
|
1468
|
+
}
|
|
1469
|
+
)
|
|
1470
|
+
}, [enablePivotTable, pivotTableConfig?.triggerButton])
|
|
1471
|
+
|
|
1472
|
+
const effectiveHeaderSlot1 =
|
|
1473
|
+
pivotTriggerSlot === 1 && pivotTriggerButton
|
|
1474
|
+
? pivotTriggerButton
|
|
1475
|
+
: headerSlot1
|
|
1476
|
+
const effectiveHeaderSlot2 =
|
|
1477
|
+
pivotTriggerSlot === 2 && pivotTriggerButton
|
|
1478
|
+
? pivotTriggerButton
|
|
1479
|
+
: headerSlot2
|
|
1480
|
+
const effectiveHeaderSlot3 =
|
|
1481
|
+
pivotTriggerSlot === 3 ? (
|
|
1482
|
+
<>
|
|
1483
|
+
{headerSlot2}
|
|
1484
|
+
{pivotTriggerButton}
|
|
1485
|
+
</>
|
|
1486
|
+
) : (
|
|
1487
|
+
effectiveHeaderSlot2
|
|
1488
|
+
)
|
|
1489
|
+
|
|
1397
1490
|
return (
|
|
1398
1491
|
<Block
|
|
1399
1492
|
ref={containerRefCallback}
|
|
@@ -1474,8 +1567,8 @@ const DataTable = forwardRef(
|
|
|
1474
1567
|
</>
|
|
1475
1568
|
) : null
|
|
1476
1569
|
}
|
|
1477
|
-
headerSlot2={
|
|
1478
|
-
headerSlot3={
|
|
1570
|
+
headerSlot2={effectiveHeaderSlot1}
|
|
1571
|
+
headerSlot3={effectiveHeaderSlot3}
|
|
1479
1572
|
{...rest}
|
|
1480
1573
|
/>
|
|
1481
1574
|
|
|
@@ -1615,6 +1708,9 @@ const DataTable = forwardRef(
|
|
|
1615
1708
|
selectAll={selectAll}
|
|
1616
1709
|
sortConfig={sortConfig}
|
|
1617
1710
|
enableInlineEdit={enableInlineEdit}
|
|
1711
|
+
showActionsColumn={
|
|
1712
|
+
showActionsColumn
|
|
1713
|
+
}
|
|
1618
1714
|
enableColumnManager={
|
|
1619
1715
|
effectiveEnableColumnManager
|
|
1620
1716
|
}
|
|
@@ -1715,6 +1811,7 @@ const DataTable = forwardRef(
|
|
|
1715
1811
|
{currentData.length > 0 && (
|
|
1716
1812
|
<TableBodyComponent
|
|
1717
1813
|
currentData={currentData}
|
|
1814
|
+
dataVersion={tbodyDataVersion}
|
|
1718
1815
|
visibleColumns={
|
|
1719
1816
|
effectiveVisibleColumns as ColumnDefinition<
|
|
1720
1817
|
Record<string, unknown>
|
|
@@ -1740,6 +1837,9 @@ const DataTable = forwardRef(
|
|
|
1740
1837
|
enableInlineEdit={
|
|
1741
1838
|
enableInlineEdit
|
|
1742
1839
|
}
|
|
1840
|
+
showActionsColumn={
|
|
1841
|
+
showActionsColumn
|
|
1842
|
+
}
|
|
1743
1843
|
enableColumnManager={
|
|
1744
1844
|
effectiveEnableColumnManager
|
|
1745
1845
|
}
|
|
@@ -2005,6 +2105,58 @@ const DataTable = forwardRef(
|
|
|
2005
2105
|
)}
|
|
2006
2106
|
</Block>
|
|
2007
2107
|
|
|
2108
|
+
{enablePivotTable && (
|
|
2109
|
+
<PivotTableModal
|
|
2110
|
+
isOpen={isPivotModalOpen}
|
|
2111
|
+
onClose={() => setIsPivotModalOpen(false)}
|
|
2112
|
+
data={processedData as Record<string, unknown>[]}
|
|
2113
|
+
columns={
|
|
2114
|
+
visibleColumns as ColumnDefinition<
|
|
2115
|
+
Record<string, unknown>
|
|
2116
|
+
>[]
|
|
2117
|
+
}
|
|
2118
|
+
title={pivotTableConfig?.title}
|
|
2119
|
+
description={pivotTableConfig?.description}
|
|
2120
|
+
showExport={pivotTableConfig?.showExport}
|
|
2121
|
+
previewColumns={pivotTableConfig?.previewColumns}
|
|
2122
|
+
previewRows={
|
|
2123
|
+
pivotTableConfig?.previewRows as
|
|
2124
|
+
| ({
|
|
2125
|
+
__pivotId: string
|
|
2126
|
+
} & Record<string, unknown>)[]
|
|
2127
|
+
| undefined
|
|
2128
|
+
}
|
|
2129
|
+
availableAggregations={
|
|
2130
|
+
pivotTableConfig?.availableAggregations
|
|
2131
|
+
}
|
|
2132
|
+
initialConfig={
|
|
2133
|
+
pivotTableConfig?.initialConfig as
|
|
2134
|
+
| Partial<
|
|
2135
|
+
PivotTableConfig<Record<string, unknown>>
|
|
2136
|
+
>
|
|
2137
|
+
| undefined
|
|
2138
|
+
}
|
|
2139
|
+
onConfigChange={
|
|
2140
|
+
pivotTableConfig?.onConfigChange as
|
|
2141
|
+
| ((
|
|
2142
|
+
config: PivotTableConfig<
|
|
2143
|
+
Record<string, unknown>
|
|
2144
|
+
>
|
|
2145
|
+
) => void)
|
|
2146
|
+
| undefined
|
|
2147
|
+
}
|
|
2148
|
+
onExport={
|
|
2149
|
+
pivotTableConfig?.onExport as
|
|
2150
|
+
| ((
|
|
2151
|
+
config: PivotTableConfig<
|
|
2152
|
+
Record<string, unknown>
|
|
2153
|
+
>
|
|
2154
|
+
) => void)
|
|
2155
|
+
| undefined
|
|
2156
|
+
}
|
|
2157
|
+
/>
|
|
2158
|
+
)}
|
|
2159
|
+
|
|
2008
2160
|
{mobileConfig.enableColumnOverflow && selectedRowForDrawer && (
|
|
2009
2161
|
<MobileColumnDrawer
|
|
2010
2162
|
isOpen={mobileDrawerOpen}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { forwardRef, useState, useCallback, useEffect } from 'react'
|
|
2
|
+
import Block from '../../Primitives/Block/Block'
|
|
3
|
+
import PrimitiveText from '../../Primitives/PrimitiveText/PrimitiveText'
|
|
4
|
+
import Button from '../../Button/Button'
|
|
5
|
+
import { ButtonSize, ButtonType } from '../../Button/types'
|
|
6
|
+
import DataTable from '../DataTable'
|
|
7
|
+
import { NoScrollbar } from './pivotModal.styled'
|
|
8
|
+
import { PivotTableIllustration } from './PivotTableIllustration'
|
|
9
|
+
import type { PivotPreviewPanelProps } from './types'
|
|
10
|
+
import type { ColumnDefinition } from '../types'
|
|
11
|
+
|
|
12
|
+
const PivotPreviewPanel = forwardRef<HTMLDivElement, PivotPreviewPanelProps>(
|
|
13
|
+
(
|
|
14
|
+
{
|
|
15
|
+
pivot,
|
|
16
|
+
tableToken,
|
|
17
|
+
showExport,
|
|
18
|
+
previewRows,
|
|
19
|
+
previewTableColumns: initialColumns,
|
|
20
|
+
onExport,
|
|
21
|
+
hasValues,
|
|
22
|
+
},
|
|
23
|
+
ref
|
|
24
|
+
) => {
|
|
25
|
+
const [previewTableColumns, setPreviewTableColumns] =
|
|
26
|
+
useState<ColumnDefinition<Record<string, unknown>>[]>(
|
|
27
|
+
initialColumns
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setPreviewTableColumns(initialColumns)
|
|
32
|
+
}, [initialColumns])
|
|
33
|
+
|
|
34
|
+
const handleHeaderChange = useCallback(
|
|
35
|
+
(field: keyof Record<string, unknown>, newHeader: string) => {
|
|
36
|
+
setPreviewTableColumns((prev) =>
|
|
37
|
+
prev.map((col) =>
|
|
38
|
+
col.field === field
|
|
39
|
+
? { ...col, header: newHeader }
|
|
40
|
+
: col
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
},
|
|
44
|
+
[]
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
const hasPreviewGrid =
|
|
48
|
+
previewTableColumns.length > 0 &&
|
|
49
|
+
previewRows &&
|
|
50
|
+
previewRows.length > 0
|
|
51
|
+
const showEmptyState = !hasValues || !hasPreviewGrid
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<NoScrollbar
|
|
55
|
+
ref={ref}
|
|
56
|
+
style={{
|
|
57
|
+
padding: '0',
|
|
58
|
+
overflow: 'auto',
|
|
59
|
+
backgroundColor: 'transparent',
|
|
60
|
+
display: 'flex',
|
|
61
|
+
flexDirection: 'column',
|
|
62
|
+
height: '100%',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{showEmptyState ? (
|
|
66
|
+
<Block
|
|
67
|
+
style={{
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
justifyContent: 'center',
|
|
72
|
+
flex: 1,
|
|
73
|
+
minHeight: '300px',
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
<PivotTableIllustration />
|
|
77
|
+
<PrimitiveText
|
|
78
|
+
style={{
|
|
79
|
+
fontSize: pivot.emptyState.titleFontSize,
|
|
80
|
+
color: pivot.emptyState.titleColor,
|
|
81
|
+
marginTop: pivot.spacing.iconBadgeGap,
|
|
82
|
+
fontWeight: 500,
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
Rows
|
|
86
|
+
</PrimitiveText>
|
|
87
|
+
</Block>
|
|
88
|
+
) : (
|
|
89
|
+
<Block
|
|
90
|
+
style={{
|
|
91
|
+
flex: 1,
|
|
92
|
+
display: 'flex',
|
|
93
|
+
flexDirection: 'column',
|
|
94
|
+
overflow: 'hidden',
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
{showExport && (
|
|
98
|
+
<Block
|
|
99
|
+
display="flex"
|
|
100
|
+
alignItems="center"
|
|
101
|
+
justifyContent="space-between"
|
|
102
|
+
style={{
|
|
103
|
+
marginBottom:
|
|
104
|
+
pivot.preview.headerMarginBottom,
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<Button
|
|
108
|
+
text="Export CSV"
|
|
109
|
+
buttonType={ButtonType.SECONDARY}
|
|
110
|
+
size={ButtonSize.SMALL}
|
|
111
|
+
onClick={onExport}
|
|
112
|
+
disabled={!previewRows?.length}
|
|
113
|
+
/>
|
|
114
|
+
</Block>
|
|
115
|
+
)}
|
|
116
|
+
<Block style={{ flex: 1, overflow: 'auto' }}>
|
|
117
|
+
<DataTable
|
|
118
|
+
key={`pivot-preview-${previewRows?.length || 0}-${previewTableColumns.length}`}
|
|
119
|
+
data={
|
|
120
|
+
(previewRows || []) as Record<
|
|
121
|
+
string,
|
|
122
|
+
unknown
|
|
123
|
+
>[]
|
|
124
|
+
}
|
|
125
|
+
columns={previewTableColumns}
|
|
126
|
+
idField="__pivotId"
|
|
127
|
+
pagination={{
|
|
128
|
+
currentPage: 1,
|
|
129
|
+
pageSize: Math.max(
|
|
130
|
+
previewRows?.length || 0,
|
|
131
|
+
1
|
|
132
|
+
),
|
|
133
|
+
totalRows: previewRows?.length || 0,
|
|
134
|
+
pageSizeOptions: [
|
|
135
|
+
Math.max(previewRows?.length || 0, 1),
|
|
136
|
+
],
|
|
137
|
+
}}
|
|
138
|
+
enableSearch={false}
|
|
139
|
+
enableFiltering={false}
|
|
140
|
+
enableAdvancedFilter={false}
|
|
141
|
+
enableColumnManager={false}
|
|
142
|
+
enableColumnReordering={false}
|
|
143
|
+
enableRowExpansion={false}
|
|
144
|
+
enableRowSelection={false}
|
|
145
|
+
enableInlineEdit={true}
|
|
146
|
+
showActionsColumn={false}
|
|
147
|
+
onHeaderChange={handleHeaderChange}
|
|
148
|
+
showHeader
|
|
149
|
+
showToolbar={false}
|
|
150
|
+
showFooter={false}
|
|
151
|
+
getRowStyle={(row) =>
|
|
152
|
+
row.__pivotRowType === 'grand_total' ||
|
|
153
|
+
row.__pivotRowType === 'subtotal'
|
|
154
|
+
? {
|
|
155
|
+
backgroundColor:
|
|
156
|
+
tableToken.dataTable.table
|
|
157
|
+
.header.backgroundColor,
|
|
158
|
+
fontWeight:
|
|
159
|
+
pivot.preview.titleFontWeight,
|
|
160
|
+
}
|
|
161
|
+
: {}
|
|
162
|
+
}
|
|
163
|
+
/>
|
|
164
|
+
</Block>
|
|
165
|
+
</Block>
|
|
166
|
+
)}
|
|
167
|
+
</NoScrollbar>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
PivotPreviewPanel.displayName = 'PivotPreviewPanel'
|
|
173
|
+
|
|
174
|
+
export default PivotPreviewPanel
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pivot Table Illustration Component
|
|
3
|
+
* Displays when no pivot configuration is set
|
|
4
|
+
* Uses optimized PNG illustration with proper sizing
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Import the pivot table illustration image
|
|
8
|
+
import pivotTableIllustration from './pivot-table-illustration.png'
|
|
9
|
+
|
|
10
|
+
export const PivotTableIllustration = () => {
|
|
11
|
+
return (
|
|
12
|
+
<img
|
|
13
|
+
src={pivotTableIllustration}
|
|
14
|
+
alt="Pivot table illustration"
|
|
15
|
+
width={255}
|
|
16
|
+
height={150}
|
|
17
|
+
style={{
|
|
18
|
+
objectFit: 'contain',
|
|
19
|
+
objectPosition: 'center',
|
|
20
|
+
userSelect: 'none',
|
|
21
|
+
pointerEvents: 'none',
|
|
22
|
+
display: 'block',
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default PivotTableIllustration
|