@@ -3,8 +3,6 @@ import { action } from "@storybook/addon-actions";
33import { Meta } from "@storybook/react" ;
44import { useEffect , useState } from "react" ;
55
6- import Button from "Components/Button" ;
7-
86import Accordion from "." ;
97import { ISection } from "./types" ;
108
@@ -239,96 +237,6 @@ export const WithoutDragAndDrop = () => {
239237 ) ;
240238} ;
241239
242- export const AddSectionAndSectionItem = ( ) => {
243- const [ sections , setSections ] = useState < ISection [ ] > ( [
244- {
245- id : 1 ,
246- title : "velum constans brevis canis corrumpo magni attollo" ,
247- description :
248- "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." ,
249- order : 0 ,
250- items : [
251- {
252- id : 597358 ,
253- title : "officia" ,
254- order : 0
255- }
256- ]
257- }
258- ] ) ;
259-
260- const [ expandedSections , setExpandedSections ] = useState < number [ ] > ( [ 1 ] ) ;
261- const [ selectedSection , setSelectedSection ] = useState < number | null > ( null ) ;
262- const [ selectedItem , setSelectedItem ] = useState < number | null > ( null ) ;
263-
264- if ( ! sections . length ) {
265- return < div > Loading...</ div > ;
266- }
267-
268- return (
269- < div >
270- < Button
271- onClick = { ( ) => {
272- const newSection = sections [ 0 ] ;
273- if ( newSection ) {
274- newSection . items . push ( {
275- id : Math . floor ( Math . random ( ) * 1000000 ) ,
276- title : faker . lorem . words ( Math . floor ( Math . random ( ) * 10 ) + 1 ) ,
277- order : newSection . items . length
278- } ) ;
279- }
280-
281- setSections ( [ newSection as ISection ] ) ;
282- } }
283- >
284- Add Section
285- </ Button >
286- < Accordion
287- className = 'yl:w-[500px]'
288- selected = { {
289- sectionId : selectedSection ?? 0 ,
290- itemId : selectedItem ?? 0
291- } }
292- setSelectedSection = { sectionId => {
293- setSelectedSection ( sectionId ) ;
294- } }
295- setSelectedItem = { itemId => {
296- setSelectedItem ( itemId ) ;
297- } }
298- sections = { sections }
299- expanded = { expandedSections }
300- hasDraggableSectionItems = { true }
301- onSectionItemClick = { sectionItem => {
302- const newSection = sections [ 0 ] ;
303- if ( newSection ) {
304- newSection . items = newSection . items . filter (
305- item => item . id !== sectionItem . id
306- ) ;
307- }
308-
309- setSections ( [ newSection as ISection ] ) ;
310- } }
311- onSorted = { ( _ , sections ) => {
312- setSections ( sections ) ;
313- } }
314- onAddSection = { ( ) => {
315- action ( "onAddSection" ) ( ) ;
316- } }
317- onAddSectionItem = { section => {
318- action ( "onAddSectionItem" ) ( section ) ;
319- } }
320- setExpanded = { ( expanded : number [ ] ) => {
321- setExpandedSections ( expanded ) ;
322- action ( "setExpanded" ) ( expanded ) ;
323- } }
324- onSelected = { item => {
325- action ( "onSelected" ) ( item ) ;
326- } }
327- />
328- </ div >
329- ) ;
330- } ;
331-
332240export const WithAddLabels = ( ) => {
333241 const [ sections , setSections ] = useState < ISection [ ] > ( [ ] ) ;
334242 const [ expandedSections , setExpandedSections ] = useState < number [ ] > ( [ 1 ] ) ;
@@ -440,7 +348,7 @@ export const WithNoItems = () => {
440348 ) ;
441349} ;
442350
443- export const DefaultExpanded = ( ) => {
351+ export const ExpandedByDefault = ( ) => {
444352 const [ sections , setSections ] = useState < ISection [ ] > ( [ ] ) ;
445353 const [ expandedSections , setExpandedSections ] = useState < number [ ] > ( [ ] ) ;
446354 const [ selectedSection , setSelectedSection ] = useState < number | null > ( null ) ;
@@ -461,6 +369,7 @@ export const DefaultExpanded = () => {
461369 return (
462370 < div >
463371 < Accordion
372+ defaultExpanded = { true }
464373 className = 'yl:w-[500px]'
465374 selected = { {
466375 sectionId : selectedSection ?? 0 ,
0 commit comments