@navikt/ds-react 8.10.5 → 8.10.6
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/cjs/data/data-grid/index.d.ts +2 -0
- package/cjs/data/data-grid/index.js +7 -0
- package/cjs/data/data-grid/index.js.map +1 -0
- package/cjs/data/data-grid/root/DataGridRoot.context.d.ts +11 -0
- package/cjs/data/data-grid/root/DataGridRoot.context.js +11 -0
- package/cjs/data/data-grid/root/DataGridRoot.context.js.map +1 -0
- package/cjs/data/data-grid/root/DataGridRoot.d.ts +38 -0
- package/cjs/data/data-grid/root/DataGridRoot.js +68 -0
- package/cjs/data/data-grid/root/DataGridRoot.js.map +1 -0
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +0 -1
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.d.ts +5 -5
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +4 -27
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/cjs/data/stories/Data.test-data.d.ts +2 -5
- package/cjs/data/stories/Data.test-data.js +30 -38
- package/cjs/data/stories/Data.test-data.js.map +1 -1
- package/cjs/data/table/base-cell/DataTableBaseCell.d.ts +15 -15
- package/cjs/data/table/base-cell/DataTableBaseCell.js +4 -8
- package/cjs/data/table/base-cell/DataTableBaseCell.js.map +1 -1
- package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +24 -6
- package/cjs/data/table/column-header/DataTableColumnHeader.js +22 -27
- package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/cjs/data/table/column-header/useTableColumnResize.d.ts +19 -29
- package/cjs/data/table/column-header/useTableColumnResize.js +24 -22
- package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +1 -1
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js +2 -2
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -1
- package/cjs/data/table/helpers/collectTableRowEntries.d.ts +2 -2
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.d.ts +13 -11
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +43 -53
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/getSingleSelectProps.d.ts +9 -8
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js +23 -10
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/selection.types.d.ts +19 -19
- package/cjs/data/table/helpers/selection/selection.utils.d.ts +21 -0
- package/cjs/data/table/helpers/selection/selection.utils.js +46 -0
- package/cjs/data/table/helpers/selection/selection.utils.js.map +1 -0
- package/cjs/data/table/hooks/useColumnOptions.d.ts +16 -5
- package/cjs/data/table/hooks/useColumnOptions.js +26 -8
- package/cjs/data/table/hooks/useColumnOptions.js.map +1 -1
- package/cjs/data/table/hooks/useTableDetailsPanel.d.ts +10 -13
- package/cjs/data/table/hooks/useTableDetailsPanel.js +6 -5
- package/cjs/data/table/hooks/useTableDetailsPanel.js.map +1 -1
- package/cjs/data/table/hooks/useTableItems.d.ts +29 -15
- package/cjs/data/table/hooks/useTableItems.js +2 -12
- package/cjs/data/table/hooks/useTableItems.js.map +1 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.d.ts +1 -6
- package/cjs/data/table/hooks/useTableKeyboardNav.js +1 -4
- package/cjs/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/hooks/useTableSelection.d.ts +6 -6
- package/cjs/data/table/hooks/useTableSelection.js +13 -13
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
- package/cjs/data/table/hooks/useTableSort.d.ts +2 -2
- package/cjs/data/table/hooks/useTableSort.js +4 -5
- package/cjs/data/table/hooks/useTableSort.js.map +1 -1
- package/cjs/data/table/root/DataTable.types.d.ts +22 -10
- package/cjs/data/table/root/DataTableRoot.context.d.ts +13 -7
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +49 -72
- package/cjs/data/table/root/DataTableRoot.js +54 -66
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.legacy.d.ts +2 -7
- package/cjs/data/table/root/DataTableRoot.legacy.js +17 -3
- package/cjs/data/table/root/DataTableRoot.legacy.js.map +1 -1
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js +4 -4
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -1
- package/cjs/data/table/tbody/DataTableTbody.js +4 -2
- package/cjs/data/table/tbody/DataTableTbody.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.d.ts +5 -3
- package/cjs/data/table/tr/DataTableTr.js +36 -23
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/table/ColumnHeader.js +2 -1
- package/cjs/table/ColumnHeader.js.map +1 -1
- package/esm/data/data-grid/index.d.ts +2 -0
- package/esm/data/data-grid/index.js +3 -0
- package/esm/data/data-grid/index.js.map +1 -0
- package/esm/data/data-grid/root/DataGridRoot.context.d.ts +11 -0
- package/esm/data/data-grid/root/DataGridRoot.context.js +7 -0
- package/esm/data/data-grid/root/DataGridRoot.context.js.map +1 -0
- package/esm/data/data-grid/root/DataGridRoot.d.ts +38 -0
- package/esm/data/data-grid/root/DataGridRoot.js +32 -0
- package/esm/data/data-grid/root/DataGridRoot.js.map +1 -0
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +0 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDropRoot.d.ts +5 -5
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js +4 -27
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/esm/data/stories/Data.test-data.d.ts +2 -5
- package/esm/data/stories/Data.test-data.js +30 -38
- package/esm/data/stories/Data.test-data.js.map +1 -1
- package/esm/data/table/base-cell/DataTableBaseCell.d.ts +15 -15
- package/esm/data/table/base-cell/DataTableBaseCell.js +4 -8
- package/esm/data/table/base-cell/DataTableBaseCell.js.map +1 -1
- package/esm/data/table/column-header/DataTableColumnHeader.d.ts +24 -6
- package/esm/data/table/column-header/DataTableColumnHeader.js +23 -28
- package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/esm/data/table/column-header/useTableColumnResize.d.ts +19 -29
- package/esm/data/table/column-header/useTableColumnResize.js +24 -22
- package/esm/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +1 -1
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js +2 -2
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -1
- package/esm/data/table/helpers/collectTableRowEntries.d.ts +2 -2
- package/esm/data/table/helpers/selection/getMultipleSelectProps.d.ts +13 -11
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js +43 -53
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/getSingleSelectProps.d.ts +9 -8
- package/esm/data/table/helpers/selection/getSingleSelectProps.js +23 -10
- package/esm/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/selection.types.d.ts +19 -19
- package/esm/data/table/helpers/selection/selection.utils.d.ts +21 -0
- package/esm/data/table/helpers/selection/selection.utils.js +43 -0
- package/esm/data/table/helpers/selection/selection.utils.js.map +1 -0
- package/esm/data/table/hooks/useColumnOptions.d.ts +16 -5
- package/esm/data/table/hooks/useColumnOptions.js +26 -8
- package/esm/data/table/hooks/useColumnOptions.js.map +1 -1
- package/esm/data/table/hooks/useTableDetailsPanel.d.ts +10 -13
- package/esm/data/table/hooks/useTableDetailsPanel.js +6 -5
- package/esm/data/table/hooks/useTableDetailsPanel.js.map +1 -1
- package/esm/data/table/hooks/useTableItems.d.ts +29 -15
- package/esm/data/table/hooks/useTableItems.js +3 -10
- package/esm/data/table/hooks/useTableItems.js.map +1 -1
- package/esm/data/table/hooks/useTableKeyboardNav.d.ts +1 -6
- package/esm/data/table/hooks/useTableKeyboardNav.js +1 -4
- package/esm/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/hooks/useTableSelection.d.ts +6 -6
- package/esm/data/table/hooks/useTableSelection.js +13 -13
- package/esm/data/table/hooks/useTableSelection.js.map +1 -1
- package/esm/data/table/hooks/useTableSort.d.ts +2 -2
- package/esm/data/table/hooks/useTableSort.js +4 -5
- package/esm/data/table/hooks/useTableSort.js.map +1 -1
- package/esm/data/table/root/DataTable.types.d.ts +22 -10
- package/esm/data/table/root/DataTableRoot.context.d.ts +13 -7
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +49 -72
- package/esm/data/table/root/DataTableRoot.js +56 -68
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.legacy.d.ts +2 -7
- package/esm/data/table/root/DataTableRoot.legacy.js +17 -3
- package/esm/data/table/root/DataTableRoot.legacy.js.map +1 -1
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js +4 -4
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -1
- package/esm/data/table/tbody/DataTableTbody.js +4 -2
- package/esm/data/table/tbody/DataTableTbody.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.d.ts +5 -3
- package/esm/data/table/tr/DataTableTr.js +35 -23
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/table/ColumnHeader.js +2 -1
- package/esm/table/ColumnHeader.js.map +1 -1
- package/package.json +3 -3
- package/src/data/data-grid/index.ts +3 -0
- package/src/data/data-grid/root/DataGridRoot.context.ts +16 -0
- package/src/data/data-grid/root/DataGridRoot.tsx +71 -0
- package/src/data/drag-and-drop/drag-handler/DragAndDropDragHandler.tsx +0 -1
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +15 -49
- package/src/data/stories/Data.test-data.tsx +52 -43
- package/src/data/table/agent-component-review.md +175 -0
- package/src/data/table/base-cell/DataTableBaseCell.tsx +31 -21
- package/src/data/table/column-header/DataTableColumnHeader.tsx +61 -58
- package/src/data/table/column-header/useTableColumnResize.ts +55 -71
- package/src/data/table/details-panel-row/DataTableDetailsPanelRow.tsx +3 -3
- package/src/data/table/helpers/collectTableRowEntries.ts +1 -2
- package/src/data/table/helpers/selection/getMultipleSelectProps.ts +65 -85
- package/src/data/table/helpers/selection/getSingleSelectProps.ts +35 -17
- package/src/data/table/helpers/selection/selection.types.ts +19 -19
- package/src/data/table/helpers/selection/selection.utils.test.ts +161 -0
- package/src/data/table/helpers/selection/selection.utils.ts +73 -0
- package/src/data/table/hooks/__tests__/useTableItems.test.ts +2 -1
- package/src/data/table/hooks/useColumnOptions.ts +48 -14
- package/src/data/table/hooks/useTableDetailsPanel.tsx +22 -25
- package/src/data/table/hooks/useTableItems.ts +32 -24
- package/src/data/table/hooks/useTableKeyboardNav.ts +1 -13
- package/src/data/table/hooks/useTableSelection.ts +26 -31
- package/src/data/table/hooks/useTableSort.ts +10 -9
- package/src/data/table/root/DataTable.types.ts +30 -22
- package/src/data/table/root/DataTableRoot.context.ts +19 -7
- package/src/data/table/root/DataTableRoot.legacy.tsx +22 -14
- package/src/data/table/root/DataTableRoot.tsx +244 -293
- package/src/data/table/sub-row-toggle/DataTableSubRowToggle.tsx +5 -4
- package/src/data/table/tbody/DataTableTbody.tsx +6 -2
- package/src/data/table/tr/DataTableTr.tsx +98 -35
- package/src/table/ColumnHeader.tsx +2 -1
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.d.ts +0 -22
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js +0 -35
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js.map +0 -1
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.d.ts +0 -27
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js +0 -86
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js.map +0 -1
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.d.ts +0 -5
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js +0 -6
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js.map +0 -1
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.d.ts +0 -24
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js +0 -108
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js.map +0 -1
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +0 -46
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js +0 -112
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.d.ts +0 -22
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js +0 -29
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.d.ts +0 -27
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js +0 -50
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.d.ts +0 -5
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js +0 -3
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.d.ts +0 -24
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js +0 -68
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js.map +0 -1
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +0 -46
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js +0 -109
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js.map +0 -1
- package/src/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.tsx +0 -104
- package/src/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.tsx +0 -74
- package/src/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.tsx +0 -11
- package/src/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.tsx +0 -94
- package/src/data/table/helpers/selection/SelectionSubtreeHelper.test.ts +0 -66
- package/src/data/table/helpers/selection/SelectionSubtreeHelper.ts +0 -162
- package/src/data/table/hooks/__tests__/useTableSelection.test.ts +0 -488
- package/src/data/table/root/agent-feature-gap.md +0 -96
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ChevronDownIcon, ChevronRightIcon } from "@navikt/aksel-icons";
|
|
3
3
|
import { Button } from "../../../button";
|
|
4
|
-
import { type ItemDetail
|
|
4
|
+
import { type ItemDetail } from "../hooks/useTableItems";
|
|
5
|
+
import { useDataTableContext } from "../root/DataTableRoot.context";
|
|
5
6
|
|
|
6
7
|
function DataTableSubRowToggle({ details }: { details: ItemDetail<any> }) {
|
|
7
|
-
const {
|
|
8
|
+
const { tableItems } = useDataTableContext();
|
|
8
9
|
|
|
9
10
|
const subRows = details.children;
|
|
10
11
|
const hasSubRows = subRows && subRows.length > 0;
|
|
11
|
-
const isRowExpanded = isSubRowExpanded(details.id);
|
|
12
|
+
const isRowExpanded = tableItems.isSubRowExpanded(details.id);
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
15
|
<div className="aksel-data-table__nested-toggle">
|
|
@@ -19,7 +20,7 @@ function DataTableSubRowToggle({ details }: { details: ItemDetail<any> }) {
|
|
|
19
20
|
size="small"
|
|
20
21
|
onClick={(e) => {
|
|
21
22
|
e.stopPropagation();
|
|
22
|
-
onExpandedRowIdsChange(details.id);
|
|
23
|
+
tableItems.onExpandedRowIdsChange(details.id);
|
|
23
24
|
}}
|
|
24
25
|
aria-expanded={isRowExpanded}
|
|
25
26
|
aria-label={isRowExpanded ? "Skjul under-rader" : "Vis under-rader"}
|
|
@@ -11,7 +11,7 @@ const inertValue = parseInt(version.split(".")[0], 10) > 18 ? true : ""; // Supp
|
|
|
11
11
|
|
|
12
12
|
const DataTableTbody = forwardRef<HTMLTableSectionElement, DataTableTbodyProps>(
|
|
13
13
|
({ className, ...rest }, forwardedRef) => {
|
|
14
|
-
const {
|
|
14
|
+
const { loading } = useDataTableContext();
|
|
15
15
|
return (
|
|
16
16
|
<DataTableLocationProvider location="tbody">
|
|
17
17
|
<tbody
|
|
@@ -19,7 +19,11 @@ const DataTableTbody = forwardRef<HTMLTableSectionElement, DataTableTbodyProps>(
|
|
|
19
19
|
ref={forwardedRef}
|
|
20
20
|
className={cl("aksel-data-table__tbody", className)}
|
|
21
21
|
// @ts-expect-error - inert is not yet recognized by React's type definitions, but we want to use it for better accessibility when showing the loading overlay.
|
|
22
|
-
inert={
|
|
22
|
+
inert={
|
|
23
|
+
loading?.isLoading && loading.variant === "overlay"
|
|
24
|
+
? inertValue
|
|
25
|
+
: false
|
|
26
|
+
}
|
|
23
27
|
/>
|
|
24
28
|
</DataTableLocationProvider>
|
|
25
29
|
);
|
|
@@ -12,26 +12,30 @@ import { Skeleton } from "../../../skeleton";
|
|
|
12
12
|
import { Label } from "../../../typography";
|
|
13
13
|
import { useId } from "../../../utils-external";
|
|
14
14
|
import { cl, composeEventHandlers } from "../../../utils/helpers";
|
|
15
|
+
import { consoleWarning } from "../../../utils/helpers/consoleWarning";
|
|
15
16
|
import { DataTableBaseCell } from "../base-cell/DataTableBaseCell";
|
|
16
17
|
import { DataTableColumnHeader } from "../column-header/DataTableColumnHeader";
|
|
17
18
|
import {
|
|
18
19
|
getDataTableDetailsPanelId,
|
|
19
20
|
useDataTableDetailsPanel,
|
|
20
21
|
} from "../hooks/useTableDetailsPanel";
|
|
22
|
+
import type { TableRowEntryId } from "../root/DataTable.types";
|
|
21
23
|
import {
|
|
22
24
|
useDataTableContext,
|
|
23
25
|
useDataTableLocation,
|
|
24
26
|
} from "../root/DataTableRoot.context";
|
|
25
27
|
import { DataTableTd } from "../td/DataTableTd";
|
|
26
28
|
|
|
27
|
-
const
|
|
29
|
+
const ACTION_CELL_WIDTH = 50;
|
|
30
|
+
|
|
31
|
+
const ACTION_CELL_CSS_WIDTH = `${ACTION_CELL_WIDTH}px`;
|
|
28
32
|
|
|
29
33
|
type DataTableTrProps = React.HTMLAttributes<HTMLTableRowElement> & {
|
|
30
34
|
selected?: boolean;
|
|
31
35
|
/**
|
|
32
36
|
* Unique identifier for the row, used for selection..
|
|
33
37
|
*/
|
|
34
|
-
rowId?:
|
|
38
|
+
rowId?: TableRowEntryId;
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
@@ -49,6 +53,7 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
49
53
|
const { layout, stickyHeader, selectionState, onRowClick } =
|
|
50
54
|
useDataTableContext();
|
|
51
55
|
const { location } = useDataTableLocation();
|
|
56
|
+
const { tableItems } = useDataTableContext();
|
|
52
57
|
|
|
53
58
|
const renderFillerCell = layout === "fixed" && children;
|
|
54
59
|
|
|
@@ -76,10 +81,17 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
if (
|
|
79
|
-
|
|
84
|
+
selectionState.selectionTrigger === "row" &&
|
|
80
85
|
selectionState.selection.selectionMode !== "none"
|
|
81
86
|
) {
|
|
82
|
-
|
|
87
|
+
const rowData = tableItems.itemDetails.get(rowId)?.rowData;
|
|
88
|
+
|
|
89
|
+
if (!rowData) {
|
|
90
|
+
consoleWarning(
|
|
91
|
+
`No row data found for rowId ${rowId}. This may cause issues with selection if enableRowSelection is used.`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
selectionState.selection.toggleSelection(rowId, rowData);
|
|
83
95
|
}
|
|
84
96
|
onRowClick?.(rowId, event);
|
|
85
97
|
}
|
|
@@ -113,8 +125,10 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
113
125
|
},
|
|
114
126
|
);
|
|
115
127
|
|
|
116
|
-
function RowExpansionCell({ rowId }: { rowId?:
|
|
117
|
-
const { tableId,
|
|
128
|
+
function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
129
|
+
const { tableId, loading, stickyStart } = useDataTableContext();
|
|
130
|
+
const stickyExpansion = stickyStart.expansion;
|
|
131
|
+
|
|
118
132
|
const { location } = useDataTableLocation();
|
|
119
133
|
|
|
120
134
|
const {
|
|
@@ -131,20 +145,25 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
131
145
|
return null;
|
|
132
146
|
}
|
|
133
147
|
|
|
134
|
-
if (
|
|
148
|
+
if (loading?.isLoading && loading?.variant === "skeleton") {
|
|
135
149
|
if (location === "thead") {
|
|
136
150
|
return (
|
|
137
151
|
<DataTableColumnHeader
|
|
138
|
-
width={
|
|
139
|
-
|
|
152
|
+
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
153
|
+
cellType="action"
|
|
140
154
|
data-block-keyboard-nav
|
|
141
155
|
label=""
|
|
142
|
-
|
|
156
|
+
isSticky={stickyExpansion && "start"}
|
|
157
|
+
style={stickyExpansion ? { left: 0 } : undefined}
|
|
143
158
|
/>
|
|
144
159
|
);
|
|
145
160
|
}
|
|
146
161
|
return (
|
|
147
|
-
<DataTableBaseCell
|
|
162
|
+
<DataTableBaseCell
|
|
163
|
+
as="td"
|
|
164
|
+
isSticky={stickyExpansion && "start"}
|
|
165
|
+
style={stickyExpansion ? { left: 0 } : undefined}
|
|
166
|
+
>
|
|
148
167
|
<Skeleton variant="text" />
|
|
149
168
|
</DataTableBaseCell>
|
|
150
169
|
);
|
|
@@ -153,11 +172,12 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
153
172
|
if (location === "thead" && !showExpandAll) {
|
|
154
173
|
return (
|
|
155
174
|
<DataTableColumnHeader
|
|
156
|
-
width={
|
|
157
|
-
|
|
175
|
+
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
176
|
+
cellType="action"
|
|
158
177
|
data-block-keyboard-nav
|
|
159
178
|
label=""
|
|
160
|
-
|
|
179
|
+
isSticky={stickyExpansion && "start"}
|
|
180
|
+
style={stickyExpansion ? { left: 0 } : undefined}
|
|
161
181
|
/>
|
|
162
182
|
);
|
|
163
183
|
}
|
|
@@ -166,10 +186,11 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
166
186
|
return (
|
|
167
187
|
<DataTableColumnHeader
|
|
168
188
|
textAlign="center"
|
|
169
|
-
width={
|
|
170
|
-
|
|
189
|
+
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
190
|
+
cellType="action"
|
|
171
191
|
label=""
|
|
172
|
-
|
|
192
|
+
isSticky={stickyExpansion && "start"}
|
|
193
|
+
style={stickyExpansion ? { left: 0 } : undefined}
|
|
173
194
|
>
|
|
174
195
|
<Button
|
|
175
196
|
variant="tertiary"
|
|
@@ -199,11 +220,23 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
199
220
|
const expansionId = getDataTableDetailsPanelId(tableId, rowId);
|
|
200
221
|
|
|
201
222
|
if (!canExpandRow) {
|
|
202
|
-
return
|
|
223
|
+
return (
|
|
224
|
+
<DataTableTd
|
|
225
|
+
cellType="action"
|
|
226
|
+
preventRowClick
|
|
227
|
+
isSticky={stickyExpansion && "start"}
|
|
228
|
+
style={stickyExpansion ? { left: 0 } : undefined}
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
203
231
|
}
|
|
204
232
|
|
|
205
233
|
return (
|
|
206
|
-
<DataTableTd
|
|
234
|
+
<DataTableTd
|
|
235
|
+
cellType="action"
|
|
236
|
+
preventRowClick
|
|
237
|
+
isSticky={stickyExpansion && "start"}
|
|
238
|
+
style={stickyExpansion ? { left: 0 } : undefined}
|
|
239
|
+
>
|
|
207
240
|
<Button
|
|
208
241
|
variant="tertiary"
|
|
209
242
|
data-color="neutral"
|
|
@@ -227,10 +260,14 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
227
260
|
* TODO: How do these cells handle multiple thead rows, or col/row-spans?
|
|
228
261
|
* TODO: a11y for labels
|
|
229
262
|
*/
|
|
230
|
-
function RowSelectionCell({ rowId }: { rowId?:
|
|
231
|
-
const { selectionState,
|
|
232
|
-
|
|
263
|
+
function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
264
|
+
const { selectionState, stickyStart, loading } = useDataTableContext();
|
|
265
|
+
const stickySelection = stickyStart.selection;
|
|
266
|
+
const stickySelectionOffset = stickyStart.selectionOffset;
|
|
233
267
|
const { location } = useDataTableLocation();
|
|
268
|
+
|
|
269
|
+
const { tableItems } = useDataTableContext();
|
|
270
|
+
|
|
234
271
|
const inputId = useId();
|
|
235
272
|
|
|
236
273
|
const { selection, renderSelection } = selectionState;
|
|
@@ -239,21 +276,26 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
239
276
|
return null;
|
|
240
277
|
}
|
|
241
278
|
|
|
242
|
-
if (
|
|
279
|
+
if (loading?.isLoading && loading?.variant === "skeleton") {
|
|
243
280
|
if (location === "thead") {
|
|
244
281
|
return (
|
|
245
282
|
<DataTableColumnHeader
|
|
246
|
-
width={
|
|
247
|
-
|
|
283
|
+
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
284
|
+
cellType="action"
|
|
248
285
|
label=""
|
|
249
286
|
data-block-keyboard-nav
|
|
250
287
|
isSticky={stickySelection && "start"}
|
|
288
|
+
style={stickySelection ? { left: stickySelectionOffset } : undefined}
|
|
251
289
|
/>
|
|
252
290
|
);
|
|
253
291
|
}
|
|
254
292
|
|
|
255
293
|
return (
|
|
256
|
-
<DataTableBaseCell
|
|
294
|
+
<DataTableBaseCell
|
|
295
|
+
as="td"
|
|
296
|
+
isSticky={stickySelection && "start"}
|
|
297
|
+
style={stickySelection ? { left: stickySelectionOffset } : undefined}
|
|
298
|
+
>
|
|
257
299
|
<Skeleton variant="text" />
|
|
258
300
|
</DataTableBaseCell>
|
|
259
301
|
);
|
|
@@ -271,10 +313,11 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
271
313
|
return (
|
|
272
314
|
<DataTableColumnHeader
|
|
273
315
|
textAlign="center"
|
|
274
|
-
width={
|
|
275
|
-
|
|
316
|
+
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
317
|
+
cellType="action"
|
|
276
318
|
label=""
|
|
277
319
|
isSticky={stickySelection && "start"}
|
|
320
|
+
style={stickySelection ? { left: stickySelectionOffset } : undefined}
|
|
278
321
|
>
|
|
279
322
|
<Label htmlFor={inputId} visuallyHidden>
|
|
280
323
|
{labelText}
|
|
@@ -287,11 +330,12 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
287
330
|
if (selection.selectionMode === "single" && location === "thead") {
|
|
288
331
|
return (
|
|
289
332
|
<DataTableColumnHeader
|
|
290
|
-
width={
|
|
291
|
-
|
|
333
|
+
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
334
|
+
cellType="action"
|
|
292
335
|
label=""
|
|
293
336
|
data-block-keyboard-nav
|
|
294
337
|
isSticky={stickySelection && "start"}
|
|
338
|
+
style={stickySelection ? { left: stickySelectionOffset } : undefined}
|
|
295
339
|
/>
|
|
296
340
|
);
|
|
297
341
|
}
|
|
@@ -302,16 +346,35 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
302
346
|
|
|
303
347
|
if (selection.selectionMode === "multiple" && location === "tbody") {
|
|
304
348
|
return (
|
|
305
|
-
<DataTableTd
|
|
306
|
-
|
|
349
|
+
<DataTableTd
|
|
350
|
+
cellType="action"
|
|
351
|
+
isSticky={stickySelection && "start"}
|
|
352
|
+
style={stickySelection ? { left: stickySelectionOffset } : undefined}
|
|
353
|
+
>
|
|
354
|
+
<CheckboxInput
|
|
355
|
+
{...selection.getRowCheckboxProps(
|
|
356
|
+
rowId,
|
|
357
|
+
tableItems.itemDetails.get(rowId)?.rowData,
|
|
358
|
+
)}
|
|
359
|
+
compact
|
|
360
|
+
/>
|
|
307
361
|
</DataTableTd>
|
|
308
362
|
);
|
|
309
363
|
}
|
|
310
364
|
|
|
311
365
|
if (selection.selectionMode === "single" && location === "tbody") {
|
|
312
366
|
return (
|
|
313
|
-
<DataTableTd
|
|
314
|
-
|
|
367
|
+
<DataTableTd
|
|
368
|
+
cellType="action"
|
|
369
|
+
isSticky={stickySelection && "start"}
|
|
370
|
+
style={stickySelection ? { left: stickySelectionOffset } : undefined}
|
|
371
|
+
>
|
|
372
|
+
<RadioInput
|
|
373
|
+
{...selection.getRowRadioProps(
|
|
374
|
+
rowId,
|
|
375
|
+
tableItems.itemDetails.get(rowId)?.rowData,
|
|
376
|
+
)}
|
|
377
|
+
/>
|
|
315
378
|
</DataTableTd>
|
|
316
379
|
);
|
|
317
380
|
}
|
|
@@ -326,5 +389,5 @@ function isInteractiveTarget(target: EventTarget | null): boolean {
|
|
|
326
389
|
);
|
|
327
390
|
}
|
|
328
391
|
|
|
329
|
-
export { DataTableTr };
|
|
392
|
+
export { DataTableTr, ACTION_CELL_WIDTH };
|
|
330
393
|
export type { DataTableTrProps };
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
SortDownIcon,
|
|
5
5
|
SortUpIcon,
|
|
6
6
|
} from "@navikt/aksel-icons";
|
|
7
|
+
import { consoleWarning } from "../utils/helpers/consoleWarning";
|
|
7
8
|
import HeaderCell, { HeaderCellProps } from "./HeaderCell";
|
|
8
9
|
import { TableContext } from "./context";
|
|
9
10
|
|
|
@@ -28,7 +29,7 @@ export const ColumnHeader: ColumnHeaderType = forwardRef(
|
|
|
28
29
|
const context = useContext(TableContext);
|
|
29
30
|
|
|
30
31
|
if (sortable && !sortKey) {
|
|
31
|
-
|
|
32
|
+
consoleWarning("ColumnHeader with `sortable=true` must have a sortKey.");
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
return (
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface DragAndDropDragHandlerLegacyProps {
|
|
3
|
-
/**
|
|
4
|
-
* Whether the drag handler is disabled
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Wether dragging is done by keyboard. Used to conditionally render drag indicators.
|
|
8
|
-
*/
|
|
9
|
-
keyboardDragging?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Handle ref is forwarded to the button element serving as drag handle.
|
|
12
|
-
*/
|
|
13
|
-
handleRef: React.Ref<HTMLDivElement>;
|
|
14
|
-
alt?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* DragAndDropDragHandlerLegacy
|
|
18
|
-
*
|
|
19
|
-
* A button component that serves as a drag handle for drag and drop operations.
|
|
20
|
-
* Can be used to initiate dragging of elements in a data table or list.
|
|
21
|
-
*/
|
|
22
|
-
export declare const DragAndDropDragHandlerLegacy: React.ForwardRefExoticComponent<DragAndDropDragHandlerLegacyProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DragAndDropDragHandlerLegacy = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
9
|
-
const Floating_1 = require("../../../utils/components/floating/Floating");
|
|
10
|
-
/**
|
|
11
|
-
* DragAndDropDragHandlerLegacy
|
|
12
|
-
*
|
|
13
|
-
* A button component that serves as a drag handle for drag and drop operations.
|
|
14
|
-
* Can be used to initiate dragging of elements in a data table or list.
|
|
15
|
-
*/
|
|
16
|
-
exports.DragAndDropDragHandlerLegacy = react_1.default.forwardRef(({ keyboardDragging, handleRef, alt }) => {
|
|
17
|
-
if (alt) {
|
|
18
|
-
return (react_1.default.createElement("div", { className: "aksel-data-drag-and-drop__drag-handler__legacy" },
|
|
19
|
-
keyboardDragging && (react_1.default.createElement("span", { className: "aksel-data-drag-and-drop__drag-handler__arrow", "data-direction": "up" },
|
|
20
|
-
react_1.default.createElement(aksel_icons_1.CaretUpCircleFillIcon, { "aria-hidden": true, fontSize: "1.2rem" }))),
|
|
21
|
-
react_1.default.createElement("div", { ref: handleRef, className: "aksel-data-drag-and-drop__drag-handler__button" },
|
|
22
|
-
react_1.default.createElement(aksel_icons_1.DragVerticalIcon, { "aria-hidden": true, title: "Dra for \u00E5 flytte", fontSize: "1.5rem" })),
|
|
23
|
-
keyboardDragging && (react_1.default.createElement("span", { className: "aksel-data-drag-and-drop__drag-handler__arrow", "data-direction": "down" },
|
|
24
|
-
react_1.default.createElement(aksel_icons_1.CaretDownCircleFillIcon, { "aria-hidden": true, fontSize: "1.2rem" })))));
|
|
25
|
-
}
|
|
26
|
-
return (react_1.default.createElement(Floating_1.Floating, null,
|
|
27
|
-
keyboardDragging && (react_1.default.createElement(Floating_1.Floating.Content, { side: "top", avoidCollisions: false, updatePositionStrategy: "always", className: "aksel-data-drag-and-drop__drag-handler__arrow" },
|
|
28
|
-
react_1.default.createElement(aksel_icons_1.CaretUpCircleFillIcon, { "aria-hidden": true, fontSize: "1.2rem" }))),
|
|
29
|
-
react_1.default.createElement(Floating_1.Floating.Anchor, { asChild: true },
|
|
30
|
-
react_1.default.createElement("div", { ref: handleRef, className: "aksel-data-drag-and-drop__drag-handler__button" },
|
|
31
|
-
react_1.default.createElement(aksel_icons_1.DragVerticalIcon, { "aria-hidden": true, title: "Dra for \u00E5 flytte", fontSize: "1.5rem" }))),
|
|
32
|
-
keyboardDragging && (react_1.default.createElement(Floating_1.Floating.Content, { avoidCollisions: false, updatePositionStrategy: "always", className: "aksel-data-drag-and-drop__drag-handler__arrow" },
|
|
33
|
-
react_1.default.createElement(aksel_icons_1.CaretDownCircleFillIcon, { "aria-hidden": true, fontSize: "1.2rem" })))));
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=DragAndDropDragHandlerLegacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropDragHandlerLegacy.js","sourceRoot":"","sources":["../../../../src/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,qDAI6B;AAC7B,0EAAuE;AAmBvE;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG,eAAK,CAAC,UAAU,CAG1D,CAAC,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE;IACzC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,CACL,uCAAK,SAAS,EAAC,gDAAgD;YAC5D,gBAAgB,IAAI,CACnB,wCACE,SAAS,EAAC,+CAA+C,oBAC1C,IAAI;gBAEnB,8BAAC,mCAAqB,yBAAa,QAAQ,EAAC,QAAQ,GAAG,CAClD,CACR;YACD,uCACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAC,gDAAgD;gBAE1D,8BAAC,8BAAgB,yBAEf,KAAK,EAAC,uBAAkB,EACxB,QAAQ,EAAC,QAAQ,GACjB,CACE;YACL,gBAAgB,IAAI,CACnB,wCACE,SAAS,EAAC,+CAA+C,oBAC1C,MAAM;gBAErB,8BAAC,qCAAuB,yBAAa,QAAQ,EAAC,QAAQ,GAAG,CACpD,CACR,CACG,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,8BAAC,mBAAQ;QACN,gBAAgB,IAAI,CACnB,8BAAC,mBAAQ,CAAC,OAAO,IACf,IAAI,EAAC,KAAK,EACV,eAAe,EAAE,KAAK,EACtB,sBAAsB,EAAC,QAAQ,EAC/B,SAAS,EAAC,+CAA+C;YAEzD,8BAAC,mCAAqB,yBAAa,QAAQ,EAAC,QAAQ,GAAG,CACtC,CACpB;QACD,8BAAC,mBAAQ,CAAC,MAAM,IAAC,OAAO;YACtB,uCACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAC,gDAAgD;gBAE1D,8BAAC,8BAAgB,yBAEf,KAAK,EAAC,uBAAkB,EACxB,QAAQ,EAAC,QAAQ,GACjB,CACE,CACU;QACjB,gBAAgB,IAAI,CACnB,8BAAC,mBAAQ,CAAC,OAAO,IACf,eAAe,EAAE,KAAK,EACtB,sBAAsB,EAAC,QAAQ,EAC/B,SAAS,EAAC,+CAA+C;YAEzD,8BAAC,qCAAuB,yBAAa,QAAQ,EAAC,QAAQ,GAAG,CACxC,CACpB,CACQ,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface DragAndDropItemLegacyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
/**
|
|
5
|
-
* Unique id
|
|
6
|
-
*/
|
|
7
|
-
id: string;
|
|
8
|
-
/**
|
|
9
|
-
* Index of the item being dragged
|
|
10
|
-
*/
|
|
11
|
-
index: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* TODO
|
|
15
|
-
*
|
|
16
|
-
* @see 🏷️ {@link DragAndDropItemLegacyProps}
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* <DragAndDropLegacy.Item numOfSelectedRows={selectedRows.length} onClear={handleClear}>
|
|
20
|
-
* TODO
|
|
21
|
-
* </DragAndDropLegacy.Item>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare const DragAndDropItemLegacy: React.ForwardRefExoticComponent<DragAndDropItemLegacyProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
-
export default DragAndDropItemLegacy;
|
|
26
|
-
export { DragAndDropItemLegacy };
|
|
27
|
-
export type { DragAndDropItemLegacyProps };
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
-
var t = {};
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
-
t[p[i]] = s[p[i]];
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
};
|
|
46
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.DragAndDropItemLegacy = void 0;
|
|
48
|
-
const sortable_1 = require("@dnd-kit/react/sortable");
|
|
49
|
-
const react_1 = __importStar(require("react"));
|
|
50
|
-
const stack_1 = require("../../../primitives/stack");
|
|
51
|
-
const helpers_1 = require("../../../utils/helpers");
|
|
52
|
-
const hooks_1 = require("../../../utils/hooks");
|
|
53
|
-
const DragAndDropDragHandlerLegacy_1 = require("../drag-handler/DragAndDropDragHandlerLegacy");
|
|
54
|
-
const DragAndDropLegacy_context_1 = require("../root/DragAndDropLegacy.context");
|
|
55
|
-
/**
|
|
56
|
-
* TODO
|
|
57
|
-
*
|
|
58
|
-
* @see 🏷️ {@link DragAndDropItemLegacyProps}
|
|
59
|
-
* @example
|
|
60
|
-
* ```tsx
|
|
61
|
-
* <DragAndDropLegacy.Item numOfSelectedRows={selectedRows.length} onClear={handleClear}>
|
|
62
|
-
* TODO
|
|
63
|
-
* </DragAndDropLegacy.Item>
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
const DragAndDropItemLegacy = react_1.default.forwardRef((_a, forwardedRef) => {
|
|
67
|
-
var { children, id, index, className } = _a, rest = __rest(_a, ["children", "id", "index", "className"]);
|
|
68
|
-
const handleRef = (0, react_1.useRef)(null);
|
|
69
|
-
const { ref, isDragging, isDropTarget } = (0, sortable_1.useSortable)({
|
|
70
|
-
id,
|
|
71
|
-
index,
|
|
72
|
-
handle: handleRef,
|
|
73
|
-
});
|
|
74
|
-
const mergedRef = (0, hooks_1.useMergeRefs)(ref, forwardedRef);
|
|
75
|
-
const context = react_1.default.useContext(DragAndDropLegacy_context_1.DragAndDropLegacyContext);
|
|
76
|
-
const mouseDragging = isDragging && (context === null || context === void 0 ? void 0 : context.inputMethod) === "mouse";
|
|
77
|
-
const mouseDropTarget = isDropTarget && (context === null || context === void 0 ? void 0 : context.inputMethod) === "mouse";
|
|
78
|
-
const keyboardDragging = isDragging && (context === null || context === void 0 ? void 0 : context.inputMethod) === "keyboard";
|
|
79
|
-
return (react_1.default.createElement(stack_1.HStack, { gap: "space-8", align: "center", wrap: false, asChild: true },
|
|
80
|
-
react_1.default.createElement("div", Object.assign({ ref: mergedRef }, rest, { className: (0, helpers_1.cl)("aksel-data-table__drag-and-drop-item", className), "data-dragging": isDragging, "data-mouse-dragging": mouseDragging, "data-keyboard-dragging": keyboardDragging, "data-drop-target": mouseDropTarget, tabIndex: -1 }),
|
|
81
|
-
react_1.default.createElement(DragAndDropDragHandlerLegacy_1.DragAndDropDragHandlerLegacy, { handleRef: handleRef, keyboardDragging: keyboardDragging, alt: true }),
|
|
82
|
-
react_1.default.createElement("div", null, children))));
|
|
83
|
-
});
|
|
84
|
-
exports.DragAndDropItemLegacy = DragAndDropItemLegacy;
|
|
85
|
-
exports.default = DragAndDropItemLegacy;
|
|
86
|
-
//# sourceMappingURL=DragAndDropItemLegacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropItemLegacy.js","sourceRoot":"","sources":["../../../../src/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAsD;AACtD,+CAAsC;AACtC,qDAAmD;AACnD,oDAA4C;AAC5C,gDAAoD;AACpD,+FAA4F;AAC5F,iFAA6E;AAc7E;;;;;;;;;;GAUG;AACH,MAAM,qBAAqB,GAAG,eAAK,CAAC,UAAU,CAG5C,CAAC,EAA2C,EAAE,YAAY,EAAE,EAAE;QAA7D,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,OAAW,EAAN,IAAI,cAAzC,wCAA2C,CAAF;IAC1C,MAAM,SAAS,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,IAAA,sBAAW,EAAC;QACpD,EAAE;QACF,KAAK;QACL,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAA,oBAAY,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,oDAAwB,CAAC,CAAC;IAC3D,MAAM,aAAa,GAAG,UAAU,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,MAAK,OAAO,CAAC;IACrE,MAAM,eAAe,GAAG,YAAY,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,MAAK,OAAO,CAAC;IACzE,MAAM,gBAAgB,GAAG,UAAU,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,MAAK,UAAU,CAAC;IAE3E,OAAO,CACL,8BAAC,cAAM,IAAC,GAAG,EAAC,SAAS,EAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO;QAEvD,qDACE,GAAG,EAAE,SAAS,IACV,IAAI,IACR,SAAS,EAAE,IAAA,YAAE,EAAC,sCAAsC,EAAE,SAAS,CAAC,mBACjD,UAAU,yBACJ,aAAa,4BACV,gBAAgB,sBACtB,eAAe,EACjC,QAAQ,EAAE,CAAC,CAAC;YAEZ,8BAAC,2DAA4B,IAC3B,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,SACH;YACF,2CAAM,QAAQ,CAAO,CACjB,CACC,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAGM,sDAAqB;AAD9B,kBAAe,qBAAqB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DragAndDropLegacyContext = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
exports.DragAndDropLegacyContext = (0, react_1.createContext)(undefined);
|
|
6
|
-
//# sourceMappingURL=DragAndDropLegacy.context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDropLegacy.context.js","sourceRoot":"","sources":["../../../../src/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.tsx"],"names":[],"mappings":";;;AAAA,iCAAsC;AAQzB,QAAA,wBAAwB,GAAG,IAAA,qBAAa,EAEnD,SAAS,CAAC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import DragAndDropItemLegacy from "../item/DragAndDropItemLegacy";
|
|
3
|
-
interface DragAndDropLegacyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
children: any[];
|
|
5
|
-
setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
6
|
-
}
|
|
7
|
-
interface DragAndDropLegacyRootComponent extends React.ForwardRefExoticComponent<DragAndDropLegacyProps & React.RefAttributes<HTMLDivElement>> {
|
|
8
|
-
/**
|
|
9
|
-
* @see 🏷️ {@link DragAndDropItemLegacyProps}
|
|
10
|
-
* * @example
|
|
11
|
-
* ```jsx
|
|
12
|
-
* <DragAndDropLegacy>
|
|
13
|
-
* <DragAndDropLegacy.Item id="1" index={0}>
|
|
14
|
-
* ...
|
|
15
|
-
* </DragAndDropLegacy.Item>
|
|
16
|
-
* </DragAndDropLegacy>
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
Item: typeof DragAndDropItemLegacy;
|
|
20
|
-
}
|
|
21
|
-
declare const DragAndDropLegacy: DragAndDropLegacyRootComponent;
|
|
22
|
-
export { DragAndDropLegacy, DragAndDropItemLegacy };
|
|
23
|
-
export default DragAndDropLegacy;
|
|
24
|
-
export type { DragAndDropLegacyProps };
|