@@ -76,6 +76,21 @@ export class AccordionPanel {
7676 this . _deferredContentAware . contentVisible . set ( ! this . _pattern . hidden ( ) ) ;
7777 } ) ;
7878 }
79+
80+ /** Opens this item. */
81+ open ( itemValue : string ) {
82+ this . accordionTrigger ( ) ?. expansionControl . open ( ) ;
83+ }
84+
85+ /** Closes this item. */
86+ close ( itemValue : string ) {
87+ this . accordionTrigger ( ) ?. expansionControl . close ( ) ;
88+ }
89+
90+ /** Toggles the expansion state of this item. */
91+ toggle ( itemValue : string ) {
92+ this . accordionTrigger ( ) ?. expansionControl . toggle ( ) ;
93+ }
7994}
8095
8196/**
@@ -135,6 +150,21 @@ export class AccordionTrigger {
135150 accordionGroup : computed ( ( ) => this . _accordionGroup . _pattern ) ,
136151 accordionPanel : this . accordionPanel ,
137152 } ) ;
153+
154+ /** Opens this item. */
155+ open ( itemValue : string ) {
156+ this . _pattern . expansionControl . open ( ) ;
157+ }
158+
159+ /** Closes this item. */
160+ close ( itemValue : string ) {
161+ this . _pattern . expansionControl . close ( ) ;
162+ }
163+
164+ /** Toggles the expansion state of this item. */
165+ toggle ( itemValue : string ) {
166+ this . _pattern . expansionControl . toggle ( ) ;
167+ }
138168}
139169
140170/**
@@ -204,6 +234,69 @@ export class AccordionGroup {
204234 }
205235 } ) ;
206236 }
237+
238+ /** Navigates to the first accordion panel. */
239+ first ( ) {
240+ this . _pattern . navigation . first ( ) ;
241+ }
242+
243+ /** Navigates to the last accordion panel. */
244+ last ( ) {
245+ this . _pattern . navigation . last ( ) ;
246+ }
247+
248+ /** Navigates to the previous accordion panel. */
249+ prev ( ) {
250+ this . _pattern . navigation . prev ( ) ;
251+ }
252+
253+ /** Navigates to the next accordion panel. */
254+ next ( ) {
255+ this . _pattern . navigation . next ( ) ;
256+ }
257+
258+ /** Opens the accordion panel with the specified value. */
259+ open ( itemValue : string ) {
260+ const trigger = this . _findTriggerPatternByValue ( itemValue ) ;
261+
262+ if ( trigger ) {
263+ this . _pattern . expansionManager . open ( trigger ) ;
264+ }
265+ }
266+
267+ /** Closes the accordion panel with the specified value. */
268+ close ( itemValue : string ) {
269+ const trigger = this . _findTriggerPatternByValue ( itemValue ) ;
270+
271+ if ( trigger ) {
272+ this . _pattern . expansionManager . close ( trigger ) ;
273+ }
274+ }
275+
276+ /** Toggles the expansion state of the accordion panel with the specified value. */
277+ toggle ( itemValue : string ) {
278+ const trigger = this . _findTriggerPatternByValue ( itemValue ) ;
279+
280+ if ( trigger ) {
281+ this . _pattern . expansionManager . toggle ( trigger ) ;
282+ }
283+ }
284+
285+ /** Opens all accordion panels if multi-expandable. */
286+ openAll ( ) {
287+ this . _pattern . expansionManager . openAll ( ) ;
288+ }
289+
290+ /** Closes all accordion panels. */
291+ closeAll ( ) {
292+ this . _pattern . expansionManager . closeAll ( ) ;
293+ }
294+
295+ _findTriggerPatternByValue ( value : string ) {
296+ const trigger = this . _triggers ( ) . find ( t => t . value ( ) === value ) ;
297+
298+ return trigger ?. _pattern ;
299+ }
207300}
208301
209302/**
0 commit comments