Skip to content

Commit b49baee

Browse files
committed
chore: Update package version to 1.0.185 and improve Accordion component
1 parent 8907ff9 commit b49baee

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.0.184",
3+
"version": "1.0.185",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {

src/Components/Accordion/Accordion.stories.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export const WithoutDragAndDrop = () => {
153153
export const AddSectionAndSectionItem = () => {
154154
const [sections, setSections] = useState<ISection[]>([
155155
{
156-
id: 236163,
156+
id: 1,
157157
title: "velum constans brevis canis corrumpo magni attollo",
158158
description:
159159
"Creber aeneus versus itaque alioqui abeo crux sperno. Atrox subseco ater tenetur libero absum quidem thymum degusto allatus. Venia in carbo cibus desolo contego suffragium. Vero civitas tredecim ventosus dapifer quas. Animadverto spiculum velut.",
@@ -195,6 +195,15 @@ export const AddSectionAndSectionItem = () => {
195195
selectedId={2}
196196
sections={sections}
197197
expanded={expandedSections}
198+
hasDraggableSectionItems={true}
199+
onSectionItemClick={sectionItem => {
200+
const newSection = sections[0];
201+
newSection.items = newSection.items.filter(
202+
item => item.id !== sectionItem.id
203+
);
204+
205+
setSections([newSection]);
206+
}}
198207
onSorted={setSections}
199208
onAddSection={() => {
200209
action("onAddSection")();

src/Components/DraggableList/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ const DraggableList: FC<IDraggableList> = ({
4040
item => item.id === draggedOverId
4141
);
4242

43-
setLocalItems(ArrayUtils.reorder(items, draggedIndex, draggedOverIndex));
43+
const withNewOrder = ArrayUtils.reorder(
44+
items,
45+
draggedIndex,
46+
draggedOverIndex
47+
);
48+
49+
setLocalItems(withNewOrder);
50+
onDragged?.(withNewOrder);
4451
}
4552

4653
setDraggedId(null);
@@ -51,10 +58,6 @@ const DraggableList: FC<IDraggableList> = ({
5158
setLocalItems(items || []);
5259
}, [items]);
5360

54-
useEffect(() => {
55-
onDragged?.(localItems);
56-
}, [localItems]);
57-
5861
return (
5962
<ul
6063
className={classNames(

0 commit comments

Comments
 (0)