@juspay/blend-design-system 0.0.37-beta.3 → 0.0.37-beta.4
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/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/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/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/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/SidebarV2/index.d.ts +5 -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/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 +87817 -85412
- package/dist/{node-CRWdZOVN.js → node-C2uf3sNA.js} +1303 -1300
- package/dist/node.js +1 -1
- package/dist/tokens.js +1 -1
- package/lib/components/AccordionV2/index.ts +3 -0
- package/lib/components/AvatarV2/AvatarV2.tsx +2 -2
- package/lib/components/AvatarV2/avatarV2.utils.ts +1 -1
- package/lib/components/AvatarV2/index.ts +1 -12
- package/lib/components/BreadcrumbV2/index.ts +10 -0
- 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/Charts/BlendChart.tsx +1 -1
- package/lib/components/ChartsV2/ChartV2.tsx +3 -2
- package/lib/components/ChartsV2/index.ts +5 -0
- 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 +148 -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/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/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/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/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/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 +7 -2
- package/lib/components/SidebarV2/index.ts +5 -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/StatCardV2/index.ts +13 -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/TooltipV2/index.ts +1 -0
- package/lib/components/common/index.ts +1 -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
|
) => {
|
|
@@ -1241,7 +1278,8 @@ const DataTable = forwardRef(
|
|
|
1241
1278
|
effectiveVisibleColumns.length +
|
|
1242
1279
|
(enableRowSelection ? 1 : 0) +
|
|
1243
1280
|
(enableRowExpansion ? 1 : 0) +
|
|
1244
|
-
(
|
|
1281
|
+
(showActionsColumn &&
|
|
1282
|
+
(enableInlineEdit || rowActions) &&
|
|
1245
1283
|
!(mobileConfig.isMobile && mobileConfig.enableColumnOverflow)
|
|
1246
1284
|
? 1
|
|
1247
1285
|
: 0) +
|
|
@@ -1394,6 +1432,53 @@ const DataTable = forwardRef(
|
|
|
1394
1432
|
[ref]
|
|
1395
1433
|
)
|
|
1396
1434
|
|
|
1435
|
+
const pivotTriggerSlot = pivotTableConfig?.triggerSlot || 2
|
|
1436
|
+
|
|
1437
|
+
const pivotTriggerButton = useMemo(() => {
|
|
1438
|
+
if (!enablePivotTable || !pivotTableConfig?.triggerButton) {
|
|
1439
|
+
return null
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
const triggerNode = pivotTableConfig.triggerButton
|
|
1443
|
+
if (!React.isValidElement(triggerNode)) {
|
|
1444
|
+
return triggerNode
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
const existingOnClick = (
|
|
1448
|
+
triggerNode.props as { onClick?: (event: unknown) => void }
|
|
1449
|
+
).onClick
|
|
1450
|
+
|
|
1451
|
+
return React.cloneElement(
|
|
1452
|
+
triggerNode as React.ReactElement<{
|
|
1453
|
+
onClick?: (event: unknown) => void
|
|
1454
|
+
}>,
|
|
1455
|
+
{
|
|
1456
|
+
onClick: (event: unknown) => {
|
|
1457
|
+
existingOnClick?.(event)
|
|
1458
|
+
setIsPivotModalOpen(true)
|
|
1459
|
+
},
|
|
1460
|
+
}
|
|
1461
|
+
)
|
|
1462
|
+
}, [enablePivotTable, pivotTableConfig?.triggerButton])
|
|
1463
|
+
|
|
1464
|
+
const effectiveHeaderSlot1 =
|
|
1465
|
+
pivotTriggerSlot === 1 && pivotTriggerButton
|
|
1466
|
+
? pivotTriggerButton
|
|
1467
|
+
: headerSlot1
|
|
1468
|
+
const effectiveHeaderSlot2 =
|
|
1469
|
+
pivotTriggerSlot === 2 && pivotTriggerButton
|
|
1470
|
+
? pivotTriggerButton
|
|
1471
|
+
: headerSlot2
|
|
1472
|
+
const effectiveHeaderSlot3 =
|
|
1473
|
+
pivotTriggerSlot === 3 ? (
|
|
1474
|
+
<>
|
|
1475
|
+
{headerSlot2}
|
|
1476
|
+
{pivotTriggerButton}
|
|
1477
|
+
</>
|
|
1478
|
+
) : (
|
|
1479
|
+
effectiveHeaderSlot2
|
|
1480
|
+
)
|
|
1481
|
+
|
|
1397
1482
|
return (
|
|
1398
1483
|
<Block
|
|
1399
1484
|
ref={containerRefCallback}
|
|
@@ -1474,8 +1559,8 @@ const DataTable = forwardRef(
|
|
|
1474
1559
|
</>
|
|
1475
1560
|
) : null
|
|
1476
1561
|
}
|
|
1477
|
-
headerSlot2={
|
|
1478
|
-
headerSlot3={
|
|
1562
|
+
headerSlot2={effectiveHeaderSlot1}
|
|
1563
|
+
headerSlot3={effectiveHeaderSlot3}
|
|
1479
1564
|
{...rest}
|
|
1480
1565
|
/>
|
|
1481
1566
|
|
|
@@ -1615,6 +1700,9 @@ const DataTable = forwardRef(
|
|
|
1615
1700
|
selectAll={selectAll}
|
|
1616
1701
|
sortConfig={sortConfig}
|
|
1617
1702
|
enableInlineEdit={enableInlineEdit}
|
|
1703
|
+
showActionsColumn={
|
|
1704
|
+
showActionsColumn
|
|
1705
|
+
}
|
|
1618
1706
|
enableColumnManager={
|
|
1619
1707
|
effectiveEnableColumnManager
|
|
1620
1708
|
}
|
|
@@ -1715,6 +1803,7 @@ const DataTable = forwardRef(
|
|
|
1715
1803
|
{currentData.length > 0 && (
|
|
1716
1804
|
<TableBodyComponent
|
|
1717
1805
|
currentData={currentData}
|
|
1806
|
+
dataVersion={tbodyDataVersion}
|
|
1718
1807
|
visibleColumns={
|
|
1719
1808
|
effectiveVisibleColumns as ColumnDefinition<
|
|
1720
1809
|
Record<string, unknown>
|
|
@@ -1740,6 +1829,9 @@ const DataTable = forwardRef(
|
|
|
1740
1829
|
enableInlineEdit={
|
|
1741
1830
|
enableInlineEdit
|
|
1742
1831
|
}
|
|
1832
|
+
showActionsColumn={
|
|
1833
|
+
showActionsColumn
|
|
1834
|
+
}
|
|
1743
1835
|
enableColumnManager={
|
|
1744
1836
|
effectiveEnableColumnManager
|
|
1745
1837
|
}
|
|
@@ -2005,6 +2097,58 @@ const DataTable = forwardRef(
|
|
|
2005
2097
|
)}
|
|
2006
2098
|
</Block>
|
|
2007
2099
|
|
|
2100
|
+
{enablePivotTable && (
|
|
2101
|
+
<PivotTableModal
|
|
2102
|
+
isOpen={isPivotModalOpen}
|
|
2103
|
+
onClose={() => setIsPivotModalOpen(false)}
|
|
2104
|
+
data={processedData as Record<string, unknown>[]}
|
|
2105
|
+
columns={
|
|
2106
|
+
visibleColumns as ColumnDefinition<
|
|
2107
|
+
Record<string, unknown>
|
|
2108
|
+
>[]
|
|
2109
|
+
}
|
|
2110
|
+
title={pivotTableConfig?.title}
|
|
2111
|
+
description={pivotTableConfig?.description}
|
|
2112
|
+
showExport={pivotTableConfig?.showExport}
|
|
2113
|
+
previewColumns={pivotTableConfig?.previewColumns}
|
|
2114
|
+
previewRows={
|
|
2115
|
+
pivotTableConfig?.previewRows as
|
|
2116
|
+
| ({
|
|
2117
|
+
__pivotId: string
|
|
2118
|
+
} & Record<string, unknown>)[]
|
|
2119
|
+
| undefined
|
|
2120
|
+
}
|
|
2121
|
+
availableAggregations={
|
|
2122
|
+
pivotTableConfig?.availableAggregations
|
|
2123
|
+
}
|
|
2124
|
+
initialConfig={
|
|
2125
|
+
pivotTableConfig?.initialConfig as
|
|
2126
|
+
| Partial<
|
|
2127
|
+
PivotTableConfig<Record<string, unknown>>
|
|
2128
|
+
>
|
|
2129
|
+
| undefined
|
|
2130
|
+
}
|
|
2131
|
+
onConfigChange={
|
|
2132
|
+
pivotTableConfig?.onConfigChange as
|
|
2133
|
+
| ((
|
|
2134
|
+
config: PivotTableConfig<
|
|
2135
|
+
Record<string, unknown>
|
|
2136
|
+
>
|
|
2137
|
+
) => void)
|
|
2138
|
+
| undefined
|
|
2139
|
+
}
|
|
2140
|
+
onExport={
|
|
2141
|
+
pivotTableConfig?.onExport as
|
|
2142
|
+
| ((
|
|
2143
|
+
config: PivotTableConfig<
|
|
2144
|
+
Record<string, unknown>
|
|
2145
|
+
>
|
|
2146
|
+
) => void)
|
|
2147
|
+
| undefined
|
|
2148
|
+
}
|
|
2149
|
+
/>
|
|
2150
|
+
)}
|
|
2151
|
+
|
|
2008
2152
|
{mobileConfig.enableColumnOverflow && selectedRowForDrawer && (
|
|
2009
2153
|
<MobileColumnDrawer
|
|
2010
2154
|
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
|