@@ -14,17 +14,11 @@ import {
14
14
connectConditionalSlotComponent ,
15
15
disconnectConditionalSlotComponent
16
16
} from "../../utils/conditionalSlot" ;
17
- import {
18
- closestElementCrossShadowBoundary ,
19
- getElementDir ,
20
- getElementProp ,
21
- getSlotted ,
22
- toAriaBoolean
23
- } from "../../utils/dom" ;
17
+ import { getElementDir , getSlotted , toAriaBoolean } from "../../utils/dom" ;
24
18
import { CSS_UTILITY } from "../../utils/resources" ;
25
19
import { SLOTS , CSS } from "./resources" ;
26
- import { FlipContext , Position , Scale } from "../interfaces" ;
27
- import { RegistryEntry , RequestedItem } from "./interfaces" ;
20
+ import { FlipContext , Position , Scale , SelectionMode } from "../interfaces" ;
21
+ import { RequestedItem } from "./interfaces" ;
28
22
29
23
/**
30
24
* @slot - A slot for adding custom content, including nested `calcite-accordion-item`s.
@@ -69,6 +63,40 @@ export class AccordionItem implements ConditionalSlotComponent {
69
63
/** Displays the `iconStart` and/or `iconEnd` as flipped when the element direction is right-to-left (`"rtl"`). */
70
64
@Prop ( { reflect : true } ) iconFlipRtl : FlipContext ;
71
65
66
+ /**
67
+ * Specifies the placement of the icon in the header inherited from the `calcite-accordion`.
68
+ *
69
+ * @internal
70
+ */
71
+ @Prop ( ) iconPosition : Position ;
72
+
73
+ /** Specifies the type of the icon in the header inherited from the `calcite-accordion`.
74
+ *
75
+ * @internal
76
+ */
77
+ @Prop ( ) iconType : "chevron" | "caret" | "plus-minus" ;
78
+
79
+ /**
80
+ * The containing `accordion` element.
81
+ *
82
+ * @internal
83
+ */
84
+ @Prop ( ) accordionParent : HTMLCalciteAccordionElement ;
85
+
86
+ /**
87
+ * Specifies the `selectionMode` of the component inherited from the `calcite-accordion`.
88
+ *
89
+ * @internal
90
+ */
91
+ @Prop ( ) selectionMode : Extract < "single" | "single-persist" | "multiple" , SelectionMode > ;
92
+
93
+ /**
94
+ * Specifies the size of the component inherited from the `calcite-accordion`.
95
+ *
96
+ * @internal
97
+ */
98
+ @Prop ( ) scale : Scale ;
99
+
72
100
//--------------------------------------------------------------------------
73
101
//
74
102
// Events
@@ -85,34 +113,16 @@ export class AccordionItem implements ConditionalSlotComponent {
85
113
*/
86
114
@Event ( { cancelable : false } ) calciteInternalAccordionItemClose : EventEmitter < void > ;
87
115
88
- /**
89
- * @internal
90
- */
91
- @Event ( { cancelable : false } ) calciteInternalAccordionItemRegister : EventEmitter < RegistryEntry > ;
92
-
93
116
//--------------------------------------------------------------------------
94
117
//
95
118
// Lifecycle
96
119
//
97
120
//--------------------------------------------------------------------------
98
121
99
122
connectedCallback ( ) : void {
100
- this . parent = this . el . parentElement as HTMLCalciteAccordionElement ;
101
- this . iconType = getElementProp ( this . el , "icon-type" , "chevron" ) ;
102
- this . iconPosition = getElementProp ( this . el , "icon-position" , this . iconPosition ) ;
103
- this . scale = getElementProp ( this . el , "scale" , this . scale ) ;
104
-
105
123
connectConditionalSlotComponent ( this ) ;
106
124
}
107
125
108
- componentDidLoad ( ) : void {
109
- this . itemPosition = this . getItemPosition ( ) ;
110
- this . calciteInternalAccordionItemRegister . emit ( {
111
- parent : this . parent ,
112
- position : this . itemPosition
113
- } ) ;
114
- }
115
-
116
126
disconnectedCallback ( ) : void {
117
127
disconnectConditionalSlotComponent ( this ) ;
118
128
}
@@ -248,38 +258,19 @@ export class AccordionItem implements ConditionalSlotComponent {
248
258
//
249
259
//--------------------------------------------------------------------------
250
260
251
- /** the containing accordion element */
252
- private parent : HTMLCalciteAccordionElement ;
253
-
254
- /** position within parent */
255
- private itemPosition : number ;
256
-
257
261
/** the latest requested item */
258
262
private requestedAccordionItem : HTMLCalciteAccordionItemElement ;
259
263
260
- /** what selection mode is the parent accordion in */
261
- private selectionMode : string ;
262
-
263
- /** what icon position does the parent accordion specify */
264
- private iconPosition : Position = "end" ;
265
-
266
- /** what icon type does the parent accordion specify */
267
- private iconType : string ;
268
-
269
264
/** handle clicks on item header */
270
265
private itemHeaderClickHandler = ( ) : void => this . emitRequestedItem ( ) ;
271
266
272
- /** Specifies the scale of the `accordion-item` controlled by the parent, defaults to m */
273
- scale : Scale = "m" ;
274
-
275
267
//--------------------------------------------------------------------------
276
268
//
277
269
// Private Methods
278
270
//
279
271
//--------------------------------------------------------------------------
280
272
281
273
private determineActiveItem ( ) : void {
282
- this . selectionMode = getElementProp ( this . el , "selection-mode" , "multiple" ) ;
283
274
switch ( this . selectionMode ) {
284
275
case "multiple" :
285
276
if ( this . el === this . requestedAccordionItem ) {
@@ -302,14 +293,4 @@ export class AccordionItem implements ConditionalSlotComponent {
302
293
requestedAccordionItem : this . el as HTMLCalciteAccordionItemElement
303
294
} ) ;
304
295
}
305
-
306
- private getItemPosition ( ) : number {
307
- const { el } = this ;
308
-
309
- const items = closestElementCrossShadowBoundary ( el , "calcite-accordion" ) ?. querySelectorAll (
310
- "calcite-accordion-item"
311
- ) ;
312
-
313
- return items ? Array . from ( items ) . indexOf ( el ) : - 1 ;
314
- }
315
296
}
0 commit comments