@fluid-topics/ft-filter 2.2.37 → 2.2.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ export interface FtFilterMessages extends I18nMessages {
3
3
  filterInputPlaceHolder(label: string): string;
4
4
  clearFilterButton(): string;
5
5
  displayMoreFilterValuesButton(): string;
6
+ displayLessFilterValuesButton(): string;
6
7
  noFilterValuesAvailable(): string;
7
8
  }
8
9
  export declare const ftFilterContext: I18nMessageContext<FtFilterMessages>;
@@ -9,6 +9,11 @@ export declare const analyticsActions: {
9
9
  defaultEventName: string;
10
10
  defaultComponentId: string;
11
11
  };
12
+ "less-filters-button-pressed": {
13
+ label: string;
14
+ defaultEventName: string;
15
+ defaultComponentId: string;
16
+ };
12
17
  };
13
18
  declare const FtFilterLevel_base: import("@fluid-topics/ft-wc-utils").withAnalyticsType<typeof FtLitElement & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtLitElementWithAriaNotificationInterface> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>, {
14
19
  "more-filters-button-pressed": {
@@ -16,6 +21,11 @@ declare const FtFilterLevel_base: import("@fluid-topics/ft-wc-utils").withAnalyt
16
21
  defaultEventName: string;
17
22
  defaultComponentId: string;
18
23
  };
24
+ "less-filters-button-pressed": {
25
+ label: string;
26
+ defaultEventName: string;
27
+ defaultComponentId: string;
28
+ };
19
29
  }>;
