@reltio/components 1.4.2018 → 1.4.2019
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/BarChart/helpers.d.ts +2 -2
- package/BasicTable/IntegrationBasicTable.test.js +6 -18
- package/EditModeAttributesView/IntegrationEditModeAttributesView.test.js +2 -5
- package/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +2 -5
- package/InlineAttributesPager/components/InlineSimpleAttributesBlock/InlineSimpleAttributesBlock.js +33 -22
- package/InlineAttributesPager/components/InlineSimpleAttributesBlock/InlineSimpleAttributesBlock.test.js +120 -112
- package/InlineSimpleAttribute/InlineSimpleAttribute.js +1 -1
- package/LineChart/helpers.d.ts +2 -2
- package/PieChart/PieChart.test.js +4 -0
- package/UploadImageDialog/UploadImageDialog.specs.js +1 -4
- package/UploadImageDialog/components/TargetBox/TargetBox.js +31 -20
- package/UploadImageDialog/components/TargetBox/TargetBox.specs.d.ts +1 -1
- package/UploadImageDialog/components/TargetBox/TargetBox.specs.js +57 -16
- package/UploadImageDialog/components/TargetBox/styles.js +2 -1
- package/VerticalHeadingsTable/DndVerticalHeadingsTable.test.js +114 -0
- package/VerticalHeadingsTable/VerticalHeadingsTable.d.ts +2 -1
- package/VerticalHeadingsTable/VerticalHeadingsTable.js +10 -13
- package/VerticalHeadingsTable/VerticalHeadingsTable.test.js +74 -269
- package/VerticalHeadingsTable/components/DndComponent/DndComponent.d.ts +14 -0
- package/VerticalHeadingsTable/components/DndComponent/DndComponent.js +96 -0
- package/VerticalHeadingsTable/components/DndComponent/helpers.d.ts +3 -0
- package/VerticalHeadingsTable/components/DndComponent/helpers.js +35 -0
- package/VerticalHeadingsTable/components/DndComponent/index.d.ts +1 -0
- package/VerticalHeadingsTable/components/DndComponent/index.js +1 -0
- package/VerticalHeadingsTable/components/{TableColumnDragLayer → DndComponent}/styles.d.ts +1 -1
- package/VerticalHeadingsTable/components/DndComponent/styles.js +10 -0
- package/VerticalHeadingsTable/components/DndComponent/types.d.ts +14 -0
- package/VerticalHeadingsTable/components/DndMeasurer/DndMeasurer.d.ts +7 -0
- package/VerticalHeadingsTable/components/DndMeasurer/DndMeasurer.js +13 -0
- package/VerticalHeadingsTable/components/DndMeasurer/index.d.ts +1 -0
- package/VerticalHeadingsTable/components/DndMeasurer/index.js +1 -0
- package/VerticalHeadingsTable/components/TableCell/TableCell.d.ts +2 -2
- package/VerticalHeadingsTable/components/TableCell/TableCell.js +2 -2
- package/VerticalHeadingsTable/components/TableCell/TableCell.test.js +101 -43
- package/VerticalHeadingsTable/components/TableCellWithDnd/ColumnDragIndicator.d.ts +10 -0
- package/VerticalHeadingsTable/components/TableCellWithDnd/ColumnDragIndicator.js +32 -0
- package/VerticalHeadingsTable/components/TableCellWithDnd/TableCellWithDnd.d.ts +2 -4
- package/VerticalHeadingsTable/components/TableCellWithDnd/TableCellWithDnd.js +30 -59
- package/VerticalHeadingsTable/components/TableCellWithDnd/TableCellWithDnd.test.js +126 -56
- package/VerticalHeadingsTable/components/TableColumnDragPreview/TableColumnDragPreview.d.ts +3 -3
- package/VerticalHeadingsTable/components/TableColumnDragPreview/TableColumnDragPreview.js +16 -6
- package/VerticalHeadingsTable/components/TableHeadCell/RowDragIndicator.d.ts +9 -0
- package/VerticalHeadingsTable/components/TableHeadCell/RowDragIndicator.js +30 -0
- package/VerticalHeadingsTable/components/TableHeadCell/TableHeadCell.d.ts +4 -4
- package/VerticalHeadingsTable/components/TableHeadCell/TableHeadCell.js +3 -4
- package/VerticalHeadingsTable/components/TableHeadCell/TableHeadCell.test.js +44 -29
- package/VerticalHeadingsTable/components/TableRow/TableRow.d.ts +4 -5
- package/VerticalHeadingsTable/components/TableRow/TableRow.js +3 -3
- package/VerticalHeadingsTable/components/TableRow/TableRow.test.js +35 -57
- package/VerticalHeadingsTable/components/TableRowDragPreview/TableRowDragPreview.d.ts +12 -0
- package/VerticalHeadingsTable/components/TableRowDragPreview/TableRowDragPreview.js +16 -0
- package/VerticalHeadingsTable/components/TableRowDragPreview/index.d.ts +1 -0
- package/VerticalHeadingsTable/components/TableRowDragPreview/index.js +1 -0
- package/{cjs/VerticalHeadingsTable/components/TableColumnDragLayer → VerticalHeadingsTable/components/TableRowDragPreview}/styles.d.ts +1 -1
- package/VerticalHeadingsTable/components/TableRowDragPreview/styles.js +8 -0
- package/VerticalHeadingsTable/components/TableRowWithDnd/TableRowWithDnd.d.ts +2 -8
- package/VerticalHeadingsTable/components/TableRowWithDnd/TableRowWithDnd.js +22 -53
- package/VerticalHeadingsTable/components/TableRowWithDnd/TableRowWithDnd.test.js +53 -83
- package/cjs/BarChart/helpers.d.ts +2 -2
- package/cjs/BasicTable/IntegrationBasicTable.test.js +6 -18
- package/cjs/EditModeAttributesView/IntegrationEditModeAttributesView.test.js +2 -5
- package/cjs/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +2 -5
- package/cjs/InlineAttributesPager/components/InlineSimpleAttributesBlock/InlineSimpleAttributesBlock.js +55 -21
- package/cjs/InlineAttributesPager/components/InlineSimpleAttributesBlock/InlineSimpleAttributesBlock.test.js +120 -135
- package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.js +1 -1
- package/cjs/LineChart/helpers.d.ts +2 -2
- package/cjs/PieChart/PieChart.test.js +4 -0
- package/cjs/UploadImageDialog/UploadImageDialog.specs.js +1 -4
- package/cjs/UploadImageDialog/components/TargetBox/TargetBox.js +54 -20
- package/cjs/UploadImageDialog/components/TargetBox/TargetBox.specs.d.ts +1 -1
- package/cjs/UploadImageDialog/components/TargetBox/TargetBox.specs.js +57 -16
- package/cjs/UploadImageDialog/components/TargetBox/styles.js +2 -1
- package/cjs/VerticalHeadingsTable/DndVerticalHeadingsTable.test.d.ts +1 -0
- package/cjs/VerticalHeadingsTable/DndVerticalHeadingsTable.test.js +119 -0
- package/cjs/VerticalHeadingsTable/VerticalHeadingsTable.d.ts +2 -1
- package/cjs/VerticalHeadingsTable/VerticalHeadingsTable.js +9 -12
- package/cjs/VerticalHeadingsTable/VerticalHeadingsTable.test.js +74 -269
- package/cjs/VerticalHeadingsTable/components/DndComponent/DndComponent.d.ts +14 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/DndComponent.js +123 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/helpers.d.ts +3 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/helpers.js +40 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/index.d.ts +1 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/index.js +5 -0
- package/{features/crosswalks/CrosswalkDragLayer → cjs/VerticalHeadingsTable/components/DndComponent}/styles.d.ts +1 -1
- package/cjs/VerticalHeadingsTable/components/DndComponent/styles.js +13 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/types.d.ts +14 -0
- package/cjs/VerticalHeadingsTable/components/DndComponent/types.js +2 -0
- package/cjs/VerticalHeadingsTable/components/DndMeasurer/DndMeasurer.d.ts +7 -0
- package/cjs/VerticalHeadingsTable/components/DndMeasurer/DndMeasurer.js +40 -0
- package/cjs/VerticalHeadingsTable/components/DndMeasurer/index.d.ts +1 -0
- package/cjs/VerticalHeadingsTable/components/DndMeasurer/index.js +5 -0
- package/cjs/VerticalHeadingsTable/components/TableCell/TableCell.d.ts +2 -2
- package/cjs/VerticalHeadingsTable/components/TableCell/TableCell.js +2 -2
- package/cjs/VerticalHeadingsTable/components/TableCell/TableCell.test.js +101 -43
- package/cjs/VerticalHeadingsTable/components/TableCellWithDnd/ColumnDragIndicator.d.ts +10 -0
- package/cjs/VerticalHeadingsTable/components/TableCellWithDnd/ColumnDragIndicator.js +39 -0
- package/cjs/VerticalHeadingsTable/components/TableCellWithDnd/TableCellWithDnd.d.ts +2 -4
- package/cjs/VerticalHeadingsTable/components/TableCellWithDnd/TableCellWithDnd.js +29 -58
- package/cjs/VerticalHeadingsTable/components/TableCellWithDnd/TableCellWithDnd.test.js +128 -58
- package/cjs/VerticalHeadingsTable/components/TableColumnDragPreview/TableColumnDragPreview.d.ts +3 -3
- package/cjs/VerticalHeadingsTable/components/TableColumnDragPreview/TableColumnDragPreview.js +38 -9
- package/cjs/VerticalHeadingsTable/components/TableHeadCell/RowDragIndicator.d.ts +9 -0
- package/cjs/VerticalHeadingsTable/components/TableHeadCell/RowDragIndicator.js +37 -0
- package/cjs/VerticalHeadingsTable/components/TableHeadCell/TableHeadCell.d.ts +4 -4
- package/cjs/VerticalHeadingsTable/components/TableHeadCell/TableHeadCell.js +3 -4
- package/cjs/VerticalHeadingsTable/components/TableHeadCell/TableHeadCell.test.js +43 -51
- package/cjs/VerticalHeadingsTable/components/TableRow/TableRow.d.ts +4 -5
- package/cjs/VerticalHeadingsTable/components/TableRow/TableRow.js +3 -3
- package/cjs/VerticalHeadingsTable/components/TableRow/TableRow.test.js +35 -57
- package/cjs/VerticalHeadingsTable/components/TableRowDragPreview/TableRowDragPreview.d.ts +12 -0
- package/cjs/VerticalHeadingsTable/components/TableRowDragPreview/TableRowDragPreview.js +42 -0
- package/cjs/VerticalHeadingsTable/components/TableRowDragPreview/index.d.ts +1 -0
- package/cjs/VerticalHeadingsTable/components/TableRowDragPreview/index.js +5 -0
- package/cjs/{features/crosswalks/CrosswalkDragLayer → VerticalHeadingsTable/components/TableRowDragPreview}/styles.d.ts +1 -1
- package/cjs/VerticalHeadingsTable/components/TableRowDragPreview/styles.js +11 -0
- package/cjs/VerticalHeadingsTable/components/TableRowWithDnd/TableRowWithDnd.d.ts +2 -8
- package/cjs/VerticalHeadingsTable/components/TableRowWithDnd/TableRowWithDnd.js +21 -52
- package/cjs/VerticalHeadingsTable/components/TableRowWithDnd/TableRowWithDnd.test.js +55 -85
- package/cjs/contexts/CrosswalksDisplayContext/index.d.ts +2 -2
- package/cjs/contexts/CrosswalksDisplayContext/index.js +6 -2
- package/cjs/features/crosswalks/AttributesTable/AttributesTable.d.ts +3 -1
- package/cjs/features/crosswalks/AttributesTable/AttributesTable.js +2 -2
- package/cjs/features/crosswalks/AttributesTable/AttributesTable.test.js +17 -10
- package/cjs/features/crosswalks/AttributesTable/components/OvValuesRenderer/OvValuesRenderer.d.ts +3 -2
- package/cjs/features/crosswalks/AttributesTable/components/OvValuesRenderer/OvValuesRenderer.js +13 -2
- package/cjs/features/crosswalks/CrosswalkDndComponent/CrosswalkDndComponent.d.ts +8 -0
- package/cjs/features/crosswalks/CrosswalkDndComponent/CrosswalkDndComponent.js +51 -0
- package/cjs/features/crosswalks/CrosswalkDndComponent/index.d.ts +1 -0
- package/cjs/features/crosswalks/CrosswalkDndComponent/index.js +5 -0
- package/cjs/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/CrosswalkDragPreview.js +16 -5
- package/cjs/features/crosswalks/CrosswalkDragPreview/CrosswalkDragPreview.test.d.ts +1 -0
- package/cjs/features/crosswalks/CrosswalkDragPreview/CrosswalkDragPreview.test.js +97 -0
- package/{features/crosswalks/CrosswalkDragLayer/components → cjs/features/crosswalks}/CrosswalkDragPreview/styles.d.ts +1 -1
- package/cjs/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/styles.js +6 -1
- package/cjs/features/crosswalks/CrosswalkRow/CrosswalkRow.js +25 -16
- package/cjs/features/crosswalks/CrosswalkRow/CrosswalkRow.test.js +7 -33
- package/cjs/features/crosswalks/CrosswalkRow/DndCrosswalkRow.test.d.ts +1 -0
- package/cjs/features/crosswalks/CrosswalkRow/DndCrosswalkRow.test.js +134 -0
- package/cjs/features/crosswalks/CrosswalkRow/styles.d.ts +1 -1
- package/cjs/features/crosswalks/CrosswalkRow/styles.js +10 -1
- package/cjs/features/crosswalks/SourceCrosswalksRow/SourceCrosswalksRow.test.js +0 -1
- package/cjs/features/crosswalks/hooks/useDraggingCrosswalk.d.ts +6 -0
- package/cjs/features/crosswalks/hooks/useDraggingCrosswalk.js +19 -0
- package/cjs/features/crosswalks/hooks/useModifiedEntity.js +6 -6
- package/cjs/features/crosswalks/index.d.ts +1 -1
- package/cjs/features/crosswalks/index.js +3 -3
- package/cjs/hooks/useDndBasicTableScrollModifier/index.d.ts +1 -0
- package/cjs/hooks/useDndBasicTableScrollModifier/index.js +5 -0
- package/cjs/hooks/useDndBasicTableScrollModifier/useDndBasicTableScrollModifier.d.ts +10 -0
- package/cjs/hooks/useDndBasicTableScrollModifier/useDndBasicTableScrollModifier.js +57 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/test-utils/dndKit/DndContext.d.ts +12 -0
- package/cjs/test-utils/dndKit/DndContext.js +5 -0
- package/cjs/test-utils/dndKit/DndContextComponent.d.ts +5 -0
- package/cjs/test-utils/dndKit/DndContextComponent.js +97 -0
- package/cjs/test-utils/dndKit/DndMonitorContext.d.ts +2 -0
- package/cjs/test-utils/dndKit/DndMonitorContext.js +5 -0
- package/cjs/test-utils/dndKit/DragOverlay.d.ts +5 -0
- package/cjs/test-utils/dndKit/DragOverlay.js +14 -0
- package/cjs/test-utils/dndKit/index.d.ts +32 -0
- package/cjs/test-utils/dndKit/index.js +22 -0
- package/cjs/test-utils/dndKit/type.d.ts +17 -0
- package/cjs/test-utils/dndKit/type.js +2 -0
- package/cjs/test-utils/dndKit/useDndContext.d.ts +8 -0
- package/cjs/test-utils/dndKit/useDndContext.js +13 -0
- package/cjs/test-utils/dndKit/useDndMonitor.d.ts +2 -0
- package/cjs/test-utils/dndKit/useDndMonitor.js +13 -0
- package/cjs/test-utils/dndKit/useDndMonitorProvider.d.ts +1 -0
- package/cjs/test-utils/dndKit/useDndMonitorProvider.js +17 -0
- package/cjs/test-utils/dndKit/useDraggable.d.ts +12 -0
- package/cjs/test-utils/dndKit/useDraggable.js +43 -0
- package/cjs/test-utils/dndKit/useDroppable.d.ts +4 -0
- package/cjs/test-utils/dndKit/useDroppable.js +45 -0
- package/cjs/types/basicTable.d.ts +4 -0
- package/contexts/CrosswalksDisplayContext/index.d.ts +2 -2
- package/contexts/CrosswalksDisplayContext/index.js +6 -2
- package/features/crosswalks/AttributesTable/AttributesTable.d.ts +3 -1
- package/features/crosswalks/AttributesTable/AttributesTable.js +2 -2
- package/features/crosswalks/AttributesTable/AttributesTable.test.js +17 -10
- package/features/crosswalks/AttributesTable/components/OvValuesRenderer/OvValuesRenderer.d.ts +3 -2
- package/features/crosswalks/AttributesTable/components/OvValuesRenderer/OvValuesRenderer.js +13 -2
- package/features/crosswalks/CrosswalkDndComponent/CrosswalkDndComponent.d.ts +8 -0
- package/features/crosswalks/CrosswalkDndComponent/CrosswalkDndComponent.js +24 -0
- package/features/crosswalks/CrosswalkDndComponent/index.d.ts +1 -0
- package/features/crosswalks/CrosswalkDndComponent/index.js +1 -0
- package/features/crosswalks/CrosswalkDragPreview/CrosswalkDragPreview.js +30 -0
- package/features/crosswalks/CrosswalkDragPreview/CrosswalkDragPreview.test.d.ts +1 -0
- package/features/crosswalks/CrosswalkDragPreview/CrosswalkDragPreview.test.js +69 -0
- package/{cjs/features/crosswalks/CrosswalkDragLayer/components → features/crosswalks}/CrosswalkDragPreview/styles.d.ts +1 -1
- package/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/styles.js +6 -1
- package/features/crosswalks/CrosswalkRow/CrosswalkRow.js +25 -16
- package/features/crosswalks/CrosswalkRow/CrosswalkRow.test.js +7 -33
- package/features/crosswalks/CrosswalkRow/DndCrosswalkRow.test.d.ts +1 -0
- package/features/crosswalks/CrosswalkRow/DndCrosswalkRow.test.js +129 -0
- package/features/crosswalks/CrosswalkRow/styles.d.ts +1 -1
- package/features/crosswalks/CrosswalkRow/styles.js +10 -1
- package/features/crosswalks/SourceCrosswalksRow/SourceCrosswalksRow.test.js +0 -1
- package/features/crosswalks/hooks/useDraggingCrosswalk.d.ts +6 -0
- package/features/crosswalks/hooks/useDraggingCrosswalk.js +15 -0
- package/features/crosswalks/hooks/useModifiedEntity.js +6 -6
- package/features/crosswalks/index.d.ts +1 -1
- package/features/crosswalks/index.js +1 -1
- package/hooks/useDndBasicTableScrollModifier/index.d.ts +1 -0
- package/hooks/useDndBasicTableScrollModifier/index.js +1 -0
- package/hooks/useDndBasicTableScrollModifier/useDndBasicTableScrollModifier.d.ts +10 -0
- package/hooks/useDndBasicTableScrollModifier/useDndBasicTableScrollModifier.js +53 -0
- package/index.d.ts +2 -1
- package/index.js +1 -0
- package/package.json +3 -3
- package/test-utils/dndKit/DndContext.d.ts +12 -0
- package/test-utils/dndKit/DndContext.js +2 -0
- package/test-utils/dndKit/DndContextComponent.d.ts +5 -0
- package/test-utils/dndKit/DndContextComponent.js +70 -0
- package/test-utils/dndKit/DndMonitorContext.d.ts +2 -0
- package/test-utils/dndKit/DndMonitorContext.js +2 -0
- package/test-utils/dndKit/DragOverlay.d.ts +5 -0
- package/test-utils/dndKit/DragOverlay.js +7 -0
- package/test-utils/dndKit/index.d.ts +32 -0
- package/test-utils/dndKit/index.js +19 -0
- package/test-utils/dndKit/type.d.ts +17 -0
- package/test-utils/dndKit/type.js +1 -0
- package/test-utils/dndKit/useDndContext.d.ts +8 -0
- package/test-utils/dndKit/useDndContext.js +9 -0
- package/test-utils/dndKit/useDndMonitor.d.ts +2 -0
- package/test-utils/dndKit/useDndMonitor.js +9 -0
- package/test-utils/dndKit/useDndMonitorProvider.d.ts +1 -0
- package/test-utils/dndKit/useDndMonitorProvider.js +13 -0
- package/test-utils/dndKit/useDraggable.d.ts +12 -0
- package/test-utils/dndKit/useDraggable.js +39 -0
- package/test-utils/dndKit/useDroppable.d.ts +4 -0
- package/test-utils/dndKit/useDroppable.js +41 -0
- package/types/basicTable.d.ts +4 -0
- package/VerticalHeadingsTable/components/TableColumnDragLayer/TableColumnDragLayer.d.ts +0 -6
- package/VerticalHeadingsTable/components/TableColumnDragLayer/TableColumnDragLayer.js +0 -23
- package/VerticalHeadingsTable/components/TableColumnDragLayer/helpers.d.ts +0 -6
- package/VerticalHeadingsTable/components/TableColumnDragLayer/helpers.js +0 -11
- package/VerticalHeadingsTable/components/TableColumnDragLayer/index.d.ts +0 -1
- package/VerticalHeadingsTable/components/TableColumnDragLayer/index.js +0 -1
- package/VerticalHeadingsTable/components/TableColumnDragLayer/styles.js +0 -13
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/TableColumnDragLayer.d.ts +0 -6
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/TableColumnDragLayer.js +0 -50
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/helpers.d.ts +0 -6
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/helpers.js +0 -15
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/index.d.ts +0 -1
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/index.js +0 -5
- package/cjs/VerticalHeadingsTable/components/TableColumnDragLayer/styles.js +0 -16
- package/cjs/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.d.ts +0 -2
- package/cjs/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.js +0 -51
- package/cjs/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.test.js +0 -93
- package/cjs/features/crosswalks/CrosswalkDragLayer/index.d.ts +0 -1
- package/cjs/features/crosswalks/CrosswalkDragLayer/index.js +0 -5
- package/cjs/features/crosswalks/CrosswalkDragLayer/styles.js +0 -17
- package/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.d.ts +0 -2
- package/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.js +0 -25
- package/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.test.js +0 -65
- package/features/crosswalks/CrosswalkDragLayer/components/CrosswalkDragPreview/CrosswalkDragPreview.js +0 -19
- package/features/crosswalks/CrosswalkDragLayer/index.d.ts +0 -1
- package/features/crosswalks/CrosswalkDragLayer/index.js +0 -1
- package/features/crosswalks/CrosswalkDragLayer/styles.js +0 -14
- /package/{cjs/features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.test.d.ts → VerticalHeadingsTable/DndVerticalHeadingsTable.test.d.ts} +0 -0
- /package/{features/crosswalks/CrosswalkDragLayer/CrosswalkDragLayer.test.d.ts → VerticalHeadingsTable/components/DndComponent/types.js} +0 -0
- /package/cjs/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/CrosswalkDragPreview.d.ts +0 -0
- /package/cjs/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/index.d.ts +0 -0
- /package/cjs/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/index.js +0 -0
- /package/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/CrosswalkDragPreview.d.ts +0 -0
- /package/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/index.d.ts +0 -0
- /package/features/crosswalks/{CrosswalkDragLayer/components/CrosswalkDragPreview → CrosswalkDragPreview}/index.js +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { closestCenter, DndContext, DragOverlay, MouseSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
2
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { DndItemTypes } from '../../types';
|
|
5
|
+
import { DndMeasurer } from '../DndMeasurer';
|
|
6
|
+
import { TableColumnDragPreview } from '../TableColumnDragPreview';
|
|
7
|
+
import { TableRowDragPreview } from '../TableRowDragPreview';
|
|
8
|
+
import { columnMoveModifier, rowMoveModifier } from './helpers';
|
|
9
|
+
import { useStyles } from './styles';
|
|
10
|
+
export var DndComponent = function (_a) {
|
|
11
|
+
var _b, _c;
|
|
12
|
+
var children = _a.children, containerRef = _a.containerRef, onMoveColumn = _a.onMoveColumn, onDropColumn = _a.onDropColumn, onMoveRow = _a.onMoveRow, onDropRow = _a.onDropRow, columnsId = _a.columnsId, rowsId = _a.rowsId, tableClassName = _a.tableClassName;
|
|
13
|
+
var styles = useStyles();
|
|
14
|
+
var containerHeight = (_b = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight;
|
|
15
|
+
var containerWidth = (_c = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth;
|
|
16
|
+
var _d = useState(null), draggingType = _d[0], setDraggingType = _d[1];
|
|
17
|
+
var _e = useState(null), draggingColumn = _e[0], setDraggingColumn = _e[1];
|
|
18
|
+
var _f = useState(null), draggingRow = _f[0], setDraggingRow = _f[1];
|
|
19
|
+
var onDragStart = useCallback(function (event) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
var dndData = (_b = (_a = event.active) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.current;
|
|
22
|
+
if (dndData) {
|
|
23
|
+
setDraggingType(dndData === null || dndData === void 0 ? void 0 : dndData.type);
|
|
24
|
+
}
|
|
25
|
+
if ((dndData === null || dndData === void 0 ? void 0 : dndData.type) === DndItemTypes.Column) {
|
|
26
|
+
setDraggingColumn(dndData);
|
|
27
|
+
}
|
|
28
|
+
if ((dndData === null || dndData === void 0 ? void 0 : dndData.type) === DndItemTypes.Row) {
|
|
29
|
+
setDraggingRow(dndData);
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
var onDragEnd = useCallback(function (event) {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
var draggingType = (_c = (_b = (_a = event.active) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.type;
|
|
35
|
+
setDraggingType(null);
|
|
36
|
+
setDraggingColumn(null);
|
|
37
|
+
setDraggingRow(null);
|
|
38
|
+
if (draggingType === DndItemTypes.Column) {
|
|
39
|
+
onDropColumn();
|
|
40
|
+
}
|
|
41
|
+
if (draggingType === DndItemTypes.Row) {
|
|
42
|
+
onDropRow();
|
|
43
|
+
}
|
|
44
|
+
}, [onDropColumn, onDropRow]);
|
|
45
|
+
var modifiers = useMemo(function () {
|
|
46
|
+
switch (draggingType) {
|
|
47
|
+
case DndItemTypes.Column:
|
|
48
|
+
return [columnMoveModifier];
|
|
49
|
+
case DndItemTypes.Row:
|
|
50
|
+
return [rowMoveModifier];
|
|
51
|
+
default:
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}, [draggingType]);
|
|
55
|
+
var onDragOver = useCallback(function (_a) {
|
|
56
|
+
var _b, _c;
|
|
57
|
+
var active = _a.active, over = _a.over;
|
|
58
|
+
if (active.id === (over === null || over === void 0 ? void 0 : over.id))
|
|
59
|
+
return;
|
|
60
|
+
switch ((_c = (_b = active === null || active === void 0 ? void 0 : active.data) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.type) {
|
|
61
|
+
case DndItemTypes.Column:
|
|
62
|
+
return onMoveColumn(active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
63
|
+
case DndItemTypes.Row:
|
|
64
|
+
return onMoveRow(active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
65
|
+
}
|
|
66
|
+
}, [onMoveColumn, onMoveRow]);
|
|
67
|
+
var dragOverlayStyle = useMemo(function () {
|
|
68
|
+
var _a;
|
|
69
|
+
var containerRect = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
70
|
+
switch (draggingType) {
|
|
71
|
+
case DndItemTypes.Column:
|
|
72
|
+
return {
|
|
73
|
+
top: containerRect.top,
|
|
74
|
+
width: 'auto',
|
|
75
|
+
height: 'auto'
|
|
76
|
+
};
|
|
77
|
+
case DndItemTypes.Row:
|
|
78
|
+
return {
|
|
79
|
+
left: containerRect.left,
|
|
80
|
+
width: 'auto',
|
|
81
|
+
height: 'auto'
|
|
82
|
+
};
|
|
83
|
+
default:
|
|
84
|
+
return {};
|
|
85
|
+
}
|
|
86
|
+
}, [containerRef, draggingType]);
|
|
87
|
+
var mouseSensor = useSensor(MouseSensor);
|
|
88
|
+
var sensors = useSensors(mouseSensor);
|
|
89
|
+
return (React.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: onDragStart, onDragEnd: onDragEnd, onDragOver: onDragOver },
|
|
90
|
+
children,
|
|
91
|
+
draggingType && createPortal(React.createElement("div", { className: styles.backDrop }), document.body),
|
|
92
|
+
React.createElement(DndMeasurer, { columnsId: columnsId, rowsId: rowsId }),
|
|
93
|
+
createPortal(React.createElement(DragOverlay, { dropAnimation: null, style: dragOverlayStyle, modifiers: modifiers },
|
|
94
|
+
React.createElement(TableColumnDragPreview, { columnHeight: containerHeight, draggingColumn: draggingColumn }),
|
|
95
|
+
React.createElement(TableRowDragPreview, { tableWidth: containerWidth, draggingRow: draggingRow, tableClassName: tableClassName })), document.body)));
|
|
96
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { getEventCoordinates } from '@dnd-kit/utilities';
|
|
13
|
+
export var columnMoveModifier = function (_a) {
|
|
14
|
+
var activatorEvent = _a.activatorEvent, draggingNodeRect = _a.draggingNodeRect, transform = _a.transform;
|
|
15
|
+
if (draggingNodeRect && activatorEvent) {
|
|
16
|
+
var activatorCoordinates = getEventCoordinates(activatorEvent);
|
|
17
|
+
if (!activatorCoordinates) {
|
|
18
|
+
return transform;
|
|
19
|
+
}
|
|
20
|
+
var offsetX = activatorCoordinates.x - draggingNodeRect.left;
|
|
21
|
+
return __assign(__assign({}, transform), { x: transform.x + offsetX - draggingNodeRect.width / 2, y: 0 });
|
|
22
|
+
}
|
|
23
|
+
return transform;
|
|
24
|
+
};
|
|
25
|
+
export var rowMoveModifier = function (_a) {
|
|
26
|
+
var activatorEvent = _a.activatorEvent, draggingNodeRect = _a.draggingNodeRect, transform = _a.transform;
|
|
27
|
+
if (draggingNodeRect && activatorEvent) {
|
|
28
|
+
var activatorCoordinates = getEventCoordinates(activatorEvent);
|
|
29
|
+
if (!activatorCoordinates) {
|
|
30
|
+
return transform;
|
|
31
|
+
}
|
|
32
|
+
return __assign(__assign({}, transform), { x: 0, y: transform.y });
|
|
33
|
+
}
|
|
34
|
+
return transform;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DndComponent } from './DndComponent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DndComponent } from './DndComponent';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"backDrop">;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnData, DndItemTypes, RowData } from '../../types';
|
|
2
|
+
export type ColumnDndData = {
|
|
3
|
+
type: DndItemTypes.Column;
|
|
4
|
+
getColumnWidth: () => number;
|
|
5
|
+
columnValue: ColumnData;
|
|
6
|
+
rowData: RowData;
|
|
7
|
+
index: number;
|
|
8
|
+
};
|
|
9
|
+
export type RowDndData = {
|
|
10
|
+
type: DndItemTypes.Row;
|
|
11
|
+
rowData: RowData;
|
|
12
|
+
columnsData: ColumnData[];
|
|
13
|
+
};
|
|
14
|
+
export type DndData = ColumnDndData | RowDndData | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useDndContext } from '@dnd-kit/core';
|
|
3
|
+
export var DndMeasurer = function (_a) {
|
|
4
|
+
var columnsId = _a.columnsId, rowsId = _a.rowsId;
|
|
5
|
+
var measureDroppableContainers = useDndContext().measureDroppableContainers;
|
|
6
|
+
useEffect(function () {
|
|
7
|
+
measureDroppableContainers(columnsId);
|
|
8
|
+
}, [columnsId]);
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
measureDroppableContainers(rowsId);
|
|
11
|
+
}, [rowsId]);
|
|
12
|
+
return React.createElement(React.Fragment, null);
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DndMeasurer } from './DndMeasurer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DndMeasurer } from './DndMeasurer';
|
|
@@ -5,7 +5,7 @@ type Props = {
|
|
|
5
5
|
rowData: RowData;
|
|
6
6
|
setHoveredColumn: (columnValue: ColumnData) => void;
|
|
7
7
|
resetHoveredColumn: () => void;
|
|
8
|
-
|
|
8
|
+
rowIsDragging?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export declare const TableCell: ({ columnValue, rowData, setHoveredColumn, resetHoveredColumn,
|
|
10
|
+
export declare const TableCell: ({ columnValue, rowData, setHoveredColumn, resetHoveredColumn, rowIsDragging }: Props) => React.JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -4,11 +4,11 @@ import { DefaultCellRenderer } from '../../helpers';
|
|
|
4
4
|
import { useStyles } from './styles';
|
|
5
5
|
export var TableCell = function (_a) {
|
|
6
6
|
var _b;
|
|
7
|
-
var columnValue = _a.columnValue, rowData = _a.rowData, setHoveredColumn = _a.setHoveredColumn, resetHoveredColumn = _a.resetHoveredColumn,
|
|
7
|
+
var columnValue = _a.columnValue, rowData = _a.rowData, setHoveredColumn = _a.setHoveredColumn, resetHoveredColumn = _a.resetHoveredColumn, rowIsDragging = _a.rowIsDragging;
|
|
8
8
|
var styles = useStyles();
|
|
9
9
|
var CellRenderer = rowData.cellRenderer || DefaultCellRenderer;
|
|
10
10
|
var onMouseOver = setHoveredColumn ? function () { return setHoveredColumn(columnValue); } : undefined;
|
|
11
11
|
return (React.createElement("td", { onMouseOver: onMouseOver, onMouseLeave: resetHoveredColumn },
|
|
12
|
-
React.createElement("div", { className: classnames((_b = {}, _b[styles.hidden] =
|
|
12
|
+
React.createElement("div", { className: classnames((_b = {}, _b[styles.hidden] = rowIsDragging, _b)) },
|
|
13
13
|
React.createElement(CellRenderer, { value: columnValue[rowData.id] }))));
|
|
14
14
|
};
|
|
@@ -1,58 +1,116 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
1
48
|
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { act } from 'react-dom/test-utils';
|
|
4
49
|
import { TableCell } from './TableCell';
|
|
5
|
-
import {
|
|
50
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
6
51
|
var columnValue = {
|
|
7
|
-
'attributes.FirstName':
|
|
52
|
+
'attributes.FirstName': 'Some value',
|
|
8
53
|
id: 'entities/123'
|
|
9
54
|
};
|
|
10
|
-
var
|
|
11
|
-
|
|
55
|
+
var rowData = {
|
|
56
|
+
id: 'attributes.FirstName',
|
|
57
|
+
label: 'FirstName'
|
|
58
|
+
};
|
|
59
|
+
var defaultProps = {
|
|
60
|
+
columnValue: columnValue,
|
|
61
|
+
rowData: rowData,
|
|
62
|
+
setHoveredColumn: jest.fn(),
|
|
63
|
+
resetHoveredColumn: jest.fn()
|
|
64
|
+
};
|
|
65
|
+
var setUp = function (props) {
|
|
66
|
+
if (props === void 0) { props = defaultProps; }
|
|
67
|
+
var Wrapper = function (_a) {
|
|
68
|
+
var children = _a.children;
|
|
69
|
+
return (React.createElement("table", null,
|
|
70
|
+
React.createElement("tbody", null,
|
|
71
|
+
React.createElement("tr", null, children))));
|
|
72
|
+
};
|
|
73
|
+
return render(React.createElement(TableCell, __assign({}, props)), { wrapper: Wrapper });
|
|
74
|
+
};
|
|
12
75
|
describe('TableCell tests', function () {
|
|
13
76
|
it('should render cellRenderer from rowData correctly', function () {
|
|
14
|
-
var CellRenderer = function () {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
label: 'FirstName',
|
|
18
|
-
cellRenderer: CellRenderer
|
|
77
|
+
var CellRenderer = function (_a) {
|
|
78
|
+
var value = _a.value;
|
|
79
|
+
return React.createElement("div", { className: "cellRenderer" }, value);
|
|
19
80
|
};
|
|
20
|
-
|
|
21
|
-
expect(
|
|
81
|
+
setUp(__assign(__assign({}, defaultProps), { rowData: __assign(__assign({}, rowData), { cellRenderer: CellRenderer }) }));
|
|
82
|
+
expect(screen.getByText(columnValue['attributes.FirstName'])).toHaveClass('cellRenderer');
|
|
22
83
|
});
|
|
23
84
|
it('should render DefaultHeadCellRenderer if headCellRenderer is missing in rowData', function () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
label: 'FirstName'
|
|
27
|
-
};
|
|
28
|
-
var component = shallow(React.createElement(TableCell, { rowData: rowData, columnValue: columnValue, setHoveredColumn: setHoveredColumn, resetHoveredColumn: resetHoveredColumn }));
|
|
29
|
-
expect(component.find(DefaultCellRenderer).prop('value')).toEqual(columnValue[rowData.id]);
|
|
85
|
+
setUp();
|
|
86
|
+
expect(screen.getByText(columnValue['attributes.FirstName'])).toBeInTheDocument();
|
|
30
87
|
});
|
|
31
|
-
it('setHoveredColumn handler should work correctly', function () {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
88
|
+
it('setHoveredColumn handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
+
var setHoveredColumn;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
setHoveredColumn = jest.fn();
|
|
92
|
+
setUp(__assign(__assign({}, defaultProps), { setHoveredColumn: setHoveredColumn }));
|
|
93
|
+
fireEvent.mouseOver(screen.getByRole('cell', { name: columnValue['attributes.FirstName'] }));
|
|
94
|
+
expect(setHoveredColumn).toHaveBeenCalledWith(columnValue);
|
|
95
|
+
return [2 /*return*/];
|
|
39
96
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
97
|
+
}); });
|
|
98
|
+
it('resetHoveredColumn handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var resetHoveredColumn;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
resetHoveredColumn = jest.fn();
|
|
102
|
+
setUp(__assign(__assign({}, defaultProps), { resetHoveredColumn: resetHoveredColumn }));
|
|
103
|
+
fireEvent.mouseLeave(screen.getByRole('cell', { name: columnValue['attributes.FirstName'] }));
|
|
104
|
+
expect(resetHoveredColumn).toHaveBeenCalled();
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
}); });
|
|
108
|
+
it('should pass ".hidden" classname to div wrapper correctly if "rowIsDragging" prop is true', function () {
|
|
109
|
+
setUp(__assign(__assign({}, defaultProps), { rowIsDragging: true }));
|
|
110
|
+
expect(screen.getByText(columnValue['attributes.FirstName'])).toHaveClass('hidden');
|
|
49
111
|
});
|
|
50
|
-
it('should not pass ".hidden" classname to div wrapper if "
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
label: 'FirstName'
|
|
54
|
-
};
|
|
55
|
-
var component = shallow(React.createElement(TableCell, { rowData: rowData, columnValue: columnValue, setHoveredColumn: setHoveredColumn, resetHoveredColumn: resetHoveredColumn, someRowIsDragging: false }));
|
|
56
|
-
expect(component.find('.hidden')).toHaveLength(0);
|
|
112
|
+
it('should not pass ".hidden" classname to div wrapper if "rowIsDragging" prop is false', function () {
|
|
113
|
+
setUp();
|
|
114
|
+
expect(screen.getByText(columnValue['attributes.FirstName'])).not.toHaveClass('hidden');
|
|
57
115
|
});
|
|
58
116
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ColumnData, RowData } from '../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
columnValue: ColumnData;
|
|
5
|
+
rowData: RowData;
|
|
6
|
+
index: number;
|
|
7
|
+
getColumnWidth: () => number;
|
|
8
|
+
};
|
|
9
|
+
export declare const ColumnDragIndicator: ({ columnValue, rowData, index, getColumnWidth }: Props) => React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
14
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
15
|
+
import { DndItemTypes } from '../../types';
|
|
16
|
+
import { useStyles } from './styles';
|
|
17
|
+
export var ColumnDragIndicator = function (_a) {
|
|
18
|
+
var columnValue = _a.columnValue, rowData = _a.rowData, index = _a.index, getColumnWidth = _a.getColumnWidth;
|
|
19
|
+
var styles = useStyles();
|
|
20
|
+
var _b = useDraggable({
|
|
21
|
+
id: columnValue.id,
|
|
22
|
+
data: {
|
|
23
|
+
type: DndItemTypes.Column,
|
|
24
|
+
getColumnWidth: getColumnWidth,
|
|
25
|
+
columnValue: columnValue,
|
|
26
|
+
rowData: rowData,
|
|
27
|
+
index: index
|
|
28
|
+
}
|
|
29
|
+
}), setDraggableNodeRef = _b.setNodeRef, attributes = _b.attributes, listeners = _b.listeners;
|
|
30
|
+
return (React.createElement("div", __assign({ ref: setDraggableNodeRef, className: styles.dragIndicator }, attributes, listeners),
|
|
31
|
+
React.createElement(DragIndicatorIcon, { className: styles.dragIndicatorIcon })));
|
|
32
|
+
};
|
|
@@ -4,12 +4,10 @@ type Props = {
|
|
|
4
4
|
columnValue: ColumnData;
|
|
5
5
|
rowData: RowData;
|
|
6
6
|
index: number;
|
|
7
|
-
onMoveColumn: (dragId: string, hoverId: string) => void;
|
|
8
|
-
onDropColumn?: () => void;
|
|
9
7
|
shouldRenderDragIndicator: boolean;
|
|
10
8
|
setHoveredColumn: (columnValue: ColumnData) => void;
|
|
11
9
|
resetHoveredColumn: () => void;
|
|
12
|
-
|
|
10
|
+
rowIsDragging?: boolean;
|
|
13
11
|
};
|
|
14
|
-
export declare const TableCellWithDnd: ({ columnValue, rowData, index,
|
|
12
|
+
export declare const TableCellWithDnd: ({ columnValue, rowData, index, shouldRenderDragIndicator, setHoveredColumn, resetHoveredColumn, rowIsDragging }: Props) => React.JSX.Element;
|
|
15
13
|
export {};
|
|
@@ -1,71 +1,42 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
4
|
-
import { useDrag, useDrop } from 'react-dnd';
|
|
5
|
-
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
6
3
|
import { DndItemTypes } from '../../types';
|
|
7
4
|
import { DefaultCellRenderer } from '../../helpers';
|
|
8
5
|
import { useStyles } from './styles';
|
|
6
|
+
import { useDndMonitor, useDroppable } from '@dnd-kit/core';
|
|
7
|
+
import { ColumnDragIndicator } from './ColumnDragIndicator';
|
|
9
8
|
export var TableCellWithDnd = function (_a) {
|
|
10
9
|
var _b;
|
|
11
|
-
var columnValue = _a.columnValue, rowData = _a.rowData, index = _a.index,
|
|
10
|
+
var columnValue = _a.columnValue, rowData = _a.rowData, index = _a.index, shouldRenderDragIndicator = _a.shouldRenderDragIndicator, setHoveredColumn = _a.setHoveredColumn, resetHoveredColumn = _a.resetHoveredColumn, rowIsDragging = _a.rowIsDragging;
|
|
12
11
|
var styles = useStyles();
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _a;
|
|
21
|
-
if (!dropRef.current) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
var dragIndex = item.index;
|
|
25
|
-
var hoverIndex = index;
|
|
26
|
-
if (dragIndex === hoverIndex) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
var hoverBoundingRect = (_a = dropRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
30
|
-
var hoverMiddleX = (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
|
|
31
|
-
var clientOffset = monitor.getClientOffset();
|
|
32
|
-
var hoverClientX = clientOffset.x - hoverBoundingRect.left;
|
|
33
|
-
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {
|
|
37
|
-
return;
|
|
12
|
+
var _c = useState(false), enableDropForColumn = _c[0], setEnableDropForColumn = _c[1];
|
|
13
|
+
var _d = useState(false), isColumnDragging = _d[0], setIsColumnDragging = _d[1];
|
|
14
|
+
useDndMonitor({
|
|
15
|
+
onDragStart: function (event) {
|
|
16
|
+
if (event.active.data.current.type === DndItemTypes.Column) {
|
|
17
|
+
setEnableDropForColumn(true);
|
|
18
|
+
setIsColumnDragging(event.active.id === columnValue.id);
|
|
38
19
|
}
|
|
39
|
-
onMoveColumn(item.columnValue.id, columnValue.id);
|
|
40
|
-
item.index = hoverIndex;
|
|
41
20
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
sourceId: monitor.getHandlerId()
|
|
58
|
-
}); }
|
|
59
|
-
}), _e = _d[0], opacity = _e.opacity, sourceId = _e.sourceId, drag = _d[1], preview = _d[2];
|
|
60
|
-
useEffect(function () {
|
|
61
|
-
preview(getEmptyImage(), { captureDraggingState: true });
|
|
62
|
-
drop(dropRef);
|
|
63
|
-
drag(dragRef);
|
|
64
|
-
}, []);
|
|
21
|
+
onDragEnd: function () {
|
|
22
|
+
setEnableDropForColumn(false);
|
|
23
|
+
setIsColumnDragging(false);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var setDroppableNodeRef = useDroppable({
|
|
27
|
+
id: columnValue.id
|
|
28
|
+
}).setNodeRef;
|
|
29
|
+
var columnRef = useRef(null);
|
|
30
|
+
var setColumnRef = useCallback(function (elem) {
|
|
31
|
+
setDroppableNodeRef(elem);
|
|
32
|
+
columnRef.current = elem;
|
|
33
|
+
}, [setDroppableNodeRef]);
|
|
34
|
+
var getColumnWidth = function () { var _a; return (_a = columnRef === null || columnRef === void 0 ? void 0 : columnRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth; };
|
|
35
|
+
var CellRenderer = rowData.cellRenderer || DefaultCellRenderer;
|
|
65
36
|
var onMouseOver = setHoveredColumn ? function () { return setHoveredColumn(columnValue); } : undefined;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
37
|
+
var draggingColumnStyle = useMemo(function () { return ({ opacity: isColumnDragging ? 0 : 1 }); }, [isColumnDragging]);
|
|
38
|
+
return (React.createElement("td", { style: draggingColumnStyle, ref: enableDropForColumn ? setColumnRef : undefined, className: styles.tableData, onMouseOver: onMouseOver, onMouseLeave: resetHoveredColumn },
|
|
39
|
+
React.createElement("div", { className: classnames((_b = {}, _b[styles.hidden] = rowIsDragging, _b)) },
|
|
40
|
+
shouldRenderDragIndicator && (React.createElement(ColumnDragIndicator, { columnValue: columnValue, rowData: rowData, index: index, getColumnWidth: getColumnWidth })),
|
|
70
41
|
React.createElement(CellRenderer, { value: columnValue[rowData.id] }))));
|
|
71
42
|
};
|