pixel-react 1.10.5 → 1.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Select/components/types.d.ts +6 -1
- package/lib/components/Select/types.d.ts +17 -0
- package/lib/components/Table/Table.d.ts +1 -1
- package/lib/components/Table/Types.d.ts +1 -0
- package/lib/index.d.ts +18 -1
- package/lib/index.esm.js +116 -26
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +116 -26
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Select/Select.stories.tsx +43 -1
- package/src/components/Select/Select.tsx +16 -1
- package/src/components/Select/components/Dropdown.scss +41 -1
- package/src/components/Select/components/Dropdown.tsx +52 -6
- package/src/components/Select/components/types.ts +7 -2
- package/src/components/Select/types.ts +22 -0
- package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.stories.tsx +8 -2
- package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +1 -1
- package/src/components/SequentialConnectingBranch/components/DatasetTooltip/DataSetTooltip.scss +14 -0
- package/src/components/SequentialConnectingBranch/components/DatasetTooltip/DataSetTooltip.tsx +6 -11
- package/src/components/Table/Table.tsx +47 -0
- package/src/components/Table/Types.ts +4 -1
- package/src/utils/getTreeDetails/getTreeDetails.ts +7 -6
package/package.json
CHANGED
@@ -44,6 +44,11 @@ export const Primary: Story = {
|
|
44
44
|
value: 'fire-flink-LIC4999',
|
45
45
|
name: 'lambda test',
|
46
46
|
},
|
47
|
+
{
|
48
|
+
label: 'fire-flink-LIC4999',
|
49
|
+
value: 'fire-flink-LIC4999',
|
50
|
+
name: 'lambda test',
|
51
|
+
},
|
47
52
|
],
|
48
53
|
},
|
49
54
|
};
|
@@ -160,6 +165,22 @@ export const OptionSelection: Story = {
|
|
160
165
|
label: 'fire-flink-LIC4999',
|
161
166
|
value: 'fire-flink-LIC4999',
|
162
167
|
},
|
168
|
+
{
|
169
|
+
label: 'fire-flink-LIC4999',
|
170
|
+
value: 'fire-flink-LIC4999',
|
171
|
+
},
|
172
|
+
{
|
173
|
+
label: 'fire-flink-LIC4999',
|
174
|
+
value: 'fire-flink-LIC4999',
|
175
|
+
},
|
176
|
+
{
|
177
|
+
label: 'fire-flink-LIC4999',
|
178
|
+
value: 'fire-flink-LIC4999',
|
179
|
+
},
|
180
|
+
{
|
181
|
+
label: 'fire-flink-LIC4999',
|
182
|
+
value: 'fire-flink-LIC4999',
|
183
|
+
},
|
163
184
|
];
|
164
185
|
|
165
186
|
const [selectedOption, setSelectedOption] = useState<Option>({
|
@@ -412,10 +433,23 @@ export const SelectWithToolTip: Story = {
|
|
412
433
|
label: 'fire-flink-LIC4937',
|
413
434
|
value: 'fire-flink-LIC4937',
|
414
435
|
},
|
436
|
+
{
|
437
|
+
label: 'fire-flink-LIC5937',
|
438
|
+
value: 'fire-flink-LIC5937',
|
439
|
+
},
|
440
|
+
{
|
441
|
+
label: 'fire-flink-LIC6937',
|
442
|
+
value: 'fire-flink-LIC6937',
|
443
|
+
},
|
444
|
+
{
|
445
|
+
label: 'fire-flink-LIC7937',
|
446
|
+
value: 'fire-flink-LIC7937',
|
447
|
+
},
|
415
448
|
{
|
416
449
|
label: 'fire-flink-LIC4999',
|
417
450
|
value: 'fire-flink-LIC4999',
|
418
|
-
|
451
|
+
recurrence: true,
|
452
|
+
},
|
419
453
|
];
|
420
454
|
|
421
455
|
const [selectedOption, setSelectedOption] = useState<Option>({
|
@@ -427,6 +461,12 @@ export const SelectWithToolTip: Story = {
|
|
427
461
|
setSelectedOption(option);
|
428
462
|
};
|
429
463
|
|
464
|
+
const getMiniModalJSX = () => (
|
465
|
+
<>
|
466
|
+
<h1>Test Mini Modal</h1>
|
467
|
+
</>
|
468
|
+
);
|
469
|
+
|
430
470
|
return (
|
431
471
|
<Select
|
432
472
|
optionsList={optionsList}
|
@@ -434,6 +474,8 @@ export const SelectWithToolTip: Story = {
|
|
434
474
|
onChange={handleChange}
|
435
475
|
label="Select Option"
|
436
476
|
showToolTip={true}
|
477
|
+
modalJSXProps={getMiniModalJSX()}
|
478
|
+
recurrence
|
437
479
|
/>
|
438
480
|
);
|
439
481
|
},
|
@@ -34,10 +34,15 @@ const Select: FC<SelectProps> = ({
|
|
34
34
|
showIcon = false,
|
35
35
|
placeHolder = '',
|
36
36
|
showToolTip = false,
|
37
|
+
onCancelModal = () => {},
|
38
|
+
onSaveModal = () => {},
|
39
|
+
modalJSXProps = <></>,
|
40
|
+
recurrence = false,
|
37
41
|
}) => {
|
38
42
|
const selectWidth = typeof width === 'number' ? `${width}px` : width;
|
39
43
|
|
40
44
|
const [showDropdownOptions, setShowDropdownOptions] = useState(false);
|
45
|
+
const [customRecurrence, setCustomRecurrence] = useState(false);
|
41
46
|
const [searchedOption, setSearchedOption] = useState<any>({
|
42
47
|
searchedText: '',
|
43
48
|
searchedIcon: '',
|
@@ -124,12 +129,14 @@ const Select: FC<SelectProps> = ({
|
|
124
129
|
searchedIcon: selectedOption.iconName,
|
125
130
|
});
|
126
131
|
setSelectOptionList(optionsList);
|
132
|
+
setCustomRecurrence(false);
|
127
133
|
onBlur();
|
128
134
|
};
|
129
135
|
|
130
136
|
const onSelectOptionSelector = (option: Option): void => {
|
131
137
|
if (disabled) return;
|
132
|
-
|
138
|
+
const isCustomRecurrence = option?.recurrence || false;
|
139
|
+
setCustomRecurrence(isCustomRecurrence);
|
133
140
|
setSearchedOption({
|
134
141
|
searchedText: getValue(selectedOption, valueAccessor),
|
135
142
|
searchedIcon: selectedOption.iconName,
|
@@ -137,6 +144,9 @@ const Select: FC<SelectProps> = ({
|
|
137
144
|
if (onChange) {
|
138
145
|
onChange(option);
|
139
146
|
}
|
147
|
+
if (!isCustomRecurrence) {
|
148
|
+
onSelectBlur();
|
149
|
+
}
|
140
150
|
};
|
141
151
|
|
142
152
|
const handleResizeOrScroll = () => onSelectUpdatePosition();
|
@@ -277,6 +287,11 @@ const Select: FC<SelectProps> = ({
|
|
277
287
|
selectedOption={searchedText}
|
278
288
|
showIcon={showIcon}
|
279
289
|
showToolTip={showToolTip}
|
290
|
+
customReccurenece={customRecurrence}
|
291
|
+
onSaveModal={onSaveModal}
|
292
|
+
onCancelModal={onCancelModal}
|
293
|
+
modalJSXProps={modalJSXProps}
|
294
|
+
recurrence={recurrence}
|
280
295
|
/>,
|
281
296
|
document.body
|
282
297
|
)}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
.ff-select-dropdown-wrapper
|
1
|
+
.ff-select-dropdown-wrapper,
|
2
|
+
.ff-select-dropdown-mini-modal-wrapper {
|
2
3
|
max-height: 160px;
|
3
4
|
z-index: 999999;
|
4
5
|
position: absolute;
|
@@ -59,3 +60,42 @@
|
|
59
60
|
cursor: not-allowed;
|
60
61
|
}
|
61
62
|
}
|
63
|
+
|
64
|
+
.ff-select-dropdown-modal-wrapper {
|
65
|
+
max-height: 256px;
|
66
|
+
}
|
67
|
+
|
68
|
+
.ff-select-dropdown-mini-modal-wrapper {
|
69
|
+
display: flex;
|
70
|
+
justify-content: space-between;
|
71
|
+
|
72
|
+
.ff-select-label-minimodal-wrapper {
|
73
|
+
width: calc(50% - 4px);
|
74
|
+
}
|
75
|
+
.ff-select-mini-modal-wrapper {
|
76
|
+
width: 50%;
|
77
|
+
padding: 8px 2px 0px 4px;
|
78
|
+
display: flex;
|
79
|
+
align-items: flex-end;
|
80
|
+
margin-left: 4px;
|
81
|
+
border-left: 1px dashed var(--border-color);
|
82
|
+
|
83
|
+
.ff-select-modal-wrapper {
|
84
|
+
height: fit-content;
|
85
|
+
width: calc(100% - 4px);
|
86
|
+
border-radius: 8px;
|
87
|
+
border: 1px solid var(--ff-select-background-color);
|
88
|
+
box-shadow: 0px 1px 8px 0px var(--ff-select-option-wrapper-box-shadow);
|
89
|
+
border: 1px solid var(--border-color);
|
90
|
+
|
91
|
+
.ff-select-mini-modal-footer {
|
92
|
+
min-height: 32px;
|
93
|
+
border-top: 1px solid var(--border-color);
|
94
|
+
display: flex;
|
95
|
+
align-items: center;
|
96
|
+
justify-content: flex-end;
|
97
|
+
gap: 8px;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
@@ -6,12 +6,11 @@ import Typography from '../../Typography';
|
|
6
6
|
import { ffid } from '../../../utils/ffID/ffid';
|
7
7
|
import { ThemeContext } from '../../ThemeProvider/ThemeProvider';
|
8
8
|
import classNames from 'classnames';
|
9
|
-
import {
|
10
|
-
getLabel,
|
11
|
-
} from '../../../utils/getSelectOptionValue/getSelectOptionValue';
|
9
|
+
import { getLabel } from '../../../utils/getSelectOptionValue/getSelectOptionValue';
|
12
10
|
import useClickOutside from '../../../hooks/useClickOutside';
|
13
11
|
import Icon from '../../Icon';
|
14
12
|
import Tooltip from '../../Tooltip';
|
13
|
+
import Button from '../../Button';
|
15
14
|
|
16
15
|
const Dropdown: FC<DropdownProps> = ({
|
17
16
|
options = [],
|
@@ -27,12 +26,22 @@ const Dropdown: FC<DropdownProps> = ({
|
|
27
26
|
valueAccessor,
|
28
27
|
showIcon = false,
|
29
28
|
showToolTip = false,
|
29
|
+
customReccurenece = true,
|
30
|
+
onCancelModal = () => {},
|
31
|
+
onSaveModal = () => {},
|
32
|
+
recurrence = false,
|
33
|
+
modalJSXProps = <></>,
|
30
34
|
}) => {
|
31
35
|
const themeContext = useContext(ThemeContext);
|
32
36
|
const currentTheme = themeContext?.currentTheme;
|
33
37
|
|
38
|
+
const customRecurrenceOnBlur = customReccurenece ? () => {} : onSelectBlur;
|
39
|
+
|
34
40
|
const optionsWrapperRef = useRef<HTMLDivElement>(null);
|
35
|
-
useClickOutside(optionsWrapperRef,
|
41
|
+
useClickOutside(optionsWrapperRef, customRecurrenceOnBlur, [
|
42
|
+
inputRef,
|
43
|
+
selectArrowRef,
|
44
|
+
]);
|
36
45
|
|
37
46
|
const { positionX, positionY, fromBottom, width } = dropdownPosition;
|
38
47
|
const { margin, optionHeight, selectInputHeight, dropDownWrapperPadding } =
|
@@ -98,13 +107,30 @@ const Dropdown: FC<DropdownProps> = ({
|
|
98
107
|
);
|
99
108
|
};
|
100
109
|
|
110
|
+
const onHandleCancelModal = () => {
|
111
|
+
onSelectBlur();
|
112
|
+
onCancelModal();
|
113
|
+
};
|
114
|
+
|
115
|
+
const onHandleSaveModal = () => {
|
116
|
+
onSelectBlur();
|
117
|
+
onSaveModal();
|
118
|
+
};
|
119
|
+
|
101
120
|
return (
|
102
121
|
<div
|
103
|
-
className={classNames('ff-select-dropdown-wrapper', currentTheme
|
122
|
+
className={classNames('ff-select-dropdown-wrapper', currentTheme, {
|
123
|
+
'ff-select-dropdown-modal-wrapper': recurrence,
|
124
|
+
'ff-select-dropdown-mini-modal-wrapper': customReccurenece,
|
125
|
+
})}
|
104
126
|
ref={optionsWrapperRef}
|
105
127
|
style={updateDropdownPosition()}
|
106
128
|
>
|
107
|
-
<div
|
129
|
+
<div
|
130
|
+
className={classNames({
|
131
|
+
'ff-select-label-minimodal-wrapper': customReccurenece,
|
132
|
+
})}
|
133
|
+
>
|
108
134
|
{!checkEmpty(options) ? (
|
109
135
|
options.map((option) => (
|
110
136
|
<div
|
@@ -140,6 +166,26 @@ const Dropdown: FC<DropdownProps> = ({
|
|
140
166
|
</Typography>
|
141
167
|
)}
|
142
168
|
</div>
|
169
|
+
|
170
|
+
{customReccurenece && (
|
171
|
+
<div className="ff-select-mini-modal-wrapper" id="ff-select-mini-id">
|
172
|
+
<div className="ff-select-modal-wrapper">
|
173
|
+
{<>{modalJSXProps}</>}
|
174
|
+
<div className="ff-select-mini-modal-footer">
|
175
|
+
<Button
|
176
|
+
label="Cancel"
|
177
|
+
variant="tertiary"
|
178
|
+
onClick={onHandleCancelModal}
|
179
|
+
/>
|
180
|
+
<Button
|
181
|
+
label="Save"
|
182
|
+
variant="secondary"
|
183
|
+
onClick={onHandleSaveModal}
|
184
|
+
/>
|
185
|
+
</div>
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
)}
|
143
189
|
</div>
|
144
190
|
);
|
145
191
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { DropdownPosition, Option } from '../types';
|
2
|
-
import { RefObject } from 'react';
|
2
|
+
import { ReactNode, RefObject } from 'react';
|
3
3
|
|
4
4
|
export interface DropdownProps {
|
5
5
|
options: Option[];
|
@@ -14,7 +14,12 @@ export interface DropdownProps {
|
|
14
14
|
heightFromTop: number;
|
15
15
|
selectedOption?: Option;
|
16
16
|
showIcon?: boolean;
|
17
|
-
showToolTip?: boolean
|
17
|
+
showToolTip?: boolean;
|
18
|
+
customReccurenece?: boolean;
|
19
|
+
onCancelModal?: () => void;
|
20
|
+
onSaveModal?: () => void;
|
21
|
+
modalJSXProps?: ReactNode;
|
22
|
+
recurrence?: boolean;
|
18
23
|
}
|
19
24
|
|
20
25
|
export const dropdownDefaultCSSData = {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
|
1
3
|
export interface SelectProps {
|
2
4
|
/*
|
3
5
|
* Label for the select dropdown
|
@@ -123,6 +125,26 @@ export interface SelectProps {
|
|
123
125
|
* Provide the background color for the select label on the hover state
|
124
126
|
*/
|
125
127
|
labelBackgroundColor?: string;
|
128
|
+
|
129
|
+
/**
|
130
|
+
* To close the modal in the select dropdown
|
131
|
+
*/
|
132
|
+
onCancelModal?: () => void;
|
133
|
+
|
134
|
+
/**
|
135
|
+
* To close the modal in the select dropdown
|
136
|
+
*/
|
137
|
+
onSaveModal?: () => void;
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Pass the custom Jsx for the Modal
|
141
|
+
*/
|
142
|
+
modalJSXProps?: ReactNode;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Pass the recurrence boolean for the exeception cases
|
146
|
+
*/
|
147
|
+
recurrence?: boolean;
|
126
148
|
}
|
127
149
|
|
128
150
|
export interface DropdownPosition {
|
@@ -21,6 +21,7 @@ export const Primary: Story = {
|
|
21
21
|
label: 'ffe-Mahesh',
|
22
22
|
value: {
|
23
23
|
status: 'running',
|
24
|
+
clientId: 'test',
|
24
25
|
},
|
25
26
|
name: 'ffe-Mahesh',
|
26
27
|
});
|
@@ -33,6 +34,7 @@ export const Primary: Story = {
|
|
33
34
|
status: 'running',
|
34
35
|
},
|
35
36
|
name: 'ffe-Ganesh',
|
37
|
+
clientId: 'test',
|
36
38
|
},
|
37
39
|
{
|
38
40
|
label: 'ffe-Mahesh',
|
@@ -40,6 +42,7 @@ export const Primary: Story = {
|
|
40
42
|
status: 'running',
|
41
43
|
},
|
42
44
|
name: 'ffe-Mahesh',
|
45
|
+
clientId: 'test',
|
43
46
|
},
|
44
47
|
];
|
45
48
|
|
@@ -52,8 +55,10 @@ export const Primary: Story = {
|
|
52
55
|
return (
|
53
56
|
<>
|
54
57
|
<SequentialConnectingBranch
|
55
|
-
projectType="web"
|
56
58
|
dataSetValues={{
|
59
|
+
globalVariableSetName: 'test dev',
|
60
|
+
peVariableSetName: 'test dev',
|
61
|
+
testDataSetName: 'test dev',
|
57
62
|
peVariableSetId: 'Test dev',
|
58
63
|
globalVariableSetId: 'Test dev',
|
59
64
|
testDataSetId: 'Test dev',
|
@@ -64,7 +69,8 @@ export const Primary: Story = {
|
|
64
69
|
machineInstances={[]}
|
65
70
|
selectedMachine={machineSelect}
|
66
71
|
onHandleSelect={onMachineHandleSelect}
|
67
|
-
scriptType="Manual"
|
72
|
+
// scriptType="Manual"
|
73
|
+
readOnly={true}
|
68
74
|
/>
|
69
75
|
</>
|
70
76
|
);
|
package/src/components/SequentialConnectingBranch/components/DatasetTooltip/DataSetTooltip.tsx
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { FC } from 'react';
|
2
|
-
import Tooltip from '../../../Tooltip';
|
3
2
|
import Typography from '../../../Typography';
|
4
3
|
import { DataSetTooltipProps } from './types';
|
5
4
|
|
@@ -18,22 +17,18 @@ const DataSetTooltip: FC<DataSetTooltipProps> = ({
|
|
18
17
|
|
19
18
|
return (
|
20
19
|
<>
|
21
|
-
|
22
|
-
{
|
23
|
-
<div
|
24
|
-
<Typography
|
25
|
-
as="div"
|
26
|
-
fontSize={10}
|
27
|
-
lineHeight="15px"
|
28
|
-
>
|
20
|
+
{Object.entries(toolTipTitleValue).map(([key, value], index) => (
|
21
|
+
<div key={index} className='' >
|
22
|
+
<div className='' >
|
23
|
+
<Typography as="div" fontSize={10} lineHeight="15px">
|
29
24
|
{key}
|
30
25
|
</Typography>
|
31
26
|
<Typography as="div" lineHeight="18px">
|
32
27
|
{value}
|
33
28
|
</Typography>
|
34
29
|
</div>
|
35
|
-
|
36
|
-
|
30
|
+
</div>
|
31
|
+
))}
|
37
32
|
</>
|
38
33
|
);
|
39
34
|
};
|
@@ -18,6 +18,7 @@ import {
|
|
18
18
|
verticalListSortingStrategy,
|
19
19
|
} from '@dnd-kit/sortable';
|
20
20
|
import { CSS } from '@dnd-kit/utilities';
|
21
|
+
import { useEffect, useRef } from 'react';
|
21
22
|
|
22
23
|
const SortableRow = ({
|
23
24
|
row,
|
@@ -115,7 +116,49 @@ const Table = ({
|
|
115
116
|
headerIconOnClick = () => {},
|
116
117
|
draggable = false,
|
117
118
|
onDragEnd,
|
119
|
+
loadMore = () => {},
|
118
120
|
}: TableProps) => {
|
121
|
+
|
122
|
+
const observerRef = useRef<IntersectionObserver | null>(null);
|
123
|
+
|
124
|
+
useEffect(() => {
|
125
|
+
const scrollContainer = document.getElementById(
|
126
|
+
'ff-table-scroll-container'
|
127
|
+
);
|
128
|
+
const firstNode = document.getElementById('ff-table-first-node');
|
129
|
+
const lastNode = document.getElementById('ff-table-last-node');
|
130
|
+
|
131
|
+
// Exit early if data is empty or elements are missing
|
132
|
+
if (!scrollContainer || !firstNode || !lastNode || !data?.length) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
observerRef.current = new IntersectionObserver(
|
137
|
+
(entries) => {
|
138
|
+
entries.forEach((entry) => {
|
139
|
+
if (entry.isIntersecting) {
|
140
|
+
const direction =
|
141
|
+
entry.target.id === 'ff-table-last-node' ? 'below' : 'above';
|
142
|
+
loadMore(direction);
|
143
|
+
}
|
144
|
+
});
|
145
|
+
},
|
146
|
+
{
|
147
|
+
root: scrollContainer,
|
148
|
+
rootMargin: '8px',
|
149
|
+
threshold: 0.1,
|
150
|
+
}
|
151
|
+
);
|
152
|
+
|
153
|
+
observerRef.current.observe(firstNode);
|
154
|
+
observerRef.current.observe(lastNode);
|
155
|
+
|
156
|
+
return () => {
|
157
|
+
// Cleanup observer
|
158
|
+
observerRef.current?.disconnect();
|
159
|
+
};
|
160
|
+
}, [data, loadMore]);
|
161
|
+
|
119
162
|
const handleOnclick = (column: ColumnsProps, row: DataProps) => {
|
120
163
|
let { onClick, accessor } = column;
|
121
164
|
if (onClick && isFunction(onClick)) {
|
@@ -153,6 +196,7 @@ const Table = ({
|
|
153
196
|
>
|
154
197
|
<div
|
155
198
|
style={{ height: height, position: 'relative' }}
|
199
|
+
id="ff-table-scroll-container"
|
156
200
|
className={classNames(className, {
|
157
201
|
'ff-fixed-header-table': withFixedHeader,
|
158
202
|
'border-borderRadius': borderWithRadius,
|
@@ -216,6 +260,7 @@ const Table = ({
|
|
216
260
|
</tr>
|
217
261
|
</thead>
|
218
262
|
<tbody className="ff-fixed-header-table">
|
263
|
+
<tr id="ff-table-first-node" />
|
219
264
|
{data?.length > 0 &&
|
220
265
|
data?.map((row: any) => (
|
221
266
|
<SortableRow
|
@@ -230,6 +275,8 @@ const Table = ({
|
|
230
275
|
draggable={draggable}
|
231
276
|
/>
|
232
277
|
))}
|
278
|
+
<tr id="ff-table-last-node" />
|
279
|
+
|
233
280
|
</tbody>
|
234
281
|
</table>
|
235
282
|
{data?.length <= 0 && (
|
@@ -128,5 +128,8 @@ export interface TableProps {
|
|
128
128
|
/**
|
129
129
|
* Drag and Drop indexes
|
130
130
|
*/
|
131
|
-
onDragEnd?: (startIndex: number, endIndex: number) => void | undefined
|
131
|
+
onDragEnd?: (startIndex: number, endIndex: number) => void | undefined,
|
132
|
+
|
133
|
+
loadMore?: (_direction?: string) => void;
|
134
|
+
|
132
135
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { TreeNodeProps as TreeNode } from '../../ComponentProps/TreeNodeProps';
|
2
|
+
import { checkEmpty } from '../checkEmpty/checkEmpty';
|
2
3
|
|
3
4
|
export interface TreeDetailsResult {
|
4
5
|
treeDataList: TreeNode[];
|
@@ -36,7 +37,7 @@ export const getTreeDetails = (
|
|
36
37
|
}
|
37
38
|
break;
|
38
39
|
case 'start':
|
39
|
-
if (newData
|
40
|
+
if (!checkEmpty(newData)) {
|
40
41
|
root = newData[0];
|
41
42
|
treeDataList = newData.slice(1);
|
42
43
|
} else {
|
@@ -47,7 +48,7 @@ export const getTreeDetails = (
|
|
47
48
|
throw new Error(`Invalid action: ${action}`);
|
48
49
|
}
|
49
50
|
|
50
|
-
if (treeDataList
|
51
|
+
if (checkEmpty(treeDataList) && action !== 'start') {
|
51
52
|
throw new Error('Tree data list is empty.');
|
52
53
|
}
|
53
54
|
|
@@ -56,10 +57,10 @@ export const getTreeDetails = (
|
|
56
57
|
|
57
58
|
return {
|
58
59
|
treeDataList,
|
59
|
-
next: !lastNode
|
60
|
-
previous: !firstNode
|
61
|
-
startId: firstNode
|
62
|
-
endId: lastNode
|
60
|
+
next: !lastNode?.lastResource,
|
61
|
+
previous: !firstNode?.lastResource,
|
62
|
+
startId: firstNode?.key,
|
63
|
+
endId: lastNode?.key,
|
63
64
|
root,
|
64
65
|
};
|
65
66
|
};
|