@juspay/blend-design-system 0.0.37-beta.7 → 0.0.37
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/{node-C_DmV86X.js → breadcrumbV2.tokens-CovJEwot.js} +16 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/AccordionV2/accordionV2.animations.d.ts +1 -1
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Breadcrumb/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/ButtonGroup/index.d.ts +1 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/CardV2/CardV2.d.ts +45 -0
- package/dist/components/CardV2/CardV2.utils.d.ts +14 -0
- package/dist/components/CardV2/CardV2Components.d.ts +8 -0
- package/dist/components/CardV2/CardV2Context.d.ts +14 -0
- package/dist/components/CardV2/CardV2Skeleton.d.ts +6 -0
- package/dist/components/CardV2/accessibility/CardV2AccessibilityReport.d.ts +2 -0
- package/dist/components/CardV2/accessibility/index.d.ts +1 -0
- package/dist/components/CardV2/cardV2.dark.tokens.d.ts +3 -0
- package/dist/components/CardV2/cardV2.light.tokens.d.ts +3 -0
- package/dist/components/CardV2/cardV2.tokens.d.ts +5 -0
- package/dist/components/CardV2/cardV2.tokens.types.d.ts +92 -0
- package/dist/components/CardV2/cardV2.types.d.ts +106 -0
- package/dist/components/CardV2/index.d.ts +5 -0
- package/dist/components/Charts/index.d.ts +10 -0
- package/dist/components/Charts/types.d.ts +2 -0
- package/dist/components/ChatInput/index.d.ts +1 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/CodeEditor/index.d.ts +1 -0
- package/dist/components/CodeEditor/types.d.ts +22 -2
- package/dist/components/CodeEditorV2/CodeEditorV2.d.ts +1 -1
- package/dist/components/CodeEditorV2/codeEditorV2.types.d.ts +23 -2
- package/dist/components/DataTable/PivotTableModal/pivotModal.styled.d.ts +184 -0
- package/dist/components/DataTable/TableBody/types.d.ts +3 -1
- package/dist/components/DataTable/hooks/index.d.ts +2 -0
- package/dist/components/DataTable/hooks/useReducedMotion.d.ts +1 -0
- package/dist/components/DataTable/hooks/useRowFlip.d.ts +6 -0
- package/dist/components/DataTable/types.d.ts +26 -0
- package/dist/components/DateRangePicker/CalendarGrid.d.ts +5 -2
- package/dist/components/DateRangePicker/types.d.ts +3 -1
- package/dist/components/DateRangePicker/utils.d.ts +5 -5
- package/dist/components/Directory/Directory.d.ts +1 -1
- package/dist/components/Directory/NavItem.d.ts +1 -1
- package/dist/components/Directory/Section.d.ts +1 -1
- package/dist/components/Directory/VirtualizedDirectory.d.ts +3 -0
- package/dist/components/Directory/directory.tokens.d.ts +7 -0
- package/dist/components/Directory/types.d.ts +38 -1
- package/dist/components/Directory/utils.d.ts +3 -1
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Inputs/MultiValueInput/index.d.ts +1 -0
- package/dist/components/Inputs/NumberInput/index.d.ts +1 -0
- package/dist/components/Inputs/OTPInput/index.d.ts +1 -0
- package/dist/components/Inputs/SearchInput/index.d.ts +1 -0
- package/dist/components/Inputs/TextArea/index.d.ts +1 -0
- package/dist/components/Inputs/TextInput/index.d.ts +1 -0
- package/dist/components/InputsV2/TextAreaV2/utils.d.ts +2 -1
- package/dist/components/InputsV2/TextInputV2/utils.d.ts +2 -1
- package/dist/components/InputsV2/UploadV2/UploadContainerV2.d.ts +24 -0
- package/dist/components/InputsV2/UploadV2/UploadV2.d.ts +31 -0
- package/dist/components/InputsV2/UploadV2/UploadV2.dark.tokens.d.ts +3 -0
- package/dist/components/InputsV2/UploadV2/UploadV2.light.tokens.d.ts +3 -0
- package/dist/components/InputsV2/UploadV2/UploadV2.tokens.d.ts +5 -0
- package/dist/components/InputsV2/UploadV2/UploadV2.tokens.types.d.ts +115 -0
- package/dist/components/InputsV2/UploadV2/UploadV2.types.d.ts +56 -0
- package/dist/components/InputsV2/UploadV2/index.d.ts +3 -0
- package/dist/components/InputsV2/UploadV2/utils.d.ts +32 -0
- package/dist/components/KeyValuePair/index.d.ts +1 -0
- package/dist/components/Menu/Menu.d.ts +1 -1
- package/dist/components/Menu/index.d.ts +1 -0
- package/dist/components/Menu/types.d.ts +7 -0
- package/dist/components/Menu/utils.d.ts +10 -2
- package/dist/components/MenuV2/MenuV2Content.d.ts +1 -0
- package/dist/components/MenuV2/menuV2.types.d.ts +5 -0
- package/dist/components/MenuV2/menuV2.utils.d.ts +10 -2
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/ModalV2/ModalV2.d.ts +22 -0
- package/dist/components/ModalV2/ModalV2Footer.d.ts +10 -0
- package/dist/components/ModalV2/ModalV2Header.d.ts +15 -0
- package/dist/components/ModalV2/ModalV2Skeleton.d.ts +4 -0
- package/dist/components/ModalV2/index.d.ts +4 -0
- package/dist/components/ModalV2/mobileModalV2.d.ts +23 -0
- package/dist/components/ModalV2/modalAnimationV2.d.ts +3 -0
- package/dist/components/ModalV2/modalV2.dark.tokens.d.ts +3 -0
- package/dist/components/ModalV2/modalV2.light.tokens.d.ts +3 -0
- package/dist/components/ModalV2/modalV2.tokens.d.ts +5 -0
- package/dist/components/ModalV2/modalV2.tokens.types.d.ts +91 -0
- package/dist/components/ModalV2/modalV2.types.d.ts +66 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelectMenu.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts +2 -0
- package/dist/components/MultiSelect/types.d.ts +2 -0
- package/dist/components/MultiSelectV2/MultiSelectV2.d.ts +1 -1
- package/dist/components/MultiSelectV2/MultiSelectV2Menu.d.ts +1 -1
- package/dist/components/MultiSelectV2/multiSelectV2.types.d.ts +2 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Primitives/Block/Block.d.ts +1 -1
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/Sidebar/SidebarContent.d.ts +9 -1
- package/dist/components/Sidebar/index.d.ts +1 -0
- package/dist/components/Sidebar/types.d.ts +9 -1
- package/dist/components/SidebarV2/SidebarV2Panel.d.ts +10 -2
- package/dist/components/SidebarV2/types.d.ts +9 -1
- package/dist/components/SingleSelect/SingleSelect.d.ts +1 -1
- package/dist/components/SingleSelect/SingleSelectMenu.d.ts +2 -1
- package/dist/components/SingleSelect/index.d.ts +1 -0
- package/dist/components/SingleSelect/types.d.ts +1 -0
- package/dist/components/SingleSelectV2/SingleSelectV2.d.ts +1 -1
- package/dist/components/SingleSelectV2/SingleSelectV2Menu.d.ts +1 -1
- package/dist/components/SingleSelectV2/singleSelectV2.tokens.types.d.ts +8 -0
- package/dist/components/SingleSelectV2/singleSelectV2.types.d.ts +2 -0
- package/dist/components/Skeleton/SkeletonCompound.d.ts +24 -33
- package/dist/components/Snackbar/Snackbar.d.ts +1 -1
- package/dist/components/Snackbar/index.d.ts +2 -0
- package/dist/components/Snackbar/snackbar.tokens.d.ts +1 -0
- package/dist/components/Snackbar/types.d.ts +2 -0
- package/dist/components/StatCard/index.d.ts +1 -0
- package/dist/components/Stepper/index.d.ts +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Tags/index.d.ts +1 -0
- package/dist/components/Timeline/Timeline.d.ts +13 -37
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Topbar/index.d.ts +1 -0
- package/dist/components/Upload/index.d.ts +1 -0
- package/dist/context/ThemeContext.d.ts +6 -0
- package/dist/context/useComponentToken.d.ts +4 -1
- package/dist/main.d.ts +6 -0
- package/dist/main.js +45436 -42186
- package/dist/node-B3rrXW84.js +1023 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.js +21 -18
- package/dist/{tokens.js → token-engine.js} +1 -1
- package/lib/components/Accordion/AccordionItem.tsx +2 -6
- package/lib/components/Accordion/index.ts +2 -0
- package/lib/components/AccordionV2/AccordionV2Item.tsx +1 -1
- package/lib/components/AccordionV2/accordionV2.animations.ts +1 -5
- package/lib/components/Alert/index.ts +1 -0
- package/lib/components/Avatar/index.ts +1 -0
- package/lib/components/Breadcrumb/index.ts +1 -0
- package/lib/components/Button/index.ts +1 -0
- package/lib/components/ButtonGroup/index.ts +1 -0
- package/lib/components/Card/index.ts +1 -0
- package/lib/components/CardV2/CardV2.tsx +327 -0
- package/lib/components/CardV2/CardV2.utils.tsx +77 -0
- package/lib/components/CardV2/CardV2Components.tsx +297 -0
- package/lib/components/CardV2/CardV2Context.tsx +18 -0
- package/lib/components/CardV2/CardV2Skeleton.tsx +40 -0
- package/lib/components/CardV2/accessibility/CardV2AccessibilityReport.ts +284 -0
- package/lib/components/CardV2/accessibility/index.ts +1 -0
- package/lib/components/CardV2/cardV2.dark.tokens.ts +177 -0
- package/lib/components/CardV2/cardV2.light.tokens.ts +177 -0
- package/lib/components/CardV2/cardV2.tokens.ts +21 -0
- package/lib/components/CardV2/cardV2.tokens.types.ts +94 -0
- package/lib/components/CardV2/cardV2.types.ts +131 -0
- package/lib/components/CardV2/index.ts +13 -0
- package/lib/components/Charts/ChartLegend.tsx +25 -5
- package/lib/components/Charts/Charts.tsx +10 -0
- package/lib/components/Charts/index.ts +10 -0
- package/lib/components/Charts/types.tsx +2 -0
- package/lib/components/ChatInput/index.tsx +1 -0
- package/lib/components/Checkbox/index.ts +1 -0
- package/lib/components/CodeEditor/MonacoEditorWrapper.tsx +6 -2
- package/lib/components/CodeEditor/index.ts +1 -0
- package/lib/components/CodeEditor/types.ts +52 -2
- package/lib/components/CodeEditorV2/MonacoEditor/MonacoEditorWrapper.tsx +6 -2
- package/lib/components/CodeEditorV2/codeEditorV2.types.ts +44 -5
- package/lib/components/DataTable/DataTable.tsx +8 -0
- package/lib/components/DataTable/TableBody/index.tsx +47 -11
- package/lib/components/DataTable/TableBody/types.ts +7 -1
- package/lib/components/DataTable/TableCell/index.tsx +1 -1
- package/lib/components/DataTable/hooks/index.ts +2 -0
- package/lib/components/DataTable/hooks/useReducedMotion.ts +19 -0
- package/lib/components/DataTable/hooks/useRowFlip.ts +170 -0
- package/lib/components/DataTable/types.ts +32 -0
- package/lib/components/DateRangePicker/CalendarGrid.tsx +39 -6
- package/lib/components/DateRangePicker/DateRangePicker.tsx +27 -4
- package/lib/components/DateRangePicker/types.ts +6 -1
- package/lib/components/DateRangePicker/utils.ts +123 -12
- package/lib/components/Directory/Directory.tsx +31 -0
- package/lib/components/Directory/NavItem.tsx +177 -86
- package/lib/components/Directory/Section.tsx +9 -0
- package/lib/components/Directory/VirtualizedDirectory.tsx +670 -0
- package/lib/components/Directory/directory.tokens.ts +21 -0
- package/lib/components/Directory/types.ts +43 -1
- package/lib/components/Directory/utils.ts +81 -1
- package/lib/components/Drawer/index.ts +1 -0
- package/lib/components/Inputs/DropdownInput/DropdownInput.tsx +6 -2
- package/lib/components/Inputs/MultiValueInput/index.ts +1 -0
- package/lib/components/Inputs/NumberInput/NumberInput.tsx +6 -2
- package/lib/components/Inputs/NumberInput/index.ts +1 -0
- package/lib/components/Inputs/OTPInput/index.ts +1 -0
- package/lib/components/Inputs/SearchInput/index.ts +1 -0
- package/lib/components/Inputs/TextArea/TextArea.tsx +4 -2
- package/lib/components/Inputs/TextArea/index.ts +1 -0
- package/lib/components/Inputs/TextInput/TextInput.tsx +6 -2
- package/lib/components/Inputs/TextInput/index.ts +1 -0
- package/lib/components/Inputs/UnitInput/UnitInput.tsx +6 -2
- package/lib/components/InputsV2/NumberInputV2/NumberInputV2.tsx +6 -2
- package/lib/components/InputsV2/TextAreaV2/TextAreaV2.tsx +2 -1
- package/lib/components/InputsV2/TextAreaV2/utils.ts +3 -1
- package/lib/components/InputsV2/TextInputV2/TextInputV2.tsx +1 -0
- package/lib/components/InputsV2/TextInputV2/utils.ts +6 -8
- package/lib/components/InputsV2/UploadV2/UploadContainerV2.tsx +470 -0
- package/lib/components/InputsV2/UploadV2/UploadV2.dark.tokens.ts +348 -0
- package/lib/components/InputsV2/UploadV2/UploadV2.light.tokens.ts +348 -0
- package/lib/components/InputsV2/UploadV2/UploadV2.tokens.ts +20 -0
- package/lib/components/InputsV2/UploadV2/UploadV2.tokens.types.ts +117 -0
- package/lib/components/InputsV2/UploadV2/UploadV2.tsx +336 -0
- package/lib/components/InputsV2/UploadV2/UploadV2.types.ts +67 -0
- package/lib/components/InputsV2/UploadV2/index.ts +3 -0
- package/lib/components/InputsV2/UploadV2/utils.ts +170 -0
- package/lib/components/KeyValuePair/index.ts +1 -0
- package/lib/components/Menu/Menu.tsx +18 -2
- package/lib/components/Menu/SubMenu.tsx +25 -3
- package/lib/components/Menu/index.ts +1 -0
- package/lib/components/Menu/types.tsx +14 -0
- package/lib/components/Menu/utils.ts +46 -3
- package/lib/components/MenuV2/MenuV2.tsx +9 -2
- package/lib/components/MenuV2/MenuV2Content.tsx +6 -0
- package/lib/components/MenuV2/MenuV2SubMenu.tsx +16 -2
- package/lib/components/MenuV2/menuV2.types.ts +11 -0
- package/lib/components/MenuV2/menuV2.utils.ts +45 -3
- package/lib/components/Modal/index.ts +1 -0
- package/lib/components/ModalV2/ModalV2.tsx +269 -0
- package/lib/components/ModalV2/ModalV2Footer.tsx +76 -0
- package/lib/components/ModalV2/ModalV2Header.tsx +144 -0
- package/lib/components/ModalV2/ModalV2Skeleton.tsx +80 -0
- package/lib/components/ModalV2/index.ts +4 -0
- package/lib/components/ModalV2/mobileModalV2.tsx +411 -0
- package/lib/components/ModalV2/modalAnimationV2.tsx +19 -0
- package/lib/components/ModalV2/modalV2.dark.tokens.ts +183 -0
- package/lib/components/ModalV2/modalV2.light.tokens.ts +183 -0
- package/lib/components/ModalV2/modalV2.tokens.ts +21 -0
- package/lib/components/ModalV2/modalV2.tokens.types.ts +94 -0
- package/lib/components/ModalV2/modalV2.types.ts +80 -0
- package/lib/components/MultiSelect/MultiSelect.tsx +4 -1
- package/lib/components/MultiSelect/MultiSelectMenu.tsx +8 -0
- package/lib/components/MultiSelect/MultiSelectTrigger.tsx +2 -1
- package/lib/components/MultiSelect/index.ts +2 -0
- package/lib/components/MultiSelect/types.ts +2 -0
- package/lib/components/MultiSelectV2/MultiSelectV2.tsx +2 -0
- package/lib/components/MultiSelectV2/MultiSelectV2Menu.tsx +8 -0
- package/lib/components/MultiSelectV2/MultiSelectV2Trigger.tsx +4 -1
- package/lib/components/MultiSelectV2/multiSelectV2.types.ts +2 -0
- package/lib/components/Popover/index.ts +1 -0
- package/lib/components/Primitives/Block/Block.tsx +1 -1
- package/lib/components/ProgressBar/index.ts +1 -0
- package/lib/components/Radio/index.ts +2 -0
- package/lib/components/Sidebar/Sidebar.tsx +38 -0
- package/lib/components/Sidebar/SidebarContent.tsx +25 -1
- package/lib/components/Sidebar/index.ts +1 -0
- package/lib/components/Sidebar/types.ts +13 -1
- package/lib/components/SidebarV2/SidebarV2.tsx +30 -0
- package/lib/components/SidebarV2/SidebarV2Panel.tsx +25 -1
- package/lib/components/SidebarV2/types.ts +9 -1
- package/lib/components/SingleSelect/SingleSelect.tsx +4 -1
- package/lib/components/SingleSelect/SingleSelectMenu.tsx +171 -138
- package/lib/components/SingleSelect/SingleSelectTrigger.tsx +3 -1
- package/lib/components/SingleSelect/index.ts +1 -0
- package/lib/components/SingleSelect/types.ts +1 -0
- package/lib/components/SingleSelectV2/SingleSelectV2.tsx +2 -0
- package/lib/components/SingleSelectV2/SingleSelectV2Menu.tsx +84 -58
- package/lib/components/SingleSelectV2/SingleSelectV2Search.tsx +1 -0
- package/lib/components/SingleSelectV2/SingleSelectV2Trigger.tsx +3 -1
- package/lib/components/SingleSelectV2/singleSelectV2.dark.tokens.ts +8 -0
- package/lib/components/SingleSelectV2/singleSelectV2.light.tokens.ts +8 -0
- package/lib/components/SingleSelectV2/singleSelectV2.tokens.types.ts +8 -0
- package/lib/components/SingleSelectV2/singleSelectV2.types.ts +2 -0
- package/lib/components/Skeleton/SkeletonCompound.tsx +45 -31
- package/lib/components/Snackbar/Snackbar.tsx +18 -8
- package/lib/components/Snackbar/index.ts +2 -0
- package/lib/components/Snackbar/snackbar.tokens.ts +6 -0
- package/lib/components/Snackbar/types.ts +2 -0
- package/lib/components/StatCard/StatCard.tsx +29 -0
- package/lib/components/StatCard/index.ts +1 -0
- package/lib/components/Stepper/index.ts +1 -0
- package/lib/components/Switch/index.ts +2 -0
- package/lib/components/Tabs/index.ts +1 -0
- package/lib/components/Tags/index.ts +1 -0
- package/lib/components/Timeline/Timeline.tsx +9 -1
- package/lib/components/Tooltip/index.ts +1 -0
- package/lib/components/Topbar/index.ts +1 -0
- package/lib/components/Upload/index.ts +1 -0
- package/lib/context/ThemeContext.tsx +16 -0
- package/lib/context/initComponentTokens.ts +11 -0
- package/lib/context/useComponentToken.ts +15 -1
- package/lib/hooks/useResponsiveTokens.ts +63 -0
- package/lib/main.ts +16 -0
- package/lib/node.ts +2 -0
- package/package.json +5 -4
- package/dist/tokens.d.ts +0 -2
|
@@ -29,6 +29,7 @@ const Charts: React.FC<ChartsProps> = ({
|
|
|
29
29
|
chartHeaderSlot,
|
|
30
30
|
stackedLegends = false,
|
|
31
31
|
stackedLegendsData,
|
|
32
|
+
showAllLegends = false,
|
|
32
33
|
barsize,
|
|
33
34
|
xAxis,
|
|
34
35
|
yAxis,
|
|
@@ -404,6 +405,7 @@ const Charts: React.FC<ChartsProps> = ({
|
|
|
404
405
|
hoveredKey={hoveredKey}
|
|
405
406
|
activeKeys={selectedKeys}
|
|
406
407
|
stacked={false}
|
|
408
|
+
showAllLegends={showAllLegends}
|
|
407
409
|
/>
|
|
408
410
|
}
|
|
409
411
|
<Block
|
|
@@ -566,6 +568,7 @@ const Charts: React.FC<ChartsProps> = ({
|
|
|
566
568
|
stackedLegendsData={
|
|
567
569
|
stackedLegendsData
|
|
568
570
|
}
|
|
571
|
+
showAllLegends={showAllLegends}
|
|
569
572
|
/>
|
|
570
573
|
</Block>
|
|
571
574
|
</Block>
|
|
@@ -714,6 +717,9 @@ const Charts: React.FC<ChartsProps> = ({
|
|
|
714
717
|
hoveredKey={hoveredKey}
|
|
715
718
|
activeKeys={selectedKeys}
|
|
716
719
|
stacked={false}
|
|
720
|
+
showAllLegends={
|
|
721
|
+
showAllLegends
|
|
722
|
+
}
|
|
717
723
|
/>
|
|
718
724
|
</Block>
|
|
719
725
|
)}
|
|
@@ -827,6 +833,9 @@ const Charts: React.FC<ChartsProps> = ({
|
|
|
827
833
|
stackedLegendsData={
|
|
828
834
|
stackedLegendsData
|
|
829
835
|
}
|
|
836
|
+
showAllLegends={
|
|
837
|
+
showAllLegends
|
|
838
|
+
}
|
|
830
839
|
/>
|
|
831
840
|
)}
|
|
832
841
|
{stackedLegends && (
|
|
@@ -987,6 +996,7 @@ const Charts: React.FC<ChartsProps> = ({
|
|
|
987
996
|
stackedLegendsData={
|
|
988
997
|
stackedLegendsData
|
|
989
998
|
}
|
|
999
|
+
showAllLegends={showAllLegends}
|
|
990
1000
|
/>
|
|
991
1001
|
</Block>
|
|
992
1002
|
</Block>
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
1
2
|
export { default as Charts } from './Charts'
|
|
2
3
|
|
|
4
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
3
5
|
export { default as CoreChart } from './CoreChart'
|
|
6
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
4
7
|
export { default as ChartContainer } from './ChartContainer'
|
|
8
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
5
9
|
export { default as ChartHeader } from './ChartHeader'
|
|
10
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
6
11
|
export { default as ChartLegends } from './ChartLegend'
|
|
12
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
7
13
|
export { default as SankeyNode } from './SankeyNode'
|
|
14
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
8
15
|
export { default as SankeyLink } from './SankeyLink'
|
|
9
16
|
|
|
17
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
10
18
|
export { default as BlendChart } from './BlendChart'
|
|
19
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
11
20
|
export { default as BlendChartContainer } from './BlendChartContainer'
|
|
21
|
+
/** @deprecated Will be deprecated soon. Use ChartV2 instead. */
|
|
12
22
|
export { default as BlendChartHeader } from './BlendChartHeader'
|
|
13
23
|
export * from './chart.tokens'
|
|
14
24
|
export * from './types'
|
|
@@ -184,6 +184,7 @@ export type ChartsProps = {
|
|
|
184
184
|
chartHeaderSlot: ReactNode
|
|
185
185
|
stackedLegends?: boolean
|
|
186
186
|
stackedLegendsData?: StackedLegendsDataPoint[]
|
|
187
|
+
showAllLegends?: boolean
|
|
187
188
|
barsize?: number
|
|
188
189
|
xAxis?: XAxisConfig
|
|
189
190
|
yAxis?: YAxisConfig
|
|
@@ -236,6 +237,7 @@ export type ChartLegendsProps = {
|
|
|
236
237
|
isSmallScreen?: boolean
|
|
237
238
|
stackedLegendsData?: StackedLegendsDataPoint[]
|
|
238
239
|
legends?: { title: string; total?: string }[]
|
|
240
|
+
showAllLegends?: boolean
|
|
239
241
|
}
|
|
240
242
|
|
|
241
243
|
export type CustomTooltipProps = TooltipProps<ValueType, NameType> & {
|
|
@@ -5,9 +5,13 @@ import Block from '../Primitives/Block/Block'
|
|
|
5
5
|
import type { CodeBlockTokenType } from '../CodeBlock/codeBlock.token'
|
|
6
6
|
import './monaco-editor.css'
|
|
7
7
|
|
|
8
|
+
// Monaco registers only `javascript`/`typescript` (VS Code's
|
|
9
|
+
// `javascriptreact`/`typescriptreact` IDs are not registered, so they would
|
|
10
|
+
// fall back to plaintext with no highlighting). Monaco's JS/TS tokenizers
|
|
11
|
+
// handle JSX/TSX syntax fine, so map the ergonomic aliases onto them.
|
|
8
12
|
const LANGUAGE_MAP: Record<string, string> = {
|
|
9
|
-
jsx: '
|
|
10
|
-
tsx: '
|
|
13
|
+
jsx: 'javascript',
|
|
14
|
+
tsx: 'typescript',
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
const mapLanguage = (value: string) => LANGUAGE_MAP[value] ?? value
|
|
@@ -1,11 +1,61 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
-
import type { SupportedLanguage } from '../CodeBlock/types'
|
|
3
2
|
|
|
4
3
|
export enum CodeEditorVariant {
|
|
5
4
|
DEFAULT = 'default',
|
|
6
5
|
NO_GUTTER = 'no-gutter',
|
|
7
6
|
}
|
|
8
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Common Monaco language IDs, provided purely for IDE autocomplete on the
|
|
10
|
+
* `language` prop — NOT a runtime constraint. Every entry is verified against
|
|
11
|
+
* the language IDs monaco-editor actually registers (Monaco does not export a
|
|
12
|
+
* static union of its built-in IDs; they are only enumerable at runtime via
|
|
13
|
+
* `monaco.languages.getLanguages()`). Note Monaco's plain-text ID is
|
|
14
|
+
* `plaintext` and shell scripts are `shell` (there is no `bash` ID). Monaco
|
|
15
|
+
* also has no distinct `jsx`/`tsx` IDs — those still work through the open
|
|
16
|
+
* string arm of {@link CodeEditorLanguage}: the editor maps them onto the
|
|
17
|
+
* `javascript`/`typescript` tokenizers.
|
|
18
|
+
*/
|
|
19
|
+
export type KnownCodeEditorLanguage =
|
|
20
|
+
| 'javascript'
|
|
21
|
+
| 'typescript'
|
|
22
|
+
| 'json'
|
|
23
|
+
| 'css'
|
|
24
|
+
| 'scss'
|
|
25
|
+
| 'less'
|
|
26
|
+
| 'html'
|
|
27
|
+
| 'xml'
|
|
28
|
+
| 'markdown'
|
|
29
|
+
| 'yaml'
|
|
30
|
+
| 'ini'
|
|
31
|
+
| 'graphql'
|
|
32
|
+
| 'sql'
|
|
33
|
+
| 'python'
|
|
34
|
+
| 'rust'
|
|
35
|
+
| 'go'
|
|
36
|
+
| 'java'
|
|
37
|
+
| 'kotlin'
|
|
38
|
+
| 'swift'
|
|
39
|
+
| 'c'
|
|
40
|
+
| 'cpp'
|
|
41
|
+
| 'csharp'
|
|
42
|
+
| 'php'
|
|
43
|
+
| 'ruby'
|
|
44
|
+
| 'shell'
|
|
45
|
+
| 'powershell'
|
|
46
|
+
| 'dockerfile'
|
|
47
|
+
| 'plaintext'
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Language accepted by {@link CodeEditorProps.language}: autocomplete for
|
|
51
|
+
* {@link KnownCodeEditorLanguage}, while `(string & {})` keeps the prop open
|
|
52
|
+
* to every other Monaco language ID (the component forwards to Monaco, whose
|
|
53
|
+
* own `language` option is a plain `string`). Decoupled from `CodeBlock`'s
|
|
54
|
+
* `SupportedLanguage`, which is scoped to CodeBlock's hand-rolled tokenizer
|
|
55
|
+
* rather than Monaco.
|
|
56
|
+
*/
|
|
57
|
+
export type CodeEditorLanguage = KnownCodeEditorLanguage | (string & {})
|
|
58
|
+
|
|
9
59
|
export type CodeEditorProps = {
|
|
10
60
|
value: string
|
|
11
61
|
onChange?: (value: string) => void
|
|
@@ -30,7 +80,7 @@ export type CodeEditorProps = {
|
|
|
30
80
|
*/
|
|
31
81
|
showLeftIcon?: boolean
|
|
32
82
|
showCopyButton?: boolean
|
|
33
|
-
language?:
|
|
83
|
+
language?: CodeEditorLanguage
|
|
34
84
|
placeholder?: string
|
|
35
85
|
readOnly?: boolean
|
|
36
86
|
disabled?: boolean
|
|
@@ -25,9 +25,13 @@ import { CSSObject } from 'styled-components'
|
|
|
25
25
|
// Language mapping
|
|
26
26
|
// ---------------------------------------------------------------------------
|
|
27
27
|
|
|
28
|
+
// Monaco registers only `javascript`/`typescript` (VS Code's
|
|
29
|
+
// `javascriptreact`/`typescriptreact` IDs are not registered, so they would
|
|
30
|
+
// fall back to plaintext with no highlighting). Monaco's JS/TS tokenizers
|
|
31
|
+
// handle JSX/TSX syntax fine, so map the ergonomic aliases onto them.
|
|
28
32
|
const LANGUAGE_MAP: Record<string, string> = {
|
|
29
|
-
jsx: '
|
|
30
|
-
tsx: '
|
|
33
|
+
jsx: 'javascript',
|
|
34
|
+
tsx: 'typescript',
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
const mapLanguage = (lang: string) => LANGUAGE_MAP[lang] ?? lang
|
|
@@ -21,19 +21,58 @@ export type CodeEditorV2DiffLine = {
|
|
|
21
21
|
type: CodeEditorV2DiffLineType
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Common Monaco language IDs, provided purely for IDE autocomplete on the
|
|
26
|
+
* `language` prop — NOT a runtime constraint. Every entry is verified against
|
|
27
|
+
* the language IDs monaco-editor actually registers (Monaco does not export a
|
|
28
|
+
* static union of its built-in IDs; they are only enumerable at runtime via
|
|
29
|
+
* `monaco.languages.getLanguages()`). Note Monaco's plain-text ID is
|
|
30
|
+
* `plaintext` and shell scripts are `shell` (there is no `bash` ID). Monaco
|
|
31
|
+
* also has no distinct `jsx`/`tsx` IDs — those still work through the open
|
|
32
|
+
* string arm of {@link CodeEditorV2Language}: the editor maps them onto the
|
|
33
|
+
* `javascript`/`typescript` tokenizers.
|
|
34
|
+
*/
|
|
35
|
+
export type KnownCodeEditorV2Language =
|
|
25
36
|
| 'javascript'
|
|
26
37
|
| 'typescript'
|
|
27
|
-
| 'jsx'
|
|
28
|
-
| 'tsx'
|
|
29
38
|
| 'json'
|
|
30
39
|
| 'css'
|
|
40
|
+
| 'scss'
|
|
41
|
+
| 'less'
|
|
31
42
|
| 'html'
|
|
43
|
+
| 'xml'
|
|
32
44
|
| 'markdown'
|
|
33
45
|
| 'yaml'
|
|
46
|
+
| 'ini'
|
|
47
|
+
| 'graphql'
|
|
48
|
+
| 'sql'
|
|
34
49
|
| 'python'
|
|
35
50
|
| 'rust'
|
|
36
|
-
| '
|
|
51
|
+
| 'go'
|
|
52
|
+
| 'java'
|
|
53
|
+
| 'kotlin'
|
|
54
|
+
| 'swift'
|
|
55
|
+
| 'c'
|
|
56
|
+
| 'cpp'
|
|
57
|
+
| 'csharp'
|
|
58
|
+
| 'php'
|
|
59
|
+
| 'ruby'
|
|
60
|
+
| 'shell'
|
|
61
|
+
| 'powershell'
|
|
62
|
+
| 'dockerfile'
|
|
63
|
+
| 'plaintext'
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Language accepted by {@link CodeEditorV2Props.language}: autocomplete for
|
|
67
|
+
* {@link KnownCodeEditorV2Language}, while `(string & {})` keeps the prop open
|
|
68
|
+
* to every other Monaco language ID (matching the internal
|
|
69
|
+
* `MonacoEditorWrapper`'s `language: string` — Monaco itself types the option
|
|
70
|
+
* as a plain `string`).
|
|
71
|
+
*/
|
|
72
|
+
export type CodeEditorV2Language = KnownCodeEditorV2Language | (string & {})
|
|
73
|
+
|
|
74
|
+
/** @deprecated Use {@link CodeEditorV2Language} instead. */
|
|
75
|
+
export type CodeEditorV2SupportedLanguage = CodeEditorV2Language
|
|
37
76
|
|
|
38
77
|
export type CodeEditorV2Dimensions = {
|
|
39
78
|
width?: CSSObject['width']
|
|
@@ -56,7 +95,7 @@ export type CodeEditorV2Props = {
|
|
|
56
95
|
rightSlot?: ReactNode
|
|
57
96
|
showCopyButton?: boolean
|
|
58
97
|
}
|
|
59
|
-
language?:
|
|
98
|
+
language?: CodeEditorV2Language
|
|
60
99
|
placeholder?: string
|
|
61
100
|
readOnly?: boolean
|
|
62
101
|
disabled?: boolean
|
|
@@ -155,6 +155,8 @@ const DataTable = forwardRef(
|
|
|
155
155
|
onInsertRight,
|
|
156
156
|
onDeleteColumn,
|
|
157
157
|
getRowStyle,
|
|
158
|
+
enableRowAnimation,
|
|
159
|
+
rowAnimationConfig,
|
|
158
160
|
tableBodyHeight,
|
|
159
161
|
mobileColumnsToShow,
|
|
160
162
|
enablePivotTable = false,
|
|
@@ -1997,6 +1999,12 @@ const DataTable = forwardRef(
|
|
|
1997
1999
|
) => boolean)
|
|
1998
2000
|
| undefined
|
|
1999
2001
|
}
|
|
2002
|
+
enableRowAnimation={
|
|
2003
|
+
enableRowAnimation
|
|
2004
|
+
}
|
|
2005
|
+
rowAnimationConfig={
|
|
2006
|
+
rowAnimationConfig
|
|
2007
|
+
}
|
|
2000
2008
|
/>
|
|
2001
2009
|
)}
|
|
2002
2010
|
</table>
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useMemo,
|
|
4
|
+
useRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
useCallback,
|
|
8
|
+
} from 'react'
|
|
2
9
|
import {
|
|
3
10
|
Edit,
|
|
4
11
|
Save,
|
|
@@ -18,6 +25,7 @@ import Menu from '../../Menu/Menu'
|
|
|
18
25
|
import { MenuAlignment, MenuSide } from '../../Menu/types'
|
|
19
26
|
import Skeleton from '../../Skeleton/Skeleton'
|
|
20
27
|
import { getSkeletonState } from '../../Skeleton/utils'
|
|
28
|
+
import { useRowFlip } from '../hooks/useRowFlip'
|
|
21
29
|
|
|
22
30
|
import { Button, ButtonType, ButtonSize, ButtonSubType } from '../../Button'
|
|
23
31
|
import { Checkbox, CheckboxSize } from '../../Checkbox'
|
|
@@ -571,6 +579,8 @@ const TableBody = forwardRef<
|
|
|
571
579
|
isRowLoading,
|
|
572
580
|
focusedCell,
|
|
573
581
|
onCellFocus,
|
|
582
|
+
enableRowAnimation = false,
|
|
583
|
+
rowAnimationConfig,
|
|
574
584
|
},
|
|
575
585
|
ref
|
|
576
586
|
) => {
|
|
@@ -650,13 +660,33 @@ const TableBody = forwardRef<
|
|
|
650
660
|
return `tbody-${len}-${firstId}-${lastId}`
|
|
651
661
|
}, [currentData, dataVersion, idField])
|
|
652
662
|
|
|
663
|
+
const orderedRowIds = useMemo(
|
|
664
|
+
() => currentData.map((row) => String(row[idField])),
|
|
665
|
+
[currentData, idField]
|
|
666
|
+
)
|
|
667
|
+
|
|
668
|
+
const { register } = useRowFlip(
|
|
669
|
+
enableRowAnimation ? orderedRowIds : [],
|
|
670
|
+
rowAnimationConfig
|
|
671
|
+
)
|
|
672
|
+
|
|
673
|
+
const getFlipRefCallback = useCallback(
|
|
674
|
+
(rowId: string) => (el: HTMLTableRowElement | null) => {
|
|
675
|
+
if (!enableRowAnimation) return
|
|
676
|
+
register(rowId, el)
|
|
677
|
+
},
|
|
678
|
+
[enableRowAnimation, register]
|
|
679
|
+
)
|
|
680
|
+
|
|
681
|
+
const isPageTransition = !enableRowAnimation
|
|
682
|
+
|
|
653
683
|
return (
|
|
654
684
|
<motion.tbody
|
|
655
|
-
key={tbodyKey}
|
|
685
|
+
key={isPageTransition ? tbodyKey : undefined}
|
|
656
686
|
ref={ref}
|
|
657
|
-
initial={{ opacity: 0 }}
|
|
658
|
-
animate={{ opacity: 1 }}
|
|
659
|
-
transition={{ duration: 0.3 }}
|
|
687
|
+
initial={isPageTransition ? { opacity: 0 } : undefined}
|
|
688
|
+
animate={isPageTransition ? { opacity: 1 } : undefined}
|
|
689
|
+
transition={isPageTransition ? { duration: 0.3 } : undefined}
|
|
660
690
|
style={{
|
|
661
691
|
backgroundColor: FOUNDATION_THEME.colors.gray[0],
|
|
662
692
|
}}
|
|
@@ -685,7 +715,6 @@ const TableBody = forwardRef<
|
|
|
685
715
|
const isSelected = selectedRows[rowId] || false
|
|
686
716
|
const rowAriaLabel = `Row ${index + 1}${isSelected ? ', selected' : ''}${isExpanded ? ', expanded' : ''}`
|
|
687
717
|
|
|
688
|
-
// Helper to calculate absolute column index
|
|
689
718
|
const getAbsoluteColIndex = (
|
|
690
719
|
relativeColIndex: number
|
|
691
720
|
) => {
|
|
@@ -695,11 +724,18 @@ const TableBody = forwardRef<
|
|
|
695
724
|
return colIndex
|
|
696
725
|
}
|
|
697
726
|
|
|
698
|
-
const rowKey =
|
|
727
|
+
const rowKey = enableRowAnimation
|
|
728
|
+
? rowId
|
|
729
|
+
: `${rowId}-${index}`
|
|
699
730
|
|
|
700
731
|
return (
|
|
701
732
|
<React.Fragment key={rowKey}>
|
|
702
733
|
<TableRow
|
|
734
|
+
ref={
|
|
735
|
+
enableRowAnimation
|
|
736
|
+
? getFlipRefCallback(rowId)
|
|
737
|
+
: undefined
|
|
738
|
+
}
|
|
703
739
|
$isClickable={!!onRowClick}
|
|
704
740
|
$customBackgroundColor={
|
|
705
741
|
rowStyling.backgroundColor
|
|
@@ -1156,6 +1192,9 @@ const TableBody = forwardRef<
|
|
|
1156
1192
|
$hasCustomBackground={
|
|
1157
1193
|
hasCustomBackground
|
|
1158
1194
|
}
|
|
1195
|
+
$isFirstRow={
|
|
1196
|
+
index === 0
|
|
1197
|
+
}
|
|
1159
1198
|
data-row-index={index}
|
|
1160
1199
|
data-col-index={
|
|
1161
1200
|
absoluteColIndex
|
|
@@ -1188,9 +1227,6 @@ const TableBody = forwardRef<
|
|
|
1188
1227
|
getFrozenBodyStyles()),
|
|
1189
1228
|
outline: 'none',
|
|
1190
1229
|
}}
|
|
1191
|
-
$isFirstRow={
|
|
1192
|
-
index === 0
|
|
1193
|
-
}
|
|
1194
1230
|
>
|
|
1195
1231
|
<Skeleton
|
|
1196
1232
|
variant={
|
|
@@ -1537,6 +1573,7 @@ const TableBody = forwardRef<
|
|
|
1537
1573
|
$hasCustomBackground={
|
|
1538
1574
|
hasCustomBackground
|
|
1539
1575
|
}
|
|
1576
|
+
$isFirstRow={index === 0}
|
|
1540
1577
|
data-row-index={index}
|
|
1541
1578
|
data-col-index={
|
|
1542
1579
|
columnManagerColIndex
|
|
@@ -1562,7 +1599,6 @@ const TableBody = forwardRef<
|
|
|
1562
1599
|
)
|
|
1563
1600
|
}
|
|
1564
1601
|
role="gridcell"
|
|
1565
|
-
$isFirstRow={index === 0}
|
|
1566
1602
|
style={{
|
|
1567
1603
|
minWidth:
|
|
1568
1604
|
FOUNDATION_THEME
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ColumnDefinition,
|
|
3
|
+
RowActionsConfig,
|
|
4
|
+
RowAnimationConfig,
|
|
5
|
+
} from '../types'
|
|
2
6
|
import { MobileDataTableConfig } from '../hooks/useMobileDataTable'
|
|
3
7
|
import type { SkeletonVariant } from '../../Skeleton/skeleton.tokens'
|
|
4
8
|
|
|
@@ -57,4 +61,6 @@ export type TableBodyProps<T extends Record<string, unknown>> = {
|
|
|
57
61
|
isRowLoading?: (row: T, index: number) => boolean
|
|
58
62
|
focusedCell?: { rowIndex: number; colIndex: number } | null
|
|
59
63
|
onCellFocus?: (rowIndex: number, colIndex: number) => void
|
|
64
|
+
enableRowAnimation?: boolean
|
|
65
|
+
rowAnimationConfig?: RowAnimationConfig
|
|
60
66
|
}
|
|
@@ -576,8 +576,8 @@ const TableCell = forwardRef<
|
|
|
576
576
|
column.type === ColumnType.REACT_ELEMENT ||
|
|
577
577
|
(isEditing && column.isEditable)
|
|
578
578
|
}
|
|
579
|
-
$isFirstRow={isFirstRow}
|
|
580
579
|
$customBackgroundColor={customBackgroundColor}
|
|
580
|
+
$isFirstRow={isFirstRow}
|
|
581
581
|
$hasCustomBackground={hasCustomBackground}
|
|
582
582
|
data-row-index={dataRowIndex}
|
|
583
583
|
data-col-index={dataColIndex}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useReducedMotion(): boolean {
|
|
4
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = useState(() => {
|
|
5
|
+
if (typeof window === 'undefined') return false
|
|
6
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const mql = window.matchMedia('(prefers-reduced-motion: reduce)')
|
|
11
|
+
const handler = (e: MediaQueryListEvent) => {
|
|
12
|
+
setPrefersReducedMotion(e.matches)
|
|
13
|
+
}
|
|
14
|
+
mql.addEventListener('change', handler)
|
|
15
|
+
return () => mql.removeEventListener('change', handler)
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
return prefersReducedMotion
|
|
19
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useRef, useLayoutEffect, useCallback, useMemo } from 'react'
|
|
2
|
+
import { useReducedMotion } from './useReducedMotion'
|
|
3
|
+
import type { RowAnimationConfig } from '../types'
|
|
4
|
+
|
|
5
|
+
function toCssTransition(config: RowAnimationConfig): {
|
|
6
|
+
transition: string
|
|
7
|
+
duration: number
|
|
8
|
+
} {
|
|
9
|
+
if (config.transitionType === 'bezier') {
|
|
10
|
+
const [p0, p1, p2, p3] = config.bezier
|
|
11
|
+
const cssBezier = `cubic-bezier(${p0}, ${p1}, ${p2}, ${p3})`
|
|
12
|
+
return {
|
|
13
|
+
duration: config.duration,
|
|
14
|
+
transition: `transform ${config.duration}s ${cssBezier}, opacity ${config.duration}s ${cssBezier}`,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const cssBezier = `cubic-bezier(0.32, 0.72, 0, 1)`
|
|
19
|
+
const transition = `transform 0.35s ${cssBezier}, opacity 0.35s ${cssBezier}`
|
|
20
|
+
return {
|
|
21
|
+
duration: 0.35,
|
|
22
|
+
transition,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface UseRowFlipReturn {
|
|
27
|
+
register: (id: string, el: HTMLTableRowElement | null) => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function useRowFlip(
|
|
31
|
+
orderedIds: string[],
|
|
32
|
+
animationConfig?: RowAnimationConfig
|
|
33
|
+
): UseRowFlipReturn {
|
|
34
|
+
const elementsRef = useRef<Map<string, HTMLTableRowElement>>(new Map())
|
|
35
|
+
const prevTopsRef = useRef<Map<string, number>>(new Map())
|
|
36
|
+
const prevIdsRef = useRef<Set<string>>(new Set())
|
|
37
|
+
const configRef = useRef<RowAnimationConfig | undefined>(animationConfig)
|
|
38
|
+
const orderedIdsRef = useRef(orderedIds)
|
|
39
|
+
const prefersReducedMotion = useReducedMotion()
|
|
40
|
+
const cleanupTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
41
|
+
const serializedOrderedIds = useMemo(
|
|
42
|
+
() => JSON.stringify(orderedIds),
|
|
43
|
+
[orderedIds]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
configRef.current = animationConfig
|
|
47
|
+
orderedIdsRef.current = orderedIds
|
|
48
|
+
|
|
49
|
+
const register = useCallback(
|
|
50
|
+
(id: string, el: HTMLTableRowElement | null) => {
|
|
51
|
+
if (el === null) {
|
|
52
|
+
elementsRef.current.delete(id)
|
|
53
|
+
} else {
|
|
54
|
+
elementsRef.current.set(id, el)
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
[]
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
useLayoutEffect(() => {
|
|
61
|
+
const currentOrderedIds = orderedIdsRef.current
|
|
62
|
+
const currentConfig = configRef.current
|
|
63
|
+
|
|
64
|
+
if (prefersReducedMotion) {
|
|
65
|
+
const newTops = new Map<string, number>()
|
|
66
|
+
for (const id of currentOrderedIds) {
|
|
67
|
+
const el = elementsRef.current.get(id)
|
|
68
|
+
if (el) {
|
|
69
|
+
newTops.set(id, el.getBoundingClientRect().top)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
prevTopsRef.current = newTops
|
|
73
|
+
prevIdsRef.current = new Set(currentOrderedIds)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const currentTops = new Map<string, number>()
|
|
78
|
+
for (const id of currentOrderedIds) {
|
|
79
|
+
const el = elementsRef.current.get(id)
|
|
80
|
+
if (el) {
|
|
81
|
+
currentTops.set(id, el.getBoundingClientRect().top)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!currentConfig) {
|
|
86
|
+
prevTopsRef.current = currentTops
|
|
87
|
+
prevIdsRef.current = new Set(currentOrderedIds)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { transition: cssTransition, duration } =
|
|
92
|
+
toCssTransition(currentConfig)
|
|
93
|
+
const enterDuration = currentConfig.enterDuration
|
|
94
|
+
const enterOffset = currentConfig.enterOffset
|
|
95
|
+
|
|
96
|
+
const prevIds = prevIdsRef.current
|
|
97
|
+
const newRowIdSet = new Set(
|
|
98
|
+
currentOrderedIds.filter((id) => !prevIds.has(id))
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
for (const [id, newTop] of currentTops) {
|
|
102
|
+
if (newRowIdSet.has(id)) continue
|
|
103
|
+
|
|
104
|
+
const prevTop = prevTopsRef.current.get(id)
|
|
105
|
+
if (prevTop === undefined) continue
|
|
106
|
+
|
|
107
|
+
const delta = prevTop - newTop
|
|
108
|
+
if (Math.abs(delta) < 1) continue
|
|
109
|
+
|
|
110
|
+
const el = elementsRef.current.get(id)
|
|
111
|
+
if (!el) continue
|
|
112
|
+
|
|
113
|
+
el.style.transition = 'none'
|
|
114
|
+
el.style.transform = `translateY(${delta}px)`
|
|
115
|
+
|
|
116
|
+
requestAnimationFrame(() => {
|
|
117
|
+
requestAnimationFrame(() => {
|
|
118
|
+
el.style.transition = cssTransition
|
|
119
|
+
el.style.transform = ''
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
for (const id of newRowIdSet) {
|
|
125
|
+
const el = elementsRef.current.get(id)
|
|
126
|
+
if (!el) continue
|
|
127
|
+
|
|
128
|
+
el.style.transition = 'none'
|
|
129
|
+
el.style.transform = `translateY(${enterOffset}px)`
|
|
130
|
+
el.style.opacity = '0'
|
|
131
|
+
|
|
132
|
+
requestAnimationFrame(() => {
|
|
133
|
+
requestAnimationFrame(() => {
|
|
134
|
+
el.style.transition = `transform ${enterDuration}s cubic-bezier(0.32, 0.72, 0, 1), opacity ${enterDuration}s cubic-bezier(0.32, 0.72, 0, 1)`
|
|
135
|
+
el.style.transform = ''
|
|
136
|
+
el.style.opacity = '1'
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const cleanupTimeout = Math.max(duration, enterDuration) * 1000 + 50
|
|
142
|
+
|
|
143
|
+
if (cleanupTimeoutRef.current) {
|
|
144
|
+
clearTimeout(cleanupTimeoutRef.current)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
cleanupTimeoutRef.current = setTimeout(() => {
|
|
148
|
+
for (const id of currentOrderedIds) {
|
|
149
|
+
const el = elementsRef.current.get(id)
|
|
150
|
+
if (el) {
|
|
151
|
+
el.style.transition = ''
|
|
152
|
+
el.style.transform = ''
|
|
153
|
+
el.style.opacity = ''
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, cleanupTimeout)
|
|
157
|
+
|
|
158
|
+
prevTopsRef.current = currentTops
|
|
159
|
+
prevIdsRef.current = new Set(currentOrderedIds)
|
|
160
|
+
|
|
161
|
+
return () => {
|
|
162
|
+
if (cleanupTimeoutRef.current) {
|
|
163
|
+
clearTimeout(cleanupTimeoutRef.current)
|
|
164
|
+
cleanupTimeoutRef.current = null
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, [serializedOrderedIds, prefersReducedMotion])
|
|
168
|
+
|
|
169
|
+
return { register }
|
|
170
|
+
}
|