ff-step-table 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/lib/components/EditLabel/EditLabel.d.ts +1 -1
  2. package/lib/components/EditLabel/EditLabel.js +2 -2
  3. package/lib/components/EditLabel/EditLabel.js.map +1 -1
  4. package/lib/components/EditLabel/types.d.ts +1 -0
  5. package/lib/components/Icon/Icon.js +2 -2
  6. package/lib/components/Icon/Icon.js.map +1 -1
  7. package/lib/components/Icon/iconList.js +2 -0
  8. package/lib/components/Icon/iconList.js.map +1 -1
  9. package/lib/components/StatusButton/StatusButton.js +2 -2
  10. package/lib/components/StatusButton/StatusButton.js.map +1 -1
  11. package/lib/components/StepsLandingTable/StepLandingTable.d.ts +0 -1
  12. package/lib/components/StepsLandingTable/StepLandingTable.js +160 -447
  13. package/lib/components/StepsLandingTable/StepLandingTable.js.map +1 -1
  14. package/lib/components/StepsLandingTable/types.d.ts +1 -0
  15. package/lib/components/StepsLandingTableV2/StepLandingTable.d.ts +6 -0
  16. package/lib/components/StepsLandingTableV2/StepLandingTable.js +682 -0
  17. package/lib/components/StepsLandingTableV2/StepLandingTable.js.map +1 -0
  18. package/lib/components/StepsLandingTableV2/compat/legacyAdapter.d.ts +10 -0
  19. package/lib/components/StepsLandingTableV2/compat/legacyAdapter.js +35 -0
  20. package/lib/components/StepsLandingTableV2/compat/legacyAdapter.js.map +1 -0
  21. package/lib/components/StepsLandingTableV2/index.d.ts +4 -0
  22. package/lib/components/StepsLandingTableV2/index.js +5 -0
  23. package/lib/components/StepsLandingTableV2/index.js.map +1 -0
  24. package/lib/components/StepsLandingTableV2/model/blockGraph.d.ts +12 -0
  25. package/lib/components/StepsLandingTableV2/model/blockGraph.js +167 -0
  26. package/lib/components/StepsLandingTableV2/model/blockGraph.js.map +1 -0
  27. package/lib/components/StepsLandingTableV2/model/normalize.d.ts +10 -0
  28. package/lib/components/StepsLandingTableV2/model/normalize.js +166 -0
  29. package/lib/components/StepsLandingTableV2/model/normalize.js.map +1 -0
  30. package/lib/components/StepsLandingTableV2/model/rowClassification.d.ts +14 -0
  31. package/lib/components/StepsLandingTableV2/model/rowClassification.js +132 -0
  32. package/lib/components/StepsLandingTableV2/model/rowClassification.js.map +1 -0
  33. package/lib/components/StepsLandingTableV2/model/types.d.ts +108 -0
  34. package/lib/components/StepsLandingTableV2/model/types.js.map +1 -0
  35. package/lib/components/StepsLandingTableV2/selection/IntervalSelection.d.ts +18 -0
  36. package/lib/components/StepsLandingTableV2/selection/IntervalSelection.js +133 -0
  37. package/lib/components/StepsLandingTableV2/selection/IntervalSelection.js.map +1 -0
  38. package/lib/components/StepsLandingTableV2/selection/selectionEngine.d.ts +23 -0
  39. package/lib/components/StepsLandingTableV2/selection/selectionEngine.js +221 -0
  40. package/lib/components/StepsLandingTableV2/selection/selectionEngine.js.map +1 -0
  41. package/lib/components/StepsLandingTableV2/store/store.d.ts +104 -0
  42. package/lib/components/StepsLandingTableV2/store/store.js +509 -0
  43. package/lib/components/StepsLandingTableV2/store/store.js.map +1 -0
  44. package/lib/components/StepsLandingTableV2/virtual/BlockPrefixIndex.d.ts +20 -0
  45. package/lib/components/StepsLandingTableV2/virtual/BlockPrefixIndex.js +112 -0
  46. package/lib/components/StepsLandingTableV2/virtual/BlockPrefixIndex.js.map +1 -0
  47. package/lib/components/StepsLandingTableV2/virtual/viewportController.d.ts +11 -0
  48. package/lib/components/StepsLandingTableV2/virtual/viewportController.js +55 -0
  49. package/lib/components/StepsLandingTableV2/virtual/viewportController.js.map +1 -0
  50. package/lib/components/StepsLandingTableV2/visible/ChunkedSequence.d.ts +24 -0
  51. package/lib/components/StepsLandingTableV2/visible/ChunkedSequence.js +189 -0
  52. package/lib/components/StepsLandingTableV2/visible/ChunkedSequence.js.map +1 -0
  53. package/lib/components/StepsLandingTableV2/visible/buildVisibleSequence.d.ts +4 -0
  54. package/lib/components/StepsLandingTableV2/visible/buildVisibleSequence.js +124 -0
  55. package/lib/components/StepsLandingTableV2/visible/buildVisibleSequence.js.map +1 -0
  56. package/lib/components/StepsLandingTableV2/visible/visibleTypes.d.ts +50 -0
  57. package/lib/components/StepsLandingTableV2/visible/visibleTypes.js +2 -0
  58. package/lib/components/StepsLandingTableV2/visible/visibleTypes.js.map +1 -0
  59. package/lib/components/StorageUsageBar/StorageUsageBar.d.ts +4 -0
  60. package/lib/components/StorageUsageBar/StorageUsageBar.js +9 -0
  61. package/lib/components/StorageUsageBar/StorageUsageBar.js.map +1 -0
  62. package/lib/components/StorageUsageBar/index.d.ts +1 -0
  63. package/lib/components/StorageUsageBar/index.js +2 -0
  64. package/lib/components/StorageUsageBar/index.js.map +1 -0
  65. package/lib/components/StorageUsageBar/types.d.ts +7 -0
  66. package/lib/components/StorageUsageBar/types.js +2 -0
  67. package/lib/components/StorageUsageBar/types.js.map +1 -0
  68. package/lib/components/TableTreeFn/Components/TableCell.js +1 -1
  69. package/lib/components/TableTreeFn/Components/TableCell.js.map +1 -1
  70. package/lib/components/TableTreeFn/TableTreeFn.js +25 -4
  71. package/lib/components/TableTreeFn/TableTreeFn.js.map +1 -1
  72. package/lib/components/Typography/Typography.js +2 -2
  73. package/lib/components/Typography/Typography.js.map +1 -1
  74. package/lib/components/ZoomControl/ZoomControl.d.ts +5 -0
  75. package/lib/components/ZoomControl/ZoomControl.js +22 -0
  76. package/lib/components/ZoomControl/ZoomControl.js.map +1 -0
  77. package/lib/components/ZoomControl/index.d.ts +1 -0
  78. package/lib/components/ZoomControl/index.js +2 -0
  79. package/lib/components/ZoomControl/index.js.map +1 -0
  80. package/lib/components/ZoomControl/types.d.ts +8 -0
  81. package/lib/components/ZoomControl/types.js +2 -0
  82. package/lib/components/ZoomControl/types.js.map +1 -0
  83. package/lib/index.d.ts +25 -2
  84. package/lib/index.js +9 -9
  85. package/lib/index.js.map +1 -1
  86. package/lib/styles.css +1 -1
  87. package/lib/styles.css.map +1 -1
  88. package/lib/tsconfig.tsbuildinfo +1 -1
  89. package/lib/utils/getTreeDetails/getTreeDetails.js +70 -11
  90. package/lib/utils/getTreeDetails/getTreeDetails.js.map +1 -1
  91. package/lib/utils/handleTreeExpandAllCollapseAll/handleTreeExpandAllCollapseAll.js +1 -0
  92. package/lib/utils/handleTreeExpandAllCollapseAll/handleTreeExpandAllCollapseAll.js.map +1 -1
  93. package/package.json +2 -2
  94. package/lib/components/StepsLandingTable/internal/FenwickTree.d.ts +0 -9
  95. package/lib/components/StepsLandingTable/internal/FenwickTree.js +0 -57
  96. package/lib/components/StepsLandingTable/internal/FenwickTree.js.map +0 -1
  97. package/lib/components/StepsLandingTable/internal/VirtualSurface.d.ts +0 -4
  98. package/lib/components/StepsLandingTable/internal/VirtualSurface.js +0 -303
  99. package/lib/components/StepsLandingTable/internal/VirtualSurface.js.map +0 -1
  100. package/lib/components/StepsLandingTable/internal/flattenVisibleNodes.d.ts +0 -4
  101. package/lib/components/StepsLandingTable/internal/flattenVisibleNodes.js +0 -156
  102. package/lib/components/StepsLandingTable/internal/flattenVisibleNodes.js.map +0 -1
  103. package/lib/components/StepsLandingTable/internal/renderers.d.ts +0 -62
  104. package/lib/components/StepsLandingTable/internal/renderers.js +0 -109
  105. package/lib/components/StepsLandingTable/internal/renderers.js.map +0 -1
  106. package/lib/components/StepsLandingTable/internal/types.d.ts +0 -80
  107. package/lib/components/StepsLandingTable/internal/types.js.map +0 -1
  108. /package/lib/components/{StepsLandingTable/internal → StepsLandingTableV2/model}/types.js +0 -0
