Skip to content

Commit e74a953

Browse files
committed
chore: Update package version to 1.0.186 and improve Accordion component
1 parent b49baee commit e74a953

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-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.185",
3+
"version": "1.0.186",
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: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export const Primary = () => {
6262
className='yl-w-[500px]'
6363
selectedId={2}
6464
sections={sections}
65-
onSorted={setSections}
65+
onSorted={(type, data) => {
66+
setSections(data);
67+
}}
6668
expanded={expandedSections}
6769
hasDraggableSections={true}
6870
hasDraggableSectionItems={true}
@@ -102,7 +104,9 @@ export const NonInteractive = () => {
102104
className='yl-w-[500px]'
103105
selectedId={2}
104106
sections={sections}
105-
onSorted={setSections}
107+
onSorted={(type, sections) => {
108+
setSections(sections);
109+
}}
106110
expanded={expandedSections}
107111
setExpanded={(expanded: number[]) => {
108112
setExpandedSections(expanded);
@@ -137,7 +141,9 @@ export const WithoutDragAndDrop = () => {
137141
className='yl-w-[500px]'
138142
selectedId={2}
139143
sections={sections}
140-
onSorted={setSections}
144+
onSorted={(type, sections) => {
145+
setSections(sections);
146+
}}
141147
expanded={expandedSections}
142148
setExpanded={(expanded: number[]) => {
143149
setExpandedSections(expanded);
@@ -204,7 +210,9 @@ export const AddSectionAndSectionItem = () => {
204210

205211
setSections([newSection]);
206212
}}
207-
onSorted={setSections}
213+
onSorted={(type, sections) => {
214+
setSections(sections);
215+
}}
208216
onAddSection={() => {
209217
action("onAddSection")();
210218
}}
@@ -246,7 +254,9 @@ export const WithAddLabels = () => {
246254
selectedId={2}
247255
sections={sections}
248256
expanded={expandedSections}
249-
onSorted={setSections}
257+
onSorted={(type, sections) => {
258+
setSections(sections);
259+
}}
250260
onAddSection={() => {
251261
action("onAddSection")();
252262
}}

src/Components/Accordion/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Paragraph } from "Components/Typography";
1313

1414
import ArrayUtils from "Utils/Array";
1515

16-
import { IAccordionProps } from "./types";
16+
import { AccordionOrderType, IAccordionProps } from "./types";
1717

1818
const Accordion: FC<IAccordionProps> = ({
1919
className,
@@ -66,8 +66,10 @@ const Accordion: FC<IAccordionProps> = ({
6666

6767
const handleSectionDrop = (e: React.DragEvent<Element>) => {
6868
e.preventDefault();
69+
e.stopPropagation();
6970
if (draggedId != null && draggedOverId != null) {
7071
onSorted(
72+
AccordionOrderType.SECTIONS,
7173
ArrayUtils.reorder(
7274
sections,
7375
sections.findIndex(item => item.id === draggedId),
@@ -182,6 +184,7 @@ const Accordion: FC<IAccordionProps> = ({
182184
}}
183185
onDragged={(items: IDraggableListItem[]) => {
184186
onSorted(
187+
AccordionOrderType.LECTURES,
185188
[
186189
...sections.map(s =>
187190
s.id === section.id ? { ...s, items } : s

src/Components/Accordion/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface IAccordionProps {
2424
sections: ISection[];
2525
sectionTitleClassName?: string;
2626
onSorted: (
27+
type: AccordionOrderType,
2728
sections: ISection[],
2829
section: { sectionId: number; items: IDraggableListItem[] }
2930
) => void;

src/Components/DraggableList/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const DraggableList: FC<IDraggableList> = ({
3333

3434
const handleDrop = (e: DragEvent<Element>) => {
3535
e.preventDefault();
36+
e.stopPropagation();
3637

3738
if (draggedId != null && draggedOverId != null) {
3839
const draggedIndex = items.findIndex(item => item.id === draggedId);

0 commit comments

Comments
 (0)