@@ -22,6 +22,15 @@ export class PfLabelGroupExpandEvent extends Event {
2222 }
2323}
2424
25+ /**
26+ * Event fired when the label group is removed/closed.
27+ */
28+ export class PfLabelGroupRemoveEvent extends Event {
29+ constructor ( ) {
30+ super ( 'remove' , { bubbles : true , cancelable : true , composed : true } ) ;
31+ }
32+ }
33+
2534/**
2635 * A **label group** is a collection of labels that can be grouped by category
2736 * and used to represent one or more values assigned to a single attribute.
@@ -52,26 +61,25 @@ export class PfLabelGroup extends LitElement {
5261 } ;
5362
5463 /**
55- * Orientation of the label group.
56- */
64+ * Orientation of the label group.
65+ */
5766 @property ( ) orientation : 'horizontal' | 'vertical' = 'horizontal' ;
5867
5968 /**
6069 * Accessible label for the label group when no category name is provided.
6170 * @default ''
6271 */
6372 @property ( { attribute : 'accessible-label' , type : String } ) accessibleLabel = '' ;
64-
6573 /**
66- * Accessible label for the close button.
67- * @default 'Close'
68- */
74+ * Accessible label for the close button.
75+ * @default 'Close'
76+ */
6977 @property ( { attribute : 'accessible-close-label' , type : String } ) accessibleCloseLabel = 'Close' ;
7078
7179 /**
72- * Text for collapsed overflow label. Use `${remaining}` to indicate number of hidden labels.
73- * @default '${remaining} more'
74- */
80+ * Text for collapsed overflow label. Use `${remaining}` to indicate number of hidden labels.
81+ * @default '${remaining} more'
82+ */
7583 @property ( { attribute : 'collapsed-text' , type : String } ) collapsedText = '${remaining} more' ;
7684
7785 /**
@@ -81,53 +89,53 @@ export class PfLabelGroup extends LitElement {
8189 @property ( { attribute : 'expanded-text' , type : String } ) expandedText = 'show less' ;
8290
8391 /**
84- * Number of labels to show before creating an overflow label.
85- * @default 3
86- */
92+ * Number of labels to show before creating an overflow label.
93+ * @default 3
94+ */
8795 @property ( { attribute : 'num-labels' , type : Number } ) numLabels = 3 ;
8896
8997 /**
90- * Whether the overflow labels are visible (expanded state).
91- * @default false
92- */
98+ * Whether the overflow labels are visible (expanded state).
99+ * @default false
100+ */
93101 @property ( { reflect : true , type : Boolean } ) open = false ;
94102
95103 /**
96- * Whether the label group can be closed.
97- * @default true
98- */
104+ * Whether the label group can be closed.
105+ * @default true
106+ */
99107 @property ( { reflect : true , type : Boolean } ) closeable = false ;
100108
101109 /** --- ADD LABEL FUNCTIONALITY --- */
102110
103111 /**
104- * Mode controlling how labels can be added.
105- * - `none`: No add label functionality
106- * - `autoNoEdit`: Adds a default label automatically
107- * - `fromList`: Allows choosing a label from a predefined list
108- * - `customForm`: Opens a form for custom label creation
109- */
112+ * Mode controlling how labels can be added.
113+ * - `none`: No add label functionality
114+ * - `autoNoEdit`: Adds a default label automatically
115+ * - `fromList`: Allows choosing a label from a predefined list
116+ * - `customForm`: Opens a form for custom label creation
117+ */
110118 @property ( { type : String , reflect : true , attribute : 'add-label-mode' } )
111119 addLabelMode : 'none' | 'autoNoEdit' | 'fromList' | 'customForm' = 'none' ;
112120
113121 /**
114- * Controls visibility of the label dropdown for `fromList` mode.
115- */
122+ * Controls visibility of the label dropdown for `fromList` mode.
123+ */
116124 @state ( ) showDropdown = false ;
117125
118126 /**
119- * Controls visibility of the custom label form for `customForm` mode.
120- */
127+ * Controls visibility of the custom label form for `customForm` mode.
128+ */
121129 @state ( ) showCustomForm = false ;
122130
123131 /**
124- * Text value for a new custom label.
125- */
132+ * Text value for a new custom label.
133+ */
126134 @state ( ) newLabelText = 'Text box' ;
127135
128136 /**
129- * Color value for a new custom label.
130- */
137+ * Color value for a new custom label.
138+ */
131139 @state ( ) newLabelColor = 'grey' ;
132140
133141 /**
@@ -356,8 +364,8 @@ export class PfLabelGroup extends LitElement {
356364 }
357365
358366 /**
359- * Handles overflow label's click event.
360- * @param {Event } event - Click event
367+ * Handles overflow label's click event.
368+ * @param {Event } event - Click event
361369 */
362370 async #onMoreClick( event : Event ) {
363371 event . stopPropagation ( ) ;
@@ -376,6 +384,7 @@ export class PfLabelGroup extends LitElement {
376384 */
377385 #onCloseClick( ) {
378386 if ( this . isConnected ) {
387+ this . dispatchEvent ( new PfLabelGroupRemoveEvent ( ) ) ;
379388 this . remove ( ) ;
380389 }
381390 }
0 commit comments