@@ -1,513 +1,226 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useCallback, useEffect, useImperativeHandle, useMemo, useState, } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import './StepLandingTable.scss';
5
- import '../Checkbox/Checkbox.scss';
5
+ import StepInnerTable from './Components';
6
6
  import { gettingBlockMap, getUpdatedExpandedRows, getUpdatedPartialSelect, getUpdatedSelectedRows, hasSelectedIds, updateCheckboxStatus, } from './Components/handleStepCheckBox';
7
- import VirtualSurface from './internal/VirtualSurface';
8
- import { buildGridTemplates, flattenVisibleNodes, } from './internal/flattenVisibleNodes';
9
- import { DataRow, InlineDetailRow, InlineEditRow, InlineNlpRow, NoDataRow, SectionHeaderRow, } from './internal/renderers';
7
+ import StepsTitle from './Components/StepsTitle';
10
8
  import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
11
9
  import Typography from '../Typography';
12
- const createEmptySelection = (tableData) => Object.fromEntries(tableData.map((section) => [section.title, new Set()]));
13
- const getChildRows = (row) => Array.isArray(row?.data)
14
- ? row.data
15
- : Array.isArray(row?.stepResults)
16
- ? row.stepResults
17
- : [];
18
- const collectStepIds = (rows, target = new Set()) => {
19
- rows.forEach((row) => {
20
- if (row?.stepId) {
21
- target.add(row.stepId);
22
- }
23
- const children = getChildRows(row);
24
- if (children.length > 0) {
25
- collectStepIds(children, target);
26
- }
27
- });
28
- return target;
29
- };
30
- const StepLandingTable = React.memo(React.forwardRef(({ tableMeta = [], tableData = [], noDataContent, height = '100%', withFixedHeader = false, headerType, handleDragStart, onDragEnd, editMode, editComponent, NlpComponent, AddNlp, handleAccordion, handleViewComponent, onSelectClick, loading = false, isViewPrivilegeMode = false, defaultExpanded = 'Steps', isHeaderRequired = true, isClientSide = false, highlightKey, onHighlightComplete, isDraggable = true, isMaximize = false, handleParentRowHover, handleParentRowHoverOut, }, ref) => {
31
- const surfaceRef = useRef(null);
32
- const selectedRowsRef = useRef(createEmptySelection(tableData));
33
- const partialSelectionRef = useRef(new Set());
34
- const hoveredRootRowRef = useRef(null);
35
- const dragSessionRef = useRef(null);
36
- const [viewModeId, setViewModeId] = useState(null);
10
+ import StepLandingTableV2 from '../StepsLandingTableV2';
11
+ const LegacyStepLandingTable = React.memo(React.forwardRef(({ tableMeta = [], tableData = [], noDataContent, height = '100%', withFixedHeader = false, headerType, handleDragStart, onDragEnd, editMode, editComponent, NlpComponent, AddNlp, handleAccordion, handleViewComponent, onSelectClick, loading = false, isViewPrivilegeMode = false, defaultExpanded = 'Steps', isHeaderRequired = true, isClientSide = false, highlightKey, onHighlightComplete, isDraggable = true, isMaximize = false, handleParentRowHover, handleParentRowHoverOut, }, ref) => {
37
12
  const [ViewComponent, setViewComponent] = useState(null);
13
+ const [viewModeId, setViewModeId] = useState(null);
38
14
  const [expandedRows, setExpandedRows] = useState({});
39
- const [expandedGroups, setExpandedGroups] = useState(new Set());
40
- const [selectedRows, setSelectedRows] = useState(() => createEmptySelection(tableData));
41
- const [stepPartialSelect, setStepPartialSelect] = useState(() => new Set());
42
- const [dragState, setDragState] = useState(null);
43
- useEffect(() => {
44
- selectedRowsRef.current = selectedRows;
45
- }, [selectedRows]);
46
- useEffect(() => {
47
- partialSelectionRef.current = stepPartialSelect;
48
- }, [stepPartialSelect]);
49
- const gridTemplates = useMemo(() => buildGridTemplates(tableMeta), [tableMeta]);
50
- const onAccordionClick = useCallback((title, action = 'toggle') => {
51
- const section = tableData.find((row) => row.title === title);
52
- if (!section || !Array.isArray(section.data) || section.data.length === 0) {
15
+ const [expandStepGroup, setExpandStepGroup] = useState(new Map());
16
+ const [isBulkEnable, setBulkEnable] = useState(false);
17
+ const onAccordionClick = useCallback((title, action) => {
18
+ const row = tableData.find((row) => row.title === title);
19
+ if (!row || !row.data || row.data.length === 0) {
53
20
  return;
54
21
  }
55
- setExpandedRows((previous) => ({
56
- ...previous,
57
- [title]: action === 'open' ? true : !previous[title],
22
+ setExpandedRows((prev) => ({
23
+ ...prev,
24
+ [title]: action === 'open' ? true : !prev[title],
58
25
  }));
59
26
  }, [tableData]);
27
+ const isExpanded = useMemo(() => (title) => expandedRows[title] ?? false, [expandedRows]);
60
28
  const toggleViewRow = useCallback((row) => {
61
- setViewModeId((previous) => (previous === row?.stepId ? null : row?.stepId ?? null));
29
+ setViewModeId((prev) => (prev === row?.stepId ? null : row?.stepId));
62
30
  }, []);
63
31
  const handleClick = useCallback((item) => {
64
32
  toggleViewRow(item);
65
- const component = handleViewComponent?.(item, toggleViewRow);
66
- if (component) {
67
- setViewComponent(() => component);
68
- return;
69
- }
70
- toggleViewRow(null);
71
- setViewComponent(null);
72
- }, [handleViewComponent, toggleViewRow]);
73
- const handleUpdateCheckboxState = useCallback((updatedTableData, rowData, isChecked, sectionTitle = 'Steps') => {
74
- const { updateSelectRow, updateStepPartialSelect } = updateCheckboxStatus(updatedTableData, rowData, isChecked, selectedRowsRef.current, partialSelectionRef.current, sectionTitle);
75
- if (updateSelectRow) {
76
- setSelectedRows(updateSelectRow);
77
- }
78
- if (updateStepPartialSelect) {
79
- setStepPartialSelect(updateStepPartialSelect);
80
- }
81
- }, []);
82
- useEffect(() => {
83
- const nextSelected = getUpdatedSelectedRows(tableData, selectedRowsRef.current);
84
- let nextPartial = getUpdatedPartialSelect(tableData, partialSelectionRef.current);
85
- if (hasSelectedIds(nextSelected)) {
86
- const { updateSelectRow, updateStepPartialSelect } = gettingBlockMap(tableData, nextSelected, nextPartial);
87
- if (updateSelectRow) {
88
- setSelectedRows(updateSelectRow);
89
- }
90
- else {
91
- setSelectedRows(nextSelected);
92
- }
93
- if (updateStepPartialSelect) {
94
- nextPartial = updateStepPartialSelect;
95
- }
33
+ const Component = handleViewComponent?.(item, toggleViewRow);
34
+ if (Component) {
35
+ setViewComponent(() => Component);
96
36
  }
97
37
  else {
98
- setSelectedRows(nextSelected);
38
+ toggleViewRow(null);
99
39
  }
100
- setStepPartialSelect(nextPartial);
101
- setExpandedRows((previous) => getUpdatedExpandedRows(tableData, previous, defaultExpanded));
102
- setExpandedGroups((previous) => {
103
- const validIds = collectStepIds(tableData.flatMap((section) => section.data ?? []));
104
- return new Set([...previous].filter((rowId) => validIds.has(rowId)));
105
- });
106
- }, [defaultExpanded, tableData]);
40
+ }, [handleViewComponent, toggleViewRow]);
41
+ const [selectedRows, setSelectedRows] = useState(Object.fromEntries(tableData.map((section) => [section.title, new Set()])));
42
+ const [stepPartialSelect, setStepPartialSelect] = useState(new Set());
43
+ useEffect(() => {
44
+ setSelectedRows((pre) => getUpdatedSelectedRows(tableData, pre));
45
+ setStepPartialSelect((prevPartialSelect) => getUpdatedPartialSelect(tableData, prevPartialSelect));
46
+ setExpandedRows((prev) => getUpdatedExpandedRows(tableData, prev, defaultExpanded));
47
+ if (selectedRows && !hasSelectedIds(selectedRows))
48
+ return;
49
+ const { updateSelectRow, updateStepPartialSelect } = gettingBlockMap(tableData, selectedRows, stepPartialSelect);
50
+ if (updateStepPartialSelect)
51
+ setStepPartialSelect(updateStepPartialSelect);
52
+ if (updateSelectRow)
53
+ setSelectedRows(updateSelectRow);
54
+ }, [tableData]);
107
55
  useEffect(() => {
108
56
  if (hasSelectedIds(selectedRows)) {
109
- onSelectClick?.({
57
+ const updatedSelection = {
110
58
  ...selectedRows,
111
59
  partialSelected: stepPartialSelect,
112
- });
113
- return;
60
+ };
61
+ onSelectClick?.(updatedSelection);
114
62
  }
115
- onSelectClick?.(selectedRows);
116
- }, [onSelectClick, selectedRows, stepPartialSelect]);
63
+ else {
64
+ onSelectClick?.(selectedRows);
65
+ }
66
+ }, [selectedRows]);
117
67
  const handleMainCheckbox = useCallback((sectionTitle, checked) => {
118
- const section = tableData.find((item) => item.title === sectionTitle);
119
- const allRowIds = section?.data?.map((row) => row.stepId) ?? [];
120
- setSelectedRows((previous) => ({
121
- ...previous,
122
- [sectionTitle]: checked ? new Set(allRowIds) : new Set(),
123
- }));
124
- if (!checked) {
125
- setStepPartialSelect(new Set());
68
+ const allRowIds = tableData
69
+ .find((section) => section.title === sectionTitle)
70
+ ?.data.map((row) => row.stepId);
71
+ if (allRowIds) {
72
+ setSelectedRows((prev) => ({
73
+ ...prev,
74
+ [sectionTitle]: checked ? new Set(allRowIds) : new Set(),
75
+ }));
76
+ if (!checked)
77
+ setStepPartialSelect(new Set());
126
78
  }
127
79
  }, [tableData]);
128
- const handleRowCheckbox = useCallback((sectionTitle, rowData, isChecked) => {
129
- handleUpdateCheckboxState(tableData, rowData, isChecked, sectionTitle);
130
- }, [handleUpdateCheckboxState, tableData]);
80
+ const handleUpdateCheckboxState = useCallback((tableData, rowData, isChecked, sectionTitle) => {
81
+ const { updateSelectRow, updateStepPartialSelect } = updateCheckboxStatus(tableData, rowData, isChecked, selectedRows, stepPartialSelect, sectionTitle);
82
+ if (updateStepPartialSelect)
83
+ setStepPartialSelect(updateStepPartialSelect);
84
+ if (updateSelectRow)
85
+ setSelectedRows(updateSelectRow);
86
+ }, [selectedRows, stepPartialSelect]);
87
+ const handleRowCheckbox = useCallback((sectionTitle, row, isChecked) => {
88
+ handleUpdateCheckboxState(tableData, row, isChecked, sectionTitle);
89
+ }, [tableData, handleUpdateCheckboxState]);
90
+ const isAllSelected = useCallback((sectionTitle, totalRows) => {
91
+ const isSelected = totalRows > 0 && selectedRows[sectionTitle]?.size === totalRows;
92
+ if (sectionTitle.includes('Script')) {
93
+ setBulkEnable(isSelected);
94
+ }
95
+ return isSelected;
96
+ }, [selectedRows]);
97
+ const isPartialSelected = useCallback((sectionTitle, totalRows) => {
98
+ const selectedCount = selectedRows[sectionTitle]?.size || 0;
99
+ return selectedCount > 0 && selectedCount < totalRows;
100
+ }, [selectedRows]);
101
+ const isStepGroupExpanded = useCallback((stepId) => expandStepGroup.has(stepId), [expandStepGroup]);
131
102
  const handleStepGroupExpand = useCallback((rowData) => {
132
- const rowId = rowData?.stepId;
133
- if (!rowId) {
134
- return;
135
- }
136
- const isExpanded = expandedGroups.has(rowId);
137
- if (!isExpanded) {
138
- if (viewModeId) {
103
+ if (!isStepGroupExpanded(rowData?.stepId)) {
104
+ if (viewModeId)
139
105
  toggleViewRow(null);
140
- setViewComponent(null);
141
- }
142
106
  handleAccordion?.(rowData);
143
107
  }
144
108
  if (!loading) {
145
- setExpandedGroups((previous) => {
146
- const next = new Set(previous);
147
- if (next.has(rowId)) {
148
- next.delete(rowId);
109
+ setExpandStepGroup((prev) => {
110
+ const newMap = new Map(prev);
111
+ if (newMap.has(rowData?.stepId)) {
112
+ newMap.delete(rowData?.stepId);
149
113
  }
150
114
  else {
151
- next.add(rowId);
115
+ newMap.set(rowData?.stepId, true);
152
116
  }
153
- return next;
117
+ return newMap;
154
118
  });
155
119
  }
156
- }, [expandedGroups, handleAccordion, loading, toggleViewRow, viewModeId]);
157
- const visibleNodes = useMemo(() => flattenVisibleNodes({
158
- tableData,
159
- addNlp: AddNlp,
160
- editMode,
120
+ }, [
121
+ isStepGroupExpanded,
161
122
  viewModeId,
162
- expandedGroups,
163
- expandedSections: expandedRows,
123
+ toggleViewRow,
124
+ handleAccordion,
125
+ loading,
126
+ ]);
127
+ const getAccordionTableContent = useCallback((rows) => {
128
+ if (rows.title === 'Steps' && !isViewPrivilegeMode) {
129
+ return (_jsx(StepInnerTable, { onHighlightComplete: onHighlightComplete, highlightKey: highlightKey, draggable: isDraggable, columns: tableMeta, onDragEnd: onDragEnd, data: rows.data, headerType: headerType, withCheckbox: true, editMode: editMode, editComponent: editComponent, noDataContent: noDataContent, NlpComponent: NlpComponent, AddNlp: AddNlp, tableType: rows.title, handleDragStart: () => {
130
+ expandStepGroup.clear();
131
+ handleDragStart?.();
132
+ }, onSelect: handleRowCheckbox, selectedRows: selectedRows, viewModeId: viewModeId, ViewComponent: ViewComponent, handleClick: handleClick, handleStepGroupExpand: handleStepGroupExpand, isStepGroupExpanded: isStepGroupExpanded, stepPartialSelect: stepPartialSelect, height: rows?.data?.length === 0
133
+ ? '300px'
134
+ : rows?.data?.length <= 12
135
+ ? 'auto'
136
+ : height, isClientSide: isClientSide, handleRowHover: handleParentRowHover, handleRowHoverOut: handleParentRowHoverOut }));
137
+ }
138
+ else {
139
+ return (_jsx(StepInnerTable, { onHighlightComplete: onHighlightComplete, highlightKey: highlightKey, draggable: false, editMode: editMode, withCheckbox: !isViewPrivilegeMode, editComponent: editComponent, columns: tableMeta, data: rows.data, headerType: headerType, noDataContent: noDataContent, tableType: rows.title, onSelect: handleRowCheckbox, selectedRows: selectedRows, viewModeId: viewModeId, ViewComponent: ViewComponent, handleClick: handleClick, handleStepGroupExpand: handleStepGroupExpand, isStepGroupExpanded: isStepGroupExpanded, isViewPrivilegeMode: isViewPrivilegeMode, height: rows?.data?.length <= 15 ? 'auto' : height, isClientSide: isClientSide }));
140
+ }
141
+ }, [
164
142
  isViewPrivilegeMode,
143
+ onHighlightComplete,
144
+ highlightKey,
165
145
  isDraggable,
166
- noDataContent,
167
- }), [
168
- AddNlp,
146
+ tableMeta,
147
+ onDragEnd,
148
+ headerType,
169
149
  editMode,
170
- expandedGroups,
171
- expandedRows,
172
- isDraggable,
173
- isViewPrivilegeMode,
150
+ editComponent,
174
151
  noDataContent,
175
- tableData,
152
+ NlpComponent,
153
+ AddNlp,
154
+ expandStepGroup,
155
+ handleDragStart,
156
+ handleRowCheckbox,
157
+ selectedRows,
176
158
  viewModeId,
177
- ]);
178
- const nodeByRowId = useMemo(() => {
179
- const lookup = new Map();
180
- visibleNodes.forEach((node) => {
181
- if (node.rowId && !lookup.has(node.rowId)) {
182
- lookup.set(node.rowId, node);
183
- }
184
- });
185
- return lookup;
186
- }, [visibleNodes]);
187
- const scrollTargetKey = useMemo(() => {
188
- if (!checkEmpty(highlightKey)) {
189
- return visibleNodes.find((node) => node.rowId === highlightKey)?.key ?? null;
190
- }
191
- if (editMode) {
192
- return (visibleNodes.find((node) => node.kind === 'edit-row' && node.row?.stepId === editMode)?.key ?? null);
193
- }
194
- if (AddNlp && !checkEmpty(AddNlp)) {
195
- return visibleNodes.find((node) => node.kind === 'nlp-row')?.key ?? null;
196
- }
197
- if (viewModeId) {
198
- return (visibleNodes.find((node) => node.kind === 'detail-row' && node.row?.stepId === viewModeId)?.key ?? null);
199
- }
200
- return null;
201
- }, [AddNlp, editMode, highlightKey, viewModeId, visibleNodes]);
202
- const stepsRootNodeLookup = useMemo(() => {
203
- const lookup = new Map();
204
- visibleNodes.forEach((node) => {
205
- if (node.kind === 'data-row' &&
206
- node.depth === 0 &&
207
- node.sectionTitle === 'Steps' &&
208
- node.rowId) {
209
- lookup.set(node.rowId, node);
210
- }
211
- });
212
- return lookup;
213
- }, [visibleNodes]);
214
- const handleSurfaceClick = useCallback((event) => {
215
- const actionTarget = event.target.closest('[data-step-action]');
216
- if (!actionTarget) {
217
- return;
218
- }
219
- const action = actionTarget.dataset.stepAction;
220
- const rowId = actionTarget.dataset.stepRowId;
221
- const sectionTitle = actionTarget.dataset.stepSectionTitle;
222
- switch (action) {
223
- case 'toggle-section': {
224
- if (sectionTitle) {
225
- onAccordionClick(sectionTitle, 'toggle');
226
- }
227
- break;
228
- }
229
- case 'toggle-section-checkbox': {
230
- if (!sectionTitle) {
231
- break;
232
- }
233
- const totalRows = tableData.find((section) => section.title === sectionTitle)?.data?.length ?? 0;
234
- const selectedCount = selectedRows[sectionTitle]?.size ?? 0;
235
- const nextChecked = (selectedCount > 0 && selectedCount < totalRows) ||
236
- selectedCount !== totalRows;
237
- handleMainCheckbox(sectionTitle, nextChecked);
238
- break;
239
- }
240
- case 'toggle-row-checkbox': {
241
- if (!rowId || !sectionTitle) {
242
- break;
243
- }
244
- const rowNode = nodeByRowId.get(rowId);
245
- if (!rowNode?.row) {
246
- break;
247
- }
248
- const isChecked = selectedRows[sectionTitle]?.has(rowId) ?? false;
249
- const nextChecked = stepPartialSelect.has(rowId) || !isChecked;
250
- handleRowCheckbox(sectionTitle, rowNode.row, nextChecked);
251
- break;
252
- }
253
- case 'toggle-group': {
254
- if (!rowId) {
255
- break;
256
- }
257
- const rowNode = nodeByRowId.get(rowId);
258
- if (!rowNode?.row) {
259
- break;
260
- }
261
- handleStepGroupExpand({
262
- ...rowNode.row,
263
- tableType: rowNode.tableType,
264
- serialNumber: rowNode.serialNumber,
265
- });
266
- break;
267
- }
268
- case 'toggle-view': {
269
- if (!rowId) {
270
- break;
271
- }
272
- const rowNode = nodeByRowId.get(rowId);
273
- if (rowNode?.row) {
274
- handleClick({ ...rowNode.row, tableType: rowNode.tableType });
275
- }
276
- break;
277
- }
278
- default:
279
- break;
280
- }
281
- }, [
159
+ ViewComponent,
282
160
  handleClick,
283
- handleMainCheckbox,
284
- handleRowCheckbox,
285
161
  handleStepGroupExpand,
286
- nodeByRowId,
287
- onAccordionClick,
288
- selectedRows,
162
+ isStepGroupExpanded,
289
163
  stepPartialSelect,
290
- tableData,
291
- ]);
292
- const stopDragging = useCallback((commit) => {
293
- const session = dragSessionRef.current;
294
- window.removeEventListener('pointermove', handlePointerMove);
295
- window.removeEventListener('pointerup', handlePointerUp);
296
- document.body.style.userSelect = '';
297
- dragSessionRef.current = null;
298
- setDragState(null);
299
- if (!commit || !session || session.sourceIndex === session.targetIndex) {
300
- return;
301
- }
302
- onDragEnd?.(session.sourceIndex, session.targetIndex);
303
- }, [onDragEnd]);
304
- const handlePointerMove = useCallback((event) => {
305
- const session = dragSessionRef.current;
306
- const surface = surfaceRef.current;
307
- if (!session || !surface) {
308
- return;
309
- }
310
- const surfaceRect = surface.getBoundingClientRect();
311
- const nextOverlayTop = event.clientY - session.pointerOffsetY;
312
- const autoScrollEdge = 56;
313
- if (event.clientY < surfaceRect.top + autoScrollEdge) {
314
- surface.scrollTop -= 18;
315
- }
316
- else if (event.clientY > surfaceRect.bottom - autoScrollEdge) {
317
- surface.scrollTop += 18;
318
- }
319
- const rootRows = Array.from(surface.querySelectorAll('.ff-step-row--data[data-step-root-row="true"][data-step-section-title="Steps"]'));
320
- let nextTargetIndex = session.targetIndex;
321
- let nextMarkerTop = session.markerTop;
322
- if (rootRows.length > 0) {
323
- const firstRootRow = rootRows[0];
324
- if (!firstRootRow) {
325
- return;
326
- }
327
- let closestElement = firstRootRow;
328
- let smallestDistance = Number.POSITIVE_INFINITY;
329
- rootRows.forEach((element) => {
330
- const bounds = element.getBoundingClientRect();
331
- const center = bounds.top + bounds.height / 2;
332
- const distance = Math.abs(center - event.clientY);
333
- if (distance < smallestDistance) {
334
- smallestDistance = distance;
335
- closestElement = element;
336
- }
337
- });
338
- const nextRowId = closestElement.dataset.stepRowId;
339
- const targetNode = nextRowId ? stepsRootNodeLookup.get(nextRowId) : undefined;
340
- if (targetNode) {
341
- nextTargetIndex = targetNode.rootIndex;
342
- nextMarkerTop = closestElement.getBoundingClientRect().top;
343
- }
344
- }
345
- const nextSession = {
346
- ...session,
347
- targetIndex: nextTargetIndex,
348
- overlayTop: nextOverlayTop,
349
- overlayLeft: surfaceRect.left,
350
- overlayWidth: surfaceRect.width,
351
- markerTop: nextMarkerTop,
352
- };
353
- dragSessionRef.current = nextSession;
354
- setDragState(nextSession);
355
- }, [stepsRootNodeLookup]);
356
- const handlePointerUp = useCallback(() => {
357
- stopDragging(true);
358
- }, [stopDragging]);
359
- const handleSurfacePointerDown = useCallback((event) => {
360
- const dragHandle = event.target.closest('[data-step-action="start-drag"]');
361
- if (!dragHandle || !surfaceRef.current || !onDragEnd) {
362
- return;
363
- }
364
- const rowId = dragHandle.dataset.stepRowId;
365
- if (!rowId) {
366
- return;
367
- }
368
- const node = stepsRootNodeLookup.get(rowId);
369
- const rowElement = dragHandle.closest('.ff-step-row--data[data-step-row-id]');
370
- if (!node || !node.row || !rowElement) {
371
- return;
372
- }
373
- event.preventDefault();
374
- setExpandedGroups(new Set());
375
- handleDragStart?.();
376
- const rowRect = rowElement.getBoundingClientRect();
377
- const session = {
378
- rowId,
379
- sourceIndex: node.rootIndex,
380
- targetIndex: node.rootIndex,
381
- pointerOffsetY: event.clientY - rowRect.top,
382
- overlayTop: rowRect.top,
383
- overlayLeft: rowRect.left,
384
- overlayWidth: rowRect.width,
385
- markerTop: rowRect.top,
386
- node,
387
- };
388
- dragSessionRef.current = session;
389
- setDragState(session);
390
- document.body.style.userSelect = 'none';
391
- window.addEventListener('pointermove', handlePointerMove);
392
- window.addEventListener('pointerup', handlePointerUp, { once: true });
393
- }, [
394
- handleDragStart,
395
- handlePointerMove,
396
- handlePointerUp,
397
- onDragEnd,
398
- stepsRootNodeLookup,
164
+ tableData.length,
165
+ height,
166
+ isClientSide,
399
167
  ]);
400
- const handleSurfaceMouseOver = useCallback((event) => {
401
- if (!handleParentRowHover && !handleParentRowHoverOut) {
402
- return;
403
- }
404
- const rootRow = event.target.closest('.ff-step-row--data[data-step-root-row="true"][data-step-row-id]');
405
- const rowId = rootRow?.dataset.stepRowId ?? null;
406
- if (rowId === hoveredRootRowRef.current) {
407
- return;
408
- }
409
- if (hoveredRootRowRef.current) {
410
- handleParentRowHoverOut?.(hoveredRootRowRef.current);
411
- }
412
- hoveredRootRowRef.current = rowId;
413
- if (rowId) {
414
- handleParentRowHover?.(rowId);
415
- }
416
- }, [handleParentRowHover, handleParentRowHoverOut]);
417
- const handleSurfaceMouseLeave = useCallback(() => {
418
- if (hoveredRootRowRef.current) {
419
- handleParentRowHoverOut?.(hoveredRootRowRef.current);
420
- hoveredRootRowRef.current = null;
421
- }
422
- }, [handleParentRowHoverOut]);
423
- useEffect(() => {
424
- if (!checkEmpty(AddNlp)) {
425
- setViewComponent(null);
426
- setViewModeId(null);
427
- if (AddNlp?.action === 'addLast') {
428
- onAccordionClick('Steps', 'open');
429
- }
430
- }
431
- }, [AddNlp, onAccordionClick]);
432
168
  useImperativeHandle(ref, () => ({
433
169
  resetSelection: () => {
434
- setSelectedRows(createEmptySelection(tableData));
170
+ setSelectedRows(Object.fromEntries(tableData.map((section) => [section.title, new Set()])));
435
171
  setStepPartialSelect(new Set());
436
172
  },
437
173
  handleUpdateCheckbox: (rowData, updatedTableData) => {
438
- if (rowData?.parentSpecialNlpId || rowData?.conditionSearchKey) {
439
- handleUpdateCheckboxState(updatedTableData ?? tableData, rowData, false);
440
- }
174
+ const parentSpecialNlpId = rowData?.parentSpecialNlpId;
175
+ const conditionSearchKey = rowData?.conditionSearchKey;
176
+ if (parentSpecialNlpId || conditionSearchKey)
177
+ if (updatedTableData) {
178
+ handleUpdateCheckboxState(updatedTableData, rowData, false);
179
+ }
180
+ else {
181
+ handleUpdateCheckboxState(tableData, rowData, false);
182
+ }
441
183
  },
442
184
  deleteRow: (rowData) => {
443
- setSelectedRows((previous) => Object.fromEntries(Object.entries(previous).map(([key, ids]) => [
185
+ setSelectedRows((prev) => Object.fromEntries(Object.entries(prev)?.map(([key, ids]) => [
444
186
  key,
445
187
  new Set([...ids].filter((id) => id !== rowData?.stepId)),
446
188
  ])));
447
- setStepPartialSelect((previous) => {
448
- const next = new Set(previous);
449
- next.delete(rowData?.stepId);
450
- return next;
451
- });
452
189
  },
453
190
  resetStepGroupAccordion: () => {
454
- setExpandedGroups(new Set());
191
+ setExpandStepGroup(new Map());
455
192
  },
456
- }), [handleUpdateCheckboxState, tableData]);
457
- useEffect(() => () => {
458
- stopDragging(false);
459
- }, [stopDragging]);
460
- const renderNode = useCallback((node) => {
461
- switch (node.kind) {
462
- case 'section-header': {
463
- const totalRows = node.section?.data?.length ?? 0;
464
- const selectedCount = selectedRows[node.sectionTitle]?.size ?? 0;
465
- return (_jsx(SectionHeaderRow, { section: node.section, columns: tableMeta, grid: gridTemplates, expanded: expandedRows[node.sectionTitle] ?? false, totalRows: totalRows, selectedCount: selectedCount, isAllSelected: totalRows > 0 && selectedCount === totalRows, isPartialSelected: selectedCount > 0 && selectedCount < totalRows, showActionCell: selectedCount > 0 &&
466
- totalRows > 0 &&
467
- Boolean(node.section?.actionCell), isViewPrivilegeMode: isViewPrivilegeMode, isClientSide: isClientSide, isHeaderRequired: isHeaderRequired, isMaximize: isMaximize }));
468
- }
469
- case 'data-row': {
470
- const rowId = node.rowId ?? '';
471
- return (_jsx(DataRow, { node: node, columns: tableMeta, grid: gridTemplates, row: node.row, isSelected: selectedRows[node.sectionTitle]?.has(rowId) ?? false, isPartial: stepPartialSelect.has(rowId), isViewPrivilegeMode: isViewPrivilegeMode, isClientSide: isClientSide, showDragHandle: isDraggable && node.sectionTitle === 'Steps' }));
193
+ }), [tableData, handleUpdateCheckboxState]);
194
+ useEffect(() => {
195
+ if (!checkEmpty(AddNlp)) {
196
+ setViewComponent(() => null);
197
+ setViewModeId(null);
198
+ if (AddNlp?.action === 'addLast') {
199
+ onAccordionClick('Steps', 'open');
472
200
  }
473
- case 'edit-row':
474
- return (_jsx(InlineEditRow, { columns: tableMeta, grid: gridTemplates, editComponent: editComponent, node: node }));
475
- case 'nlp-row':
476
- return (_jsx(InlineNlpRow, { columns: tableMeta, grid: gridTemplates, nlpComponent: NlpComponent, node: node }));
477
- case 'detail-row':
478
- return (_jsx(InlineDetailRow, { columns: tableMeta, grid: gridTemplates, viewComponent: ViewComponent, node: node }));
479
- case 'no-data-row':
480
- default:
481
- return (_jsx(NoDataRow, { columns: tableMeta, grid: gridTemplates, content: noDataContent, sectionTitle: node.sectionTitle }));
482
201
  }
483
- }, [
484
- NlpComponent,
485
- ViewComponent,
486
- editComponent,
487
- expandedRows,
488
- gridTemplates,
489
- isClientSide,
490
- isHeaderRequired,
491
- isMaximize,
492
- isViewPrivilegeMode,
493
- noDataContent,
494
- selectedRows,
495
- stepPartialSelect,
496
- tableMeta,
497
- ]);
498
- return (_jsxs("div", { className: classNames('ff-accordion-table-container-steps', {
202
+ }, [AddNlp]);
203
+ return (_jsxs("div", {
204
+ // style={{ height, overflowY: 'auto' }}
205
+ className: classNames('ff-accordion-table-container-steps', {
499
206
  'ff-accordion-fixed-header-table': withFixedHeader,
500
- }), children: [isHeaderRequired && !isClientSide && (_jsx("div", { className: classNames('ff-step-grid-header', {
207
+ }), children: [isHeaderRequired && !isClientSide && (_jsx("table", { cellSpacing: 0, className: classNames('ff-accordion-table', {
501
208
  'ff-accordion-fixed-header': withFixedHeader,
502
- }), style: { gridTemplateColumns: gridTemplates.bodyTemplate }, role: "row", children: tableMeta.map((column, index) => (_jsx("div", { style: { width: column?.width }, className: classNames('ff-table-header', headerType && `ff-accordion-table--${headerType}-bg`), role: "columnheader", children: _jsx(Typography, { as: "div", fontWeight: "semi-bold", lineHeight: "18px", color: "var(--drawer-title-color)", children: column.header }) }, `${column.header}-${index}`))) })), _jsx(VirtualSurface, { surfaceRef: surfaceRef, className: "ff-accordion-table-body", nodes: visibleNodes, height: height, renderNode: renderNode, scrollTargetKey: scrollTargetKey, onScrollTargetSettled: () => {
503
- if (!checkEmpty(highlightKey)) {
504
- onHighlightComplete?.();
505
- }
506
- }, onClick: handleSurfaceClick, onPointerDown: handleSurfacePointerDown, onMouseOver: handleSurfaceMouseOver, onMouseLeave: handleSurfaceMouseLeave }), dragState && (_jsxs(_Fragment, { children: [_jsx("div", { className: "ff-step-drag-overlay", style: {
507
- top: dragState.overlayTop,
508
- left: dragState.overlayLeft,
509
- width: dragState.overlayWidth,
510
- }, children: _jsx(DataRow, { node: dragState.node, columns: tableMeta, grid: gridTemplates, row: dragState.node.row, isSelected: selectedRows[dragState.node.sectionTitle]?.has(dragState.rowId) ?? false, isPartial: stepPartialSelect.has(dragState.rowId), isViewPrivilegeMode: isViewPrivilegeMode, isClientSide: isClientSide, showDragHandle: isDraggable && dragState.node.sectionTitle === 'Steps' }) }), _jsx("div", { className: "ff-step-drag-marker", style: { top: dragState.markerTop, left: dragState.overlayLeft, width: dragState.overlayWidth } })] }))] }));
209
+ }), children: _jsx("thead", { className: "table-thead", children: _jsx("tr", { className: "ff-table-row", children: tableMeta.map((column, index) => (_jsx("th", { style: { width: column?.width }, className: classNames('ff-table-header', headerType && `ff-accordion-table--${headerType}-bg`), children: _jsx(Typography, { as: "div", fontWeight: "semi-bold", lineHeight: "18px", color: "var(--drawer-title-color)", children: column.header }) }, `${column.header}-${index}`))) }) }) })), _jsx("div", { className: "ff-accordion-table-body", style: { height: height, overflowY: 'auto' }, children: tableData?.map((row) => {
210
+ const { title, data, actionCell, metaData } = row;
211
+ const totalRows = data.length;
212
+ const expanded = isExpanded(title);
213
+ const selectedCount = selectedRows[title]?.size ?? 0;
214
+ const showActionCell = selectedCount > 0 && totalRows > 0 && actionCell;
215
+ return (_jsxs("div", { className: "column-table-accordion", children: [_jsx(StepsTitle, { isViewPrivilegeMode: isViewPrivilegeMode, onAccordionClick: onAccordionClick, showActionCell: showActionCell, handleMainCheckbox: handleMainCheckbox, isAllSelected: isAllSelected, isPartialSelected: isPartialSelected, title: title, totalRows: totalRows, expanded: expanded, metaData: metaData, actionCell: actionCell, row: row, tableMeta: tableMeta, isHeaderRequired: isHeaderRequired, isBulkEnable: isBulkEnable, isClientSide: isClientSide, isMaximize: isMaximize }), expanded && getAccordionTableContent(row)] }, title));
216
+ }) })] }));
217
+ }));
218
+ LegacyStepLandingTable.displayName = 'LegacyStepLandingTable';
219
+ const StepLandingTable = React.memo(React.forwardRef((props, ref) => {
220
+ if (props.useV2Engine) {
221
+ return _jsx(StepLandingTableV2, { ...props, ref: ref });
222
+ }
223
+ return _jsx(LegacyStepLandingTable, { ...props, ref: ref });
511
224
  }));
512
225
  StepLandingTable.displayName = 'StepLandingTable';
513
226
  export default StepLandingTable;