ff-step-table 1.0.1 → 1.0.3

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 +637 -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 +508 -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 +110 -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 +167 -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
@@ -0,0 +1,637 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { cloneElement, isValidElement, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useSyncExternalStore, } from 'react';
3
+ import { closestCorners, DndContext } from '@dnd-kit/core';
4
+ import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
5
+ import { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
6
+ import { CSS } from '@dnd-kit/utilities';
7
+ import classNames from 'classnames';
8
+ import Checkbox from '../Checkbox';
9
+ import Icon from '../Icon';
10
+ import Typography from '../Typography';
11
+ import StepsTitle from '../StepsLandingTable/Components/StepsTitle';
12
+ import { fromLegacyProps, toLegacySelectionPayload } from './compat/legacyAdapter';
13
+ import { isRowPartial, isRowSelected } from './selection/selectionEngine';
14
+ import { createTableStore } from './store/store';
15
+ import '../StepsLandingTable/StepLandingTable.scss';
16
+ import '../StepsLandingTable/Components/StepInnerTable.scss';
17
+ const StepLandingTableV2 = React.memo(React.forwardRef((props, ref) => {
18
+ const initialAdapterInput = useMemo(() => fromLegacyProps(props), []);
19
+ const storeRef = useRef(createTableStore(initialAdapterInput.snapshot));
20
+ const previousSnapshotRef = useRef(initialAdapterInput.snapshot);
21
+ const onSelectClickRef = useRef(props.onSelectClick);
22
+ const viewportRef = useRef(null);
23
+ const scrollRafRef = useRef(null);
24
+ const scrollIdleRef = useRef(null);
25
+ const latestScrollTopRef = useRef(0);
26
+ const adapterInput = useMemo(() => fromLegacyProps(props, previousSnapshotRef.current), [
27
+ props.defaultExpanded,
28
+ props.isDraggable,
29
+ props.isViewPrivilegeMode,
30
+ props.tableData,
31
+ props.tableMeta,
32
+ ]);
33
+ useEffect(() => {
34
+ const currentSnapshot = previousSnapshotRef.current;
35
+ if (areSnapshotsEquivalent(currentSnapshot, adapterInput.snapshot)) {
36
+ return;
37
+ }
38
+ previousSnapshotRef.current = adapterInput.snapshot;
39
+ storeRef.current.actions.setSnapshot(adapterInput.snapshot);
40
+ }, [adapterInput.snapshot]);
41
+ const state = useSyncExternalStore(storeRef.current.subscribe, storeRef.current.getState, storeRef.current.getState);
42
+ const selectionPayload = useMemo(() => toLegacySelectionPayload(state), [state.selection.version, state.snapshot.version]);
43
+ useEffect(() => {
44
+ onSelectClickRef.current = props.onSelectClick;
45
+ }, [props.onSelectClick]);
46
+ useEffect(() => {
47
+ onSelectClickRef.current?.(selectionPayload);
48
+ }, [selectionPayload]);
49
+ useEffect(() => {
50
+ const nextEditorState = deriveEditorState(props, storeRef.current.getState().snapshot);
51
+ storeRef.current.actions.setEditorState(nextEditorState);
52
+ if (nextEditorState.active) {
53
+ storeRef.current.actions.setDetailRow(null);
54
+ }
55
+ if (nextEditorState.active && nextEditorState.mode === 'add-last' && nextEditorState.sectionId) {
56
+ storeRef.current.actions.toggleSectionExpansion(nextEditorState.sectionId, 'open');
57
+ }
58
+ }, [props.AddNlp, props.editMode, state.snapshot.version]);
59
+ useLayoutEffect(() => {
60
+ const viewport = viewportRef.current;
61
+ if (!viewport) {
62
+ return undefined;
63
+ }
64
+ const updateSize = () => {
65
+ storeRef.current.actions.setViewportSize(viewport.clientWidth, viewport.clientHeight);
66
+ };
67
+ updateSize();
68
+ const resizeObserver = new ResizeObserver(updateSize);
69
+ resizeObserver.observe(viewport);
70
+ return () => {
71
+ resizeObserver.disconnect();
72
+ };
73
+ }, []);
74
+ useEffect(() => {
75
+ const viewport = viewportRef.current;
76
+ if (!viewport) {
77
+ return undefined;
78
+ }
79
+ const flushScroll = (timestamp) => {
80
+ scrollRafRef.current = null;
81
+ storeRef.current.actions.flushScrollFrame(latestScrollTopRef.current, timestamp);
82
+ };
83
+ const handleScroll = () => {
84
+ latestScrollTopRef.current = viewport.scrollTop;
85
+ if (scrollRafRef.current == null) {
86
+ scrollRafRef.current = requestAnimationFrame(flushScroll);
87
+ }
88
+ if (scrollIdleRef.current != null) {
89
+ window.clearTimeout(scrollIdleRef.current);
90
+ }
91
+ scrollIdleRef.current = window.setTimeout(() => {
92
+ storeRef.current.actions.settleScroll();
93
+ }, 120);
94
+ };
95
+ viewport.addEventListener('scroll', handleScroll, { passive: true });
96
+ handleScroll();
97
+ return () => {
98
+ viewport.removeEventListener('scroll', handleScroll);
99
+ if (scrollRafRef.current != null) {
100
+ cancelAnimationFrame(scrollRafRef.current);
101
+ }
102
+ if (scrollIdleRef.current != null) {
103
+ window.clearTimeout(scrollIdleRef.current);
104
+ }
105
+ };
106
+ }, []);
107
+ useImperativeHandle(ref, () => ({
108
+ resetSelection: () => {
109
+ storeRef.current.actions.resetSelection();
110
+ },
111
+ handleUpdateCheckbox: (rowData) => {
112
+ const rowId = rowData?.stepId;
113
+ if (rowId) {
114
+ storeRef.current.actions.removeRowSelection(rowId);
115
+ }
116
+ },
117
+ deleteRow: (rowData) => {
118
+ const rowId = rowData?.stepId;
119
+ if (rowId) {
120
+ storeRef.current.actions.removeRowSelection(rowId);
121
+ }
122
+ },
123
+ resetStepGroupAccordion: () => {
124
+ storeRef.current.actions.resetStepGroupAccordion();
125
+ },
126
+ }), []);
127
+ const gridTemplateColumns = useMemo(() => state.snapshot.columns.map((column) => `${column.width}px`).join(' '), [state.snapshot.columns]);
128
+ const sectionSourceById = useMemo(() => {
129
+ const map = new Map();
130
+ props.tableData.forEach((section) => {
131
+ const snapshotSection = state.snapshot.sectionIds.find((sectionId) => {
132
+ const entity = state.snapshot.sectionsById.get(sectionId);
133
+ return entity?.title === section?.title;
134
+ });
135
+ if (snapshotSection) {
136
+ map.set(snapshotSection, section);
137
+ }
138
+ });
139
+ return map;
140
+ }, [props.tableData, state.snapshot.sectionIds, state.snapshot.version]);
141
+ const topLevelIndexByRowId = useMemo(() => {
142
+ const map = new Map();
143
+ state.snapshot.sectionIds.forEach((sectionId) => {
144
+ const section = state.snapshot.sectionsById.get(sectionId);
145
+ section?.rowIds.forEach((rowId, index) => {
146
+ map.set(rowId, index);
147
+ });
148
+ });
149
+ return map;
150
+ }, [state.snapshot.version]);
151
+ const sortableRowIds = useMemo(() => {
152
+ const stepsSectionId = getStepsSectionId(state.snapshot);
153
+ if (!stepsSectionId) {
154
+ return [];
155
+ }
156
+ const stepsSection = state.snapshot.sectionsById.get(stepsSectionId);
157
+ return (stepsSection?.rowIds.filter((rowId) => {
158
+ const row = state.snapshot.rowsById.get(rowId);
159
+ return Boolean(row?.isDraggable);
160
+ }) ?? []);
161
+ }, [state.snapshot.version, props.isDraggable]);
162
+ const renderedNodes = useMemo(() => {
163
+ const { overscanStartIndex, overscanEndIndex } = state.viewport.range;
164
+ if (overscanEndIndex < overscanStartIndex) {
165
+ return [];
166
+ }
167
+ const nodes = state.visible.seq.range(overscanStartIndex, overscanEndIndex + 1);
168
+ return nodes.map((node, offset) => {
169
+ const index = overscanStartIndex + offset;
170
+ return {
171
+ node,
172
+ index,
173
+ top: state.heights.index.prefixSum(index),
174
+ };
175
+ });
176
+ }, [
177
+ state.visible.version,
178
+ state.viewport.range.overscanStartIndex,
179
+ state.viewport.range.overscanEndIndex,
180
+ state.heights.version,
181
+ ]);
182
+ const handleMeasuredHeight = useCallback((patch) => {
183
+ storeRef.current.actions.setMeasuredHeights([
184
+ {
185
+ index: 0,
186
+ nodeId: patch.node.id,
187
+ nextHeight: patch.height,
188
+ contentVersion: patch.node.contentVersion,
189
+ },
190
+ ]);
191
+ }, []);
192
+ const toggleSectionExpansion = useCallback((sectionId) => {
193
+ storeRef.current.actions.toggleSectionExpansion(sectionId);
194
+ }, []);
195
+ const toggleSectionSelection = useCallback((sectionId, checked) => {
196
+ storeRef.current.actions.toggleSectionSelection(sectionId, checked);
197
+ }, []);
198
+ const toggleDetailRow = useCallback((rowId) => {
199
+ const current = storeRef.current.getState().detail.activeRowId;
200
+ storeRef.current.actions.setDetailRow(current === rowId ? null : rowId);
201
+ }, []);
202
+ const handleGroupToggle = useCallback((rowId) => {
203
+ const current = storeRef.current.getState();
204
+ const row = current.snapshot.rowsById.get(rowId);
205
+ if (!row) {
206
+ return;
207
+ }
208
+ const isExpanded = current.expansion.expandedGroupIds.has(rowId);
209
+ if (!isExpanded && row.hasAsyncChildren && !row.childrenLoaded) {
210
+ const section = current.snapshot.sectionsById.get(row.sectionId);
211
+ const serialIndex = topLevelIndexByRowId.get(rowId);
212
+ storeRef.current.actions.setLoadingRow(rowId, true);
213
+ props.handleAccordion?.({
214
+ ...row.raw,
215
+ tableType: section?.title,
216
+ serialNumber: serialIndex != null ? String(serialIndex + 1) : undefined,
217
+ });
218
+ }
219
+ storeRef.current.actions.toggleGroupExpansion(rowId);
220
+ }, [props.handleAccordion, topLevelIndexByRowId]);
221
+ const handleDragStart = useCallback((event) => {
222
+ const rowId = event.active.id;
223
+ storeRef.current.actions.setDragState(rowId);
224
+ props.handleDragStart?.();
225
+ }, [props.handleDragStart]);
226
+ const handleDragEnd = useCallback((event) => {
227
+ const activeId = event.active.id;
228
+ const overId = event.over?.id;
229
+ storeRef.current.actions.clearDrag();
230
+ if (!overId || activeId === overId) {
231
+ return;
232
+ }
233
+ const stepsSectionId = getStepsSectionId(storeRef.current.getState().snapshot);
234
+ if (!stepsSectionId) {
235
+ return;
236
+ }
237
+ const stepsSection = storeRef.current.getState().snapshot.sectionsById.get(stepsSectionId);
238
+ if (!stepsSection) {
239
+ return;
240
+ }
241
+ const oldIndex = stepsSection.rowIds.indexOf(activeId);
242
+ const newIndex = stepsSection.rowIds.indexOf(overId);
243
+ if (oldIndex === -1 || newIndex === -1) {
244
+ return;
245
+ }
246
+ props.onDragEnd?.(oldIndex, newIndex);
247
+ }, [props.onDragEnd]);
248
+ const totalHeight = state.heights.index.totalHeight();
249
+ const hasSections = state.snapshot.sectionIds.length > 0;
250
+ return (_jsxs("div", { className: classNames('ff-accordion-table-container-steps', {
251
+ 'ff-accordion-fixed-header-table': props.withFixedHeader,
252
+ }), children: [props.isHeaderRequired !== false && !props.isClientSide && (_jsx("table", { cellSpacing: 0, className: classNames('ff-accordion-table', {
253
+ 'ff-accordion-fixed-header': props.withFixedHeader,
254
+ }), children: _jsx("thead", { className: "table-thead", children: _jsx("tr", { className: "ff-table-row", children: state.snapshot.columns.map((column, index) => (_jsx("th", { style: { width: column.width }, className: classNames('ff-table-header', props.headerType && `ff-accordion-table--${props.headerType}-bg`), children: _jsx(Typography, { as: "div", fontWeight: "semi-bold", lineHeight: "18px", color: "var(--drawer-title-color)", children: column.header }) }, `${column.id}:${index}`))) }) }) })), _jsx(DndContext, { collisionDetection: closestCorners, modifiers: [restrictToVerticalAxis], onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: _jsx(SortableContext, { items: sortableRowIds, strategy: verticalListSortingStrategy, children: _jsx("div", { ref: viewportRef, className: "ff-accordion-table-body", style: {
255
+ height: props.height ?? '100%',
256
+ overflowY: 'auto',
257
+ position: 'relative',
258
+ }, children: !hasSections ? (props.noDataContent ?? null) : (_jsx("div", { style: {
259
+ height: `${Math.max(totalHeight, 1)}px`,
260
+ position: 'relative',
261
+ }, children: renderedNodes.map(({ node, index, top }) => (_jsx(MeasuredNode, { node: node, top: top, onMeasure: handleMeasuredHeight, children: renderNode({
262
+ node,
263
+ index,
264
+ props,
265
+ state,
266
+ store: storeRef.current,
267
+ gridTemplateColumns,
268
+ selectionPayload,
269
+ sectionSourceById,
270
+ topLevelIndexByRowId,
271
+ onToggleSectionExpansion: toggleSectionExpansion,
272
+ onToggleSectionSelection: toggleSectionSelection,
273
+ onToggleDetailRow: toggleDetailRow,
274
+ onToggleGroup: handleGroupToggle,
275
+ }) }, node.id))) })) }) }) })] }));
276
+ }));
277
+ StepLandingTableV2.displayName = 'StepLandingTableV2';
278
+ export default StepLandingTableV2;
279
+ function renderNode({ node, index, props, state, store, gridTemplateColumns, selectionPayload, sectionSourceById, topLevelIndexByRowId, onToggleSectionExpansion, onToggleSectionSelection, onToggleDetailRow, onToggleGroup, }) {
280
+ switch (node.kind) {
281
+ case 'section': {
282
+ const section = state.snapshot.sectionsById.get(node.sectionId);
283
+ if (!section) {
284
+ return _jsx(React.Fragment, {});
285
+ }
286
+ const rawSection = sectionSourceById.get(node.sectionId);
287
+ const selectedSet = selectionPayload[section.title] ?? new Set();
288
+ const totalRows = section.rowIds.length;
289
+ const isAllSelected = totalRows > 0 && selectedSet.size === totalRows;
290
+ const isPartialSelected = selectedSet.size > 0 && selectedSet.size < totalRows;
291
+ const showActionCell = selectedSet.size > 0 && totalRows > 0 && Boolean(section.actionCell);
292
+ const isBulkEnable = section.title.includes('Script') && isAllSelected;
293
+ return (_jsx("div", { className: "column-table-accordion", children: _jsx(StepsTitle, { isViewPrivilegeMode: props.isViewPrivilegeMode, onAccordionClick: () => onToggleSectionExpansion(node.sectionId), showActionCell: showActionCell, handleMainCheckbox: (title, checked) => {
294
+ if (title === section.title) {
295
+ onToggleSectionSelection(node.sectionId, checked);
296
+ }
297
+ }, isAllSelected: () => isAllSelected, isPartialSelected: () => isPartialSelected, title: section.title, totalRows: totalRows, expanded: state.expansion.expandedSectionIds.has(node.sectionId), metaData: section.metaData, actionCell: section.actionCell, row: rawSection ?? {
298
+ title: section.title,
299
+ data: section.rowIds.map((rowId) => state.snapshot.rowsById.get(rowId)?.raw),
300
+ }, tableMeta: props.tableMeta, isHeaderRequired: props.isHeaderRequired, isBulkEnable: isBulkEnable, isClientSide: props.isClientSide, isMaximize: props.isMaximize }) }));
301
+ }
302
+ case 'row': {
303
+ const row = state.snapshot.rowsById.get(node.rowId);
304
+ if (!row) {
305
+ return _jsx(React.Fragment, {});
306
+ }
307
+ return (_jsx(VirtualDataRow, { row: row, node: node, props: props, state: state, store: store, gridTemplateColumns: gridTemplateColumns, rowIndex: topLevelIndexByRowId.get(row.id) ?? index, onToggleDetailRow: onToggleDetailRow, onToggleGroup: onToggleGroup }));
308
+ }
309
+ case 'detail': {
310
+ const row = state.snapshot.rowsById.get(node.rowId);
311
+ const DetailComponent = row
312
+ ? props.handleViewComponent?.(row.raw, () => store.actions.setDetailRow(null))
313
+ : null;
314
+ return (_jsx("div", { className: "steps-edit-row", style: { padding: '8px 16px' }, children: DetailComponent ? (_jsx(DetailComponent, {})) : (_jsx(Typography, { as: "div", lineHeight: "18px", children: "Detail unavailable" })) }));
315
+ }
316
+ case 'editor': {
317
+ const anchorRow = node.anchorRowId
318
+ ? state.snapshot.rowsById.get(node.anchorRowId)
319
+ : null;
320
+ const editorRowData = buildEditorRowData(state, node, anchorRow ?? null);
321
+ const rowIndex = state.editor.sourceIndex ??
322
+ (node.anchorRowId ? topLevelIndexByRowId.get(node.anchorRowId) ?? index : index);
323
+ return (_jsx("div", { className: "steps-edit-row", children: node.mode === 'edit' && isValidElement(props.editComponent) ? (cloneElement(props.editComponent, {
324
+ rowData: anchorRow?.raw ?? editorRowData,
325
+ rowIndex: rowIndex + 1,
326
+ })) : isValidElement(props.NlpComponent) ? (cloneElement(props.NlpComponent, {
327
+ rowData: editorRowData,
328
+ rowIndex,
329
+ })) : (_jsx(Typography, { as: "div", lineHeight: "18px", children: "Editor unavailable" })) }));
330
+ }
331
+ case 'loading':
332
+ return (_jsx("div", { className: "steps-edit-row", style: { padding: '8px 16px' }, children: _jsx(Typography, { as: "div", lineHeight: "18px", children: "Loading..." }) }));
333
+ case 'empty':
334
+ return (_jsx("div", { className: "steps-no-data-content", children: props.noDataContent ?? (_jsx(Typography, { as: "div", lineHeight: "18px", children: "No data available" })) }));
335
+ }
336
+ }
337
+ function MeasuredNode({ node, top, onMeasure, children }) {
338
+ const ref = useRef(null);
339
+ useLayoutEffect(() => {
340
+ const element = ref.current;
341
+ if (!element) {
342
+ return undefined;
343
+ }
344
+ const measure = () => {
345
+ onMeasure({
346
+ node,
347
+ height: element.getBoundingClientRect().height,
348
+ });
349
+ };
350
+ measure();
351
+ const observer = new ResizeObserver(measure);
352
+ observer.observe(element);
353
+ return () => {
354
+ observer.disconnect();
355
+ };
356
+ }, [node, onMeasure]);
357
+ return (_jsx("div", { ref: ref, "data-nodeid": node.id, style: {
358
+ position: 'absolute',
359
+ top,
360
+ left: 0,
361
+ right: 0,
362
+ }, children: children }));
363
+ }
364
+ function VirtualDataRow({ row, props, state, store, gridTemplateColumns, rowIndex, onToggleDetailRow, onToggleGroup, }) {
365
+ const section = state.snapshot.sectionsById.get(row.sectionId);
366
+ const isSelected = isRowSelected(state.snapshot, state.selection.bySectionId, row.id);
367
+ const isPartial = isRowPartial(state.snapshot, state.selection.bySectionId, row.id);
368
+ const showCheckbox = row.parentId == null && !props.isViewPrivilegeMode && !props.isClientSide;
369
+ const canDrag = Boolean(props.isDraggable !== false &&
370
+ !props.isClientSide &&
371
+ row.parentId == null &&
372
+ row.isDraggable);
373
+ const canToggleDetail = row.parentId != null &&
374
+ !row.isDisabled &&
375
+ !String(row.displayName ?? row.name ?? '').includes('End') &&
376
+ Boolean(props.handleViewComponent);
377
+ const isGroupExpanded = state.expansion.expandedGroupIds.has(row.id);
378
+ const isDragDisabled = !canDrag;
379
+ const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
380
+ id: row.id,
381
+ disabled: isDragDisabled,
382
+ });
383
+ const style = {
384
+ transform: CSS.Transform.toString(transform),
385
+ transition,
386
+ };
387
+ return (_jsx("div", { ref: setNodeRef, "data-rowid": row.id, className: classNames('sortable-item', {
388
+ 'disabled-inner-row': row.isDisabled || isDragDisabled,
389
+ }), onMouseEnter: () => {
390
+ store.actions.setHoveredRow(row.id);
391
+ if (row.parentId == null) {
392
+ props.handleParentRowHover?.(row.id);
393
+ }
394
+ }, onMouseLeave: () => {
395
+ store.actions.setHoveredRow(null);
396
+ if (row.parentId == null) {
397
+ props.handleParentRowHoverOut?.(row.id);
398
+ }
399
+ }, style: {
400
+ ...style,
401
+ display: 'grid',
402
+ gridTemplateColumns,
403
+ alignItems: 'center',
404
+ }, children: state.snapshot.columns.map((column, columnIndex) => {
405
+ const value = row.raw?.[column.accessor];
406
+ const tableType = section?.title;
407
+ const refId = row.raw?._id || row.raw?.id;
408
+ const cellContent = column.renderCell
409
+ ? column.renderCell({
410
+ value,
411
+ row: row.raw,
412
+ column: column.accessor,
413
+ index: rowIndex,
414
+ tableType,
415
+ refId,
416
+ })
417
+ : value ?? '--';
418
+ return (_jsx("div", { className: column.className, style: {
419
+ padding: columnIndex === 0
420
+ ? row.parentId == null
421
+ ? canDrag
422
+ ? '4px 8px 4px 0'
423
+ : '4px 8px 4px 24px'
424
+ : '7px 8px'
425
+ : row.parentId == null && tableType === 'Steps'
426
+ ? '4px 8px'
427
+ : '7px 8px',
428
+ maxWidth: column.width,
429
+ }, children: _jsxs(Typography, { as: "div", lineHeight: "18px", className: "ff-data-checkbox-container", children: [columnIndex === 0 && canDrag && (_jsx("div", { className: isDragDisabled ? 'ff-table-drag' : 'ff-table-drag-icon', ...listeners, ...attributes, children: _jsx(Icon, { name: "drag", className: isDragDisabled ? 'drag-icon-disabled' : 'drag-icon' }) })), columnIndex === 0 && showCheckbox && (_jsx("span", { className: isSelected || isPartial
430
+ ? 'ff-step-table-select-checkbox'
431
+ : 'ff-table-checkbox-step', children: _jsx(Checkbox, { onChange: (event) => store.actions.toggleRowSelection(row.id, event.target.checked), checked: isSelected, partial: isPartial, disabled: row.kind === 'special-end' }) })), _jsxs("div", { className: "ff-margin-container", style: {
432
+ marginLeft: columnIndex === 0 ? row.marginLeft : 0,
433
+ display: 'flex',
434
+ alignItems: 'center',
435
+ gap: '8px',
436
+ }, onDoubleClick: () => {
437
+ if (columnIndex === 0 && canToggleDetail) {
438
+ onToggleDetailRow(row.id);
439
+ }
440
+ }, children: [_jsx("div", { style: { minWidth: 0, flex: 1 }, children: cellContent }), columnIndex === 0 && row.isExpandable && !props.isClientSide && (_jsx("button", { type: "button", className: `ff-accordion-arrow ${isGroupExpanded ? 'expanded' : ''}`, style: {
441
+ border: 0,
442
+ background: 'transparent',
443
+ padding: 0,
444
+ }, onClick: () => onToggleGroup(row.id), children: _jsx(Icon, { name: "arrow_right", color: isGroupExpanded
445
+ ? 'var(--brand-color)'
446
+ : 'var(--default-color)', className: "steps-arrow-svg", width: 12, height: 12 }) })), column.renderExtraInfo?.({
447
+ value,
448
+ row: row.raw,
449
+ column: column.accessor,
450
+ index: rowIndex,
451
+ tableType,
452
+ refId,
453
+ })] })] }) }, `${row.id}:${column.id}`));
454
+ }) }));
455
+ }
456
+ function deriveEditorState(props, snapshot) {
457
+ const stepsSectionId = getStepsSectionId(snapshot);
458
+ const stepsSection = stepsSectionId
459
+ ? snapshot.sectionsById.get(stepsSectionId)
460
+ : null;
461
+ if (props.editMode) {
462
+ const rowId = String(props.editMode);
463
+ const row = snapshot.rowsById.get(rowId);
464
+ return {
465
+ active: Boolean(row),
466
+ mode: row ? 'edit' : 'none',
467
+ anchorRowId: row?.id ?? null,
468
+ sectionId: row?.sectionId ?? null,
469
+ sourceIndex: row && stepsSection ? stepsSection.rowIds.indexOf(row.id) : null,
470
+ };
471
+ }
472
+ if (!props.AddNlp?.action || !stepsSectionId || !stepsSection) {
473
+ return {
474
+ active: false,
475
+ mode: 'none',
476
+ };
477
+ }
478
+ const sourceIndex = props.AddNlp.sourceIndex != null ? props.AddNlp.sourceIndex : null;
479
+ const anchorRowId = sourceIndex != null ? stepsSection.rowIds[sourceIndex] ?? null : null;
480
+ const modeMap = {
481
+ addBelow: 'add-below',
482
+ addLast: 'add-last',
483
+ replaceNlp: 'replace',
484
+ EditNlp: 'replace',
485
+ };
486
+ return {
487
+ active: true,
488
+ mode: modeMap[props.AddNlp.action] ?? 'none',
489
+ anchorRowId,
490
+ sectionId: stepsSectionId,
491
+ sourceIndex,
492
+ nlpName: props.AddNlp.nlpName,
493
+ };
494
+ }
495
+ function getStepsSectionId(snapshot) {
496
+ return (snapshot.sectionIds.find((sectionId) => {
497
+ const section = snapshot.sectionsById.get(sectionId);
498
+ return section?.kind === 'steps' || section?.title === 'Steps';
499
+ }) ?? null);
500
+ }
501
+ function buildEditorRowData(state, _node, anchorRow) {
502
+ return {
503
+ ...(anchorRow?.raw ?? {}),
504
+ stepId: anchorRow?.id ?? 'new-row',
505
+ isNew: true,
506
+ name: state.editor.nlpName ?? anchorRow?.name ?? '',
507
+ };
508
+ }
509
+ function areSnapshotsEquivalent(previous, next) {
510
+ if (previous === next) {
511
+ return true;
512
+ }
513
+ if (previous.columns.length !== next.columns.length) {
514
+ return false;
515
+ }
516
+ for (let index = 0; index < previous.columns.length; index += 1) {
517
+ const prevColumn = previous.columns[index];
518
+ const nextColumn = next.columns[index];
519
+ if (!prevColumn || !nextColumn) {
520
+ return false;
521
+ }
522
+ if (prevColumn.id !== nextColumn.id ||
523
+ prevColumn.header !== nextColumn.header ||
524
+ prevColumn.accessor !== nextColumn.accessor ||
525
+ prevColumn.width !== nextColumn.width ||
526
+ prevColumn.className !== nextColumn.className ||
527
+ Boolean(prevColumn.renderCell) !== Boolean(nextColumn.renderCell) ||
528
+ Boolean(prevColumn.renderExtraInfo) !== Boolean(nextColumn.renderExtraInfo)) {
529
+ return false;
530
+ }
531
+ }
532
+ if (!isSameArray(previous.sectionIds, next.sectionIds)) {
533
+ return false;
534
+ }
535
+ if (previous.sectionsById.size !== next.sectionsById.size) {
536
+ return false;
537
+ }
538
+ for (let index = 0; index < previous.sectionIds.length; index += 1) {
539
+ const sectionId = previous.sectionIds[index];
540
+ if (!sectionId) {
541
+ return false;
542
+ }
543
+ const previousSection = previous.sectionsById.get(sectionId);
544
+ const nextSection = next.sectionsById.get(sectionId);
545
+ if (!previousSection || !nextSection) {
546
+ return false;
547
+ }
548
+ if (previousSection.title !== nextSection.title ||
549
+ previousSection.kind !== nextSection.kind ||
550
+ previousSection.selectableOrdinalStart !== nextSection.selectableOrdinalStart ||
551
+ previousSection.selectableOrdinalEnd !== nextSection.selectableOrdinalEnd ||
552
+ previousSection.selectableCount !== nextSection.selectableCount ||
553
+ previousSection.metaData !== nextSection.metaData ||
554
+ previousSection.actionCell !== nextSection.actionCell ||
555
+ previousSection.isDefaultExpanded !== nextSection.isDefaultExpanded ||
556
+ !isSameArray(previousSection.rowIds, nextSection.rowIds)) {
557
+ return false;
558
+ }
559
+ }
560
+ if (!isSameArray(previous.rowIds, next.rowIds)) {
561
+ return false;
562
+ }
563
+ if (previous.rowsById.size !== next.rowsById.size ||
564
+ previous.blocksById.size !== next.blocksById.size) {
565
+ return false;
566
+ }
567
+ for (let index = 0; index < previous.rowIds.length; index += 1) {
568
+ const rowId = previous.rowIds[index];
569
+ if (!rowId) {
570
+ return false;
571
+ }
572
+ const previousRow = previous.rowsById.get(rowId);
573
+ const nextRow = next.rowsById.get(rowId);
574
+ if (!previousRow || !nextRow) {
575
+ return false;
576
+ }
577
+ if (previousRow.sectionId !== nextRow.sectionId ||
578
+ previousRow.parentId !== nextRow.parentId ||
579
+ previousRow.depth !== nextRow.depth ||
580
+ previousRow.kind !== nextRow.kind ||
581
+ previousRow.name !== nextRow.name ||
582
+ previousRow.displayName !== nextRow.displayName ||
583
+ previousRow.message !== nextRow.message ||
584
+ previousRow.status !== nextRow.status ||
585
+ previousRow.marginLeft !== nextRow.marginLeft ||
586
+ previousRow.raw !== nextRow.raw ||
587
+ previousRow.isDisabled !== nextRow.isDisabled ||
588
+ previousRow.isDraggable !== nextRow.isDraggable ||
589
+ previousRow.isSelectable !== nextRow.isSelectable ||
590
+ previousRow.isExpandable !== nextRow.isExpandable ||
591
+ previousRow.hasAsyncChildren !== nextRow.hasAsyncChildren ||
592
+ previousRow.childrenLoaded !== nextRow.childrenLoaded ||
593
+ previousRow.detailCapable !== nextRow.detailCapable ||
594
+ previousRow.selectableOrdinal !== nextRow.selectableOrdinal ||
595
+ previousRow.subtreeSelectableStart !== nextRow.subtreeSelectableStart ||
596
+ previousRow.subtreeSelectableEnd !== nextRow.subtreeSelectableEnd ||
597
+ previousRow.blockId !== nextRow.blockId ||
598
+ previousRow.contentVersion !== nextRow.contentVersion ||
599
+ !isSameArray(previousRow.childIds, nextRow.childIds) ||
600
+ !isSameArray(previousRow.ancestorBlockIds, nextRow.ancestorBlockIds)) {
601
+ return false;
602
+ }
603
+ }
604
+ for (const [blockId, previousBlock] of previous.blocksById.entries()) {
605
+ const nextBlock = next.blocksById.get(blockId);
606
+ if (!nextBlock) {
607
+ return false;
608
+ }
609
+ if (previousBlock.kind !== nextBlock.kind ||
610
+ previousBlock.startRowId !== nextBlock.startRowId ||
611
+ previousBlock.endRowId !== nextBlock.endRowId ||
612
+ previousBlock.sectionId !== nextBlock.sectionId ||
613
+ previousBlock.parentBlockId !== nextBlock.parentBlockId ||
614
+ previousBlock.familyId !== nextBlock.familyId ||
615
+ previousBlock.selectableStartOrdinal !== nextBlock.selectableStartOrdinal ||
616
+ previousBlock.selectableEndOrdinal !== nextBlock.selectableEndOrdinal ||
617
+ previousBlock.selectableLeafCount !== nextBlock.selectableLeafCount ||
618
+ previousBlock.startDepth !== nextBlock.startDepth ||
619
+ !isSameArray(previousBlock.childRowIds, nextBlock.childRowIds) ||
620
+ !isSameArray(previousBlock.allRowIds, nextBlock.allRowIds)) {
621
+ return false;
622
+ }
623
+ }
624
+ return true;
625
+ }
626
+ function isSameArray(previous, next) {
627
+ if (previous.length !== next.length) {
628
+ return false;
629
+ }
630
+ for (let index = 0; index < previous.length; index += 1) {
631
+ if (previous[index] !== next[index]) {
632
+ return false;
633
+ }
634
+ }
635
+ return true;
636
+ }
637
+ //# sourceMappingURL=StepLandingTable.js.map