20
30
  export declare class FtFilterLevel extends FtFilterLevel_base {
21
31
  static elementDefinitions: ElementDefinitionsMap;
@@ -30,7 +40,7 @@ export declare class FtFilterLevel extends FtFilterLevel_base {
30
40
  preventNavigation: boolean;
31
41
  filter: string;
32
42
  filteredOptionsNumberAriaNotification?: I18nAttributeValue;
33
- displayedValuesLimit: number;
43
+ displayedValuesMinimum: number;
34
44
  protected container?: HTMLDivElement;
35
45
  protected radios?: FtRadio[];
36
46
  protected displayedPages: number;
@@ -48,6 +58,7 @@ export declare class FtFilterLevel extends FtFilterLevel_base {
48
58
  private goBackOnKeyPress;
49
59
  private goBackOnClick;
50
60
  private displayMore;
61
+ private displayLess;
51
62
  private buildMultiValuedOption;
52
63
  private buildMonoValuedOption;
53
64
  private onRadioKeyDown;
@@ -23,6 +23,11 @@ export const analyticsActions = {
23
23
  defaultEventName: "filters-click_see_more",
24
24
  defaultComponentId: "ft-filter-level",
25
25
  },
26
+ "less-filters-button-pressed": {
27
+ label: "Revealing less filters",
28
+ defaultEventName: "filters-click_see_less",
29
+ defaultComponentId: "ft-filter-level",
30
+ },
26
31
  };
27
32
  export class FtFilterLevel extends withAnalytics(withI18n(withAriaNotification(FtLitElement)), analyticsActions) {
28
33
  constructor() {
@@ -35,7 +40,7 @@ export class FtFilterLevel extends withAnalytics(withI18n(withAriaNotification(F
35
40
  this.displayCount = false;
36
41
  this.preventNavigation = false;
37
42
  this.filter = "";
38
- this.displayedValuesLimit = 0;
43
+ this.displayedValuesMinimum = 0;
39
44
  this.displayedPages = 1;
40
45
  this.filteredOptions = [];
41
46
  this.ariaNotificationDebouncer = new Debouncer(500);
@@ -45,7 +50,7 @@ export class FtFilterLevel extends withAnalytics(withI18n(withAriaNotification(F
45
50
  return limit != null && limit < this.options.length;
46
51
  }
47
52
  get limit() {
48
- return this.displayedValuesLimit > 0 ? this.displayedPages * this.displayedValuesLimit : undefined;
53
+ return this.displayedValuesMinimum > 0 ? this.displayedPages * this.displayedValuesMinimum : undefined;
49
54
  }
50
55
  get height() {
51
56
  var _a;
@@ -86,6 +91,8 @@ export class FtFilterLevel extends withAnalytics(withI18n(withAriaNotification(F
86
91
  }
87
92
  render() {
88
93
  const limitedOptions = this.filteredOptions.slice(0, this.limit);
94
+ const displayMoreButton = limitedOptions.length < this.filteredOptions.length;
95
+ const displayLessButton = this.displayedValuesMinimum > 0 && limitedOptions.length > this.displayedValuesMinimum;
89
96
  return html `
90
97
  <div class="ft-filter-level--container ${this.disabled ? "ft-filter--disabled" : ""}">
91
98
  ${this.parent == null ? null : html `
@@ -125,18 +132,35 @@ export class FtFilterLevel extends withAnalytics(withI18n(withAriaNotification(F
125
132
  `}
126
133
  </div>
127
134
  `; })}
128
- ${limitedOptions.length < this.filteredOptions.length ? html `
129
- <ft-button
130
- class="ft-filter-level--display-more"
131
- icon="thin_arrow"
132
- dense trailingIcon
133
- part="controls display-more"
134
- @click=${() => {
135
+ ${displayMoreButton || displayLessButton ? html `
136
+ <div class="ft-filter-level--display-buttons" part="controls-container">
137
+ ${displayLessButton ? html `
138
+ <ft-button
139
+ class="ft-filter-level--display-less"
140
+ icon="thin_arrow_up"
141
+ dense trailingIcon
142
+ part="controls display-less"
143
+ @click=${() => {
144
+ this.emitAnalyticsAction("less-filters-button-pressed", {});
145
+ this.displayLess();
146
+ }}>
147
+ ${ftFilterContext.messages.displayLessFilterValuesButton()}
148
+ </ft-button>
149
+ ` : nothing}
150
+ ${displayMoreButton ? html `
151
+ <ft-button
152
+ class="ft-filter-level--display-more"
153
+ icon="thin_arrow"
154
+ dense trailingIcon
155
+ part="controls display-more"
156
+ @click=${() => {
135
157
  this.emitAnalyticsAction("more-filters-button-pressed", {});
136
158
  this.displayMore();
137
159
  }}>
138
- ${ftFilterContext.messages.displayMoreFilterValuesButton()}
139
- </ft-button>
160
+ ${ftFilterContext.messages.displayMoreFilterValuesButton()}
161
+ </ft-button>
162
+ ` : nothing}
163
+ </div>
140
164
  ` : nothing}
141
165
  </div>
142
166
  `;
@@ -161,6 +185,13 @@ export class FtFilterLevel extends withAnalytics(withI18n(withAriaNotification(F
161
185
  selector: `.ft-filter-level--option:nth-child(${previousLimit + (hasGoBackButton ? 2 : 1)}) [part~="option"]`,
162
186
  };
163
187
  }
188
+ displayLess() {
189
+ this.displayedPages = 1;
190
+ // The "Less" button disappears once collapsed, keep the focus on the "More" button
191
+ this.elementToFocus = {
192
+ selector: `.ft-filter-level--display-more`,
193
+ };
194
+ }
164
195
  buildMultiValuedOption(option) {
165
196
  var _a;
166
197
  return html `
@@ -262,7 +293,7 @@ __decorate([
262
293
  ], FtFilterLevel.prototype, "filteredOptionsNumberAriaNotification", void 0);
263
294
  __decorate([
264
295
  numberProperty()
265
- ], FtFilterLevel.prototype, "displayedValuesLimit", void 0);
296
+ ], FtFilterLevel.prototype, "displayedValuesMinimum", void 0);
266
297
  __decorate([
267
298
  query(".ft-filter-level--container")
268
299
  ], FtFilterLevel.prototype, "container", void 0);
@@ -73,7 +73,15 @@ export const levelStyles = css `
73
73
  ${setVariable(FtButtonCssVariables.color, FtFilterLevelCssVariables.colorOnSurface)};
74
74
  }
75
75
 
76
- ft-button.ft-filter-level--display-more {
76
+ .ft-filter-level--display-buttons {
77
+ display: flex;
78
+ gap: 4px;
79
+ }
80
+
81
+ ft-button.ft-filter-level--display-more,
82
+ ft-button.ft-filter-level--display-less {
83
+ flex: 1 1 0;
84
+ min-width: 0;
77
85
  ${setVariable(FtButtonCssVariables.color, FtFilterLevelCssVariables.buttonMoreColor)};
78
86
  }
79
87
 
@@ -12,6 +12,11 @@ declare const FtFilter_base: import("@fluid-topics/ft-wc-utils").withAnalyticsTy
12
12
  defaultEventName: string;
13
13
  defaultComponentId: string;
14
14
  };
15
+ "less-filters-button-pressed": {
16
+ label: string;
17
+ defaultEventName: string;
18
+ defaultComponentId: string;
19
+ };
15
20
  }>;
16
21
  export declare class FtFilter extends FtFilter_base implements FtFilterProperties {
17
22
  static elementDefinitions: ElementDefinitionsMap;
@@ -23,7 +28,7 @@ export declare class FtFilter extends FtFilter_base implements FtFilterPropertie
23
28
  disabled: boolean;
24
29
  raiseSelectedOptions: boolean;
25
30
  displayCount: boolean;
26
- displayedValuesLimit: number;
31
+ displayedValuesMinimum: number;
27
32
  filteredOptionsNumberAriaNotification?: I18nAttributeValue;
28
33
  hideClearButton: boolean;
29
34
  private slotElement;
@@ -28,7 +28,7 @@ export class FtFilter extends withAnalytics(FtLitElement, analyticsActions) {
28
28
  this.disabled = false;
29
29
  this.raiseSelectedOptions = false;
30
30
  this.displayCount = false;
31
- this.displayedValuesLimit = 0;
31
+ this.displayedValuesMinimum = 0;
32
32
  this.hideClearButton = false;
33
33
  this.lastLevelHasHiddenvalues = false;
34
34
  this.withScroll = false;
@@ -193,7 +193,7 @@ export class FtFilter extends withAnalytics(FtLitElement, analyticsActions) {
193
193
  ?displayCount=${this.displayCount}
194
194
  .parent=${parent}
195
195
  .options=${options}
196
- .displayedValuesLimit=${this.displayedValuesLimit}
196
+ .displayedValuesMinimum=${this.displayedValuesMinimum}
197
197
  @change=${this.onChange}
198
198
  @go-back=${this.goBack}
199
199
  @display-level=${this.onDisplayLevel}
@@ -320,7 +320,7 @@ __decorate([
320
320
  ], FtFilter.prototype, "displayCount", void 0);
321
321
  __decorate([
322
322
  numberProperty()
323
- ], FtFilter.prototype, "displayedValuesLimit", void 0);
323
+ ], FtFilter.prototype, "displayedValuesMinimum", void 0);
324
324
  __decorate([
325
325
  jsonProperty(undefined)
326
326
  ], FtFilter.prototype, "filteredOptionsNumberAriaNotification", void 0);