@ynput/ayon-frontend-shared 0.2.16 → 0.2.17
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/DetailsPanel.cjs.js +9 -10
- package/dist/DetailsPanel.cjs.js.map +1 -1
- package/dist/DetailsPanel.es.js +9 -10
- package/dist/DetailsPanel.es.js.map +1 -1
- package/dist/ProjectTreeTable.cjs.js +38 -34
- package/dist/ProjectTreeTable.cjs.js.map +1 -1
- package/dist/ProjectTreeTable.es.js +20 -16
- package/dist/ProjectTreeTable.es.js.map +1 -1
- package/dist/_virtual/index.cjs10.js +4 -4
- package/dist/_virtual/index.cjs5.js +5 -3
- package/dist/_virtual/index.cjs5.js.map +1 -1
- package/dist/_virtual/index.cjs6.js +3 -5
- package/dist/_virtual/index.cjs6.js.map +1 -1
- package/dist/_virtual/index.cjs8.js +4 -4
- package/dist/_virtual/index.cjs9.js +4 -4
- package/dist/_virtual/index.es10.js +4 -4
- package/dist/_virtual/index.es5.js +5 -2
- package/dist/_virtual/index.es5.js.map +1 -1
- package/dist/_virtual/index.es6.js +2 -5
- package/dist/_virtual/index.es6.js.map +1 -1
- package/dist/_virtual/index.es8.js +4 -4
- package/dist/_virtual/index.es9.js +4 -4
- package/dist/index.cjs.js +6 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +6 -7
- package/dist/index.es.js.map +1 -1
- package/dist/node_modules/graphql-request/build/legacy/helpers/analyzeDocument.cjs.js +1 -2
- package/dist/node_modules/graphql-request/build/legacy/helpers/analyzeDocument.cjs.js.map +1 -1
- package/dist/node_modules/graphql-request/build/legacy/helpers/analyzeDocument.es.js +1 -2
- package/dist/node_modules/graphql-request/build/legacy/helpers/analyzeDocument.es.js.map +1 -1
- package/dist/node_modules/rehype/node_modules/unified/lib/index.cjs.js +2 -2
- package/dist/node_modules/rehype/node_modules/unified/lib/index.es.js +2 -2
- package/dist/node_modules/rehype-parse/lib/index.cjs.js +1 -1
- package/dist/node_modules/rehype-parse/lib/index.es.js +1 -1
- package/dist/node_modules/rehype-prism-plus/dist/index.es.cjs.js +1 -1
- package/dist/node_modules/rehype-prism-plus/dist/index.es.es.js +1 -1
- package/dist/node_modules/remove-accents/index.cjs.js +1 -1
- package/dist/node_modules/remove-accents/index.es.js +1 -1
- package/dist/node_modules/vfile/lib/index.cjs.js +1 -1
- package/dist/node_modules/vfile/lib/index.es.js +1 -1
- package/dist/shared/src/components/EntityThumbnailUploader/EntityThumbnailUploader.cjs.js +6 -7
- package/dist/shared/src/components/EntityThumbnailUploader/EntityThumbnailUploader.cjs.js.map +1 -1
- package/dist/shared/src/components/EntityThumbnailUploader/EntityThumbnailUploader.es.js +6 -7
- package/dist/shared/src/components/EntityThumbnailUploader/EntityThumbnailUploader.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ColumnItem.cjs.js +2 -0
- package/dist/shared/src/components/ProjectTableSettings/ColumnItem.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ColumnItem.es.js +2 -0
- package/dist/shared/src/components/ProjectTableSettings/ColumnItem.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.cjs.js +5 -1
- package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.es.js +5 -1
- package/dist/shared/src/components/ProjectTableSettings/ColumnsSettings.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.cjs.js +21 -86
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.es.js +21 -86
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/SortableColumnItem.cjs.js +2 -0
- package/dist/shared/src/components/ProjectTableSettings/SortableColumnItem.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/SortableColumnItem.es.js +2 -0
- package/dist/shared/src/components/ProjectTableSettings/SortableColumnItem.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.cjs.js +6 -7
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.es.js +6 -7
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.cjs.js +6 -7
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.es.js +6 -7
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.cjs.js +6 -7
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.es.js +6 -7
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.es.js.map +1 -1
- package/dist/shared/src/components/SettingsPanel/SettingsPanelItemTemplate.cjs.js +27 -6
- package/dist/shared/src/components/SettingsPanel/SettingsPanelItemTemplate.cjs.js.map +1 -1
- package/dist/shared/src/components/SettingsPanel/SettingsPanelItemTemplate.es.js +27 -6
- package/dist/shared/src/components/SettingsPanel/SettingsPanelItemTemplate.es.js.map +1 -1
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.cjs.js +6 -7
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.es.js +6 -7
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.cjs.js +6 -7
- package/dist/shared/src/containers/Actions/ActionConfigDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.es.js +6 -7
- package/dist/shared/src/containers/Actions/ActionConfigDialog.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.cjs.js +6 -7
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.es.js +6 -7
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js +9 -10
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js +9 -10
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js +6 -7
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.es.js +6 -7
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.cjs.js +6 -7
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.es.js +6 -7
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.cjs.js +5 -6
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.es.js +5 -6
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js +16 -9
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js +16 -9
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.cjs.js +5 -7
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.es.js +5 -7
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsContext.cjs.js +1 -174
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsContext.es.js +2 -175
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsProvider.cjs.js +212 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsProvider.cjs.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsProvider.es.js +212 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ColumnSettingsProvider.es.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableContext.cjs.js +1 -185
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableContext.es.js +2 -186
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableProvider.cjs.js +191 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableProvider.cjs.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableProvider.es.js +191 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableProvider.es.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsContext.cjs.js +1 -79
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsContext.es.js +2 -80
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsProvider.cjs.js +84 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsProvider.cjs.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsProvider.es.js +84 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectedRowsProvider.es.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsContext.cjs.js +1 -277
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsContext.es.js +2 -278
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.cjs.js +282 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.cjs.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.es.js +282 -0
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.es.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.cjs.js +3 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.es.js +3 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useEntitiesMap.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useEntitiesMap.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useFetchOverviewData.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.cjs.js +8 -175
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.es.js +8 -175
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/{context/ProjectTableModulesContext.cjs.js → hooks/useProjectTableModules.cjs.js} +26 -48
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useProjectTableModules.cjs.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/{context/ProjectTableModulesContext.es.js → hooks/useProjectTableModules.es.js} +26 -48
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useProjectTableModules.es.js.map +1 -0
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.cjs.js +4 -3
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.es.js +4 -3
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.cjs.js +8 -5
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.es.js +7 -4
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.es.js.map +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.cjs.js +7 -8
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.cjs.js.map +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.es.js +7 -8
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.es.js.map +1 -1
- package/dist/shared/src/context/RemoteModulesContext.es.js +1 -1
- package/dist/shared/src/hooks/useLoadModule.cjs.js +3 -3
- package/dist/shared/src/hooks/useLoadModule.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useLoadModule.es.js +3 -3
- package/dist/shared/src/hooks/useLoadModule.es.js.map +1 -1
- package/dist/types/components/ProjectTableSettings/ColumnItem.d.ts +1 -0
- package/dist/types/components/ProjectTableSettings/SortableColumnItem.d.ts +1 -0
- package/dist/types/components/SettingsPanel/SettingsPanelItemTemplate.d.ts +1 -0
- package/dist/types/containers/ProjectTreeTable/components/GroupSettingsFallback.d.ts +9 -2
- package/dist/types/containers/ProjectTreeTable/context/ColumnSettingsContext.d.ts +16 -16
- package/dist/types/containers/ProjectTreeTable/context/ColumnSettingsProvider.d.ts +9 -0
- package/dist/types/containers/ProjectTreeTable/context/ProjectTableContext.d.ts +5 -61
- package/dist/types/containers/ProjectTreeTable/context/ProjectTableProvider.d.ts +59 -0
- package/dist/types/containers/ProjectTreeTable/context/SelectedRowsContext.d.ts +3 -8
- package/dist/types/containers/ProjectTreeTable/context/SelectedRowsProvider.d.ts +6 -0
- package/dist/types/containers/ProjectTreeTable/context/SelectionCellsContext.d.ts +2 -4
- package/dist/types/containers/ProjectTreeTable/context/SelectionCellsProvider.d.ts +4 -0
- package/dist/types/containers/ProjectTreeTable/context/index.d.ts +4 -2
- package/dist/types/containers/ProjectTreeTable/hooks/index.d.ts +1 -0
- package/dist/types/containers/ProjectTreeTable/hooks/useBuildGroupByTableData.d.ts +1 -2
- package/dist/types/containers/ProjectTreeTable/hooks/useEntitiesMap.d.ts +1 -1
- package/dist/types/containers/ProjectTreeTable/hooks/useFetchOverviewData.d.ts +4 -3
- package/dist/types/containers/ProjectTreeTable/hooks/useGetGroupedFields.d.ts +1 -1
- package/dist/types/containers/ProjectTreeTable/{context/ProjectTableModulesContext.d.ts → hooks/useProjectTableModules.d.ts} +5 -12
- package/dist/types/containers/ProjectTreeTable/index.d.ts +1 -10
- package/dist/types/containers/ProjectTreeTable/types/overviewContext.d.ts +3 -3
- package/package.json +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableModulesContext.cjs.js.map +0 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableModulesContext.es.js.map +0 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableSelectionContext.cjs.js +0 -33
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableSelectionContext.cjs.js.map +0 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableSelectionContext.es.js +0 -33
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectTableSelectionContext.es.js.map +0 -1
- package/dist/types/containers/ProjectTreeTable/context/ProjectTableSelectionContext.d.ts +0 -11
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../../../_virtual/jsx-runtime.es.js";
|
|
2
|
+
import { useRef, useMemo, useCallback } from "react";
|
|
3
|
+
import { useSelectionCellsContext, ROW_SELECTION_COLUMN_ID } from "./SelectionCellsContext.es.js";
|
|
4
|
+
import { parseCellId, getCellId } from "../utils/cellUtils.es.js";
|
|
5
|
+
import { SelectedRowsContext } from "./SelectedRowsContext.es.js";
|
|
6
|
+
const SelectedRowsProvider = ({ children }) => {
|
|
7
|
+
const { selectedCells, gridMap, setSelectedCells, setFocusedCellId, setAnchorCell } = useSelectionCellsContext();
|
|
8
|
+
const prevSelectedRowsRef = useRef([]);
|
|
9
|
+
const currentSelectedRows = useMemo(
|
|
10
|
+
() => Array.from(selectedCells).filter(
|
|
11
|
+
(cellId) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return ((_a = parseCellId(cellId)) == null ? void 0 : _a.colId) === ROW_SELECTION_COLUMN_ID && ((_b = parseCellId(cellId)) == null ? void 0 : _b.rowId);
|
|
14
|
+
}
|
|
15
|
+
).map((cellId) => {
|
|
16
|
+
var _a;
|
|
17
|
+
return (_a = parseCellId(cellId)) == null ? void 0 : _a.rowId;
|
|
18
|
+
}),
|
|
19
|
+
[selectedCells]
|
|
20
|
+
);
|
|
21
|
+
const selectedRows = useMemo(() => {
|
|
22
|
+
const sortedCurrent = [...currentSelectedRows].sort();
|
|
23
|
+
const sortedPrev = [...prevSelectedRowsRef.current].sort();
|
|
24
|
+
const hasChanged = sortedCurrent.length !== sortedPrev.length || sortedCurrent.some((id, index) => id !== sortedPrev[index]);
|
|
25
|
+
if (hasChanged) {
|
|
26
|
+
prevSelectedRowsRef.current = currentSelectedRows;
|
|
27
|
+
return currentSelectedRows;
|
|
28
|
+
}
|
|
29
|
+
return prevSelectedRowsRef.current;
|
|
30
|
+
}, [currentSelectedRows]);
|
|
31
|
+
const selectAllRows = useCallback(() => {
|
|
32
|
+
const allRowIds = Array.from(gridMap.rowIdToIndex.keys());
|
|
33
|
+
const newSelection = /* @__PURE__ */ new Set();
|
|
34
|
+
allRowIds.forEach((rowId) => {
|
|
35
|
+
newSelection.add(getCellId(rowId, ROW_SELECTION_COLUMN_ID));
|
|
36
|
+
});
|
|
37
|
+
setSelectedCells(newSelection);
|
|
38
|
+
if (allRowIds.length > 0) {
|
|
39
|
+
const firstCellId = getCellId(allRowIds[0], ROW_SELECTION_COLUMN_ID);
|
|
40
|
+
setFocusedCellId(firstCellId);
|
|
41
|
+
setAnchorCell(parseCellId(firstCellId));
|
|
42
|
+
}
|
|
43
|
+
}, [gridMap]);
|
|
44
|
+
const clearRowsSelection = useCallback(() => {
|
|
45
|
+
setSelectedCells((prev) => {
|
|
46
|
+
const newSelection = new Set(prev);
|
|
47
|
+
Array.from(newSelection).forEach((cellId) => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (((_a = parseCellId(cellId)) == null ? void 0 : _a.colId) === ROW_SELECTION_COLUMN_ID) {
|
|
50
|
+
newSelection.delete(cellId);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return newSelection;
|
|
54
|
+
});
|
|
55
|
+
}, [setSelectedCells]);
|
|
56
|
+
const isRowSelected = useCallback(
|
|
57
|
+
(rowId) => {
|
|
58
|
+
return selectedRows.includes(rowId);
|
|
59
|
+
},
|
|
60
|
+
[selectedRows]
|
|
61
|
+
);
|
|
62
|
+
const areAllRowsSelected = useCallback(() => {
|
|
63
|
+
const totalRows = gridMap.rowIdToIndex.size;
|
|
64
|
+
return totalRows > 0 && selectedRows.length === totalRows;
|
|
65
|
+
}, [gridMap, selectedRows]);
|
|
66
|
+
const areSomeRowsSelected = useCallback(() => {
|
|
67
|
+
return selectedRows.length > 0 && !areAllRowsSelected();
|
|
68
|
+
}, [selectedRows, areAllRowsSelected]);
|
|
69
|
+
const value = useMemo(() => {
|
|
70
|
+
return {
|
|
71
|
+
selectedRows,
|
|
72
|
+
selectAllRows,
|
|
73
|
+
clearRowsSelection,
|
|
74
|
+
isRowSelected,
|
|
75
|
+
areAllRowsSelected,
|
|
76
|
+
areSomeRowsSelected
|
|
77
|
+
};
|
|
78
|
+
}, [selectedRows, selectAllRows, areAllRowsSelected, areSomeRowsSelected, clearRowsSelection]);
|
|
79
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectedRowsContext.Provider, { value, children });
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
SelectedRowsProvider
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=SelectedRowsProvider.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectedRowsProvider.es.js","sources":["../../../../../../src/containers/ProjectTreeTable/context/SelectedRowsProvider.tsx"],"sourcesContent":["import { ReactNode, useCallback, useMemo, useRef } from 'react'\nimport { ROW_SELECTION_COLUMN_ID, useSelectionCellsContext } from './SelectionCellsContext'\nimport { CellId, getCellId, parseCellId, RowId } from '../utils/cellUtils'\nimport { SelectedRowsContext } from './SelectedRowsContext'\n\ninterface SelectedRowsProviderProps {\n children: ReactNode\n}\n\nexport const SelectedRowsProvider = ({ children }: SelectedRowsProviderProps) => {\n const { selectedCells, gridMap, setSelectedCells, setFocusedCellId, setAnchorCell } =\n useSelectionCellsContext()\n const prevSelectedRowsRef = useRef<string[]>([])\n\n // Calculate the current selected rows\n const currentSelectedRows = useMemo(\n () =>\n Array.from(selectedCells)\n .filter(\n (cellId) =>\n parseCellId(cellId)?.colId === ROW_SELECTION_COLUMN_ID && parseCellId(cellId)?.rowId,\n )\n .map((cellId) => parseCellId(cellId)?.rowId) as string[],\n [selectedCells],\n )\n\n // Memoize the selected rows with a stable reference\n const selectedRows = useMemo(() => {\n // Sort for consistent comparison\n const sortedCurrent = [...currentSelectedRows].sort()\n const sortedPrev = [...prevSelectedRowsRef.current].sort()\n\n // Check if the arrays are different\n const hasChanged =\n sortedCurrent.length !== sortedPrev.length ||\n sortedCurrent.some((id, index) => id !== sortedPrev[index])\n\n // Update ref and return new array only if changed\n if (hasChanged) {\n prevSelectedRowsRef.current = currentSelectedRows\n return currentSelectedRows\n }\n\n // Return the previous reference if no change\n return prevSelectedRowsRef.current\n }, [currentSelectedRows])\n\n // Select all rows in the grid\n const selectAllRows = useCallback(() => {\n const allRowIds = Array.from(gridMap.rowIdToIndex.keys())\n const newSelection = new Set<CellId>()\n\n // Create cells for each row with the row selection column ID\n allRowIds.forEach((rowId) => {\n newSelection.add(getCellId(rowId, ROW_SELECTION_COLUMN_ID))\n })\n\n setSelectedCells(newSelection)\n // If there are rows, set focus to the first one\n if (allRowIds.length > 0) {\n const firstCellId = getCellId(allRowIds[0], ROW_SELECTION_COLUMN_ID)\n setFocusedCellId(firstCellId)\n setAnchorCell(parseCellId(firstCellId))\n }\n }, [gridMap])\n\n // clear rows selection\n const clearRowsSelection = useCallback(() => {\n setSelectedCells((prev) => {\n const newSelection = new Set(prev)\n Array.from(newSelection).forEach((cellId) => {\n if (parseCellId(cellId)?.colId === ROW_SELECTION_COLUMN_ID) {\n newSelection.delete(cellId)\n }\n })\n return newSelection\n })\n }, [setSelectedCells])\n\n // check if a row is selected (using selectedRows array)\n const isRowSelected = useCallback(\n (rowId: RowId) => {\n return selectedRows.includes(rowId)\n },\n [selectedRows],\n )\n\n // Check if all rows are selected\n const areAllRowsSelected = useCallback(() => {\n const totalRows = gridMap.rowIdToIndex.size\n return totalRows > 0 && selectedRows.length === totalRows\n }, [gridMap, selectedRows])\n\n // Check if some but not all rows are selected\n const areSomeRowsSelected = useCallback(() => {\n return selectedRows.length > 0 && !areAllRowsSelected()\n }, [selectedRows, areAllRowsSelected])\n\n const value = useMemo(() => {\n return {\n selectedRows,\n selectAllRows,\n clearRowsSelection,\n isRowSelected,\n areAllRowsSelected,\n areSomeRowsSelected,\n }\n }, [selectedRows, selectAllRows, areAllRowsSelected, areSomeRowsSelected, clearRowsSelection])\n\n return <SelectedRowsContext.Provider value={value}>{children}</SelectedRowsContext.Provider>\n}\n"],"names":["jsx"],"mappings":";;;;;AASO,MAAM,uBAAuB,CAAC,EAAE,eAA0C;AAC/E,QAAM,EAAE,eAAe,SAAS,kBAAkB,kBAAkB,kBAClE,yBAAyB;AACrB,QAAA,sBAAsB,OAAiB,EAAE;AAG/C,QAAM,sBAAsB;AAAA,IAC1B,MACE,MAAM,KAAK,aAAa,EACrB;AAAA,MACC,CAAC;;AACC,kCAAY,MAAM,MAAlB,mBAAqB,WAAU,6BAA2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gBAAgB,CAAC;AAGrB,QAAM,gBAAgB;AAAA,IACpB,CAAC,UAAiB;AACT,aAAA,aAAa,SAAS,KAAK;AAAA,IACpC;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAGM,QAAA,qBAAqB,YAAY,MAAM;AACrC,UAAA,YAAY,QAAQ,aAAa;AAChC,WAAA,YAAY,KAAK,aAAa,WAAW;AAAA,EAAA,GAC/C,CAAC,SAAS,YAAY,CAAC;AAGpB,QAAA,sBAAsB,YAAY,MAAM;AAC5C,WAAO,aAAa,SAAS,KAAK,CAAC,mBAAmB;AAAA,EAAA,GACrD,CAAC,cAAc,kBAAkB,CAAC;AAE/B,QAAA,QAAQ,QAAQ,MAAM;AACnB,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA,GACC,CAAC,cAAc,eAAe,oBAAoB,qBAAqB,kBAAkB,CAAC;AAE7F,SAAQA,kCAAAA,IAAA,oBAAoB,UAApB,EAA6B,OAAe,SAAS,CAAA;AAC/D;"}
|
|
@@ -1,284 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("../../../../../_virtual/jsx-runtime.cjs.js");
|
|
4
3
|
const React = require("react");
|
|
5
|
-
const cellUtils = require("../utils/cellUtils.cjs.js");
|
|
6
|
-
const ProjectTreeTable = require("../ProjectTreeTable.cjs.js");
|
|
7
4
|
const ROW_SELECTION_COLUMN_ID = "__row_selection__";
|
|
8
5
|
const SelectionCellsContext = React.createContext(void 0);
|
|
9
|
-
const SelectionCellsProvider = ({ children }) => {
|
|
10
|
-
const [selectedCells, setSelectedCells] = React.useState(/* @__PURE__ */ new Set());
|
|
11
|
-
const [focusedCellId, setFocusedCellId] = React.useState(null);
|
|
12
|
-
const [selectionInProgress, setSelectionInProgress] = React.useState(false);
|
|
13
|
-
const [anchorCell, setAnchorCell] = React.useState(null);
|
|
14
|
-
const [gridMap, setGridMap] = React.useState({
|
|
15
|
-
rowIdToIndex: /* @__PURE__ */ new Map(),
|
|
16
|
-
colIdToIndex: /* @__PURE__ */ new Map(),
|
|
17
|
-
indexToRowId: /* @__PURE__ */ new Map(),
|
|
18
|
-
indexToColId: /* @__PURE__ */ new Map()
|
|
19
|
-
});
|
|
20
|
-
const mapToString = (map) => {
|
|
21
|
-
return JSON.stringify(Array.from(map.entries()));
|
|
22
|
-
};
|
|
23
|
-
const stableGridMap = React.useMemo(
|
|
24
|
-
() => gridMap,
|
|
25
|
-
[
|
|
26
|
-
mapToString(gridMap.rowIdToIndex),
|
|
27
|
-
mapToString(gridMap.colIdToIndex),
|
|
28
|
-
mapToString(gridMap.indexToRowId),
|
|
29
|
-
mapToString(gridMap.indexToColId)
|
|
30
|
-
]
|
|
31
|
-
);
|
|
32
|
-
const initialCellSelected = React.useRef(false);
|
|
33
|
-
const selectedRows = React.useMemo(
|
|
34
|
-
() => Array.from(selectedCells).filter(
|
|
35
|
-
(cellId) => {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
return ((_a = cellUtils.parseCellId(cellId)) == null ? void 0 : _a.colId) === ROW_SELECTION_COLUMN_ID && ((_b = cellUtils.parseCellId(cellId)) == null ? void 0 : _b.rowId);
|
|
38
|
-
}
|
|
39
|
-
).map((cellId) => {
|
|
40
|
-
var _a;
|
|
41
|
-
return (_a = cellUtils.parseCellId(cellId)) == null ? void 0 : _a.rowId;
|
|
42
|
-
}),
|
|
43
|
-
[selectedCells]
|
|
44
|
-
);
|
|
45
|
-
const registerGrid = React.useCallback((rows, columns) => {
|
|
46
|
-
const rowIdToIndex = /* @__PURE__ */ new Map();
|
|
47
|
-
const colIdToIndex = /* @__PURE__ */ new Map();
|
|
48
|
-
const indexToRowId = /* @__PURE__ */ new Map();
|
|
49
|
-
const indexToColId = /* @__PURE__ */ new Map();
|
|
50
|
-
rows.forEach((rowId, index) => {
|
|
51
|
-
rowIdToIndex.set(rowId, index);
|
|
52
|
-
indexToRowId.set(index, rowId);
|
|
53
|
-
});
|
|
54
|
-
columns.forEach((colId, index) => {
|
|
55
|
-
colIdToIndex.set(colId, index);
|
|
56
|
-
indexToColId.set(index, colId);
|
|
57
|
-
});
|
|
58
|
-
setGridMap({ rowIdToIndex, colIdToIndex, indexToRowId, indexToColId });
|
|
59
|
-
}, []);
|
|
60
|
-
const updateSelection = React.useCallback((selection, position) => {
|
|
61
|
-
setSelectedCells((prevSelectedCells) => {
|
|
62
|
-
let newSelection = new Set(selection);
|
|
63
|
-
if (position.colId !== ROW_SELECTION_COLUMN_ID && position.colId !== ProjectTreeTable.DRAG_HANDLE_COLUMN_ID) {
|
|
64
|
-
const rowSelection = Array.from(prevSelectedCells).filter(
|
|
65
|
-
(id) => {
|
|
66
|
-
var _a;
|
|
67
|
-
return ((_a = cellUtils.parseCellId(id)) == null ? void 0 : _a.colId) === ROW_SELECTION_COLUMN_ID;
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
if (rowSelection.length) {
|
|
71
|
-
newSelection = /* @__PURE__ */ new Set([...newSelection, ...rowSelection]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return newSelection;
|
|
75
|
-
});
|
|
76
|
-
}, []);
|
|
77
|
-
const selectCellRange = React.useCallback(
|
|
78
|
-
(start, end, additive) => {
|
|
79
|
-
if (!additive) {
|
|
80
|
-
updateSelection(/* @__PURE__ */ new Set(), start);
|
|
81
|
-
}
|
|
82
|
-
const startRowIdx = stableGridMap.rowIdToIndex.get(start.rowId) ?? 0;
|
|
83
|
-
const startColIdx = stableGridMap.colIdToIndex.get(start.colId) ?? 0;
|
|
84
|
-
const endRowIdx = stableGridMap.rowIdToIndex.get(end.rowId) ?? 0;
|
|
85
|
-
const endColIdx = stableGridMap.colIdToIndex.get(end.colId) ?? 0;
|
|
86
|
-
const minRowIdx = Math.min(startRowIdx, endRowIdx);
|
|
87
|
-
const maxRowIdx = Math.max(startRowIdx, endRowIdx);
|
|
88
|
-
const minColIdx = Math.min(startColIdx, endColIdx);
|
|
89
|
-
const maxColIdx = Math.max(startColIdx, endColIdx);
|
|
90
|
-
const newSelection = new Set(additive ? selectedCells : []);
|
|
91
|
-
for (let r = minRowIdx; r <= maxRowIdx; r++) {
|
|
92
|
-
const rowId = stableGridMap.indexToRowId.get(r);
|
|
93
|
-
if (!rowId) continue;
|
|
94
|
-
for (let c = minColIdx; c <= maxColIdx; c++) {
|
|
95
|
-
const colId = stableGridMap.indexToColId.get(c);
|
|
96
|
-
if (!colId) continue;
|
|
97
|
-
newSelection.add(cellUtils.getCellId(rowId, colId));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return newSelection;
|
|
101
|
-
},
|
|
102
|
-
[stableGridMap, selectedCells]
|
|
103
|
-
);
|
|
104
|
-
const startSelection = React.useCallback(
|
|
105
|
-
(cellId, additive) => {
|
|
106
|
-
const position = cellUtils.parseCellId(cellId);
|
|
107
|
-
if (!position) return;
|
|
108
|
-
setSelectionInProgress(true);
|
|
109
|
-
initialCellSelected.current = selectedCells.has(cellId);
|
|
110
|
-
if (additive) {
|
|
111
|
-
setSelectedCells((prev) => {
|
|
112
|
-
const newSelection = new Set(prev);
|
|
113
|
-
if (newSelection.has(cellId)) {
|
|
114
|
-
newSelection.delete(cellId);
|
|
115
|
-
if (focusedCellId === cellId) {
|
|
116
|
-
if (newSelection.size > 0) {
|
|
117
|
-
setFocusedCellId(Array.from(newSelection)[Array.from(newSelection).length - 1]);
|
|
118
|
-
} else {
|
|
119
|
-
setFocusedCellId(null);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
newSelection.add(cellId);
|
|
124
|
-
setFocusedCellId(cellId);
|
|
125
|
-
setAnchorCell(position);
|
|
126
|
-
}
|
|
127
|
-
return newSelection;
|
|
128
|
-
});
|
|
129
|
-
} else {
|
|
130
|
-
if (selectedCells.size === 1 && selectedCells.has(cellId) && [ROW_SELECTION_COLUMN_ID, "name"].includes(position.colId)) {
|
|
131
|
-
setSelectedCells(/* @__PURE__ */ new Set());
|
|
132
|
-
setAnchorCell(null);
|
|
133
|
-
setFocusedCellId(null);
|
|
134
|
-
} else {
|
|
135
|
-
updateSelection(/* @__PURE__ */ new Set([cellId]), position);
|
|
136
|
-
setAnchorCell(position);
|
|
137
|
-
setFocusedCellId(cellId);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
[selectedCells, focusedCellId]
|
|
142
|
-
);
|
|
143
|
-
const extendSelection = React.useCallback(
|
|
144
|
-
(cellId, isRowSelectionColumn) => {
|
|
145
|
-
if (!selectionInProgress || !anchorCell) return;
|
|
146
|
-
const currentPosition = cellUtils.parseCellId(cellId);
|
|
147
|
-
if (!currentPosition) return;
|
|
148
|
-
if (isRowSelectionColumn) {
|
|
149
|
-
setSelectedCells((prev) => {
|
|
150
|
-
const newSelection = new Set(prev);
|
|
151
|
-
const position = cellUtils.parseCellId(cellId);
|
|
152
|
-
if (!position) return newSelection;
|
|
153
|
-
if (initialCellSelected.current) {
|
|
154
|
-
newSelection.delete(cellId);
|
|
155
|
-
} else {
|
|
156
|
-
newSelection.add(cellId);
|
|
157
|
-
}
|
|
158
|
-
return newSelection;
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
const newSelection = selectCellRange(anchorCell, currentPosition, false);
|
|
162
|
-
updateSelection(newSelection, currentPosition);
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
[selectionInProgress, anchorCell, selectCellRange]
|
|
166
|
-
);
|
|
167
|
-
const endSelection = React.useCallback(() => {
|
|
168
|
-
setSelectionInProgress(false);
|
|
169
|
-
}, []);
|
|
170
|
-
const selectCell = React.useCallback(
|
|
171
|
-
(cellId, additive, range) => {
|
|
172
|
-
const position = cellUtils.parseCellId(cellId);
|
|
173
|
-
if (!position) return;
|
|
174
|
-
if (range && anchorCell) {
|
|
175
|
-
const newSelection = selectCellRange(anchorCell, position, additive);
|
|
176
|
-
updateSelection(newSelection, position);
|
|
177
|
-
} else if (additive) {
|
|
178
|
-
setSelectedCells((prev) => {
|
|
179
|
-
const newSelection = new Set(prev);
|
|
180
|
-
if (newSelection.has(cellId)) {
|
|
181
|
-
newSelection.delete(cellId);
|
|
182
|
-
} else {
|
|
183
|
-
newSelection.add(cellId);
|
|
184
|
-
}
|
|
185
|
-
return newSelection;
|
|
186
|
-
});
|
|
187
|
-
} else {
|
|
188
|
-
updateSelection(/* @__PURE__ */ new Set([cellId]), position);
|
|
189
|
-
setAnchorCell(position);
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
[anchorCell, selectCellRange]
|
|
193
|
-
);
|
|
194
|
-
const focusCell = React.useCallback((cellId) => {
|
|
195
|
-
setFocusedCellId(cellId);
|
|
196
|
-
}, []);
|
|
197
|
-
const clearSelection = React.useCallback(() => {
|
|
198
|
-
setSelectedCells(/* @__PURE__ */ new Set());
|
|
199
|
-
setAnchorCell(null);
|
|
200
|
-
setFocusedCellId(null);
|
|
201
|
-
}, []);
|
|
202
|
-
const isCellSelected = React.useCallback((cellId) => selectedCells.has(cellId), [selectedCells]);
|
|
203
|
-
const isCellFocused = React.useCallback((cellId) => cellId === focusedCellId, [focusedCellId]);
|
|
204
|
-
const getCellPositionFromId = React.useCallback((cellId) => cellUtils.parseCellId(cellId), []);
|
|
205
|
-
const getCellBorderClasses = React.useCallback(
|
|
206
|
-
(cellId) => {
|
|
207
|
-
if (!isCellSelected(cellId)) return [];
|
|
208
|
-
const position = cellUtils.parseCellId(cellId);
|
|
209
|
-
if (!position) return [];
|
|
210
|
-
const rowIndex = stableGridMap.rowIdToIndex.get(position.rowId);
|
|
211
|
-
const colIndex = stableGridMap.colIdToIndex.get(position.colId);
|
|
212
|
-
if (rowIndex === void 0 || colIndex === void 0) return [];
|
|
213
|
-
const top = stableGridMap.indexToRowId.get(rowIndex - 1);
|
|
214
|
-
const right = stableGridMap.indexToColId.get(colIndex + 1);
|
|
215
|
-
const bottom = stableGridMap.indexToRowId.get(rowIndex + 1);
|
|
216
|
-
const left = stableGridMap.indexToColId.get(colIndex - 1);
|
|
217
|
-
let borderPos = cellUtils.BorderPosition.None;
|
|
218
|
-
if (!top || !selectedCells.has(cellUtils.getCellId(top, position.colId))) {
|
|
219
|
-
borderPos |= cellUtils.BorderPosition.Top;
|
|
220
|
-
}
|
|
221
|
-
if (!right || !selectedCells.has(cellUtils.getCellId(position.rowId, right))) {
|
|
222
|
-
borderPos |= cellUtils.BorderPosition.Right;
|
|
223
|
-
}
|
|
224
|
-
if (!bottom || !selectedCells.has(cellUtils.getCellId(bottom, position.colId))) {
|
|
225
|
-
borderPos |= cellUtils.BorderPosition.Bottom;
|
|
226
|
-
}
|
|
227
|
-
if (!left || !selectedCells.has(cellUtils.getCellId(position.rowId, left))) {
|
|
228
|
-
borderPos |= cellUtils.BorderPosition.Left;
|
|
229
|
-
}
|
|
230
|
-
return cellUtils.getBorderClasses(borderPos);
|
|
231
|
-
},
|
|
232
|
-
[selectedCells, stableGridMap, isCellSelected]
|
|
233
|
-
);
|
|
234
|
-
const value = React.useMemo(
|
|
235
|
-
() => ({
|
|
236
|
-
selectedCells,
|
|
237
|
-
selectedRows,
|
|
238
|
-
focusedCellId,
|
|
239
|
-
selectionInProgress,
|
|
240
|
-
anchorCell,
|
|
241
|
-
gridMap: stableGridMap,
|
|
242
|
-
setSelectedCells,
|
|
243
|
-
setFocusedCellId,
|
|
244
|
-
setAnchorCell,
|
|
245
|
-
registerGrid,
|
|
246
|
-
selectCell,
|
|
247
|
-
startSelection,
|
|
248
|
-
extendSelection,
|
|
249
|
-
endSelection,
|
|
250
|
-
focusCell,
|
|
251
|
-
clearSelection,
|
|
252
|
-
isCellSelected,
|
|
253
|
-
isCellFocused,
|
|
254
|
-
getCellPositionFromId,
|
|
255
|
-
getCellBorderClasses
|
|
256
|
-
}),
|
|
257
|
-
[
|
|
258
|
-
selectedCells,
|
|
259
|
-
selectedRows,
|
|
260
|
-
focusedCellId,
|
|
261
|
-
selectionInProgress,
|
|
262
|
-
anchorCell,
|
|
263
|
-
stableGridMap,
|
|
264
|
-
setSelectedCells,
|
|
265
|
-
setFocusedCellId,
|
|
266
|
-
setAnchorCell,
|
|
267
|
-
registerGrid,
|
|
268
|
-
selectCell,
|
|
269
|
-
startSelection,
|
|
270
|
-
extendSelection,
|
|
271
|
-
endSelection,
|
|
272
|
-
focusCell,
|
|
273
|
-
clearSelection,
|
|
274
|
-
isCellSelected,
|
|
275
|
-
isCellFocused,
|
|
276
|
-
getCellPositionFromId,
|
|
277
|
-
getCellBorderClasses
|
|
278
|
-
]
|
|
279
|
-
);
|
|
280
|
-
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(SelectionCellsContext.Provider, { value, children });
|
|
281
|
-
};
|
|
282
6
|
const useSelectionCellsContext = () => {
|
|
283
7
|
const context = React.useContext(SelectionCellsContext);
|
|
284
8
|
if (context === void 0) {
|
|
@@ -287,6 +11,6 @@ const useSelectionCellsContext = () => {
|
|
|
287
11
|
return context;
|
|
288
12
|
};
|
|
289
13
|
exports.ROW_SELECTION_COLUMN_ID = ROW_SELECTION_COLUMN_ID;
|
|
290
|
-
exports.
|
|
14
|
+
exports.SelectionCellsContext = SelectionCellsContext;
|
|
291
15
|
exports.useSelectionCellsContext = useSelectionCellsContext;
|
|
292
16
|
//# sourceMappingURL=SelectionCellsContext.cjs.js.map
|
package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsContext.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionCellsContext.cjs.js","sources":["../../../../../../src/containers/ProjectTreeTable/context/SelectionCellsContext.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n ReactNode,\n useRef,\n} from 'react'\nimport {\n CellId,\n RowId,\n ColId,\n CellPosition,\n getCellId,\n parseCellId,\n BorderPosition,\n getBorderClasses,\n} from '../utils/cellUtils'\nimport { DRAG_HANDLE_COLUMN_ID } from '../ProjectTreeTable'\n\nexport const ROW_SELECTION_COLUMN_ID = '__row_selection__' // ID for the row selection column\n\n// Cell range for selections\n\n// Structure to map row/column IDs to their positions in the grid\nexport interface GridMap {\n rowIdToIndex: Map<RowId, number>\n colIdToIndex: Map<ColId, number>\n indexToRowId: Map<number, RowId>\n indexToColId: Map<number, ColId>\n}\n\nexport interface SelectionCellsContextType {\n // Selected cells\n selectedCells: Set<CellId>\n // Focused cell (single cell that has focus)\n focusedCellId: CellId | null\n // Selection in progress state\n selectionInProgress: boolean\n // Anchor point for range selections\n anchorCell: CellPosition | null\n // Grid mapping for coordinate lookups\n gridMap: GridMap\n\n selectedRows: string[] // Array of selected row IDs\n\n // State setters\n setSelectedCells: React.Dispatch<React.SetStateAction<Set<CellId>>>\n setFocusedCellId: React.Dispatch<React.SetStateAction<CellId | null>>\n setAnchorCell: React.Dispatch<React.SetStateAction<CellPosition | null>>\n // Methods\n registerGrid: (rows: RowId[], columns: ColId[]) => void\n selectCell: (cellId: CellId, additive: boolean, range: boolean) => void\n startSelection: (cellId: CellId, additive: boolean) => void\n extendSelection: (cellId: CellId, isRowSelectionColumn?: boolean) => void\n endSelection: (cellId: CellId) => void\n focusCell: (cellId: CellId | null) => void\n clearSelection: () => void\n isCellSelected: (cellId: CellId) => boolean\n isCellFocused: (cellId: CellId) => boolean\n getCellPositionFromId: (cellId: CellId) => CellPosition | null\n getCellBorderClasses: (cellId: CellId) => string[]\n}\n\n// Create the context\nconst SelectionCellsContext = createContext<SelectionCellsContextType | undefined>(undefined)\n\nexport const SelectionCellsProvider: React.FC<{ children: ReactNode }> = ({ children }) => {\n const [selectedCells, setSelectedCells] = useState<Set<CellId>>(new Set())\n const [focusedCellId, setFocusedCellId] = useState<CellId | null>(null)\n const [selectionInProgress, setSelectionInProgress] = useState<boolean>(false)\n const [anchorCell, setAnchorCell] = useState<CellPosition | null>(null)\n const [gridMap, setGridMap] = useState<GridMap>({\n rowIdToIndex: new Map(),\n colIdToIndex: new Map(),\n indexToRowId: new Map(),\n indexToColId: new Map(),\n })\n const mapToString = (map: Map<any, any>) => {\n return JSON.stringify(Array.from(map.entries()))\n }\n\n const stableGridMap = useMemo(\n () => gridMap,\n [\n mapToString(gridMap.rowIdToIndex),\n mapToString(gridMap.colIdToIndex),\n mapToString(gridMap.indexToRowId),\n mapToString(gridMap.indexToColId),\n ],\n )\n // Track whether we're selecting or unselecting during drag\n const initialCellSelected = useRef<boolean>(false)\n\n const selectedRows = useMemo(\n () =>\n Array.from(selectedCells)\n .filter(\n (cellId) =>\n parseCellId(cellId)?.colId === ROW_SELECTION_COLUMN_ID && parseCellId(cellId)?.rowId,\n )\n .map((cellId) => parseCellId(cellId)?.rowId) as string[],\n [selectedCells],\n )\n\n // Register grid structure for range selections\n const registerGrid = useCallback((rows: RowId[], columns: ColId[]) => {\n const rowIdToIndex = new Map<RowId, number>()\n const colIdToIndex = new Map<ColId, number>()\n const indexToRowId = new Map<number, RowId>()\n const indexToColId = new Map<number, ColId>()\n\n rows.forEach((rowId, index) => {\n rowIdToIndex.set(rowId, index)\n indexToRowId.set(index, rowId)\n })\n\n columns.forEach((colId, index) => {\n colIdToIndex.set(colId, index)\n indexToColId.set(index, colId)\n })\n\n setGridMap({ rowIdToIndex, colIdToIndex, indexToRowId, indexToColId })\n }, [])\n\n // update the selection whilst properly handling the row-selection column\n const updateSelection = useCallback((selection: Set<CellId>, position: CellPosition) => {\n setSelectedCells((prevSelectedCells) => {\n let newSelection = new Set(selection)\n if (position.colId !== ROW_SELECTION_COLUMN_ID && position.colId !== DRAG_HANDLE_COLUMN_ID) {\n const rowSelection = Array.from(prevSelectedCells).filter(\n (id) => parseCellId(id)?.colId === ROW_SELECTION_COLUMN_ID,\n )\n if (rowSelection.length) {\n newSelection = new Set([...newSelection, ...rowSelection])\n }\n }\n return newSelection\n })\n }, [])\n\n // Select cells between two points in the grid\n const selectCellRange = useCallback(\n (start: CellPosition, end: CellPosition, additive: boolean): Set<CellId> => {\n if (!additive) {\n // Clear existing selection if not additive\n updateSelection(new Set(), start)\n }\n\n const startRowIdx = stableGridMap.rowIdToIndex.get(start.rowId) ?? 0\n const startColIdx = stableGridMap.colIdToIndex.get(start.colId) ?? 0\n const endRowIdx = stableGridMap.rowIdToIndex.get(end.rowId) ?? 0\n const endColIdx = stableGridMap.colIdToIndex.get(end.colId) ?? 0\n\n const minRowIdx = Math.min(startRowIdx, endRowIdx)\n const maxRowIdx = Math.max(startRowIdx, endRowIdx)\n const minColIdx = Math.min(startColIdx, endColIdx)\n const maxColIdx = Math.max(startColIdx, endColIdx)\n\n const newSelection = new Set(additive ? selectedCells : [])\n\n for (let r = minRowIdx; r <= maxRowIdx; r++) {\n const rowId = stableGridMap.indexToRowId.get(r)\n if (!rowId) continue\n\n for (let c = minColIdx; c <= maxColIdx; c++) {\n const colId = stableGridMap.indexToColId.get(c)\n if (!colId) continue\n\n newSelection.add(getCellId(rowId, colId))\n }\n }\n\n return newSelection\n },\n [stableGridMap, selectedCells],\n )\n\n // Start a selection operation\n const startSelection = useCallback(\n (cellId: CellId, additive: boolean) => {\n const position = parseCellId(cellId)\n if (!position) return\n\n setSelectionInProgress(true)\n // Store whether the initial cell was selected to determine drag behavior\n initialCellSelected.current = selectedCells.has(cellId)\n\n if (additive) {\n // Toggle this cell in multi-select mode\n setSelectedCells((prev) => {\n const newSelection = new Set(prev)\n if (newSelection.has(cellId)) {\n newSelection.delete(cellId)\n // If this was the focused cell, set focus to another cell in the selection or null\n if (focusedCellId === cellId) {\n if (newSelection.size > 0) {\n setFocusedCellId(Array.from(newSelection)[Array.from(newSelection).length - 1])\n } else {\n setFocusedCellId(null)\n }\n }\n } else {\n newSelection.add(cellId)\n setFocusedCellId(cellId)\n setAnchorCell(position)\n }\n return newSelection\n })\n } else {\n // Single cell selection\n // If this cell is already the only selected cell, deselect it\n // and it is from name column\n if (\n selectedCells.size === 1 &&\n selectedCells.has(cellId) &&\n [ROW_SELECTION_COLUMN_ID, 'name'].includes(position.colId)\n ) {\n setSelectedCells(new Set())\n setAnchorCell(null)\n setFocusedCellId(null)\n } else {\n updateSelection(new Set([cellId]), position)\n setAnchorCell(position)\n setFocusedCellId(cellId)\n }\n }\n },\n [selectedCells, focusedCellId],\n )\n\n // Extend the current selection during drag\n const extendSelection = useCallback(\n (cellId: CellId, isRowSelectionColumn?: boolean) => {\n if (!selectionInProgress || !anchorCell) return\n\n const currentPosition = parseCellId(cellId)\n if (!currentPosition) return\n\n if (isRowSelectionColumn) {\n // Handle row selection column differently during drag\n setSelectedCells((prev) => {\n const newSelection = new Set(prev)\n const position = parseCellId(cellId)\n\n if (!position) return newSelection\n\n // We're either selecting or unselecting based on the initial cell's state\n if (initialCellSelected.current) {\n // If we started on a selected cell, we're removing cells during drag\n newSelection.delete(cellId)\n } else {\n // If we started on an unselected cell, we're adding cells during drag\n newSelection.add(cellId)\n }\n\n return newSelection\n })\n } else {\n // For normal cells, use the range selection behavior\n const newSelection = selectCellRange(anchorCell, currentPosition, false)\n updateSelection(newSelection, currentPosition)\n }\n },\n [selectionInProgress, anchorCell, selectCellRange],\n )\n\n // End a selection operation\n const endSelection = useCallback(() => {\n setSelectionInProgress(false)\n }, [])\n\n // Select a cell (click or programmatically)\n const selectCell = useCallback(\n (cellId: CellId, additive: boolean, range: boolean) => {\n const position = parseCellId(cellId)\n if (!position) return\n\n if (range && anchorCell) {\n // Shift+click for range selection - select cells between anchor and current\n const newSelection = selectCellRange(anchorCell, position, additive)\n updateSelection(newSelection, position)\n } else if (additive) {\n // Ctrl/Cmd+click for toggling selection\n setSelectedCells((prev) => {\n const newSelection = new Set(prev)\n if (newSelection.has(cellId)) {\n newSelection.delete(cellId)\n } else {\n newSelection.add(cellId)\n }\n return newSelection\n })\n } else {\n // Normal click - select just this cell and set as new anchor\n updateSelection(new Set([cellId]), position)\n setAnchorCell(position)\n }\n },\n [anchorCell, selectCellRange],\n )\n\n // Focus a cell without changing selection\n const focusCell = useCallback((cellId: CellId | null) => {\n setFocusedCellId(cellId)\n }, [])\n\n // Clear all selections\n const clearSelection = useCallback(() => {\n setSelectedCells(new Set())\n setAnchorCell(null)\n setFocusedCellId(null)\n }, [])\n\n // Check if a cell is selected\n const isCellSelected = useCallback((cellId: CellId) => selectedCells.has(cellId), [selectedCells])\n\n // Check if a cell is focused\n const isCellFocused = useCallback((cellId: CellId) => cellId === focusedCellId, [focusedCellId])\n\n // Get position from cell ID - using shared utility\n const getCellPositionFromId = useCallback((cellId: CellId) => parseCellId(cellId), [])\n\n // Get border classes for a cell based on its selection state and neighbors\n const getCellBorderClasses = useCallback(\n (cellId: CellId): string[] => {\n if (!isCellSelected(cellId)) return []\n\n const position = parseCellId(cellId)\n if (!position) return []\n\n const rowIndex = stableGridMap.rowIdToIndex.get(position.rowId)\n const colIndex = stableGridMap.colIdToIndex.get(position.colId)\n\n if (rowIndex === undefined || colIndex === undefined) return []\n\n // Check if the cell's neighbors in all four directions are selected\n const top = stableGridMap.indexToRowId.get(rowIndex - 1)\n const right = stableGridMap.indexToColId.get(colIndex + 1)\n const bottom = stableGridMap.indexToRowId.get(rowIndex + 1)\n const left = stableGridMap.indexToColId.get(colIndex - 1)\n\n // Default to no borders\n let borderPos = BorderPosition.None\n\n // Top edge check: show border if we're at the top of the grid or the cell above is not selected\n if (!top || !selectedCells.has(getCellId(top, position.colId))) {\n borderPos |= BorderPosition.Top\n }\n\n // Right edge check: show border if we're at the right edge of the grid or the cell to the right is not selected\n if (!right || !selectedCells.has(getCellId(position.rowId, right))) {\n borderPos |= BorderPosition.Right\n }\n\n // Bottom edge check: show border if we're at the bottom of the grid or the cell below is not selected\n if (!bottom || !selectedCells.has(getCellId(bottom, position.colId))) {\n borderPos |= BorderPosition.Bottom\n }\n\n // Left edge check: show border if we're at the left edge of the grid or the cell to the left is not selected\n if (!left || !selectedCells.has(getCellId(position.rowId, left))) {\n borderPos |= BorderPosition.Left\n }\n\n return getBorderClasses(borderPos)\n },\n [selectedCells, stableGridMap, isCellSelected],\n )\n\n // Memoize context value to prevent unnecessary re-renders\n const value = useMemo(\n () => ({\n selectedCells,\n selectedRows,\n focusedCellId,\n selectionInProgress,\n anchorCell,\n gridMap: stableGridMap,\n setSelectedCells,\n setFocusedCellId,\n setAnchorCell,\n registerGrid,\n selectCell,\n startSelection,\n extendSelection,\n endSelection,\n focusCell,\n clearSelection,\n isCellSelected,\n isCellFocused,\n getCellPositionFromId,\n getCellBorderClasses,\n }),\n [\n selectedCells,\n selectedRows,\n focusedCellId,\n selectionInProgress,\n anchorCell,\n stableGridMap,\n setSelectedCells,\n setFocusedCellId,\n setAnchorCell,\n registerGrid,\n selectCell,\n startSelection,\n extendSelection,\n endSelection,\n focusCell,\n clearSelection,\n isCellSelected,\n isCellFocused,\n getCellPositionFromId,\n getCellBorderClasses,\n ],\n )\n\n return <SelectionCellsContext.Provider value={value}>{children}</SelectionCellsContext.Provider>\n}\n\nexport const useSelectionCellsContext = (): SelectionCellsContextType => {\n const context = useContext(SelectionCellsContext)\n if (context === undefined) {\n throw new Error('useSelectionCellsContext must be used within a SelectionCellsProvider')\n }\n return context\n}\n"],"names":["createContext","useState","useMemo","useRef","parseCellId","useCallback","DRAG_HANDLE_COLUMN_ID","getCellId","BorderPosition","getBorderClasses","jsx","useContext"],"mappings":";;;;;;AAqBO,MAAM,0BAA0B;AA6CvC,MAAM,wBAAwBA,oBAAqD,MAAS;AAErF,MAAM,yBAA4D,CAAC,EAAE,eAAe;AACzF,QAAM,CAAC,eAAe,gBAAgB,IAAIC,MAAAA,SAAsB,oBAAI,KAAK;AACzE,QAAM,CAAC,eAAe,gBAAgB,IAAIA,MAAAA,SAAwB,IAAI;AACtE,QAAM,CAAC,qBAAqB,sBAAsB,IAAIA,MAAAA,SAAkB,KAAK;AAC7E,QAAM,CAAC,YAAY,aAAa,IAAIA,MAAAA,SAA8B,IAAI;AACtE,QAAM,CAAC,SAAS,UAAU,IAAIA,eAAkB;AAAA,IAC9C,kCAAkB,IAAI;AAAA,IACtB,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":["../../../../../../src/containers/ProjectTreeTable/context/SelectionCellsContext.ts"],"sourcesContent":["import React, { createContext, useContext } from 'react'\nimport {\n CellId,\n RowId,\n ColId,\n CellPosition,\n} from '../utils/cellUtils'\n\nexport const ROW_SELECTION_COLUMN_ID = '__row_selection__' // ID for the row selection column\n\n// Structure to map row/column IDs to their positions in the grid\nexport interface GridMap {\n rowIdToIndex: Map<RowId, number>\n colIdToIndex: Map<ColId, number>\n indexToRowId: Map<number, RowId>\n indexToColId: Map<number, ColId>\n}\n\nexport interface SelectionCellsContextType {\n // Selected cells\n selectedCells: Set<CellId>\n // Focused cell (single cell that has focus)\n focusedCellId: CellId | null\n // Selection in progress state\n selectionInProgress: boolean\n // Anchor point for range selections\n anchorCell: CellPosition | null\n // Grid mapping for coordinate lookups\n gridMap: GridMap\n\n selectedRows: string[] // Array of selected row IDs\n\n // State setters\n setSelectedCells: React.Dispatch<React.SetStateAction<Set<CellId>>>\n setFocusedCellId: React.Dispatch<React.SetStateAction<CellId | null>>\n setAnchorCell: React.Dispatch<React.SetStateAction<CellPosition | null>>\n // Methods\n registerGrid: (rows: RowId[], columns: ColId[]) => void\n selectCell: (cellId: CellId, additive: boolean, range: boolean) => void\n startSelection: (cellId: CellId, additive: boolean) => void\n extendSelection: (cellId: CellId, isRowSelectionColumn?: boolean) => void\n endSelection: (cellId: CellId) => void\n focusCell: (cellId: CellId | null) => void\n clearSelection: () => void\n isCellSelected: (cellId: CellId) => boolean\n isCellFocused: (cellId: CellId) => boolean\n getCellPositionFromId: (cellId: CellId) => CellPosition | null\n getCellBorderClasses: (cellId: CellId) => string[]\n}\n\n// Create the context\nexport const SelectionCellsContext = createContext<SelectionCellsContextType | undefined>(undefined)\n\nexport const useSelectionCellsContext = (): SelectionCellsContextType => {\n const context = useContext(SelectionCellsContext)\n if (context === undefined) {\n throw new Error('useSelectionCellsContext must be used within a SelectionCellsProvider')\n }\n return context\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAQO,MAAM,0BAA0B;AA2C1B,MAAA,wBAAwBA,oBAAqD,MAAS;AAE5F,MAAM,2BAA2B,MAAiC;AACjE,QAAA,UAAUC,iBAAW,qBAAqB;AAChD,MAAI,YAAY,QAAW;AACnB,UAAA,IAAI,MAAM,uEAAuE;AAAA,EAAA;AAElF,SAAA;AACT;;;;"}
|